@underpostnet/underpost 2.8.4 → 2.8.5

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 (61) 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 +6 -1
  7. package/CHANGELOG.md +16 -0
  8. package/Dockerfile +6 -27
  9. package/bin/build.js +52 -169
  10. package/bin/deploy.js +6 -27
  11. package/bin/file.js +29 -15
  12. package/bin/index.js +158 -30
  13. package/bin/util.js +0 -8
  14. package/docker-compose.yml +1 -1
  15. package/manifests/mongodb/backup-access.yaml +16 -0
  16. package/manifests/mongodb/backup-cronjob.yaml +42 -0
  17. package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
  18. package/manifests/mongodb/configmap.yaml +26 -0
  19. package/manifests/mongodb/headless-service.yaml +10 -0
  20. package/manifests/mongodb/kustomization.yaml +11 -0
  21. package/manifests/mongodb/pv-pvc.yaml +23 -0
  22. package/manifests/mongodb/statefulset.yaml +125 -0
  23. package/manifests/valkey/kustomization.yaml +2 -2
  24. package/manifests/valkey/service.yaml +17 -0
  25. package/manifests/valkey/statefulset.yaml +39 -0
  26. package/package.json +21 -5
  27. package/src/api/core/core.service.js +1 -1
  28. package/src/cli/cluster.js +154 -0
  29. package/src/cli/cron.js +90 -0
  30. package/src/cli/db.js +148 -0
  31. package/src/cli/deploy.js +277 -0
  32. package/src/cli/env.js +52 -0
  33. package/src/cli/image.js +125 -0
  34. package/src/cli/repository.js +104 -0
  35. package/src/cli/script.js +29 -0
  36. package/src/cli/secrets.js +37 -0
  37. package/src/cli/test.js +83 -0
  38. package/src/client/components/core/Auth.js +22 -4
  39. package/src/client/components/core/CommonJs.js +82 -1
  40. package/src/client/components/core/Css.js +1 -0
  41. package/src/client/components/core/Input.js +1 -1
  42. package/src/client/components/core/Modal.js +0 -1
  43. package/src/client/components/core/Scroll.js +1 -0
  44. package/src/client/components/core/Translate.js +4 -0
  45. package/src/client/components/core/VanillaJs.js +0 -9
  46. package/src/client/components/core/Worker.js +34 -31
  47. package/src/client/ssr/body/CacheControl.js +2 -2
  48. package/src/index.js +77 -26
  49. package/src/server/backup.js +49 -93
  50. package/src/server/client-build.js +1 -10
  51. package/src/server/client-formatted.js +5 -3
  52. package/src/server/conf.js +68 -187
  53. package/src/server/dns.js +48 -65
  54. package/src/server/logger.js +7 -7
  55. package/src/server/network.js +17 -7
  56. package/src/server/runtime.js +8 -22
  57. package/src/dns.js +0 -22
  58. package/src/server/project.js +0 -39
  59. package/startup.cjs +0 -12
  60. /package/manifests/deployment/{mongo-express.yaml → mongo-express/deployment.yaml} +0 -0
  61. /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",
@@ -113,5 +115,8 @@
113
115
  "editor.defaultFormatter": "foxundermoon.shell-format"
114
116
  },
115
117
  "docwriter.progress.trackTypes": true,
116
- "docwriter.hotkey.mac": "⌘ + ."
118
+ "docwriter.hotkey.mac": "⌘ + .",
119
+ "[dotenv]": {
120
+ "editor.defaultFormatter": "foxundermoon.shell-format"
121
+ }
117
122
  }
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
@@ -4,7 +4,7 @@ FROM debian:${BASE_DEBIAN}
4
4
 
5
5
  ENV DEBIAN_FRONTEND=noninteractive
6
6
 
7
- WORKDIR /code
7
+ WORKDIR /home/dd
8
8
 
9
9
  # Set root password to root, format is 'user:password'.
10
10
  RUN echo 'root:root' | chpasswd
@@ -32,38 +32,17 @@ COPY supervisord-openssh-server.conf /etc/supervisor/conf.d/supervisord-openssh-
32
32
  RUN apt-get install -yq --no-install-recommends libssl-dev curl wget git gnupg
33
33
 
34
34
  # install nodejs https://github.com/nodesource/distributions/blob/master/README.md#deb
35
- RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
35
+ RUN curl -fsSL https://deb.nodesource.com/setup_23.x | bash -
36
36
  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
- VOLUME [ "/code/app/logs" ]
42
+ VOLUME [ "/home/dd/engine/logs" ]
43
+
44
+ EXPOSE 22
64
45
 
65
- EXPOSE 22 80 443 3306 27017
66
- # EXPOSE 22
67
46
  EXPOSE 4000-4004
68
47
 
