cyberia 3.2.9 → 3.2.22

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 (184) hide show
  1. package/.github/workflows/engine-cyberia.cd.yml +7 -0
  2. package/.github/workflows/engine-cyberia.ci.yml +14 -2
  3. package/.github/workflows/ghpkg.ci.yml +1 -0
  4. package/.github/workflows/npmpkg.ci.yml +10 -5
  5. package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
  6. package/.github/workflows/release.cd.yml +1 -0
  7. package/.vscode/extensions.json +9 -9
  8. package/.vscode/settings.json +20 -4
  9. package/CHANGELOG.md +363 -1
  10. package/CLI-HELP.md +975 -1061
  11. package/README.md +190 -348
  12. package/bin/build.js +102 -125
  13. package/bin/build.template.js +33 -0
  14. package/bin/cyberia.js +238 -56
  15. package/bin/deploy.js +16 -3
  16. package/bin/index.js +238 -56
  17. package/bump.config.js +26 -0
  18. package/conf.js +131 -24
  19. package/deployment.yaml +76 -2
  20. package/hardhat/package-lock.json +113 -144
  21. package/hardhat/package.json +4 -3
  22. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +2 -2
  23. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
  24. package/manifests/deployment/dd-cyberia-development/deployment.yaml +76 -2
  25. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  26. package/manifests/kind-config-dev.yaml +8 -0
  27. package/manifests/lxd/lxd-admin-profile.yaml +12 -3
  28. package/manifests/mongodb/pv-pvc.yaml +44 -8
  29. package/manifests/mongodb/statefulset.yaml +55 -68
  30. package/manifests/mongodb-4.4/headless-service.yaml +10 -0
  31. package/manifests/mongodb-4.4/kustomization.yaml +3 -1
  32. package/manifests/mongodb-4.4/mongodb-nodeport.yaml +17 -0
  33. package/manifests/mongodb-4.4/pv-pvc.yaml +10 -14
  34. package/manifests/mongodb-4.4/statefulset.yaml +79 -0
  35. package/manifests/mongodb-4.4/storage-class.yaml +9 -0
  36. package/manifests/valkey/statefulset.yaml +1 -1
  37. package/manifests/valkey/valkey-nodeport.yaml +17 -0
  38. package/package.json +31 -19
  39. package/scripts/ipxe-setup.sh +52 -49
  40. package/scripts/k3s-node-setup.sh +81 -46
  41. package/scripts/link-local-underpost-cli.sh +6 -0
  42. package/scripts/lxd-vm-setup.sh +193 -8
  43. package/scripts/maas-nat-firewalld.sh +145 -0
  44. package/scripts/test-monitor.sh +250 -0
  45. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +38 -33
  46. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +16 -16
  47. package/src/api/core/core.router.js +19 -14
  48. package/src/api/core/core.service.js +5 -5
  49. package/src/api/crypto/crypto.router.js +18 -12
  50. package/src/api/crypto/crypto.service.js +3 -3
  51. package/src/api/cyberia-action/cyberia-action.model.js +1 -1
  52. package/src/api/cyberia-action/cyberia-action.router.js +22 -18
  53. package/src/api/cyberia-action/cyberia-action.service.js +5 -5
  54. package/src/api/cyberia-client-hints/cyberia-client-hints.controller.js +74 -0
  55. package/src/api/cyberia-client-hints/cyberia-client-hints.model.js +99 -0
  56. package/src/api/cyberia-client-hints/cyberia-client-hints.router.js +98 -0
  57. package/src/api/cyberia-client-hints/cyberia-client-hints.service.js +152 -0
  58. package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +25 -20
  59. package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +6 -6
  60. package/src/api/cyberia-entity/cyberia-entity.router.js +22 -18
  61. package/src/api/cyberia-entity/cyberia-entity.service.js +5 -5
  62. package/src/api/cyberia-instance/cyberia-fallback-world.js +79 -4
  63. package/src/api/cyberia-instance/cyberia-instance.router.js +57 -52
  64. package/src/api/cyberia-instance/cyberia-instance.service.js +10 -10
  65. package/src/api/cyberia-instance/cyberia-world-generator.js +3 -3
  66. package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +14 -48
  67. package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +22 -18
  68. package/src/api/cyberia-instance-conf/cyberia-instance-conf.service.js +5 -5
  69. package/src/api/cyberia-map/cyberia-map.router.js +35 -30
  70. package/src/api/cyberia-map/cyberia-map.service.js +7 -7
  71. package/src/api/cyberia-quest/cyberia-quest.model.js +1 -1
  72. package/src/api/cyberia-quest/cyberia-quest.router.js +22 -18
  73. package/src/api/cyberia-quest/cyberia-quest.service.js +5 -5
  74. package/src/api/cyberia-quest-progress/cyberia-quest-progress.router.js +22 -18
  75. package/src/api/cyberia-quest-progress/cyberia-quest-progress.service.js +5 -5
  76. package/src/api/cyberia-server-defaults/cyberia-server-defaults.js +458 -0
  77. package/src/api/default/default.router.js +22 -18
  78. package/src/api/default/default.service.js +5 -5
  79. package/src/api/document/document.router.js +28 -23
  80. package/src/api/document/document.service.js +100 -23
  81. package/src/api/file/file.router.js +19 -13
  82. package/src/api/file/file.service.js +9 -7
  83. package/src/api/instance/instance.router.js +29 -24
  84. package/src/api/instance/instance.service.js +6 -6
  85. package/src/api/ipfs/ipfs.router.js +21 -16
  86. package/src/api/ipfs/ipfs.service.js +8 -8
  87. package/src/api/object-layer/object-layer.router.js +512 -507
  88. package/src/api/object-layer/object-layer.service.js +17 -14
  89. package/src/api/object-layer-render-frames/object-layer-render-frames.router.js +22 -18
  90. package/src/api/object-layer-render-frames/object-layer-render-frames.service.js +5 -5
  91. package/src/api/test/test.router.js +17 -12
  92. package/src/api/types.js +24 -0
  93. package/src/api/user/guest.service.js +5 -4
  94. package/src/api/user/user.router.js +297 -288
  95. package/src/api/user/user.service.js +100 -35
  96. package/src/cli/baremetal.js +132 -101
  97. package/src/cli/cluster.js +700 -232
  98. package/src/cli/db.js +59 -60
  99. package/src/cli/deploy.js +291 -294
  100. package/src/cli/env.js +1 -4
  101. package/src/cli/fs.js +13 -3
  102. package/src/cli/image.js +58 -4
  103. package/src/cli/index.js +127 -15
  104. package/src/cli/ipfs.js +4 -6
  105. package/src/cli/kubectl.js +4 -1
  106. package/src/cli/lxd.js +1099 -223
  107. package/src/cli/monitor.js +396 -9
  108. package/src/cli/release.js +355 -146
  109. package/src/cli/repository.js +169 -30
  110. package/src/cli/run.js +347 -117
  111. package/src/cli/secrets.js +11 -2
  112. package/src/cli/test.js +9 -3
  113. package/src/client/Default.index.js +9 -3
  114. package/src/client/components/core/Auth.js +5 -0
  115. package/src/client/components/core/ClientEvents.js +76 -0
  116. package/src/client/components/core/EventBus.js +4 -0
  117. package/src/client/components/core/Modal.js +82 -41
  118. package/src/client/components/core/PanelForm.js +14 -10
  119. package/src/client/components/core/Worker.js +162 -363
  120. package/src/client/components/cyberia/MapEngineCyberia.js +1 -1
  121. package/src/client/components/cyberia/SharedDefaultsCyberia.js +330 -0
  122. package/src/client/public/cyberia-docs/ACTION-SYSTEM.md +55 -1
  123. package/src/client/public/cyberia-docs/ARCHITECTURE.md +223 -361
  124. package/src/client/public/cyberia-docs/CYBERIA-CLI.md +114 -327
  125. package/src/client/public/cyberia-docs/CYBERIA-CLIENT.md +200 -222
  126. package/src/client/public/cyberia-docs/CYBERIA-SERVER.md +212 -185
  127. package/src/client/public/cyberia-docs/CYBERIA.md +259 -0
  128. package/src/client/public/cyberia-docs/OFF-CHAIN-ECONOMY.md +2 -2
  129. package/src/client/public/cyberia-docs/QUEST-SYSTEM.md +23 -1
  130. package/src/client/public/cyberia-docs/ROADMAP.md +1 -1
  131. package/src/client/public/cyberia-docs/UNDERPOST-PLATFORM.md +106 -0
  132. package/src/client/public/cyberia-docs/WHITE-PAPER.md +1 -1
  133. package/src/client/services/cyberia-client-hints/cyberia-client-hints.service.js +99 -0
  134. package/src/client/ssr/views/CyberiaServerMetrics.js +982 -0
  135. package/src/client/sw/core.sw.js +174 -112
  136. package/src/db/DataBaseProvider.js +115 -15
  137. package/src/db/mariadb/MariaDB.js +2 -1
  138. package/src/db/mongo/MongoBootstrap.js +657 -0
  139. package/src/db/mongo/MongooseDB.js +130 -21
  140. package/src/grpc/cyberia/grpc-server.js +25 -57
  141. package/src/index.js +1 -1
  142. package/src/runtime/cyberia-client/Dockerfile +10 -7
  143. package/src/runtime/cyberia-client/Dockerfile.dev +67 -0
  144. package/src/runtime/cyberia-server/Dockerfile +11 -6
  145. package/src/runtime/cyberia-server/Dockerfile.dev +47 -0
  146. package/src/runtime/express/Express.js +2 -2
  147. package/src/runtime/wp/Dockerfile +3 -3
  148. package/src/runtime/wp/Wp.js +8 -5
  149. package/src/server/auth.js +2 -2
  150. package/src/server/catalog-underpost.js +61 -0
  151. package/src/server/catalog.js +77 -0
  152. package/src/server/client-build-docs.js +1 -1
  153. package/src/server/client-build.js +94 -129
  154. package/src/server/conf.js +496 -135
  155. package/src/server/ipfs-client.js +5 -3
  156. package/src/server/process.js +180 -19
  157. package/src/server/proxy.js +9 -2
  158. package/src/server/runtime-status.js +235 -0
  159. package/src/server/runtime.js +1 -1
  160. package/src/server/start.js +44 -11
  161. package/src/server/valkey.js +2 -0
  162. package/src/ws/IoInterface.js +16 -16
  163. package/src/ws/core/channels/core.ws.chat.js +11 -11
  164. package/src/ws/core/channels/core.ws.mailer.js +29 -29
  165. package/src/ws/core/channels/core.ws.stream.js +19 -19
  166. package/src/ws/core/core.ws.connection.js +8 -8
  167. package/src/ws/core/core.ws.server.js +6 -5
  168. package/src/ws/default/channels/default.ws.main.js +10 -10
  169. package/src/ws/default/default.ws.connection.js +4 -4
  170. package/src/ws/default/default.ws.server.js +4 -3
  171. package/test/deploy-monitor.test.js +251 -0
  172. package/bin/file.js +0 -202
  173. package/bin/vs.js +0 -74
  174. package/bin/zed.js +0 -84
  175. package/manifests/deployment/dd-test-development/deployment.yaml +0 -254
  176. package/manifests/deployment/dd-test-development/proxy.yaml +0 -102
  177. package/src/api/cyberia-instance-conf/cyberia-instance-conf.defaults.js +0 -574
  178. package/src/client/components/cyberia-portal/CommonCyberiaPortal.js +0 -467
  179. package/src/client/ssr/email/DefaultRecoverEmail.js +0 -21
  180. package/src/client/ssr/email/DefaultVerifyEmail.js +0 -17
  181. package/src/client/ssr/pages/CyberiaServerMetrics.js +0 -461
  182. /package/src/client/ssr/{offline → views}/Maintenance.js +0 -0
  183. /package/src/client/ssr/{offline → views}/NoNetworkConnection.js +0 -0
  184. /package/src/client/ssr/{pages → views}/Test.js +0 -0
