@underpostnet/underpost 2.8.4 → 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 (82) hide show
  1. package/.github/workflows/ghpkg.yml +12 -45
  2. package/.github/workflows/npmpkg.yml +67 -0
  3. package/.github/workflows/publish.yml +5 -5
  4. package/.github/workflows/pwa-microservices-template.page.yml +2 -1
  5. package/.github/workflows/pwa-microservices-template.test.yml +2 -2
  6. package/.vscode/settings.json +10 -1
  7. package/CHANGELOG.md +40 -0
  8. package/Dockerfile +6 -27
  9. package/bin/build.js +73 -165
  10. package/bin/deploy.js +76 -101
  11. package/bin/file.js +29 -15
  12. package/bin/hwt.js +0 -10
  13. package/bin/index.js +191 -32
  14. package/bin/util.js +0 -15
  15. package/bin/vs.js +1 -0
  16. package/conf.js +0 -2
  17. package/docker-compose.yml +1 -1
  18. package/manifests/kind-config-dev.yaml +12 -0
  19. package/manifests/{core/underpost-engine-mongodb-backup-cronjob.yaml → mongodb/backup-cronjob.yaml} +14 -12
  20. package/manifests/mongodb/kustomization.yaml +11 -0
  21. package/manifests/mongodb/pv-pvc.yaml +23 -0
  22. package/manifests/{core/underpost-engine-statefulset.yaml → mongodb/statefulset.yaml} +34 -0
  23. package/manifests/mongodb-4.4/kustomization.yaml +7 -0
  24. package/manifests/mongodb-4.4/service-deployment.yaml +63 -0
  25. package/manifests/valkey/kustomization.yaml +2 -2
  26. package/package.json +22 -4
  27. package/src/api/core/core.service.js +1 -1
  28. package/src/cli/cluster.js +202 -0
  29. package/src/cli/cron.js +90 -0
  30. package/src/cli/db.js +212 -0
  31. package/src/cli/deploy.js +318 -0
  32. package/src/cli/env.js +52 -0
  33. package/src/cli/fs.js +149 -0
  34. package/src/cli/image.js +148 -0
  35. package/src/cli/repository.js +125 -0
  36. package/src/cli/script.js +53 -0
  37. package/src/cli/secrets.js +37 -0
  38. package/src/cli/test.js +118 -0
  39. package/src/client/components/core/Auth.js +22 -4
  40. package/src/client/components/core/CalendarCore.js +12 -1
  41. package/src/client/components/core/CommonJs.js +134 -2
  42. package/src/client/components/core/Css.js +1 -0
  43. package/src/client/components/core/CssCore.js +2 -4
  44. package/src/client/components/core/Docs.js +1 -2
  45. package/src/client/components/core/Input.js +5 -3
  46. package/src/client/components/core/LoadingAnimation.js +8 -1
  47. package/src/client/components/core/Modal.js +30 -7
  48. package/src/client/components/core/Panel.js +8 -6
  49. package/src/client/components/core/PanelForm.js +23 -7
  50. package/src/client/components/core/Scroll.js +1 -0
  51. package/src/client/components/core/Translate.js +4 -0
  52. package/src/client/components/core/VanillaJs.js +0 -9
  53. package/src/client/components/core/Worker.js +34 -31
  54. package/src/client/services/core/core.service.js +15 -10
  55. package/src/client/ssr/Render.js +4 -1
  56. package/src/client/ssr/body/CacheControl.js +2 -3
  57. package/src/client/sw/default.sw.js +3 -3
  58. package/src/db/mongo/MongooseDB.js +17 -1
  59. package/src/index.js +85 -26
  60. package/src/server/backup.js +49 -93
  61. package/src/server/client-build.js +33 -33
  62. package/src/server/client-formatted.js +6 -3
  63. package/src/server/conf.js +82 -199
  64. package/src/server/dns.js +29 -53
  65. package/src/server/downloader.js +0 -8
  66. package/src/server/logger.js +7 -7
  67. package/src/server/network.js +17 -7
  68. package/src/server/runtime.js +24 -23
  69. package/test/api.test.js +0 -8
  70. package/manifests/core/kustomization.yaml +0 -11
  71. package/src/dns.js +0 -22
  72. package/src/server/project.js +0 -39
  73. package/startup.cjs +0 -12
  74. /package/manifests/deployment/{mongo-express.yaml → mongo-express/deployment.yaml} +0 -0
  75. /package/manifests/deployment/{phpmyadmin.yaml → phpmyadmin/deployment.yaml} +0 -0
  76. /package/manifests/{core/underpost-engine-backup-access.yaml → mongodb/backup-access.yaml} +0 -0
  77. /package/manifests/{core/underpost-engine-backup-pv-pvc.yaml → mongodb/backup-pv-pvc.yaml} +0 -0
  78. /package/manifests/{core/underpost-engine-mongodb-configmap.yaml → mongodb/configmap.yaml} +0 -0
  79. /package/manifests/{core/underpost-engine-headless-service.yaml → mongodb/headless-service.yaml} +0 -0
  80. /package/manifests/{core/underpost-engine-pv-pvc.yaml → mongodb-4.4/pv-pvc.yaml} +0 -0
  81. /package/manifests/valkey/{underpost-engine-valkey-service.yaml → service.yaml} +0 -0
  82. /package/manifests/valkey/{underpost-engine-valkey-statefulset.yaml → statefulset.yaml} +0 -0
