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(cli): the problem of isListablePackage condition #985

Merged
merged 4 commits into from Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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", async () => {
Andarist marked this conversation as resolved.
Show resolved Hide resolved
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