package/bin/build.js CHANGED
@@ -1,104 +1,65 @@
1
+ #! /usr/bin/env node
2
+
3
+ import { Command } from 'commander';
1
4
  import fs from 'fs-extra';
2
- import { loggerFactory } from '../src/server/logger.js';
3
- import { shellExec } from '../src/server/process.js';
4
5
  import dotenv from 'dotenv';
6
+ import { loggerFactory } from '../src/server/logger.js';
5
7
  import { getCapVariableName } from '../src/client/components/core/CommonJs.js';
6
- import { getPathsSSR } from '../src/server/conf.js';
8
+ import {
9
+ getPathsSSR,
10
+ resolveDeployList,
11
+ syncPrivateConf,
12
+ syncDeployIdSources,
13
+ buildTemplate,
14
+ updatePrivateEngineTestRepo,
15
+ } from '../src/server/conf.js';
16
+ import { loadDeployCatalog } from '../src/server/catalog.js';
17
+ import UnderpostRepository from '../src/cli/repository.js';
7
18
 
8
19
  const baseConfPath = './engine-private/conf/dd-cron/.env.production';
9
20
  if (fs.existsSync(baseConfPath)) dotenv.config({ path: baseConfPath, override: true });
10
21
 
11
22
  const logger = loggerFactory(import.meta);