package/bin/deploy.js CHANGED
@@ -2,7 +2,6 @@ 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
6
  import { pbcopy, shellCd, shellExec } from '../src/server/process.js';
8
7
  import { loggerFactory } from '../src/server/logger.js';
@@ -26,6 +25,7 @@ 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';
@@ -141,28 +141,7 @@ try {
141
141
  loadConf(process.argv[3], process.argv[4]);
142
142
  break;
143
143
  }
144
- case 'run':
145
- {
146
- if (process.argv.includes('replicas')) {
147
- const deployGroupId = getDeployGroupId();
148
- const dataDeploy = getDataDeploy({
149
- deployId: process.argv[3],
150
- buildSingleReplica: true,
151
- deployGroupId,
152
- });
153
- if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
154
- await deployRun(dataDeploy);
155
- } else {
156
- loadConf(process.argv[3]);
157
- shellExec(`npm start ${process.argv.includes('maintenance') ? 'maintenance' : ''}`);
158
- }
159
- }
160
- break;
161
144
 
162
- case 'remove-await-deploy': {
163
- if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
164
- break;
165
- }
166
145
  case 'new-nodejs-app':
167
146
  {
168
147
  const deployId = process.argv[3];
@@ -229,6 +208,7 @@ try {
229
208
  break;
230
209
  case 'build-full-client':
231
210
  {
211
+ dotenv.config({ override: true });
232
212
  if (!process.argv[3]) process.argv[3] = 'default';
233
213
  const { deployId, folder } = loadConf(process.argv[3]);
234
214
 
@@ -254,20 +234,7 @@ try {
254
234
  serverConf[host][path].replicas.map((replica) => buildReplicaId({ deployId, replica })),
255
235
  );
256
236
 
257
- shellExec(Cmd.replica(deployId, host, path));
258
- }
259
- if (serverConf[host][path].db) {
260
- switch (serverConf[host][path].db.provider) {
261
- case 'mariadb':
262
- {
263
- shellExec(`node bin/db ${host}${path} create ${deployId}`);
264
- }
265
-
266
- break;
267
-
268
- default:
269
- break;
270
- }
237
+ // shellExec(Cmd.replica(deployId, host, path));
271
238
  }
272
239
  }
273
240
  }
@@ -276,7 +243,7 @@ try {
276
243
  await buildClient();
277
244
 
278
245
  for (const replicaDeployId of deployIdSingleReplicas) {
279
- shellExec(Cmd.conf(replicaDeployId));
246
+ shellExec(Cmd.conf(replicaDeployId, process.env.NODE_ENV));
280
247
  shellExec(Cmd.build(replicaDeployId));
281
248
  }
282
249
  }
@@ -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,68 +672,80 @@ 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
- }
734
- if (filePah.split('/').pop() === 'deployment.yaml') {
735
- fs.writeFileSync(
736
- filePah,
737
- fs
738
- .readFileSync(filePah, 'utf8')
739
- .replaceAll(`v${version}`, `v${newVersion}`)
740
- .replaceAll(`engine.version: ${version}`, `engine.version: ${newVersion}`),
741
- 'utf8',
742
- );
743
- }
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
+ );
744
705
  }
745
706
  }
