@deadbolt/cli 0.0.0-dev-134 → 0.0.0-stage
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/README.md +3 -0
- package/package.json +4 -34
- package/bin/deadbolt +0 -21
- package/postinstall.mjs +0 -121
package/README.md
ADDED
package/package.json
CHANGED
|
@@ -1,36 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deadbolt/cli",
|
|
3
|
-
"version": "0.0.0-
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/anomalyco/deadbolt.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/anomalyco/deadbolt/issues"
|
|
13
|
-
},
|
|
14
|
-
"bin": {
|
|
15
|
-
"deadbolt": "./bin/deadbolt"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"postinstall": "node ./postinstall.mjs"
|
|
19
|
-
},
|
|
20
|
-
"os": [
|
|
21
|
-
"darwin",
|
|
22
|
-
"linux"
|
|
23
|
-
],
|
|
24
|
-
"cpu": [
|
|
25
|
-
"arm64",
|
|
26
|
-
"x64"
|
|
27
|
-
],
|
|
28
|
-
"optionalDependencies": {
|
|
29
|
-
"@deadbolt/cli-linux-x64": "0.0.0-dev-134",
|
|
30
|
-
"@deadbolt/cli-linux-arm64": "0.0.0-dev-134",
|
|
31
|
-
"@deadbolt/cli-linux-x64-musl": "0.0.0-dev-134",
|
|
32
|
-
"@deadbolt/cli-linux-arm64-musl": "0.0.0-dev-134",
|
|
33
|
-
"@deadbolt/cli-darwin-arm64": "0.0.0-dev-134",
|
|
34
|
-
"@deadbolt/cli-darwin-x64": "0.0.0-dev-134"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
3
|
+
"version": "0.0.0-stage",
|
|
4
|
+
"stub": true,
|
|
5
|
+
"description": "Temporary package placeholder for staged publishing"
|
|
6
|
+
}
|
package/bin/deadbolt
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# @deadbolt/cli's postinstall replaces this with a link to this platform's
|
|
3
|
-
# deadbolt (postinstall.mjs). When the package manager skipped install
|
|
4
|
-
# scripts (pnpm, bun, npm with scripts disallowed), the first run links it
|
|
5
|
-
# here, then runs it.
|
|
6
|
-
self=$0
|
|
7
|
-
while [ -L "$self" ]; do
|
|
8
|
-
link=$(readlink "$self")
|
|
9
|
-
case "$link" in
|
|
10
|
-
/*) self=$link ;;
|
|
11
|
-
*) self=$(dirname "$self")/$link ;;
|
|
12
|
-
esac
|
|
13
|
-
done
|
|
14
|
-
package=$(cd "$(dirname "$self")/.." && pwd)
|
|
15
|
-
if command -v node > /dev/null 2>&1 && node "$package/postinstall.mjs" >&2 && [ -L "$package/bin/deadbolt" ]; then
|
|
16
|
-
exec "$package/bin/deadbolt" "$@"
|
|
17
|
-
fi
|
|
18
|
-
echo "Error: @deadbolt/cli's postinstall script was not run, and running it failed." >&2
|
|
19
|
-
echo "" >&2
|
|
20
|
-
echo "Run \`node $package/postinstall.mjs\`, or reinstall with install scripts enabled." >&2
|
|
21
|
-
exit 1
|
package/postinstall.mjs
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// @deadbolt/cli's postinstall: points bin/deadbolt at this platform's
|
|
3
|
-
// `deadbolt` from its @deadbolt/cli-<platform> package, as @opencode/cli's
|
|
4
|
-
// postinstall does. On macOS that's Deadbolt.app's Contents/Helpers/deadbolt
|
|
5
|
-
// (the package carries the signed app), so the command, the agent and the app
|
|
6
|
-
// are one install, and `deadbolt app` opens that Deadbolt.app. Links, never
|
|
7
|
-
// copies: Deadbolt knows its own files by real path (the Touch ID helper
|
|
8
|
-
// beside it, the app around it).
|
|
9
|
-
|
|
10
|
-
import childProcess from "node:child_process"
|
|
11
|
-
import fs from "node:fs"
|
|
12
|
-
import os from "node:os"
|
|
13
|
-
import path from "node:path"
|
|
14
|
-
import { createRequire } from "node:module"
|
|
15
|
-
import { fileURLToPath } from "node:url"
|
|
16
|
-
|
|
17
|
-
const directory = path.dirname(fileURLToPath(import.meta.url))
|
|
18
|
-
const require = createRequire(import.meta.url)
|
|
19
|
-
const packageJson = JSON.parse(fs.readFileSync(path.join(directory, "package.json"), "utf8"))
|
|
20
|
-
const target = path.join(directory, "bin", "deadbolt")
|
|
21
|
-
const dependencies = packageJson.optionalDependencies ?? {}
|
|
22
|
-
const platform = { darwin: "darwin", linux: "linux" }[os.platform()]
|
|
23
|
-
const arch = { x64: "x64", arm64: "arm64" }[os.arch()]
|
|
24
|
-
if (!platform || !arch) throw new Error(`Deadbolt has no build for ${os.platform()}-${os.arch()}`)
|
|
25
|
-
const base = `@deadbolt/cli-${platform}-${arch}`
|
|
26
|
-
const npm = process.env.npm_execpath?.endsWith("npm-cli.js") ? [process.execPath, process.env.npm_execpath] : ["npm"]
|
|
27
|
-
|
|
28
|
-
function isMusl() {
|
|
29
|
-
if (platform !== "linux") return false
|
|
30
|
-
try {
|
|
31
|
-
if (fs.existsSync("/etc/alpine-release")) return true
|
|
32
|
-
if (fs.readdirSync("/lib").some((name) => name.startsWith("ld-musl-"))) return true
|
|
33
|
-
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
34
|
-
return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
|
|
35
|
-
} catch {
|
|
36
|
-
return false
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// The build with the app first; on musl, the static build first. Either runs
|
|
41
|
-
// a glibc system's CLI, so each falls back to the other.
|
|
42
|
-
function packageNames() {
|
|
43
|
-
const names = platform === "linux" ? (isMusl() ? [`${base}-musl`, base] : [base, `${base}-musl`]) : [base]
|
|
44
|
-
return names.filter((name) => dependencies[name])
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// `deadbolt` inside a platform package's directory: Deadbolt.app's helper on
|
|
48
|
-
// macOS (bin/deadbolt in an unsigned build without the app), else bin/deadbolt.
|
|
49
|
-
function binaryIn(packageDir) {
|
|
50
|
-
const helper = path.join(packageDir, "Deadbolt.app", "Contents", "Helpers", "deadbolt")
|
|
51
|
-
return fs.existsSync(helper) ? helper : path.join(packageDir, "bin", "deadbolt")
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function link(source) {
|
|
55
|
-
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
|
|
56
|
-
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
57
|
-
fs.rmSync(target, { force: true })
|
|
58
|
-
fs.symlinkSync(path.relative(path.dirname(target), source), target)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function resolvePackage(name) {
|
|
62
|
-
const packagePath = require.resolve(`${name}/package.json`)
|
|
63
|
-
// Package managers keep an older platform package when the matching version is not yet on the registry,
|
|
64
|
-
// which would silently install the previous release under the new launcher.
|
|
65
|
-
const version = JSON.parse(fs.readFileSync(packagePath, "utf8")).version
|
|
66
|
-
if (version !== dependencies[name]) throw new Error(`${name} is ${version}, expected ${dependencies[name]}`)
|
|
67
|
-
return path.dirname(packagePath)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// When the package manager skipped the optional dependency: install it beside
|
|
71
|
-
// this package, where it stays (the link points into it).
|
|
72
|
-
function installPackage(name) {
|
|
73
|
-
const prefix = path.join(directory, "platform")
|
|
74
|
-
fs.rmSync(prefix, { recursive: true, force: true })
|
|
75
|
-
const result = childProcess.spawnSync(
|
|
76
|
-
npm[0],
|
|
77
|
-
[
|
|
78
|
-
...npm.slice(1),
|
|
79
|
-
"install",
|
|
80
|
-
"--ignore-scripts",
|
|
81
|
-
"--no-save",
|
|
82
|
-
"--no-package-lock",
|
|
83
|
-
"--loglevel=error",
|
|
84
|
-
// npm refuses a package built for another libc or CPU unless forced.
|
|
85
|
-
...(name === packageNames()[0] ? [] : ["--force"]),
|
|
86
|
-
"--prefix",
|
|
87
|
-
prefix,
|
|
88
|
-
`${name}@${dependencies[name]}`,
|
|
89
|
-
],
|
|
90
|
-
{ stdio: "inherit" },
|
|
91
|
-
)
|
|
92
|
-
if (result.status !== 0) return false
|
|
93
|
-
link(binaryIn(path.join(prefix, "node_modules", name)))
|
|
94
|
-
return true
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function verify() {
|
|
98
|
-
return childProcess.spawnSync(target, ["--version"], { stdio: "ignore" }).status === 0
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function main() {
|
|
102
|
-
const names = packageNames()
|
|
103
|
-
for (const name of names) {
|
|
104
|
-
try {
|
|
105
|
-
link(binaryIn(resolvePackage(name)))
|
|
106
|
-
if (verify()) return
|
|
107
|
-
} catch {
|
|
108
|
-
if (installPackage(name) && verify()) return
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
throw new Error(
|
|
112
|
-
`Failed to install Deadbolt. Try manually installing ${names.map((name) => JSON.stringify(name)).join(" or ")}.`,
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
main()
|
|
118
|
-
} catch (error) {
|
|
119
|
-
console.error(error instanceof Error ? error.message : String(error))
|
|
120
|
-
process.exit(1)
|
|
121
|
-
}
|