@skillsgate/tui 0.1.6 → 0.1.10

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.
Files changed (2) hide show
  1. package/bin/skillsgate-tui +32 -19
  2. package/package.json +6 -6
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { execFileSync } from "node:child_process";
2
+ import { execFileSync, execSync } from "node:child_process";
3
3
  import { createRequire } from "node:module";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import path from "node:path";
6
+ import fs from "node:fs";
6
7
  import os from "node:os";
7
8
 
8
9
  const platform = os.platform();
@@ -20,35 +21,47 @@ if (!pkg) {
20
21
  process.exit(1);
21
22
  }
22
23
 
23
- // Try multiple resolution strategies since global installs place optional
24
- // deps as siblings rather than nested under this package's node_modules.
25
24
  const binName = platform === "win32" ? "skillsgate-tui.exe" : "skillsgate-tui";
26
25
  const require = createRequire(import.meta.url);
27
26
  const thisDir = path.dirname(fileURLToPath(import.meta.url));
28
27
 
29
- const candidates = [
30
- // 1. Nested node_modules (local installs)
31
- () => require.resolve(`@skillsgate/${pkg}/${binName}`),
32
- // 2. Sibling in global node_modules (npm install -g)
33
- // thisDir = .../node_modules/@skillsgate/tui/bin go up 3 to node_modules
34
- () => path.join(thisDir, "..", "..", "..", `@skillsgate/${pkg}`, binName),
35
- ];
28
+ function findBinary() {
29
+ const candidates = [
30
+ // Nested node_modules (local installs)
31
+ () => require.resolve(`@skillsgate/${pkg}/${binName}`),
32
+ // Sibling in global node_modules (npm install -g)
33
+ () => path.join(thisDir, "..", "..", "..", `@skillsgate/${pkg}`, binName),
34
+ ];
36
35
 
37
- let binPath = null;
38
- for (const resolve of candidates) {
36
+ for (const resolve of candidates) {
37
+ try {
38
+ const p = resolve();
39
+ fs.accessSync(p, fs.constants.X_OK);
40
+ return p;
41
+ } catch {
42
+ continue;
43
+ }
44
+ }
45
+ return null;
46
+ }
47
+
48
+ let binPath = findBinary();
49
+
50
+ // Auto-install the platform binary if missing (npm v11+ skips optionalDeps for global installs)
51
+ if (!binPath) {
52
+ const version = require("../package.json").version;
53
+ const fullPkg = `@skillsgate/${pkg}@${version}`;
54
+ console.error(`Installing platform binary (${fullPkg})...`);
39
55
  try {
40
- const p = resolve();
41
- // Verify it exists by importing fs synchronously
42
- require("fs").accessSync(p, require("fs").constants.X_OK);
43
- binPath = p;
44
- break;
56
+ execSync(`npm install -g ${fullPkg}`, { stdio: "inherit", timeout: 30000 });
57
+ binPath = findBinary();
45
58
  } catch {
46
- continue;
59
+ // fall through to error below
47
60
  }
48
61
  }
49
62
 
50
63
  if (!binPath) {
51
- console.error("Platform binary not found. Try reinstalling: npm install -g @skillsgate/tui");
64
+ console.error(`Platform binary not found. Run manually: npm install -g @skillsgate/${pkg}`);
52
65
  process.exit(1);
53
66
  }
54
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillsgate/tui",
3
- "version": "0.1.6",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "skillsgate-tui": "bin/skillsgate-tui"
@@ -16,11 +16,11 @@
16
16
  "gray-matter": "4.0.3"
17
17
  },
18
18
  "optionalDependencies": {
19
- "@skillsgate/tui-darwin-arm64": "0.1.6",
20
- "@skillsgate/tui-darwin-x64": "0.1.6",
21
- "@skillsgate/tui-linux-x64": "0.1.6",
22
- "@skillsgate/tui-linux-arm64": "0.1.6",
23
- "@skillsgate/tui-win32-x64": "0.1.6"
19
+ "@skillsgate/tui-darwin-arm64": "0.1.10",
20
+ "@skillsgate/tui-darwin-x64": "0.1.10",
21
+ "@skillsgate/tui-linux-x64": "0.1.10",
22
+ "@skillsgate/tui-linux-arm64": "0.1.10",
23
+ "@skillsgate/tui-win32-x64": "0.1.10"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "19.1.5"