underpost 2.8.44 → 2.8.46

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 (45) hide show
  1. package/.github/workflows/ghpkg.yml +13 -46
  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 +3 -2
  5. package/.github/workflows/pwa-microservices-template.test.yml +2 -2
  6. package/.vscode/settings.json +2 -0
  7. package/CHANGELOG.md +16 -0
  8. package/Dockerfile +3 -24
  9. package/bin/build.js +37 -0
  10. package/bin/deploy.js +1 -14
  11. package/bin/file.js +19 -13
  12. package/bin/index.js +117 -39
  13. package/docker-compose.yml +1 -1
  14. package/manifests/mongodb/backup-access.yaml +16 -0
  15. package/manifests/mongodb/backup-cronjob.yaml +40 -0
  16. package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
  17. package/manifests/mongodb/configmap.yaml +26 -0
  18. package/manifests/mongodb/headless-service.yaml +10 -0
  19. package/manifests/mongodb/kustomization.yaml +11 -0
  20. package/manifests/mongodb/pv-pvc.yaml +23 -0
  21. package/manifests/mongodb/statefulset.yaml +125 -0
  22. package/manifests/valkey/kustomization.yaml +2 -2
  23. package/manifests/valkey/service.yaml +17 -0
  24. package/manifests/valkey/statefulset.yaml +39 -0
  25. package/package.json +25 -5
  26. package/src/cli/cluster.js +154 -0
  27. package/src/cli/db.js +98 -0
  28. package/src/cli/env.js +52 -0
  29. package/src/cli/image.js +118 -0
  30. package/src/cli/repository.js +108 -0
  31. package/src/cli/script.js +29 -0
  32. package/src/cli/secrets.js +37 -0
  33. package/src/cli/test.js +32 -0
  34. package/src/client/components/core/Auth.js +22 -4
  35. package/src/client/components/core/CommonJs.js +73 -1
  36. package/src/client/components/core/Input.js +1 -1
  37. package/src/client/components/core/Scroll.js +1 -0
  38. package/src/client/components/core/Translate.js +4 -0
  39. package/src/index.js +61 -24
  40. package/src/server/conf.js +6 -208
  41. package/src/server/logger.js +3 -3
  42. package/src/server/network.js +2 -2
  43. package/startup.cjs +0 -12
  44. /package/manifests/deployment/{mongo-express.yaml → mongo-express/deployment.yaml} +0 -0
  45. /package/manifests/deployment/{phpmyadmin.yaml → phpmyadmin/deployment.yaml} +0 -0
@@ -9,47 +9,6 @@ permissions:
9
9
  packages: write
10
10
  id-token: write
11
11
  jobs:
12
- pwa-microservices-template:
13
- if: github.repository == 'underpostnet/engine' && startsWith(github.event.head_commit.message, 'ci(package-pwa-microservices-template)')
14
- name: Update github repo package Jobs
15
- runs-on: ubuntu-latest
16
- permissions:
17
- contents: write
18
- packages: write
19
- id-token: write
20
- steps:
21
- - uses: actions/checkout@v3
22
-
23
- - uses: actions/setup-node@v4
24
- with:
25
- node-version: '22.x'
26
-
27
- - name: Install dependencies
28
- run: |
29
- npm install
30
-
31
- - name: Set git credentials
32
- run: |
33
- git config --global credential.helper ""
34
- git config credential.helper ""
35
- git config --global user.name 'underpostnet'
36
- git config --global user.email 'development@underpost.net'
37
- git config --global credential.interactive always
38
- git config user.name 'underpostnet'
39
- git config user.email 'development@underpost.net'
40
- git config credential.interactive always
41
-
42
- - name: Clone github package repository
43
- run: |
44
- cd .. && git clone https://github.com/underpostnet/pwa-microservices-template.git
45
- cd engine
46
- npm run update-template
47
- cd ../pwa-microservices-template
48
- git remote set-url origin git@github.com:underpostnet/pwa-microservices-template.git
49
- git add .
50
- git commit -m "ci(package-pwa-microservices-template-ghpkg): ⚙️ Update github repo package"
51
- git push https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/pwa-microservices-template.git
52
-
53
12
  pwa-microservices-template-ghpk:
