@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
@@ -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: |
44
+ npm install -g underpost
45
+ underpost config set GITHUB_TOKEN ${{ secrets.GIT_AUTH_TOKEN }}
85
46
  npm 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
+ npm 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,10 +38,11 @@ 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 -g underpost
45
46
  npm 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
@@ -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
 
@@ -42,6 +42,7 @@
42
42
  "Itemledger",
43
43
  "jsonld",
44
44
  "lampp",
45
+ "letsencrypt",
45
46
  "loadingio",
46
47
  "Longname",
47
48
  "metanarrative",
@@ -59,9 +60,11 @@
59
60
  "runas",
60
61
  "Scatterplot",
61
62
  "sortablejs",
63
+ "statefulset",
62
64
  "supervisord",
63
65
  "Tokenomics",
64
66
  "underpost",
67
+ "underpostnet",
65
68
  "Unequip",
66
69
  "uuidv",
67
70
  "Valkey",
@@ -113,5 +116,11 @@
113
116
  "editor.defaultFormatter": "foxundermoon.shell-format"
114
117
  },
115
118
  "docwriter.progress.trackTypes": true,
116
- "docwriter.hotkey.mac": "⌘ + ."
119
+ "docwriter.hotkey.mac": "⌘ + .",
120
+ "[dotenv]": {
121
+ "editor.defaultFormatter": "foxundermoon.shell-format"
122
+ },
123
+ "[shellscript]": {
124
+ "editor.defaultFormatter": "foxundermoon.shell-format"
125
+ }
117
126
  }
package/CHANGELOG.md CHANGED
@@ -4,6 +4,46 @@ 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.521](https://github.com/underpostnet/engine/compare/v2.8.51...v2.8.521)
8
+
9
+ > 4 March 2025
10
+
11
+ - ci(package-pwa-microservices-template): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`5878342`](https://github.com/underpostnet/engine/commit/587834206f07a508b3e12ff5b5727c5979c06499)
12
+ - ci(package-pwa-microservices-template): ⚙️ update version 2.8.521 [`5fada73`](https://github.com/underpostnet/engine/commit/5fada73abf960567f4ecdc01062a987f4d7b4e79)
13
+ - fix(cli): 🐛 run prod img [`94743ef`](https://github.com/underpostnet/engine/commit/94743efe2cf214f0dbcf4db9f0b83ecf50b396f5)
14
+
15
+ #### [v2.8.51](https://github.com/underpostnet/engine/compare/v2.8.46...v2.8.51)
16
+
17
+ > 4 March 2025
18
+
19
+ - ci: ⚙️ add dd-core-development yamls [`a236466`](https://github.com/underpostnet/engine/commit/a2364666f5ddc0e824fa8b68b203bb9e021cca0c)
20
+ - refactor(cli): 📦 cron jobs management refactor [`8c28689`](https://github.com/underpostnet/engine/commit/8c28689cd514ee0e30a38be22ca3dbd292aa3a8a)
21
+ - ci(package-pwa-microservices-template): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`dd3557b`](https://github.com/underpostnet/engine/commit/dd3557bc52724d9231a0a13a320108758b6a84d2)
22
+
23
+ #### [v2.8.46](https://github.com/underpostnet/engine/compare/v2.8.44...v2.8.46)
24
+
25
+ > 28 February 2025
26
+
27
+ - refactor(add cli module directory): 📦 A code change that neither fixes a bug nor adds a feature [`56eea01`](https://github.com/underpostnet/engine/commit/56eea0121489998945c1b2040c3fc53cf6ee295c)
28
+ - refactor(bin): 📦 static API method access [`dcac59e`](https://github.com/underpostnet/engine/commit/dcac59e0cc3fb3e7eeef490d7ded3adb921f4e7a)
29
+ - ci(package-pwa-microservices-template): ⚙️ update version 2.8.45 [`11795eb`](https://github.com/underpostnet/engine/commit/11795eb2b57243530bfd027774005a83edbdee3b)
30
+
31
+ #### [v2.8.44](https://github.com/underpostnet/engine/compare/v2.8.42...v2.8.44)
32
+
33
+ > 18 February 2025
34
+
35
+ - ci(package-pwa-microservices-template): ⚙️ update version 2.8.44 [`1d1731d`](https://github.com/underpostnet/engine/commit/1d1731d8c81389f9ba6a308af9a66e455baa8fad)
36
+ - 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)
37
+ - ci(package-pwa-microservices-template): ⚙️ add underpost cli root env management [`1923fb6`](https://github.com/underpostnet/engine/commit/1923fb6b32c1d2df1564fb94d3475b4ef0400f99)
38
+
39
+ #### [v2.8.42](https://github.com/underpostnet/engine/compare/v2.8.31...v2.8.42)
40
+
41
+ > 18 February 2025
42
+
43
+ - 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)
44
+ - 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)
45
+ - 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)
46
+
7
47
  #### [v2.8.31](https://github.com/underpostnet/engine/compare/v2.8.1...v2.8.31)
8
48
 
9
49
  > 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,69 @@ 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]}`;
23
+ const deployList = (confName === 'dd' ? fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8') : confName).split(
24
+ ',',
25
+ );
26
26
 
27
27
  logger.info('', {
28
28
  confName,
29
- // gitUrl,
30
29
  repoName,
31
- repoNameBackUp,
32
30
  basePath,
31
+ deployList,
33
32
  });
34
33
 
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
- });
34
+ if (process.argv.includes('clean')) {
35
+ if (fs.existsSync(`${basePath}/images`)) fs.copySync(`${basePath}/images`, `./images`);
36
+ shellExec(`cd ${basePath} && git checkout .`);
37
+ shellExec(`cd ${basePath} && git clean -f -d`);
38
+ process.exit(0);
39
+ }
106
40
 
107
- if (peer) {
108
- // logger.info('', { host, port: port + 1, path: '/peer' });
109
- pathPortConditions.push({
110
- port: port + 1,
111
- path: '/peer',
112
- });
113
- }
41
+ if (process.argv.includes('conf')) {
42
+ for (const _confName of deployList) {
43
+ const _repoName = `engine-${_confName.split('dd-')[1]}`;
44
+ const privateRepoName = `${_repoName}-private`;
45
+ const privateGitUri = `${process.env.GITHUB_USERNAME}/${privateRepoName}`;
46
+
47
+ if (!fs.existsSync(`../${privateRepoName}`)) {
48
+ shellExec(`cd .. && underpost clone ${privateGitUri}`, { silent: true });
49
+ } else {
50
+ shellExec(`cd ../${privateRepoName} && underpost pull . ${privateGitUri}`);
114
51
  }
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}`
52
+ const toPath = `../${privateRepoName}/conf/${_confName}`;
53
+ fs.removeSync(toPath);
54
+ fs.mkdirSync(toPath, { recursive: true });
55
+ fs.copySync(`./engine-private/conf/${_confName}`, toPath);
56
+ if (fs.existsSync(`./engine-private/replica`)) {
57
+ const replicas = await fs.readdir(`./engine-private/replica`);
58
+ for (const replica of replicas)
59
+ if (replica.match(_confName))
60
+ fs.copySync(`./engine-private/replica/${replica}`, `../${privateRepoName}/replica/${replica}`);
130
61
  }
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}`;
62
+ if (fs.existsSync(`./engine-private/itc-scripts`)) {
63
+ const itcScripts = await fs.readdir(`./engine-private/itc-scripts`);
64
+ for (const itcScript of itcScripts)
65
+ if (itcScript.match(_confName))
66
+ fs.copySync(`./engine-private/itc-scripts/${itcScript}`, `../${privateRepoName}/itc-scripts/${itcScript}`);
141
67
  }
68
+ shellExec(
69
+ `cd ../${privateRepoName}` +
70
+ ` && git add .` +
71
+ ` && underpost cmt . ci engine-core-conf 'Update ${_confName} conf'` +
72
+ ` && underpost push . ${privateGitUri}`,
73
+ );
142
74
  }
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
- );
168
75
  process.exit(0);
169
76
  }
170
77
 
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`);
78
+ if (confName === 'dd') {
79
+ for (const _confName of deployList) {
80
+ shellExec(`node bin/build ${_confName}`);
176
81
  }
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
- }
188
- }
189
- }
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
82
  process.exit(0);
