underpost 2.8.0 → 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 (119) 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 +20 -4
  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 +168 -157
  16. package/bin/file.js +59 -16
  17. package/bin/hwt.js +0 -10
  18. package/bin/index.js +201 -61
  19. package/bin/ssl.js +19 -11
  20. package/bin/util.js +24 -101
  21. package/bin/vs.js +26 -2
  22. package/conf.js +30 -132
  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 -134
  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/Account.js +4 -2
  66. package/src/client/components/core/Auth.js +24 -6
  67. package/src/client/components/core/CalendarCore.js +127 -50
  68. package/src/client/components/core/CommonJs.js +282 -19
  69. package/src/client/components/core/Css.js +2 -1
  70. package/src/client/components/core/CssCore.js +8 -4
  71. package/src/client/components/core/Docs.js +1 -1
  72. package/src/client/components/core/DropDown.js +5 -1
  73. package/src/client/components/core/Input.js +22 -6
  74. package/src/client/components/core/JoyStick.js +8 -5
  75. package/src/client/components/core/LoadingAnimation.js +8 -1
  76. package/src/client/components/core/Modal.js +47 -18
  77. package/src/client/components/core/Panel.js +93 -31
  78. package/src/client/components/core/PanelForm.js +27 -19
  79. package/src/client/components/core/Scroll.js +1 -0
  80. package/src/client/components/core/SignUp.js +4 -1
  81. package/src/client/components/core/Translate.js +61 -9
  82. package/src/client/components/core/Validator.js +9 -1
  83. package/src/client/components/core/VanillaJs.js +0 -9
  84. package/src/client/components/core/Worker.js +34 -31
  85. package/src/client/public/default/plantuml/client-conf.svg +1 -1
  86. package/src/client/public/default/plantuml/server-conf.svg +1 -1
  87. package/src/client/public/default/plantuml/server-schema.svg +1 -1
  88. package/src/client/public/default/plantuml/ssr-conf.svg +1 -1
  89. package/src/client/public/default/plantuml/ssr-schema.svg +1 -1
  90. package/src/client/services/core/core.service.js +15 -8
  91. package/src/client/services/default/default.management.js +4 -2
  92. package/src/client/ssr/Render.js +4 -1
  93. package/src/client/ssr/body/CacheControl.js +2 -2
  94. package/src/client/ssr/body/DefaultSplashScreen.js +3 -3
  95. package/src/client/ssr/offline/Maintenance.js +63 -0
  96. package/src/client/sw/default.sw.js +26 -6
  97. package/src/db/mongo/MongooseDB.js +29 -1
  98. package/src/index.js +91 -17
  99. package/src/runtime/lampp/Lampp.js +1 -13
  100. package/src/runtime/xampp/Xampp.js +0 -13
  101. package/src/server/auth.js +3 -3
  102. package/src/server/backup.js +49 -93
  103. package/src/server/client-build.js +41 -50
  104. package/src/server/client-formatted.js +6 -3
  105. package/src/server/client-icons.js +1 -1
  106. package/src/server/conf.js +207 -57
  107. package/src/server/dns.js +30 -55
  108. package/src/server/downloader.js +0 -8
  109. package/src/server/logger.js +22 -15
  110. package/src/server/network.js +17 -43
  111. package/src/server/process.js +25 -2
  112. package/src/server/proxy.js +4 -26
  113. package/src/server/runtime.js +30 -30
  114. package/src/server/ssl.js +1 -1
  115. package/src/server/valkey.js +3 -0
  116. package/test/api.test.js +0 -8
  117. package/src/dns.js +0 -22
  118. package/src/server/prompt-optimizer.js +0 -28
  119. 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,103 +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
 
737
- fs.writeFileSync(
738
- `./docker-compose.yml`,
739
- fs
740
- .readFileSync(`./docker-compose.yml`, 'utf8')
741
- .replaceAll(`engine.version: '${version}'`, `engine.version: '${newVersion}'`),
742
- 'utf8',
743
- );
744
-
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
- );
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
+ );
753
716
 
717
+ if (fs.existsSync(`./.github/workflows/docker-image.yml`))
754
718
  fs.writeFileSync(
755
- `./src/client/components/core/Docs.js`,
719
+ `./.github/workflows/docker-image.yml`,
756
720
  fs
757
- .readFileSync(`./src/client/components/core/Docs.js`, 'utf8')
758
- .replaceAll(`/engine/${version}`, `/engine/${newVersion}`),
721
+ .readFileSync(`./.github/workflows/docker-image.yml`, 'utf8')
722
+ .replaceAll(`underpost-engine:v${version}`, `underpost-engine:v${newVersion}`),
759
723
  'utf8',
760
724
  );
761
725
 
