diff --git a/packages/shadcn/src/utils/scaffold.test.ts b/packages/shadcn/src/utils/scaffold.test.ts index 2a25ef5f8..9840c7f8a 100644 --- a/packages/shadcn/src/utils/scaffold.test.ts +++ b/packages/shadcn/src/utils/scaffold.test.ts @@ -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() diff --git a/templates/astro-app/pnpm-workspace.yaml b/templates/astro-app/pnpm-workspace.yaml new file mode 100644 index 000000000..96142df1c --- /dev/null +++ b/templates/astro-app/pnpm-workspace.yaml @@ -0,0 +1,6 @@ +packages: [] + +allowBuilds: + esbuild: true + sharp: true + msw: false diff --git a/templates/next-app/pnpm-workspace.yaml b/templates/next-app/pnpm-workspace.yaml new file mode 100644 index 000000000..b71df62da --- /dev/null +++ b/templates/next-app/pnpm-workspace.yaml @@ -0,0 +1,6 @@ +packages: [] + +allowBuilds: + sharp: true + unrs-resolver: true + msw: false diff --git a/templates/react-router-app/pnpm-workspace.yaml b/templates/react-router-app/pnpm-workspace.yaml new file mode 100644 index 000000000..6afd1d41d --- /dev/null +++ b/templates/react-router-app/pnpm-workspace.yaml @@ -0,0 +1,5 @@ +packages: [] + +allowBuilds: + esbuild: true + msw: false diff --git a/templates/start-app/pnpm-workspace.yaml b/templates/start-app/pnpm-workspace.yaml new file mode 100644 index 000000000..0b5bb8339 --- /dev/null +++ b/templates/start-app/pnpm-workspace.yaml @@ -0,0 +1,6 @@ +packages: [] + +allowBuilds: + esbuild: true + unrs-resolver: true + msw: false diff --git a/templates/vite-app/pnpm-workspace.yaml b/templates/vite-app/pnpm-workspace.yaml index 5ed0b5af0..6afd1d41d 100644 --- a/templates/vite-app/pnpm-workspace.yaml +++ b/templates/vite-app/pnpm-workspace.yaml @@ -1,2 +1,5 @@ +packages: [] + allowBuilds: esbuild: true + msw: false