fix(core): update

This commit is contained in:
2023-07-26 16:05:53 +02:00
parent 1b6b2a24f1
commit 509ee83a15
25 changed files with 5181 additions and 1973 deletions

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartnginx',
version: '2.0.52',
description: 'control nginx from node, TypeScript ready'
}

View File

@ -1,6 +1,4 @@
import * as plugins from './smartnginx.plugins';
// classes
export * from './smartnginx.classes.smartnginx';
export * from './smartnginx.classes.nginxprocess';
export * from './smartnginx.classes.nginxhost';
export * from './smartnginx.classes.smartnginx.js';
export * from './smartnginx.classes.nginxprocess.js';
export * from './smartnginx.classes.nginxhost.js';

View File

@ -1,13 +1,13 @@
import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths';
import * as snippets from './smartnginx.snippets';
import * as plugins from './smartnginx.plugins.js';
import * as paths from './smartnginx.paths.js';
import * as snippets from './smartnginx.snippets.js';
import { SmartNginx } from './smartnginx.classes.smartnginx';
import { SmartNginx } from './smartnginx.classes.smartnginx.js';
import { IHostConfig } from './interfaces/hostconfig';
import { type IHostConfig } from './interfaces/hostconfig.js';
export enum hostTypes {
reverseProxy
reverseProxy,
}
/**

View File

@ -1,9 +1,7 @@
import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths';
import { SmartNginx } from './smartnginx.classes.smartnginx';
import { NginxHost } from './smartnginx.classes.nginxhost';
import { Smartshell } from '@pushrocks/smartshell';
import * as plugins from './smartnginx.plugins.js';
import * as paths from './smartnginx.paths.js';
import { SmartNginx } from './smartnginx.classes.smartnginx.js';
import { NginxHost } from './smartnginx.classes.nginxhost.js';
import { ChildProcess } from 'child_process';
@ -14,8 +12,8 @@ export class NginxProcess {
public started: boolean = false;
public smartNginxRef: SmartNginx;
private nginxChildProcess: ChildProcess;
private smartshellInstance = new Smartshell({
executor: 'bash'
private smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
});
constructor(nginxRefArg: SmartNginx) {
@ -27,12 +25,12 @@ export class NginxProcess {
*/
public async start() {
if (!this.nginxChildProcess) {
this.nginxChildProcess = (await this.smartshellInstance.execStreaming(
`nginx -c ${paths.nginxConfFile}`
)).childProcess;
this.nginxChildProcess = (
await this.smartshellInstance.execStreaming(`nginx -c ${paths.nginxConfFile}`)
).childProcess;
}
this.started = true;
plugins.smartlog.defaultLogger.log('info', 'started Nginx!');
console.log('info', 'started Nginx!');
}
/**

View File

@ -1,9 +1,9 @@
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 { IHostConfig } from './interfaces/hostconfig';
import * as plugins from './smartnginx.plugins.js';
import * as paths from './smartnginx.paths.js';
import * as snippets from './smartnginx.snippets.js';
import { NginxHost } from './smartnginx.classes.nginxhost.js';
import { NginxProcess } from './smartnginx.classes.nginxprocess.js';
import { type IHostConfig } from './interfaces/hostconfig.js';
export interface ISmartNginxContructorOptions {
logger?: plugins.smartlog.Smartlog;
@ -18,15 +18,17 @@ export class SmartNginx {
public logger: plugins.smartlog.Smartlog;
// the objectmaps
private deployedHosts = new plugins.lik.Objectmap<NginxHost>();
private hostCandidates = new plugins.lik.Objectmap<NginxHost>();
private deployedHosts = new plugins.lik.ObjectMap<NginxHost>();
private hostCandidates = new plugins.lik.ObjectMap<NginxHost>();
public nginxProcess: NginxProcess = new NginxProcess(this);
constructor(optionsArg: ISmartNginxContructorOptions) {
this.options = optionsArg;
this.options.logger
? (this.logger = this.options.logger)
: (this.logger = plugins.smartlog.defaultLogger);
: (this.logger = new plugins.smartlog.Smartlog({
logContext: null
}));
}
// ===================
@ -48,7 +50,7 @@ export class SmartNginx {
* @param hostNameArg
*/
public getDeployedNginxHostByHostName(hostNameArg: string): NginxHost {
return this.deployedHosts.find(nginxHost => {
return this.deployedHosts.findSync((nginxHost) => {
return nginxHost.hostName === hostNameArg;
});
}
@ -65,7 +67,7 @@ export class SmartNginx {
*/
public async removeDeployedHost(nginxHostArg: NginxHost) {
if (this.hostCandidates.isEmpty()) {
this.deployedHosts.forEach(hostArg => {
this.deployedHosts.forEach((hostArg) => {
this.hostCandidates.add(hostArg);
});
}
@ -80,9 +82,9 @@ export class SmartNginx {
private async areHostsDiverged(): Promise<boolean> {
let hostCounter = 0;
let unfoundHosts = 0;
await this.hostCandidates.forEach(async hostCandidateArg => {
await this.hostCandidates.forEach(async (hostCandidateArg) => {
let foundHost = false;
await this.deployedHosts.forEach(async deployedHostArg => {
await this.deployedHosts.forEach(async (deployedHostArg) => {
if (
hostCandidateArg.hostName === deployedHostArg.hostName &&
hostCandidateArg.destination === deployedHostArg.destination &&

View File

@ -1,7 +1,7 @@
import * as plugins from './smartnginx.plugins';
import * as plugins from './smartnginx.plugins.js';
// directories
export const packageBase = plugins.path.join(__dirname, '../');
export const packageBase = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
export const nginxConfigDirPath = plugins.path.join(packageBase, 'nginxconfig');
export const nginxHostDirPath = plugins.path.join(nginxConfigDirPath, 'hosts');

View File

@ -4,17 +4,18 @@ import * as path from 'path';
export { path };
// @pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartlog from '@pushrocks/smartlog';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartshell from '@pushrocks/smartshell';
import * as smartfile from '@pushrocks/smartfile';
import * as smartstring from '@pushrocks/smartstring';
import * as smartunique from '@pushrocks/smartunique';
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';
export { lik, smartlog, smartpromise, smartshell, smartfile, smartstring, smartunique };
export { lik, smartfile, smartlog, smartpath, smartpromise, smartshell, smartstring, smartunique };
// thirdparty scope
import * as selfsigned from 'selfsigned';
import * as selfsigned from 'selfsigned';
export { selfsigned };

View File

@ -1,5 +1,5 @@
import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths';
import * as plugins from './smartnginx.plugins.js';
import * as paths from './smartnginx.paths.js';
export let getBaseConfigString = (defaultProxy: string) => {
const baseConfig = plugins.smartstring.indent.normalize(`
user www-data;