underpost 2.8.875 → 2.8.877

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.
@@ -4,7 +4,7 @@ name: CD | Gihub page | PWA Microservices Template
4
4
  on:
5
5
  # Runs on pushes targeting the default branch
6
6
  push:
7
- branches: ['main']
7
+ branches: ["main"]
8
8
 
9
9
  # Allows you to run this workflow manually from the Actions tab
10
10
  workflow_dispatch:
@@ -18,7 +18,7 @@ permissions:
18
18
  # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19
19
  # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20
20
  concurrency:
21
- group: 'pages'
21
+ group: "pages"
22
22
  cancel-in-progress: false
23
23
 
24
24
  jobs:
@@ -53,7 +53,8 @@ jobs:
53
53
  run: |
54
54
  npm install -g underpost
55
55
  npm install
56
- node bin/deploy update-default-conf ghpkg
56
+ node bin/deploy update-default-conf dd-github-pages
57
+ underpost env dd-github-pages production
57
58
  env-cmd -f .env.production node bin/deploy build-full-client dd-github-pages underpostnet.github.io /pwa-microservices-template-ghpkg
58
59
  # git lfs install
59
60
  # git lfs track
@@ -65,7 +66,7 @@ jobs:
65
66
  uses: actions/upload-pages-artifact@v3
66
67
  with:
67
68
  # Upload entire repository
68
- path: './public/underpostnet.github.io/pwa-microservices-template-ghpkg/'
69
+ path: "./public/underpostnet.github.io/pwa-microservices-template-ghpkg/"
69
70
  - name: Deploy to GitHub Pages
70
71
  id: deployment
71
72
  uses: actions/deploy-pages@v4
@@ -34,4 +34,5 @@ jobs:
34
34
  node bin run --dev pull
35
35
  underpost run secret
36
36
  underpost run underpost-config
37
+ node bin run --dev pull
37
38
  underpost run ssh-deploy engine-test
package/README.md CHANGED
@@ -49,6 +49,10 @@
49
49
 
50
50
 
51
51
 
52
+
53
+
54
+
55
+
52
56
 
53
57
 
54
58
 
@@ -57,7 +61,7 @@
57
61
  <!-- badges -->
58
62
 
59
63
 
