bincode-cli 1.0.1 โ†’ 1.0.3

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 (3) hide show
  1. package/bin/bincode +29 -25
  2. package/package.json +21 -25
  3. package/script/publish.ts +101 -2
package/bin/bincode CHANGED
@@ -1,12 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const childProcess = require("child_process")
4
- const fs = require("fs")
5
- const path = require("path")
6
- const os = require("os")
3
+ import { spawnSync } from "child_process"
4
+ import { existsSync, realpathSync, readdirSync } from "fs"
5
+ import { dirname, join } from "path"
6
+ import { platform, arch } from "os"
7
+ import { fileURLToPath } from "url"
8
+
9
+ const __filename = fileURLToPath(import.meta.url)
10
+ const __dirname = dirname(__filename)
7
11
 
8
12
  function run(target) {
9
- const result = childProcess.spawnSync(target, process.argv.slice(2), {
13
+ const result = spawnSync(target, process.argv.slice(2), {
10
14
  stdio: "inherit",
11
15
  })
12
16
  if (result.error) {
@@ -22,8 +26,8 @@ if (envPath) {
22
26
  run(envPath)
23
27
  }
24
28
 
25
- const scriptPath = fs.realpathSync(__filename)
26
- const scriptDir = path.dirname(scriptPath)
29
+ const scriptPath = realpathSync(__filename)
30
+ const scriptDir = dirname(scriptPath)
27
31
 
28
32
  const platformMap = {
29
33
  darwin: "darwin",
@@ -36,48 +40,48 @@ const archMap = {
36
40
  arm: "arm",
37
41
  }
38
42
 
39
- let platform = platformMap[os.platform()]
40
- if (!platform) {
41
- platform = os.platform()
43
+ let platformName = platformMap[platform()]
44
+ if (!platformName) {
45
+ platformName = platform()
42
46
  }
43
- let arch = archMap[os.arch()]
44
- if (!arch) {
45
- arch = os.arch()
47
+ let archName = archMap[arch()]
48
+ if (!archName) {
49
+ archName = arch()
46
50
  }
47
- const base = "bincode-" + platform + "-" + arch
48
- const binary = platform === "windows" ? "bincode.exe" : "bincode"
51
+ const base = "bincode-cli-" + platformName + "-" + archName
52
+ const binary = platformName === "windows" ? "bincode.exe" : "bincode"
49
53
 
50
54
  function findBinary(startDir) {
51
55
  // First, try to find binary in local package binaries directory
52
- const localBinariesPath = path.join(startDir, "..", "binaries", base, "bin", binary)
53
- if (fs.existsSync(localBinariesPath)) {
56
+ const localBinariesPath = join(startDir, "..", "binaries", base, "bin", binary)
57
+ if (existsSync(localBinariesPath)) {
54
58
  return localBinariesPath
55
59
  }
56
60
 
57
61
  // Try baseline variant if available
58
62
  const baselineBase = base + "-baseline"
59
- const baselinePath = path.join(startDir, "..", "binaries", baselineBase, "bin", binary)
60
- if (fs.existsSync(baselinePath)) {
63
+ const baselinePath = join(startDir, "..", "binaries", baselineBase, "bin", binary)
64
+ if (existsSync(baselinePath)) {
61
65
  return baselinePath
62
66
  }
63
67
 
64
68
  // Fallback: search in node_modules (for backward compatibility)
65
69
  let current = startDir
66
70
  for (;;) {
67
- const modules = path.join(current, "node_modules")
68
- if (fs.existsSync(modules)) {
69
- const entries = fs.readdirSync(modules)
71
+ const modules = join(current, "node_modules")
72
+ if (existsSync(modules)) {
73
+ const entries = readdirSync(modules)
70
74
  for (const entry of entries) {
71
75
  if (!entry.startsWith(base)) {
72
76
  continue
73
77
  }
74
- const candidate = path.join(modules, entry, "bin", binary)
75
- if (fs.existsSync(candidate)) {
78
+ const candidate = join(modules, entry, "bin", binary)
79
+ if (existsSync(candidate)) {
76
80
  return candidate
77
81
  }
78
82
  }
79
83
  }
80
- const parent = path.dirname(current)
84
+ const parent = dirname(current)
81
85
  if (parent === current) {
82
86
  return
83
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "name": "bincode-cli",
5
5
  "type": "module",
6
6
  "private": false,
@@ -10,6 +10,7 @@
10
10
  "build": "bun run script/build.ts",
11
11
  "dev": "bun run --conditions=browser ./src/index.ts",
12
12
  "publish:cli": "bun run script/publish.ts",
13
+ "prepublishOnly": "echo 'Preparing to publish...'",
13
14
  "random": "echo 'Random script updated at $(date)' && echo 'Change queued successfully' && echo 'Another change made' && echo 'Yet another change' && echo 'One more change' && echo 'Final change' && echo 'Another final change' && echo 'Yet another final change'",
14
15
  "clean": "echo 'Cleaning up...' && rm -rf node_modules dist",
15
16
  "lint": "echo 'Running lint checks...' && bun test --coverage",
@@ -18,7 +19,7 @@
18
19
  "deploy": "echo 'Deploying application...' && bun run build && echo 'Deployment completed successfully'"
19
20
  },
20
21
  "bin": {
21
- "bincode": "./bin/bincode"
22
+ "bincode": "bin/bincode"
22
23
  },
23
24
  "files": [
24
25
  "bin",
@@ -45,17 +46,16 @@
45
46
  "@parcel/watcher-linux-x64-musl": "2.5.1",
46
47
  "@parcel/watcher-win32-x64": "2.5.1",
47
48
  "@standard-schema/spec": "1.0.0",
48
- "@tsconfig/bun": "catalog:",
49
+ "@tsconfig/bun": "1.0.9",
49
50
  "@types/babel__core": "7.20.5",
50
- "@types/bun": "catalog:",
51
+ "@types/bun": "1.3.4",
51
52
  "@types/turndown": "5.0.5",
52
53
  "@types/yargs": "17.0.33",
53
- "typescript": "catalog:",
54
- "@typescript/native-preview": "catalog:",
54
+ "typescript": "5.8.2",
55
+ "@typescript/native-preview": "7.0.0-dev.20251207.1",
55
56
  "vscode-languageserver-types": "3.17.5",
56
57
  "why-is-node-running": "3.2.2",
57
- "zod-to-json-schema": "3.24.5",
58
- "@bincode-ai/script": "workspace:*"
58
+ "zod-to-json-schema": "3.24.5"
59
59
  },
60
60
  "dependencies": {
61
61
  "@actions/core": "1.11.1",
@@ -73,52 +73,48 @@
73
73
  "@ai-sdk/provider": "2.0.0",
74
74
  "@ai-sdk/provider-utils": "3.0.18",
75
75
  "@ai-sdk/xai": "2.0.42",
76
- "@bincode-ai/plugin": "workspace:*",
77
- "@bincode-ai/script": "workspace:*",
78
- "@bincode-ai/sdk": "workspace:*",
79
- "@bincode-ai/util": "workspace:*",
80
76
  "@clack/prompts": "1.0.0-alpha.1",
81
77
  "@hono/standard-validator": "0.1.5",
82
- "@hono/zod-validator": "catalog:",
78
+ "@hono/zod-validator": "0.4.2",
83
79
  "@modelcontextprotocol/sdk": "1.15.1",
84
80
  "@octokit/graphql": "9.0.2",
85
- "@octokit/rest": "catalog:",
86
- "@openauthjs/openauth": "catalog:",
81
+ "@octokit/rest": "22.0.0",
82
+ "@openauthjs/openauth": "0.0.0-20250322224806",
87
83
  "@openrouter/ai-sdk-provider": "1.5.2",
88
84
  "@opentui/core": "0.1.63",
89
85
  "@opentui/solid": "0.1.63",
90
86
  "@parcel/watcher": "2.5.1",
91
- "@pierre/diffs": "catalog:",
87
+ "@pierre/diffs": "1.0.2",
92
88
  "@solid-primitives/event-bus": "1.1.2",
93
89
  "@standard-schema/spec": "1.0.0",
94
90
  "@zip.js/zip.js": "2.7.62",
95
- "ai": "catalog:",
91
+ "ai": "5.0.97",
96
92
  "bun-pty": "0.4.2",
97
93
  "chokidar": "4.0.3",
98
94
  "clipboardy": "4.0.0",
99
95
  "decimal.js": "10.5.0",
100
- "diff": "catalog:",
96
+ "diff": "8.0.2",
101
97
  "fuzzysort": "3.1.0",
102
98
  "gray-matter": "4.0.3",
103
- "hono": "catalog:",
104
- "hono-openapi": "catalog:",
99
+ "hono": "4.10.7",
100
+ "hono-openapi": "1.1.2",
105
101
  "ignore": "7.0.5",
106
102
  "jsonc-parser": "3.3.1",
107
103
  "minimatch": "10.0.3",
108
104
  "open": "10.1.2",
109
105
  "opentui-spinner": "0.0.6",
110
106
  "partial-json": "0.1.7",
111
- "remeda": "catalog:",
112
- "solid-js": "catalog:",
107
+ "remeda": "2.26.0",
108
+ "solid-js": "1.9.10",
113
109
  "strip-ansi": "7.1.2",
114
110
  "tree-sitter-bash": "0.25.0",
115
111
  "turndown": "7.2.0",
116
- "ulid": "catalog:",
112
+ "ulid": "3.0.1",
117
113
  "vscode-jsonrpc": "8.2.1",
118
114
  "web-tree-sitter": "0.25.10",
119
115
  "xdg-basedir": "5.1.0",
120
116
  "yargs": "18.0.0",
121
- "zod": "catalog:",
117
+ "zod": "4.1.8",
122
118
  "zod-to-json-schema": "3.24.5"
123
119
  }
124
- }
120
+ }
package/script/publish.ts CHANGED
@@ -29,6 +29,94 @@ const pkg = await Bun.file("package.json").json()
29
29
  console.log(`๐Ÿ“ฆ Package: ${pkg.name}`)
30
30
  console.log(`๐Ÿ“Œ Current version: ${pkg.version}\n`)
31
31
 
32
+ // Step 2.5: Remove workspace dependencies and replace catalog: with actual versions
33
+ console.log("๐Ÿงน Cleaning up dependencies for publishing...")
34
+ const originalPkg = JSON.parse(JSON.stringify(pkg)) // Deep copy
35
+
36
+ // Read root package.json to get catalog versions
37
+ const rootPkgPath = path.join(dir, "..", "..", "package.json")
38
+ let catalog = {}
39
+ if (existsSync(rootPkgPath)) {
40
+ try {
41
+ const rootPkg = await Bun.file(rootPkgPath).json()
42
+ if (rootPkg.workspaces?.catalog) {
43
+ catalog = rootPkg.workspaces.catalog
44
+ console.log(" Found catalog with versions")
45
+ }
46
+ } catch (e) {
47
+ console.log(" Warning: Could not read root package.json catalog")
48
+ }
49
+ }
50
+
51
+ // Ensure package.json is restored on exit
52
+ const restorePackageJson = async () => {
53
+ try {
54
+ await Bun.write("package.json", JSON.stringify(originalPkg, null, 2))
55
+ } catch (e) {
56
+ // Ignore errors during cleanup
57
+ }
58
+ }
59
+
60
+ process.on("exit", () => restorePackageJson())
61
+ process.on("SIGINT", async () => {
62
+ await restorePackageJson()
63
+ process.exit(1)
64
+ })
65
+ process.on("SIGTERM", async () => {
66
+ await restorePackageJson()
67
+ process.exit(1)
68
+ })
69
+
70
+ // Remove workspace dependencies from dependencies
71
+ if (pkg.dependencies) {
72
+ Object.keys(pkg.dependencies).forEach((key) => {
73
+ if (pkg.dependencies[key] === "workspace:*") {
74
+ delete pkg.dependencies[key]
75
+ console.log(` Removed: ${key}`)
76
+ }
77
+ })
78
+ }
79
+
80
+ // Remove workspace dependencies from devDependencies
81
+ if (pkg.devDependencies) {
82
+ Object.keys(pkg.devDependencies).forEach((key) => {
83
+ if (pkg.devDependencies[key] === "workspace:*") {
84
+ delete pkg.devDependencies[key]
85
+ console.log(` Removed (dev): ${key}`)
86
+ } else if (pkg.devDependencies[key] === "catalog:") {
87
+ if (catalog[key]) {
88
+ pkg.devDependencies[key] = catalog[key]
89
+ console.log(` Replaced catalog (dev): ${key} -> ${catalog[key]}`)
90
+ } else {
91
+ delete pkg.devDependencies[key]
92
+ console.log(` Removed (dev, no catalog): ${key}`)
93
+ }
94
+ }
95
+ })
96
+ }
97
+
98
+ // Replace catalog: in dependencies
99
+ if (pkg.dependencies) {
100
+ Object.keys(pkg.dependencies).forEach((key) => {
101
+ if (pkg.dependencies[key] === "workspace:*") {
102
+ delete pkg.dependencies[key]
103
+ console.log(` Removed: ${key}`)
104
+ } else if (pkg.dependencies[key] === "catalog:") {
105
+ if (catalog[key]) {
106
+ pkg.dependencies[key] = catalog[key]
107
+ console.log(` Replaced catalog: ${key} -> ${catalog[key]}`)
108
+ } else {
109
+ delete pkg.dependencies[key]
110
+ console.log(` Removed (no catalog): ${key}`)
111
+ }
112
+ }
113
+ })
114
+ }
115
+
116
+ // Write modified package.json
117
+ await Bun.write("package.json", JSON.stringify(pkg, null, 2))
118
+ console.log("โœ… Dependencies cleaned up\n")
119
+
32
120
  // Step 3: Build binaries
33
121
  console.log("๐Ÿ”จ Building binaries for all platforms...")
34
122
  console.log(" This may take a few minutes...\n")
@@ -36,6 +124,7 @@ const buildResult = await $`bun run build`.quiet()
36
124
  if (buildResult.exitCode !== 0) {
37
125
  console.error("โŒ Build failed!")
38
126
  console.error(await buildResult.text())
127
+ await restorePackageJson()
39
128
  process.exit(1)
40
129
  }
41
130
  console.log("โœ… Build completed!\n")
@@ -45,6 +134,7 @@ const distPath = path.join(dir, "dist")
45
134
  if (!existsSync(distPath)) {
46
135
  console.error("โŒ Error: dist folder not found after build!")
47
136
  console.error(` Expected path: ${distPath}`)
137
+ await restorePackageJson()
48
138
  process.exit(1)
49
139
  }
50
140
 
@@ -52,6 +142,7 @@ if (!existsSync(distPath)) {
52
142
  const distContents = await $`ls -1 ${distPath}`.quiet()
53
143
  if (distContents.exitCode !== 0 || !(await distContents.text()).trim()) {
54
144
  console.error("โŒ Error: dist folder is empty!")
145
+ await restorePackageJson()
55
146
  process.exit(1)
56
147
  }
57
148
  console.log("โœ… Dist folder found with binaries\n")
@@ -62,6 +153,7 @@ const dryRunResult = await $`npm publish --dry-run`.quiet()
62
153
  if (dryRunResult.exitCode !== 0) {
63
154
  console.error("โŒ Dry run failed!")
64
155
  console.error(await dryRunResult.text())
156
+ await restorePackageJson()
65
157
  process.exit(1)
66
158
  }
67
159
  console.log(await dryRunResult.text())
@@ -86,12 +178,19 @@ if (process.argv.includes("--yes") || process.argv.includes("-y")) {
86
178
  // Step 7: Publish
87
179
  console.log("๐Ÿ“ค Publishing to npm...\n")
88
180
  const publishResult = await $`npm publish`
89
- if (publishResult.exitCode !== 0) {
181
+ const publishSuccess = publishResult.exitCode === 0
182
+
183
+ // Step 8: Restore original package.json
184
+ console.log("\n๐Ÿ”„ Restoring original package.json...")
185
+ await Bun.write("package.json", JSON.stringify(originalPkg, null, 2))
186
+ console.log("โœ… Original package.json restored\n")
187
+
188
+ if (!publishSuccess) {
90
189
  console.error("โŒ Publish failed!")
91
190
  process.exit(1)
92
191
  }
93
192
 
94
- console.log("\nโœ… Successfully published!")
193
+ console.log("โœ… Successfully published!")
95
194
  console.log(`\n๐Ÿ“ฅ Users can now install with:`)
96
195
  console.log(` npm install -g ${pkg.name}`)
97
196
  console.log(` bun install -g ${pkg.name}`)