fix(cli): extend pnpm 11 build-script allowlists across app templates

- Add packages: [] to single-app pnpm-workspace.yaml so pnpm 9 does
  not reject the file with "packages field missing or empty".
- Add astro-app, react-router-app, start-app, next-app workspace
  yamls with the build-script allowlist each template needs
  (esbuild, sharp, unrs-resolver as applicable).
- Set msw: false across all app allowlists so the registry component
  install runs cleanly under pnpm 11 without executing msw's
  service-worker postinstall.
- Add a scaffold test pinning the packages:[] + allowBuilds shape
  so the parser keeps treating it as single-app.
This commit is contained in:
shadcn
2026-05-21 20:00:42 +04:00
parent 5a4abc0ee8
commit d63c7813f2
6 changed files with 67 additions and 0 deletions

View File

@@ -348,6 +348,47 @@ describe("defaultScaffold", () => {
expect(written.workspaces).toBeUndefined()
})
it("should treat single-app workspace yaml (packages:[] + allowBuilds) as non-monorepo", async () => {
vi.mocked(fs.existsSync).mockImplementation((p: any) => {
const s = p.toString()
return s.includes("pnpm-workspace.yaml") || s.includes("package.json")
})
vi.mocked(fs.readFile).mockImplementation(((filePath: string) => {
if (filePath.includes("pnpm-workspace.yaml")) {
return Promise.resolve(
"packages: []\n\nallowBuilds:\n esbuild: true\n"
)
}
return Promise.resolve(
JSON.stringify({ name: "my-app", packageManager: "pnpm@9.0.0" })
)
}) as any)
const template = createTestTemplate()
await template.scaffold({
projectPath: "/test/my-app",
packageManager: "npm",
cwd: "/test",
})
// Inline empty packages array must not be parsed as a monorepo;
// the yaml is stripped and no workspaces array is added.
expect(vi.mocked(fs.remove)).toHaveBeenCalledWith(
path.join("/test/my-app", "pnpm-workspace.yaml")
)
const writeCalls = vi.mocked(fs.writeFile).mock.calls
const adaptCall = writeCalls.find(
(call) => call[0] === path.join("/test/my-app", "package.json")
)
expect(adaptCall).toBeDefined()
const written = JSON.parse(adaptCall![1] as string)
expect(written.packageManager).toBeUndefined()
expect(written.workspaces).toBeUndefined()
})
it("should rewrite workspace: protocol refs to * for npm monorepo", async () => {
vi.mocked(fs.existsSync).mockImplementation((p: any) => {
const s = p.toString()

View File

@@ -0,0 +1,6 @@
packages: []
allowBuilds:
esbuild: true
sharp: true
msw: false

View File

@@ -0,0 +1,6 @@
packages: []
allowBuilds:
sharp: true
unrs-resolver: true
msw: false

View File

@@ -0,0 +1,5 @@
packages: []
allowBuilds:
esbuild: true
msw: false

View File

@@ -0,0 +1,6 @@
packages: []
allowBuilds:
esbuild: true
unrs-resolver: true
msw: false

View File

@@ -1,2 +1,5 @@
packages: []
allowBuilds:
esbuild: true
msw: false