54
13
  if: github.repository == 'underpostnet/pwa-microservices-template' && startsWith(github.event.head_commit.message, 'ci(package-pwa-microservices-template-ghpkg)')
55
14
  name: Update github repo package Jobs
@@ -63,7 +22,7 @@ jobs:
63
22
 
64
23
  - uses: actions/setup-node@v4
65
24
  with:
66
- node-version: '22.x'
25
+ node-version: '23.x'
67
26
 
68
27
  # - name: Get npm root
69
28
  # run: sudo npm root -g
@@ -82,13 +41,15 @@ jobs:
82
41
 
83
42
  - name: Install dependencies and set repo configuration
84
43
  run: |
85
- npm install
44
+ npm install -g underpost
45
+ underpost config set GITHUB_TOKEN ${{ secrets.GIT_AUTH_TOKEN }}
46
+ underpost install
86
47
  node ./bin/deploy rename-package @underpostnet/underpost
87
48
  node ./bin/deploy set-repo underpostnet/pwa-microservices-template-ghpkg
88
49
 
89
50
  - name: Clone github package repository
90
51
  run: |
91
- git clone --bare https://github.com/underpostnet/pwa-microservices-template-ghpkg.git
52
+ underpost clone --bare underpostnet/pwa-microservices-template-ghpkg
92
53
  rm -rf ./.git
93
54
  cp -rf -a ./pwa-microservices-template-ghpkg.git ./.git
94
55
  rm -rf ./pwa-microservices-template-ghpkg.git
@@ -111,8 +72,14 @@ jobs:
111
72
  git status
112
73
  git remote set-url origin git@github.com:underpostnet/pwa-microservices-template-ghpkg.git
113
74
  git add .
114
- git commit -m "ci(package-pwa-microservices-template-ghpkg): ⚙️ Update github repo package"
115
- git push https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/pwa-microservices-template-ghpkg.git
75
+ underpost cmt . ci package-pwa-microservices-template-ghpkg 'Update github repo package'
76
+ underpost push . underpostnet/pwa-microservices-template-ghpkg
77
+
78
+ # git clone --bare https://github.com/underpostnet/engine.git
79
+ # mkdir engine
80
+ # mv ./engine.git ./engine/.git
81
+ # cd engine
82
+ # git init
116
83
 
117
84
  # git push -u origin https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/pwa-microservices-template-ghpkg.git
118
85
  # git push -u origin master
