underpost 2.8.832 → 2.8.836

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.
@@ -58,8 +58,8 @@ jobs:
58
58
  - name: Set git global credentials
59
59
  run: |
60
60
  git config --global credential.helper ""
61
- git config --global user.name 'underpost.net'
62
- git config --global user.email 'admin@underpost.net'
61
+ git config --global user.name 'underpostnet'
62
+ git config --global user.email 'fcoverdugoa@underpost.net'
63
63
 
64
64
  - name: Clone and Push to github package repository
65
65
  run: |
@@ -70,8 +70,8 @@ jobs:
70
70
  git config --global --add safe.directory /__w/pwa-microservices-template/pwa-microservices-template
71
71
  git remote set-url origin git@github.com:underpostnet/pwa-microservices-template-ghpkg.git
72
72
  git init
73
- git config user.name 'underpost.net'
74
- git config user.email 'admin@underpost.net'
73
+ git config user.name 'underpostnet'
74
+ git config user.email 'fcoverdugoa@underpost.net'
75
75
  git add .
76
76
  git status
77
77
  underpost cmt . ci package-pwa-microservices-template-ghpkg 'Update github repo package'
@@ -41,8 +41,8 @@ jobs:
41
41
  - name: Set git global credentials
42
42
  run: |
43
43
  git config --global credential.helper ""
44
- git config --global user.name 'underpost.net'
45
- git config --global user.email 'admin@underpost.net'
44
+ git config --global user.name 'underpostnet'
45
+ git config --global user.email 'fcoverdugoa@underpost.net'
46
46
 
47
47
  - name: Clone github package repository
48
48
  run: |
@@ -52,8 +52,8 @@ jobs:
52
52
  cd ../pwa-microservices-template
53
53
  git remote set-url origin git@github.com:underpostnet/pwa-microservices-template.git
54
54
  git add .
55
- git config user.name 'underpost.net'
56
- git config user.email 'admin@underpost.net'
55
+ git config user.name 'underpostnet'
56
+ git config user.email 'fcoverdugoa@underpost.net'
57
57
  underpost cmt . ci package-pwa-microservices-template-ghpkg 'Update npm repo package'
58
58
  underpost push . underpostnet/pwa-microservices-template
59
59
  # cd ../engine
package/README.md CHANGED
@@ -22,7 +22,15 @@ template
22
22
 
23
23
  <div align="center">
24
24
 
