@underpostnet/cyberia 3.2.90 → 3.3.0

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 (129) hide show
  1. package/.env.example +16 -0
  2. package/.github/workflows/coverall.cyberia.ci.yml +87 -0
  3. package/.github/workflows/cyberia-client.cd.yml +1 -18
  4. package/.github/workflows/cyberia-server.cd.yml +1 -18
  5. package/.github/workflows/docker-image.cyberia-client.ci.yml +1 -1
  6. package/.github/workflows/docker-image.cyberia-client.dev.ci.yml +1 -1
  7. package/.github/workflows/docker-image.cyberia-server.ci.yml +1 -1
  8. package/.github/workflows/docker-image.cyberia-server.dev.ci.yml +1 -1
  9. package/.github/workflows/docker-image.engine-cyberia.ci.yml +1 -1
  10. package/.github/workflows/docker-image.engine-cyberia.dev.ci.yml +1 -1
  11. package/.github/workflows/engine-cyberia.cd.yml +3 -78
  12. package/.github/workflows/ghpkg.ci.yml +7 -1
  13. package/.github/workflows/pwa-microservices-template-page.cd.yml +1 -16
  14. package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
  15. package/.github/workflows/release.cd.yml +1 -9
  16. package/CHANGELOG.md +110 -1
  17. package/CLI-HELP.md +139 -9
  18. package/Dockerfile +1 -1
  19. package/Dockerfile.dev +1 -1
  20. package/Dockerfile.test +1 -1
  21. package/bin/build.js +7 -5
  22. package/bin/cyberia.js +73 -53
  23. package/bin/deploy.js +1 -1
  24. package/bin/index.js +73 -53
  25. package/compose.env +16 -0
  26. package/conf.js +2 -0
  27. package/deploy/dd-cyberia/deploy.sh +42 -0
  28. package/deploy/dd-cyberia/init.sh +63 -0
  29. package/deploy/dd-cyberia/sync-deploy.sh +194 -0
  30. package/deploy/lib/logging.sh +96 -0
  31. package/deploy/pwa-microservices-template/deploy.sh +72 -0
  32. package/deploy/release/deploy.sh +62 -0
  33. package/deployment.yaml +1 -1
  34. package/docker-compose.yml +31 -37
  35. package/hardhat/package-lock.json +9 -9
  36. package/hardhat/package.json +3 -3
  37. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +5 -1
  38. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
  39. package/manifests/cronjobs/dd-cron/dd-cron-vultr.yaml +52 -0
  40. package/manifests/deployment/dd-cyberia-development/deployment.yaml +1 -1
  41. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  42. package/package.json +2 -2
  43. package/scripts/audit-selinux.sh +64 -0
  44. package/scripts/coverall-test-cyberia.sh +24 -0
  45. package/scripts/coverall-test.sh +24 -0
  46. package/scripts/gpu-diag.sh +0 -0
  47. package/scripts/ip-info.sh +0 -0
  48. package/scripts/k3s-node-setup.sh +18 -15
  49. package/scripts/kubeadm-node-setup.sh +12 -23
  50. package/scripts/link-local-underpost-cli.sh +0 -0
  51. package/scripts/lxd-vm-setup.sh +0 -0
  52. package/scripts/maas-nat-firewalld.sh +0 -0
  53. package/scripts/nat-iptables.sh +2 -0
  54. package/scripts/rhel-grpc-setup.sh +0 -0
  55. package/scripts/rocky-kickstart.sh +25 -9
  56. package/scripts/test-monitor.sh +1 -1
  57. package/src/api/cyberia-instance/cyberia-fallback-default-items.js +63 -0
  58. package/src/api/cyberia-instance/cyberia-fallback-world.js +8 -1
  59. package/src/api/cyberia-instance/cyberia-instance.controller.js +3 -0
  60. package/src/api/cyberia-instance/cyberia-instance.router.js +13 -0
  61. package/src/api/cyberia-instance/cyberia-instance.service.js +43 -0
  62. package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +1 -0
  63. package/src/api/cyberia-server-defaults/cyberia-server-defaults.js +16 -3
  64. package/src/api/object-layer/object-layer.model.js +204 -3
  65. package/src/api/object-layer/object-layer.service.js +1 -14
  66. package/src/cli/baremetal.js +1 -2
  67. package/src/cli/cloud-init.js +1 -1
  68. package/src/cli/cluster.js +73 -68
  69. package/src/cli/db.js +9 -2
  70. package/src/cli/deploy.js +21 -5
  71. package/src/cli/docker-compose.js +1 -1
  72. package/src/cli/env.js +1 -1
  73. package/src/cli/image.js +0 -1
  74. package/src/cli/index.js +121 -9
  75. package/src/cli/lxd.js +1 -1
  76. package/src/cli/monitor.js +1 -1
  77. package/src/cli/release.js +57 -22
  78. package/src/cli/repository.js +11 -9
  79. package/src/cli/run.js +36 -9
  80. package/src/cli/ssh.js +198 -77
  81. package/src/cli/system.js +26 -13
  82. package/src/cli/test.js +1 -1
  83. package/src/cli/vultr.js +583 -0
  84. package/src/cli/wireguard.js +2125 -0
  85. package/src/client/components/cyberia/FallbackWorldEngineCyberia.js +368 -0
  86. package/src/client/components/cyberia-portal/AppShellCyberiaPortal.js +33 -0
  87. package/src/client/components/cyberia-portal/RouterCyberiaPortal.js +4 -0
  88. package/src/client/components/cyberia-portal/TranslateCyberiaPortal.js +4 -0
  89. package/src/client/public/cyberia-docs/ARCHITECTURE.md +17 -3
  90. package/src/client/public/cyberia-docs/CYBERIA-SERVER.md +1 -1
  91. package/src/client/public/cyberia-docs/ROADMAP.md +1 -1
  92. package/src/client/public/cyberia-docs/WHITE-PAPER.md +1 -1
  93. package/src/client/services/cyberia-instance/cyberia-instance.service.js +40 -0
  94. package/src/client/services/object-layer/object-layer.management.js +4 -4
  95. package/src/client-builder/client-build.js +20 -14
  96. package/src/db/mongo/MongooseDB.js +4 -0
  97. package/src/index.js +25 -1
  98. package/src/projects/cyberia/catalog-cyberia.js +5 -0
  99. package/src/projects/cyberia/generate-saga.js +14 -23
  100. package/src/projects/cyberia/instance-data.js +21 -2
  101. package/src/projects/cyberia/object-layer.js +11 -21
  102. package/src/projects/underpost/catalog-underpost.js +4 -1
  103. package/src/runtime/cyberia-client/Dockerfile +1 -1
  104. package/src/runtime/cyberia-client/Dockerfile.dev +1 -1
  105. package/src/runtime/cyberia-server/Dockerfile +1 -1
  106. package/src/runtime/cyberia-server/Dockerfile.dev +1 -1
  107. package/src/runtime/engine-cyberia/Dockerfile +1 -1
  108. package/src/runtime/engine-cyberia/Dockerfile.dev +1 -1
  109. package/src/runtime/engine-cyberia/Dockerfile.test +1 -1
  110. package/src/runtime/engine-cyberia/compose.env +16 -0
  111. package/src/runtime/engine-cyberia/docker-compose.yml +31 -37
  112. package/src/server/backup.js +1 -1
  113. package/src/server/conf.js +18 -108
  114. package/src/server/cron.js +249 -51
  115. package/src/server/dns.js +100 -6
  116. package/src/server/environment.js +98 -0
  117. package/src/server/forward-proxy.js +549 -0
  118. package/src/server/middlewares.js +56 -1
  119. package/src/server/process.js +0 -1
  120. package/src/server/selinux.js +185 -0
  121. package/src/server/systemd.js +205 -0
  122. package/src/server/underpost-compression.js +186 -0
  123. package/src/server/underpost-gateway.js +20 -10
  124. package/src/server/underpost-ingress.js +18 -2
  125. package/test/cyberia-instance-conf-defaults.test.js +1 -0
  126. package/test/selinux.test.js +71 -0
  127. package/test/underpost-gateway.test.js +41 -0
  128. package/test/underpost-ingress.test.js +52 -0
  129. package/test/wireguard-edge.test.js +1177 -0
