underpost 2.8.1 → 2.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +1 -0
- package/.github/workflows/ghpkg.yml +19 -49
- package/.github/workflows/npmpkg.yml +67 -0
- package/.github/workflows/publish.yml +5 -5
- package/.github/workflows/pwa-microservices-template.page.yml +12 -4
- package/.github/workflows/pwa-microservices-template.test.yml +2 -2
- package/.vscode/extensions.json +18 -71
- package/.vscode/settings.json +20 -3
- package/AUTHORS.md +16 -5
- package/CHANGELOG.md +123 -3
- package/Dockerfile +27 -70
- package/README.md +39 -29
- package/bin/build.js +186 -0
- package/bin/db.js +2 -24
- package/bin/deploy.js +1467 -236
- package/bin/file.js +67 -16
- package/bin/hwt.js +0 -10
- package/bin/index.js +1 -77
- package/bin/ssl.js +19 -11
- package/bin/util.js +9 -104
- package/bin/vs.js +26 -2
- package/cli.md +451 -0
- package/conf.js +29 -138
- package/docker-compose.yml +1 -1
- package/jsdoc.json +1 -1
- package/manifests/calico-custom-resources.yaml +25 -0
- package/manifests/deployment/adminer/deployment.yaml +32 -0
- package/manifests/deployment/adminer/kustomization.yaml +7 -0
- package/manifests/deployment/adminer/service.yaml +13 -0
- package/manifests/deployment/fastapi/backend-deployment.yml +120 -0
- package/manifests/deployment/fastapi/backend-service.yml +19 -0
- package/manifests/deployment/fastapi/frontend-deployment.yml +54 -0
- package/manifests/deployment/fastapi/frontend-service.yml +15 -0
- package/manifests/deployment/kafka/deployment.yaml +69 -0
- package/manifests/deployment/mongo-express/deployment.yaml +60 -0
- package/manifests/deployment/phpmyadmin/deployment.yaml +54 -0
- package/manifests/kind-config-dev.yaml +12 -0
- package/manifests/kind-config.yaml +12 -0
- package/manifests/kubeadm-calico-config.yaml +119 -0
- package/manifests/letsencrypt-prod.yaml +15 -0
- package/manifests/mariadb/config.yaml +10 -0
- package/manifests/mariadb/kustomization.yaml +9 -0
- package/manifests/mariadb/pv.yaml +12 -0
- package/manifests/mariadb/pvc.yaml +10 -0
- package/manifests/mariadb/secret.yaml +8 -0
- package/manifests/mariadb/service.yaml +10 -0
- package/manifests/mariadb/statefulset.yaml +55 -0
- package/manifests/mongodb/backup-access.yaml +16 -0
- package/manifests/mongodb/backup-cronjob.yaml +42 -0
- package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
- package/manifests/mongodb/configmap.yaml +26 -0
- package/manifests/mongodb/headless-service.yaml +10 -0
- package/manifests/mongodb/kustomization.yaml +11 -0
- package/manifests/mongodb/pv-pvc.yaml +23 -0
- package/manifests/mongodb/statefulset.yaml +125 -0
- package/manifests/mongodb-4.4/kustomization.yaml +7 -0
- package/manifests/mongodb-4.4/pv-pvc.yaml +23 -0
- package/manifests/mongodb-4.4/service-deployment.yaml +63 -0
- package/manifests/postgresql/configmap.yaml +9 -0
- package/manifests/postgresql/kustomization.yaml +10 -0
- package/manifests/postgresql/pv.yaml +15 -0
- package/manifests/postgresql/pvc.yaml +13 -0
- package/manifests/postgresql/service.yaml +10 -0
- package/manifests/postgresql/statefulset.yaml +37 -0
- package/manifests/valkey/kustomization.yaml +7 -0
- package/manifests/valkey/service.yaml +17 -0
- package/manifests/valkey/statefulset.yaml +41 -0
- package/package.json +127 -136
- package/src/api/core/core.service.js +1 -1
- package/src/api/default/default.service.js +1 -1
- package/src/api/user/user.model.js +16 -3
- package/src/api/user/user.service.js +15 -12
- package/src/cli/cluster.js +389 -0
- package/src/cli/cron.js +121 -0
- package/src/cli/db.js +222 -0
- package/src/cli/deploy.js +487 -0
- package/src/cli/env.js +58 -0
- package/src/cli/fs.js +161 -0
- package/src/cli/image.js +66 -0
- package/src/cli/index.js +312 -0
- package/src/cli/monitor.js +236 -0
- package/src/cli/repository.js +128 -0
- package/src/cli/script.js +53 -0
- package/src/cli/secrets.js +37 -0
- package/src/cli/test.js +118 -0
- package/src/client/components/core/Account.js +28 -24
- package/src/client/components/core/Auth.js +22 -4
- package/src/client/components/core/Blockchain.js +1 -1
- package/src/client/components/core/CalendarCore.js +128 -121
- package/src/client/components/core/CommonJs.js +283 -19
- package/src/client/components/core/CssCore.js +16 -4
- package/src/client/components/core/Docs.js +1 -2
- package/src/client/components/core/DropDown.js +5 -1
- package/src/client/components/core/EventsUI.js +3 -3
- package/src/client/components/core/FileExplorer.js +86 -78
- package/src/client/components/core/Input.js +22 -6
- package/src/client/components/core/JoyStick.js +2 -2
- package/src/client/components/core/LoadingAnimation.js +3 -12
- package/src/client/components/core/LogIn.js +3 -3
- package/src/client/components/core/LogOut.js +1 -1
- package/src/client/components/core/Modal.js +54 -20
- package/src/client/components/core/Panel.js +109 -90
- package/src/client/components/core/PanelForm.js +23 -30
- package/src/client/components/core/Recover.js +3 -3
- package/src/client/components/core/RichText.js +1 -11
- package/src/client/components/core/Router.js +3 -1
- package/src/client/components/core/Scroll.js +1 -0
- package/src/client/components/core/SignUp.js +2 -2
- package/src/client/components/core/Translate.js +47 -9
- package/src/client/components/core/Validator.js +9 -1
- package/src/client/components/core/VanillaJs.js +0 -9
- package/src/client/components/core/Worker.js +34 -31
- package/src/client/components/default/RoutesDefault.js +3 -2
- package/src/client/services/core/core.service.js +15 -10
- package/src/client/services/default/default.management.js +46 -37
- package/src/client/ssr/Render.js +6 -1
- package/src/client/ssr/body/CacheControl.js +2 -3
- package/src/client/sw/default.sw.js +3 -3
- package/src/db/mongo/MongooseDB.js +29 -1
- package/src/index.js +101 -19
- package/src/mailer/MailerProvider.js +3 -0
- package/src/runtime/lampp/Dockerfile +65 -0
- package/src/runtime/lampp/Lampp.js +1 -13
- package/src/runtime/xampp/Xampp.js +0 -13
- package/src/server/auth.js +3 -3
- package/src/server/backup.js +49 -93
- package/src/server/client-build.js +49 -46
- package/src/server/client-formatted.js +6 -3
- package/src/server/conf.js +297 -55
- package/src/server/dns.js +75 -62
- package/src/server/downloader.js +0 -8
- package/src/server/json-schema.js +77 -0
- package/src/server/logger.js +15 -10
- package/src/server/network.js +20 -161
- package/src/server/peer.js +2 -2
- package/src/server/process.js +25 -2
- package/src/server/proxy.js +7 -29
- package/src/server/runtime.js +53 -40
- package/src/server/ssl.js +1 -1
- package/src/server/start.js +122 -0
- package/src/server/valkey.js +27 -11
- package/test/api.test.js +0 -8
- package/src/dns.js +0 -22
- package/src/server/prompt-optimizer.js +0 -28
- package/startup.js +0 -11
package/bin/file.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
|
|
3
3
|
import { loggerFactory } from '../src/server/logger.js';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
cap,
|
|
6
|
+
getCapVariableName,
|
|
7
|
+
getDirname,
|
|
8
|
+
newInstance,
|
|
9
|
+
uniqueArray,
|
|
10
|
+
} from '../src/client/components/core/CommonJs.js';
|
|
5
11
|
import { shellCd, shellExec } from '../src/server/process.js';
|
|
6
12
|
import walk from 'ignore-walk';
|
|
7
13
|
import { validateTemplatePath } from '../src/server/conf.js';
|
|
@@ -25,16 +31,8 @@ let name = getCapVariableName(file.split('.')[0]);
|
|
|
25
31
|
logger.info('File metadata', { path, file, ext, name });
|
|
26
32
|
|
|
27
33
|
try {
|
|
28
|
-
// throw '';
|
|
29
|
-
// let cmd;
|
|
30
34
|
let content = '';
|
|
31
35
|
switch (type) {
|
|
32
|
-
case 'create-js-module':
|
|
33
|
-
// node bin/file './src/client/components/core/progress bar.js'
|
|
34
|
-
content = `const ${name} = {}; export { ${name} }`;
|
|
35
|
-
setTimeout(() => shellExec(`prettier --write ${buildPath}`));
|
|
36
|
-
break;
|
|
37
|
-
|
|
38
36
|
case 'update-template':
|
|
39
37
|
case 'copy-src':
|
|
40
38
|
console.log({ rawPath, toPath });
|
|
@@ -77,22 +75,75 @@ try {
|
|
|
77
75
|
fs.copySync(`./.github`, `../pwa-microservices-template/.github`);
|
|
78
76
|
fs.copySync(`./src/client/public/default`, `../pwa-microservices-template/src/client/public/default`);
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
78
|
+
for (const checkoutPath of ['README.md', 'package-lock.json', 'package.json'])
|
|
79
|
+
shellExec(`cd ../pwa-microservices-template && git checkout ${checkoutPath}`);
|
|
80
|
+
|
|
84
81
|
for (const deletePath of [
|
|
85
82
|
'.github/workflows/coverall.yml',
|
|
86
83
|
'.github/workflows/docker-image.yml',
|
|
87
84
|
'.github/workflows/deploy.ssh.yml',
|
|
88
85
|
'.github/workflows/deploy.api-rest.yml',
|
|
86
|
+
'.github/workflows/engine.lampp.ci.yml',
|
|
87
|
+
'.github/workflows/engine.core.ci.yml',
|
|
88
|
+
'.github/workflows/engine.cyberia.ci.yml',
|
|
89
|
+
'./manifests/deployment/dd-lampp-development',
|
|
90
|
+
'./manifests/deployment/dd-cyberia-development',
|
|
91
|
+
'./manifests/deployment/dd-core-development',
|
|
89
92
|
'bin/web3.js',
|
|
90
93
|
'bin/cyberia.js',
|
|
91
|
-
'src/ipfs.js',
|
|
92
|
-
'src/k8s.js',
|
|
93
94
|
]) {
|
|
94
|
-
fs.removeSync('../pwa-microservices-template/' + deletePath);
|
|
95
|
+
if (fs.existsSync(deletePath)) fs.removeSync('../pwa-microservices-template/' + deletePath);
|
|
95
96
|
}
|
|
97
|
+
const originPackageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
|
98
|
+
const templatePackageJson = JSON.parse(fs.readFileSync('../pwa-microservices-template/package.json', 'utf8'));
|
|
99
|
+
|
|
100
|
+
const name = templatePackageJson.name;
|
|
101
|
+
const description = templatePackageJson.description;
|
|
102
|
+
const dev = templatePackageJson.scripts.dev;
|
|
103
|
+
const build = templatePackageJson.scripts.build;
|
|
104
|
+
|
|
105
|
+
templatePackageJson.dependencies = originPackageJson.dependencies;
|
|
106
|
+
templatePackageJson.devDependencies = originPackageJson.devDependencies;
|
|
107
|
+
templatePackageJson.version = originPackageJson.version;
|
|
108
|
+
templatePackageJson.scripts = originPackageJson.scripts;
|
|
109
|
+
templatePackageJson.name = name;
|
|
110
|
+
templatePackageJson.description = description;
|
|
111
|
+
templatePackageJson.scripts.dev = dev;
|
|
112
|
+
templatePackageJson.scripts.build = build;
|
|
113
|
+
templatePackageJson.keywords = uniqueArray(
|
|
114
|
+
['pwa', 'microservices', 'template', 'builder'].concat(templatePackageJson.keywords),
|
|
115
|
+
);
|
|
116
|
+
delete templatePackageJson.scripts['update-template'];
|
|
117
|
+
fs.writeFileSync(
|
|
118
|
+
'../pwa-microservices-template/package.json',
|
|
119
|
+
JSON.stringify(templatePackageJson, null, 4),
|
|
120
|
+
'utf8',
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const originPackageLockJson = JSON.parse(fs.readFileSync('./package-lock.json', 'utf8'));
|
|
124
|
+
const templatePackageLockJson = JSON.parse(
|
|
125
|
+
fs.readFileSync('../pwa-microservices-template/package-lock.json', 'utf8'),
|
|
126
|
+
);
|
|
127
|
+
const originBasePackageLock = newInstance(templatePackageLockJson.packages['']);
|
|
128
|
+
templatePackageLockJson.version = originPackageLockJson.version;
|
|
129
|
+
templatePackageLockJson.packages = originPackageLockJson.packages;
|
|
130
|
+
templatePackageLockJson.packages[''].name = originBasePackageLock.name;
|
|
131
|
+
templatePackageLockJson.packages[''].version = originPackageLockJson.version;
|
|
132
|
+
templatePackageLockJson.packages[''].hasInstallScript = originBasePackageLock.hasInstallScript;
|
|
133
|
+
templatePackageLockJson.packages[''].license = originBasePackageLock.license;
|
|
134
|
+
fs.writeFileSync(
|
|
135
|
+
'../pwa-microservices-template/package-lock.json',
|
|
136
|
+
JSON.stringify(templatePackageLockJson, null, 4),
|
|
137
|
+
'utf8',
|
|
138
|
+
);
|
|
139
|
+
const splitKeyword = '## underpost ci/cd cli';
|
|
140
|
+
fs.writeFileSync(
|
|
141
|
+
`../pwa-microservices-template/README.md`,
|
|
142
|
+
fs.readFileSync(`../pwa-microservices-template/README.md`, 'utf8').split(`<!-- -->`)[0] +
|
|
143
|
+
`<!-- -->
|
|
144
|
+
${splitKeyword + fs.readFileSync(`./README.md`, 'utf8').split(splitKeyword)[1]}`,
|
|
145
|
+
'utf8',
|
|
146
|
+
);
|
|
96
147
|
}
|
|
97
148
|
|
|
98
149
|
break;
|
package/bin/hwt.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import https from 'https';
|
|
4
2
|
|
|
5
|
-
import dotenv from 'dotenv';
|
|
6
|
-
import { shellCd, shellExec } from '../src/server/process.js';
|
|
7
3
|
import { loggerFactory } from '../src/server/logger.js';
|
|
8
4
|
|
|
9
5
|
const logger = loggerFactory(import.meta);
|
|
10
6
|
|
|
11
|
-
const httpsAgent = new https.Agent({
|
|
12
|
-
rejectUnauthorized: false,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
axios.defaults.httpsAgent = httpsAgent;
|
|
16
|
-
|
|
17
7
|
logger.info('argv', process.argv);
|
|
18
8
|
|
|
19
9
|
const [exe, dir, operator, templateId, publicPath] = process.argv;
|
package/bin/index.js
CHANGED
|
@@ -1,81 +1,5 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { shellCd, shellExec } from '../src/server/process.js';
|
|
5
|
-
import fs from 'fs-extra';
|
|
6
|
-
import { Command } from 'commander';
|
|
7
|
-
import { MongooseDB } from '../src/db/mongo/MongooseDB.js';
|
|
8
|
-
import { loggerFactory, underpostASCI } from '../src/server/logger.js';
|
|
9
|
-
import Underpost from '../src/index.js';
|
|
10
|
-
|
|
11
|
-
dotenv.config();
|
|
12
|
-
|
|
13
|
-
const logger = loggerFactory(import.meta);
|
|
14
|
-
|
|
15
|
-
const globalBinFolder = `${shellExec(`npm root -g`, {
|
|
16
|
-
stdout: true,
|
|
17
|
-
silent: true,
|
|
18
|
-
disableLog: true,
|
|
19
|
-
}).trim()}/underpost`;
|
|
20
|
-
|
|
21
|
-
const program = new Command();
|
|
22
|
-
|
|
23
|
-
program.name('underpost').description(`underpost.net ci/cd cli ${Underpost.version}`).version(Underpost.version);
|
|
24
|
-
|
|
25
|
-
program
|
|
26
|
-
.command('new <app-name>')
|
|
27
|
-
.description('Create a new project')
|
|
28
|
-
.action(async (appName) => {
|
|
29
|
-
console.log(
|
|
30
|
-
underpostASCI() +
|
|
31
|
-
`
|
|
32
|
-
${Underpost.version} https://www.nexodev.org/docs
|
|
33
|
-
`,
|
|
34
|
-
);
|
|
35
|
-
await logger.setUpInfo();
|
|
36
|
-
const destFolder = `${process.cwd()}/${appName}`;
|
|
37
|
-
logger.info('Note: This process may take several minutes to complete');
|
|
38
|
-
logger.info('build app', { destFolder });
|
|
39
|
-
fs.mkdirSync(destFolder, { recursive: true });
|
|
40
|
-
fs.copySync(globalBinFolder, destFolder);
|
|
41
|
-
fs.writeFileSync(`${destFolder}/.gitignore`, fs.readFileSync(`${globalBinFolder}/.dockerignore`, 'utf8'), 'utf8');
|
|
42
|
-
shellCd(`${destFolder}`);
|
|
43
|
-
shellExec(`git init && git add . && git commit -m "Base template implementation"`);
|
|
44
|
-
shellExec(`npm run install-template`);
|
|
45
|
-
switch (process.platform) {
|
|
46
|
-
case 'linux':
|
|
47
|
-
try {
|
|
48
|
-
await MongooseDB.server();
|
|
49
|
-
} catch (error) {
|
|
50
|
-
logger.error(error, 'failed to start mongodb server');
|
|
51
|
-
}
|
|
52
|
-
break;
|
|
53
|
-
|
|
54
|
-
default:
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
shellExec(`npm run dev`);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
program
|
|
61
|
-
.command('test')
|
|
62
|
-
.description('Run tests')
|
|
63
|
-
.action(() => {
|
|
64
|
-
console.log(
|
|
65
|
-
underpostASCI() +
|
|
66
|
-
`
|
|
67
|
-
${Underpost.version} https://www.nexodev.org/docs
|
|
68
|
-
`,
|
|
69
|
-
);
|
|
70
|
-
shellCd(`${globalBinFolder}`);
|
|
71
|
-
shellExec(`npm run test`);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
program
|
|
75
|
-
.command('help')
|
|
76
|
-
.description('Display help information')
|
|
77
|
-
.action(() => {
|
|
78
|
-
program.outputHelp();
|
|
79
|
-
});
|
|
3
|
+
import { program } from '../src/cli/index.js';
|
|
80
4
|
|
|
81
5
|
program.parse();
|
package/bin/ssl.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import read from 'read';
|
|
3
|
-
import ncp from 'copy-paste';
|
|
4
3
|
import dotenv from 'dotenv';
|
|
5
|
-
|
|
6
|
-
import { getRootDirectory, shellExec } from '../src/server/process.js';
|
|
4
|
+
import { getRootDirectory, pbcopy, shellExec } from '../src/server/process.js';
|
|
7
5
|
import { loggerFactory } from '../src/server/logger.js';
|
|
8
6
|
import { Cmd, loadConf } from '../src/server/conf.js';
|
|
9
7
|
import { buildSSL } from '../src/server/ssl.js';
|
|
@@ -24,9 +22,9 @@ try {
|
|
|
24
22
|
for (const host of hosts.split(',')) {
|
|
25
23
|
if (host in confServer) {
|
|
26
24
|
const directory = confServer[host]['/']?.['directory'] ? confServer[host]['/']['directory'] : undefined;
|
|
27
|
-
cmd = `certbot certonly --webroot --webroot-path ${
|
|
25
|
+
cmd = `sudo certbot certonly --webroot --webroot-path ${
|
|
28
26
|
directory ? directory : `${getRootDirectory()}/public/${host}`
|
|
29
|
-
} -d ${host}`;
|
|
27
|
+
} --cert-name ${host} -d ${host}`;
|
|
30
28
|
// directory ? directory : `${getRootDirectory()}/public/${host}`
|
|
31
29
|
// directory ? directory : `${getRootDirectory()}/public/www.${host.split('.').slice(-2).join('.')}`
|
|
32
30
|
|
|
@@ -38,16 +36,26 @@ try {
|
|
|
38
36
|
// certbot delete --cert-name <domain>
|
|
39
37
|
|
|
40
38
|
logger.info(`Run the following command`, cmd);
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
try {
|
|
40
|
+
await pbcopy(cmd);
|
|
41
|
+
await read({ prompt: 'Command copy to clipboard, press enter to continue.\n' });
|
|
42
|
+
} catch (error) {
|
|
43
|
+
logger.error(error);
|
|
44
|
+
}
|
|
43
45
|
// Certificate
|
|
44
|
-
await buildSSL(host);
|
|
46
|
+
if (process.argv.includes('build')) await buildSSL(host);
|
|
45
47
|
logger.info('Certificate saved', host);
|
|
46
48
|
} else throw new Error(`host not found: ${host}`);
|
|
47
49
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
// check for renewal conf:
|
|
51
|
+
// /etc/letsencrypt/renewal
|
|
52
|
+
// /etc/letsencrypt/live
|
|
53
|
+
cmd = `sudo certbot renew --dry-run`;
|
|
54
|
+
try {
|
|
55
|
+
await pbcopy(cmd);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
logger.error(error);
|
|
58
|
+
}
|
|
51
59
|
logger.info(`run the following command for renewal. Command copy to clipboard`, cmd);
|
|
52
60
|
logger.info(`success install SLL`, hosts);
|
|
53
61
|
} catch (error) {
|
package/bin/util.js
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
|
-
import merge from 'deepmerge';
|
|
3
2
|
import si from 'systeminformation';
|
|
4
3
|
import * as dir from 'path';
|
|
5
4
|
import { svg } from 'font-awesome-assets';
|
|
6
|
-
import axios from 'axios';
|
|
7
|
-
import https from 'https';
|
|
8
5
|
|
|
9
6
|
import { loggerFactory } from '../src/server/logger.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { network } from '../src/server/network.js';
|
|
13
|
-
import { Config } from '../src/server/conf.js';
|
|
7
|
+
import { pbcopy, shellExec } from '../src/server/process.js';
|
|
8
|
+
import { buildKindPorts } from '../src/server/conf.js';
|
|
14
9
|
import { FileFactory } from '../src/api/file/file.service.js';
|
|
15
|
-
import {
|
|
10
|
+
import { faBase64Png, getBufferPngText } from '../src/server/client-icons.js';
|
|
16
11
|
import keyword_extractor from 'keyword-extractor';
|
|
17
12
|
|
|
18
|
-
const httpsAgent = new https.Agent({
|
|
19
|
-
rejectUnauthorized: false,
|
|
20
|
-
});
|
|
21
|
-
axios.defaults.httpsAgent = httpsAgent;
|
|
22
|
-
|
|
23
13
|
const logger = loggerFactory(import.meta);
|
|
24
14
|
|
|
25
15
|
logger.info('argv', process.argv);
|
|
@@ -29,35 +19,10 @@ const operator = process.argv[2];
|
|
|
29
19
|
try {
|
|
30
20
|
// let cmd;
|
|
31
21
|
switch (operator) {
|
|
32
|
-
case 'cls':
|
|
33
|
-
fs.removeSync('./public');
|
|
34
|
-
fs.removeSync('./logs');
|
|
35
|
-
fs.removeSync('./conf');
|
|
36
|
-
// fs.removeSync('./engine-private');
|
|
37
|
-
// fs.removeSync('./node_modules');
|
|
38
|
-
break;
|
|
39
22
|
case 'log':
|
|
40
|
-
(()
|
|
41
|
-
const logPath = `./logs/${process.argv[3]}/${process.argv[4]}.log`;
|
|
42
|
-
logger.info('Read', logPath);
|
|
43
|
-
console.log(fs.readFileSync(logPath, 'utf8'));
|
|
44
|
-
})();
|
|
45
|
-
break;
|
|
46
|
-
case 'kill-ports':
|
|
47
|
-
if (!process.argv[3]) process.argv[3] = '22,80,443,3000-3020';
|
|
48
|
-
for (const port of process.argv[3].split(',')) {
|
|
49
|
-
const rangePort = port.split('-');
|
|
50
|
-
if (rangePort[1])
|
|
51
|
-
for (const port of range(parseInt(rangePort[0]), parseInt(rangePort[1]))) {
|
|
52
|
-
logger.info('clean port', port);
|
|
53
|
-
await network.port.portClean(port);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
logger.info('clean port', parseInt(port));
|
|
57
|
-
await network.port.portClean(port);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
23
|
+
console.log(fs.readFileSync(process.argv[3], 'utf8'));
|
|
60
24
|
break;
|
|
25
|
+
|
|
61
26
|
case 'system-info':
|
|
62
27
|
await (async () => {
|
|
63
28
|
for (const infoKey of Object.keys(si)) {
|
|
@@ -74,56 +39,6 @@ try {
|
|
|
74
39
|
}
|
|
75
40
|
})();
|
|
76
41
|
break;
|
|
77
|
-
case 'export-git-changes':
|
|
78
|
-
{
|
|
79
|
-
const baseFrom = process.argv[3];
|
|
80
|
-
const baseTo = process.argv[4];
|
|
81
|
-
// if (fs.existsSync(baseTo)) fs.removeSync(baseTo);
|
|
82
|
-
shellCd(baseFrom);
|
|
83
|
-
{
|
|
84
|
-
try {
|
|
85
|
-
let output = shellExec('git status', { silent: true, stdout: true });
|
|
86
|
-
console.log('output:', output);
|
|
87
|
-
output = output
|
|
88
|
-
.split(`to discard changes in working directory)`)[1]
|
|
89
|
-
.split(`Untracked files:`)[0]
|
|
90
|
-
.split('modified:')
|
|
91
|
-
.map((c) => c.trim().replaceAll(`\n`, ''));
|
|
92
|
-
output[output.length - 1] = output[output.length - 1].split('no changes added to commit')[0];
|
|
93
|
-
output.shift();
|
|
94
|
-
for (const fromPath of output) {
|
|
95
|
-
const from = `${baseFrom}/${fromPath}`;
|
|
96
|
-
const to = `${baseTo}/${fromPath}`;
|
|
97
|
-
logger.info('Copy path', { from, to });
|
|
98
|
-
fs.copySync(from, to);
|
|
99
|
-
}
|
|
100
|
-
} catch (error) {
|
|
101
|
-
logger.error(error);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
{
|
|
105
|
-
try {
|
|
106
|
-
let output = shellExec('git status', { silent: true, stdout: true });
|
|
107
|
-
console.log('output:', output);
|
|
108
|
-
output = output
|
|
109
|
-
.split(`to include in what will be committed)`)[1]
|
|
110
|
-
.split(`no changes added to commit`)[0]
|
|
111
|
-
.split(`\n`)
|
|
112
|
-
.map((l) => l.trim())
|
|
113
|
-
.filter((l) => l);
|
|
114
|
-
|
|
115
|
-
for (const fromPath of output) {
|
|
116
|
-
const from = `${baseFrom}/${fromPath}`;
|
|
117
|
-
const to = `${baseTo}/${fromPath}`;
|
|
118
|
-
logger.info('Copy path', { from, to });
|
|
119
|
-
fs.copySync(from, to);
|
|
120
|
-
}
|
|
121
|
-
} catch (error) {
|
|
122
|
-
logger.error(error);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
break;
|
|
127
42
|
case 'delete-empty-folder':
|
|
128
43
|
function cleanEmptyFoldersRecursively(folder) {
|
|
129
44
|
if (!fs.existsSync(folder)) {
|
|
@@ -190,20 +105,6 @@ try {
|
|
|
190
105
|
fs.writeFileSync('b64-image', `data:image/jpg;base64,${fs.readFileSync(process.argv[3]).toString('base64')}`);
|
|
191
106
|
break;
|
|
192
107
|
|
|
193
|
-
case 'get-ip': {
|
|
194
|
-
const response = await axios.get(process.argv[3]);
|
|
195
|
-
logger.info(process.argv[3] + ' IP', response.request.socket.remoteAddress);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
case 'clean-env': {
|
|
200
|
-
shellExec(`git checkout package.json`);
|
|
201
|
-
shellExec(`git checkout .env.production`);
|
|
202
|
-
shellExec(`git checkout .env.development`);
|
|
203
|
-
shellExec(`git checkout .env.test`);
|
|
204
|
-
shellExec(`git checkout jsdoc.json`);
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
108
|
case 'get-keys': {
|
|
208
109
|
const sentence = fs.existsSync('./_')
|
|
209
110
|
? fs.readFileSync('./_', 'utf8')
|
|
@@ -222,6 +123,10 @@ try {
|
|
|
222
123
|
console.log(extraction_result.join(', '));
|
|
223
124
|
break;
|
|
224
125
|
}
|
|
126
|
+
|
|
127
|
+
case 'build-ports': {
|
|
128
|
+
pbcopy(buildKindPorts(process.argv[3], process.argv[4]));
|
|
129
|
+
}
|
|
225
130
|
default:
|
|
226
131
|
break;
|
|
227
132
|
}
|
package/bin/vs.js
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import { shellExec } from '../src/server/process.js';
|
|
3
|
+
import { loggerFactory } from '../src/server/logger.js';
|
|
4
|
+
|
|
5
|
+
const logger = loggerFactory(import.meta);
|
|
3
6
|
|
|
4
7
|
switch (process.argv[2]) {
|
|
8
|
+
case 'info': {
|
|
9
|
+
logger.info('Formatted', 'Ctrl shift I');
|
|
10
|
+
logger.info('Command', 'Ctrl shift P');
|
|
11
|
+
logger.info('Search', 'Ctrl shift F');
|
|
12
|
+
logger.info('Debug', 'Ctrl shift D');
|
|
13
|
+
logger.info('New File', 'Ctrl N');
|
|
14
|
+
logger.info('Change tab', 'Ctrl Tab');
|
|
15
|
+
logger.info('Fold All', 'Ctrl K + Ctrl 0');
|
|
16
|
+
logger.info('Unfold All', 'Ctrl K + Ctrl J');
|
|
17
|
+
logger.info('Close All tabs', 'Ctrl K + W');
|
|
18
|
+
logger.info('Go to line number', 'Ctrl G');
|
|
19
|
+
logger.info('Change current project folder', 'Ctrl K + Ctrl O');
|
|
20
|
+
logger.info('Open new vs windows', 'Ctrl Shift N');
|
|
21
|
+
logger.info('Close current vs windows', 'Ctrl Shift W');
|
|
22
|
+
logger.info('Preview md', 'Ctrl shift V');
|
|
23
|
+
logger.info('Open git changes', 'Ctrl G + G');
|
|
24
|
+
logger.warn('Terminal shortcut configure with command pallette', 'Ctl shift T');
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
5
27
|
case 'import':
|
|
6
28
|
{
|
|
7
29
|
const extensions = JSON.parse(fs.readFileSync(`./.vscode/extensions.json`, 'utf8'));
|
|
8
30
|
extensions.recommendations.map((extension) => {
|
|
9
|
-
if (extension)
|
|
31
|
+
if (extension)
|
|
32
|
+
shellExec(`sudo code --user-data-dir="/root/.vscode-root" --no-sandbox --install-extension ${extension}`);
|
|
10
33
|
});
|
|
11
34
|
}
|
|
12
35
|
break;
|
|
13
36
|
case 'export':
|
|
14
37
|
{
|
|
15
|
-
shellExec(`code --list-extensions > vs-extensions.txt`);
|
|
38
|
+
shellExec(`sudo code --user-data-dir="/root/.vscode-root" --no-sandbox --list-extensions > vs-extensions.txt`);
|
|
16
39
|
fs.writeFileSync(
|
|
17
40
|
`./.vscode/extensions.json`,
|
|
18
41
|
JSON.stringify(
|
|
@@ -31,5 +54,6 @@ switch (process.argv[2]) {
|
|
|
31
54
|
}
|
|
32
55
|
break;
|
|
33
56
|
default:
|
|
57
|
+
shellExec(`sudo code ${process.argv[2]} --user-data-dir="/root/.vscode-root" --no-sandbox`);
|
|
34
58
|
break;
|
|
35
59
|
}
|