Skip to content

Commit

Permalink
Test(cli): should not include private packages with a version in the …
Browse files Browse the repository at this point in the history
…prompt
  • Loading branch information
mino01x committed Oct 19, 2022
1 parent 334f7d6 commit f831c88
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 1 deletion.
@@ -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 () => {
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?.version && packageJson.private) {
if (!config.privatePackages.version && packageJson.private) {
return false;
}

Expand Down

0 comments on commit f831c88

Please sign in to comment.