69
- CMD [ "node", "./startup.cjs" ]
48
+ CMD [ "underpost", "new", "service" ]
package/bin/build.js CHANGED
@@ -3,7 +3,7 @@ import { loggerFactory } from '../src/server/logger.js';
3
3
  import { shellExec } from '../src/server/process.js';
4
4
  import dotenv from 'dotenv';
5
5
  import { getCapVariableName } from '../src/client/components/core/CommonJs.js';
6
- import { buildProxyRouter, buildPortProxyRouter, Config, getPathsSSR, buildKindPorts } from '../src/server/conf.js';
6
+ import { getPathsSSR } from '../src/server/conf.js';
7
7
 
8
8
  const baseConfPath = './engine-private/conf/dd-cron/.env.production';
9
9
  if (fs.existsSync(baseConfPath)) dotenv.config({ path: baseConfPath, override: true });
@@ -19,188 +19,55 @@ const logger = loggerFactory(import.meta);
19
19
 
20
20
  const confName = process.argv[2];
21
21
  const basePath = '../pwa-microservices-template';
22
- const repoName = `engine-${confName.split('dd-')[1]}-private`;
23
- const repoNameBackUp = `engine-${confName.split('dd-')[1]}-cron-backups`;
24
- const gitUrl = `https://${process.env.GITHUB_TOKEN}@github.com/underpostnet/${repoName}.git`;
25
- const gitBackUpUrl = `https://${process.env.GITHUB_TOKEN}@github.com/underpostnet/${repoNameBackUp}.git`;
22
+ const repoName = `engine-${confName.split('dd-')[1]}`;
26
23
 
27
24
  logger.info('', {
28
25
  confName,
29
- // gitUrl,
30
26
  repoName,
31
- repoNameBackUp,
32
27
  basePath,
33
28
  });
34
29
 
