underpost 2.8.856 → 2.8.858

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.
@@ -8,7 +8,7 @@ on:
8
8
 
9
9
  jobs:
10
10
  after-publish:
11
- if: github.repository == 'underpostnet/pwa-microservices-template'
11
+ if: github.repository == 'underpostnet/pwa-microservices-template' || startsWith(github.event.head_commit.message, 'cd(ssh-release)')
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
14
  - name: Run remote deploy via SSH
@@ -30,7 +30,8 @@ jobs:
30
30
  echo "Starting remote release deploy"
31
31
  cd /home/dd/engine
32
32
  npm install -g underpost
33
- underpost set GITHUB_TOKEN ${{ secrets.GITHUB_TOKEN }}
33
+ underpost config set GITHUB_TOKEN ${{ secrets.GITHUB_TOKEN }}
34
34
  node bin run --dev pull
35
35
  underpost run secret
36
+ underpost run underpost-config
36
37
  underpost run release-deploy
package/README.md CHANGED
@@ -20,10 +20,13 @@
20
20
 
21
21
 
22
22
 
23
+
24
+
25
+
23
26
  <!-- badges -->
24
27
 
25
28
 
26
- [![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.856)](https://socket.dev/npm/package/underpost/overview/2.8.856) [![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)
29
+ [![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.858)](https://socket.dev/npm/package/underpost/overview/2.8.858) [![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)
27
30
 
28
31
 
29
32
  <!-- end-badges -->
@@ -32,6 +35,9 @@
32
35
 
33
36
 
34
37
 
38
+
39
+
40
+
35
41
  </div>
36
42
 
37
43
  <div align="center">
@@ -76,7 +82,7 @@ Run dev client server
76
82
  npm run dev
77
83
  ```
78
84
  <!-- -->
79
- ## underpost ci/cd cli v2.8.856
85
+ ## underpost ci/cd cli v2.8.858
80
86
 
81
87
  ### Usage: `underpost [options] [command]`
82
88
  ```
package/bin/deploy.js CHANGED
@@ -383,7 +383,7 @@ try {
383
383
  }
384
384
 
385
385
  case 'version-build': {
386
- shellExec(`node bin clean-core-repo`);
386
+ shellExec(`node bin/deploy clean-core-repo`);
387
387
  shellCd(`/home/dd/engine`);
388
388
  const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
389
389
  const newVersion = process.argv[3] ?? originPackageJson.version;
package/bin/file.js CHANGED
@@ -55,7 +55,15 @@ try {
55
55
 
56
56
  console.log('copy paths', result);
57
57
 
58
- if (type !== 'update-template') fs.removeSync(toPath);
58
+ if (type === 'update-template') {
59
+ if (!fs.existsSync(toPath)) shellExec(`cd .. && underpost clone underpostnet/pwa-microservices-template`);
60
+ else {
61
+ shellExec(`cd ${toPath} && git reset && git checkout . && git clean -f -d`);
62
+ shellExec(`underpost pull ${toPath} underpostnet/pwa-microservices-template`);
63
+ }
64
+ } else {
65
+ fs.removeSync(toPath);
66
+ }
59
67
 
60
68
  for (const copyPath of result) {
61
69
  const folder = getDirname(`${toPath}/${copyPath}`);
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.856
1
+ ## underpost ci/cd cli v2.8.858
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -442,6 +442,8 @@ Options:
442
442
  --export Exports to local storage.
443
443
  --crons Apply to cron data collection
444
444
  --instances Apply to instance data collection
445
+ --generate Generate cluster metadata
446
+ --itc Apply under container execution context
445
447
  -h, --help display help for command
446
448
 
447
449
  ```
@@ -483,8 +485,8 @@ updates.
483
485
  Arguments:
484
486
  deploy-list A comma-separated list of deployment IDs (e.g.,
485
487
  "default-a,default-b").
486
- job-list A comma-separated list of job IDs. Options: callback. Defaults
487
- to all available jobs.
488
+ job-list A comma-separated list of job IDs. Options: callback,
489
+ getRelatedDeployId. Defaults to all available jobs.
488
490
 
489
491
  Options:
490
492
  --itc Executes cron jobs within the container execution context.
@@ -591,7 +593,7 @@ Options:
591
593
  Runs a script from the specified path.
592
594
 
593
595
  Arguments:
594
- runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, cyberia-ide, engine-ide, template-deploy, clean, pull, release-deploy, ssh-deploy, ide, monitor, db-client, cluster, deploy, tf-vae-test, deploy-job.
596
+ runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, underpost-config, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, cyberia-ide, engine-ide, template-deploy, clean, pull, release-deploy, ssh-deploy, ide, dev-client, dev-api, monitor, db-client, cluster, deploy, tf-vae-test, deploy-job.
595
597
  path The absolute or relative directory path where the script is located.
596
598
 
597
599
  Options:
@@ -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.856
20
+ image: localhost/rockylinux9-underpost:v2.8.858
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.856
103
+ image: localhost/rockylinux9-underpost:v2.8.858
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
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.856",
5
+ "version": "2.8.858",
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/cron.js CHANGED
@@ -21,7 +21,6 @@ const logger = loggerFactory(import.meta);
21
21
  * @memberof UnderpostCron
22
22
  */
23
23
  class UnderpostCron {
24
- static NETWORK = [];
25
24
  static JOB = {
26
25
  /**
27
26
  * DNS cli API
@@ -53,7 +52,6 @@ class UnderpostCron {
53
52
  options = { itc: false, init: false, git: false },
54
53
  ) {
55
54
  if (options.init === true) {
56
- UnderpostCron.NETWORK = [];
57
55
  const jobDeployId = fs.readFileSync('./engine-private/deploy/dd.cron', 'utf8').trim();
58
56
  deployList = fs.readFileSync('./engine-private/deploy/dd.router', 'utf8').trim();
59
57
  const confCronConfig = JSON.parse(fs.readFileSync(`./engine-private/conf/${jobDeployId}/conf.cron.json`));
@@ -62,21 +60,8 @@ class UnderpostCron {
62
60
  const name = `${jobDeployId}-${job}`;
63
61
  let deployId;
64
62
  shellExec(Cmd.delete(name));
65
- switch (job) {
66
- case 'dns':
67
- deployId = jobDeployId;
68
- break;
69
-
70
- default:
71
- deployId = deployList;
72
- break;
73
- }
63
+ deployId = UnderpostCron.API.getRelatedDeployId(job);
74
64
  shellExec(Cmd.cron(deployId, job, name, confCronConfig.jobs[job].expression, options));
75
- UnderpostCron.NETWORK.push({
76
- deployId,
77
- jobId: job,
78
- expression: confCronConfig.jobs[job].expression,
79
- });
80
65
  }
81
66
  }
82
67
  if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
@@ -87,6 +72,16 @@ class UnderpostCron {
87
72
  if (UnderpostCron.JOB[jobId]) await UnderpostCron.JOB[jobId].callback(deployList, options);
88
73
  }
89
74
  },
75
+ getRelatedDeployId(jobId) {
76
+ switch (jobId) {
77
+ case 'dns':
78
+ return fs.readFileSync('./engine-private/deploy/dd.cron', 'utf8').trim();
79
+ case 'backup':
80
+ return fs.readFileSync('./engine-private/deploy/dd.router', 'utf8').trim();
81
+ default:
82
+ return fs.readFileSync('./engine-private/deploy/dd.cron', 'utf8').trim();
83
+ }
84
+ },
90
85
  };
91
86
  }
92
87
 
package/src/cli/db.js CHANGED
@@ -4,6 +4,8 @@ import { shellExec } from '../server/process.js';
4
4
  import fs from 'fs-extra';
5
5
  import UnderpostDeploy from './deploy.js';
6
6
  import UnderpostCron from './cron.js';
7
+ import { DataBaseProvider } from '../db/DataBaseProvider.js';
8
+ import { loadReplicas, pathPortAssignmentFactory } from '../server/conf.js';
7
9
 
8
10
  const logger = loggerFactory(import.meta);
9
11
 
@@ -217,28 +219,29 @@ class UnderpostDB {
217
219
  }
218
220
  }
219
221
  },
220
- async updateDashboardData(
222
+ async clusterMetadataFactory(
221
223
  deployId = process.env.DEFAULT_DEPLOY_ID,
222
224
  host = process.env.DEFAULT_DEPLOY_HOST,
223
225
  path = process.env.DEFAULT_DEPLOY_PATH,
224
226
  ) {
225
- try {
226
- deployId = deployId ?? process.env.DEFAULT_DEPLOY_ID;
227
- host = host ?? process.env.DEFAULT_DEPLOY_HOST;
228
- path = path ?? process.env.DEFAULT_DEPLOY_PATH;
229
-
230
- const { db } = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'))[host][
231
- path
232
- ];
227
+ deployId = deployId ?? process.env.DEFAULT_DEPLOY_ID;
228
+ host = host ?? process.env.DEFAULT_DEPLOY_HOST;
229
+ path = path ?? process.env.DEFAULT_DEPLOY_PATH;
230
+ const env = 'production';
231
+ const deployList = fs.readFileSync('./engine-private/deploy/dd.router', 'utf8').split(',');
233
232
 
234
- await DataBaseProvider.load({ apis: ['instance'], host, path, db });
233
+ const { db } = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'))[host][
234
+ path
235
+ ];
236
+ try {
237
+ await DataBaseProvider.load({ apis: ['instance', 'cron'], host, path, db });
235
238
 
236
239
  /** @type {import('../api/instance/instance.model.js').InstanceModel} */
237
240
  const Instance = DataBaseProvider.instance[`${host}${path}`].mongoose.models.Instance;
238
241
 
239
242
  await Instance.deleteMany();
240
243
 
241
- for (const _deployId of deployList.split(',')) {
244
+ for (const _deployId of deployList) {
242
245
  const deployId = _deployId.trim();
243
246
  if (!deployId) continue;
244
247
  const confServer = loadReplicas(
@@ -252,34 +255,45 @@ class UnderpostDB {
252
255
  for (const { path, port } of pathPortAssignmentData[host]) {
253
256
  if (!confServer[host][path]) continue;
254
257
 
255
- const { client, runtime, apis } = confServer[host][path];
256
-
257
- const body = {
258
- deployId,
259
- host,
260
- path,
261
- port,
262
- client,
263
- runtime,
264
- apis,
265
- };
266
-
267
- logger.info('save', body);
258
+ const { client, runtime, apis, peer } = confServer[host][path];
259
+ {
260
+ const body = {
261
+ deployId,
262
+ host,
263
+ path,
264
+ port,
265
+ client,
266
+ runtime,
267
+ apis,
268
+ };
269
+
270
+ logger.info('Instance save', body);
271
+ await new Instance(body).save();
272
+ }
268
273
 
269
- await new Instance(body).save();
274
+ if (peer) {
275
+ const body = {
276
+ deployId,
277
+ host,
278
+ path: path === '/' ? '/peer' : `${path}/peer`,
279
+ port: port + 1,
280
+ runtime: 'nodejs',
281
+ };
282
+
283
+ logger.info('Instance save', body);
284
+ await new Instance(body).save();
285
+ }
270
286
  }
271
287
  }
272
288
  }
273
-
274
- await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
275
289
  } catch (error) {
276
290
  logger.error(error, error.stack);
277
291
  }
278
292
 
279
293
  try {
280
- const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
281
- const confServer = JSON.parse(fs.readFileSync(confServerPath, 'utf8'));
282
- const { db } = confServer[host][path];
294
+ const cronDeployId = fs.readFileSync('./engine-private/deploy/dd.cron', 'utf8').trim();
295
+ const confCronPath = `./engine-private/conf/${cronDeployId}/conf.cron.json`;
296
+ const confCron = JSON.parse(fs.readFileSync(confCronPath, 'utf8'));
283
297
 
284
298
  await DataBaseProvider.load({ apis: ['cron'], host, path, db });
285
299
 
@@ -288,21 +302,28 @@ class UnderpostDB {
288
302
 
289
303
  await Cron.deleteMany();
290
304
 
291
- for (const cronInstance of UnderpostCron.NETWORK) {
292
- logger.info('save', cronInstance);
293
- await new Cron(cronInstance).save();
305
+ for (const jobId of Object.keys(confCron.jobs)) {
306
+ const body = {
307
+ jobId,
308
+ deployId: UnderpostCron.API.getRelatedDeployId(jobId),
309
+ expression: confCron.jobs[jobId].expression,
310
+ enabled: confCron.jobs[jobId].enabled,
311
+ };
312
+ logger.info('Cron save', body);
313
+ await new Cron(body).save();
294
314
  }
295
-
296
- await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
297
315
  } catch (error) {
298
316
  logger.error(error, error.stack);
299
317
  }
318
+ await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
300
319
  },
301
320
  clusterMetadataBackupCallback(
302
321
  deployId = process.env.DEFAULT_DEPLOY_ID,
303
322
  host = process.env.DEFAULT_DEPLOY_HOST,
304
323
  path = process.env.DEFAULT_DEPLOY_PATH,
305
324
  options = {
325
+ generate: false,
326
+ itc: false,
306
327
  import: false,
307
328
  export: false,
308
329
  instances: false,
@@ -313,6 +334,10 @@ class UnderpostDB {
313
334
  host = host ?? process.env.DEFAULT_DEPLOY_HOST;
314
335
  path = path ?? process.env.DEFAULT_DEPLOY_PATH;
315
336
 
337
+ if (options.generate === true) {
338
+ UnderpostDB.API.clusterMetadataFactory(deployId, host, path);
339
+ }
340
+
316
341
  if (options.instances === true) {
317
342
  const outputPath = './engine-private/instances';
318
343
  if (fs.existsSync(outputPath)) fs.mkdirSync(outputPath, { recursive: true });
package/src/cli/deploy.js CHANGED
@@ -323,10 +323,7 @@ Password: <Your Key>
323
323
  logger.info('router', await UnderpostDeploy.API.routerFactory(deployList, env));
324
324
  return;
325
325
  }
326
- shellExec(`kubectl delete configmap underpost-config`);
327
- shellExec(
328
- `kubectl create configmap underpost-config --from-file=/home/dd/engine/engine-private/conf/dd-cron/.env.${env}`,
329
- );
326
+ UnderpostDeploy.API.configMap(env);
330
327
  let renderHosts = '';
331
328
  let concatHots = '';
332
329
  const etcHost = (
@@ -477,6 +474,12 @@ Password: <Your Key>
477
474
  }
478
475
  return { ready: notReadyPods.length === 0, notReadyPods, readyPods };
479
476
  },
477
+ configMap(env) {
478
+ shellExec(`kubectl delete configmap underpost-config`);
479
+ shellExec(
480
+ `kubectl create configmap underpost-config --from-file=/home/dd/engine/engine-private/conf/dd-cron/.env.${env}`,
481
+ );
482
+ },
480
483
  };
481
484
  }
482
485
 
package/src/cli/index.js CHANGED
@@ -249,6 +249,8 @@ program
249
249
  .option('--export', 'Exports to local storage.')
250
250
  .option('--crons', 'Apply to cron data collection')
251
251
  .option('--instances', 'Apply to instance data collection')
252
+ .option('--generate', 'Generate cluster metadata')
253
+ .option('--itc', 'Apply under container execution context')
252
254
  .description('Manages cluster metadata operations, including import and export.')
253
255
  .action(Underpost.db.clusterMetadataBackupCallback);
254
256
 
@@ -120,10 +120,7 @@ class UnderpostMonitor {
120
120
  fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'),
121
121
  );
122
122
 
123
- shellExec(`kubectl delete configmap underpost-config`);
124
- shellExec(
125
- `kubectl create configmap underpost-config --from-file=/home/dd/engine/engine-private/conf/dd-cron/.env.${env}`,
126
- );
123
+ UnderpostDeploy.API.configMap(env);
127
124
 
128
125
  for (const host of Object.keys(confServer)) {
129
126
  shellExec(`sudo kubectl delete HTTPProxy ${host}`);
package/src/cli/run.js CHANGED
@@ -54,6 +54,9 @@ class UnderpostRun {
54
54
  }`,
55
55
  );
56
56
  },
57
+ 'underpost-config': (path, options = UnderpostRun.DEFAULT_OPTION) => {
58
+ UnderpostDeploy.API.configMap(path ?? 'production');
59
+ },
57
60
  'gpu-env': (path, options = UnderpostRun.DEFAULT_OPTION) => {
58
61
  shellExec(
59
62
  `node bin cluster --dev --reset && node bin cluster --dev --dedicated-gpu --kubeadm && kubectl get pods --all-namespaces -o wide -w`,
@@ -128,6 +131,16 @@ class UnderpostRun {
128
131
  const { underpostRoot } = options;
129
132
  shellExec(`node ${underpostRoot}/bin/vs ${path}`);
130
133
  },
134
+ 'dev-client': (_path, options = UnderpostRun.DEFAULT_OPTION) => {
135
+ let [deployId, hostpath, subConf, lite] = _path.split(',');
136
+ let [host, path] = hostpath.split('/');
137
+ if (!path) path = '/';
138
+ shellExec(`npm run dev-client ${deployId} ${host} ${path} ${subConf} static${lite === 'l' ? ' l' : ''}`);
139
+ },
140
+ 'dev-api': (path, options = UnderpostRun.DEFAULT_OPTION) => {
141
+ let [deployId, subConf] = path.split(',');
142
+ shellExec(`npm run dev-api ${deployId} ${subConf}`);
143
+ },
131
144
  monitor: (path, options = UnderpostRun.DEFAULT_OPTION) => {
132
145
  const pid = getTerminalPid();
133
146
  logger.info('monitor pid', pid);
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.856';
38
+ static version = 'v2.8.858';
39
39
  /**
40
40
  * Repository cli API
41
41
  * @static
@@ -59,7 +59,7 @@ const clientLiveBuild = async () => {
59
59
  const updates = JSON.parse(fs.readFileSync(`./tmp/client.build.json`, 'utf8'));
60
60
  const liveClientBuildPaths = [];
61
61
  for (let srcPath of updates) {
62
- srcPath = srcPath.replaceAll('/', `\\`); // linux case
62
+ srcPath = srcPath.replaceAll('/', `\\`);
63
63
 
64
64
  const srcBuildPath = `./src${srcPath.split('src')[1].replace(/\\/g, '/')}`;
65
65
  if (
@@ -7,7 +7,7 @@ const logger = loggerFactory(import.meta);
7
7
 
8
8
  const createClientDevServer = () => {
9
9
  // process.argv.slice(2).join(' ')
10
- shellExec(`env-cmd -f .env.development node bin/deploy build-full-client ${process.argv.slice(2).join(' ')} l`);
10
+ shellExec(`env-cmd -f .env.development node bin/deploy build-full-client ${process.argv.slice(2).join(' ')}`);
11
11
  shellExec(
12
12
  `env-cmd -f .env.development node src/api ${process.argv[2]}${process.argv[5] ? ` ${process.argv[5]}` : ''}${
13
13
  process.argv.includes('static') ? ' static' : ''