707
+ }
746
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`))
747
718
  fs.writeFileSync(
748
- `./docker-compose.yml`,
719
+ `./.github/workflows/docker-image.yml`,
749
720
  fs
750
- .readFileSync(`./docker-compose.yml`, 'utf8')
751
- .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}`),
752
723
  'utf8',
753
724
  );
754
725
 
755
- if (fs.existsSync(`./.github/workflows/docker-image.yml`))
756
- fs.writeFileSync(
757
- `./.github/workflows/docker-image.yml`,
758
- fs
759
- .readFileSync(`./.github/workflows/docker-image.yml`, 'utf8')
760
- .replaceAll(`underpost-engine:v${version}`, `underpost-engine:v${newVersion}`),
761
- 'utf8',
762
- );
726
+ fs.writeFileSync(
727
+ `./src/index.js`,
728
+ fs.readFileSync(`./src/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
729
+ 'utf8',
730
+ );
763
731
 
764
- fs.writeFileSync(
765
- `./src/index.js`,
766
- fs.readFileSync(`./src/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
767
- 'utf8',
768
- );
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
+ }
769
739
 
770
- shellExec(`node bin/deploy update-dependencies`);
771
- shellExec(`auto-changelog`);
772
- }
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`);
773
747
  break;
748
+ }
774
749
 
775
750
  case 'update-authors': {
776
751
  // #### Ordered by first contribution.
@@ -863,7 +838,7 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
863
838
  DefaultConf.client = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.client.json`, 'utf8'));
864
839
  DefaultConf.server = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
865
840
  DefaultConf.ssr = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.ssr.json`, 'utf8'));
866
- DefaultConf.cron = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.cron.json`, 'utf8'));
841
+ // DefaultConf.cron = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.cron.json`, 'utf8'));
867
842
 
868
843
  for (const host of Object.keys(DefaultConf.server)) {
869
844
  for (const path of Object.keys(DefaultConf.server[host])) {
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, newInstance } 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,10 +75,9 @@ 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 ['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',
@@ -89,17 +86,34 @@ try {
89
86
  '.github/workflows/engine.lampp.ci.yml',
90
87
  '.github/workflows/engine.core.ci.yml',
91
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',
92
92
  'bin/web3.js',
93
93
  'bin/cyberia.js',
94
94
  ]) {
95
- fs.removeSync('../pwa-microservices-template/' + deletePath);
95
+ if (fs.existsSync(deletePath)) fs.removeSync('../pwa-microservices-template/' + deletePath);
96
96
  }
97
- shellCd('../engine');
98
97
  const originPackageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
99
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
+
100
105
  templatePackageJson.dependencies = originPackageJson.dependencies;
101
106
  templatePackageJson.devDependencies = originPackageJson.devDependencies;
102
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'];
103
117
  fs.writeFileSync(
104
118
  '../pwa-microservices-template/package.json',
105
119
  JSON.stringify(templatePackageJson, null, 4),
package/bin/hwt.js CHANGED
@@ -1,19 +1,9 @@
1
1
  import fs from 'fs-extra';
2
- import axios from 'axios';
3
- import https from 'https';
4
2
 
5
- import dotenv from 'dotenv';
6
- import { shellCd, shellExec } from '../src/server/process.js';
7
3
  import { loggerFactory } from '../src/server/logger.js';
8
4
 
9
5
  const logger = loggerFactory(import.meta);
10
6
 
11
- const httpsAgent = new https.Agent({
12
- rejectUnauthorized: false,
13
- });
14
-
15
- axios.defaults.httpsAgent = httpsAgent;
16
-
17
7
  logger.info('argv', process.argv);
18
8
 
19
9
  const [exe, dir, operator, templateId, publicPath] = process.argv;
package/bin/index.js CHANGED
@@ -1,63 +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
4
  import { Command } from 'commander';
6
- import { actionInitLog, loggerFactory } from '../src/server/logger.js';
7
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';
8
9
 
9
- dotenv.config();
10
-
11
- const logger = loggerFactory(import.meta);
10
+ const underpostRootPath = getUnderpostRootPath();
11
+ fs.existsSync(`${underpostRootPath}/.env`)
12
+ ? dotenv.config({ path: `${underpostRootPath}/.env`, override: true })
13
+ : dotenv.config();
12
14
 
13
15
  const program = new Command();
14
16
 
15
- program.name('underpost').description(`underpost.net ci/cd cli ${Underpost.version}`).version(Underpost.version);
17
+ program.name('underpost').description(`underpost ci/cd cli ${Underpost.version}`).version(Underpost.version);
16
18
 
17
19
  program
18
- .command('new <app-name>')
20
+ .command('new')
21
+ .argument('<app-name>', 'Application name')
19
22
  .description('Create a new project')
20
- .action((...args) => ((args[1] = Underpost.version), new Underpost.project(...args)));
23
+ .action(Underpost.repo.new);
21
24
 
22
25
  program
23
- .command('clone <uri>')
24
- .description('Clone github repository, if your GITHUB_TOKEN environment exists, it will be used')
25
- .action(Underpost.project.clone);
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);
26
31
 
27
32
  program
28
- .command('pull <path> <uri>')
29
- .description('Pull github repository, if your GITHUB_TOKEN environment exists, it will be used')
30
- .action(Underpost.project.pull);
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);
31
38
 