25
- [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.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) [![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)
25
+
26
+ <!-- badges -->
27
+
28
+
29
+ [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.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.836)](https://socket.dev/npm/package/underpost/overview/2.8.836) [![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)
30
+
31
+
32
+ <!-- end-badges -->
33
+
26
34
 
27
35
  </div>
28
36
 
@@ -68,7 +76,7 @@ Run dev client server
68
76
  npm run dev
69
77
  ```
70
78
  <!-- -->
71
- ## underpost ci/cd cli v2.8.832
79
+ ## underpost ci/cd cli v2.8.836
72
80
 
73
81
  ### Usage: `underpost [options] [command]`
74
82
  ```
@@ -98,7 +106,7 @@ Commands:
98
106
  fs [options] [path] Manages file storage, defaulting to file upload operations.
99
107
  test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
100
108
  monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
101
- run [options] [path] Runs a script from the specified path.
109
+ run [options] <runner-id> [path] Runs a script from the specified path.
102
110
  lxd [options] Manages LXD containers and virtual machines.
103
111
  baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
104
112
  help [command] display help for command
package/bin/deploy.js CHANGED
@@ -744,7 +744,7 @@ try {
744
744
  fs.readFileSync(`./src/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
745
745
  'utf8',
746
746
  );
747
- shellExec(`node bin/deploy cli-docs`);
747
+ shellExec(`node bin/deploy cli-docs ${version} ${newVersion}`);
748
748
  shellExec(`node bin/deploy update-dependencies`);
749
749
  shellExec(`auto-changelog`);
750
750
  shellExec(`node bin/build dd`);
@@ -1106,7 +1106,7 @@ EOF`);
1106
1106
  }
1107
1107
 
1108
1108
  case 'cli-docs': {
1109
- buildCliDoc(program);
1109
+ buildCliDoc(program, process.argv[3], process.argv[4]);
1110
1110
  break;
1111
1111
  }
1112
1112
 
package/bin/file.js CHANGED
@@ -136,10 +136,27 @@ try {
136
136
  JSON.stringify(templatePackageLockJson, null, 4),
137
137
  'utf8',
138
138
  );
139
+ const badges = fs
140
+ .readFileSync(`./README.md`, 'utf8')
141
+ .split(`<!-- badges -->`)[1]
142
+ .split(`<!-- end-badges -->`)[0];
143
+ let originMd = fs.readFileSync(`../pwa-microservices-template/README.md`, 'utf8');
144
+
145
+ originMd =
146
+ originMd.split(`<!-- badges -->`)[0] +
147
+ `
148
+ <!-- badges -->
149
+ ` +
150
+ badges +
151
+ `
152
+ <!-- end-badges -->
153
+ ` +
154
+ originMd.split(`<!-- end-badges -->`)[1];
155
+
139
156
  const splitKeyword = '## underpost ci/cd cli';
140
157
  fs.writeFileSync(
141
158
  `../pwa-microservices-template/README.md`,
142
- fs.readFileSync(`../pwa-microservices-template/README.md`, 'utf8').split(`<!-- -->`)[0] +
159
+ originMd.split(`<!-- -->`)[0] +
143
160
  `<!-- -->
144
161
  ${splitKeyword + fs.readFileSync(`./README.md`, 'utf8').split(splitKeyword)[1]}`,
145
162
  'utf8',
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.832
1
+ ## underpost ci/cd cli v2.8.836
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -28,7 +28,7 @@ Commands:
28
28
  fs [options] [path] Manages file storage, defaulting to file upload operations.
29
29
  test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
30
30
  monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
31
- run [options] [path] Runs a script from the specified path.
31
+ run [options] <runner-id> [path] Runs a script from the specified path.
32
32
  lxd [options] Manages LXD containers and virtual machines.
33
33
  baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
34
34
  help [command] display help for command
@@ -549,17 +549,22 @@ Options:
549
549
 
550
550
  ### `run` :
551
551
  ```
552
- Usage: underpost run [options] [path]
552
+ Usage: underpost run [options] <runner-id> [path]
553
553
 
554
554
  Runs a script from the specified path.
555
555
 
556
556
  Arguments:
557
- path The absolute or relative directory path where the script is
558
- located.
557
+ runner-id The runner ID to run. Options: spark-template,
558
+ gpu-env, tf-gpu-test, ide, single-job.
559
+ path The absolute or relative directory path where the
560
+ script is located.
559
561
 
560
562
  Options:
561
- --dev Sets the development context environment for the script.
562
- -h, --help display help for command
563
+ --command <command-array> Array of commands to run.
564
+ --args <args-array> Array of arguments to pass to the command.
565
+ --dev Sets the development context environment for the
566
+ script.
567
+ -h, --help display help for command
563
568
 
564
569
  ```
565
570
 
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.8.832'
61
+ engine.version: '2.8.836'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-template-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.832
20
+ image: localhost/rockylinux9-underpost:v2.8.836
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-template-development-green
103
- image: localhost/rockylinux9-underpost:v2.8.832
103
+ image: localhost/rockylinux9-underpost:v2.8.836
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.832",
5
+ "version": "2.8.836",
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/index.js CHANGED
@@ -4,9 +4,9 @@ import Underpost from '../index.js';
4
4
  import { getNpmRootPath, getUnderpostRootPath, loadConf } from '../server/conf.js';
5
5
  import fs from 'fs-extra';
6
6
  import { commitData } from '../client/components/core/CommonJs.js';
7
- import { shellExec } from '../server/process.js';
8
7
  import UnderpostLxd from './lxd.js';
9
8
  import UnderpostBaremetal from './baremetal.js';
9
+ import UnderpostRun from './run.js';
10
10
 
11
11
  // Load environment variables from .env file
12
12
  const underpostRootPath = getUnderpostRootPath();
@@ -318,10 +318,13 @@ program
318
318
  // 'run' command: Run a script
319
319
  program
320
320
  .command('run')
321
+ .argument('<runner-id>', `The runner ID to run. Options: ${Object.keys(UnderpostRun.RUNNERS).join(', ')}.`)
321
322
  .argument('[path]', 'The absolute or relative directory path where the script is located.')
323
+ .option('--command <command-array>', 'Array of commands to run.')
324
+ .option('--args <args-array>', 'Array of arguments to pass to the command.')
322
325
  .option('--dev', 'Sets the development context environment for the script.')
323
326
  .description('Runs a script from the specified path.')
324
- .action(Underpost.run.callback);
327
+ .action(UnderpostRun.API.callback);
325
328
 
326
329
  // 'lxd' command: LXD management
327
330
  program
package/src/cli/run.js CHANGED
@@ -1,48 +1,118 @@
1
1
  import { pbcopy, shellCd, shellExec } from '../server/process.js';
2
2
  import read from 'read';
3
3
  import { getNpmRootPath } from '../server/conf.js';
4
+ import { loggerFactory } from '../server/logger.js';
5
+ import UnderpostTest from './test.js';
6
+ import fs from 'fs-extra';
7
+
8
+ const logger = loggerFactory(import.meta);
4
9
 
5
10
  class UnderpostRun {
11
+ static DEFAULT_OPTION = { dev: false };
12
+ static RUNNERS = {
13
+ 'spark-template': (path, options = UnderpostRun.DEFAULT_OPTION) => {
14
+ const dir = '/home/dd/spark-template';
15
+ shellExec(`sudo rm -rf ${dir}`);
16
+ shellCd('/home/dd');
17
+
18
+ // pbcopy(`cd /home/dd && sbt new underpostnet/spark-template.g8`);
19
+ // await read({ prompt: 'Command copy to clipboard, press enter to continue.\n' });
20
+ shellExec(`cd /home/dd && sbt new underpostnet/spark-template.g8 '--name=spark-template'`);
21
+
22
+ shellCd(dir);
23
+
24
+ shellExec(`git init && git add . && git commit -m "Base implementation"`);
25
+ shellExec(`chmod +x ./replace_params.sh`);
26
+ shellExec(`chmod +x ./build.sh`);
27
+
28
+ shellExec(`./replace_params.sh`);
29
+ shellExec(`./build.sh`);
30
+
31
+ shellCd('/home/dd/engine');
32
+ },
33
+ 'gpu-env': (path, options = UnderpostRun.DEFAULT_OPTION) => {
34
+ shellExec(
35
+ `node bin cluster --dev --reset && node bin cluster --dev --dedicated-gpu --kubeadm && kubectl get pods --all-namespaces -o wide -w`,
36
+ );
37
+ },
38
+ 'tf-gpu-test': (path, options = UnderpostRun.DEFAULT_OPTION) => {
39
+ const { underpostRoot } = options;
40
+ shellExec(`kubectl delete configmap tf-gpu-test-script`);
41
+ shellExec(`kubectl delete pod tf-gpu-test-pod`);
42
+ shellExec(`kubectl apply -f ${underpostRoot}/manifests/deployment/tensorflow/tf-gpu-test.yaml`);
43
+ },
44
+ ide: (path, options = UnderpostRun.DEFAULT_OPTION) => {
45
+ const { underpostRoot } = options;
46
+ shellExec(`node ${underpostRoot}/bin/vs ${path}`);
47
+ },
48
+ 'single-job': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
49
+ const podName = 'single-job';
50
+ const volumeName = 'single-job-volume';
51
+ const args = (options.args ? options.args : path ? [`python ${path}`] : []).filter((c) => c.trim());
52
+
53
+ const cmd = `kubectl apply -f - <<EOF
54
+ apiVersion: v1
55
+ kind: Pod
56
+ metadata:
57
+ name: ${podName}
58
+ namespace: default
59
+ spec:
60
+ restartPolicy: Never
61
+ runtimeClassName: nvidia
62
+ containers:
63
+ - name: tensorflow-gpu-tester
64
+ image: nvcr.io/nvidia/tensorflow:24.04-tf2-py3
65
+ imagePullPolicy: IfNotPresent
66
+ tty: true
67
+ stdin: true
68
+ command: ${JSON.stringify(options.command ? options.command : ['/bin/bash', '-c'])}
69
+ ${
70
+ args.length > 0
71
+ ? ` args:
72
+ - |
73
+ ${args.map((arg) => ` ${arg}`).join('\n')}`
74
+ : ''
75
+ }
76
+ resources:
77
+ limits:
78
+ nvidia.com/gpu: '1'
79
+ env:
80
+ - name: NVIDIA_VISIBLE_DEVICES
81
+ value: all
82
+ ${
83
+ path
84
+ ? `
85
+ volumeMounts:
86
+ - name: ${volumeName}
87
+ mountPath: ${path}
88
+ volumes:
89
+ - name: ${volumeName}
90
+ hostPath:
91
+ path: ${path}
92
+ type: ${fs.statSync(path).isDirectory() ? 'Directory' : 'File'}`
93
+ : ''
94
+ }
95
+ EOF`;
96
+ shellExec(`kubectl delete pod ${podName}`);
97
+ console.log(cmd);
98
+ shellExec(cmd, { disableLog: true });
99
+ const successInstance = await UnderpostTest.API.statusMonitor(podName);
100
+ if (successInstance) {
101
+ shellExec(`kubectl logs -f ${podName}`);
102
+ }
103
+ },
104
+ };
6
105
  static API = {
7
- async callback(path, options = { dev: false }) {
8
- const fileName = path.split('/').pop();
106
+ async callback(runner, path, options = UnderpostRun.DEFAULT_OPTION) {
9
107
  const npmRoot = getNpmRootPath();
10
108
  const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
11
-
12
- switch (fileName) {
13
- case 'spark-template': {
14
- const path = '/home/dd/spark-template';
15
- shellExec(`sudo rm -rf ${path}`);
16
- shellCd('/home/dd');
17
-
18
- // pbcopy(`cd /home/dd && sbt new underpostnet/spark-template.g8`);
19
- // await read({ prompt: 'Command copy to clipboard, press enter to continue.\n' });
20
- shellExec(`cd /home/dd && sbt new underpostnet/spark-template.g8 '--name=spark-template'`);
21
-
22
- shellCd(path);
23
-
24
- shellExec(`git init && git add . && git commit -m "Base implementation"`);
25
- shellExec(`chmod +x ./replace_params.sh`);
26
- shellExec(`chmod +x ./build.sh`);
27
-
28
- shellExec(`./replace_params.sh`);
29
- shellExec(`./build.sh`);
30
-
31
- shellCd('/home/dd/engine');
32
- break;
33
- }
34
- case 'gpu': {
35
- shellExec(
36
- `node bin cluster --dev --reset && node bin cluster --dev --dedicated-gpu --kubeadm && kubectl get pods --all-namespaces -o wide -w`,
37
- );
38
- break;
39
- }
40
- case 'tf':
41
- shellExec(`kubectl delete configmap tf-gpu-test-script`);
42
- shellExec(`kubectl delete pod tf-gpu-test-pod`);
43
- shellExec(`kubectl apply -f ${underpostRoot}/manifests/deployment/tensorflow/tf-gpu-test.yaml`);
44
- break;
45
- }
109
+ if (options.command) options.command = options.command.split(',');
110
+ if (options.args) options.args = options.args.split(',');
111
+ options.underpostRoot = underpostRoot;
112
+ options.npmRoot = npmRoot;
113
+ logger.info('callback', { path, options });
114
+ const result = await UnderpostRun.RUNNERS[runner](path, options);
115
+ return result;
46
116
  },
47
117
  };
48
118
  }
package/src/cli/test.js CHANGED
@@ -94,7 +94,7 @@ class UnderpostTest {
94
94
  const _monitor = async () => {
95
95
  await timer(deltaMs);
96
96
  const pods = UnderpostDeploy.API.get(podName, kindType);
97
- const result = pods.find((p) => p.STATUS === status);
97
+ let result = pods.find((p) => p.STATUS === status || (status === 'Running' && p.STATUS === 'Completed'));
98
98
  logger.info(
99
99
  `Testing pod ${podName}... ${result ? 1 : 0}/1 - elapsed time ${deltaMs * (index + 1)}s - attempt ${
100
100
  index + 1
package/src/index.js CHANGED
@@ -34,7 +34,7 @@ class Underpost {
34
34
  * @type {String}
35
35
  * @memberof Underpost
36
36
  */
37
- static version = 'v2.8.832';
37
+ static version = 'v2.8.836';
38
38
  /**
39
39
  * Repository cli API
40
40
  * @static
@@ -1171,7 +1171,7 @@ const writeEnv = (envPath, envObj) =>
1171
1171
  'utf8',
1172
1172
  );
1173
1173
 
1174
- const buildCliDoc = (program) => {
1174
+ const buildCliDoc = (program, oldVersion, newVersion) => {
1175
1175
  let md = shellExec(`node bin help`, { silent: true, stdout: true }).split('Options:');
1176
1176
  const baseOptions =
1177
1177
  `## ${md[0].split(`\n`)[2]}
@@ -1207,13 +1207,15 @@ const buildCliDoc = (program) => {
1207
1207
  `
1208
1208
  `;
1209
1209
  });
1210
+ md = md.replaceAll(oldVersion, newVersion);
1210
1211
  fs.writeFileSync(`./src/client/public/nexodev/docs/references/Command Line Interface.md`, md, 'utf8');
1211
1212
  fs.writeFileSync(`./cli.md`, md, 'utf8');
1212
1213
  const readmeSplit = `pwa-microservices-template</a>`;
1213
1214
  const readme = fs.readFileSync(`./README.md`, 'utf8').split(readmeSplit);
1214
1215
  fs.writeFileSync(
1215
1216
  './README.md',
1216
- readme[0] +
1217
+ (
1218
+ readme[0] +
1217
1219
  readmeSplit +
1218
1220
  `
1219
1221
 
@@ -1223,7 +1225,8 @@ const buildCliDoc = (program) => {
1223
1225
 
1224
1226
  <a target="_top" href="https://github.com/underpostnet/pwa-microservices-template/blob/master/cli.md">See complete CLI Docs here.</a>
1225
1227
 
1226
- `,
1228
+ `
1229
+ ).replaceAll(oldVersion, newVersion),
1227
1230
  'utf8',
1228
1231
  );
1229
1232
  };