762
- fs.writeFileSync(
763
- `./src/client/ssr/body/CacheControl.js`,
764
- fs.readFileSync(`./src/client/ssr/body/CacheControl.js`, 'utf8').replaceAll(`v${version}`, `v${newVersion}`),
765
- 'utf8',
766
- );
726
+ fs.writeFileSync(
727
+ `./src/index.js`,
728
+ fs.readFileSync(`./src/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
729
+ 'utf8',
730
+ );
767
731
 
768
- fs.writeFileSync(
769
- `./bin/index.js`,
770
- fs.readFileSync(`./bin/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
771
- 'utf8',
772
- );
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
+ }
773
739
 
774
- shellExec(`node bin/deploy update-package`);
775
- shellExec(`auto-changelog`);
776
- }
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`);
777
747
  break;
748
+ }
778
749
 
779
750
  case 'update-authors': {
780
- // shellExec(`git log --reverse --format='%aN (<%aE>)' | sort -u`, { stdout: true });
781
- const logs = await simpleGit().log();
782
-
751
+ // #### Ordered by first contribution.
783
752
  fs.writeFileSync(
784
753
  './AUTHORS.md',
785
754
  `# Authors
786
755
 
787
- #### Ordered by first contribution.
788
756
 
789
- ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}](mailto:${log.author_email}))`)).join(`
790
- `)}
757
+ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).join(`\n\n\n`)}
791
758
 
792
759
  #### Generated by [underpost.net](https://underpost.net)`,
793
760
  'utf8',
794
761
  );
795
762
 
796
- // hash: '1c7418ad2f49c7798a6d28d370b34c69d31dce46',
797
- // date: '2024-09-16T17:10:13-03:00',
798
- // message: 'update',
799
- // refs: '',
800
- // body: '',
801
- // author_name: 'fcoverdugo',
802
- // author_email: 'fcoverdugoa@underpost.net'
763
+ break;
803
764
  }
804
765
 
805
766
  case 'restore-macro-db':
806
767
  {
807
768
  const deployGroupId = process.argv[3];
808
- await restoreMacroDb(deployGroupId);
769
+ const deployId = process.argv[4];
770
+ await restoreMacroDb(deployGroupId, deployId);
809
771
  }
810
772
 
811
773
  break;
@@ -840,10 +802,10 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
840
802
  shellExec(`bin/besu --help`);
841
803
 
842
804
  // Set env path
843
- // export PATH=$PATH:/dd/besu-24.9.1/bin
805
+ // export PATH=$PATH:/home/dd/besu-24.9.1/bin
844
806
 
845
807
  // Open src
846
- // 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`);
847
809
  }
848
810
 
849
811
  break;
@@ -861,23 +823,43 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
861
823
  }
862
824
 
863
825
  case 'update-default-conf': {
864
- const host = process.argv[3] ? process.argv[3] : 'underpostnet.github.io';
865
- const path = process.argv[4] ? process.argv[4] : '/pwa-microservices-template-ghpkg';
866
- DefaultConf.server = {
867
- [host]: { [path]: DefaultConf.server['default.net']['/'] },
868
- };
869
- DefaultConf.server[host][path].apiBaseProxyPath = '/';
870
- DefaultConf.server[host][path].apiBaseHost = 'www.nexodev.org';
871
- fs.writeFileSync(
872
- './conf.js',
873
- `
874
- const DefaultConf = ${JSONweb(DefaultConf)};
875
-
876
- export { DefaultConf }
877
-
878
- `,
879
- 'utf8',
880
- );
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}`);
881
863
 
882
864
  break;
883
865
  }
@@ -893,7 +875,11 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
893
875
  }
894
876
  case 'ssh-import-client-keys': {
895
877
  const host = process.argv[3];
896
- 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
+ );
897
883
  break;
898
884
  }
899
885
  case 'ssh-keys': {
@@ -958,14 +944,24 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
958
944
  }
959
945
 
960
946
  case 'ssh': {
961
- if (!process.argv.includes('server')) {
962
- shellExec(`sudo apt update`);
963
- shellExec(`sudo apt install openssh-server -y`);
964
- 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`);
965
964
  }
966
- shellExec(`sudo systemctl enable ssh`);
967
- shellExec(`sudo systemctl restart ssh`);
968
- shellExec(`sudo systemctl status ssh`);
969
965
  // sudo service ssh restart
970
966
  shellExec(`ip a`);
971
967
 
@@ -1023,11 +1019,26 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
1023
1019
 
1024
1020
  case 'valkey': {
1025
1021
  if (!process.argv.includes('server')) {
1026
- shellExec(`cd /dd && git clone https://github.com/valkey-io/valkey.git`);
1027
- shellExec(`cd /dd/valkey && make`);
1028
- 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
+ }
1029
1037
  }
1030
- 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`);
1031
1042
 
1032
1043
  break;
1033
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;