60
- [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [![Downloads](https://img.shields.io/npm/dm/underpost.svg)](https://www.npmjs.com/package/underpost) [![Socket Badge](https://socket.dev/api/badge/npm/package/underpost/2.8.875)](https://socket.dev/npm/package/underpost/overview/2.8.875) [![Coverage Status](https://coveralls.io/repos/github/underpostnet/engine/badge.svg?branch=master)](https://coveralls.io/github/underpostnet/engine?branch=master) [![Version](https://img.shields.io/npm/v/underpost.svg)](https://www.npmjs.org/package/underpost) [![License](https://img.shields.io/npm/l/underpost.svg)](https://www.npmjs.com/package/underpost)
64
+ [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [![Downloads](https://img.shields.io/npm/dm/underpost.svg)](https://www.npmjs.com/package/underpost) [![Socket Badge](https://socket.dev/api/badge/npm/package/underpost/2.8.877)](https://socket.dev/npm/package/underpost/overview/2.8.877) [![Coverage Status](https://coveralls.io/repos/github/underpostnet/engine/badge.svg?branch=master)](https://coveralls.io/github/underpostnet/engine?branch=master) [![Version](https://img.shields.io/npm/v/underpost.svg)](https://www.npmjs.org/package/underpost) [![License](https://img.shields.io/npm/l/underpost.svg)](https://www.npmjs.com/package/underpost)
61
65
 
62
66
 
63
67
  <!-- end-badges -->
@@ -95,6 +99,10 @@
95
99
 
96
100
 
97
101
 
102
+
103
+
104
+
105
+
98
106
 
99
107
 
100
108
 
@@ -144,7 +152,7 @@ Run dev client server
144
152
  npm run dev
145
153
  ```
146
154
  <!-- -->
147
- ## underpost ci/cd cli v2.8.875
155
+ ## underpost ci/cd cli v2.8.877
148
156
 
149
157
  ### Usage: `underpost [options] [command]`
150
158
  ```
package/bin/deploy.js CHANGED
@@ -370,6 +370,7 @@ try {
370
370
  case 'version-build': {
371
371
  shellCd(`/home/dd/engine`);
372
372
  shellExec(`node bin/deploy clean-core-repo`);
373
+ shellExec(`node bin pull . ${process.env.GITHUB_USERNAME}/engine`);
373
374
  shellExec(`node bin run kill 4001`);
374
375
  shellExec(`node bin run kill 4002`);
375
376
  shellExec(`node bin run kill 4003`);
@@ -479,8 +480,8 @@ try {
479
480
  shellExec(`git add . && cd ./engine-private && git add .`);
480
481
  shellExec(`node bin cmt . ci package-pwa-microservices-template`);
481
482
  shellExec(`node bin cmt ./engine-private ci package-pwa-microservices-template`);
482
- shellExec(`node bin push . underpostnet/engine`);
483
- shellExec(`cd ./engine-private && node ../bin push . underpostnet/engine-private`);
483
+ shellExec(`node bin push . ${process.env.GITHUB_USERNAME}/engine`);
484
+ shellExec(`cd ./engine-private && node ../bin push . ${process.env.GITHUB_USERNAME}/engine-private`);
484
485
  break;
485
486
  }
486
487
 
@@ -538,15 +539,16 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
538
539
  case 'update-default-conf': {
539
540
  const defaultServer = DefaultConf.server['default.net']['/'];
540
541
  let confName = process.argv[3];
541
- if (confName === 'ghpkg') {
542
- confName = undefined;
543
- const host = 'underpostnet.github.io';
542
+ let defaultConf = false;
543
+ if (confName === 'dd-github-pages') {
544
+ const host = `${process.env.GITHUB_USERNAME ?? 'underpostnet'}.github.io`;
544
545
  const path = '/pwa-microservices-template-ghpkg';
545
546
  DefaultConf.server = {
546
547
  [host]: { [path]: defaultServer },
547
548
  };
548
549
  DefaultConf.server[host][path].apiBaseProxyPath = '/';
549
550
  DefaultConf.server[host][path].apiBaseHost = 'www.nexodev.org';
551
+ defaultConf = true;
550
552
  } else if (confName === 'template') {
551
553
  const host = 'default.net';
552
554
  const path = '/';
@@ -556,7 +558,7 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
556
558
  };
557
559
  // mongodb-0.mongodb-service
558
560
  DefaultConf.server[host][path].db.host = 'mongodb://mongodb-service:27017';
559
- confName = '';
561
+ defaultConf = true;
560
562
  } else if (confName && fs.existsSync(`./engine-private/conf/${confName}`)) {
561
563
  DefaultConf.client = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.client.json`, 'utf8'));
562
564
  DefaultConf.server = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
@@ -580,10 +582,22 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
580
582
  const sepRender = '/**/';
581
583
  const confRawPaths = fs.readFileSync('./conf.js', 'utf8').split(sepRender);
582
584
  confRawPaths[1] = `${JSON.stringify(DefaultConf)};`;
583
- const targetConfPath = `./conf${confName ? `.${confName}` : ''}.js`;
585
+ const targetConfPath = `./conf${defaultConf ? '' : `.${confName}`}.js`;
584
586
  fs.writeFileSync(targetConfPath, confRawPaths.join(sepRender), 'utf8');
585
587
  shellExec(`prettier --write ${targetConfPath}`);
586
588
 
589
+ switch (confName) {
590
+ case 'dd-github-pages':
591
+ {
592
+ if (fs.exists(`./engine-private/conf/${confName}`)) fs.removeSync(`./engine-private/conf/${confName}`);
593
+ shellExec(`node bin new --deploy-id ${confName}`);
594
+ }
595
+ break;
596
+
597
+ default:
598
+ break;
599
+ }
600
+
587
601
  break;
588
602
  }
589
603
 
package/bin/file.js CHANGED
@@ -56,10 +56,11 @@ try {
56
56
  console.log('copy paths', result);
57
57
 
58
58
  if (type === 'update-template') {
59
- if (!fs.existsSync(toPath)) shellExec(`cd .. && underpost clone underpostnet/pwa-microservices-template`);
59
+ if (!fs.existsSync(toPath))
60
+ shellExec(`cd .. && underpost clone ${process.env.GITHUB_USERNAME}/pwa-microservices-template`);
60
61
  else {
61
62
  shellExec(`cd ${toPath} && git reset && git checkout . && git clean -f -d`);
62
- shellExec(`underpost pull ${toPath} underpostnet/pwa-microservices-template`);
63
+ shellExec(`underpost pull ${toPath} ${process.env.GITHUB_USERNAME}/pwa-microservices-template`);
63
64
  shellExec(`sudo rm -rf ${toPath}/engine-private`);
64
65
  shellExec(`sudo rm -rf ${toPath}/logs`);
65
66
  }
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.875
1
+ ## underpost ci/cd cli v2.8.877
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -609,6 +609,8 @@ Options:
609
609
  --command <command-array> Array of commands to run.
610
610
  --args <args-array> Array of arguments to pass to the command.
611
611
  --dev Sets the development context environment for the script.
612
+ --build Set builder context runner
613
+ --replicas <replicas> Sets a custom number of replicas for deployment.
612
614
  --pod-name <pod-name> Optional: Specifies the pod name for test execution.
613
615
  --volume-host-path <volume-host-path> Optional: Specifies the volume host path for test execution.
614
616
  --volume-mount-path <volume-mount-path> Optional: Specifies the volume mount path for test execution.
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-default-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.875
20
+ image: localhost/rockylinux9-underpost:v2.8.877
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "124Ki"
@@ -100,7 +100,7 @@ spec:
100
100
  spec:
101
101
  containers:
102
102
  - name: dd-default-development-green
103
- image: localhost/rockylinux9-underpost:v2.8.875
103
+ image: localhost/rockylinux9-underpost:v2.8.877
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -17,13 +17,13 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-test-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.875
20
+ image: localhost/rockylinux9-underpost:v2.8.877
21
21
  # resources:
22
22
  # requests:
23
- # memory: "96294Ki"
23
+ # memory: "94Ki"
24
24
  # cpu: "75m"
25
25
  # limits:
26
- # memory: "1540709Ki"
26
+ # memory: "1504Ki"
27
27
  # cpu: "1200m"
28
28
  command:
29
29
  - /bin/sh
@@ -104,13 +104,13 @@ spec:
104
104
  spec:
105
105
  containers:
106
106
  - name: dd-test-development-green
107
- image: localhost/rockylinux9-underpost:v2.8.875
107
+ image: localhost/rockylinux9-underpost:v2.8.877
108
108
  # resources:
109
109
  # requests:
110
- # memory: "96294Ki"
110
+ # memory: "94Ki"
111
111
  # cpu: "75m"
112
112
  # limits:
113
- # memory: "1540709Ki"
113
+ # memory: "1504Ki"
114
114
  # cpu: "1200m"
115
115
  command:
116
116
  - /bin/sh
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "main": "src/index.js",
4
4
  "name": "underpost",
5
- "version": "2.8.875",
5
+ "version": "2.8.877",
6
6
  "description": "pwa api rest template",
7
7
  "scripts": {
8
8
  "start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
package/src/cli/deploy.js CHANGED
@@ -384,7 +384,8 @@ EOF`);
384
384
  if (!options.remove === true) {
385
385
  if (!options.disableUpdateDeployment) shellExec(`sudo kubectl apply -f ./${manifestsPath}/deployment.yaml`);
386
386
  shellExec(`sudo kubectl apply -f ./${manifestsPath}/proxy.yaml`);
387
- if (UnderpostDeploy.API.isValidTLSContext({ host, env, options }))
387
+
388
+ if (UnderpostDeploy.API.isValidTLSContext({ host: Object.keys(confServer)[0], env, options }))
388
389
  shellExec(`sudo kubectl apply -f ./${manifestsPath}/secret.yaml`);
389
390
  }
390
391
  }
package/src/cli/index.js CHANGED
@@ -350,6 +350,8 @@ program
350
350
  .option('--command <command-array>', 'Array of commands to run.')
351
351
  .option('--args <args-array>', 'Array of arguments to pass to the command.')
352
352
  .option('--dev', 'Sets the development context environment for the script.')
353
+ .option('--build', 'Set builder context runner')
354
+ .option('--replicas <replicas>', 'Sets a custom number of replicas for deployment.')
353
355
  .option('--pod-name <pod-name>', 'Optional: Specifies the pod name for test execution.')
354
356
  .option('--volume-host-path <volume-host-path>', 'Optional: Specifies the volume host path for test execution.')
355
357
  .option('--volume-mount-path <volume-mount-path>', 'Optional: Specifies the volume mount path for test execution.')
@@ -13,7 +13,7 @@ const logger = loggerFactory(import.meta);
13
13
 
14
14
  class UnderpostRepository {
15
15
  static API = {
16
- clone(gitUri = 'underpostnet/pwa-microservices-template', options = { bare: false, g8: false }) {
16
+ clone(gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template`, options = { bare: false, g8: false }) {
17
17
  const gExtension = options.g8 === true ? '.g8' : '.git';
18
18
  const repoName = gitUri.split('/').pop();
19
19
  if (fs.existsSync(`./${repoName}`)) fs.removeSync(`./${repoName}`);
@@ -26,7 +26,11 @@ class UnderpostRepository {
26
26
  },
27
27
  );
28
28
  },
29
- pull(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { g8: false }) {
29
+ pull(
30
+ repoPath = './',
31
+ gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template`,
32
+ options = { g8: false },
33
+ ) {
30
34
  const gExtension = options.g8 === true ? '.g8' : '.git';
31
35
  shellExec(
32
36
  `cd ${repoPath} && git pull https://${
@@ -61,7 +65,11 @@ class UnderpostRepository {
61
65
  shellExec(`cd ${repoPath} && git commit ${options?.empty ? `--allow-empty ` : ''}-m "${_message}"`);
62
66
  },
63
67
 
64
- push(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { f: false, g8: false }) {
68
+ push(
69
+ repoPath = './',
70
+ gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template}`,
71
+ options = { f: false, g8: false },
72
+ ) {
65
73
  const gExtension = options.g8 === true || options.G8 === true ? '.g8' : '.git';
66
74
  shellExec(
67
75
  `cd ${repoPath} && git push https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}${gExtension}${
@@ -145,7 +153,25 @@ class UnderpostRepository {
145
153
  if (fs.existsSync(privateRepoPath)) fs.removeSync(privateRepoPath);
146
154
  shellExec(`cd .. && underpost clone ${process.env.GITHUB_USERNAME}/${privateRepoName}`);
147
155
  shellExec(`cd ${privateRepoPath} && underpost pull . ${process.env.GITHUB_USERNAME}/${privateRepoName}`);
156
+ const packageJsonDeploy = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/package.json`, 'utf8'));
157
+ const packageJsonEngine = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
158
+ if (packageJsonDeploy.version !== packageJsonEngine.version) {
159
+ logger.warn(
160
+ `Version mismatch: deploy-version:${packageJsonDeploy.version} !== engine-version:${packageJsonEngine.version},
161
+ Prevent build private config repo.`,
162
+ );
163
+ return {
164
+ validVersion: false,
165
+ engineVersion: packageJsonEngine.version,
166
+ deployVersion: packageJsonDeploy.version,
167
+ };
168
+ }
148
169
  shellExec(`node bin/build ${deployId} conf`);
170
+ return {
171
+ validVersion: true,
172
+ engineVersion: packageJsonEngine.version,
173
+ deployVersion: packageJsonDeploy.version,
174
+ };
149
175
  },
150
176
  };
151
177
  }
package/src/cli/run.js CHANGED
@@ -8,6 +8,7 @@ import { range, setPad, timer } from '../client/components/core/CommonJs.js';
8
8
  import UnderpostDeploy from './deploy.js';
9
9
  import UnderpostRootEnv from './env.js';
10
10
  import UnderpostRepository from './repository.js';
11
+ import os from 'os';
11
12
 
12
13
  const logger = loggerFactory(import.meta);
13
14
 
@@ -20,6 +21,8 @@ class UnderpostRun {
20
21
  imageName: '',
21
22
  containerName: '',
22
23
  namespace: '',
24
+ build: false,
25
+ replicas: 1,
23
26
  };
24
27
  static RUNNERS = {
25
28
  'spark-template': (path, options = UnderpostRun.DEFAULT_OPTION) => {
@@ -27,9 +30,9 @@ class UnderpostRun {
27
30
  shellExec(`sudo rm -rf ${dir}`);
28
31
  shellCd('/home/dd');
29
32
 
30
- // pbcopy(`cd /home/dd && sbt new underpostnet/spark-template.g8`);
33
+ // pbcopy(`cd /home/dd && sbt new ${process.env.GITHUB_USERNAME}/spark-template.g8`);
31
34
  // await read({ prompt: 'Command copy to clipboard, press enter to continue.\n' });
32
- shellExec(`cd /home/dd && sbt new underpostnet/spark-template.g8 '--name=spark-template'`);
35
+ shellExec(`cd /home/dd && sbt new ${process.env.GITHUB_USERNAME}/spark-template.g8 '--name=spark-template'`);
33
36
 
34
37
  shellCd(dir);
35
38
 
@@ -107,7 +110,7 @@ class UnderpostRun {
107
110
  shellCd('/home/dd/engine');
108
111
  shellExec(`git reset`);
109
112
  shellExec(`${baseCommand} cmt . --empty ci package-pwa-microservices-template`);
110
- shellExec(`${baseCommand} push . underpostnet/engine`);
113
+ shellExec(`${baseCommand} push . ${process.env.GITHUB_USERNAME}/engine`);
111
114
  },
112
115
  clean: (path, options = UnderpostRun.DEFAULT_OPTION) => {
113
116
  shellCd(path ?? `/home/dd/engine`);
@@ -116,8 +119,8 @@ class UnderpostRun {
116
119
  pull: (path, options = UnderpostRun.DEFAULT_OPTION) => {
117
120
  shellCd(`/home/dd/engine`);
118
121
  shellExec(`node bin/deploy clean-core-repo`);
119
- shellExec(`underpost pull . underpostnet/engine`);
120
- shellExec(`underpost pull engine-private underpostnet/engine-private`, { silent: true });
122
+ shellExec(`underpost pull . ${process.env.GITHUB_USERNAME}/engine`);
123
+ shellExec(`underpost pull ./engine-private ${process.env.GITHUB_USERNAME}/engine-private`);
121
124
  },
122
125
  'release-deploy': (path, options = UnderpostRun.DEFAULT_OPTION) => {
123
126
  actionInitLog();
@@ -134,7 +137,7 @@ class UnderpostRun {
134
137
  shellCd('/home/dd/engine');
135
138
  shellExec(`git reset`);
136
139
  shellExec(`${baseCommand} cmt . --empty cd ssh-${path}`);
137
- shellExec(`${baseCommand} push . underpostnet/engine`);
140
+ shellExec(`${baseCommand} push . ${process.env.GITHUB_USERNAME}/engine`);
138
141
  },
139
142
  ide: (path, options = UnderpostRun.DEFAULT_OPTION) => {
140
143
  const { underpostRoot } = options;
@@ -154,17 +157,21 @@ class UnderpostRun {
154
157
  const env = options.dev ? 'development' : 'production';
155
158
  const baseCommand = options.dev || true ? 'node bin' : 'underpost';
156
159
  shellExec(`${baseCommand} run clean`);
157
- const defaultPaht = ['dd', 1, ``, 'kind-control-plane'];
158
- let [deployId, replicas, image, node] = path ? path.split(',') : defaultPaht;
159
- deployId = deployId ?? defaultPaht[0];
160
- replicas = replicas ?? defaultPaht[1];
161
- image = image ?? defaultPaht[2];
162
- node = node ?? defaultPaht[3];
160
+ const defaultPath = ['dd-default', 1, ``, ``, 'kind-control-plane'];
161
+ let [deployId, replicas, versions, image, node] = path ? path.split(',') : defaultPath;
162
+ deployId = deployId ?? defaultPath[0];
163
+ replicas = replicas ?? defaultPath[1];
164
+ versions = versions ?? defaultPath[2];
165
+ image = image ?? defaultPath[3];
166
+ node = node ?? defaultPath[4];
163
167
  shellExec(
164
168
  `${baseCommand} deploy --kubeadm --build-manifest --sync --info-router --replicas ${
165
169
  replicas ?? 1
166
- } --node ${node}${image ? ` --image ${image}` : ''} ${deployId} ${env}`,
170
+ } --node ${node}${image ? ` --image ${image}` : ''}${
171
+ versions ? ` --versions ${versions.replaceAll('+', ',')}` : ''
172
+ } dd ${env}`,
167
173
  );
174
+ if (!options.build) shellExec(`${baseCommand} deploy --kubeadm ${deployId} ${env}`);
168
175
  },
169
176
  'ls-deployments': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
170
177
  console.table(await UnderpostDeploy.API.get(path, 'deployments'));
@@ -303,12 +310,21 @@ class UnderpostRun {
303
310
  },
304
311
  deploy: async (path, options = UnderpostRun.DEFAULT_OPTION) => {
305
312
  const deployId = path;
306
- UnderpostRepository.API.privateConfUpdate(deployId);
313
+ const { validVersion, deployVersion } = UnderpostRepository.API.privateConfUpdate(deployId);
314
+ if (!validVersion) throw new Error('Version mismatch');
307
315
  const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId);
308
316
  const targetTraffic = currentTraffic === 'blue' ? 'green' : 'blue';
309
317
  const env = 'production';
310
318
  const ignorePods = UnderpostDeploy.API.get(`${deployId}-${env}-${targetTraffic}`).map((p) => p.NAME);
311
- shellExec(`sudo kubectl rollout restart deployment/${deployId}-${env}-${targetTraffic}`);
319
+
320
+ if (options.build === true) {
321
+ // deployId, replicas, versions, image, node
322
+ shellExec(
323
+ `node bin run sync ${deployId},${options.replicas ?? 1},${targetTraffic},${
324
+ options.imageName ?? `localhost/rockylinux9-underpost:${deployVersion}`
325
+ },${os.hostname()}`,
326
+ );
327
+ } else shellExec(`sudo kubectl rollout restart deployment/${deployId}-${env}-${targetTraffic}`);
312
328
 
313
329
  let checkStatusIteration = 0;
314
330
  const checkStatusIterationMsDelay = 1000;
@@ -4,7 +4,6 @@ import { loggerFactory } from './Logger.js';
4
4
  import { LogIn } from './LogIn.js';
5
5
  import { LogOut } from './LogOut.js';
6
6
  import { NotificationManager } from './NotificationManager.js';
7
- import { SignUp } from './SignUp.js';
8
7
  import { Translate } from './Translate.js';
9
8
  import { s } from './VanillaJs.js';
10
9
 
@@ -35,8 +35,6 @@ const getWsBaseUrl = (options = { id: '', endpoint: '', wsBasePath: '' }) =>
35
35
  const headersFactory = (headerId = '') => {
36
36
  const headers = {
37
37
  Authorization: Auth.getJWT(),
38
- withCredentials: true,
39
- credentials: 'include', // no cors: 'same-origin'
40
38
  };
41
39
  switch (headerId) {
42
40
  case 'file':
@@ -71,29 +69,12 @@ const CoreService = {
71
69
  return reject(error);
72
70
  }),
73
71
  ),
74
- getRandomImage: (options = { category: ['city'], mimetype: 'image/jpg' }) => {
75
- const src = `https://api.api-ninjas.com/v1/randomimage?category=${options.category[0]}`;
76
- return new Promise((resolve) => {
77
- fetch(src, {
78
- headers: { 'X-Api-Key': 'FyITmcxRXkCaUehbX6K0/g==uxZcFKL0dZUUg48G', Accept: options.mimetype },
79
- })
80
- .then((res) => res.blob())
81
- .then(async (blob) => {
82
- return resolve({
83
- file: {
84
- mimetype: 'image/jpg',
85
- name: 'image.jpg',
86
- },
87
- url: URL.createObjectURL(blob),
88
- });
89
- });
90
- });
91
- },
92
72
  post: (options = { id: '', body: {} }) =>
93
73
  new Promise((resolve, reject) =>
94
74
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
95
75
  method: 'POST',
96
76
  headers: headersFactory(),
77
+ credentials: 'include',
97
78
  body: payloadFactory(options.body),
98
79
  })
99
80
  .then(async (res) => {
@@ -113,6 +94,7 @@ const CoreService = {
113
94
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
114
95
  method: 'PUT',
115
96
  headers: headersFactory(),
97
+ credentials: 'include',
116
98
  body: payloadFactory(options.body),
117
99
  })
118
100
  .then(async (res) => {
@@ -132,6 +114,7 @@ const CoreService = {
132
114
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
133
115
  method: 'GET',
134
116
  headers: headersFactory(),
117
+ credentials: 'include',
135
118
  })
136
119
  .then(async (res) => {
137
120
  return await res.json();
@@ -150,6 +133,7 @@ const CoreService = {
150
133
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
151
134
  method: 'DELETE',
152
135
  headers: headersFactory(),
136
+ credentials: 'include',
153
137
  body: payloadFactory(options.body),
154
138
  })
155
139
  .then(async (res) => {
@@ -14,6 +14,7 @@ const DefaultService = {
14
14
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
15
15
  method: 'POST',
16
16
  headers: headersFactory(),
17
+ credentials: 'include',
17
18
  body: payloadFactory(options.body),
18
19
  })
19
20
  .then(async (res) => {
@@ -33,6 +34,7 @@ const DefaultService = {
33
34
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
34
35
  method: 'PUT',
35
36
  headers: headersFactory(),
37
+ credentials: 'include',
36
38
  body: payloadFactory(options.body),
37
39
  })
38
40
  .then(async (res) => {
@@ -56,6 +58,7 @@ const DefaultService = {
56
58
  fetch(url.toString(), {
57
59
  method: 'GET',
58
60
  headers: headersFactory(),
61
+ credentials: 'include',
59
62
  })
60
63
  .then(async (res) => {
61
64
  return await res.json();
@@ -75,6 +78,7 @@ const DefaultService = {
75
78
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
76
79
  method: 'DELETE',
77
80
  headers: headersFactory(),
81
+ credentials: 'include',
78
82
  body: payloadFactory(options.body),
79
83
  })
80
84
  .then(async (res) => {
@@ -14,6 +14,7 @@ const TestService = {
14
14
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
15
15
  method: 'POST',
16
16
  headers: headersFactory(),
17
+ credentials: 'include',
17
18
  body: payloadFactory(options.body),
18
19
  })
19
20
  .then(async (res) => {
@@ -33,6 +34,7 @@ const TestService = {
33
34
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
34
35
  method: 'GET',
35
36
  headers: headersFactory(),
37
+ credentials: 'include',
36
38
  })
37
39
  .then(async (res) => {
38
40
  return await res.json();
@@ -51,6 +53,7 @@ const TestService = {
51
53
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
52
54
  method: 'DELETE',
53
55
  headers: headersFactory(),
56
+ credentials: 'include',
54
57
  body: payloadFactory(options.body),
55
58
  })
56
59
  .then(async (res) => {
@@ -22,6 +22,7 @@ const UserService = {
22
22
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
23
23
  method: 'POST',
24
24
  headers: headersFactory(),
25
+ credentials: 'include',
25
26
  body: payloadFactory(options.body),
26
27
  })
27
28
  .then(async (res) => {
@@ -47,6 +48,7 @@ const UserService = {
47
48
  fetch(url, {
48
49
  method: 'GET',
49
50
  headers: headersFactory(),
51
+ credentials: 'include',
50
52
  })
51
53
  .then(async (res) => {
52
54
  return await res.json();
@@ -66,6 +68,7 @@ const UserService = {
66
68
  fetch(getApiBaseUrl({ id: options.id, endpoint }), {
67
69
  method: 'DELETE',
68
70
  headers: headersFactory(),
71
+ credentials: 'include',
69
72
  body: payloadFactory(options.body),
70
73
  })
71
74
  .then(async (res) => {
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.875';
38
+ static version = 'v2.8.877';
39
39
  /**
40
40
  * Repository cli API
41
41
  * @static
@@ -552,7 +552,7 @@ function applySecurity(app, opts = {}) {
552
552
  origin: origin || false,
553
553
  methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
554
554
  credentials: true,
555
- allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'Accept', 'withcredentials'],
555
+ allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'Accept', 'withcredentials', 'credentials'],
556
556
  maxAge: 600,
557
557
  }),
558
558
  );
@@ -61,10 +61,10 @@ class BackUp {
61
61
  }
62
62
  shellExec(
63
63
  `cd ./engine-private/cron-backups` +
64
- ` && underpost pull . underpostnet/cron-backups` +
64
+ ` && underpost pull . ${process.env.GITHUB_USERNAME}/cron-backups` +
65
65
  ` && git add .` +
66
66
  ` && underpost cmt . backup cron-job '${new Date().toLocaleDateString()}'` +
67
- ` && underpost push . underpostnet/cron-backups`,
67
+ ` && underpost push . ${process.env.GITHUB_USERNAME}/cron-backups`,
68
68
  {
69
69
  disableLog: true,
70
70
  },
@@ -918,7 +918,7 @@ const buildCliDoc = (program, oldVersion, newVersion) => {
918
918
  baseOptions +
919
919
  `
920
920
 
921
- <a target="_top" href="https://github.com/underpostnet/pwa-microservices-template/blob/master/cli.md">See complete CLI Docs here.</a>
921
+ <a target="_top" href="https://github.com/${process.env.GITHUB_USERNAME}/pwa-microservices-template/blob/master/cli.md">See complete CLI Docs here.</a>
922
922
 
923
923
  `
924
924
  ).replaceAll(oldVersion, newVersion),
@@ -63,6 +63,7 @@ const buildRuntime = async () => {
63
63
  singleReplica,
64
64
  replicas,
65
65
  valkey,
66
+ apiBaseHost,
66
67
  } = confServer[host][path];
67
68
 
68
69
  const { redirectTarget, singleReplicaHost } = await getInstanceContext({
@@ -188,97 +189,102 @@ const buildRuntime = async () => {
188
189
  await UnderpostStartUp.API.listenPortController(app, port, runningData);
189
190
  break;
190
191
  }
192
+ // instance server
193
+ const server = createServer({}, app);
194
+ if (peer) currentPort++;
191
195
 
192
- const swaggerJsonPath = `./public/${host}${path === '/' ? path : `${path}/`}swagger-output.json`;
193
- if (fs.existsSync(swaggerJsonPath)) {
194
- // logger.info('Build swagger serve', swaggerJsonPath);
196
+ if (!apiBaseHost) {
197
+ const swaggerJsonPath = `./public/${host}${path === '/' ? path : `${path}/`}swagger-output.json`;
198
+ if (fs.existsSync(swaggerJsonPath)) {
199
+ // logger.info('Build swagger serve', swaggerJsonPath);
195
200
 
196
- const swaggerInstance =
197
- (swaggerDoc) =>
198
- (...args) =>
199
- swaggerUi.setup(swaggerDoc)(...args);
201
+ const swaggerInstance =
202
+ (swaggerDoc) =>
203
+ (...args) =>
204
+ swaggerUi.setup(swaggerDoc)(...args);
200
205
 
201
- const swaggerDoc = JSON.parse(fs.readFileSync(swaggerJsonPath, 'utf8'));
206
+ const swaggerDoc = JSON.parse(fs.readFileSync(swaggerJsonPath, 'utf8'));
202
207
 
203
- app.use(`${path === '/' ? `/api-docs` : `${path}/api-docs`}`, swaggerUi.serve, swaggerInstance(swaggerDoc));
204
- }
208
+ app.use(
209
+ `${path === '/' ? `/api-docs` : `${path}/api-docs`}`,
210
+ swaggerUi.serve,
211
+ swaggerInstance(swaggerDoc),
212
+ );
213
+ }
205
214
 
206
- if (db && apis) await DataBaseProvider.load({ apis, host, path, db });
215
+ if (db && apis) await DataBaseProvider.load({ apis, host, path, db });
207
216
 
208
- // valkey server
209
- if (valkey) await createValkeyConnection({ host, path }, valkey);
217
+ // valkey server
218
+ if (valkey) await createValkeyConnection({ host, path }, valkey);
210
219
 
211
- if (mailer) {
212
- const mailerSsrConf = confSSR[getCapVariableName(client)];
213
- await MailerProvider.load({
214
- id: `${host}${path}`,
215
- meta: `mailer-${host}${path}`,
216
- host,
217
- path,
218
- ...mailer,
219
- templates: mailerSsrConf ? mailerSsrConf.mailer : {},
220
- });
221
- }
222
- if (apis) {
223
- const authMiddleware = authMiddlewareFactory({ host, path });
220
+ if (mailer) {
221
+ const mailerSsrConf = confSSR[getCapVariableName(client)];
222
+ await MailerProvider.load({
223
+ id: `${host}${path}`,
224
+ meta: `mailer-${host}${path}`,
225
+ host,
226
+ path,
227
+ ...mailer,
228
+ templates: mailerSsrConf ? mailerSsrConf.mailer : {},
229
+ });
230
+ }
231
+ if (apis) {
232
+ const authMiddleware = authMiddlewareFactory({ host, path });
233
+
234
+ const apiPath = `${path === '/' ? '' : path}/${process.env.BASE_API}`;
235
+ for (const api of apis)
236
+ await (async () => {
237
+ const { ApiRouter } = await import(`../api/${api}/${api}.router.js`);
238
+ const router = ApiRouter({ host, path, apiPath, mailer, db, authMiddleware });
239
+ // router.use(cors({ origin: origins }));
240
+ // logger.info('Load api router', { host, path: apiPath, api });
241
+ app.use(`${apiPath}/${api}`, router);
242
+ })();
243
+ }
244
+
245
+ // load ssr
246
+ const ssr = await ssrMiddlewareFactory({ app, directory, rootHostPath, path });
247
+ for (const [_, ssrMiddleware] of Object.entries(ssr)) app.use(ssrMiddleware);
224
248
 
225
- const apiPath = `${path === '/' ? '' : path}/${process.env.BASE_API}`;
226
- for (const api of apis)
249
+ if (ws)
227
250
  await (async () => {
228
- const { ApiRouter } = await import(`../api/${api}/${api}.router.js`);
229
- const router = ApiRouter({ host, path, apiPath, mailer, db, authMiddleware });
230
- // router.use(cors({ origin: origins }));
231
- // logger.info('Load api router', { host, path: apiPath, api });
232
- app.use(`${apiPath}/${api}`, router);
251
+ const { createIoServer } = await import(`../ws/${ws}/${ws}.ws.server.js`);
252
+ // logger.info('Load socket.io ws router', { host, ws });
253
+ // start socket.io
254
+ const { options, meta } = await createIoServer(server, {
255
+ host,
256
+ path,
257
+ db,
258
+ port,
259
+ origins,
260
+ });
261
+ await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), port, {
262
+ runtime: 'nodejs',
263
+ client: null,
264
+ host,
265
+ path: options.path,
266
+ meta,
267
+ });
233
268
  })();
234
- }
235
-
236
- // load ssr
237
- const ssr = await ssrMiddlewareFactory({ app, directory, rootHostPath, path });
238
- for (const [_, ssrMiddleware] of Object.entries(ssr)) app.use(ssrMiddleware);
239
269
 
240
- // instance server
241
- const server = createServer({}, app);
242
-
243
- if (ws)
244
- await (async () => {
245
- const { createIoServer } = await import(`../ws/${ws}/${ws}.ws.server.js`);
246
- // logger.info('Load socket.io ws router', { host, ws });
247
- // start socket.io
248
- const { options, meta } = await createIoServer(server, {
270
+ if (peer) {
271
+ const peerPort = newInstance(currentPort);
272
+ const { options, meta, peerServer } = await createPeerServer({
273
+ port: peerPort,
274
+ devPort: port,
275
+ origins,
249
276
  host,
250
277
  path,
251
- db,
252
- port,
253
- origins,
254
278
  });
255
- await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), port, {
279
+
280
+ await UnderpostStartUp.API.listenPortController(peerServer, peerPort, {
256
281
  runtime: 'nodejs',
257
282
  client: null,
258
283
  host,
259
284
  path: options.path,
260
285
  meta,
261
286
  });
262
- })();
263
-
264
- if (peer) {
265
- currentPort++;
266
- const peerPort = newInstance(currentPort);
267
- const { options, meta, peerServer } = await createPeerServer({
268
- port: peerPort,
269
- devPort: port,
270
- origins,
271
- host,
272
- path,
273
- });
274
-
275
- await UnderpostStartUp.API.listenPortController(peerServer, peerPort, {
276
- runtime: 'nodejs',
277
- client: null,
278
- host,
279
- path: options.path,
280
- meta,
281
- });
287
+ }
282
288
  }
283
289
 
284
290
  await UnderpostStartUp.API.listenPortController(server, port, runningData);
@@ -86,9 +86,9 @@ class UnderpostStartUp {
86
86
  async build(deployId = 'dd-default', env = 'development') {
87
87
  const buildBasePath = `/home/dd`;
88
88
  const repoName = `engine-${deployId.split('-')[1]}`;
89
- shellExec(`cd ${buildBasePath} && underpost clone underpostnet/${repoName}`);
89
+ shellExec(`cd ${buildBasePath} && underpost clone ${process.env.GITHUB_USERNAME}/${repoName}`);
90
90
  shellExec(`cd ${buildBasePath} && sudo mv ./${repoName} ./engine`);
91
- shellExec(`cd ${buildBasePath}/engine && underpost clone underpostnet/${repoName}-private`);
91
+ shellExec(`cd ${buildBasePath}/engine && underpost clone ${process.env.GITHUB_USERNAME}/${repoName}-private`);
92
92
  shellExec(`cd ${buildBasePath}/engine && sudo mv ./${repoName}-private ./engine-private`);
93
93
  shellCd(`${buildBasePath}/engine`);
94
94
  shellExec(`npm install`);