underpost 2.8.1 → 2.8.6
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 +17 -71
- package/.vscode/settings.json +18 -3
- package/AUTHORS.md +16 -5
- package/CHANGELOG.md +103 -3
- package/Dockerfile +24 -66
- package/README.md +1 -28
- package/bin/build.js +186 -0
- package/bin/db.js +2 -24
- package/bin/deploy.js +169 -144
- package/bin/file.js +59 -16
- package/bin/hwt.js +0 -10
- package/bin/index.js +201 -60
- package/bin/ssl.js +19 -11
- package/bin/util.js +9 -104
- package/bin/vs.js +26 -2
- package/conf.js +29 -138
- package/docker-compose.yml +1 -1
- 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/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/valkey/kustomization.yaml +7 -0
- package/manifests/valkey/service.yaml +17 -0
- package/manifests/valkey/statefulset.yaml +39 -0
- package/package.json +133 -136
- package/src/api/core/core.service.js +1 -1
- package/src/api/user/user.model.js +16 -3
- package/src/api/user/user.service.js +1 -1
- package/src/cli/cluster.js +202 -0
- package/src/cli/cron.js +90 -0
- package/src/cli/db.js +212 -0
- package/src/cli/deploy.js +318 -0
- package/src/cli/env.js +52 -0
- package/src/cli/fs.js +149 -0
- package/src/cli/image.js +148 -0
- package/src/cli/repository.js +125 -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/Auth.js +22 -4
- package/src/client/components/core/CalendarCore.js +127 -50
- package/src/client/components/core/CommonJs.js +282 -19
- package/src/client/components/core/Css.js +1 -0
- package/src/client/components/core/CssCore.js +8 -4
- package/src/client/components/core/Docs.js +1 -2
- package/src/client/components/core/DropDown.js +5 -1
- package/src/client/components/core/Input.js +22 -6
- package/src/client/components/core/LoadingAnimation.js +8 -1
- package/src/client/components/core/Modal.js +40 -12
- package/src/client/components/core/Panel.js +92 -31
- package/src/client/components/core/PanelForm.js +25 -23
- package/src/client/components/core/Scroll.js +1 -0
- 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/services/core/core.service.js +15 -10
- package/src/client/services/default/default.management.js +4 -2
- package/src/client/ssr/Render.js +4 -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 +85 -19
- 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 +36 -46
- package/src/server/client-formatted.js +6 -3
- package/src/server/conf.js +204 -54
- package/src/server/dns.js +30 -55
- package/src/server/downloader.js +0 -8
- package/src/server/logger.js +15 -10
- package/src/server/network.js +17 -43
- package/src/server/process.js +25 -2
- package/src/server/proxy.js +4 -26
- package/src/server/runtime.js +30 -30
- package/src/server/ssl.js +1 -1
- package/src/server/valkey.js +2 -0
- 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/index.js
CHANGED
|
@@ -1,81 +1,222 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import dotenv from 'dotenv';
|
|
4
|
-
import { shellCd, shellExec } from '../src/server/process.js';
|
|
5
|
-
import fs from 'fs-extra';
|
|
6
4
|
import { Command } from 'commander';
|
|
7
|
-
import { MongooseDB } from '../src/db/mongo/MongooseDB.js';
|
|
8
|
-
import { loggerFactory, underpostASCI } from '../src/server/logger.js';
|
|
9
5
|
import Underpost from '../src/index.js';
|
|
6
|
+
import { getUnderpostRootPath, loadConf } from '../src/server/conf.js';
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
import { commitData } from '../src/client/components/core/CommonJs.js';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const globalBinFolder = `${shellExec(`npm root -g`, {
|
|
16
|
-
stdout: true,
|
|
17
|
-
silent: true,
|
|
18
|
-
disableLog: true,
|
|
19
|
-
}).trim()}/underpost`;
|
|
10
|
+
const underpostRootPath = getUnderpostRootPath();
|
|
11
|
+
fs.existsSync(`${underpostRootPath}/.env`)
|
|
12
|
+
? dotenv.config({ path: `${underpostRootPath}/.env`, override: true })
|
|
13
|
+
: dotenv.config();
|
|
20
14
|
|
|
21
15
|
const program = new Command();
|
|
22
16
|
|
|
23
|
-
program.name('underpost').description(`underpost
|
|
17
|
+
program.name('underpost').description(`underpost ci/cd cli ${Underpost.version}`).version(Underpost.version);
|
|
24
18
|
|
|
25
19
|
program
|
|
26
|
-
.command('new
|
|
20
|
+
.command('new')
|
|
21
|
+
.argument('<app-name>', 'Application name')
|
|
27
22
|
.description('Create a new project')
|
|
28
|
-
.action(
|
|
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
|
-
});
|
|
23
|
+
.action(Underpost.repo.new);
|
|
59
24
|
|
|
60
25
|
program
|
|
61
|
-
.command('
|
|
62
|
-
.
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
26
|
+
.command('clone')
|
|
27
|
+
.argument(`<uri>`, 'e.g. username/repository')
|
|
28
|
+
.option('--bare', 'Clone only .git files')
|
|
29
|
+
.description('Clone github repository')
|
|
30
|
+
.action(Underpost.repo.clone);
|
|
31
|
+
|
|
32
|
+
program
|
|
33
|
+
.command('pull')
|
|
34
|
+
.argument('<path>', 'Absolute or relative directory')
|
|
35
|
+
.argument(`<uri>`, 'e.g. username/repository')
|
|
36
|
+
.description('Pull github repository')
|
|
37
|
+
.action(Underpost.repo.pull);
|
|
38
|
+
|
|
39
|
+
program
|
|
40
|
+
.command('cmt')
|
|
41
|
+
.argument('<path>', 'Absolute or relative directory')
|
|
42
|
+
.argument(`<commit-type>`, `Options: ${Object.keys(commitData)}`)
|
|
43
|
+
.argument(`[module-tag]`, 'Optional set module tag')
|
|
44
|
+
.argument(`[message]`, 'Optional set additional message')
|
|
45
|
+
.option('--empty', 'Allow empty files')
|
|
46
|
+
.option('--copy', 'Copy to clipboard message')
|
|
47
|
+
.option('--info', 'Info commit types')
|
|
48
|
+
.description('Commit github repository')
|
|
49
|
+
.action(Underpost.repo.commit);
|
|
50
|
+
|
|
51
|
+
program
|
|
52
|
+
.command('push')
|
|
53
|
+
.argument('<path>', 'Absolute or relative directory')
|
|
54
|
+
.argument(`<uri>`, 'e.g. username/repository')
|
|
55
|
+
.option('-f', 'Force push overwriting repository')
|
|
56
|
+
.description('Push github repository')
|
|
57
|
+
.action(Underpost.repo.push);
|
|
58
|
+
|
|
59
|
+
program
|
|
60
|
+
.command('env')
|
|
61
|
+
.argument('<deploy-id>', `deploy configuration id, if 'clean' restore default`)
|
|
62
|
+
.argument('[env]', 'Optional environment, for default is production')
|
|
63
|
+
.description('Set environment variables files and conf related to <deploy-id>')
|
|
64
|
+
.action(loadConf);
|
|
65
|
+
|
|
66
|
+
program
|
|
67
|
+
.command('config')
|
|
68
|
+
.argument('operator', `Options: ${Object.keys(Underpost.env)}`)
|
|
69
|
+
.argument('[key]', 'Config key')
|
|
70
|
+
.argument('[value]', 'Config value')
|
|
71
|
+
.description(`Manage configuration, operators`)
|
|
72
|
+
.action((...args) => Underpost.env[args[0]](args[1], args[2]));
|
|
73
|
+
|
|
74
|
+
program
|
|
75
|
+
.command('root')
|
|
76
|
+
.description('Get npm root path')
|
|
77
|
+
.action(() => console.log(getNpmRootPath()));
|
|
78
|
+
|
|
79
|
+
program
|
|
80
|
+
.command('cluster')
|
|
81
|
+
.argument('[pod-name]', 'Optional pod name filter')
|
|
82
|
+
.option('--reset', `Delete all clusters and prune all data and caches`)
|
|
83
|
+
.option('--mariadb', 'Init with mariadb statefulset')
|
|
84
|
+
.option('--mongodb', 'Init with mongodb statefulset')
|
|
85
|
+
.option('--mongodb4', 'Init with mongodb 4.4 service')
|
|
86
|
+
.option('--valkey', 'Init with valkey service')
|
|
87
|
+
.option('--contour', 'Init with project contour base HTTPProxy and envoy')
|
|
88
|
+
.option('--cert-manager', 'Init with letsencrypt-prod ClusterIssuer')
|
|
89
|
+
.option('--info', 'Get all kinds objects deployed')
|
|
90
|
+
.option('--full', 'Init with all statefulsets and services available')
|
|
91
|
+
.option('--ns-use <ns-name>', 'Switches current context to namespace')
|
|
92
|
+
.option('--dev', 'init with dev cluster')
|
|
93
|
+
.option('--list-pods', 'Display list pods information')
|
|
94
|
+
.action(Underpost.cluster.init)
|
|
95
|
+
.description('Manage cluster, for default initialization base kind cluster');
|
|
96
|
+
|
|
97
|
+
program
|
|
98
|
+
.command('deploy')
|
|
99
|
+
.argument('<deploy-list>', 'Deploy id list, e.g. default-a,default-b')
|
|
100
|
+
.argument('[env]', 'Optional environment, for default is development')
|
|
101
|
+
.option('--remove', 'Delete deployments and services')
|
|
102
|
+
.option('--sync', 'Sync deployments env, ports, and replicas')
|
|
103
|
+
.option('--info-router', 'Display router structure')
|
|
104
|
+
.option('--expose', 'Expose service match deploy-list')
|
|
105
|
+
.option('--info-util', 'Display kubectl util management commands')
|
|
106
|
+
.option('--cert', 'Reset tls/ssl certificate secrets')
|
|
107
|
+
.option('--build-manifest', 'Build kind yaml manifests: deployments, services, proxy and secrets')
|
|
108
|
+
.option('--version', 'Set custom version')
|
|
109
|
+
.description('Manage deployment, for default deploy development pods')
|
|
110
|
+
.action(Underpost.deploy.callback);
|
|
111
|
+
|
|
112
|
+
program
|
|
113
|
+
.command('secret')
|
|
114
|
+
.argument('<platform>', `Options: ${Object.keys(Underpost.secret)}`)
|
|
115
|
+
.option('--init', 'Init secrets platform environment')
|
|
116
|
+
.option('--create-from-file <path-env-file>', 'Create secret from env file')
|
|
117
|
+
.option('--list', 'Lists secrets')
|
|
118
|
+
// .option('--delete [secret-key]', 'Delete key secret, if not set, are default delete all')
|
|
119
|
+
// .option('--create [secret-key] [secret-value]', 'Create secret key, with secret value')
|
|
120
|
+
.description(`Manage secrets`)
|
|
121
|
+
.action((...args) => {
|
|
122
|
+
if (args[1].createFromFile) return Underpost.secret[args[0]].createFromEnvFile(args[1].createFromFile);
|
|
123
|
+
if (args[1].list) return Underpost.secret[args[0]].list();
|
|
124
|
+
if (args[1].init) return Underpost.secret[args[0]].init();
|
|
72
125
|
});
|
|
73
126
|
|
|
74
127
|
program
|
|
75
|
-
.command('
|
|
76
|
-
.
|
|
128
|
+
.command('dockerfile-node-script')
|
|
129
|
+
.argument('<deploy-id>', 'Deploy configuration id')
|
|
130
|
+
.argument('[env]', 'Optional environment, for default is development')
|
|
131
|
+
.option('--run', 'Run custom entry point script')
|
|
132
|
+
.description('Dockerfile custom node build script')
|
|
133
|
+
.action(Underpost.image.dockerfile.script);
|
|
134
|
+
|
|
135
|
+
program
|
|
136
|
+
.command('dockerfile-image-build')
|
|
137
|
+
.argument('<deploy-id>', 'Deploy configuration id')
|
|
138
|
+
.argument('[env]', 'Optional environment, for default is development')
|
|
139
|
+
.argument('[path]', 'Absolute or relative directory, for default is current')
|
|
140
|
+
.option('--image-archive', 'Only load tar image from ./images')
|
|
141
|
+
.option('--podman-save', 'Save image from podman to ./images')
|
|
142
|
+
.option('--image-name <image-name>', 'Set custom image name')
|
|
143
|
+
.option('--image-version <image-version>', 'Set custom image version')
|
|
144
|
+
.description('Build image from Dockerfile')
|
|
145
|
+
.action(Underpost.image.dockerfile.build);
|
|
146
|
+
|
|
147
|
+
program
|
|
148
|
+
.command('dockerfile-pull-base-images')
|
|
149
|
+
.description('Pull underpost dockerfile images requirements')
|
|
150
|
+
.action(Underpost.image.dockerfile.pullBaseImages);
|
|
151
|
+
|
|
152
|
+
program
|
|
153
|
+
.command('install')
|
|
154
|
+
.description('Fast import underpost npm dependencies')
|
|
77
155
|
.action(() => {
|
|
78
|
-
|
|
156
|
+
fs.copySync(`${underpostRootPath}/node_modules`, './node_modules');
|
|
79
157
|
});
|
|
80
158
|
|
|
159
|
+
program
|
|
160
|
+
.command('db')
|
|
161
|
+
.argument('<deploy-list>', 'Deploy id list, e.g. default-a,default-b')
|
|
162
|
+
.option('--import', 'Import container backups from repositories')
|
|
163
|
+
.option('--export', 'Export container backups to repositories')
|
|
164
|
+
.option('--pod-name <pod-name>', 'Optional pod context')
|
|
165
|
+
.option('--collection <collection>', 'Collection')
|
|
166
|
+
.option('--out-path <out-path>', 'Custom out path backup')
|
|
167
|
+
.option('--drop', 'Drop databases')
|
|
168
|
+
.option('--preserveUUID', 'Preserve Ids')
|
|
169
|
+
.option('--git', 'Upload to github')
|
|
170
|
+
.option('--ns <ns-name>', 'Optional name space context')
|
|
171
|
+
.description('Manage databases')
|
|
172
|
+
.action(Underpost.db.callback);
|
|
173
|
+
|
|
174
|
+
program
|
|
175
|
+
.command('script')
|
|
176
|
+
.argument('operator', `Options: ${Object.keys(Underpost.script)}`)
|
|
177
|
+
.argument('<script-name>', 'Script name')
|
|
178
|
+
.argument('[script-value]', 'Literal command, or path')
|
|
179
|
+
.option('--itc', 'Inside container execution context')
|
|
180
|
+
.option('--itc-path', 'Inside container path options')
|
|
181
|
+
.option('--ns <ns-name>', 'Options name space context')
|
|
182
|
+
.option('--pod-name <pod-name>')
|
|
183
|
+
.description(
|
|
184
|
+
'Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts',
|
|
185
|
+
)
|
|
186
|
+
.action((...args) => Underpost.script[args[0]](args[1], args[2], args[3]));
|
|
187
|
+
|
|
188
|
+
program
|
|
189
|
+
.command('cron')
|
|
190
|
+
.argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
|
|
191
|
+
.argument('[job-list]', `Deploy id list, e.g. ${Object.keys(Underpost.cron)}, for default all available jobs`)
|
|
192
|
+
.option('--itc', 'Inside container execution context')
|
|
193
|
+
.option('--init', 'Init cron jobs for cron job default deploy id')
|
|
194
|
+
.option('--git', 'Upload to github')
|
|
195
|
+
.description('Cron jobs management')
|
|
196
|
+
.action(Underpost.cron.callback);
|
|
197
|
+
|
|
198
|
+
program
|
|
199
|
+
.command('fs')
|
|
200
|
+
.argument('[path]', 'Absolute or relative directory')
|
|
201
|
+
.option('--rm', 'Remove file')
|
|
202
|
+
.option('--git', 'Current git changes')
|
|
203
|
+
.option('--recursive', 'Upload files recursively')
|
|
204
|
+
.option('--deploy-id <deploy-id>', 'Deploy configuration id')
|
|
205
|
+
.option('--pull', 'Download file')
|
|
206
|
+
.option('--force', 'Force action')
|
|
207
|
+
.description('File storage management, for default upload file')
|
|
208
|
+
.action(Underpost.fs.callback);
|
|
209
|
+
|
|
210
|
+
program
|
|
211
|
+
.command('test')
|
|
212
|
+
.argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
|
|
213
|
+
.description('Manage Test, for default run current underpost default test')
|
|
214
|
+
.option('--itc', 'Inside container execution context')
|
|
215
|
+
.option('--sh', 'Copy to clipboard, container entrypoint shell command')
|
|
216
|
+
.option('--logs', 'Display container logs')
|
|
217
|
+
.option('--pod-name <pod-name>')
|
|
218
|
+
.option('--pod-status <pod-status>')
|
|
219
|
+
.option('--kind-type <kind-type>')
|
|
220
|
+
.action(Underpost.test.callback);
|
|
221
|
+
|
|
81
222
|
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
|
}
|