fix(core): Refactor filesystem usage to smartfs async provider, update dependencies, tests and nginx config paths
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartnginx',
|
||||
version: '2.0.52',
|
||||
description: 'control nginx from node, TypeScript ready'
|
||||
version: '2.0.53',
|
||||
description: 'A TypeScript library for controlling Nginx from Node.js, with support for generating and managing Nginx configurations dynamically.'
|
||||
}
|
||||
|
||||
@@ -53,10 +53,10 @@ export class NginxHost implements IHostConfig {
|
||||
this.destination,
|
||||
this.destinationPort
|
||||
);
|
||||
plugins.smartfile.memory.toFsSync(this.configString, filePathConfig);
|
||||
await plugins.fs.file(filePathConfig).write(this.configString);
|
||||
|
||||
// write ssl
|
||||
plugins.smartfile.memory.toFsSync(this.privateKey, filePathPrivate);
|
||||
plugins.smartfile.memory.toFsSync(this.publicKey, filePathPublic);
|
||||
await plugins.fs.file(filePathPrivate).write(this.privateKey);
|
||||
await plugins.fs.file(filePathPublic).write(this.publicKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,10 +116,9 @@ export class SmartNginx {
|
||||
this.hostCandidates.wipe();
|
||||
|
||||
// write base config
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigDirPath);
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
snippets.getBaseConfigString(this.options.defaultProxyUrl),
|
||||
paths.nginxConfFile
|
||||
await plugins.fs.directory(paths.nginxConfigDirPath).recursive().create();
|
||||
await plugins.fs.file(paths.nginxConfFile).write(
|
||||
snippets.getBaseConfigString(this.options.defaultProxyUrl)
|
||||
);
|
||||
|
||||
// write standard self signed certificate
|
||||
@@ -129,15 +128,13 @@ export class SmartNginx {
|
||||
);
|
||||
|
||||
// deploy hosts
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxHostDirPath);
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
selfsignedCert.private,
|
||||
await plugins.fs.directory(paths.nginxHostDirPath).recursive().create();
|
||||
await plugins.fs.file(
|
||||
plugins.path.join(paths.nginxHostDirPath, './default.private.pem')
|
||||
);
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
selfsignedCert.cert,
|
||||
).write(selfsignedCert.private);
|
||||
await plugins.fs.file(
|
||||
plugins.path.join(paths.nginxHostDirPath, './default.public.pem')
|
||||
);
|
||||
).write(selfsignedCert.cert);
|
||||
for (const host of this.deployedHosts.getArray()) {
|
||||
await host.deploy();
|
||||
this.logger.log('info', `Host ${host.hostName} deployed!`);
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
// native
|
||||
import * as path from 'path';
|
||||
import * as path from 'node:path';
|
||||
|
||||
export { path };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as lik from '@push.rocks/lik';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartlog from '@push.rocks/smartlog';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
import * as smartunique from '@push.rocks/smartunique';
|
||||
// @push.rocks scope
|
||||
import * as lik from '@push.rocks/lik';
|
||||
import * as smartfs from '@push.rocks/smartfs';
|
||||
import * as smartlog from '@push.rocks/smartlog';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
import * as smartunique from '@push.rocks/smartunique';
|
||||
|
||||
export { lik, smartfile, smartlog, smartpath, smartpromise, smartshell, smartstring, smartunique };
|
||||
export { lik, smartfs, smartlog, smartpath, smartpromise, smartshell, smartstring, smartunique };
|
||||
|
||||
// Shared filesystem instance
|
||||
const fsProvider = new smartfs.SmartFsProviderNode();
|
||||
export const fs = new smartfs.SmartFs(fsProvider);
|
||||
|
||||
// thirdparty scope
|
||||
import * as selfsigned from 'selfsigned';
|
||||
|
||||
Reference in New Issue
Block a user