The Open Framework for Building Agents
fix(eve): pre-approve esbuild in pnpm projects (#3626)
e0-gh-vercel-connect[bot]f2b8792b1ff1
diff --git a/.changeset/quiet-builds-approve.md b/.changeset/quiet-builds-approve.mdnew file mode 100644index 000000000..49c004ff2--- /dev/null+++ b/.changeset/quiet-builds-approve.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Pre-approve esbuild install scripts in newly initialized pnpm projects so registry additions that install the Vercel CLI no longer require a separate `pnpm approve-builds` step.diff --git a/packages/eve/src/cli/commands/init.integration.test.ts b/packages/eve/src/cli/commands/init.integration.test.tsindex 6f25074be..62962ed5f 100644--- a/packages/eve/src/cli/commands/init.integration.test.ts+++ b/packages/eve/src/cli/commands/init.integration.test.ts@@ -841,7 +841,7 @@ describe("runInitCommand", () => {const projectPath = join(appsDirectory, "my-agent");await expect(pathExists(join(projectPath, "pnpm-workspace.yaml"))).resolves.toBe(false);await expect(readFile(join(workspaceRoot, "pnpm-workspace.yaml"), "utf8")).resolves.toBe(- "minimumReleaseAgeStrict: false\npackages:\n - apps/*\n\nallowBuilds:\n sharp: false\n",+ "minimumReleaseAgeStrict: false\npackages:\n - apps/*\n\nallowBuilds:\n esbuild: true\n sharp: false\n",);const projectPackageJson = JSON.parse(await readFile(join(projectPath, "package.json"), "utf8"),@@ -890,7 +890,7 @@ describe("runInitCommand", () => {const projectPath = join(agentsDirectory, "my-agent");await expect(pathExists(join(projectPath, "pnpm-workspace.yaml"))).resolves.toBe(false);await expect(readFile(join(workspaceRoot, "pnpm-workspace.yaml"), "utf8")).resolves.toBe(- "packages:\n - apps/*\n - agents/*\n\nallowBuilds:\n sharp: false\n",+ "packages:\n - apps/*\n - agents/*\n\nallowBuilds:\n esbuild: true\n sharp: false\n",);const projectPackageJson = JSON.parse(await readFile(join(projectPath, "package.json"), "utf8"),@@ -932,7 +932,7 @@ describe("runInitCommand", () => {await expect(pathExists(join(projectPath, "app/page.tsx"))).resolves.toBe(true);await expect(pathExists(join(projectPath, "pnpm-workspace.yaml"))).resolves.toBe(false);await expect(readFile(join(workspaceRoot, "pnpm-workspace.yaml"), "utf8")).resolves.toBe(- "packages:\n - apps/*\n - agents/*\n\nallowBuilds:\n sharp: false\n",+ "packages:\n - apps/*\n - agents/*\n\nallowBuilds:\n esbuild: true\n sharp: false\n",);const projectPackageJson = JSON.parse(await readFile(join(projectPath, "package.json"), "utf8"),diff --git a/packages/eve/src/setup/primitives/pm/pnpm.ts b/packages/eve/src/setup/primitives/pm/pnpm.tsindex 56c4f77b1..29373e268 100644--- a/packages/eve/src/setup/primitives/pm/pnpm.ts+++ b/packages/eve/src/setup/primitives/pm/pnpm.ts@@ -13,13 +13,16 @@ import type { PackageManagerStrategy } from "./types.js";export const PNPM_WORKSPACE_PATH = "pnpm-workspace.yaml";export const PNPM_WORKSPACE_MEMBERSHIP_ARGUMENTS = ["list", "--depth", "-1", "--json"] as const;-const SHARP_BUILD_POLICY = " sharp: false";+const DEFAULT_BUILD_POLICIES = [+ { name: "esbuild", line: " esbuild: true" },+ { name: "sharp", line: " sharp: false" },+] as const;export const PNPM_WORKSPACE_CONTENT = ["minimumReleaseAge: 0","minimumReleaseAgeStrict: true","allowBuilds:",- SHARP_BUILD_POLICY,+ ...DEFAULT_BUILD_POLICIES.map(({ line }) => line),"",].join("\n");@@ -40,12 +43,15 @@ function withPnpmWorkspacePolicy(source: string): string {if (allowBuildsIndex < 0) {const prefix = normalized.trim().length === 0 ? "" : `${normalized}\n`;- return `${prefix}allowBuilds:\n${SHARP_BUILD_POLICY}\n`;+ return `${prefix}allowBuilds:\n${DEFAULT_BUILD_POLICIES.map(({ line }) => line).join("\n")}\n`;}const blockEnd = findYamlBlockEnd(policyLines, allowBuildsIndex);const allowBuildsBlock = policyLines.slice(allowBuildsIndex + 1, blockEnd);- if (allowBuildsBlock.some((line) => /^\s+sharp:/.test(line))) {+ const missingPolicies = DEFAULT_BUILD_POLICIES.filter(+ ({ name }) => !allowBuildsBlock.some((line) => line.match(/^\s+([^:]+):/)?.[1] === name),+ );+ if (missingPolicies.length === 0) {return normalized;}@@ -53,7 +59,7 @@ function withPnpmWorkspacePolicy(source: string): string {while (insertAt > allowBuildsIndex + 1 && policyLines[insertAt - 1] === "") {insertAt -= 1;}- policyLines.splice(insertAt, 0, SHARP_BUILD_POLICY);+ policyLines.splice(insertAt, 0, ...missingPolicies.map(({ line }) => line));return policyLines.join("\n");}diff --git a/packages/eve/src/setup/scaffold/index.integration.test.ts b/packages/eve/src/setup/scaffold/index.integration.test.tsindex 917a97e00..3906a148b 100644--- a/packages/eve/src/setup/scaffold/index.integration.test.ts+++ b/packages/eve/src/setup/scaffold/index.integration.test.ts@@ -667,7 +667,7 @@ describe("ensureChannel", () => {expect(result.filesWritten).toContain(pnpmWorkspacePath);});- test("preserves an existing release-age policy", async () => {+ test("preserves an existing release-age and sharp policy", async () => {const projectRoot = await createTempDir();const pnpmWorkspacePath = join(projectRoot, "pnpm-workspace.yaml");const existingPolicy =@@ -685,8 +685,10 @@ describe("ensureChannel", () => {webPackageVersions: TEST_WEB_PACKAGE_VERSIONS,});- await expect(readFile(pnpmWorkspacePath, "utf8")).resolves.toBe(existingPolicy);- expect(result.filesSkipped).toContain(pnpmWorkspacePath);+ await expect(readFile(pnpmWorkspacePath, "utf8")).resolves.toBe(+ 'minimumReleaseAge: 2880\n"minimumReleaseAgeStrict": &strict false # Keep this comment\notherPolicy: *strict\nallowBuilds:\n sharp: true\n esbuild: true\n',+ );+ expect(result.filesWritten).toContain(pnpmWorkspacePath);});test("adds Web Chat pnpm policy and a missing package pattern at the ancestor workspace root", async () => {@@ -718,7 +720,7 @@ describe("ensureChannel", () => {expect(result.filesWritten).not.toContain(join(projectRoot, "pnpm-workspace.yaml"));await expect(pathExists(join(projectRoot, "pnpm-workspace.yaml"))).resolves.toBe(false);await expect(readFile(join(workspaceRoot, "pnpm-workspace.yaml"), "utf8")).resolves.toBe(- "packages:\n - apps/*\n - agents/*\n\nallowBuilds:\n sharp: false\n",+ "packages:\n - apps/*\n - agents/*\n\nallowBuilds:\n esbuild: true\n sharp: false\n",);const projectPackageJson = JSON.parse(await readFile(join(projectRoot, "package.json"), "utf8"),@@ -1198,7 +1200,7 @@ describe("scaffoldBaseProject", () => {await expect(pathExists(join(projectRoot, "pnpm-workspace.yaml"))).resolves.toBe(false);await expect(readFile(join(workspaceRoot, "pnpm-workspace.yaml"), "utf8")).resolves.toBe(- "minimumReleaseAge: 2880\nminimumReleaseAgeStrict: false\npackages:\n - apps/*\n\nallowBuilds:\n sharp: false\n",+ "minimumReleaseAge: 2880\nminimumReleaseAgeStrict: false\npackages:\n - apps/*\n\nallowBuilds:\n esbuild: true\n sharp: false\n",);const projectPackageJson = JSON.parse(await readFile(join(projectRoot, "package.json"), "utf8"),@@ -1241,7 +1243,7 @@ describe("scaffoldBaseProject", () => {await expect(pathExists(join(projectRoot, "pnpm-workspace.yaml"))).resolves.toBe(false);await expect(readFile(join(workspaceRoot, "pnpm-workspace.yaml"), "utf8")).resolves.toBe(- "packages:\n - apps/*\n - agents/*\n\nallowBuilds:\n sharp: false\n",+ "packages:\n - apps/*\n - agents/*\n\nallowBuilds:\n esbuild: true\n sharp: false\n",);const projectPackageJson = JSON.parse(await readFile(join(projectRoot, "package.json"), "utf8"),