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/deploy.js
CHANGED
|
@@ -2,9 +2,8 @@ import fs from 'fs-extra';
|
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
|
|
4
4
|
import dotenv from 'dotenv';
|
|
5
|
-
import plantuml from 'plantuml';
|
|
6
5
|
|
|
7
|
-
import { shellCd, shellExec } from '../src/server/process.js';
|
|
6
|
+
import { pbcopy, shellCd, shellExec } from '../src/server/process.js';
|
|
8
7
|
import { loggerFactory } from '../src/server/logger.js';
|
|
9
8
|
import {
|
|
10
9
|
Config,
|
|
@@ -26,10 +25,10 @@ import {
|
|
|
26
25
|
restoreMacroDb,
|
|
27
26
|
fixDependencies,
|
|
28
27
|
setUpProxyMaintenanceServer,
|
|
28
|
+
writeEnv,
|
|
29
29
|
} from '../src/server/conf.js';
|
|
30
30
|
import { buildClient } from '../src/server/client-build.js';
|
|
31
31
|
import { range, setPad, timer, uniqueArray } from '../src/client/components/core/CommonJs.js';
|
|
32
|
-
import simpleGit from 'simple-git';
|
|
33
32
|
import { MongooseDB } from '../src/db/mongo/MongooseDB.js';
|
|
34
33
|
import { Lampp } from '../src/runtime/lampp/Lampp.js';
|
|
35
34
|
import { DefaultConf } from '../conf.js';
|
|
@@ -139,32 +138,10 @@ try {
|
|
|
139
138
|
}
|
|
140
139
|
break;
|
|
141
140
|
case 'conf': {
|
|
142
|
-
loadConf(process.argv[3]);
|
|
143
|
-
if (process.argv[4]) fs.writeFileSync(`.env`, fs.readFileSync(`.env.${process.argv[4]}`, 'utf8'), 'utf8');
|
|
141
|
+
loadConf(process.argv[3], process.argv[4]);
|
|
144
142
|
break;
|
|
145
143
|
}
|
|
146
|
-
case 'run':
|
|
147
|
-
{
|
|
148
|
-
if (process.argv.includes('replicas')) {
|
|
149
|
-
const deployGroupId = getDeployGroupId();
|
|
150
|
-
const dataDeploy = getDataDeploy({
|
|
151
|
-
deployId: process.argv[3],
|
|
152
|
-
buildSingleReplica: true,
|
|
153
|
-
deployGroupId,
|
|
154
|
-
});
|
|
155
|
-
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
156
|
-
await deployRun(dataDeploy);
|
|
157
|
-
} else {
|
|
158
|
-
loadConf(process.argv[3]);
|
|
159
|
-
shellExec(`npm start ${process.argv.includes('maintenance') ? 'maintenance' : ''}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
144
|
|
|
164
|
-
case 'remove-await-deploy': {
|
|
165
|
-
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
145
|
case 'new-nodejs-app':
|
|
169
146
|
{
|
|
170
147
|
const deployId = process.argv[3];
|
|
@@ -231,6 +208,7 @@ try {
|
|
|
231
208
|
break;
|
|
232
209
|
case 'build-full-client':
|
|
233
210
|
{
|
|
211
|
+
dotenv.config({ override: true });
|
|
234
212
|
if (!process.argv[3]) process.argv[3] = 'default';
|
|
235
213
|
const { deployId, folder } = loadConf(process.argv[3]);
|
|
236
214
|
|
|
@@ -256,20 +234,7 @@ try {
|
|
|
256
234
|
serverConf[host][path].replicas.map((replica) => buildReplicaId({ deployId, replica })),
|
|
257
235
|
);
|
|
258
236
|
|
|
259
|
-
shellExec(Cmd.replica(deployId, host, path));
|
|
260
|
-
}
|
|
261
|
-
if (serverConf[host][path].db) {
|
|
262
|
-
switch (serverConf[host][path].db.provider) {
|
|
263
|
-
case 'mariadb':
|
|
264
|
-
{
|
|
265
|
-
shellExec(`node bin/db ${host}${path} create ${deployId}`);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
break;
|
|
269
|
-
|
|
270
|
-
default:
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
237
|
+
// shellExec(Cmd.replica(deployId, host, path));
|
|
273
238
|
}
|
|
274
239
|
}
|
|
275
240
|
}
|
|
@@ -278,7 +243,7 @@ try {
|
|
|
278
243
|
await buildClient();
|
|
279
244
|
|
|
280
245
|
for (const replicaDeployId of deployIdSingleReplicas) {
|
|
281
|
-
shellExec(Cmd.conf(replicaDeployId));
|
|
246
|
+
shellExec(Cmd.conf(replicaDeployId, process.env.NODE_ENV));
|
|
282
247
|
shellExec(Cmd.build(replicaDeployId));
|
|
283
248
|
}
|
|
284
249
|
}
|
|
@@ -307,7 +272,7 @@ try {
|
|
|
307
272
|
}
|
|
308
273
|
|
|
309
274
|
case 'adminer': {
|
|
310
|
-
const directory = '/dd/engine/public/adminer';
|
|
275
|
+
const directory = '/home/dd/engine/public/adminer';
|
|
311
276
|
// const host = '127.0.0.1';
|
|
312
277
|
const host = 'localhost';
|
|
313
278
|
const port = 80;
|
|
@@ -337,7 +302,7 @@ try {
|
|
|
337
302
|
|
|
338
303
|
case 'pma':
|
|
339
304
|
{
|
|
340
|
-
const directory = '/dd/engine/public/phpmyadmin';
|
|
305
|
+
const directory = '/home/dd/engine/public/phpmyadmin';
|
|
341
306
|
// const host = '127.0.0.1';
|
|
342
307
|
const host = 'localhost';
|
|
343
308
|
const port = 80;
|
|
@@ -454,14 +419,16 @@ try {
|
|
|
454
419
|
}
|
|
455
420
|
break;
|
|
456
421
|
|
|
457
|
-
case 'update-
|
|
422
|
+
case 'update-dependencies':
|
|
458
423
|
const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
|
|
459
424
|
const originPackage = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
|
|
460
425
|
for (const relativePath of files) {
|
|
461
426
|
const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
|
|
462
427
|
if (filePah.split('/').pop() === 'package.json') {
|
|
463
|
-
|
|
464
|
-
|
|
428
|
+
const deployPackage = JSON.parse(fs.readFileSync(filePah), 'utf8');
|
|
429
|
+
deployPackage.dependencies = originPackage.dependencies;
|
|
430
|
+
deployPackage.devDependencies = originPackage.devDependencies;
|
|
431
|
+
fs.writeFileSync(filePah, JSON.stringify(deployPackage, null, 4), 'utf8');
|
|
465
432
|
}
|
|
466
433
|
}
|
|
467
434
|
break;
|
|
@@ -469,12 +436,13 @@ try {
|
|
|
469
436
|
case 'run-macro':
|
|
470
437
|
{
|
|
471
438
|
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
472
|
-
const dataDeploy = getDataDeploy({
|
|
439
|
+
const dataDeploy = getDataDeploy({
|
|
440
|
+
deployGroupId: process.argv[3],
|
|
441
|
+
buildSingleReplica: true,
|
|
442
|
+
deployIdConcat: ['dd-proxy', 'dd-cron'],
|
|
443
|
+
});
|
|
473
444
|
if (!process.argv[4]) await setUpProxyMaintenanceServer({ deployGroupId: process.argv[3] });
|
|
474
|
-
await deployRun(
|
|
475
|
-
process.argv[4] ? dataDeploy.filter((d) => d.deployId.match(process.argv[4])) : dataDeploy,
|
|
476
|
-
true,
|
|
477
|
-
);
|
|
445
|
+
await deployRun(process.argv[4] ? dataDeploy.filter((d) => d.deployId.match(process.argv[4])) : dataDeploy);
|
|
478
446
|
}
|
|
479
447
|
break;
|
|
480
448
|
|
|
@@ -546,13 +514,7 @@ try {
|
|
|
546
514
|
? envInstanceObj.port
|
|
547
515
|
: envInstanceObj.port + port - singleReplicaHosts.length - (replicaHost ? 1 : 0);
|
|
548
516
|
|
|
549
|
-
|
|
550
|
-
envPath,
|
|
551
|
-
Object.keys(envObj)
|
|
552
|
-
.map((key) => `${key}=${envObj[key]}`)
|
|
553
|
-
.join(`\n`),
|
|
554
|
-
'utf8',
|
|
555
|
-
);
|
|
517
|
+
writeEnv(envPath, envObj);
|
|
556
518
|
}
|
|
557
519
|
const serverConf = loadReplicas(
|
|
558
520
|
JSON.parse(fs.readFileSync(`${baseConfPath}/${deployId}/conf.server.json`, 'utf8')),
|
|
@@ -596,6 +558,7 @@ try {
|
|
|
596
558
|
}
|
|
597
559
|
case 'build-uml':
|
|
598
560
|
{
|
|
561
|
+
const plantuml = await import('plantuml');
|
|
599
562
|
const folder = process.argv[3] ? process.argv[3] : `./src/client/public/default/plantuml`;
|
|
600
563
|
const confData = Config.default;
|
|
601
564
|
|
|
@@ -709,89 +672,102 @@ try {
|
|
|
709
672
|
break;
|
|
710
673
|
}
|
|
711
674
|
|
|
712
|
-
case '
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
675
|
+
case 'version-build': {
|
|
676
|
+
const newVersion = process.argv[3];
|
|
677
|
+
const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
|
|
678
|
+
const { version } = originPackageJson;
|
|
679
|
+
originPackageJson.version = newVersion;
|
|
680
|
+
fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
|
|
681
|
+
|
|
682
|
+
const originPackageLockJson = JSON.parse(fs.readFileSync(`package-lock.json`, 'utf8'));
|
|
683
|
+
originPackageLockJson.version = newVersion;
|
|
684
|
+
originPackageLockJson.packages[''].version = newVersion;
|
|
685
|
+
fs.writeFileSync(`package-lock.json`, JSON.stringify(originPackageLockJson, null, 4), 'utf8');
|
|
686
|
+
|
|
687
|
+
if (fs.existsSync(`./engine-private/conf`)) {
|
|
688
|
+
const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
|
|
689
|
+
for (const relativePath of files) {
|
|
690
|
+
const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
|
|
691
|
+
if (filePah.split('/').pop() === 'package.json') {
|
|
692
|
+
const originPackage = JSON.parse(fs.readFileSync(filePah, 'utf8'));
|
|
693
|
+
originPackage.version = newVersion;
|
|
694
|
+
fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
|
|
695
|
+
}
|
|
696
|
+
if (filePah.split('/').pop() === 'deployment.yaml') {
|
|
697
|
+
fs.writeFileSync(
|
|
698
|
+
filePah,
|
|
699
|
+
fs
|
|
700
|
+
.readFileSync(filePah, 'utf8')
|
|
701
|
+
.replaceAll(`v${version}`, `v${newVersion}`)
|
|
702
|
+
.replaceAll(`engine.version: ${version}`, `engine.version: ${newVersion}`),
|
|
703
|
+
'utf8',
|
|
704
|
+
);
|
|
734
705
|
}
|
|
735
706
|
}
|
|
707
|
+
}
|
|
736
708
|
|
|
709
|
+
fs.writeFileSync(
|
|
710
|
+
`./docker-compose.yml`,
|
|
711
|
+
fs
|
|
712
|
+
.readFileSync(`./docker-compose.yml`, 'utf8')
|
|
713
|
+
.replaceAll(`engine.version: '${version}'`, `engine.version: '${newVersion}'`),
|
|
714
|
+
'utf8',
|
|
715
|
+
);
|
|
716
|
+
|
|
717
|
+
if (fs.existsSync(`./.github/workflows/docker-image.yml`))
|
|
737
718
|
fs.writeFileSync(
|
|
738
|
-
|
|
719
|
+
`./.github/workflows/docker-image.yml`,
|
|
739
720
|
fs
|
|
740
|
-
.readFileSync(
|
|
741
|
-
.replaceAll(`engine
|
|
721
|
+
.readFileSync(`./.github/workflows/docker-image.yml`, 'utf8')
|
|
722
|
+
.replaceAll(`underpost-engine:v${version}`, `underpost-engine:v${newVersion}`),
|
|
742
723
|
'utf8',
|
|
743
724
|
);
|
|
744
725
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
.replaceAll(`underpost-engine:v${version}`, `underpost-engine:v${newVersion}`),
|
|
751
|
-
'utf8',
|
|
752
|
-
);
|
|
726
|
+
fs.writeFileSync(
|
|
727
|
+
`./src/index.js`,
|
|
728
|
+
fs.readFileSync(`./src/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
|
|
729
|
+
'utf8',
|
|
730
|
+
);
|
|
753
731
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
732
|
+
shellExec(`node bin/deploy update-dependencies`);
|
|
733
|
+
shellExec(`auto-changelog`);
|
|
734
|
+
shellExec(`node bin/build dd`);
|
|
735
|
+
shellExec(`node bin deploy dd --build-manifest --sync --info-router`);
|
|
736
|
+
shellExec(`node bin deploy dd production --build-manifest --sync --info-router`);
|
|
737
|
+
break;
|
|
738
|
+
}
|
|
759
739
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
740
|
+
case 'version-deploy': {
|
|
741
|
+
shellExec(`node bin/build dd conf`);
|
|
742
|
+
shellExec(`git add . && cd ./engine-private && git add .`);
|
|
743
|
+
shellExec(`node bin cmt . ci package-pwa-microservices-template`);
|
|
744
|
+
shellExec(`node bin cmt ./engine-private ci package-pwa-microservices-template`);
|
|
745
|
+
shellExec(`node bin push . underpostnet/engine`);
|
|
746
|
+
shellExec(`cd ./engine-private && node ../bin push . underpostnet/engine-private`);
|
|
763
747
|
break;
|
|
748
|
+
}
|
|
764
749
|
|
|
765
750
|
case 'update-authors': {
|
|
766
|
-
//
|
|
767
|
-
const logs = await simpleGit().log();
|
|
768
|
-
|
|
751
|
+
// #### Ordered by first contribution.
|
|
769
752
|
fs.writeFileSync(
|
|
770
753
|
'./AUTHORS.md',
|
|
771
754
|
`# Authors
|
|
772
755
|
|
|
773
|
-
#### Ordered by first contribution.
|
|
774
756
|
|
|
775
|
-
${
|
|
776
|
-
`)}
|
|
757
|
+
${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).join(`\n\n\n`)}
|
|
777
758
|
|
|
778
759
|
#### Generated by [underpost.net](https://underpost.net)`,
|
|
779
760
|
'utf8',
|
|
780
761
|
);
|
|
781
762
|
|
|
782
|
-
|
|
783
|
-
// date: '2024-09-16T17:10:13-03:00',
|
|
784
|
-
// message: 'update',
|
|
785
|
-
// refs: '',
|
|
786
|
-
// body: '',
|
|
787
|
-
// author_name: 'fcoverdugo',
|
|
788
|
-
// author_email: 'fcoverdugoa@underpost.net'
|
|
763
|
+
break;
|
|
789
764
|
}
|
|
790
765
|
|
|
791
766
|
case 'restore-macro-db':
|
|
792
767
|
{
|
|
793
768
|
const deployGroupId = process.argv[3];
|
|
794
|
-
|
|
769
|
+
const deployId = process.argv[4];
|
|
770
|
+
await restoreMacroDb(deployGroupId, deployId);
|
|
795
771
|
}
|
|
796
772
|
|
|
797
773
|
break;
|
|
@@ -826,10 +802,10 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
826
802
|
shellExec(`bin/besu --help`);
|
|
827
803
|
|
|
828
804
|
// Set env path
|
|
829
|
-
// export PATH=$PATH:/dd/besu-24.9.1/bin
|
|
805
|
+
// export PATH=$PATH:/home/dd/besu-24.9.1/bin
|
|
830
806
|
|
|
831
807
|
// Open src
|
|
832
|
-
// shellExec(`sudo code /dd/besu-24.9.1 --user-data-dir="/root/.vscode-root" --no-sandbox`);
|
|
808
|
+
// shellExec(`sudo code /home/dd/besu-24.9.1 --user-data-dir="/root/.vscode-root" --no-sandbox`);
|
|
833
809
|
}
|
|
834
810
|
|
|
835
811
|
break;
|
|
@@ -847,23 +823,43 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
847
823
|
}
|
|
848
824
|
|
|
849
825
|
case 'update-default-conf': {
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
`,
|
|
865
|
-
'utf8'
|
|
866
|
-
|
|
826
|
+
const defaultServer = DefaultConf.server['default.net']['/'];
|
|
827
|
+
let confName = process.argv[3];
|
|
828
|
+
if (confName === 'ghpkg') {
|
|
829
|
+
confName = undefined;
|
|
830
|
+
const host = 'underpostnet.github.io';
|
|
831
|
+
const path = '/pwa-microservices-template-ghpkg';
|
|
832
|
+
DefaultConf.server = {
|
|
833
|
+
[host]: { [path]: defaultServer },
|
|
834
|
+
};
|
|
835
|
+
DefaultConf.server[host][path].apiBaseProxyPath = '/';
|
|
836
|
+
DefaultConf.server[host][path].apiBaseHost = 'www.nexodev.org';
|
|
837
|
+
} else if (confName) {
|
|
838
|
+
DefaultConf.client = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.client.json`, 'utf8'));
|
|
839
|
+
DefaultConf.server = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
|
|
840
|
+
DefaultConf.ssr = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.ssr.json`, 'utf8'));
|
|
841
|
+
// DefaultConf.cron = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.cron.json`, 'utf8'));
|
|
842
|
+
|
|
843
|
+
for (const host of Object.keys(DefaultConf.server)) {
|
|
844
|
+
for (const path of Object.keys(DefaultConf.server[host])) {
|
|
845
|
+
DefaultConf.server[host][path].db = defaultServer.db;
|
|
846
|
+
DefaultConf.server[host][path].mailer = defaultServer.mailer;
|
|
847
|
+
|
|
848
|
+
delete DefaultConf.server[host][path]._wp_client;
|
|
849
|
+
delete DefaultConf.server[host][path]._wp_git;
|
|
850
|
+
delete DefaultConf.server[host][path]._wp_directory;
|
|
851
|
+
delete DefaultConf.server[host][path].wp;
|
|
852
|
+
delete DefaultConf.server[host][path].git;
|
|
853
|
+
delete DefaultConf.server[host][path].directory;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
const sepRender = '/**/';
|
|
858
|
+
const confRawPaths = fs.readFileSync('./conf.js', 'utf8').split(sepRender);
|
|
859
|
+
confRawPaths[1] = `${JSON.stringify(DefaultConf)};`;
|
|
860
|
+
const targetConfPath = `./conf${confName ? `.${confName}` : ''}.js`;
|
|
861
|
+
fs.writeFileSync(targetConfPath, confRawPaths.join(sepRender), 'utf8');
|
|
862
|
+
shellExec(`prettier --write ${targetConfPath}`);
|
|
867
863
|
|
|
868
864
|
break;
|
|
869
865
|
}
|
|
@@ -879,7 +875,11 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
879
875
|
}
|
|
880
876
|
case 'ssh-import-client-keys': {
|
|
881
877
|
const host = process.argv[3];
|
|
882
|
-
shellExec(
|
|
878
|
+
shellExec(
|
|
879
|
+
`node bin/deploy set-ssh-keys ./engine-private/deploy/ssh_host_rsa_key ${host ? ` ${host}` : ``} ${
|
|
880
|
+
process.argv.includes('clean') ? 'clean' : ''
|
|
881
|
+
}`,
|
|
882
|
+
);
|
|
883
883
|
break;
|
|
884
884
|
}
|
|
885
885
|
case 'ssh-keys': {
|
|
@@ -944,14 +944,24 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
944
944
|
}
|
|
945
945
|
|
|
946
946
|
case 'ssh': {
|
|
947
|
-
if (
|
|
948
|
-
shellExec(`sudo
|
|
949
|
-
|
|
950
|
-
shellExec(`sudo
|
|
947
|
+
if (process.argv.includes('rocky')) {
|
|
948
|
+
shellExec(`sudo systemctl enable sshd`);
|
|
949
|
+
|
|
950
|
+
shellExec(`sudo systemctl start sshd`);
|
|
951
|
+
|
|
952
|
+
shellExec(`sudo systemctl status sshd`);
|
|
953
|
+
|
|
954
|
+
shellExec(`sudo ss -lt`);
|
|
955
|
+
} else {
|
|
956
|
+
if (!process.argv.includes('server')) {
|
|
957
|
+
shellExec(`sudo apt update`);
|
|
958
|
+
shellExec(`sudo apt install openssh-server -y`);
|
|
959
|
+
shellExec(`sudo apt install ssh-askpass`);
|
|
960
|
+
}
|
|
961
|
+
shellExec(`sudo systemctl enable ssh`);
|
|
962
|
+
shellExec(`sudo systemctl restart ssh`);
|
|
963
|
+
shellExec(`sudo systemctl status ssh`);
|
|
951
964
|
}
|
|
952
|
-
shellExec(`sudo systemctl enable ssh`);
|
|
953
|
-
shellExec(`sudo systemctl restart ssh`);
|
|
954
|
-
shellExec(`sudo systemctl status ssh`);
|
|
955
965
|
// sudo service ssh restart
|
|
956
966
|
shellExec(`ip a`);
|
|
957
967
|
|
|
@@ -1009,11 +1019,26 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
1009
1019
|
|
|
1010
1020
|
case 'valkey': {
|
|
1011
1021
|
if (!process.argv.includes('server')) {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1022
|
+
if (process.argv.includes('rocky')) {
|
|
1023
|
+
// shellExec(`yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm`);
|
|
1024
|
+
// shellExec(`sudo percona-release enable valkey experimental`);
|
|
1025
|
+
shellExec(`sudo dnf install valkey`);
|
|
1026
|
+
shellExec(`chown -R valkey:valkey /etc/valkey`);
|
|
1027
|
+
shellExec(`chown -R valkey:valkey /var/lib/valkey`);
|
|
1028
|
+
shellExec(`chown -R valkey:valkey /var/log/valkey`);
|
|
1029
|
+
shellExec(`sudo systemctl enable valkey.service`);
|
|
1030
|
+
shellExec(`sudo systemctl start valkey`);
|
|
1031
|
+
shellExec(`valkey-cli ping`);
|
|
1032
|
+
} else {
|
|
1033
|
+
shellExec(`cd /home/dd && git clone https://github.com/valkey-io/valkey.git`);
|
|
1034
|
+
shellExec(`cd /home/dd/valkey && make`);
|
|
1035
|
+
shellExec(`apt install valkey-tools`); // valkey-cli
|
|
1036
|
+
}
|
|
1015
1037
|
}
|
|
1016
|
-
|
|
1038
|
+
if (process.argv.includes('rocky')) {
|
|
1039
|
+
shellExec(`sudo systemctl stop valkey`);
|
|
1040
|
+
shellExec(`sudo systemctl start valkey`);
|
|
1041
|
+
} else shellExec(`cd /home/dd/valkey && ./src/valkey-server`);
|
|
1017
1042
|
|
|
1018
1043
|
break;
|
|
1019
1044
|
}
|
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,67 @@ 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
|
+
);
|
|
96
139
|
}
|
|
97
140
|
|
|
98
141
|
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;
|