mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-17 00:04:54 +00:00
fix: fix bun install bug
This commit is contained in:
parent
553f249836
commit
048dcc5693
17 changed files with 354 additions and 22 deletions
|
|
@ -1,7 +1,40 @@
|
|||
#!/usr/bin/env node
|
||||
const { execFileSync } = require("child_process");
|
||||
const {
|
||||
formatNonExecutableBinaryMessage,
|
||||
isPermissionError,
|
||||
} = require("@sandbox-agent/cli-shared");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const TRUST_PACKAGES =
|
||||
"@sandbox-agent/cli-linux-x64 @sandbox-agent/cli-darwin-arm64 @sandbox-agent/cli-darwin-x64 @sandbox-agent/cli-win32-x64";
|
||||
|
||||
function printExecutableHint(binPath) {
|
||||
console.error(
|
||||
formatNonExecutableBinaryMessage({
|
||||
binPath,
|
||||
trustPackages: TRUST_PACKAGES,
|
||||
bunInstallBlocks: [
|
||||
{
|
||||
label: "Project install",
|
||||
commands: [
|
||||
`bun pm trust ${TRUST_PACKAGES}`,
|
||||
"bun add @sandbox-agent/cli",
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Global install",
|
||||
commands: [
|
||||
`bun pm -g trust ${TRUST_PACKAGES}`,
|
||||
"bun add -g @sandbox-agent/cli",
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const PLATFORMS = {
|
||||
"darwin-arm64": "@sandbox-agent/cli-darwin-arm64",
|
||||
"darwin-x64": "@sandbox-agent/cli-darwin-x64",
|
||||
|
|
@ -19,7 +52,30 @@ if (!pkg) {
|
|||
try {
|
||||
const pkgPath = require.resolve(`${pkg}/package.json`);
|
||||
const bin = process.platform === "win32" ? "sandbox-agent.exe" : "sandbox-agent";
|
||||
execFileSync(path.join(path.dirname(pkgPath), "bin", bin), process.argv.slice(2), { stdio: "inherit" });
|
||||
const binPath = path.join(path.dirname(pkgPath), "bin", bin);
|
||||
if (process.platform !== "win32") {
|
||||
try {
|
||||
fs.accessSync(binPath, fs.constants.X_OK);
|
||||
} catch (error) {
|
||||
try {
|
||||
fs.chmodSync(binPath, 0o755);
|
||||
} catch (chmodError) {
|
||||
if (isPermissionError(chmodError)) {
|
||||
printExecutableHint(binPath);
|
||||
}
|
||||
console.error(`Failed to make ${binPath} executable.`);
|
||||
throw chmodError;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
||||
} catch (execError) {
|
||||
if (isPermissionError(execError)) {
|
||||
printExecutableHint(binPath);
|
||||
}
|
||||
throw execError;
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.status !== undefined) process.exit(e.status);
|
||||
throw e;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue