Skip to content

Commit

Permalink
Fixed an issue with private packages with versions being included in …
Browse files Browse the repository at this point in the history
…the CLI prompt despite the `privatePackages.version: false` setting (#985)

* Fix(cli): the problem of isListablePackage condition

* Test(cli): should not include private packages with a version in the prompt

* Update packages/cli/src/commands/add/__tests__/add.ts

* Create blue-geckos-guess.md

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
mino01x and Andarist committed Oct 29, 2022
1 parent 1d3f9f2 commit 8d0115e
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .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.
@@ -0,0 +1 @@
{}
9 changes: 9 additions & 0 deletions __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/*"
]
}
@@ -0,0 +1,4 @@
{
"name": "pkg-a",
"version": "1.0.0"
}
@@ -0,0 +1,5 @@
{
"name": "pkg-b",
"version": "1.0.0",
"private": true
}
@@ -0,0 +1,4 @@
{
"name": "pkg-c",
"version": "1.0.0"
}
21 changes: 21 additions & 0 deletions packages/cli/src/commands/add/__tests__/add.ts
Expand Up @@ -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"]);
});
});
2 changes: 1 addition & 1 deletion packages/cli/src/commands/add/isListablePackage.ts
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8d0115e

Please sign in to comment.