35
- if (process.argv.includes('info')) process.exit(0);
36
-
37
- if (process.argv.includes('proxy')) {
38
- const env = process.argv.includes('development') ? 'development' : 'production';
39
- process.env.NODE_ENV = env;
40
- process.env.PORT = process.env.NODE_ENV === 'development' ? 4000 : 3000;
41
- process.argv[2] = 'proxy';
42
- process.argv[3] = fs.readFileSync('./engine-private/deploy/dd-router', 'utf8').trim();
43
-
44
- await Config.build();
45
- process.env.NODE_ENV = 'production';
46
- const router = buildPortProxyRouter(443, buildProxyRouter());
47
- const confServer = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
48
- const confHosts = Object.keys(confServer);
49
-
50
- for (const host of Object.keys(router)) {
51
- if (!confHosts.find((_host) => host.match(_host))) {
52
- delete router[host];
53
- }
54
- }
55
-
56
- const ports = Object.values(router).map((p) => p.split(':')[2]);
57
-
58
- const fromPort = ports[0];
59
- const toPort = ports[ports.length - 1];
60
-
61
- logger.info('port range', { fromPort, toPort, router });
62
-
63
- const deploymentYamlFilePath = `./engine-private/conf/${confName}/build/${env}/deployment.yaml`;
64
-
65
- const deploymentYamlParts = fs.readFileSync(deploymentYamlFilePath, 'utf8').split('ports:');
66
- deploymentYamlParts[1] =
67
- buildKindPorts(fromPort, toPort) +
68
- ` type: LoadBalancer
69
- `;
70
-
71
- fs.writeFileSync(
72
- deploymentYamlFilePath,
73
- deploymentYamlParts.join(`ports:
74
- `),
75
- );
76
-
77
- let proxyYaml = '';
78
- let secretYaml = '';
79
-
80
- for (const host of Object.keys(confServer)) {
81
- if (env === 'production')
82
- secretYaml += `
83
- ---
84
- apiVersion: cert-manager.io/v1
85
- kind: Certificate
86
- metadata:
87
- name: ${host}
88
- spec:
89
- commonName: ${host}
90
- dnsNames:
91
- - ${host}
92
- issuerRef:
93
- name: letsencrypt-prod
94
- kind: ClusterIssuer
95
- secretName: ${host}`;
96
-
97
- const pathPortConditions = [];
98
- for (const path of Object.keys(confServer[host])) {
99
- const { peer } = confServer[host][path];
100
- const port = parseInt(router[`${host}${path === '/' ? '' : path}`].split(':')[2]);
101
- // logger.info('', { host, port, path });
102
- pathPortConditions.push({
103
- port,
104
- path,
105
- });
106
-
107
- if (peer) {
108
- // logger.info('', { host, port: port + 1, path: '/peer' });
109
- pathPortConditions.push({
110
- port: port + 1,
111
- path: '/peer',
112
- });
113
- }
114
- }
115
- // logger.info('', { host, pathPortConditions });
116
- proxyYaml += `
117
- ---
118
- apiVersion: projectcontour.io/v1
119
- kind: HTTPProxy
120
- metadata:
121
- name: ${host}
122
- spec:
123
- virtualhost:
124
- fqdn: ${host}${
125
- env === 'development'
126
- ? ''
127
- : `
128
- tls:
129
- secretName: ${host}`
130
- }
131
- routes:`;
132
- for (const conditionObj of pathPortConditions) {
133
- const { path, port } = conditionObj;
134
- proxyYaml += `
135
- - conditions:
136
- - prefix: ${path}
137
- enableWebsockets: true
138
- services:
139
- - name: ${confName}-${env}-service
140
- port: ${port}`;
141
- }
142
- }
143
- const yamlPath = `./engine-private/conf/${confName}/build/${env}/proxy.yaml`;
144
- fs.writeFileSync(yamlPath, proxyYaml, 'utf8');
145
- if (env === 'production') {
146
- const yamlPath = `./engine-private/conf/${confName}/build/${env}/secret.yaml`;
147
- fs.writeFileSync(yamlPath, secretYaml, 'utf8');
148
- }
149
-
150
- process.exit(0);
151
- }
152
- if (process.argv.includes('conf')) {
153
- if (!fs.existsSync(`../${repoName}`)) {
154
- shellExec(`cd .. && git clone ${gitUrl}`, { silent: true });
155
- } else {
156
- shellExec(`cd ../${repoName} && git pull`);
157
- }
158
- const toPath = `../${repoName}/conf/${confName}`;
159
- fs.removeSync(toPath);
160
- fs.mkdirSync(toPath, { recursive: true });
161
- fs.copySync(`./engine-private/conf/${confName}`, toPath);
162
- shellExec(
163
- `cd ../${repoName}` +
164
- ` && git add .` +
165
- ` && git commit -m "ci(engine-core-conf): ⚙️ Update ${confName} conf"` +
166
- ` && git push`,
167
- );
30
+ if (process.argv.includes('clean')) {
31
+ if (fs.existsSync(`${basePath}/images`)) fs.copySync(`${basePath}/images`, `./images`);
32
+ shellExec(`cd ${basePath} && git checkout .`);
33
+ shellExec(`cd ${basePath} && git clean -f -d`);
168
34
  process.exit(0);
169
35
  }
170
36
 
171
- if (process.argv.includes('cron-backups')) {
172
- if (!fs.existsSync(`../${repoNameBackUp}`)) {
173
- shellExec(`cd .. && git clone ${gitBackUpUrl}`, { silent: true });
174
- } else {
175
- shellExec(`cd ../${repoNameBackUp} && git pull`);
176
- }
177
- const serverConf = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
178
- for (const host of Object.keys(serverConf)) {
179
- for (let path of Object.keys(serverConf[host])) {
180
- path = path.replaceAll('/', '-');
181
- const toPath = `../${repoNameBackUp}/${host}${path}`;
182
- const fromPath = `./engine-private/cron-backups/${host}${path}`;
183
- if (fs.existsSync(fromPath)) {
184
- if (fs.existsSync(toPath)) fs.removeSync(toPath);
185
- logger.info('Build', { fromPath, toPath });
186
- fs.copySync(fromPath, toPath);
187
- }
37
+ if (process.argv.includes('conf')) {
38
+ for (const _confName of (confName === 'dd'
39
+ ? fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8')
40
+ : confName
41
+ ).split(',')) {
42
+ const _repoName = `engine-${_confName.split('dd-')[1]}`;
43
+ const privateRepoName = `${_repoName}-private`;
44
+ const privateGitUri = `${process.env.GITHUB_USERNAME}/${privateRepoName}`;
45
+
46
+ if (!fs.existsSync(`../${privateRepoName}`)) {
47
+ shellExec(`cd .. && underpost clone ${privateGitUri}`, { silent: true });
48
+ } else {
49
+ shellExec(`cd ../${privateRepoName} && underpost pull . ${privateGitUri}`);
188
50
  }
51
+ const toPath = `../${privateRepoName}/conf/${_confName}`;
52
+ fs.removeSync(toPath);
53
+ fs.mkdirSync(toPath, { recursive: true });
54
+ fs.copySync(`./engine-private/conf/${_confName}`, toPath);
55
+ if (fs.existsSync(`./engine-private/replica`)) {
56
+ const replicas = await fs.readdir(`./engine-private/replica`);
57
+ for (const replica of replicas)
58
+ if (replica.match(_confName))
59
+ fs.copySync(`./engine-private/replica/${replica}`, `../${privateRepoName}/replica/${replica}`);
60
+ }
61
+ shellExec(
62
+ `cd ../${privateRepoName}` +
63
+ ` && git add .` +
64
+ ` && underpost cmt . ci engine-core-conf 'Update ${_confName} conf'` +
65
+ ` && underpost push . ${privateGitUri}`,
66
+ );
189
67
  }
190
- shellExec(
191
- `cd ../${repoNameBackUp}` +
192
- ` && git add .` +
193
- ` && git commit -m "ci(engine-core-cron-backups): ⚙️ Update ${confName} cron backups"` +
194
- ` && git push`,
195
- );
196
68
  process.exit(0);
197
69
  }
198
70
 
199
- if (process.argv.includes('test')) {
200
- fs.mkdirSync(`${basePath}/engine-private/conf`, { recursive: true });
201
- fs.copySync(`./engine-private/conf/${confName}`, `${basePath}/engine-private/conf/${confName}`);
202
- }
203
-
204
71
  const { DefaultConf } = await import(`../conf.${confName}.js`);
205
72
 
206
73
  {
@@ -274,5 +141,21 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
274
141
 
275
142
  const packageJson = JSON.parse(fs.readFileSync(`${basePath}/package.json`, 'utf8'));
276
143
  packageJson.name = repoName;
277
- fs.writeFileSync(`${basePath}/package.json`, JSON.stringify(packageJson, null, 4), 'utf8');
144
+ fs.writeFileSync(
145
+ `${basePath}/package.json`,
146
+ JSON.stringify(packageJson, null, 4).replaceAll('pwa-microservices-template', repoName),
147
+ 'utf8',
148
+ );
149
+
150
+ fs.copySync(`./src/cli`, `${basePath}/src/cli`);
151
+ if (!fs.existsSync(`${basePath}/images`)) fs.mkdirSync(`${basePath}/images`);
152
+
153
+ const env = process.argv.includes('development') ? 'development' : 'production';
154
+ const deploymentsFiles = ['Dockerfile', 'proxy.yaml', 'deployment.yaml', 'secret.yaml'];
155
+ // remove engine-private of .dockerignore for local testing
156
+ for (const file of deploymentsFiles) {
157
+ if (fs.existsSync(`./manifests/deployment/${confName}-${env}/${file}`)) {
158
+ fs.copyFileSync(`./manifests/deployment/${confName}-${env}/${file}`, `${basePath}/${file}`);
159
+ }
160
+ }
278
161
  }
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';
@@ -159,10 +159,6 @@ try {
159
159
  }
160
160
  break;
161
161
 
162
- case 'remove-await-deploy': {
163
- if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
164
- break;
165
- }
166
162
  case 'new-nodejs-app':
167
163
  {
168
164
  const deployId = process.argv[3];
@@ -229,6 +225,7 @@ try {
229
225
  break;
230
226
  case 'build-full-client':
231
227
  {
228
+ dotenv.config({ override: true });
232
229
  if (!process.argv[3]) process.argv[3] = 'default';
233
230
  const { deployId, folder } = loadConf(process.argv[3]);
234
231
 
@@ -254,20 +251,7 @@ try {
254
251
  serverConf[host][path].replicas.map((replica) => buildReplicaId({ deployId, replica })),
255
252
  );
256
253
 
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
- }
254
+ // shellExec(Cmd.replica(deployId, host, path));
271
255
  }
272
256
  }
273
257
  }
@@ -276,7 +260,7 @@ try {
276
260
  await buildClient();
277
261
 
278
262
  for (const replicaDeployId of deployIdSingleReplicas) {
279
- shellExec(Cmd.conf(replicaDeployId));
263
+ shellExec(Cmd.conf(replicaDeployId, process.env.NODE_ENV));
280
264
  shellExec(Cmd.build(replicaDeployId));
281
265
  }
282
266
  }
@@ -546,13 +530,7 @@ try {
546
530
  ? envInstanceObj.port
547
531
  : envInstanceObj.port + port - singleReplicaHosts.length - (replicaHost ? 1 : 0);
548
532
 
549
- fs.writeFileSync(
550
- envPath,
551
- Object.keys(envObj)
552
- .map((key) => `${key}=${envObj[key]}`)
553
- .join(`\n`),
554
- 'utf8',
555
- );
533
+ writeEnv(envPath, envObj);
556
534
  }
557
535
  const serverConf = loadReplicas(
558
536
  JSON.parse(fs.readFileSync(`${baseConfPath}/${deployId}/conf.server.json`, 'utf8')),
@@ -596,6 +574,7 @@ try {
596
574
  }
597
575
  case 'build-uml':
598
576
  {
577
+ const plantuml = await import('plantuml');
599
578
  const folder = process.argv[3] ? process.argv[3] : `./src/client/public/default/plantuml`;
600
579
  const confData = Config.default;
601
580