@@ -0,0 +1,67 @@
1
+ name: Update npm repo package
2
+ on:
3
+ push:
4
+ branches: ['master']
5
+ pull_request:
6
+ branches: ['master']
7
+ permissions:
8
+ contents: write
9
+ packages: write
10
+ id-token: write
11
+ jobs:
12
+ pwa-microservices-template:
13
+ if: github.repository == 'underpostnet/engine' && startsWith(github.event.head_commit.message, 'ci(package-pwa-microservices-template)')
14
+ name: Update npm repo package Jobs
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ contents: write
18
+ packages: write
19
+ id-token: write
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+
23
+ - uses: actions/setup-node@v4
24
+ with:
25
+ node-version: '23.x'
26
+
27
+ - name: Install dependencies
28
+ run: |
29
+ npm install -g underpost
30
+ underpost config set GITHUB_TOKEN ${{ secrets.GIT_AUTH_TOKEN }}
31
+ underpost install
32
+
33
+ - name: Set git credentials
34
+ run: |
35
+ git config --global credential.helper ""
36
+ git config credential.helper ""
37
+ git config --global user.name 'underpostnet'
38
+ git config --global user.email 'development@underpost.net'
39
+ git config --global credential.interactive always
40
+ git config user.name 'underpostnet'
41
+ git config user.email 'development@underpost.net'
42
+ git config credential.interactive always
43
+
44
+ - name: Clone github package repository
45
+ run: |
46
+ cd .. && underpost clone underpostnet/pwa-microservices-template
47
+ cd engine
48
+ npm run update-template
49
+ cd ../pwa-microservices-template
50
+ git remote set-url origin git@github.com:underpostnet/pwa-microservices-template.git
51
+ git add .
52
+ underpost cmt . ci package-pwa-microservices-template-ghpkg 'Update npm repo package'
53
+ underpost push . underpostnet/pwa-microservices-template
54
+ # cd ../engine
55
+ # git commit --allow-empty -m "ci(engine-core-repo-build): ⚙️ Update engine core repository"
56
+ # git commit --allow-empty -m "ci(engine-cyberia-repo-build): ⚙️ Update engine cyberia repository"
57
+ # git commit --allow-empty -m "ci(engine-lampp-repo-build): ⚙️ Update engine lampp repository"
58
+ # git push https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/engine.git
59
+
60
+ # git clone --bare https://github.com/underpostnet/engine.git
61
+ # mkdir engine
62
+ # mv ./engine.git ./engine/.git
63
+ # cd engine
64
+ # git init
65
+
66
+ # git push -u origin https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/pwa-microservices-template-ghpkg.git
67
+ # git push -u origin master
@@ -14,7 +14,7 @@ jobs:
14
14
  - uses: actions/checkout@v4
15
15
  - uses: actions/setup-node@v4
16
16
  with:
17
- node-version: '22.x'
17
+ node-version: '23.x'
18
18
  registry-url: 'https://registry.npmjs.org'
19
19
 
20
20
  - name: Install Dependencies
@@ -25,7 +25,7 @@ jobs:
25
25
  # Publish to npm
26
26
  - uses: actions/setup-node@v4
27
27
  with:
28
- node-version: '22.x'
28
+ node-version: '23.x'
29
29
  registry-url: 'https://registry.npmjs.org'
30
30
  # Defaults to the user or organization that owns the workflow file
31
31
  # scope: '@underpostnet'
@@ -45,7 +45,7 @@ jobs:
45
45
  - uses: actions/checkout@v4
46
46
  - uses: actions/setup-node@v4
47
47
  with:
48
- node-version: '22.x'
48
+ node-version: '23.x'
49
49
  registry-url: 'https://registry.npmjs.org'
50
50
 
51
51
  - name: Install Dependencies
@@ -56,7 +56,7 @@ jobs:
56
56
  # Publish to npm git hub package
57
57
  - uses: actions/setup-node@v4
58
58
  with:
59
- node-version: '22.x'
59
+ node-version: '23.x'
60
60
  registry-url: 'https://registry.npmjs.org'
61
61
  # Defaults to the user or organization that owns the workflow file
62
62
  scope: '@underpostnet'
@@ -70,7 +70,7 @@ jobs:
70
70
  - name: Setup node to publish to GitHub Packages
71
71
  uses: actions/setup-node@v4
72
72
  with:
73
- node-version: 22.x
73
+ node-version: 23.x
74
74
  registry-url: 'https://npm.pkg.github.com'
75
75
  # Defaults to the user or organization that owns the workflow file
76
76
  scope: '@underpostnet'
@@ -38,11 +38,12 @@ jobs:
38
38
  # run: git lfs checkout
39
39
  - uses: actions/setup-node@v4
40
40
  with:
41
- node-version: '22.x'
41
+ node-version: '23.x'
42
42
 
43
43
  - name: Build the site
44
44
  run: |
45
- npm install
45
+ npm install -g underpost
46
+ underpost install
46
47
  node bin/deploy update-default-conf ghpkg
47
48
  env-cmd -f .env.production node bin/deploy build-full-client github-pages underpostnet.github.io /pwa-microservices-template-ghpkg
48
49
  # git lfs install
@@ -2,12 +2,12 @@ name: Test
2
2
  on: [push]
3
3
  jobs:
4
4
  test:
