mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
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:
@@ -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()
|
||||
|
||||
6
templates/astro-app/pnpm-workspace.yaml
Normal file
6
templates/astro-app/pnpm-workspace.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
packages: []
|
||||
|
||||
allowBuilds:
|
||||
esbuild: true
|
||||
sharp: true
|
||||
msw: false
|
||||
6
templates/next-app/pnpm-workspace.yaml
Normal file
6
templates/next-app/pnpm-workspace.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
packages: []
|
||||
|
||||
allowBuilds:
|
||||
sharp: true
|
||||
unrs-resolver: true
|
||||
msw: false
|
||||
5
templates/react-router-app/pnpm-workspace.yaml
Normal file
5
templates/react-router-app/pnpm-workspace.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
packages: []
|
||||
|
||||
allowBuilds:
|
||||
esbuild: true
|
||||
msw: false
|
||||
6
templates/start-app/pnpm-workspace.yaml
Normal file
6
templates/start-app/pnpm-workspace.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
packages: []
|
||||
|
||||
allowBuilds:
|
||||
esbuild: true
|
||||
unrs-resolver: true
|
||||
msw: false
|
||||
@@ -1,2 +1,5 @@
|
||||
packages: []
|
||||
|
||||
allowBuilds:
|
||||
esbuild: true
|
||||
msw: false
|
||||
|
||||
Reference in New Issue
Block a user