BREAKING CHANGE(scope): change scope to @pushrocks

This commit is contained in:
2018-08-10 23:10:48 +02:00
parent 381227406b
commit 9b043d0e0d
17 changed files with 1368 additions and 345 deletions

View File

@ -0,0 +1,74 @@
import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths';
import * as snippets from './smartnginx.snippets';
import { NginxHost } from './smartnginx.classes.nginxhost';
import { NginxProcess } from './smartnginx.classes.nginxprocess';
import { CertHandler } from './smartnginx.classes.certhandler';
let allConfigs: SmartNginx[] = [];
/**
* main class that manages a NginxInstance
*/
export class SmartNginx {
certHandler = new CertHandler();
hosts: NginxHost[] = [];
nginxProcess: NginxProcess = new NginxProcess(this);
isDeployed: boolean = false;
constructor() {
};
// ===================
// interact with Hosts
// ===================
/**
* add a host
* @param nginxHostArg
*/
addHost(nginxHostArg: NginxHost) {
this.hosts.push(nginxHostArg);
}
/**
* listHosts
*/
listHosts(): NginxHost[] {
return this.hosts;
}
/**
* remove a Host
* @param nginxHostArg
*/
removeHost(nginxHostArg: NginxHost) {}
/**
* clean all hosts
*/
clean() {
this.hosts = [];
}
/**
* deploy the current stack and restart nginx
*/
async deploy() {
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
plugins.smartfile.fs.ensureDirSync(paths.nginxHostFileBase);
plugins.smartfile.fs.ensureDirSync(paths.nginxCertBase);
for (let config of allConfigs) {
config.isDeployed = false;
}
this.isDeployed = true;
// write base config
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), paths.nginxConfFile);
// deploy hosts
let promiseArray = [];
for (let host of this.hosts) {
await host.deploy();
plugins.smartlog.defaultLogger.info(`Host ${host.hostName} deployed!`);
this.nginxProcess.reloadConfig();
};
}
}