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.
Files changed (108) hide show
  1. package/.dockerignore +1 -0
  2. package/.github/workflows/ghpkg.yml +19 -49
  3. package/.github/workflows/npmpkg.yml +67 -0
  4. package/.github/workflows/publish.yml +5 -5
  5. package/.github/workflows/pwa-microservices-template.page.yml +12 -4
  6. package/.github/workflows/pwa-microservices-template.test.yml +2 -2
  7. package/.vscode/extensions.json +17 -71
  8. package/.vscode/settings.json +18 -3
  9. package/AUTHORS.md +16 -5
  10. package/CHANGELOG.md +103 -3
  11. package/Dockerfile +24 -66
  12. package/README.md +1 -28
  13. package/bin/build.js +186 -0
  14. package/bin/db.js +2 -24
  15. package/bin/deploy.js +169 -144
  16. package/bin/file.js +59 -16
  17. package/bin/hwt.js +0 -10
  18. package/bin/index.js +201 -60
  19. package/bin/ssl.js +19 -11
  20. package/bin/util.js +9 -104
  21. package/bin/vs.js +26 -2
  22. package/conf.js +29 -138
  23. package/docker-compose.yml +1 -1
  24. package/manifests/deployment/mongo-express/deployment.yaml +60 -0
  25. package/manifests/deployment/phpmyadmin/deployment.yaml +54 -0
  26. package/manifests/kind-config-dev.yaml +12 -0
  27. package/manifests/kind-config.yaml +12 -0
  28. package/manifests/letsencrypt-prod.yaml +15 -0
  29. package/manifests/mariadb/config.yaml +10 -0
  30. package/manifests/mariadb/kustomization.yaml +9 -0
  31. package/manifests/mariadb/pv.yaml +12 -0
  32. package/manifests/mariadb/pvc.yaml +10 -0
  33. package/manifests/mariadb/secret.yaml +8 -0
  34. package/manifests/mariadb/service.yaml +10 -0
  35. package/manifests/mariadb/statefulset.yaml +55 -0
  36. package/manifests/mongodb/backup-access.yaml +16 -0
  37. package/manifests/mongodb/backup-cronjob.yaml +42 -0
  38. package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
  39. package/manifests/mongodb/configmap.yaml +26 -0
  40. package/manifests/mongodb/headless-service.yaml +10 -0
  41. package/manifests/mongodb/kustomization.yaml +11 -0
  42. package/manifests/mongodb/pv-pvc.yaml +23 -0
  43. package/manifests/mongodb/statefulset.yaml +125 -0
  44. package/manifests/mongodb-4.4/kustomization.yaml +7 -0
  45. package/manifests/mongodb-4.4/pv-pvc.yaml +23 -0
  46. package/manifests/mongodb-4.4/service-deployment.yaml +63 -0
  47. package/manifests/valkey/kustomization.yaml +7 -0
  48. package/manifests/valkey/service.yaml +17 -0
  49. package/manifests/valkey/statefulset.yaml +39 -0
  50. package/package.json +133 -136
  51. package/src/api/core/core.service.js +1 -1
  52. package/src/api/user/user.model.js +16 -3
  53. package/src/api/user/user.service.js +1 -1
  54. package/src/cli/cluster.js +202 -0
  55. package/src/cli/cron.js +90 -0
  56. package/src/cli/db.js +212 -0
  57. package/src/cli/deploy.js +318 -0
  58. package/src/cli/env.js +52 -0
  59. package/src/cli/fs.js +149 -0
  60. package/src/cli/image.js +148 -0
  61. package/src/cli/repository.js +125 -0
  62. package/src/cli/script.js +53 -0
  63. package/src/cli/secrets.js +37 -0
  64. package/src/cli/test.js +118 -0
  65. package/src/client/components/core/Auth.js +22 -4
  66. package/src/client/components/core/CalendarCore.js +127 -50
  67. package/src/client/components/core/CommonJs.js +282 -19
  68. package/src/client/components/core/Css.js +1 -0
  69. package/src/client/components/core/CssCore.js +8 -4
  70. package/src/client/components/core/Docs.js +1 -2
  71. package/src/client/components/core/DropDown.js +5 -1
  72. package/src/client/components/core/Input.js +22 -6
  73. package/src/client/components/core/LoadingAnimation.js +8 -1
  74. package/src/client/components/core/Modal.js +40 -12
  75. package/src/client/components/core/Panel.js +92 -31
  76. package/src/client/components/core/PanelForm.js +25 -23
  77. package/src/client/components/core/Scroll.js +1 -0
  78. package/src/client/components/core/Translate.js +47 -9
  79. package/src/client/components/core/Validator.js +9 -1
  80. package/src/client/components/core/VanillaJs.js +0 -9
  81. package/src/client/components/core/Worker.js +34 -31
  82. package/src/client/services/core/core.service.js +15 -10
  83. package/src/client/services/default/default.management.js +4 -2
  84. package/src/client/ssr/Render.js +4 -1
  85. package/src/client/ssr/body/CacheControl.js +2 -3
  86. package/src/client/sw/default.sw.js +3 -3
  87. package/src/db/mongo/MongooseDB.js +29 -1
  88. package/src/index.js +85 -19
  89. package/src/runtime/lampp/Lampp.js +1 -13
  90. package/src/runtime/xampp/Xampp.js +0 -13
  91. package/src/server/auth.js +3 -3
  92. package/src/server/backup.js +49 -93
  93. package/src/server/client-build.js +36 -46
  94. package/src/server/client-formatted.js +6 -3
  95. package/src/server/conf.js +204 -54
  96. package/src/server/dns.js +30 -55
  97. package/src/server/downloader.js +0 -8
  98. package/src/server/logger.js +15 -10
  99. package/src/server/network.js +17 -43
  100. package/src/server/process.js +25 -2
  101. package/src/server/proxy.js +4 -26
  102. package/src/server/runtime.js +30 -30
  103. package/src/server/ssl.js +1 -1
  104. package/src/server/valkey.js +2 -0
  105. package/test/api.test.js +0 -8
  106. package/src/dns.js +0 -22
  107. package/src/server/prompt-optimizer.js +0 -28
  108. 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-package':
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
- originPackage.scripts.start = JSON.parse(fs.readFileSync(filePah), 'utf8').scripts.start;
464
- fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
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({ deployGroupId: process.argv[3], buildSingleReplica: true });
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
- fs.writeFileSync(
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 'update-version':
713
- {
714
- const newVersion = process.argv[3];
715
- const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
716
- const { version } = originPackageJson;
717
- originPackageJson.version = newVersion;
718
- fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
719
-
720
- const originPackageLockJson = JSON.parse(fs.readFileSync(`package-lock.json`, 'utf8'));
721
- originPackageLockJson.version = newVersion;
722
- originPackageLockJson.packages[''].version = newVersion;
723
- fs.writeFileSync(`package-lock.json`, JSON.stringify(originPackageLockJson, null, 4), 'utf8');
724
-
725
- if (fs.existsSync(`./engine-private/conf`)) {
726
- const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
727
- for (const relativePath of files) {
728
- const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
729
- if (filePah.split('/').pop() === 'package.json') {
730
- const originPackage = JSON.parse(fs.readFileSync(filePah, 'utf8'));
731
- originPackage.version = newVersion;
732
- fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
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
- `./docker-compose.yml`,
719
+ `./.github/workflows/docker-image.yml`,
739
720
  fs
740
- .readFileSync(`./docker-compose.yml`, 'utf8')
741
- .replaceAll(`engine.version: '${version}'`, `engine.version: '${newVersion}'`),
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
- if (fs.existsSync(`./.github/workflows/docker-image.yml`))
746
- fs.writeFileSync(
747
- `./.github/workflows/docker-image.yml`,
748
- fs
749
- .readFileSync(`./.github/workflows/docker-image.yml`, 'utf8')
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
- fs.writeFileSync(
755
- `./src/index.js`,
756
- fs.readFileSync(`./src/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
757
- 'utf8',
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
- shellExec(`node bin/deploy update-package`);
761
- shellExec(`auto-changelog`);
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
- // shellExec(`git log --reverse --format='%aN (<%aE>)' | sort -u`, { stdout: true });
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
- ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}](mailto:${log.author_email}))`)).join(`
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
- // hash: '1c7418ad2f49c7798a6d28d370b34c69d31dce46',
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
- await restoreMacroDb(deployGroupId);
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 host = process.argv[3] ? process.argv[3] : 'underpostnet.github.io';
851
- const path = process.argv[4] ? process.argv[4] : '/pwa-microservices-template-ghpkg';
852
- DefaultConf.server = {
853
- [host]: { [path]: DefaultConf.server['default.net']['/'] },
854
- };
855
- DefaultConf.server[host][path].apiBaseProxyPath = '/';
856
- DefaultConf.server[host][path].apiBaseHost = 'www.nexodev.org';
857
- fs.writeFileSync(
858
- './conf.js',
859
- `
860
- const DefaultConf = ${JSONweb(DefaultConf)};
861
-
862
- export { DefaultConf }
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(`node bin/deploy set-ssh-keys ./engine-private/deploy/ssh_host_rsa_key${host ? ` ${host}` : ``} clean`);
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 (!process.argv.includes('server')) {
948
- shellExec(`sudo apt update`);
949
- shellExec(`sudo apt install openssh-server -y`);
950
- shellExec(`sudo apt install ssh-askpass`);
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
- shellExec(`cd /dd && git clone https://github.com/valkey-io/valkey.git`);
1013
- shellExec(`cd /dd/valkey && make`);
1014
- shellExec(`apt install valkey-tools`); // valkey-cli
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
- shellExec(`cd /dd/valkey && ./src/valkey-server`);
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 { cap, getCapVariableName, getDirname } from '../src/client/components/core/CommonJs.js';
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
- shellCd('../pwa-microservices-template');
81
- for (const deletePath of ['CHANGELOG.md', 'README.md', 'package-lock.json', 'package.json']) {
82
- shellExec(`git checkout ${deletePath}`);
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;