opendocker 0.3.2 → 0.3.4
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/opendocker +0 -0
- package/package.json +17 -24
- package/postinstall.mjs +94 -0
package/bin/opendocker
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.3.2",
|
|
4
2
|
"name": "opendocker",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.3.4",
|
|
4
|
+
"description": "A CLI tool for managing Docker",
|
|
7
5
|
"bin": {
|
|
8
|
-
"opendocker": "bin/opendocker"
|
|
6
|
+
"opendocker": "./bin/opendocker"
|
|
9
7
|
},
|
|
10
|
-
"files": [
|
|
11
|
-
"bin/",
|
|
12
|
-
"package.json",
|
|
13
|
-
"README.md"
|
|
14
|
-
],
|
|
15
8
|
"scripts": {
|
|
16
|
-
"
|
|
17
|
-
"build": "bun run scripts/build.ts"
|
|
9
|
+
"postinstall": "node ./postinstall.mjs"
|
|
18
10
|
},
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
11
|
+
"optionalDependencies": {
|
|
12
|
+
"opendocker-linux-arm64-musl": "0.3.4",
|
|
13
|
+
"opendocker-darwin-x64-baseline": "0.3.4",
|
|
14
|
+
"opendocker-linux-x64": "0.3.4",
|
|
15
|
+
"opendocker-linux-arm64": "0.3.4",
|
|
16
|
+
"opendocker-linux-x64-baseline": "0.3.4",
|
|
17
|
+
"opendocker-darwin-x64": "0.3.4",
|
|
18
|
+
"opendocker-windows-x64-baseline": "0.3.4",
|
|
19
|
+
"opendocker-windows-x64": "0.3.4",
|
|
20
|
+
"opendocker-linux-x64-musl": "0.3.4",
|
|
21
|
+
"opendocker-linux-x64-baseline-musl": "0.3.4",
|
|
22
|
+
"opendocker-darwin-arm64": "0.3.4"
|
|
30
23
|
}
|
|
31
|
-
}
|
|
24
|
+
}
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "fs"
|
|
4
|
+
import path from "path"
|
|
5
|
+
import os from "os"
|
|
6
|
+
import { fileURLToPath } from "url"
|
|
7
|
+
import { createRequire } from "module"
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
const require = createRequire(import.meta.url)
|
|
11
|
+
|
|
12
|
+
function detectPlatformAndArch() {
|
|
13
|
+
// Map platform names
|
|
14
|
+
let platform
|
|
15
|
+
switch (os.platform()) {
|
|
16
|
+
case "darwin":
|
|
17
|
+
platform = "darwin"
|
|
18
|
+
break
|
|
19
|
+
case "linux":
|
|
20
|
+
platform = "linux"
|
|
21
|
+
break
|
|
22
|
+
case "win32":
|
|
23
|
+
platform = "windows"
|
|
24
|
+
break
|
|
25
|
+
default:
|
|
26
|
+
platform = os.platform()
|
|
27
|
+
break
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Map architecture names
|
|
31
|
+
let arch
|
|
32
|
+
switch (os.arch()) {
|
|
33
|
+
case "x64":
|
|
34
|
+
arch = "x64"
|
|
35
|
+
break
|
|
36
|
+
case "arm64":
|
|
37
|
+
arch = "arm64"
|
|
38
|
+
break
|
|
39
|
+
case "arm":
|
|
40
|
+
arch = "arm"
|
|
41
|
+
break
|
|
42
|
+
default:
|
|
43
|
+
arch = os.arch()
|
|
44
|
+
break
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return { platform, arch }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function findBinary() {
|
|
51
|
+
const { platform, arch } = detectPlatformAndArch()
|
|
52
|
+
const packageName = `opendocker-${platform}-${arch}`
|
|
53
|
+
const binaryName = platform === "windows" ? "opendocker.exe" : "opendocker"
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
// Use require.resolve to find the package
|
|
57
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`)
|
|
58
|
+
const packageDir = path.dirname(packageJsonPath)
|
|
59
|
+
const binaryPath = path.join(packageDir, "bin", binaryName)
|
|
60
|
+
|
|
61
|
+
if (!fs.existsSync(binaryPath)) {
|
|
62
|
+
throw new Error(`Binary not found at ${binaryPath}`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return { binaryPath, binaryName, packageName }
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw new Error(`Could not find package ${packageName}: ${error.message}`)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function main() {
|
|
72
|
+
try {
|
|
73
|
+
if (os.platform() === "win32") {
|
|
74
|
+
// On Windows, the .exe is already included in the package and bin field points to it
|
|
75
|
+
// No postinstall setup needed
|
|
76
|
+
console.log("Windows detected: binary setup not needed (using packaged .exe)")
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// On non-Windows platforms, verify the binary package exists
|
|
81
|
+
const { binaryPath, packageName } = findBinary()
|
|
82
|
+
console.log(`opendocker: Platform binary verified (${packageName})`)
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error("Failed to setup opendocker binary:", error.message)
|
|
85
|
+
process.exit(1)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
main()
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error("Postinstall script error:", error.message)
|
|
93
|
+
process.exit(0)
|
|
94
|
+
}
|