underpost 2.8.886 → 2.81.1

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.
package/src/cli/index.js CHANGED
@@ -64,10 +64,11 @@ program
64
64
  // 'cmt' command: Commit changes to a GitHub repository
65
65
  program
66
66
  .command('cmt')
67
- .argument('<path>', 'The absolute or relative directory path of the repository.')
68
- .argument(`<commit-type>`, `The type of commit to perform. Options: ${Object.keys(commitData).join(', ')}.`)
67
+ .argument('[path]', 'The absolute or relative directory path of the repository.')
68
+ .argument(`[commit-type]`, `The type of commit to perform. Options: ${Object.keys(commitData).join(', ')}.`)
69
69
  .argument(`[module-tag]`, 'Optional: Sets a specific module tag for the commit.')
70
70
  .argument(`[message]`, 'Optional: Provides an additional custom message for the commit.')
71
+ .option(`--log`, 'Shows commit history from the specified number of latest n path commits.')
71
72
  .option('--empty', 'Allows committing with empty files.')
72
73
  .option('--copy', 'Copies the generated commit message to the clipboard.')
73
74
  .option('--info', 'Displays information about available commit types.')
@@ -89,7 +90,7 @@ program
89
90
  .command('env')
90
91
  .argument(
91
92
  '[deploy-id]',
92
- `The deployment configuration ID. Use 'clean' to restore default environment settings. User 'root' to load root env. User 'current' to get plain current deploy Id.`,
93
+ `The deployment configuration ID. Use 'clean' to restore default environment settings. Use 'root' to load underpost root env. Use 'current' to get plain current deploy Id.`,
93
94
  )
94
95
  .argument('[env]', 'Optional: The environment to set (e.g., "production", "development"). Defaults to "production".')
95
96
  .argument('[subConf]', 'Optional: The sub configuration to set.')
@@ -183,7 +184,11 @@ program
183
184
  .option('--versions <deployment-versions>', 'A comma-separated list of custom deployment versions.')
184
185
  .option('--traffic <traffic-versions>', 'A comma-separated list of custom deployment traffic weights.')
185
186
  .option('--disable-update-deployment', 'Disables updates to deployments.')
186
- .option('--info-traffic', 'Retrieves traffic configuration from current resource deployments.')
187
+ .option('--disable-update-proxy', 'Disables updates to proxies.')
188
+ .option(
189
+ '--status',
190
+ 'Retrieves current network traffic data from resource deployments and the host machine network configuration.',
191
+ )
187
192
  .option('--kubeadm', 'Enables the kubeadm context for deployment operations.')
188
193
  .option('--etc-hosts', 'Enables the etc-hosts context for deployment operations.')
189
194
  .option('--restore-hosts', 'Restores default `/etc/hosts` entries.')
@@ -217,6 +222,7 @@ program
217
222
  .option('--secrets', 'Includes Dockerfile environment secrets during the build.')
218
223
  .option('--secrets-path [secrets-path]', 'Specifies a custom path for Dockerfile environment secrets.')
219
224
  .option('--reset', 'Performs a build without using the cache.')
225
+ .option('--dev', 'Use development mode.')
220
226
  .option('--k3s-load', 'Loads the image into a K3s cluster.')
