fix(core): update

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

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
dist_*/
# custom

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,40 +0,0 @@
# @pushrocks/smartnginx
control nginx from node, TypeScript ready
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartnginx)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartnginx)
* [github.com (source mirror)](https://github.com/pushrocks/smartnginx)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartnginx/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartnginx/badges/master/build.svg)](https://gitlab.com/pushrocks/smartnginx/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartnginx/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartnginx/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartnginx.svg)](https://www.npmjs.com/package/@pushrocks/smartnginx)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartnginx/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartnginx)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
We recommend the use of TypeScript! :)
```typescript
import * as smartnginx from 'smartnginx';
const smartnginxInstance = new smartnginx.SmartNginx();
myNginxHost = new smartnginx.NginxHost({
hostName: 'some.example.com',
type: 'reverseProxy',
destination: '192.192.192.192' // some destination IP
});
myNginxConfig.addZone(myNginxZone); // adds the zone to the config
myNginxConfig.deploy(); // deploys the referenced NginxConfig and gracefully reloads it
```
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,15 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCMGIi2uxtbfbDIiyL6SWwZb1RdSpjGFHwzlR+mipbwgW1JsYld
Fs463PvxsMFgyQ6Nzndj3IE1mpYQgWYSS69mV8B3XxusrxnOGeO00IdA+qPGakzq
Sm+/2ualnz6nDeVWTvQuM15Ki6WQsbvmcIKngs+5tsmYfTiAnpFUv3t6zQIDAQAB
AoGAdb6VAMdnKdEMyLAv+J3G7eWkyTfOCQTkklHuJQHr9D1DRiGhqoxlThG26p49
GQRCaCq0K0kDi7LeFwc6a3wS8LjRZ9DI+mkyA0KRM0bXEkQnBM7ZGqc32476mMp+
4GI29Xl8U1pbjI0uYsyVoVeq7r3DTvHBD22FfvbPELIVzGECQQDM9WH55J70BjhH
7h8vYD4agrVGk6AnWJaTyH4uqr3/o8tzyWMbSEDqsCo8dDufsUkrntg4DscSLVEl
MZQq+8G1AkEArvv+N2Yjef9Xplo5/Zfx+bVzGrnrWuI9KVNHQeqZj50nmQbTVf+h
qAJrJKUecJcvy5elwzMdFtw5CtU+aUXjuQJAKsHmNqOjJXVGuHrMtq11R0KNXrPd
bVfl0d65tDKagIJDJ1yT+FUSdeNabFIzPhVWFmuE3+z1Sq15iDDXoD/1IQJBA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UloKmQNypZlRWzkZt0jLgG0/ofKvvqX7c
DpzwgTIoJwWlpbug788LEm3HcTVPu0LxQ1lOpgt0PWPnasc=
gYEAQ0pJ279EDgvsY+YjslMdUaJbZcF9rFgUE3t8vDDZH99kth8gqNddahcLqEV2
8hyx7qcnplpKNVx8DYvDWoTGRdXBhCP/TBBW3jdsqaBHJey+yfAISBk4pbOow260
tNQngsMDf+PZQMLm2bT1Pxk2KXd0rFMkVWprcRs2qx3Yz0Q=
-----END CERTIFICATE-----

View File

