easc-cli 1.1.40 → 1.1.42
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/easc.js +91 -0
- package/package.json +13 -13
- package/postinstall.mjs +4 -4
- package/bin/opencode.cjs +0 -106
package/bin/easc.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const childProcess = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
|
|
8
|
+
function run(target) {
|
|
9
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
env: process.env,
|
|
12
|
+
});
|
|
13
|
+
if (result.error) {
|
|
14
|
+
throw result.error;
|
|
15
|
+
}
|
|
16
|
+
process.exit(result.status ?? 0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const scriptPath = fs.realpathSync(__filename);
|
|
20
|
+
const scriptDir = path.dirname(scriptPath);
|
|
21
|
+
|
|
22
|
+
function detectPlatformAndArch() {
|
|
23
|
+
let platform;
|
|
24
|
+
switch (os.platform()) {
|
|
25
|
+
case "darwin": platform = "darwin"; break;
|
|
26
|
+
case "linux": platform = "linux"; break;
|
|
27
|
+
case "win32": platform = "windows"; break;
|
|
28
|
+
default: platform = os.platform(); break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let arch;
|
|
32
|
+
switch (os.arch()) {
|
|
33
|
+
case "x64": arch = "x64"; break;
|
|
34
|
+
case "arm64": arch = "arm64"; break;
|
|
35
|
+
case "arm": arch = "arm"; break;
|
|
36
|
+
default: arch = os.arch(); break;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return { platform, arch };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function findBinary(startDir) {
|
|
43
|
+
const { platform, arch } = detectPlatformAndArch();
|
|
44
|
+
const binary = platform === "windows" ? "easc.exe" : "easc";
|
|
45
|
+
|
|
46
|
+
// 1. Try to find the platform-specific package
|
|
47
|
+
const base = `easc-${platform}-${arch}`;
|
|
48
|
+
const variants = [
|
|
49
|
+
base,
|
|
50
|
+
`${base}-baseline`,
|
|
51
|
+
`${base}-musl`,
|
|
52
|
+
`${base}-baseline-musl`
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
for (const variant of variants) {
|
|
56
|
+
try {
|
|
57
|
+
// Look for package in node_modules relative to script
|
|
58
|
+
const pkgPath = require.resolve(`${variant}/package.json`, { paths: [startDir] });
|
|
59
|
+
const pkgDir = path.dirname(pkgPath);
|
|
60
|
+
const binPath = path.join(pkgDir, "bin", binary);
|
|
61
|
+
if (fs.existsSync(binPath)) {
|
|
62
|
+
return binPath;
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
// ignore
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 2. Check local dist (for dev/testing)
|
|
70
|
+
const distPath = path.join(startDir, "..", "..", "dist", base, "bin", binary);
|
|
71
|
+
if (fs.existsSync(distPath)) {
|
|
72
|
+
return distPath;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const bin = findBinary(scriptDir);
|
|
80
|
+
if (bin) {
|
|
81
|
+
run(bin);
|
|
82
|
+
} else {
|
|
83
|
+
console.error("easc binary not found. Please ensure platform-specific packages are installed.");
|
|
84
|
+
const { platform, arch } = detectPlatformAndArch();
|
|
85
|
+
console.error(`Platform: ${platform}, Arch: ${arch}`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error("Error running easc:", e);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easc-cli",
|
|
3
3
|
"bin": {
|
|
4
|
-
"easc": "./bin/
|
|
4
|
+
"easc": "./bin/easc.js"
|
|
5
5
|
},
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.42",
|
|
10
10
|
"optionalDependencies": {
|
|
11
|
-
"easc-linux-arm64": "1.1.
|
|
12
|
-
"easc-linux-x64": "1.1.
|
|
13
|
-
"easc-linux-x64-baseline": "1.1.
|
|
14
|
-
"easc-linux-arm64-musl": "1.1.
|
|
15
|
-
"easc-linux-x64-musl": "1.1.
|
|
16
|
-
"easc-linux-x64-baseline-musl": "1.1.
|
|
17
|
-
"easc-darwin-arm64": "1.1.
|
|
18
|
-
"easc-darwin-x64": "1.1.
|
|
19
|
-
"easc-darwin-x64-baseline": "1.1.
|
|
20
|
-
"easc-windows-x64": "1.1.
|
|
21
|
-
"easc-windows-x64-baseline": "1.1.
|
|
11
|
+
"easc-linux-arm64": "1.1.42",
|
|
12
|
+
"easc-linux-x64": "1.1.42",
|
|
13
|
+
"easc-linux-x64-baseline": "1.1.42",
|
|
14
|
+
"easc-linux-arm64-musl": "1.1.42",
|
|
15
|
+
"easc-linux-x64-musl": "1.1.42",
|
|
16
|
+
"easc-linux-x64-baseline-musl": "1.1.42",
|
|
17
|
+
"easc-darwin-arm64": "1.1.42",
|
|
18
|
+
"easc-darwin-x64": "1.1.42",
|
|
19
|
+
"easc-darwin-x64-baseline": "1.1.42",
|
|
20
|
+
"easc-windows-x64": "1.1.42",
|
|
21
|
+
"easc-windows-x64-baseline": "1.1.42"
|
|
22
22
|
}
|
|
23
23
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -49,8 +49,8 @@ function detectPlatformAndArch() {
|
|
|
49
49
|
|
|
50
50
|
function findBinary() {
|
|
51
51
|
const { platform, arch } = detectPlatformAndArch()
|
|
52
|
-
const packageName = `
|
|
53
|
-
const binaryName = platform === "windows" ? "
|
|
52
|
+
const packageName = `easc-${platform}-${arch}`
|
|
53
|
+
const binaryName = platform === "windows" ? "easc.exe" : "easc"
|
|
54
54
|
|
|
55
55
|
try {
|
|
56
56
|
// Use require.resolve to find the package
|
|
@@ -89,7 +89,7 @@ function symlinkBinary(sourcePath, binaryName) {
|
|
|
89
89
|
const { targetPath } = prepareBinDirectory(binaryName)
|
|
90
90
|
|
|
91
91
|
fs.symlinkSync(sourcePath, targetPath)
|
|
92
|
-
console.log(`
|
|
92
|
+
console.log(`easc binary symlinked: ${targetPath} -> ${sourcePath}`)
|
|
93
93
|
|
|
94
94
|
// Verify the file exists after operation
|
|
95
95
|
if (!fs.existsSync(targetPath)) {
|
|
@@ -112,7 +112,7 @@ async function main() {
|
|
|
112
112
|
console.log(`Platform binary verified at: ${binaryPath}`)
|
|
113
113
|
console.log("Wrapper script will handle binary execution")
|
|
114
114
|
} catch (error) {
|
|
115
|
-
console.error("Failed to setup
|
|
115
|
+
console.error("Failed to setup easc binary:", error.message)
|
|
116
116
|
process.exit(1)
|
|
117
117
|
}
|
|
118
118
|
}
|
package/bin/opencode.cjs
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const childProcess = require("child_process")
|
|
4
|
-
const fs = require("fs")
|
|
5
|
-
const path = require("path")
|
|
6
|
-
const os = require("os")
|
|
7
|
-
|
|
8
|
-
function run(target) {
|
|
9
|
-
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
-
stdio: "inherit",
|
|
11
|
-
})
|
|
12
|
-
if (result.error) {
|
|
13
|
-
console.error(result.error.message)
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
-
process.exit(code)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const envPath = process.env.OPENCODE_BIN_PATH
|
|
21
|
-
if (envPath) {
|
|
22
|
-
run(envPath)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const scriptPath = fs.realpathSync(__filename)
|
|
26
|
-
const scriptDir = path.dirname(scriptPath)
|
|
27
|
-
|
|
28
|
-
const platformMap = {
|
|
29
|
-
darwin: "darwin",
|
|
30
|
-
linux: "linux",
|
|
31
|
-
win32: "windows",
|
|
32
|
-
}
|
|
33
|
-
const archMap = {
|
|
34
|
-
x64: "x64",
|
|
35
|
-
arm64: "arm64",
|
|
36
|
-
arm: "arm",
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let platform = platformMap[os.platform()]
|
|
40
|
-
if (!platform) {
|
|
41
|
-
platform = os.platform()
|
|
42
|
-
}
|
|
43
|
-
let arch = archMap[os.arch()]
|
|
44
|
-
if (!arch) {
|
|
45
|
-
arch = os.arch()
|
|
46
|
-
}
|
|
47
|
-
const base = "easc-" + platform + "-" + arch
|
|
48
|
-
const binary = platform === "windows" ? "easc.exe" : "easc"
|
|
49
|
-
|
|
50
|
-
function findBinary(startDir) {
|
|
51
|
-
let current = startDir
|
|
52
|
-
for (; ;) {
|
|
53
|
-
const modules = path.join(current, "node_modules")
|
|
54
|
-
if (fs.existsSync(modules)) {
|
|
55
|
-
const entries = fs.readdirSync(modules)
|
|
56
|
-
for (const entry of entries) {
|
|
57
|
-
if (!entry.startsWith(base)) {
|
|
58
|
-
continue
|
|
59
|
-
}
|
|
60
|
-
const candidate = path.join(modules, entry, "bin", binary)
|
|
61
|
-
if (fs.existsSync(candidate)) {
|
|
62
|
-
return candidate
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const parent = path.dirname(current)
|
|
67
|
-
if (parent === current) {
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
current = parent
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Fallback for local dev/dist build (not installed via npm)
|
|
75
|
-
function findLocalDist(startDir) {
|
|
76
|
-
let current = startDir
|
|
77
|
-
for (; ;) {
|
|
78
|
-
const dist = path.join(current, "dist", base, "bin", binary)
|
|
79
|
-
if (fs.existsSync(dist)) {
|
|
80
|
-
return dist
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const parent = path.dirname(current)
|
|
84
|
-
if (parent === current) {
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
current = parent
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
let resolved = findBinary(scriptDir)
|
|
92
|
-
if (!resolved) {
|
|
93
|
-
// If not found in node_modules, valid for local dev builds where we have a dist folder
|
|
94
|
-
resolved = findLocalDist(scriptDir)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (!resolved) {
|
|
98
|
-
console.error(
|
|
99
|
-
'It seems that your package manager failed to install the right version of the easc CLI for your platform. You can try manually installing the "' +
|
|
100
|
-
base +
|
|
101
|
-
'" package',
|
|
102
|
-
)
|
|
103
|
-
process.exit(1)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
run(resolved)
|