commit 672fd92a01ebbb79e1e031d538c56fbef3eef35a
parent 3681a992b226c9a0a3319746ed490506b45c068d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 18 Jun 2026 14:46:10 -0400
Merge branch 'fix-worktree-build-approval'
Diffstat:
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/scripts/worktree.mjs b/scripts/worktree.mjs
@@ -188,14 +188,18 @@ function cmdAdd(args) {
const positional = [];
let from = null;
let shareData = false;
+ let install = true;
for (let i = 0; i < args.length; i++) {
if (args[i] === "--from") from = args[++i];
else if (args[i] === "--share-data") shareData = true;
+ else if (args[i] === "--no-install") install = false;
else positional.push(args[i]);
}
const branch = positional[0];
if (!branch) {
- process.stderr.write("worktree add: usage: add <branch> [--from <ref>] [--share-data]\n");
+ process.stderr.write(
+ "worktree add: usage: add <branch> [--from <ref>] [--share-data] [--no-install]\n",
+ );
return 1;
}
@@ -229,6 +233,29 @@ function cmdAdd(args) {
process.stderr.write(`Wrote .worktree-env -> TRANSCRIPTS_DIR=${sharedTranscripts}\n`);
}
+ // Install deps so the worktree is immediately usable. pnpm 11 gates native
+ // build scripts (esbuild/lmdb/msgpackr-extract/sharp/unrs-resolver) behind an
+ // `allowBuilds` approval and, on a fresh worktree, injects a placeholder
+ // `allowBuilds:` block into the tracked pnpm-workspace.yaml and then fails its
+ // deps-verify-before-run check on every later `pnpm <script>`. Approving all
+ // builds for this one install runs them and records them as built, so the
+ // tracked file stays clean and subsequent plain installs/pre-run checks pass.
+ // These are the same build scripts the main worktree already runs.
+ if (install) {
+ process.stderr.write(`\nInstalling dependencies in ${dir} …\n`);
+ try {
+ execFileSync("pnpm", ["install", "--config.dangerouslyAllowAllBuilds=true"], {
+ cwd: dir,
+ stdio: "inherit",
+ });
+ } catch {
+ process.stderr.write(
+ "\npnpm install failed — run it yourself in the worktree " +
+ "(or re-run with --no-install to skip).\n",
+ );
+ }
+ }
+
const ports = portsForOffset(offsetForIndex(indexForDir(dir)));
process.stderr.write(`\nWorktree ready at ${dir}\n`);
process.stderr.write(
@@ -262,7 +289,7 @@ function usage() {
` ports [--shell fish|bash|posix] Print this worktree's assigned ports\n` +
` run -- <cmd...> Run a command with ports injected into env\n` +
` list List worktrees and their port blocks\n` +
- ` add <branch> [--from <ref>] [--share-data] Create a pre-configured worktree\n` +
+ ` add <branch> [--from <ref>] [--share-data] [--no-install] Create a pre-configured worktree (installs deps unless --no-install)\n` +
` rm <name|path> [--force] Remove a worktree (--force if it has local files)\n`,
);
}