12
23
 
13
- const confName = process.argv[2];
14
24
  const basePath = '../pwa-microservices-template';
15
- const repoName = `engine-${confName.split('dd-')[1]}`;
16
- const deployList = (confName === 'dd' ? fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8') : confName).split(
17
- ',',
18
- );
19
-
20
- logger.info('Build repository', {
21
- confName,
22
- repoName,
23
- basePath,
24
- deployList,
25
- });
26
-
27
- if (process.argv.includes('conf')) {
28
- for (const _confName of deployList) {
29
- const _repoName = `engine-${_confName.split('dd-')[1]}`;
30
- const privateRepoName = `${_repoName}-private`;
31
- const privateGitUri = `${process.env.GITHUB_USERNAME}/${privateRepoName}`;
32
-
33
- if (!fs.existsSync(`../${privateRepoName}`)) {
34
- shellExec(`cd .. && underpost clone ${privateGitUri}`, { silent: true });
35
- } else {
36
- shellExec(`cd ../${privateRepoName} && git checkout . && git clean -f -d && underpost pull . ${privateGitUri}`, {
37
- silent: true,
38
- });
39
- }
40
- const toPath = `../${privateRepoName}/conf/${_confName}`;
41
- fs.removeSync(toPath);
42
- fs.mkdirSync(toPath, { recursive: true });
43
- fs.copySync(`./engine-private/conf/${_confName}`, toPath);
44
- fs.removeSync(`../${privateRepoName}/replica`);
45
- if (fs.existsSync(`./engine-private/replica`)) {
46
- const replicas = await fs.readdir(`./engine-private/replica`);
47
- for (const replica of replicas)
48
- if (replica.match(_confName))
49
- fs.copySync(`./engine-private/replica/${replica}`, `../${privateRepoName}/replica/${replica}`);
50
- }
51
25
 
52
- if (fs.existsSync(`./engine-private/itc-scripts`)) {
53
- const itcScripts = await fs.readdir(`./engine-private/itc-scripts`);
54
- for (const itcScript of itcScripts)
55
- if (itcScript.match(_confName))
56
- fs.copySync(`./engine-private/itc-scripts/${itcScript}`, `../${privateRepoName}/itc-scripts/${itcScript}`);
57
- }
58
- switch (_confName) {
59
- case 'dd-cyberia':
60
- fs.copySync(`./engine-private/cyberia-instances/FOREST`, `../${privateRepoName}/cyberia-instances/FOREST`);
61
- break;
62
- default:
63
- break;
64
- }
65
- shellExec(
66
- `cd ../${privateRepoName}` +
67
- ` && git add .` +
68
- ` && underpost cmt . ci engine-core-conf 'Update ${_confName} conf'` +
69
- ` && underpost push . ${privateGitUri}`,
70
- {
71
- silent: true,
72
- },
73
- );
26
+ /**
27
+ * Assembles a single deploy id's public template under {@link basePath}: pulls in
28
+ * its deploy-id-specific public sources, then mirrors the APIs, client components,
29
+ * SSR assets, manifests, and packaging declared by its conf into the template repo.
30
+ * @param {string} confName - A concrete deploy id (e.g. `dd-prototype`).
31
+ */
32
+ const buildDeployTemplate = async (confName) => {
33
+ const repoName = `engine-${confName.split('dd-')[1]}`;
34
+ const catalog = await loadDeployCatalog(confName);
35
+
36
+ if (catalog.sourceMoves.length) {
37
+ UnderpostRepository.API.sparseCheckoutDirectory(`conf/${confName}`);
38
+ if (catalog.sourceMoves.some(([src]) => !fs.existsSync(src))) UnderpostRepository.API.pullSourceRepo(repoName);
74
39
  }
75
- process.exit(0);
76
- }
40
+ syncDeployIdSources(catalog.sourceMoves);
77
41
 
78
- if (confName === 'dd') {
79
- for (const _confName of deployList) {
80
- shellExec(`node bin/build ${_confName}`);
81
- }
82
- process.exit(0);
83
- }
42
+ const confDir = `./engine-private/conf/${confName}`;
43
+ const DefaultConf = {
44
+ server: JSON.parse(fs.readFileSync(`${confDir}/conf.server.json`, 'utf8')),
45
+ client: JSON.parse(fs.readFileSync(`${confDir}/conf.client.json`, 'utf8')),
46
+ ssr: JSON.parse(fs.readFileSync(`${confDir}/conf.ssr.json`, 'utf8')),
47
+ };
84
48
 
85
- const { DefaultConf } = await import(`../conf.${confName}.js`);
86
-
87
- {
88
49
  for (const host of Object.keys(DefaultConf.server)) {
89
50
  for (const path of Object.keys(DefaultConf.server[host])) {
90
51
  const { apis, ws } = DefaultConf.server[host][path];
91
52
  if (apis)
92
53
  for (const api of apis) {
93
- {
94
- const originPath = `./src/api/${api}`;
95
- logger.info(`Build`, originPath);
96
- fs.copySync(originPath, `${basePath}/src/api/${api}`);
54
+ const apiSrc = `./src/api/${api}`;
55
+ if (fs.existsSync(apiSrc)) {
56
+ logger.info(`Build`, apiSrc);
57
+ fs.copySync(apiSrc, `${basePath}/src/api/${api}`);
97
58
  }
98
- {
99
- const originPath = `./src/client/services/${api}`;
100
- logger.info(`Build`, originPath);
101
- fs.copySync(originPath, `${basePath}/src/client/services/${api}`);
59
+ const serviceSrc = `./src/client/services/${api}`;
60
+ if (fs.existsSync(serviceSrc)) {
61
+ logger.info(`Build`, serviceSrc);
62
+ fs.copySync(serviceSrc, `${basePath}/src/client/services/${api}`);
102
63
  }
103
64
  }
104
65
 
@@ -107,9 +68,7 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
107
68
  }
108
69
  }
109
70
  }
110
- }
111
71
 
112
- {
113
72
  for (const client of Object.keys(DefaultConf.client)) {
114
73
  const capName = getCapVariableName(client);
115
74
  for (const component of Object.keys(DefaultConf.client[client].components)) {
@@ -134,9 +93,7 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
134
93
  }
135
94
  }
136
95
  }
137
- }
138
96
 
139
- {
140
97
  for (const client of Object.keys(DefaultConf.ssr)) {
141
98
  const ssrPaths = getPathsSSR(DefaultConf.ssr[client]);
142
99
  for (const originPath of ssrPaths) {
@@ -148,63 +105,40 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
148
105
  }
149
106
 
150
107
  if (!fs.existsSync(`${basePath}/.github/workflows`))
151
- fs.mkdirSync(`${basePath}/.github/workflows`, {
152
- recursive: true,
153
- });
108
+ fs.mkdirSync(`${basePath}/.github/workflows`, { recursive: true });
154
109
 
155
110
  const originPackageJson = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
156
111
  const packageJson = JSON.parse(fs.readFileSync(`${basePath}/package.json`, 'utf8'));
157
112
  packageJson.name = repoName.replace('engine-', '');
158
113
 
159
114
  switch (confName) {
160
- case 'dd-cyberia':
115
+ case 'dd-cyberia': {
161
116
  fs.copyFileSync(`./bin/cyberia.js`, `${basePath}/bin/cyberia.js`);
162
117
  fs.copyFileSync(
163
118
  `./.github/workflows/publish.cyberia.ci.yml`,
164
119
  `${basePath}/.github/workflows/publish.cyberia.ci.yml`,
165
120
  );
166
- delete packageJson.bin.underpost;
121
+ if (packageJson.bin) delete packageJson.bin.underpost;
122
+ if (!packageJson.bin) packageJson.bin = {};
167
123
  packageJson.bin.cyberia = 'bin/index.js';
168
- packageJson.keywords = [
169
- 'cyberia',
170
- 'object-layer',
171
- 'game-engine',
172
- 'assets-management',
173
- 'web3',
174
- 'atlas-sprite-sheet',
175
- ];
176
- packageJson.description = 'Cyberia Engine - Object Layer and Assets Management Microservice';
177
- const { CyberiaDependencies } = await import(`../src/client/components/cyberia-portal/CommonCyberiaPortal.js`);
124
+ packageJson.keywords = catalog.keywords;
125
+ packageJson.description = catalog.description;
126
+ const { CyberiaDependencies } = await import(`../src/api/cyberia-server-defaults/cyberia-server-defaults.js`);
178
127
  packageJson.dependencies = {
179
128
  ...originPackageJson.dependencies,
180
129
  ...CyberiaDependencies,
181
130
  };
182
131
  fs.writeFileSync(`${basePath}/bin/index.js`, fs.readFileSync(`./bin/cyberia.js`, 'utf8'), 'utf8');
132
+ // Canonical Cyberia doc; engine-cyberia/README.md is a generated copy — never hand-edited.
183
133
  fs.writeFileSync(
184
134
  `${basePath}/README.md`,
185
- fs.readFileSync(`./src/client/public/cyberia-docs/CYBERIA-CLI.md`, 'utf8'),
135
+ fs.readFileSync(`./src/client/public/cyberia-docs/CYBERIA.md`, 'utf8'),
186
136
  'utf8',
187
137
  );
188
138
  fs.copySync(`./hardhat`, `${basePath}/hardhat`);
189
- for (const path of [
190
- '/src/grpc/cyberia',
191
- '/src/client/ssr/pages/CyberiaServerMetrics.js',
192
- '/src/server/object-layer.js',
193
- '/src/server/atlas-sprite-sheet-generator.js',
194
- '/src/server/shape-generator.js',
195
- '/src/server/semantic-layer-generator.js',
196
- '/src/server/semantic-layer-generator-floor.js',
197
- '/src/server/semantic-layer-generator-skin.js',
198
- '/src/server/semantic-layer-generator-resource.js',
199
- '/test/shape-generator.test.js',
200
- '/src/server/besu-genesis-generator.js',
201
- '/src/runtime/cyberia-server',
202
- '/src/runtime/cyberia-client',
203
- '/.github/workflows/hardhat.ci.yml',
204
- '/src/client/public/cyberia-docs',
205
- ])
206
- fs.copySync(`.${path}`, `${basePath}${path}`);
207
-
139
+ for (const path of catalog.templatePaths) fs.copySync(`.${path}`, `${basePath}${path}`);
140
+ break;
141
+ }
208
142
  default:
209
143
  break;
210
144
  }
@@ -232,8 +166,6 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
232
166
  `${basePath}/manifests/deployment/${confName}-development`,
233
167
  );
234
168
 
235
- // Copy conf.<deploy-id>.js to conf.js for the respective deployment
236
- fs.copyFileSync(`./conf.${confName}.js`, `${basePath}/conf.js`);
237
169
  fs.copyFileSync(`./manifests/deployment/${confName}-development/proxy.yaml`, `${basePath}/proxy.yaml`);
238
170
  fs.copyFileSync(`./manifests/deployment/${confName}-development/deployment.yaml`, `${basePath}/deployment.yaml`);
239
171
  const pvPvcPath = `./manifests/deployment/${confName}-development/pv-pvc.yaml`;
@@ -242,6 +174,51 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
242
174
  if (fs.existsSync(`./src/ws/${confName.split('-')[1]}`)) {
243
175
  fs.copySync(`./src/ws/${confName.split('-')[1]}`, `${basePath}/src/ws/${confName.split('-')[1]}`);
244
176
  }
245
- fs.copyFileSync(`.gitignore`, `${basePath}/.gitignore`);
246
- shellExec(`cd ${basePath} && npm install --ignore-scripts`);
247
- }
177
+ fs.writeFileSync(
178
+ `${basePath}/.gitignore`,
179
+ fs.readFileSync(`.gitignore`, 'utf8').split('# Ignore ERP / CRM custom prototypes src')[0],
180
+ );
181
+ };
182
+
183
+ const program = new Command();
184
+
185
+ program
186
+ .name('build')
187
+ .description('Assemble deploy id public templates and sync their private configuration repos.')
188
+ .argument('<conf-name>', 'Deploy id, comma-separated list, or the "dd" meta id (fans out via dd.router).')
189
+ .argument('[env]', 'Environment label (informational; kept for CI invocation compatibility).')
190
+ .option('--conf', 'Sync each deploy id private configuration repo and exit (no template assembly).')
191
+ .option(
192
+ '--no-template-rebuild',
193
+ 'Skip the from-scratch base template reconstruction before assembly (assemble onto the existing template).',
194
+ )
195
+ .option(
196
+ '--update-private',
197
+ 'After assembling each deploy id, publish it to its private test source repo (underpostnet/engine-test-<id>) for isolated test deploys.',
198
+ false,
199
+ )
200
+ .action(async (confName, env, options) => {
201
+ const deployList = resolveDeployList(confName);
202
+ logger.info('Build repository', { confName, basePath, deployList, conf: !!options.conf });
203
+
204
+ if (options.conf) {
205
+ for (const deployId of deployList) {
206
+ const { privateConfPaths } = await loadDeployCatalog(deployId);
207
+ syncPrivateConf(deployId, privateConfPaths);
208
+ }
209
+ return;
210
+ }
211
+
212
+ // Reconstruct the base template from 0 before assembly so no src from a previous
213
+ // build run leaks into this one. Opt out with --no-template-rebuild.
214
+ if (options.templateRebuild) await buildTemplate({ toPath: basePath });
215
+
216
+ for (const deployId of deployList) {
217
+ await buildDeployTemplate(deployId);
218
+ // Publish the just-assembled tree to the deploy id's private test repo so a
219
+ // pod started with `--private-test-repo` clones this work-in-progress source.
220
+ if (options.updatePrivate) await updatePrivateEngineTestRepo(deployId);
221
+ }
222
+ });
223
+
224
+ await program.parseAsync();
@@ -0,0 +1,33 @@
1
+ #! /usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import fs from 'fs-extra';
5
+ import dotenv from 'dotenv';
6
+ import { loggerFactory } from '../src/server/logger.js';
7
+ import { buildTemplate, updatePrivateTemplateRepo } from '../src/server/conf.js';
8
+
9
+ if (fs.existsSync('./engine-private/conf/dd-cron/.env.production'))
10
+ dotenv.config({ path: `./engine-private/conf/dd-cron/.env.production`, override: true });
11
+ else dotenv.config();
12
+
13
+ const logger = loggerFactory(import.meta);
14
+
15
+ const program = new Command();
16
+
17
+ program
18
+ .name('build.template')
19
+ .description('Rebuild the standalone pwa-microservices-template from scratch out of the engine source tree.')
20
+ .argument('[src-path]', 'Engine source root to sync from.', './')
21
+ .argument('[to-path]', 'Template output path.', '../pwa-microservices-template')
22
+ .option('--update-private', 'Update private template repository', false)
23
+ .action(async (srcPath, toPath, options) => {
24
+ try {
25
+ if (options.updatePrivate) return await updatePrivateTemplateRepo();
26
+ await buildTemplate({ srcPath: srcPath.replaceAll(`'`, ''), toPath: toPath.replaceAll(`'`, '') });
27
+ } catch (error) {
28
+ logger.error(error, error.stack);
29
+ process.exit(1);
30
+ }
31
+ });
32
+
33
+ await program.parseAsync();