diff --git a/.changeset/blue-geckos-guess.md b/.changeset/blue-geckos-guess.md new file mode 100644 index 000000000..f255ac798 --- /dev/null +++ b/.changeset/blue-geckos-guess.md @@ -0,0 +1,5 @@ +--- +"@changesets/cli": patch +--- + +Fixed an issue with private packages with versions being included in the CLI prompt despite the `privatePackages.version: false` setting. diff --git a/__fixtures__/private-package-with-version-field/.changeset/config.json b/__fixtures__/private-package-with-version-field/.changeset/config.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/__fixtures__/private-package-with-version-field/.changeset/config.json @@ -0,0 +1 @@ +{} diff --git a/__fixtures__/private-package-with-version-field/package.json b/__fixtures__/private-package-with-version-field/package.json new file mode 100644 index 000000000..14d4d5c5c --- /dev/null +++ b/__fixtures__/private-package-with-version-field/package.json @@ -0,0 +1,9 @@ +{ + "private": true, + "name": "private-package-with-version-field", + "description": "Base yarn workspace work", + "version": "1.0.0", + "workspaces": [ + "packages/*" + ] +} diff --git a/__fixtures__/private-package-with-version-field/packages/pkg-a/package.json b/__fixtures__/private-package-with-version-field/packages/pkg-a/package.json new file mode 100644 index 000000000..ee09b194d --- /dev/null +++ b/__fixtures__/private-package-with-version-field/packages/pkg-a/package.json @@ -0,0 +1,4 @@ +{ + "name": "pkg-a", + "version": "1.0.0" +} diff --git a/__fixtures__/private-package-with-version-field/packages/pkg-b/package.json b/__fixtures__/private-package-with-version-field/packages/pkg-b/package.json new file mode 100644 index 000000000..f1b81eab5 --- /dev/null +++ b/__fixtures__/private-package-with-version-field/packages/pkg-b/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg-b", + "version": "1.0.0", + "private": true +} diff --git a/__fixtures__/private-package-with-version-field/packages/pkg-c/package.json b/__fixtures__/private-package-with-version-field/packages/pkg-c/package.json new file mode 100644 index 000000000..888ba5c7e --- /dev/null +++ b/__fixtures__/private-package-with-version-field/packages/pkg-c/package.json @@ -0,0 +1,4 @@ +{ + "name": "pkg-c", + "version": "1.0.0" +} diff --git a/packages/cli/src/commands/add/__tests__/add.ts b/packages/cli/src/commands/add/__tests__/add.ts index 833e2ce30..5e62b4506 100644 --- a/packages/cli/src/commands/add/__tests__/add.ts +++ b/packages/cli/src/commands/add/__tests__/add.ts @@ -230,4 +230,25 @@ describe("Changesets", () => { const { choices } = askCheckboxPlus.mock.calls[0][1][0]; expect(choices).toEqual(["pkg-a", "pkg-c"]); }); + + it("should not include private packages with a version in the prompt if private packages are configured to be not versionable", async () => { + const cwd = f.copy("private-package-with-version-field"); + + mockUserResponses({ releases: { "pkg-a": "patch" } }); + await addChangeset( + cwd, + { empty: false }, + { + ...defaultConfig, + privatePackages: { + version: false, + tag: false, + }, + } + ); + + // @ts-ignore + const { choices } = askCheckboxPlus.mock.calls[0][1][0]; + expect(choices).toEqual(["pkg-a", "pkg-c"]); + }); }); diff --git a/packages/cli/src/commands/add/isListablePackage.ts b/packages/cli/src/commands/add/isListablePackage.ts index 16d17c177..9b11b1fdf 100644 --- a/packages/cli/src/commands/add/isListablePackage.ts +++ b/packages/cli/src/commands/add/isListablePackage.ts @@ -8,7 +8,7 @@ export function isListablePackage(config: Config, packageJson: PackageJSON) { return false; } - if (!config.privatePackages && packageJson.private) { + if (!config.privatePackages.version && packageJson.private) { return false; }