embedlabs-cli 0.1.0-alpha.44 → 0.1.0-alpha.46

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
@@ -7,4 +7,4 @@ npm install -g embedlabs-cli@alpha
7
7
  embedlabs-cli --help
8
8
  ```
9
9
 
10
- This package forwards to `@kvell007/embed-labs-cli@0.1.0-alpha.43`.
10
+ This package forwards to `@kvell007/embed-labs-cli@0.1.0-alpha.44`.
@@ -1,78 +1,38 @@
1
1
  #!/usr/bin/env node
2
- import { spawn } from "node:child_process";
3
- import { createHash } from "node:crypto";
4
- import { readFileSync, rmSync, writeFileSync } from "node:fs";
5
- import { tmpdir, arch, platform } from "node:os";
6
- import { join } from "node:path";
2
+ import { writeFileSync } from "node:fs";
3
+ import { arch, platform } from "node:os";
7
4
 
8
5
  const phase = process.argv[2] ?? "postinstall";
9
6
  const target = `${platform()}-${arch()}`;
10
- const progressId = createHash("sha256").update(process.cwd()).digest("hex").slice(0, 16);
11
- const statePath = join(tmpdir(), `embedlabs-install-${progressId}.json`);
12
- const stopPath = `${statePath}.stop`;
13
-
14
- if (phase === "preinstall") {
15
- startWorker();
16
- } else {
17
- stopWorker();
18
- await finishProgress();
19
- }
20
-
21
- function startWorker() {
22
- rmQuiet(stopPath);
23
- writeProgress(5, `install: initializing (${target})`);
24
- const child = spawn(process.execPath, ["-e", workerSource(), stopPath], {
25
- env: { ...process.env, EMBEDLABS_INSTALL_TARGET: target },
26
- stdio: "ignore"
27
- });
28
- child.unref();
29
- writeFileSync(statePath, JSON.stringify({ pid: child.pid, started_at: Date.now() }), "utf8");
30
- }
31
-
32
- function workerSource() {
33
- return [
34
- "const fs = require('node:fs');",
35
- "const stopPath = process.argv[1];",
36
- "const steps = [[10,'install: checking platform'],[15,'install: resolving packages'],[20,'install: preparing dependency graph'],[25,'install: downloading packages'],[30,'install: downloading packages'],[35,'install: extracting packages'],[40,'install: extracting packages'],[45,'install: preparing CLI'],[50,'install: preparing CLI'],[55,'install: preparing native bridge'],[60,'install: preparing native bridge'],[65,'install: preparing command links'],[70,'install: preparing command links'],[75,'install: waiting for npm'],[80,'install: waiting for npm'],[84,'install: waiting for npm']];",
37
- "let tick = 0;",
38
- "function writeProgress(percent, message) {",
39
- " const line = '[Embed Labs] ' + String(percent).padStart(3, ' ') + '% ' + message + '\\n';",
40
- " if (process.env.EMBEDLABS_INSTALL_NO_TTY === '1') { process.stdout.write(line); return; }",
41
- " try { fs.writeFileSync(process.platform === 'win32' ? '\\\\\\\\.\\\\CONOUT$' : '/dev/tty', line, { flag: 'a' }); }",
42
- " catch { process.stdout.write(line); }",
43
- "}",
44
- "const timer = setInterval(() => {",
45
- " if (fs.existsSync(stopPath) || tick >= 180) { clearInterval(timer); process.exit(0); }",
46
- " const step = steps[Math.min(tick, steps.length - 1)];",
47
- " writeProgress(step[0], step[1]);",
48
- " tick += 1;",
49
- "}, 1000);"
50
- ].join("\n");
51
- }
52
-
53
- function stopWorker() {
54
- writeFileSync(stopPath, "stop", "utf8");
55
- try {
56
- const state = JSON.parse(readFileSync(statePath, "utf8"));
57
- if (typeof state.pid === "number") {
58
- try {
59
- process.kill(state.pid, "SIGTERM");
60
- } catch {}
61
- }
62
- } catch {}
63
- rmQuiet(statePath);
64
- rmQuiet(stopPath);
65
- }
66
-
67
- async function finishProgress() {
68
- for (const [percent, message] of [
69
- [88, "install: verifying commands"],
70
- [94, "install: finalizing installation"],
71
- [100, "install: complete"]
72
- ]) {
73
- writeProgress(percent, message);
74
- await sleep(1000);
75
- }
7
+ const steps = phase === "preinstall"
8
+ ? [
9
+ [5, `install: initializing (${target})`],
10
+ [10, "install: checking platform"],
11
+ [15, "install: resolving packages"],
12
+ [20, "install: preparing dependency graph"],
13
+ [25, "install: downloading packages"],
14
+ [30, "install: downloading packages"],
15
+ [35, "install: extracting packages"],
16
+ [40, "install: extracting packages"],
17
+ [45, "install: preparing CLI"],
18
+ [50, "install: preparing CLI"],
19
+ [55, "install: preparing native bridge"],
20
+ [60, "install: preparing native bridge"],
21
+ [65, "install: preparing command links"],
22
+ [70, "install: preparing command links"],
23
+ [75, "install: waiting for npm"],
24
+ [80, "install: waiting for npm"],
25
+ [84, "install: waiting for npm"]
26
+ ]
27
+ : [
28
+ [88, "install: verifying commands"],
29
+ [94, "install: finalizing installation"],
30
+ [100, "install: complete"]
31
+ ];
32
+
33
+ for (const [percent, message] of steps) {
34
+ writeProgress(percent, message);
35
+ await sleep(1000);
76
36
  }
77
37
 
78
38
  function writeProgress(percent, message) {
@@ -91,9 +51,3 @@ function writeProgress(percent, message) {
91
51
  function sleep(ms) {
92
52
  return new Promise((resolve) => setTimeout(resolve, ms));
93
53
  }
94
-
95
- function rmQuiet(filePath) {
96
- try {
97
- rmSync(filePath, { force: true });
98
- } catch {}
99
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "embedlabs-cli",
3
- "version": "0.1.0-alpha.44",
3
+ "version": "0.1.0-alpha.46",
4
4
  "description": "EmbedBoard CLI alias package for Embed Labs Cloud integration testing.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  "README.md"
17
17
  ],
18
18
  "dependencies": {
19
- "@kvell007/embed-labs-cli": "0.1.0-alpha.43"
19
+ "@kvell007/embed-labs-cli": "0.1.0-alpha.44"
20
20
  },
21
21
  "publishConfig": {
22
22
  "access": "public",