@ -15,8 +15,8 @@ server {
server {
listen *:443 ssl;
server_name test100.bleu.de;
ssl_certificate /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/test100.bleu.de.public.pem;
ssl_certificate_key /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/test100.bleu.de.private.pem;
ssl_certificate /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test100.bleu.de.public.pem;
ssl_certificate_key /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test100.bleu.de.private.pem;
location / {
proxy_http_version 1.1;
proxy_buffering off;

View File

@ -15,8 +15,8 @@ server {
server {
listen *:443 ssl;
server_name test102.bleu.de;
ssl_certificate /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/test102.bleu.de.public.pem;
ssl_certificate_key /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/test102.bleu.de.private.pem;
ssl_certificate /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test102.bleu.de.public.pem;
ssl_certificate_key /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test102.bleu.de.private.pem;
location / {
proxy_http_version 1.1;
proxy_buffering off;

View File

@ -68,12 +68,12 @@ http {
server {
listen *:443 ssl default_server;
server_name selfsigned.git.zone;
ssl_certificate /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/default.public.pem;
ssl_certificate_key /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/default.private.pem;
ssl_certificate /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/default.public.pem;
ssl_certificate_key /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/default.private.pem;
rewrite ^ https://git.zone redirect;
}
include /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/*.conf;
include /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/*.conf;
include /etc/nginx/sites-enabled/*;
}
daemon off;

View File

@ -4,11 +4,12 @@
},
"npmdocker": {},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "push.rocks",
"gitrepo": "smartnginx",
"shortDescription": "control nginx from node, TypeScript ready",
"description": "control nginx from node, TypeScript ready",
"npmPackagename": "@push.rocks/smartnginx",
"license": "MIT"
}

1819
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,12 +3,12 @@
"version": "2.0.51",
"private": false,
"description": "control nginx from node, TypeScript ready",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "tstest test/",
"cleanTest": "(rm -r nginxconfig) && npm run test",
"build": "(tsbuild)"
"build": "(tsbuild --allowimplicitany)"
},
"repository": {
"type": "git",
@ -24,33 +24,37 @@
},
"homepage": "https://gitlab.com/pushrocks/smartnginx#README",
"dependencies": {
"@pushrocks/lik": "^3.0.10",
"@pushrocks/smartfile": "^7.0.4",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartshell": "^2.0.23",
"@pushrocks/smartstring": "^3.0.10",
"@pushrocks/smartunique": "^3.0.1",
"selfsigned": "^1.10.4"
"@push.rocks/lik": "^6.0.2",
"@push.rocks/smartfile": "^10.0.26",
"@push.rocks/smartlog": "^3.0.2",
"@push.rocks/smartpath": "^5.0.11",
"@push.rocks/smartpromise": "^4.0.2",
"@push.rocks/smartshell": "^3.0.3",
"@push.rocks/smartstring": "^4.0.7",
"@push.rocks/smartunique": "^3.0.3",
"selfsigned": "^2.1.1"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.11",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/qenv": "^4.0.2",
"@pushrocks/tapbundle": "^3.0.11",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0"
"@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.77",
"@push.rocks/qenv": "^5.0.2",
"@push.rocks/tapbundle": "^5.0.8"
},
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"dist_ts_web/*",
"assets/*",
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"type": "module",
"browserslist": [
"last 1 chrome versions"
]
}

4819
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
import { tap, expect } from '@pushrocks/tapbundle';
import { tap, expect } from '@push.rocks/tapbundle';
import path = require('path');
import { Qenv } from '@pushrocks/qenv';
import { Qenv } from '@push.rocks/qenv';
const testQenv = new Qenv('./', './.nogit/');
import * as smartnginx from '../ts/index';
import * as smartnginx from '../ts/index.js';
let testSmartNginx: smartnginx.SmartNginx;
let testNginxZone01: smartnginx.NginxHost;
@ -12,7 +12,7 @@ let testNginxZone02: smartnginx.NginxHost;
tap.test('should create a valid instance of SmartNginx', async () => {
testSmartNginx = new smartnginx.SmartNginx({ defaultProxyUrl: 'https://git.zone' });
expect(testSmartNginx).to.be.instanceof(smartnginx.SmartNginx);
expect(testSmartNginx).toBeInstanceOf(smartnginx.SmartNginx);
});
tap.test(`should produce an instance of NginxConfig`, async () => {
@ -21,16 +21,16 @@ tap.test(`should produce an instance of NginxConfig`, async () => {
destination: '192.192.192.191',
destinationPort: 3000,
privateKey: 'some private',
publicKey: 'some public'
publicKey: 'some public',
});
testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, {
hostName: 'test102.bleu.de',
destination: '192.192.192.192',
destinationPort: 3050,
privateKey: 'some private',
publicKey: 'some public'
publicKey: 'some public',
});
expect(testNginxZone01).to.be.instanceof(smartnginx.NginxHost);
expect(testNginxZone01).toBeInstanceOf(smartnginx.NginxHost);
});
tap.test('.addHostCandidate() should add a zone to NginxConfig Object', async () => {

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;

11
tsconfig.json Normal file
View File

@ -0,0 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
}
}