bincode-dev 0.0.16 → 0.0.18

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/bin/bincode CHANGED
@@ -5,6 +5,26 @@ const fs = require("fs")
5
5
  const path = require("path")
6
6
  const os = require("os")
7
7
 
8
+ function printWrapperVersionAndExit() {
9
+ try {
10
+ const pkgPath = path.join(__dirname, "..", "package.json")
11
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"))
12
+ if (pkg && pkg.version) {
13
+ process.stdout.write(String(pkg.version) + "\n")
14
+ process.exit(0)
15
+ }
16
+ } catch {
17
+ // ignore
18
+ }
19
+ }
20
+
21
+ // Ensure `bincode -v/--version/version` always reports the wrapper npm package version,
22
+ // not whatever is embedded inside the native binary (which can be confusing during publishing tests).
23
+ const rawArgs = process.argv.slice(2)
24
+ if (rawArgs.includes("-v") || rawArgs.includes("--version") || rawArgs[0] === "version") {
25
+ printWrapperVersionAndExit()
26
+ }
27
+
8
28
  function run(target) {
9
29
  const env = { ...process.env }
10
30
  // Ensure this package variant uses its own config/data directories.
@@ -66,6 +86,7 @@ try {
66
86
  `Missing optional dependency: ${targetPkg}`,
67
87
  ``,
68
88
  `This usually happens if you installed with --no-optional (or your package manager skipped optional deps).`,
89
+ `Also check that install scripts are not disabled (npm config ignore-scripts).`,
69
90
  `Reinstall without skipping optional dependencies, e.g.:`,
70
91
  ` npm i bincode-dev`,
71
92
  ``,
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "bincode-dev",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Bincode: AI-powered development CLI (dev/test version, not affiliated with opencode)",
5
5
  "bin": {
6
6
  "bincode": "./bin/bincode"
7
7
  },
8
8
  "optionalDependencies": {
9
- "bincode-dev-darwin-arm64": "0.0.16",
10
- "bincode-dev-darwin-x64": "0.0.16",
11
- "bincode-dev-linux-x64": "0.0.16",
12
- "bincode-dev-windows-x64": "0.0.16"
9
+ "bincode-dev-darwin-arm64": "0.0.18",
10
+ "bincode-dev-darwin-x64": "0.0.18",
11
+ "bincode-dev-linux-x64": "0.0.18",
12
+ "bincode-dev-windows-x64": "0.0.18"
13
13
  },
14
14
  "scripts": {
15
15
  "build": "bun script/build.ts",
16
16
  "prepack": "node scripts/prepack.js",
17
+ "postinstall": "node scripts/postinstall.js",
17
18
  "prepare:platform-packages": "node scripts/prepare-platform-packages.js"
18
19
  },
19
20
  "license": "MIT",
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Ensures the correct platform binary package is present after installation.
3
+ *
4
+ * Why:
5
+ * - Some npm setups may skip optionalDependencies, especially in global installs.
6
+ * - We want `npm i(-g) bincode-dev` to "just work" without manual platform package install.
7
+ *
8
+ * Approach:
9
+ * - Detect the expected platform package name from os/arch.
10
+ * - If not present, run `npm install --no-save <pkg>@<version>` with cwd at this package root.
11
+ * This installs into `bincode-dev/node_modules`, which `require.resolve()` can find.
12
+ */
13
+ const childProcess = require("child_process")
14
+ const fs = require("fs")
15
+ const path = require("path")
16
+ const os = require("os")
17
+
18
+ const root = path.join(__dirname, "..")
19
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"))
20
+ const version = pkg.version
21
+
22
+ const platform = os.platform()
23
+ const arch = os.arch()
24
+
25
+ const targetPkgMap = {
26
+ "darwin:arm64": "bincode-dev-darwin-arm64",
27
+ "darwin:x64": "bincode-dev-darwin-x64",
28
+ "linux:x64": "bincode-dev-linux-x64",
29
+ "win32:x64": "bincode-dev-windows-x64",
30
+ }
31
+
32
+ const key = `${platform}:${arch}`
33
+ const targetPkg = targetPkgMap[key]
34
+
35
+ if (!targetPkg) process.exit(0)
36
+
37
+ function isInstalled() {
38
+ try {
39
+ require.resolve(`${targetPkg}/package.json`, { paths: [root] })
40
+ return true
41
+ } catch {
42
+ return false
43
+ }
44
+ }
45
+
46
+ if (isInstalled()) {
47
+ process.exit(0)
48
+ }
49
+
50
+ // If scripts are disabled (ignore-scripts), this file won't run at all.
51
+ // If npm isn't available, we can't self-heal.
52
+ const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm"
53
+
54
+ const args = ["install", "--no-save", "--silent", "--no-audit", "--no-fund", `${targetPkg}@${version}`]
55
+ const res = childProcess.spawnSync(npmCmd, args, {
56
+ cwd: root,
57
+ stdio: "inherit",
58
+ env: process.env,
59
+ })
60
+
61
+ if (res.status !== 0) {
62
+ // Don't hard-fail install; wrapper will print a clearer message on execution.
63
+ process.exit(0)
64
+ }
65
+
66
+