underpost 2.8.874 → 2.8.876

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,9 @@
49
49
 
50
50
 
51
51
 
52
+
53
+
54
+
52
55
 
53
56
 
54
57
 
@@ -56,7 +59,7 @@
56
59
  <!-- badges -->
57
60
 
58
61
 
59
- [![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.874)](https://socket.dev/npm/package/underpost/overview/2.8.874) [![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)
62
+ [![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.876)](https://socket.dev/npm/package/underpost/overview/2.8.876) [![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)
60
63
 
61
64
 
62
65
  <!-- end-badges -->
@@ -94,6 +97,9 @@
94
97
 
95
98
 
96
99
 
100
+
101
+
102
+
97
103
 
98
104
 
99
105
 
@@ -142,7 +148,7 @@ Run dev client server
142
148
  npm run dev
143
149
  ```
144
150
  <!-- -->
145
- ## underpost ci/cd cli v2.8.874
151
+ ## underpost ci/cd cli v2.8.876
146
152
 
147
153
  ### Usage: `underpost [options] [command]`
148
154
  ```
package/bin/deploy.js CHANGED
@@ -368,6 +368,9 @@ try {
368
368
  }
369
369
 
370
370
  case 'version-build': {
371
+ shellCd(`/home/dd/engine`);
372
+ shellExec(`node bin/deploy clean-core-repo`);
373
+ shellExec(`node bin pull . ${process.env.GITHUB_USERNAME}/engine`);
371
374
  shellExec(`node bin run kill 4001`);
372
375
  shellExec(`node bin run kill 4002`);
373
376
  shellExec(`node bin run kill 4003`);
@@ -384,8 +387,8 @@ try {
384
387
  logger.error('Test template runner result failed');
385
388
  break;
386
389
  }
387
- shellExec(`node bin/deploy clean-core-repo`);
388
390
  shellCd(`/home/dd/engine`);
391
+ shellExec(`node bin/deploy clean-core-repo`);
389
392
  const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
390
393
  const newVersion = process.argv[3] ?? originPackageJson.version;
391
394
  const node = process.argv[4] ?? 'kind-control-plane';
@@ -477,8 +480,8 @@ try {
477
480
  shellExec(`git add . && cd ./engine-private && git add .`);
478
481
  shellExec(`node bin cmt . ci package-pwa-microservices-template`);
479
482
  shellExec(`node bin cmt ./engine-private ci package-pwa-microservices-template`);
480
- shellExec(`node bin push . underpostnet/engine`);
481
- 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`);
482
485
  break;
483
486
  }
484
487
 
@@ -536,15 +539,16 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
536
539
  case 'update-default-conf': {
537
540
  const defaultServer = DefaultConf.server['default.net']['/'];
538
541
  let confName = process.argv[3];
539
- if (confName === 'ghpkg') {
540
- confName = undefined;
541
- 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`;
542
545
  const path = '/pwa-microservices-template-ghpkg';
543
546
  DefaultConf.server = {
544
547
  [host]: { [path]: defaultServer },
545
548
  };
546
549
  DefaultConf.server[host][path].apiBaseProxyPath = '/';
547
550
  DefaultConf.server[host][path].apiBaseHost = 'www.nexodev.org';
551
+ defaultConf = true;
548
552
  } else if (confName === 'template') {
549
553
  const host = 'default.net';
550
554
  const path = '/';
@@ -554,7 +558,7 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
554
558
  };
555
559
  // mongodb-0.mongodb-service
556
560
  DefaultConf.server[host][path].db.host = 'mongodb://mongodb-service:27017';
557
- confName = '';
561
+ defaultConf = true;
558
562
  } else if (confName && fs.existsSync(`./engine-private/conf/${confName}`)) {
559
563
  DefaultConf.client = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.client.json`, 'utf8'));
560
564
  DefaultConf.server = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
@@ -578,10 +582,22 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
578
582
  const sepRender = '/**/';
579
583
  const confRawPaths = fs.readFileSync('./conf.js', 'utf8').split(sepRender);
580
584
  confRawPaths[1] = `${JSON.stringify(DefaultConf)};`;
581
- const targetConfPath = `./conf${confName ? `.${confName}` : ''}.js`;
585
+ const targetConfPath = `./conf${defaultConf ? '' : `.${confName}`}.js`;
582
586
  fs.writeFileSync(targetConfPath, confRawPaths.join(sepRender), 'utf8');
583
587
  shellExec(`prettier --write ${targetConfPath}`);
584
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
+
585
601
  break;
586
602
  }
587
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.874
1
+ ## underpost ci/cd cli v2.8.876
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -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.874
20
+ image: localhost/rockylinux9-underpost:v2.8.876
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.874
103
+ image: localhost/rockylinux9-underpost:v2.8.876
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-test-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.874
20
+ image: localhost/rockylinux9-underpost:v2.8.876
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "96294Ki"
@@ -104,7 +104,7 @@ spec:
104
104
  spec:
105
105
  containers:
106
106
  - name: dd-test-development-green
107
- image: localhost/rockylinux9-underpost:v2.8.874
107
+ image: localhost/rockylinux9-underpost:v2.8.876
108
108
  # resources:
109
109
  # requests:
110
110
  # memory: "96294Ki"
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.874",
5
+ "version": "2.8.876",
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",
@@ -1,6 +1,6 @@
1
1
  import { commitData } from '../client/components/core/CommonJs.js';
2
2
  import dotenv from 'dotenv';
3
- import { pbcopy, shellExec } from '../server/process.js';
3
+ import { pbcopy, shellCd, shellExec } from '../server/process.js';
4
4
  import { actionInitLog, loggerFactory } from '../server/logger.js';
5
5
  import fs from 'fs-extra';
6
6
  import { getNpmRootPath } from '../server/conf.js';
@@ -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://${
@@ -49,7 +53,7 @@ class UnderpostRepository {
49
53
  },
50
54
  ) {
51
55
  if (commitType === 'reset') {
52
- pbcopy(shellExec(`git --no-pager log -1 --pretty=%B`, { stdout: true }));
56
+ if (options.copy) pbcopy(shellExec(`git --no-pager log -1 --pretty=%B`, { stdout: true }));
53
57
  shellExec(`cd ${repoPath} && git reset --soft HEAD~${isNaN(parseInt(subModule)) ? 1 : parseInt(subModule)}`);
54
58
  return;
55
59
  }
@@ -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}${
@@ -138,6 +146,25 @@ class UnderpostRepository {
138
146
  .concat(diffUntrackOutput.toString().split('\n').filter(Boolean))
139
147
  .filter((f) => !deleteFiles.includes(f));
140
148
  },
149
+ privateConfUpdate(deployId) {
150
+ shellCd(`/home/dd/engine`);
151
+ const privateRepoName = `engine-${deployId.split('dd-')[1]}-private`;
152
+ const privateRepoPath = `../${privateRepoName}`;
153
+ if (fs.existsSync(privateRepoPath)) fs.removeSync(privateRepoPath);
154
+ shellExec(`cd .. && underpost clone ${process.env.GITHUB_USERNAME}/${privateRepoName}`);
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 { validVersion: false };
164
+ }
165
+ shellExec(`node bin/build ${deployId} conf`);
166
+ return { validVersion: true };
167
+ },
141
168
  };
142
169
  }
143
170
 
package/src/cli/run.js CHANGED
@@ -7,6 +7,7 @@ import fs from 'fs-extra';
7
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
+ import UnderpostRepository from './repository.js';
10
11
 
11
12
  const logger = loggerFactory(import.meta);
12
13
 
@@ -26,9 +27,9 @@ class UnderpostRun {
26
27
  shellExec(`sudo rm -rf ${dir}`);
27
28
  shellCd('/home/dd');
28
29
 
29
- // pbcopy(`cd /home/dd && sbt new underpostnet/spark-template.g8`);
30
+ // pbcopy(`cd /home/dd && sbt new ${process.env.GITHUB_USERNAME}/spark-template.g8`);
30
31
  // await read({ prompt: 'Command copy to clipboard, press enter to continue.\n' });
31
- shellExec(`cd /home/dd && sbt new underpostnet/spark-template.g8 '--name=spark-template'`);
32
+ shellExec(`cd /home/dd && sbt new ${process.env.GITHUB_USERNAME}/spark-template.g8 '--name=spark-template'`);
32
33
 
33
34
  shellCd(dir);
34
35
 
@@ -106,7 +107,7 @@ class UnderpostRun {
106
107
  shellCd('/home/dd/engine');
107
108
  shellExec(`git reset`);
108
109
  shellExec(`${baseCommand} cmt . --empty ci package-pwa-microservices-template`);
109
- shellExec(`${baseCommand} push . underpostnet/engine`);
110
+ shellExec(`${baseCommand} push . ${process.env.GITHUB_USERNAME}/engine`);
110
111
  },
111
112
  clean: (path, options = UnderpostRun.DEFAULT_OPTION) => {
112
113
  shellCd(path ?? `/home/dd/engine`);
@@ -115,8 +116,8 @@ class UnderpostRun {
115
116
  pull: (path, options = UnderpostRun.DEFAULT_OPTION) => {
116
117
  shellCd(`/home/dd/engine`);
117
118
  shellExec(`node bin/deploy clean-core-repo`);
118
- shellExec(`underpost pull . underpostnet/engine`);
119
- shellExec(`underpost pull engine-private underpostnet/engine-private`, { silent: true });
119
+ shellExec(`underpost pull . ${process.env.GITHUB_USERNAME}/engine`);
120
+ shellExec(`underpost pull ./engine-private ${process.env.GITHUB_USERNAME}/engine-private`);
120
121
  },
121
122
  'release-deploy': (path, options = UnderpostRun.DEFAULT_OPTION) => {
122
123
  actionInitLog();
@@ -131,10 +132,9 @@ class UnderpostRun {
131
132
  actionInitLog();
132
133
  const baseCommand = options.dev || true ? 'node bin' : 'underpost';
133
134
  shellCd('/home/dd/engine');
134
- shellExec(`node bin/build dd-${path.split('engine-')[1]} conf`);
135
135
  shellExec(`git reset`);
136
136
  shellExec(`${baseCommand} cmt . --empty cd ssh-${path}`);
137
- shellExec(`${baseCommand} push . underpostnet/engine`);
137
+ shellExec(`${baseCommand} push . ${process.env.GITHUB_USERNAME}/engine`);
138
138
  },
139
139
  ide: (path, options = UnderpostRun.DEFAULT_OPTION) => {
140
140
  const { underpostRoot } = options;
@@ -303,6 +303,8 @@ class UnderpostRun {
303
303
  },
304
304
  deploy: async (path, options = UnderpostRun.DEFAULT_OPTION) => {
305
305
  const deployId = path;
306
+ const { validVersion } = UnderpostRepository.API.privateConfUpdate(deployId);
307
+ if (!validVersion) throw new Error('Version mismatch');
306
308
  const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId);
307
309
  const targetTraffic = currentTraffic === 'blue' ? 'green' : 'blue';
308
310
  const env = 'production';
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.874';
38
+ static version = 'v2.8.876';
39
39
  /**
40
40
  * Repository cli API
41
41
  * @static
@@ -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),
@@ -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`);