@@ -22,6 +22,7 @@ import net from 'net';
22
22
  import crypto from 'crypto';
23
23
  import colors from 'colors';
24
24
  import { loggerFactory } from './logger.js';
25
+ import { writeEnv } from './environment.js';
25
26
  import { shellExec } from './process.js';
26
27
  import { UNDERPOST_GATEWAY, statusPageAssetPathFactory } from './underpost-gateway.js';
27
28
  import { DefaultConf } from '../../conf.js';
@@ -45,6 +46,13 @@ const logger = loggerFactory(import.meta);
45
46
  */
46
47
  const ENV_REF_PREFIX = 'env:';
47
48
 
49
+ /**
50
+ * Default deploy ID used when no deploy ID is specified.
51
+ * @constant {string}
52
+ * @memberof ServerConfBuilder
53
+ */
54
+ const DEFAULT_DEPLOY_ID = 'dd-default';
55
+
48
56
  /**
49
57
  * Resolves a standardized context key from host/path descriptors.
50
58
  * The key is used across DB, WS, mailer, and cache registries.
@@ -166,63 +174,6 @@ const getConfFolder = (deployId) => {
166
174
  : `./engine-private/conf/${deployId}`;
167
175
  };
168
176
 
169
- /**
170
- * Reads `engine-private/deploy/dd.cron` and returns the deploy-id string,
171
- * or `null` if the file does not exist or is empty.
172
- *
173
- * @method cronDeployIdResolve
174
- * @returns {string|null} The deploy-id from dd.cron, or null.
175
- * @memberof ServerConfBuilder
176
- */
177
- const cronDeployIdResolve = () => {
178
- const cronDeployFile = './engine-private/deploy/dd.cron';
179
- if (fs.existsSync(cronDeployFile)) {
180
- const id = fs.readFileSync(cronDeployFile, 'utf8').trim();
181
- return id || null;
182
- }
183
- return null;
184
- };
185
-
186
- /**
187
- * Loads the deployment-specific `.env` file referenced by `engine-private/deploy/dd.cron`
188
- * into `process.env`. Uses `NODE_ENV` to select the environment variant
189
- * (defaults to `production`).
190
- *
191
- * Safe to call multiple times; subsequent calls are no-ops once the env is loaded.
192
- *
193
- * @method loadCronDeployEnv
194
- * @memberof ServerConfBuilder
195
- */
196
- function loadCronDeployEnv() {
197
- const envName = process.env.NODE_ENV || 'production';
198
-
199
- // 1) Load dd.cron env (takes full precedence)
200
- const cronDeployId = cronDeployIdResolve();
201
- if (cronDeployId) {
202
- const cronEnvPath = `./engine-private/conf/${cronDeployId}/.env.${envName}`;
203
- if (fs.existsSync(cronEnvPath)) {
204
- const cronEnv = dotenv.parse(fs.readFileSync(cronEnvPath, 'utf8'));
205
- process.env = { ...process.env, ...cronEnv };
206
- }
207
- }
208
-
209
- // 2) Load dd.router envs — only keys not already present
210
- const routerDeployFile = './engine-private/deploy/dd.router';
211
- if (fs.existsSync(routerDeployFile)) {
212
- const routerIds = fs.readFileSync(routerDeployFile, 'utf8').trim().split(',');
213
- for (const deployId of routerIds) {
214
- const id = deployId.trim();
215
- if (!id) continue;
216
- const envPath = `./engine-private/conf/${id}/.env.${envName}`;
217
- if (!fs.existsSync(envPath)) continue;
218
- const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
219
- for (const key of Object.keys(env)) {
220
- if (!(key in process.env)) process.env[key] = env[key];
221
- }
222
- }
223
- }
224
- }
225
-
226
177
  /**
227
178
  * Resolves the full path to a specific configuration JSON file for a deploy ID.
228
179
  * For `server` configs in development mode with a subConf, it will prefer the
@@ -280,13 +231,6 @@ const readConfJson = (deployId, confType, options = {}) => {
280
231
  return parsed;
281
232
  };
282
233
 
283
- /**
284
- * Default deploy ID used when no deploy ID is specified.
285
- * @constant {string}
286
- * @memberof ServerConfBuilder
287
- */
288
- const DEFAULT_DEPLOY_ID = 'dd-default';
289
-
290
234
  /**
291
235
  * @class Config
292
236
  * @description Manages the configuration of the server.
@@ -1431,43 +1375,6 @@ const generateSecurePassword = (length = 16) => {
1431
1375
  return chars.join('');
1432
1376
  };
1433
1377
 
1434
- /**
1435
- * @method getNpmRootPath
1436
- * @description Gets the npm root path.
1437
- * @returns {string} - The npm root path.
1438
- * @memberof ServerConfBuilder
1439
- */
1440
- const getNpmRootPath = () =>
1441
- shellExec(`npm root -g`, {
1442
- stdout: true,
1443
- disableLog: true,
1444
- silent: true,
1445
- }).trim();
1446
-
1447
- /**
1448
- * @method getUnderpostRootPath
1449
- * @description Gets the underpost root path.
1450
- * @returns {string} - The underpost root path.
1451
- * @memberof ServerConfBuilder
1452
- */
1453
- const getUnderpostRootPath = () => `${getNpmRootPath()}/underpost`;
1454
-
1455
- /**
1456
- * @method writeEnv
1457
- * @description Writes the environment variables.
1458
- * @param {string} envPath - The environment path.
1459
- * @param {object} envObj - The environment object.
1460
- * @memberof ServerConfBuilder
1461
- */
1462
- const writeEnv = (envPath, envObj) =>
1463
- fs.writeFileSync(
1464
- envPath,
1465
- Object.keys(envObj)
1466
- .map((key) => `${key}=${envObj[key]}`)
1467
- .join(`\n`),
1468
- 'utf8',
1469
- );
1470
-
1471
1378
  /**
1472
1379
  * @method buildCliDoc
1473
1380
  * @description Scrapes `node bin help` (and `node bin help <command>` for every
@@ -3028,7 +2935,9 @@ ${renderHosts}`,
3028
2935
  * Resolves the concrete deploy ids a build or conf-sync run should iterate over.
3029
2936
  *
3030
2937
  * The meta deploy id `dd` fans out to the comma separated ids declared in
3031
- * `engine-private/deploy/dd.router`; any other value is parsed as a comma separated list.
2938
+ * `engine-private/deploy/dd.router`; when that file is absent (e.g. the private
2939
+ * repository is not checked out) it falls back to {@link ServerConfBuilder.DEFAULT_DEPLOY_ID}.
2940
+ * Any other value is parsed as a comma separated list.
3032
2941
  * Entries are trimmed and empties dropped.
3033
2942
  *
3034
2943
  * @method resolveDeployList
@@ -3037,7 +2946,12 @@ ${renderHosts}`,
3037
2946
  * @memberof ServerConfBuilder
3038
2947
  */
