bincode-dev 0.0.21 → 0.0.22
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/package.json +5 -5
- package/scripts/prepare-platform-packages.js +148 -117
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bincode-dev",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
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.
|
|
10
|
-
"bincode-dev-darwin-x64": "0.0.
|
|
11
|
-
"bincode-dev-linux-x64": "0.0.
|
|
12
|
-
"bincode-dev-windows-x64": "0.0.
|
|
9
|
+
"bincode-dev-darwin-arm64": "0.0.22",
|
|
10
|
+
"bincode-dev-darwin-x64": "0.0.22",
|
|
11
|
+
"bincode-dev-linux-x64": "0.0.22",
|
|
12
|
+
"bincode-dev-windows-x64": "0.0.22"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "bun script/build.ts",
|
|
@@ -1,117 +1,148 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates per-platform npm packages that contain
|
|
3
|
-
*
|
|
4
|
-
* Why:
|
|
5
|
-
* - Keeps the main `bincode-dev` package small.
|
|
6
|
-
* - Lets users run `npm i bincode-dev` on mac/linux/windows and get the right binary via optionalDependencies.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Generates per-platform npm packages that contain the native bincode binary and app dist.
|
|
3
|
+
*
|
|
4
|
+
* Why:
|
|
5
|
+
* - Keeps the main `bincode-dev` package small.
|
|
6
|
+
* - Lets users run `npm i bincode-dev` on mac/linux/windows and get the right binary via optionalDependencies.
|
|
7
|
+
* - Includes app/dist so the web console works when installed via platform packages.
|
|
8
|
+
*
|
|
9
|
+
* Expected input:
|
|
10
|
+
* - `publish-bincode-dev/dist/opencode-<platform>-<arch>/bin/(bincode|bincode.exe)` exists (copied from packages/opencode/dist).
|
|
11
|
+
* - `publish-bincode-dev/app/dist` exists (copied from packages/app/dist).
|
|
12
|
+
*
|
|
13
|
+
* Output:
|
|
14
|
+
* - `publish-bincode-dev/platform-packages/<pkgName>/{package.json,README.md,bin/*,app/dist/*}`
|
|
15
|
+
*/
|
|
16
|
+
const fs = require("fs")
|
|
17
|
+
const path = require("path")
|
|
18
|
+
|
|
19
|
+
const root = path.join(__dirname, "..")
|
|
20
|
+
const mainPkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"))
|
|
21
|
+
const version = mainPkg.version
|
|
22
|
+
|
|
23
|
+
if (!version) {
|
|
24
|
+
console.error("[prepare-platform-packages] Missing version in publish-bincode-dev/package.json")
|
|
25
|
+
process.exit(1)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function rmrf(p) {
|
|
29
|
+
fs.rmSync(p, { recursive: true, force: true })
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function mkdirp(p) {
|
|
33
|
+
fs.mkdirSync(p, { recursive: true })
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function writeJson(p, obj) {
|
|
37
|
+
fs.writeFileSync(p, JSON.stringify(obj, null, 2) + "\n")
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function copyRecursive(src, dest) {
|
|
41
|
+
mkdirp(path.dirname(dest))
|
|
42
|
+
const stat = fs.statSync(src)
|
|
43
|
+
if (stat.isDirectory()) {
|
|
44
|
+
mkdirp(dest)
|
|
45
|
+
const entries = fs.readdirSync(src)
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
copyRecursive(path.join(src, entry), path.join(dest, entry))
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
fs.copyFileSync(src, dest)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @type {Array<{pkg:string, opencodeDistDir:string, os:string, cpu:string, binName:string}>} */
|
|
55
|
+
const targets = [
|
|
56
|
+
{
|
|
57
|
+
pkg: "bincode-dev-darwin-arm64",
|
|
58
|
+
opencodeDistDir: "opencode-darwin-arm64",
|
|
59
|
+
os: "darwin",
|
|
60
|
+
cpu: "arm64",
|
|
61
|
+
binName: "bincode",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
pkg: "bincode-dev-darwin-x64",
|
|
65
|
+
opencodeDistDir: "opencode-darwin-x64",
|
|
66
|
+
os: "darwin",
|
|
67
|
+
cpu: "x64",
|
|
68
|
+
binName: "bincode",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
pkg: "bincode-dev-linux-x64",
|
|
72
|
+
opencodeDistDir: "opencode-linux-x64",
|
|
73
|
+
os: "linux",
|
|
74
|
+
cpu: "x64",
|
|
75
|
+
binName: "bincode",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
pkg: "bincode-dev-windows-x64",
|
|
79
|
+
opencodeDistDir: "opencode-windows-x64",
|
|
80
|
+
os: "win32",
|
|
81
|
+
cpu: "x64",
|
|
82
|
+
binName: "bincode.exe",
|
|
83
|
+
},
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
const distRoot = path.join(root, "dist")
|
|
87
|
+
const pkgsRoot = path.join(root, "platform-packages")
|
|
88
|
+
const appDistSource = path.join(root, "app", "dist")
|
|
89
|
+
|
|
90
|
+
mkdirp(pkgsRoot)
|
|
91
|
+
|
|
92
|
+
// Check if app/dist exists
|
|
93
|
+
if (!fs.existsSync(appDistSource)) {
|
|
94
|
+
console.error(`[prepare-platform-packages] Warning: app/dist not found at ${appDistSource}`)
|
|
95
|
+
console.error(`[prepare-platform-packages] Web console may not work in installed packages`)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
for (const t of targets) {
|
|
99
|
+
const sourceBin = path.join(distRoot, t.opencodeDistDir, "bin", t.binName)
|
|
100
|
+
if (!fs.existsSync(sourceBin)) {
|
|
101
|
+
console.error(`[prepare-platform-packages] Missing binary: ${sourceBin}`)
|
|
102
|
+
process.exit(1)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const outDir = path.join(pkgsRoot, t.pkg)
|
|
106
|
+
const outBinDir = path.join(outDir, "bin")
|
|
107
|
+
rmrf(outBinDir)
|
|
108
|
+
mkdirp(outBinDir)
|
|
109
|
+
|
|
110
|
+
const outBin = path.join(outBinDir, t.binName)
|
|
111
|
+
fs.copyFileSync(sourceBin, outBin)
|
|
112
|
+
|
|
113
|
+
// Ensure executable bit for mac/linux when packing from Windows/WSL.
|
|
114
|
+
if (t.os !== "win32") {
|
|
115
|
+
try {
|
|
116
|
+
fs.chmodSync(outBin, 0o755)
|
|
117
|
+
} catch {
|
|
118
|
+
// ignore
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Copy app/dist directory if it exists
|
|
123
|
+
const outAppDist = path.join(outDir, "app", "dist")
|
|
124
|
+
if (fs.existsSync(appDistSource)) {
|
|
125
|
+
rmrf(outAppDist)
|
|
126
|
+
copyRecursive(appDistSource, outAppDist)
|
|
127
|
+
console.log(`[prepare-platform-packages] Copied app/dist to ${t.pkg}`)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
writeJson(path.join(outDir, "package.json"), {
|
|
131
|
+
name: t.pkg,
|
|
132
|
+
version,
|
|
133
|
+
description: "Platform-specific bincode binary (internal dependency of bincode-dev).",
|
|
134
|
+
license: mainPkg.license || "MIT",
|
|
135
|
+
os: [t.os],
|
|
136
|
+
cpu: [t.cpu],
|
|
137
|
+
files: ["bin", "app/dist"],
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
fs.writeFileSync(
|
|
141
|
+
path.join(outDir, "README.md"),
|
|
142
|
+
`# ${t.pkg}\n\nPlatform-specific binary package for \`bincode-dev\`.\n\nDo not install directly unless you know what you're doing.\n`,
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
console.log(`[prepare-platform-packages] Prepared ${t.pkg}@${version}`)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|