fix(demo): default WRANGLER_CMD to npx + silence expected R2 not-found probes
The publish scripts shelled bare `wrangler` (ENOENT without a global install) and the existence probes (registry.json / per-tool meta.json) printed wrangler's 'key does not exist' on a fresh bucket. Default to `npx wrangler@4` and capture stderr on probes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e8cef07f7f
commit
5248f3a464
1 changed files with 11 additions and 5 deletions
|
|
@ -79,11 +79,14 @@ export function localDriver(outDir) {
|
|||
}
|
||||
|
||||
export function r2Driver({ bucket, remote }) {
|
||||
const wrangler = process.env.WRANGLER_CMD?.split(" ") || ["wrangler"];
|
||||
// Default to `npx wrangler` so no global install is needed (override via env).
|
||||
const wrangler = process.env.WRANGLER_CMD?.split(" ") || ["npx", "--yes", "wrangler@4"];
|
||||
const flags = remote ? ["--remote"] : [];
|
||||
const run = (args) =>
|
||||
// quiet: capture stderr instead of inheriting it — used for existence PROBES,
|
||||
// where wrangler's "key does not exist" on a fresh bucket is expected + caught.
|
||||
const run = (args, { quiet = false } = {}) =>
|
||||
execFileSync(wrangler[0], [...wrangler.slice(1), ...args], {
|
||||
stdio: ["pipe", "pipe", "inherit"],
|
||||
stdio: ["pipe", "pipe", quiet ? "pipe" : "inherit"],
|
||||
maxBuffer: 1024 * 1024 * 512,
|
||||
});
|
||||
const tmp = join(tmpdir(), `r2put-${process.pid}`);
|
||||
|
|
@ -92,9 +95,12 @@ export function r2Driver({ bucket, remote }) {
|
|||
getJSON(key) {
|
||||
const dest = `${tmp}-get`;
|
||||
try {
|
||||
run(["r2", "object", "get", `${bucket}/${key}`, "--file", dest, ...flags]);
|
||||
// Probe: a missing object is the normal "not published yet" case.
|
||||
run(["r2", "object", "get", `${bucket}/${key}`, "--file", dest, ...flags], {
|
||||
quiet: true,
|
||||
});
|
||||
} catch {
|
||||
return null; // not found / error → absent
|
||||
return null; // not found / error → absent (expected on first publish)
|
||||
}
|
||||
try {
|
||||
return JSON.parse(readFileSync(dest, "utf8"));
|
||||
|
|
|
|||
Loading…
Reference in a new issue