32
39
  program
33
- .option('--copy')
34
- .option('--info')
35
- .option('--empty')
36
- .command('cmt <path> [commit-type] [sub-module] [message]')
37
- .description(
38
- 'Commit github repository, if your GITHUB_TOKEN environment exists, it will be used, use --copy will copy to clipboard message, use --info will see info commit types, use --empty will allow empty files',
39
- )
40
- .action((...args) => ((args[4] = options), Underpost.project.commit(...args)));
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);
41
50
 
42
51
  program
43
- .command('push <path> <uri>')
44
- .description('Push github repository, if your GITHUB_TOKEN environment exists, it will be used')
45
- .action(Underpost.project.push);
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);
46
58
 
47
59
  program
48
- .command('env <deploy-id> [env]')
60
+ .command('env')
61
+ .argument('<deploy-id>', `deploy configuration id, if 'clean' restore default`)
62
+ .argument('[env]', 'Optional environment, for default is production')
49
63
  .description('Set environment variables files and conf related to <deploy-id>')
50
- .action(Underpost.project.useEnv);
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();
125
+ });
126
+
127
+ program
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);
51
146
 
52
- program.command('test').description('Run tests').action(Underpost.runTest);
147
+ program
148
+ .command('dockerfile-pull-base-images')
149
+ .description('Pull underpost dockerfile images requirements')
150
+ .action(Underpost.image.dockerfile.pullBaseImages);
53
151
 
54
152
  program
55
- .command('help')
56
- .description('Display help information')
153
+ .command('install')
154
+ .description('Fast import underpost npm dependencies')
57
155
  .action(() => {
58
- program.outputHelp();
156
+ fs.copySync(`${underpostRootPath}/node_modules`, './node_modules');
59
157
  });
60
158
 
61
- const options = program.opts();
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);
62
221
 
63
222
  program.parse();
package/bin/util.js CHANGED
@@ -2,8 +2,6 @@ import fs from 'fs-extra';
2
2
  import si from 'systeminformation';
3
3
  import * as dir from 'path';
4
4
  import { svg } from 'font-awesome-assets';
5
- import axios from 'axios';
6
- import https from 'https';
7
5
 
8
6
  import { loggerFactory } from '../src/server/logger.js';
9
7
  import { pbcopy, shellExec } from '../src/server/process.js';
@@ -12,11 +10,6 @@ import { FileFactory } from '../src/api/file/file.service.js';
12
10
  import { faBase64Png, getBufferPngText } from '../src/server/client-icons.js';
13
11
  import keyword_extractor from 'keyword-extractor';
14
12
 
15
- const httpsAgent = new https.Agent({
16
- rejectUnauthorized: false,
17
- });
18
- axios.defaults.httpsAgent = httpsAgent;
19
-
20
13
  const logger = loggerFactory(import.meta);
21
14
 
22
15
  logger.info('argv', process.argv);
@@ -112,14 +105,6 @@ try {
112
105
  fs.writeFileSync('b64-image', `data:image/jpg;base64,${fs.readFileSync(process.argv[3]).toString('base64')}`);
113
106
  break;
114
107
 
115
- case 'clean-env': {
116
- shellExec(`git checkout package.json`);
117
- shellExec(`git checkout .env.production`);
118
- shellExec(`git checkout .env.development`);
119
- shellExec(`git checkout .env.test`);
120
- shellExec(`git checkout jsdoc.json`);
121
- break;
122
- }
123
108
  case 'get-keys': {
124
109
  const sentence = fs.existsSync('./_')
125
110
  ? fs.readFileSync('./_', 'utf8')