Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: perserve peerDependencies, peerDependenciesMeta in transition mode #2061

Merged
merged 1 commit into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ export const base = createBase({
.object({
dependencies: z.record(z.string(), z.string()).optional(),
devDependencies: z.record(z.string(), z.string()).optional(),
peerDependencies: z.record(z.string(), z.string()).optional(),
peerDependenciesMeta: z.record(z.unknown()).optional(),
scripts: z.record(z.string(), z.string()).optional(),
})
.optional()
Expand Down
35 changes: 35 additions & 0 deletions src/blocks/blockPackageJson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,41 @@ describe("blockPackageJson", () => {
`);
});

test("with peerDependencies and peerDependenciesMeta", () => {
const creation = testBlock(blockPackageJson, {
options: {
...options,
packageData: {
peerDependencies: {
"@types/estree": ">=1",
eslint: ">=8",
},
peerDependenciesMeta: {
"@types/estree": {
optional: true,
},
},
},
},
});

expect(creation).toMatchInlineSnapshot(`
{
"files": {
"package.json": "{"name":"test-repository","version":"0.0.0","description":"A very very very very very very very very very very very very very very very very long HTML-ish description ending with an emoji. 🧵","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","files":["README.md","package.json"],"peerDependencies":{"@types/estree":">=1","eslint":">=8"},"peerDependenciesMeta":{"@types/estree":{"optional":true}}}",
},
"scripts": [
{
"commands": [
"pnpm install --no-frozen-lockfile",
],
"phase": 1,
},
],
}
`);
});

test("offline mode", () => {
const creation = testBlock(blockPackageJson, {
offline: true,
Expand Down
1 change: 1 addition & 0 deletions src/blocks/blockPackageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const blockPackageJson = base.createBlock({
"package.json": sortPackageJson(
JSON.stringify(
removeUndefinedObjects({
...options.packageData,
...addons.properties,
author: { email: options.email.npm, name: options.author },
bin: options.bin,
Expand Down