5
- if: (github.repository == 'underpostnet/pwa-microservices-template') || (github.repository == 'underpostnet/pwa-microservices-template-ghpkg')
5
+ # if: (github.repository == 'underpostnet/pwa-microservices-template') || (github.repository == 'underpostnet/pwa-microservices-template-ghpkg')
6
6
  name: Node ${{ matrix.node }} on ${{ matrix.os }}
7
7
  runs-on: ${{ matrix.os }}
8
8
  strategy:
9
9
  matrix:
10
- node-version: [21.x]
10
+ node-version: [23.x]
11
11
  os: [ubuntu-latest]
12
12
  # os: [ubuntu-latest, windows-latest]
13
13
 
@@ -59,9 +59,11 @@
59
59
  "runas",
60
60
  "Scatterplot",
61
61
  "sortablejs",
62
+ "statefulset",
62
63
  "supervisord",
63
64
  "Tokenomics",
64
65
  "underpost",
66
+ "underpostnet",
65
67
  "Unequip",
66
68
  "uuidv",
67
69
  "Valkey",
package/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [v2.8.44](https://github.com/underpostnet/engine/compare/v2.8.42...v2.8.44)
8
+
9
+ > 18 February 2025
10
+
11
+ - ci(package-pwa-microservices-template): ⚙️ update version 2.8.44 [`1d1731d`](https://github.com/underpostnet/engine/commit/1d1731d8c81389f9ba6a308af9a66e455baa8fad)
12
+ - ci(package-pwa-microservices-template): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`1c2cc3e`](https://github.com/underpostnet/engine/commit/1c2cc3ed8c96c1d7d219f112692397de14aea172)
13
+ - ci(package-pwa-microservices-template): ⚙️ add underpost cli root env management [`1923fb6`](https://github.com/underpostnet/engine/commit/1923fb6b32c1d2df1564fb94d3475b4ef0400f99)
14
+
15
+ #### [v2.8.42](https://github.com/underpostnet/engine/compare/v2.8.31...v2.8.42)
16
+
17
+ > 18 February 2025
18
+
19
+ - ci(engine-lampp-repo-build): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`cd076c0`](https://github.com/underpostnet/engine/commit/cd076c095fde19caf744e5e04e419973670fbc6c)
20
+ - ci(engine-cyberia-repo-build): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`69d55e2`](https://github.com/underpostnet/engine/commit/69d55e2d9f8f93252561c17747472f12c6369e1c)
21
+ - ci(engine-core-repo-build): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`b031b0f`](https://github.com/underpostnet/engine/commit/b031b0f65884d9d908143e2d609ea8b0f30828a0)
22
+
7
23
  #### [v2.8.31](https://github.com/underpostnet/engine/compare/v2.8.1...v2.8.31)
8
24
 
9
25
  > 5 February 2025
package/Dockerfile CHANGED
@@ -37,33 +37,12 @@ RUN apt-get install -y nodejs build-essential
37
37
  RUN node --version
38
38
  RUN npm --version
39
39
 
40
- # local test
41
-
42
- # COPY . .
43
-
44
- # RUN npm install
45
-
46
- # VOLUME [ "/code/logs" ]
47
- # EXPOSE 22
48
-
49
- # EXPOSE 4000-4004
50
- # CMD [ "npm", "run", "dev" ]
51
-
52
- # EXPOSE 3000-3004
53
- # CMD [ "npm", "start" ]
54
-
55
- # package
56
-
57
- # Install underpost cli
58
-
59
40
  RUN npm install -g underpost
60
- RUN npm install shelljs
61
- COPY startup.cjs /code/startup.cjs
62
41
 
63
42
  VOLUME [ "/code/app/logs" ]
64
43
 
65
- EXPOSE 22 80 443 3306 27017
66
- # EXPOSE 22
44
+ EXPOSE 22
45
+
67
46
  EXPOSE 4000-4004
68
47
 
69
- CMD [ "node", "./startup.cjs" ]
48
+ CMD [ "underpost", "new", "app" ]
package/bin/build.js CHANGED
@@ -35,6 +35,13 @@ logger.info('', {
35
35
 
36
36
  if (process.argv.includes('info')) process.exit(0);
37
37
 
38
+ if (process.argv.includes('clean')) {
39
+ if (fs.existsSync(`${basePath}/images`)) fs.copySync(`${basePath}/images`, `./images`);
40
+ shellExec(`cd ${basePath} && git checkout .`);
41
+ shellExec(`cd ${basePath} && git clean -f -d`);
42
+ process.exit(0);
43
+ }
44
+
38
45
  if (process.argv.includes('proxy')) {
39
46
  const env = process.argv.includes('development') ? 'development' : 'production';
40
47
  process.env.NODE_ENV = env;
@@ -280,4 +287,34 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
280
287
  JSON.stringify(packageJson, null, 4).replaceAll('pwa-microservices-template', repoName),
281
288
  'utf8',
282
289
  );
290
+
291
+ fs.copySync(`./src/cli`, `${basePath}/src/cli`);
292
+ if (!fs.existsSync(`${basePath}/images`)) fs.mkdirSync(`${basePath}/images`);
293
+
294
+ const env = process.argv.includes('development') ? 'development' : 'production';
295
+ const deploymentsFiles = ['Dockerfile', 'proxy.yaml', 'deployment.yaml', 'secret.yaml'];
296
+ // remove engine-private of .dockerignore for local testing
297
+
298
+ if (process.argv.includes('engine')) {
299
+ fs.removeSync(`${basePath}/manifests/deployment`);
300
+
301
+ if (!fs.existsSync(`./manifests/deployment/${confName}-${env}`))
302
+ fs.mkdirSync(`./manifests/deployment/${confName}-${env}`);
303
+
304
+ for (const file of deploymentsFiles) {
305
+ if (fs.existsSync(`./engine-private/conf/${confName}/build/${env}/${file}`)) {
306
+ fs.copyFileSync(`./engine-private/conf/${confName}/build/${env}/${file}`, `${basePath}/${file}`);
307
+ fs.copyFileSync(
308
+ `./engine-private/conf/${confName}/build/${env}/${file}`,
309
+ `./manifests/deployment/${confName}-${env}/${file}`,
310
+ );
311
+ }
312
+ }
313
+ } else {
314
+ for (const file of deploymentsFiles) {
315
+ if (fs.existsSync(`./manifests/deployment/${confName}-${env}/${file}`)) {
316
+ fs.copyFileSync(`./manifests/deployment/${confName}-${env}/${file}`, `${basePath}/${file}`);
317
+ }
318
+ }
319
+ }
283
320
  }
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';
@@ -257,19 +256,6 @@ try {
257
256
 
258
257
  shellExec(Cmd.replica(deployId, host, path));
259
258
  }
260
- if (serverConf[host][path].db) {
261
- switch (serverConf[host][path].db.provider) {
262
- case 'mariadb':
263
- {
264
- shellExec(`node bin/db ${host}${path} create ${deployId}`);
265
- }
266
-
267
- break;
268
-
269
- default:
270
- break;
271
- }
272
- }
273
259
  }
274
260
  }
275
261
  }
@@ -591,6 +577,7 @@ try {
591
577
  }
592
578
  case 'build-uml':
593
579
  {
580
+ const plantuml = await import('plantuml');
594
581
  const folder = process.argv[3] ? process.argv[3] : `./src/client/public/default/plantuml`;
595
582
  const confData = Config.default;
596
583
 
package/bin/file.js CHANGED
@@ -25,16 +25,8 @@ let name = getCapVariableName(file.split('.')[0]);
25
25
  logger.info('File metadata', { path, file, ext, name });
26
26
 
27
27
  try {
28
- // throw '';
29
- // let cmd;
30
28
  let content = '';
31
29
  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
30
  case 'update-template':
39
31
  case 'copy-src':
40
32
  console.log({ rawPath, toPath });
@@ -77,10 +69,9 @@ try {
77
69
  fs.copySync(`./.github`, `../pwa-microservices-template/.github`);
78
70
  fs.copySync(`./src/client/public/default`, `../pwa-microservices-template/src/client/public/default`);
79
71
 
80
- shellCd('../pwa-microservices-template');
81
- for (const deletePath of ['README.md', 'package-lock.json', 'package.json']) {
82
- shellExec(`git checkout ${deletePath}`);
83
- }
72
+ for (const checkoutPath of ['README.md', 'package-lock.json', 'package.json'])
73
+ shellExec(`cd ../pwa-microservices-template && git checkout ${checkoutPath}`);
74
+
84
75
  for (const deletePath of [
85
76
  '.github/workflows/coverall.yml',
86
77
  '.github/workflows/docker-image.yml',
@@ -89,17 +80,32 @@ try {
89
80
  '.github/workflows/engine.lampp.ci.yml',
90
81
  '.github/workflows/engine.core.ci.yml',
91
82
  '.github/workflows/engine.cyberia.ci.yml',
83
+ './manifests/deployment/dd-lampp-development',
92
84
  'bin/web3.js',
93
85
  'bin/cyberia.js',
94
86
  ]) {
95
87
  fs.removeSync('../pwa-microservices-template/' + deletePath);
96
88
  }
97
- shellCd('../engine');
98
89
  const originPackageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
99
90
  const templatePackageJson = JSON.parse(fs.readFileSync('../pwa-microservices-template/package.json', 'utf8'));
91
+
92
+ const name = templatePackageJson.name;
93
+ const description = templatePackageJson.description;
94
+ const dev = templatePackageJson.scripts.dev;
95
+ const build = templatePackageJson.scripts.build;
96
+
100
97
  templatePackageJson.dependencies = originPackageJson.dependencies;
101
98
  templatePackageJson.devDependencies = originPackageJson.devDependencies;
102
99
  templatePackageJson.version = originPackageJson.version;
100
+ templatePackageJson.scripts = originPackageJson.scripts;
101
+ templatePackageJson.name = name;
102
+ templatePackageJson.description = description;
103
+ templatePackageJson.scripts.dev = dev;
104
+ templatePackageJson.scripts.build = build;
105
+ templatePackageJson.keywords = ['pwa', 'microservices', 'template', 'builder'].concat(
106
+ templatePackageJson.keywords,
107
+ );
108
+ delete templatePackageJson.scripts['update-template'];
103
109
  fs.writeFileSync(
104
110
  '../pwa-microservices-template/package.json',
105
111
  JSON.stringify(templatePackageJson, null, 4),
package/bin/index.js CHANGED
@@ -4,17 +4,12 @@ import dotenv from 'dotenv';
4
4
  import { Command } from 'commander';
5
5
  import { loggerFactory } from '../src/server/logger.js';
6
6
  import Underpost from '../src/index.js';
7
- import {
8
- getNpmRootPath,
9
- loadConf,
10
- newProject,
11
- repoClone,
12
- repoCommit,
13
- repoPull,
14
- repoPush,
15
- UnderpostRootEnv,
16
- } from '../src/server/conf.js';
7
+ import { getNpmRootPath, loadConf } from '../src/server/conf.js';
17
8
  import fs from 'fs-extra';
9
+ import { commitData } from '../src/client/components/core/CommonJs.js';
10
+ import UnderpostScript from '../src/cli/script.js';
11
+ import { shellExec } from '../src/server/process.js';
12
+ import UnderpostDB from '../src/cli/db.js';
18
13
 
19
14
  const npmRoot = getNpmRootPath();
20
15
  const underpostRoot = `${npmRoot}/underpost/.env`;
@@ -24,62 +19,145 @@ const logger = loggerFactory(import.meta);
24
19
 
25
20
  const program = new Command();
26
21
 
27
- program.name('underpost').description(`underpost.net ci/cd cli ${Underpost.version}`).version(Underpost.version);
22
+ program.name('underpost').description(`underpost ci/cd cli ${Underpost.version}`).version(Underpost.version);
28
23
 
29
24
  program
30
- .command('new <app-name>')
25
+ .command('new')
26
+ .argument('<app-name>', 'Application name')
31
27
  .description('Create a new project')
32
- .action((...args) => ((args[1] = Underpost.version), newProject(...args)));
28
+ .action(Underpost.repo.new);
33
29
 
34
30
  program
35
- .command('clone <uri>')
36
- .description('Clone github repository, if your GITHUB_TOKEN environment exists, it will be used')
37
- .action(repoClone);
31
+ .command('clone')
32
+ .argument(`<uri>`, 'e.g. username/repository')
33
+ .option('--bare', 'Clone only .git files')
34
+ .description('Clone github repository')
35
+ .action(Underpost.repo.clone);
38
36
 
39
37
  program
40
- .command('pull <path> <uri>')
41
- .description('Pull github repository, if your GITHUB_TOKEN environment exists, it will be used')
42
- .action(repoPull);
38
+ .command('pull')
39
+ .argument('<path>', 'Absolute or relative directory')
40
+ .argument(`<uri>`, 'e.g. username/repository')
41
+ .description('Pull github repository')
42
+ .action(Underpost.repo.pull);
43
43
 
44
44
  program
45
- .option('--copy')
46
- .option('--info')
47
- .option('--empty')
48
- .command('cmt <path> [commit-type] [sub-module] [message]')
49
- .description(
50
- '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',
51
- )
52
- .action((...args) => ((args[4] = options), repoCommit(...args)));
45
+ .command('cmt')
46
+ .argument('<path>', 'Absolute or relative directory')
47
+ .argument(`<commit-type>`, `Options: ${Object.keys(commitData)}`)
48
+ .argument(`[module-tag]`, 'Optional set module tag')
49
+ .argument(`[message]`, 'Optional set additional message')
50
+ .option('--empty', 'Allow empty files')
51
+ .option('--copy', 'Copy to clipboard message')
52
+ .option('--info', 'Info commit types')
53
+ .description('Commit github repository')
54
+ .action(Underpost.repo.commit);
53
55
 
54
56
  program
55
- .command('push <path> <uri>')
56
- .description('Push github repository, if your GITHUB_TOKEN environment exists, it will be used')
57
- .action(repoPush);
57
+ .command('push')
58
+ .argument('<path>', 'Absolute or relative directory')
59
+ .argument(`<uri>`, 'e.g. username/repository')
60
+ .option('-f', 'Force push overwriting repository')
61
+ .description('Push github repository')
62
+ .action(Underpost.repo.push);
58
63
 
59
64
  program
60
- .command('env <deploy-id> [env]')
65
+ .command('env')
66
+ .argument('<deploy-id>', 'deploy configuration id')
67
+ .argument('[env]', 'Optional environment, for default is production')
61
68
  .description('Set environment variables files and conf related to <deploy-id>')
62
69
  .action(loadConf);
63
70
 
64
71
  program
65
- .command('config <operator> [key] [value]')
66
- .description(`Manage configuration, operators available: ${Object.keys(UnderpostRootEnv)}`)
67
- .action((...args) => UnderpostRootEnv[args[0]](args[1], args[2]));
72
+ .command('config')
73
+ .argument('operator', `Options: ${Object.keys(Underpost.env)}`)
74
+ .argument('[key]', 'Config key')
75
+ .argument('[value]', 'Config value')
76
+ .description(`Manage configuration, operators`)
77
+ .action((...args) => Underpost.env[args[0]](args[1], args[2]));
68
78
 
69
79
  program
70
80
  .command('root')
71
81
  .description('Get npm root path')
72
82
  .action(() => console.log(getNpmRootPath()));
73
83
 
74
- program.command('test').description('Run tests').action(Underpost.runTest);
84
+ program
85
+ .command('cluster')
86
+ .option('--reset', `Delete all clusters and prune all data and caches`)
87
+ .option('--mariadb', 'Init with mariadb statefulset')
88
+ .option('--mongodb', 'Init with mongodb statefulset')
89
+ .option('--valkey', 'Init with valkey service')
90
+ .option('--contour', 'Init with project contour base HTTPProxy and envoy')
91
+ .option('--info', 'Get all kinds objects deployed')
92
+ .option('--full', 'Init with all statefulsets and services available')
93
+ .option('--ns-use <ns-name>', 'Switches current context to namespace')
94
+ .action((...args) => {
95
+ if (args[0].reset) return Underpost.cluster.reset();
96
+ return Underpost.cluster.init(args[0]);
97
+ })
98
+ .description('Manage cluster, for default initialization base kind cluster');
99
+
100
+ program
101
+ .command('secret')
102
+ .argument('<platform>', `Options: ${Object.keys(Underpost.secret)}`)
103
+ .option('--init', 'Init secrets platform environment')
104
+ .option('--create-from-file <path-env-file>', 'Create secret from env file')
105
+ .option('--list', 'Lists secrets')
106
+ // .option('--delete [secret-key]', 'Delete key secret, if not set, are default delete all')
107
+ // .option('--create [secret-key] [secret-value]', 'Create secret key, with secret value')
108
+ .description(`Manage secrets`)
109
+ .action((...args) => {
110
+ if (args[1].createFromFile) return Underpost.secret[args[0]].createFromEnvFile(args[1].createFromFile);
111
+ if (args[1].list) return Underpost.secret[args[0]].list();
112
+ if (args[1].init) return Underpost.secret[args[0]].init();
113
+ });
114
+
115
+ program
116
+ .command('dockerfile-node-script')
117
+ .argument('<deploy-id>', 'Deploy configuration id')
118
+ .argument('[env]', 'Optional environment, for default is development')
119
+ .description('Dockerfile custom node build script')
120
+ .action(Underpost.image.dockerfile.script);
121
+
122
+ program
123
+ .command('dockerfile-image-build')
124
+ .argument('<deploy-id>', 'Deploy configuration id')
125
+ .argument('[env]', 'Optional environment, for default is development')
126
+ .argument('[path]', 'Absolute or relative directory, for default is current')
127
+ .option('--image-archive', 'Only load tar image from /images')
128
+ .description('Build image from Dockerfile')
129
+ .action(Underpost.image.dockerfile.build);
75
130
 
76
131
  program
77
- .command('help')
78
- .description('Display help information')
132
+ .command('dockerfile-pull-base-images')
133
+ .description('Pull underpost dockerfile images requirements')
134
+ .action(Underpost.image.dockerfile.pullBaseImages);
135
+
136
+ program
137
+ .command('install')
138
+ .description('Fast import underpost npm dependencies')
79
139
  .action(() => {
80
- program.outputHelp();
140
+ fs.copySync(`${npmRoot}/underpost/node_modules`, './node_modules');
141
+ });
142
+
143
+ program
144
+ .command('db')
145
+ .option('--import <deploy-id-list>', 'Import databases to containers from deploy id list, e.g. default-a, default-b')
146
+ .description('Manage databases')
147
+ .action((...args) => {
148
+ if (args && args[0].import) return UnderpostDB.API.import(...args);
81
149
  });
82
150
 
83
- const options = program.opts();
151
+ program
152
+ .command('script')
153
+ .argument('operator', `Options: ${Object.keys(UnderpostScript.API)}`)
154
+ .argument('<script-name>', 'Script name')
155
+ .argument('[script-value]', 'Literal command')
156
+ .description(
157
+ 'Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts',
158
+ )
159
+ .action((...args) => Underpost.script[args[0]](args[1], args[2]));
160
+
161
+ program.command('test').description('Run tests').action(Underpost.test.run);
84
162
 
85
163
  program.parse();
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.8.44'
61
+ engine.version: '2.8.46'
62
62
  networks:
63
63
  - load-balancer
64
64