221
227
  .description(
222
228
  'Builds a Docker image from a specified Dockerfile with various options for naming, saving, and loading.',
@@ -231,6 +237,7 @@ program
231
237
  .option('--kubeadm-load', 'Imports the pulled image into a Kubeadm cluster.')
232
238
  .option('--version', 'Sets a custom version for the base images.')
233
239
  .option('--k3s-load', 'Loads the image into a K3s cluster.')
240
+ .option('--dev', 'Use development mode.')
234
241
  .description('Pulls required Underpost Dockerfile base images and optionally loads them into clusters.')
235
242
  .action(Underpost.image.dockerfile.pullBaseImages);
236
243
 
@@ -65,6 +65,7 @@ class UnderpostMonitor {
65
65
  const router = auxRouter ?? (await UnderpostDeploy.API.routerFactory(deployId, env));
66
66
 
67
67
  const confServer = loadReplicas(
68
+ deployId,
68
69
  JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
69
70
  );
70
71
 
@@ -83,7 +83,7 @@ class UnderpostRepository {
83
83
  * @memberof UnderpostRepository
84
84
  */
85
85
  commit(
86
- repoPath = './',
86
+ repoPath = undefined,
87
87
  commitType = 'feat',
88
88
  subModule = '',
89
89
  message = '',
@@ -91,8 +91,31 @@ class UnderpostRepository {
91
91
  copy: false,
92
92
  info: false,
93
93
  empty: false,
94
+ log: false,
94
95
  },
95
96
  ) {
97
+ if (options.log) {
98
+ const history = UnderpostRepository.API.getHistory(repoPath);
99
+ const chainCmd = history
100
+ .reverse()
101
+ .map((commitData, i) => `${i === 0 ? '' : ' && '}git --no-pager show ${commitData.hash}`)
102
+ .join('');
103
+ if (history[0]) {
104
+ for (const commit of history) {
105
+ console.log(commit.hash.yellow, commit.message);
106
+ console.log(
107
+ shellExec(`git show --name-status --pretty="" ${commit.hash}`, {
108
+ stdout: true,
109
+ silent: true,
110
+ disableLog: true,
111
+ }).red,
112
+ );
113
+ }
114
+ if (options.copy) pbcopy(chainCmd);
115
+ else console.log('Show all:', chainCmd);
116
+ } else logger.warn('No commits found');
117
+ return;
118
+ }
96
119
  if (commitType === 'reset') {
97
120
  if (options.copy) pbcopy(shellExec(`git --no-pager log -1 --pretty=%B`, { stdout: true }));
98
121
  shellExec(`cd ${repoPath} && git reset --soft HEAD~${isNaN(parseInt(subModule)) ? 1 : parseInt(subModule)}`);
@@ -268,6 +291,29 @@ Prevent build private config repo.`,
268
291
  deployVersion: packageJsonDeploy.version,
269
292
  };
270
293
  },
294
+ getHistory(sinceCommit = 5) {
295
+ return shellExec(`git log --oneline --graph --decorate -n ${sinceCommit}`, {
296
+ stdout: true,
297
+ silent: true,
298
+ disableLog: true,
299
+ })
300
+ .split(`\n`)
301
+ .map((line) => {
302
+ return {
303
+ hash: line.slice(2, 10),
304
+ message: line.slice(11),
305
+ };
306
+ })
307
+ .filter((line) => line.hash)
308
+ .map((line) => {
309
+ line.files = shellExec(`git show --name-status --pretty="" ${line.hash}`, {
310
+ stdout: true,
311
+ silent: true,
312
+ disableLog: true,
313
+ });
314
+ return line;
315
+ });
316
+ },
271
317
  };
272
318
  }
273
319
 
package/src/cli/run.js CHANGED
@@ -169,15 +169,18 @@ class UnderpostRun {
169
169
  */
170
170
  'dev-cluster': (path, options = UnderpostRun.DEFAULT_OPTION) => {
171
171
  const baseCommand = options.dev ? 'node bin' : 'underpost';
172
- shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''} --reset`);
173
- shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''}`);
174
172
  const mongoHosts = ['mongodb-0.mongodb-service'];
175
- shellExec(
176
- `${baseCommand} cluster${options.dev ? ' --dev' : ''} --mongodb --mongo-db-host ${mongoHosts.join(
177
- ',',
178
- )} --pull-image`,
179
- );
180
- shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''} --valkey --pull-image`);
173
+ if (path !== 'expose') {
174
+ shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''} --reset`);
175
+ shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''}`);
176
+
177
+ shellExec(
178
+ `${baseCommand} cluster${options.dev ? ' --dev' : ''} --mongodb --mongo-db-host ${mongoHosts.join(
179
+ ',',
180
+ )} --pull-image`,
181
+ );
182
+ shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''} --valkey --pull-image`);
183
+ }
181
184
  shellExec(`${baseCommand} deploy --expose mongo`, { async: true });
182
185
  shellExec(`${baseCommand} deploy --expose valkey`, { async: true });
183
186
  {
@@ -197,6 +200,31 @@ class UnderpostRun {
197
200
  shellExec(`chmod +x ${underpostRoot}/scripts/ssh-cluster-info.sh`);
198
201
  shellExec(`${underpostRoot}/scripts/ssh-cluster-info.sh`);
199
202
  },
203
+
204
+ /**
205
+ * @method dev-hosts-expose
206
+ * @description Deploys a specified service in development mode with `/etc/hosts` modification for local access.
207
+ * @param {string} path - The input value, identifier, or path for the operation (used as the deployment ID to deploy).
208
+ * @param {Object} options - The default underpost runner options for customizing workflow
209
+ * @memberof UnderpostRun
210
+ */
211
+ 'dev-hosts-expose': (path, options = UnderpostRun.DEFAULT_OPTION) => {
212
+ shellExec(
213
+ `node bin deploy ${path} development --disable-update-deployment --disable-update-proxy --kubeadm --etc-hosts`,
214
+ );
215
+ },
216
+
217
+ /**
218
+ * @method dev-hosts-restore
219
+ * @description Restores the `/etc/hosts` file to its original state after modifications made during development deployments.
220
+ * @param {string} path - The input value, identifier, or path for the operation.
221
+ * @param {Object} options - The default underpost runner options for customizing workflow
222
+ * @memberof UnderpostRun
223
+ */
224
+ 'dev-hosts-restore': (path, options = UnderpostRun.DEFAULT_OPTION) => {
225
+ shellExec(`node bin deploy --restore-hosts`);
226
+ },
227
+
200
228
  /**
201
229
  * @method cyberia-ide
202
230
  * @description Starts the development environment (IDE) for both `cyberia-server` and `cyberia-client` repositories.
@@ -244,7 +272,7 @@ class UnderpostRun {
244
272
  * @memberof UnderpostRun
245
273
  */
246
274
  'template-deploy': (path, options = UnderpostRun.DEFAULT_OPTION) => {
247
- const baseCommand = options.dev || true ? 'node bin' : 'underpost';
275
+ const baseCommand = options.dev ? 'node bin' : 'underpost';
248
276
  shellExec(`${baseCommand} run clean`);
249
277
  shellExec(`${baseCommand} push ./engine-private ${process.env.GITHUB_USERNAME}/engine-private`);
250
278
  shellCd('/home/dd/engine');
@@ -301,7 +329,7 @@ class UnderpostRun {
301
329
  */
302
330
  'ssh-deploy': (path, options = UnderpostRun.DEFAULT_OPTION) => {
303
331
  actionInitLog();
304
- const baseCommand = options.dev || true ? 'node bin' : 'underpost';
332
+ const baseCommand = options.dev ? 'node bin' : 'underpost';
305
333
  shellCd('/home/dd/engine');
306
334
  shellExec(`git reset`);
307
335
  shellExec(`${baseCommand} cmt . --empty cd ssh-${path}`);
@@ -309,14 +337,14 @@ class UnderpostRun {
309
337
  },
310
338
  /**
311
339
  * @method ide
312
- * @description Opens a Visual Studio Code (VS Code) session for the specified path using `node ${underpostRoot}/bin/vs ${path}`.
340
+ * @description Opens a Visual Studio Code (VS Code) session for the specified path using `node ${underpostRoot}/bin/zed ${path}`.
313
341
  * @param {string} path - The input value, identifier, or path for the operation (used as the path to the directory to open in the IDE).
314
342
  * @param {Object} options - The default underpost runner options for customizing workflow
315
343
  * @memberof UnderpostRun
316
344
  */
317
345
  ide: (path, options = UnderpostRun.DEFAULT_OPTION) => {
318
346
  const { underpostRoot } = options;
319
- shellExec(`node ${underpostRoot}/bin/vs ${path}`);
347
+ shellExec(`node ${underpostRoot}/bin/zed ${path}`);
320
348
  },
321
349
  /**
322
350
  * @method sync
@@ -328,7 +356,7 @@ class UnderpostRun {
328
356
  sync: async (path, options = UnderpostRun.DEFAULT_OPTION) => {
329
357
  // Dev usage: node bin run --dev --build sync dd-default
330
358
  const env = options.dev ? 'development' : 'production';
331
- const baseCommand = options.dev || true ? 'node bin' : 'underpost';
359
+ const baseCommand = options.dev ? 'node bin' : 'underpost';
332
360
  const defaultPath = [
333
361
  'dd-default',
334
362
  1,
@@ -337,11 +365,11 @@ class UnderpostRun {
337
365
  options.dev || !isDeployRunnerContext(path, options) ? 'kind-control-plane' : os.hostname(),
338
366
  ];
339
367
  let [deployId, replicas, versions, image, node] = path ? path.split(',') : defaultPath;
340
- deployId = deployId ?? defaultPath[0];
341
- replicas = replicas ?? defaultPath[1];
342
- versions = versions ?? defaultPath[2];
343
- image = image ?? defaultPath[3];
344
- node = node ?? defaultPath[4];
368
+ deployId = deployId ? deployId : defaultPath[0];
369
+ replicas = replicas ? replicas : defaultPath[1];
370
+ versions = versions ? versions.replaceAll('+', ',') : defaultPath[2];
371
+ image = image ? image : defaultPath[3];
372
+ node = node ? node : defaultPath[4];
345
373
 
346
374
  if (isDeployRunnerContext(path, options)) {
347
375
  const { validVersion } = UnderpostRepository.API.privateConfUpdate(deployId);
@@ -357,13 +385,11 @@ class UnderpostRun {
357
385
  shellExec(
358
386
  `${baseCommand} deploy --kubeadm --build-manifest --sync --info-router --replicas ${
359
387
  replicas ?? 1
360
- } --node ${node}${image ? ` --image ${image}` : ''}${
361
- versions ? ` --versions ${versions.replaceAll('+', ',')}` : ''
362
- } dd ${env}`,
388
+ } --node ${node}${image ? ` --image ${image}` : ''}${versions ? ` --versions ${versions}` : ''} dd ${env}`,
363
389
  );
