diff --git a/package.json b/package.json index 2352c6d75..a08ec1c48 100644 --- a/package.json +++ b/package.json @@ -68,13 +68,13 @@ "dev": "node scripts/run-node.mjs", "postinstall": "node scripts/postinstall.js", "prepack": "pnpm build", - "docs:list": "bun scripts/docs-list.ts", - "docs:bin": "bun build scripts/docs-list.ts --compile --outfile bin/docs-list", + "docs:list": "node scripts/docs-list.js", + "docs:bin": "node scripts/build-docs-list.mjs", "docs:dev": "cd docs && mint dev", "docs:build": "cd docs && pnpm dlx --reporter append-only mint broken-links", - "build": "tsc -p tsconfig.json && bun scripts/canvas-a2ui-copy.ts && bun scripts/copy-hook-metadata.ts && bun scripts/write-build-info.ts", - "plugins:sync": "bun scripts/sync-plugin-versions.ts", - "release:check": "bun scripts/release-check.ts", + "build": "tsc -p tsconfig.json && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/write-build-info.ts", + "plugins:sync": "node --import tsx scripts/sync-plugin-versions.ts", + "release:check": "node --import tsx scripts/release-check.ts", "ui:install": "node scripts/ui.js install", "ui:dev": "node scripts/ui.js dev", "ui:build": "node scripts/ui.js build", @@ -108,7 +108,7 @@ "test": "vitest run", "test:watch": "vitest", "test:ui": "pnpm --dir ui test", - "test:force": "bun scripts/test-force.ts", + "test:force": "node --import tsx scripts/test-force.ts", "test:coverage": "vitest run --coverage", "test:e2e": "vitest run --config vitest.e2e.config.ts", "test:live": "CLAWDBOT_LIVE_TEST=1 vitest run --config vitest.live.config.ts", @@ -126,11 +126,11 @@ "test:install:smoke": "bash scripts/test-install-sh-docker.sh", "test:install:e2e:openai": "CLAWDBOT_E2E_MODELS=openai bash scripts/test-install-sh-e2e-docker.sh", "test:install:e2e:anthropic": "CLAWDBOT_E2E_MODELS=anthropic bash scripts/test-install-sh-e2e-docker.sh", - "protocol:gen": "bun scripts/protocol-gen.ts", - "protocol:gen:swift": "bun scripts/protocol-gen-swift.ts", + "protocol:gen": "node --import tsx scripts/protocol-gen.ts", + "protocol:gen:swift": "node --import tsx scripts/protocol-gen-swift.ts", "protocol:check": "pnpm protocol:gen && pnpm protocol:gen:swift && git diff --exit-code -- dist/protocol.schema.json apps/macos/Sources/ClawdbotProtocol/GatewayModels.swift", "canvas:a2ui:bundle": "bash scripts/bundle-a2ui.sh", - "check:loc": "tsx scripts/check-ts-max-loc.ts --max 500" + "check:loc": "node --import tsx scripts/check-ts-max-loc.ts --max 500" }, "keywords": [], "author": "", diff --git a/scripts/build-docs-list.mjs b/scripts/build-docs-list.mjs new file mode 100644 index 000000000..6d5dbf458 --- /dev/null +++ b/scripts/build-docs-list.mjs @@ -0,0 +1,15 @@ +#!/usr/bin/env node +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); +const binDir = path.join(root, "bin"); +const scriptPath = path.join(root, "scripts", "docs-list.js"); +const binPath = path.join(binDir, "docs-list"); + +fs.mkdirSync(binDir, { recursive: true }); + +const wrapper = `#!/usr/bin/env node\nimport { spawnSync } from "node:child_process";\nimport path from "node:path";\nimport { fileURLToPath } from "node:url";\n\nconst here = path.dirname(fileURLToPath(import.meta.url));\nconst script = path.join(here, "..", "scripts", "docs-list.js");\n\nconst result = spawnSync(process.execPath, [script], { stdio: "inherit" });\nprocess.exit(result.status ?? 1);\n`; + +fs.writeFileSync(binPath, wrapper, { mode: 0o755 }); diff --git a/scripts/docs-list.ts b/scripts/docs-list.js similarity index 98% rename from scripts/docs-list.ts rename to scripts/docs-list.js index 7fad2594a..194ea43ec 100755 --- a/scripts/docs-list.ts +++ b/scripts/docs-list.js @@ -1,10 +1,10 @@ -#!/usr/bin/env bun +#!/usr/bin/env node import { readdirSync, readFileSync } from 'node:fs'; import { join, relative } from 'node:path'; process.stdout.on('error', (error) => { - if ((error as NodeJS.ErrnoException).code === 'EPIPE') { + if (error?.code === 'EPIPE') { process.exit(0); } throw error; diff --git a/scripts/release-check.ts b/scripts/release-check.ts index d3377ce8d..a971e82cb 100755 --- a/scripts/release-check.ts +++ b/scripts/release-check.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env bun +#!/usr/bin/env -S node --import tsx import { execSync } from "node:child_process"; import { readdirSync, readFileSync } from "node:fs"; diff --git a/scripts/test-force.ts b/scripts/test-force.ts index 4e6e3bf9e..055ecd9bc 100755 --- a/scripts/test-force.ts +++ b/scripts/test-force.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env bun +#!/usr/bin/env -S node --import tsx import os from "node:os"; import path from "node:path"; import { spawnSync } from "node:child_process"; diff --git a/scripts/ui.js b/scripts/ui.js index fc7bc2ce8..32bbb2009 100644 --- a/scripts/ui.js +++ b/scripts/ui.js @@ -45,19 +45,8 @@ function which(cmd) { } function resolveRunner() { - // CLAWDBOT_PREFER_PNPM=1 forces pnpm (useful in Docker on architectures where Bun fails) - const preferPnpm = process.env.CLAWDBOT_PREFER_PNPM === "1"; - if (!preferPnpm) { - const bun = which("bun"); - if (bun) return { cmd: bun, kind: "bun" }; - } const pnpm = which("pnpm"); if (pnpm) return { cmd: pnpm, kind: "pnpm" }; - if (preferPnpm) { - // Fallback to bun if pnpm not found even when preferring pnpm - const bun = which("bun"); - if (bun) return { cmd: bun, kind: "bun" }; - } return null; } @@ -107,9 +96,7 @@ if (!action) { const runner = resolveRunner(); if (!runner) { - process.stderr.write( - "Missing UI runner: install bun or pnpm, then retry.\n", - ); + process.stderr.write("Missing UI runner: install pnpm, then retry.\n"); process.exit(1); } @@ -129,32 +116,16 @@ if (action !== "install" && !script) { process.exit(2); } -if (runner.kind === "bun") { - if (action === "install") run(runner.cmd, ["install", ...rest]); - else { - if (!depsInstalled(action === "test" ? "test" : "build")) { - const installEnv = - action === "build" - ? { ...process.env, NODE_ENV: "production" } - : process.env; - const installArgs = - action === "build" ? ["install", "--production"] : ["install"]; - runSync(runner.cmd, installArgs, installEnv); - } - run(runner.cmd, ["run", script, ...rest]); - } -} else { - if (action === "install") run(runner.cmd, ["install", ...rest]); - else { - if (!depsInstalled(action === "test" ? "test" : "build")) { - const installEnv = - action === "build" - ? { ...process.env, NODE_ENV: "production" } - : process.env; - const installArgs = - action === "build" ? ["install", "--prod"] : ["install"]; - runSync(runner.cmd, installArgs, installEnv); - } - run(runner.cmd, ["run", script, ...rest]); +if (action === "install") run(runner.cmd, ["install", ...rest]); +else { + if (!depsInstalled(action === "test" ? "test" : "build")) { + const installEnv = + action === "build" + ? { ...process.env, NODE_ENV: "production" } + : process.env; + const installArgs = + action === "build" ? ["install", "--prod"] : ["install"]; + runSync(runner.cmd, installArgs, installEnv); } + run(runner.cmd, ["run", script, ...rest]); }