@skillsgate/tui 0.1.4 → 0.1.6

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.
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ // Ensures the correct platform binary is installed.
3
+ // npm may skip optionalDependencies for global installs (npm v11+/Node v24+).
4
+ const { execSync } = require("child_process");
5
+ const os = require("os");
6
+ const path = require("path");
7
+ const fs = require("fs");
8
+
9
+ const platformMap = {
10
+ darwin: { arm64: "tui-darwin-arm64", x64: "tui-darwin-x64" },
11
+ linux: { arm64: "tui-linux-arm64", x64: "tui-linux-x64" },
12
+ win32: { x64: "tui-win32-x64" },
13
+ };
14
+
15
+ const pkg = platformMap[os.platform()]?.[os.arch()];
16
+ if (!pkg) process.exit(0);
17
+
18
+ // Check if already available as a sibling (optionalDeps worked)
19
+ const siblingPath = path.join(__dirname, "..", "..", "..", `@skillsgate/${pkg}`);
20
+ if (fs.existsSync(siblingPath)) process.exit(0);
21
+
22
+ // Also check nested node_modules
23
+ try {
24
+ require.resolve(`@skillsgate/${pkg}/package.json`);
25
+ process.exit(0);
26
+ } catch {}
27
+
28
+ // Not found — install it explicitly
29
+ const version = require("../package.json").version;
30
+ try {
31
+ execSync(`npm install -g @skillsgate/${pkg}@${version} --no-save`, {
32
+ stdio: "inherit",
33
+ timeout: 30000,
34
+ });
35
+ } catch {
36
+ console.warn(`Warning: could not install @skillsgate/${pkg}. Run manually: npm install -g @skillsgate/${pkg}`);
37
+ }
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { execFileSync } from "node:child_process";
3
3
  import { createRequire } from "node:module";
4
+ import { fileURLToPath } from "node:url";
5
+ import path from "node:path";
4
6
  import os from "node:os";
5
7
 
6
- const require = createRequire(import.meta.url);
7
-
8
8
  const platform = os.platform();
9
9
  const arch = os.arch();
10
10
 
@@ -20,10 +20,36 @@ if (!pkg) {
20
20
  process.exit(1);
21
21
  }
22
22
 
23
- try {
24
- const binPath = require.resolve(`@skillsgate/${pkg}/skillsgate-tui`);
25
- execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
26
- } catch {
23
+ // Try multiple resolution strategies since global installs place optional
24
+ // deps as siblings rather than nested under this package's node_modules.
25
+ const binName = platform === "win32" ? "skillsgate-tui.exe" : "skillsgate-tui";
26
+ const require = createRequire(import.meta.url);
27
+ const thisDir = path.dirname(fileURLToPath(import.meta.url));
28
+
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
+ ];
36
+
37
+ let binPath = null;
38
+ for (const resolve of candidates) {
39
+ 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;
45
+ } catch {
46
+ continue;
47
+ }
48
+ }
49
+
50
+ if (!binPath) {
27
51
  console.error("Platform binary not found. Try reinstalling: npm install -g @skillsgate/tui");
28
52
  process.exit(1);
29
53
  }
54
+
55
+ execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@skillsgate/tui",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "skillsgate-tui": "bin/skillsgate-tui"
7
7
  },
8
8
  "scripts": {
9
+ "postinstall": "node bin/postinstall.cjs",
9
10
  "dev": "bun --watch run src/index.tsx",
10
11
  "start": "bun run src/index.tsx"
11
12
  },
@@ -15,11 +16,11 @@
15
16
  "gray-matter": "4.0.3"
16
17
  },
17
18
  "optionalDependencies": {
18
- "@skillsgate/tui-darwin-arm64": "0.1.4",
19
- "@skillsgate/tui-darwin-x64": "0.1.4",
20
- "@skillsgate/tui-linux-x64": "0.1.4",
21
- "@skillsgate/tui-linux-arm64": "0.1.4",
22
- "@skillsgate/tui-win32-x64": "0.1.4"
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"
23
24
  },
24
25
  "peerDependencies": {
25
26
  "react": "19.1.5"