364
390
 
365
391
  if (isDeployRunnerContext(path, options)) {
366
- shellExec(`${baseCommand} deploy --kubeadm ${deployId} ${env}`);
392
+ shellExec(`${baseCommand} deploy --kubeadm --disable-update-proxy ${deployId} ${env} --versions ${versions}`);
367
393
  if (!targetTraffic) targetTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId);
368
394
  await UnderpostDeploy.API.monitorReadyRunner(deployId, env, targetTraffic);
369
395
  UnderpostDeploy.API.switchTraffic(deployId, env, targetTraffic);
@@ -529,36 +555,56 @@ class UnderpostRun {
529
555
  },
530
556
  /**
531
557
  * @method cluster
532
- * @description Deploys a full production-ready Kubernetes cluster environment including MongoDB, MariaDB, Valkey, Contour (Ingress), and Cert-Manager, and deploys all services.
558
+ * @description Deploys a full production/development ready Kubernetes cluster environment including MongoDB, MariaDB, Valkey, Contour (Ingress), and Cert-Manager, and deploys all services.
533
559
  * @param {string} path - The input value, identifier, or path for the operation.
534
560
  * @param {Object} options - The default underpost runner options for customizing workflow
535
561
  * @memberof UnderpostRun
536
562
  */
537
- cluster: async (path, options = UnderpostRun.DEFAULT_OPTION) => {
538
- const deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8').split(',');
539
- const env = 'production';
563
+ cluster: async (path = '', options = UnderpostRun.DEFAULT_OPTION) => {
564
+ const env = options.dev ? 'development' : 'production';
565
+ const baseCommand = options.dev ? 'node bin' : 'underpost';
566
+ const baseClusterCommand = options.dev ? ' --dev' : '';
540
567
  shellCd(`/home/dd/engine`);
541
- shellExec(`underpost cluster --reset`);
542
- await timer(5000);
543
- shellExec(`underpost cluster --kubeadm`);
568
+ shellExec(`${baseCommand} cluster${baseClusterCommand} --reset`);
544
569
  await timer(5000);
545
- shellExec(`underpost dockerfile-pull-base-images --path /home/dd/engine/src/runtime/lampp --kubeadm-load`);
570
+ shellExec(`${baseCommand} cluster${baseClusterCommand} --kubeadm`);
546
571
  await timer(5000);
547
- shellExec(`underpost cluster --kubeadm --pull-image --mongodb`);
572
+ let [runtimeImage, deployList] = path.split(',')
573
+ ? path.split(',')
574
+ : ['lampp', fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8').replaceAll(',', '+')];
575
+ shellExec(
576
+ `${baseCommand} dockerfile-pull-base-images${baseClusterCommand}${
577
+ runtimeImage ? ` --path /home/dd/engine/src/runtime/${runtimeImage}` : ''
578
+ } --kubeadm-load`,
579
+ );
580
+ if (!deployList) {
581
+ deployList = [];
582
+ logger.warn('No deploy list provided');
583
+ } else deployList = deployList.split('+');
548
584
  await timer(5000);
549
- shellExec(`underpost cluster --kubeadm --pull-image --mariadb`);
585
+ shellExec(`${baseCommand} cluster${baseClusterCommand} --kubeadm --pull-image --mongodb`);
586
+ if (runtimeImage === 'lampp') {
587
+ await timer(5000);
588
+ shellExec(`${baseCommand} cluster${baseClusterCommand} --kubeadm --pull-image --mariadb`);
589
+ }
550
590
  await timer(5000);
551
591
  for (const deployId of deployList) {
552
- shellExec(`underpost db ${deployId} --import --git`);
592
+ shellExec(`${baseCommand} db ${deployId} --import --git`);
553
593
  }
554
594
  await timer(5000);
555
- shellExec(`underpost cluster --kubeadm --pull-image --valkey`);
556
- await timer(5000);
557
- shellExec(`underpost cluster --kubeadm --contour`);
595
+ shellExec(`${baseCommand} cluster${baseClusterCommand} --kubeadm --pull-image --valkey`);
558
596
  await timer(5000);
559
- shellExec(`underpost cluster --kubeadm --cert-manager`);
597
+ shellExec(`${baseCommand} cluster${baseClusterCommand} --kubeadm --contour`);
598
+ if (env === 'production') {
599
+ await timer(5000);
600
+ shellExec(`${baseCommand} cluster${baseClusterCommand} --kubeadm --cert-manager`);
601
+ }
560
602
  for (const deployId of deployList) {
561
- shellExec(`underpost deploy ${deployId} ${env} --kubeadm --cert`);
603
+ shellExec(
604
+ `${baseCommand} deploy ${deployId} ${env} --kubeadm${env === 'production' ? ' --cert' : ''}${
605
+ env === 'development' ? ' --etc-hosts' : ''
606
+ }`,
607
+ );
562
608
  }
563
609
  },
564
610
  /**
@@ -593,7 +639,7 @@ class UnderpostRun {
593
639
  */
594
640
  'sync-replica': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
595
641
  const env = options.dev ? 'development' : 'production';
596
- const baseCommand = options.dev || true ? 'node bin' : 'underpost';
642
+ const baseCommand = options.dev ? 'node bin' : 'underpost';
597
643
 
598
644
  for (let deployId of fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8').split(',')) {
599
645
  deployId = deployId.trim();
package/src/index.js CHANGED
@@ -35,7 +35,7 @@ class Underpost {
35
35
  * @type {String}
36
36
  * @memberof Underpost
37
37
  */
38
- static version = 'v2.8.886';
38
+ static version = 'v2.81.1';
39
39
  /**
40
40
  * Repository cli API
41
41
  * @static
@@ -0,0 +1,41 @@
1
+ FROM rockylinux:9
2
+
3
+ # --- Update and install required packages
4
+ RUN dnf -y update && \
5
+ dnf -y install epel-release && \
6
+ dnf -y install --allowerasing \
7
+ bzip2 \
8
+ sudo \
9
+ curl \
10
+ net-tools \
11
+ openssh-server \
12
+ nano \
13
+ vim-enhanced \
14
+ less \
15
+ openssl-devel \
16
+ wget \
17
+ git \
18
+ gnupg2 \
19
+ libnsl \
20
+ perl && \
21
+ dnf clean all
22
+
23
+
24
+ # Install Node.js
25
+ RUN curl -fsSL https://rpm.nodesource.com/setup_24.x | bash -
26
+ RUN dnf install nodejs -y
27
+ RUN dnf clean all
28
+
29
+ # Verify Node.js and npm versions
30
+ RUN node --version
31
+ RUN npm --version
32
+
33
+ # Set working directory
34
+ WORKDIR /home/dd
35
+
36
+ # Expose necessary ports
37
+ EXPOSE 22
38
+ EXPOSE 80
39
+ EXPOSE 443
40
+ EXPOSE 3000-3100
41
+ EXPOSE 4000-4100
@@ -11,6 +11,7 @@ import {
11
11
  capFirst,
12
12
  getCapVariableName,
13
13
  newInstance,
14
+ orderAbc,
14
15
  orderArrayFromAttrInt,
15
16
  range,
16
17
  timer,
@@ -56,7 +57,8 @@ const Config = {
56
57
  if (process.argv[2] && typeof process.argv[2] === 'string' && process.argv[2].startsWith('dd-'))
57
58
  deployContext = process.argv[2];
58
59
  if (!subConf && process.argv[3] && typeof process.argv[3] === 'string') subConf = process.argv[3];
59
- if (!fs.existsSync(`./tmp`)) fs.mkdirSync(`./tmp`, { recursive: true });
60
+ if (!fs.existsSync(`./tmp`)) fs.mkdirSync(`./tmp`);
61
+ if (!fs.existsSync(`./conf`)) fs.mkdirSync(`./conf`);
60
62
  UnderpostRootEnv.API.set('await-deploy', new Date().toISOString());
61
63
  if (deployContext.startsWith('dd-')) loadConf(deployContext, subConf);
62
64
  if (deployContext === 'proxy') await Config.buildProxy(deployList, subConf);
@@ -154,18 +156,20 @@ const Config = {
154
156
  * @memberof ServerConfBuilder
155
157
  */
156
158
  buildProxyByDeployId: function (deployId = 'dd-default', subConf = '') {
157
- let confPath = `./engine-private/conf/${deployId}/conf.server.json`;
158
- const privateConfDevPath = fs.existsSync(`./engine-private/replica/${deployId}/conf.server.json`)
159
+ let confPath = fs.existsSync(`./engine-private/replica/${deployId}/conf.server.json`)
159
160
  ? `./engine-private/replica/${deployId}/conf.server.json`
160
- : `./engine-private/conf/${deployId}/conf.server.dev.${subConf}.json`;
161
- const confDevPath = fs.existsSync(privateConfDevPath)
162
- ? privateConfDevPath
163
- : `./engine-private/conf/${deployId}/conf.server.dev.json`;
161
+ : `./engine-private/conf/${deployId}/conf.server.json`;
162
+
163
+ if (
164
+ process.env.NODE_ENV === 'development' &&
165
+ subConf &&
166
+ fs.existsSync(`./engine-private/conf/${deployId}/conf.server.dev.${subConf}.json`)
167
+ )
168
+ confPath = `./engine-private/conf/${deployId}/conf.server.dev.${subConf}.json`;
164
169
 
165
- if (fs.existsSync(confDevPath)) confPath = confDevPath;
166
170
  const serverConf = JSON.parse(fs.readFileSync(confPath, 'utf8'));
167
171
 
168
- for (const host of Object.keys(loadReplicas(serverConf)))
172
+ for (const host of Object.keys(loadReplicas(deployId, serverConf)))
169
173
  this.default.server[host] = {
170
174
  ...this.default.server[host],
171
175
  ...serverConf[host],
@@ -231,7 +235,7 @@ const loadConf = (deployId = 'dd-default', subConf) => {
231
235
  const devConfPath = `${folder}/conf.${typeConf}.dev${subConf ? `.${subConf}` : ''}.json`;
232
236
  if (fs.existsSync(devConfPath)) srcConf = fs.readFileSync(devConfPath, 'utf8');
233
237
  }
234
- if (typeConf === 'server') srcConf = JSON.stringify(loadReplicas(JSON.parse(srcConf)), null, 4);
238
+ if (typeConf === 'server') srcConf = JSON.stringify(loadReplicas(deployId, JSON.parse(srcConf)), null, 4);
235
239
  fs.writeFileSync(`./conf/conf.${typeConf}.json`, srcConf, 'utf8');
236
240
  }
237
241
  fs.writeFileSync(`./.env.production`, fs.readFileSync(`${folder}/.env.production`, 'utf8'), 'utf8');
@@ -263,19 +267,30 @@ const loadConf = (deployId = 'dd-default', subConf) => {
263
267
  * @param {object} confServer - The server configuration.
264
268
  * @memberof ServerConfBuilder
265
269
  */
266
- const loadReplicas = (confServer) => {
270
+ const loadReplicas = (deployId, confServer) => {
271
+ const confServerOrigin = newInstance(confServer);
267
272
  for (const host of Object.keys(confServer)) {
268
273
  for (const path of Object.keys(confServer[host])) {
269
274
  const { replicas, singleReplica } = confServer[host][path];
270
- if (replicas && !singleReplica)
271
- for (const replicaPath of replicas) {
272
- {
273
- confServer[host][replicaPath] = newInstance(confServer[host][path]);
274
- delete confServer[host][replicaPath].replicas;
275
+ if (replicas) {
276
+ if (!singleReplica)
277
+ for (const replicaPath of replicas) {
278
+ {
279
+ confServer[host][replicaPath] = newInstance(confServer[host][path]);
280
+ delete confServer[host][replicaPath].replicas;
281
+ }
275
282
  }
283
+ else {
284
+ const orderReplica = orderAbc(confServerOrigin[host][path].replicas);
285
+ confServerOrigin[host][path].replicas = orderReplica;
286
+ confServer[host][path].replicas = orderReplica;
276
287
  }
288
+ }
277
289
  }
278
290
  }
291
+ const serverPath = `./engine-private/conf/${deployId}/conf.server${process.env.NODE_ENV === 'production' ? '' : '.dev'}.json`;
292
+ if (fs.existsSync(serverPath)) fs.writeFileSync(serverPath, JSON.stringify(confServerOrigin, null, 4), 'utf8');
293
+
279
294
  return confServer;
280
295
  };
281
296
 
@@ -828,7 +843,6 @@ const buildReplicaId = ({ deployId, replica }) => `${deployId}-${replica.slice(1
828
843
  * @description Gets the data deploy.
829
844
  * @param {object} options - The options.
830
845
  * @param {boolean} [options.buildSingleReplica=false] - The build single replica.
831
- * @param {string} options.deployGroupId - The deploy group ID.
832
846
  * @param {string} options.deployId - The deploy ID.
833
847
  * @param {boolean} [options.disableSyncEnvPort=false] - The disable sync env port.
834
848
  * @returns {object} - The data deploy.
@@ -837,23 +851,15 @@ const buildReplicaId = ({ deployId, replica }) => `${deployId}-${replica.slice(1
837
851
  const getDataDeploy = (
838
852
  options = {
839
853
  buildSingleReplica: false,
840
- deployGroupId: '',
841
- deployId: '',
842
854
  disableSyncEnvPort: false,
843
855
  },
844
856
  ) => {
845
- let dataDeploy =
846
- options.deployGroupId === 'dd'
847
- ? fs.readFileSync(`./engine-private/deploy/${options.deployGroupId}.router`, 'utf8')
848
- : fs.readFileSync(`./engine-private/deploy/${options.deployGroupId}`, 'utf8');
849
-
850
- dataDeploy = dataDeploy
857
+ let dataDeploy = fs
858
+ .readFileSync(`./engine-private/deploy/dd.router`, 'utf8')
851
859
  .split(',')
852
860
  .map((deployId) => deployId.trim())
853
861
  .filter((deployId) => deployId);
854
862
 
855
- if (options.deployId) dataDeploy = dataDeploy.filter((d) => d === options.deployId);
856
-
857
863
  dataDeploy = dataDeploy.map((deployId) => {
858
864
  return {
859
865
  deployId,
@@ -866,6 +872,7 @@ const getDataDeploy = (
866
872
  let buildDataDeploy = [];
867
873
  for (const deployObj of dataDeploy) {
868
874
  const serverConf = loadReplicas(
875
+ deployObj.deployId,
869
876
  JSON.parse(fs.readFileSync(`./engine-private/conf/${deployObj.deployId}/conf.server.json`, 'utf8')),
870
877
  );
871
878
  let replicaDataDeploy = [];
@@ -887,10 +894,9 @@ const getDataDeploy = (
887
894
  if (replicaDataDeploy.length > 0) buildDataDeploy = buildDataDeploy.concat(replicaDataDeploy);
888
895
  }
889
896
 
890
- const enableSyncEnvPort = !options.disableSyncEnvPort && options.buildSingleReplica;
891
- if (enableSyncEnvPort) shellExec(Cmd.syncPorts(options.deployGroupId));
897
+ if (!options.disableSyncEnvPort && options.buildSingleReplica) shellExec(Cmd.syncPorts());
892
898
 
893
- logger.info('buildDataDeploy', { buildDataDeploy, enableSyncEnvPort });
899
+ logger.info('Deployments configured', buildDataDeploy);
894
900
 
895
901
  return buildDataDeploy;
896
902
  };
@@ -1039,6 +1045,7 @@ const mergeFile = async (parts = [], outputFilePath) => {
1039
1045
  */
1040
1046
  const rebuildConfFactory = ({ deployId, valkey, mongo }) => {
1041
1047
  const confServer = loadReplicas(
1048
+ deployId,
1042
1049
  JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
1043
1050
  );
1044
1051
  const hosts = {};
@@ -1152,11 +1159,10 @@ const Cmd = {
1152
1159
  /**
1153
1160
  * @method syncPorts
1154
1161
  * @description Syncs the ports.
1155
- * @param {string} deployGroupId - The deploy group ID.
1156
1162
  * @returns {string} - The sync ports command.
1157
1163
  * @memberof Cmd
1158
1164
  */
1159
- syncPorts: (deployGroupId) => `node bin/deploy sync-env-port ${deployGroupId}`,
1165
+ syncPorts: () => `node bin/deploy sync-env-port`,
1160
1166
  /**
1161
1167
  * @method cron
1162
1168
  * @description Creates a cron job.
@@ -1306,9 +1312,9 @@ const buildCliDoc = (program, oldVersion, newVersion) => {
1306
1312
  ` +
1307
1313
  baseOptions +
1308
1314
  `
1309
-
1315
+
1310
1316
  <a target="_top" href="https://github.com/${process.env.GITHUB_USERNAME}/pwa-microservices-template/blob/master/cli.md">See complete CLI Docs here.</a>
1311
-
1317
+
1312
1318
  `
1313
1319
  ).replaceAll(oldVersion, newVersion),
1314
1320
  'utf8',