197
83
  }
198
84
 
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
85
  const { DefaultConf } = await import(`../conf.${confName}.js`);
205
86
 
206
87
  {
@@ -266,13 +147,40 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
266
147
  }
267
148
  }
268
149
 
150
+ shellExec(`node bin/deploy update-default-conf ${confName}`);
151
+
269
152
  fs.copyFileSync(`./conf.${confName}.js`, `${basePath}/conf.js`);
270
153
  fs.copyFileSync(
271
154
  `./.github/workflows/engine.${confName.split('dd-')[1]}.ci.yml`,
272
155
  `${basePath}/.github/workflows/engine.${confName.split('dd-')[1]}.ci.yml`,
273
156
  );
274
157
 
158
+ switch (confName) {
159
+ case 'dd-cyberia':
160
+ fs.copyFileSync(`./bin/cyberia.js`, `${basePath}/bin/cyberia.js`);
161
+ break;
162
+
163
+ default:
164
+ break;
165
+ }
166
+
275
167
  const packageJson = JSON.parse(fs.readFileSync(`${basePath}/package.json`, 'utf8'));
276
168
  packageJson.name = repoName;
277
- fs.writeFileSync(`${basePath}/package.json`, JSON.stringify(packageJson, null, 4), 'utf8');
169
+ fs.writeFileSync(
170
+ `${basePath}/package.json`,
171
+ JSON.stringify(packageJson, null, 4).replaceAll('pwa-microservices-template', repoName),
172
+ 'utf8',
173
+ );
174
+
175
+ fs.copySync(`./src/cli`, `${basePath}/src/cli`);
176
+ if (!fs.existsSync(`${basePath}/images`)) fs.mkdirSync(`${basePath}/images`);
177
+
178
+ const env = process.argv.includes('development') ? 'development' : 'production';
179
+ const deploymentsFiles = ['Dockerfile', 'proxy.yaml', 'deployment.yaml', 'secret.yaml'];
180
+ // remove engine-private of .dockerignore for local testing
181
+ for (const file of deploymentsFiles) {
182
+ if (fs.existsSync(`./manifests/deployment/${confName}-${env}/${file}`)) {
183
+ fs.copyFileSync(`./manifests/deployment/${confName}-${env}/${file}`, `${basePath}/${file}`);
184
+ }
185
+ }
278
186
  }