3039
2948
  const resolveDeployList = (deployId) =>
3040
- (deployId === 'dd' ? fs.readFileSync('./engine-private/deploy/dd.router', 'utf8') : deployId)
2949
+ (deployId === 'dd'
2950
+ ? fs.existsSync('./engine-private/deploy/dd.router')
2951
+ ? fs.readFileSync('./engine-private/deploy/dd.router', 'utf8')
2952
+ : DEFAULT_DEPLOY_ID
2953
+ : deployId
2954
+ )
3041
2955
  .split(',')
3042
2956
  .map((id) => id.trim())
3043
2957
  .filter(Boolean);
@@ -3186,6 +3100,7 @@ const buildTemplate = async ({ srcPath = './', toPath = '../pwa-microservices-te
3186
3100
  }
3187
3101
  shellExec(`rm -rf ${toPath}/.github`);
3188
3102
  shellExec(`rm -rf ${toPath}/manifests/deployment/dd-*`);
3103
+ shellExec(`rm -rf ${toPath}/deploy`);
3189
3104
 
3190
3105
  fs.mkdirSync(`${toPath}/.github/workflows`, { recursive: true });
3191
3106
  for (const restorePath of TEMPLATE_RESTORE_PATHS) {
@@ -3388,9 +3303,6 @@ export {
3388
3303
  splitFileFactory,
3389
3304
  generateSecurePassword,
3390
3305
  resolveReplicaCount,
3391
- getNpmRootPath,
3392
- getUnderpostRootPath,
3393
- writeEnv,
3394
3306
  pathPortAssignmentFactory,
3395
3307
  deployRangePortFactory,
3396
3308
  awaitDeployMonitor,
@@ -3410,8 +3322,6 @@ export {
3410
3322
  getConfFilePath,
3411
3323
  readConfJson,
3412
3324
  DEFAULT_DEPLOY_ID,
3413
- loadCronDeployEnv,
3414
- cronDeployIdResolve,
3415
3325
  clusterContextFactory,
3416
3326
  clusterTypeFactory,
3417
3327
  exposeTcpPortsFactory,