underpost 2.8.837 → 2.8.838

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,16 +24,18 @@ template
24
24
 
25
25
 
26
26
 
27
+
27
28
  <!-- badges -->
28
29
 
29
30
 
30
- [![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.837)](https://socket.dev/npm/package/underpost/overview/2.8.837) [![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)
31
+ [![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.838)](https://socket.dev/npm/package/underpost/overview/2.8.838) [![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)
31
32
 
32
33
 
33
34
  <!-- end-badges -->
34
35
 
35
36
 
36
37
 
38
+
37
39
  </div>
38
40
 
39
41
  <div align="center">
@@ -78,7 +80,7 @@ Run dev client server
78
80
  npm run dev
79
81
  ```
80
82
  <!-- -->
81
- ## underpost ci/cd cli v2.8.837
83
+ ## underpost ci/cd cli v2.8.838
82
84
 
83
85
  ### Usage: `underpost [options] [command]`
84
86
  ```
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.837
1
+ ## underpost ci/cd cli v2.8.838
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -556,7 +556,7 @@ Runs a script from the specified path.
556
556
  Arguments:
557
557
  runner-id The runner ID to run. Options:
558
558
  spark-template, gpu-env, tf-gpu-test, ide,
559
- tf-vae-test, deploy-job.
559
+ monitor, tf-vae-test, deploy-job.
560
560
  path The absolute or relative directory path
561
561
  where the script is located.
562
562
 
@@ -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.837'
61
+ engine.version: '2.8.838'
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.837
20
+ image: localhost/rockylinux9-underpost:v2.8.838
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.837
103
+ image: localhost/rockylinux9-underpost:v2.8.838
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -8,14 +8,14 @@ for iface_path in /sys/class/net/*; do
8
8
  operstate=$(< "$iface_path/operstate")
9
9
  mtu=$(< "$iface_path/mtu")
10
10
 
11
- # Driver: módulo kernel que maneja esta interfaz
11
+ # Driver
12
12
  if [ -L "$iface_path/device/driver" ]; then
13
13
  driver=$(basename "$(readlink -f "$iface_path/device/driver")")
14
14
  else
15
15
  driver="—"
16
16
  fi
17
17
 
18
- # Vendor:Device ID PCI
18
+ # Vendor device ID PCI
19
19
  pci_dev="$iface_path/device"
20
20
  if [ -f "$pci_dev/vendor" ] && [ -f "$pci_dev/device" ]; then
21
21
  vendor_id=$(< "$pci_dev/vendor")
@@ -28,7 +28,7 @@ for iface_path in /sys/class/net/*; do
28
28
  pci="—"
29
29
  fi
30
30
 
31
- # Link Speed: lectura directa de /sys/class/net/<iface>/speed
31
+ # Link Speed
32
32
  speed=$(cat "$iface_path/speed" 2>/dev/null || echo "—")
33
33
 
34
34
  echo "Interface: $name"
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.837",
5
+ "version": "2.8.838",
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,5 +1,5 @@
1
1
  import { getNpmRootPath, getUnderpostRootPath } from '../server/conf.js';
2
- import { pbcopy, shellExec } from '../server/process.js';
2
+ import { openTerminal, pbcopy, shellExec } from '../server/process.js';
3
3
  import dotenv from 'dotenv';
4
4
  import { loggerFactory } from '../server/logger.js';
5
5
  import { getLocalIPv4Address } from '../server/dns.js';
@@ -699,18 +699,8 @@ menuentry '${menuentryStr}' {
699
699
  fs.writeFileSync(`${nfsHostPath}/underpost/token-secret`, token_secret, 'utf8');
700
700
 
701
701
  // Open new terminals for live cloud-init logs.
702
- shellExec(
703
- `gnome-terminal -- bash -c "node ${underpostRoot}/bin baremetal --logs cloud; exec bash" & disown`,
704
- {
705
- async: true,
706
- },
707
- );
708
- shellExec(
709
- `gnome-terminal -- bash -c "node ${underpostRoot}/bin baremetal --logs machine; exec bash" & disown`,
710
- {
711
- async: true,
712
- },
713
- );
702
+ openTerminal(`node ${underpostRoot}/bin baremetal --logs cloud`);
703
+ openTerminal(`node ${underpostRoot}/bin baremetal --logs machine`);
714
704
  } catch (error) {
715
705
  logger.error(error, error.stack);
716
706
  } finally {
@@ -662,7 +662,7 @@ net.ipv4.ip_forward = 1' | sudo tee ${iptableConfPath}`);
662
662
  const archData = UnderpostBaremetal.API.getHostArch();
663
663
  logger.info('Installing essential host-level prerequisites for Kubernetes...', archData);
664
664
  // Install Docker and its dependencies
665
- shellExec(`sudo dnf -y install dnf-plugins-core`);
665
+ shellExec(`sudo dnf -y install dnf-plugins-core dbus-x11`);
666
666
  shellExec(`sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo`);
667
667
  shellExec(`sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin`);
668
668
 
package/src/cli/run.js CHANGED
@@ -1,9 +1,10 @@
1
- import { pbcopy, shellCd, shellExec } from '../server/process.js';
1
+ import { getTerminalPid, openTerminal, pbcopy, shellCd, shellExec } from '../server/process.js';
2
2
  import read from 'read';
3
3
  import { getNpmRootPath } from '../server/conf.js';
4
4
  import { loggerFactory } from '../server/logger.js';
5
5
  import UnderpostTest from './test.js';
6
6
  import fs from 'fs-extra';
7
+ import { timer } from '../client/components/core/CommonJs.js';
7
8
 
8
9
  const logger = loggerFactory(import.meta);
9
10
 
@@ -52,9 +53,73 @@ class UnderpostRun {
52
53
  const { underpostRoot } = options;
53
54
  shellExec(`node ${underpostRoot}/bin/vs ${path}`);
54
55
  },
56
+ monitor: (path, options = UnderpostRun.DEFAULT_OPTION) => {
57
+ const pid = getTerminalPid();
58
+ logger.info('monitor pid', pid);
59
+ const checkPath = '/await';
60
+ const _monitor = async () => {
61
+ const result = JSON.parse(
62
+ shellExec(`kubectl exec ${path} -- test -f ${checkPath} && echo "true" || echo "false"`, {
63
+ stdout: true,
64
+ disableLog: true,
65
+ silent: true,
66
+ }).trim(),
67
+ );
68
+ logger.info('monitor', result);
69
+ if (result === true) {
70
+ switch (path) {
71
+ case 'tf-vae-test':
72
+ {
73
+ const nameSpace = 'default';
74
+ const podName = path;
75
+ const basePath = '/home/dd';
76
+ const scriptPath = '/site/en/tutorials/generative/cvae.py';
77
+ shellExec(
78
+ `sudo kubectl cp ${nameSpace}/${podName}:${basePath}/docs${scriptPath} ${basePath}/lab/src/${scriptPath
79
+ .split('/')
80
+ .pop()}`,
81
+ );
82
+ const file = fs.readFileSync(`${basePath}/lab/src/${scriptPath.split('/').pop()}`, 'utf8');
83
+ fs.writeFileSync(
84
+ `${basePath}/lab/src/${scriptPath.split('/').pop()}`,
85
+ file.replace(
86
+ `import time`,
87
+ `import time
88
+ print('=== SCRIPT UPDATE TEST ===')`,
89
+ ),
90
+ 'utf8',
91
+ );
92
+ shellExec(
93
+ `sudo kubectl cp ${basePath}/lab/src/${scriptPath
94
+ .split('/')
95
+ .pop()} ${nameSpace}/${podName}:${basePath}/docs${scriptPath}`,
96
+ );
97
+ // shellExec(`sudo kubectl exec -i ${podName} -- sh -c "ipython ${basePath}/docs${scriptPath}"`);
98
+ shellExec(`sudo kubectl exec -i ${podName} -- sh -c "rm -rf ${checkPath}"`);
99
+ shellExec(`sudo kill -9 ${pid}`);
100
+ }
101
+ break;
102
+
103
+ default:
104
+ break;
105
+ }
106
+ return;
107
+ }
108
+ await timer(1000);
109
+ _monitor();
110
+ };
111
+ _monitor();
112
+ },
55
113
  'tf-vae-test': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
56
114
  const { underpostRoot } = options;
115
+ const podName = 'tf-vae-test';
57
116
  await UnderpostRun.RUNNERS['deploy-job']('', {
117
+ podName,
118
+ on: {
119
+ init: async () => {
120
+ openTerminal(`node bin run --dev monitor ${podName}`);
121
+ },
122
+ },
58
123
  args: [
59
124
  `pip install --upgrade \
60
125
  nbconvert \
@@ -68,7 +133,11 @@ class UnderpostRun {
68
133
  'git clone https://github.com/tensorflow/docs.git',
69
134
  'cd docs',
70
135
  'jupyter nbconvert --to python site/en/tutorials/generative/cvae.ipynb',
71
- 'ipython site/en/tutorials/generative/cvae.py',
136
+ `echo '' > /await`,
137
+ `echo '=== WAITING SCRIPT LAUNCH ==='`,
138
+ `while [ -f /await ]; do sleep 1; done`,
139
+ `ipython site/en/tutorials/generative/cvae.py`,
140
+ `echo '=== FINISHED ==='`,
72
141
  ],
73
142
  });
74
143
  },
@@ -134,6 +203,7 @@ EOF`;
134
203
  shellExec(cmd, { disableLog: true });
135
204
  const successInstance = await UnderpostTest.API.statusMonitor(podName);
136
205
  if (successInstance) {
206
+ options.on?.init ? await options.on.init() : null;
137
207
  shellExec(`kubectl logs -f ${podName}`);
138
208
  }
139
209
  },
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.837';
37
+ static version = 'v2.8.838';
38
38
  /**
39
39
  * Repository cli API
40
40
  * @static
@@ -10,8 +10,6 @@ dotenv.config();
10
10
 
11
11
  const logger = loggerFactory(import.meta);
12
12
 
13
- // process.exit();
14
-
15
13
  const getRootDirectory = () => process.cwd().replace(/\\/g, '/');
16
14
 
17
15
  const ProcessController = {
@@ -63,27 +61,19 @@ const shellCd = (cd, options = { disableLog: false }) => {
63
61
  return shell.cd(cd);
64
62
  };
65
63
 
66
- function pbcopy(data) {
67
- switch (process.platform) {
68
- case 'linux':
69
- {
70
- // sudo dnf install xclip
71
- // sudo apt update
72
- // sudo apt install xclip
73
- // paste: xclip -o
74
- // copy:
75
- // shellExec(`echo "${data}" | xclip -sel clip`, { async: true });
76
- }
77
-
78
- break;
64
+ const openTerminal = (cmd) =>
65
+ shellExec(`gnome-terminal -- bash -c "${cmd}; exec bash" & disown`, {
66
+ async: true,
67
+ stdout: true,
68
+ });
79
69
 
80
- default:
81
- break;
82
- }
70
+ // list all terminals: pgrep gnome-terminal
71
+ // list last terminal: pgrep -n gnome-terminal
72
+ const getTerminalPid = () => JSON.parse(shellExec(`pgrep -n gnome-terminal`, { stdout: true, silent: true }));
83
73
 
74
+ function pbcopy(data) {
84
75
  clipboard.writeSync(data || '🦄');
85
-
86
76
  logger.info(`copied to clipboard`, clipboard.readSync());
87
77
  }
88
78
 
89
- export { ProcessController, getRootDirectory, shellExec, shellCd, pbcopy };
79
+ export { ProcessController, getRootDirectory, shellExec, shellCd, pbcopy, openTerminal, getTerminalPid };