Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Dont't include ignored packages when adding a changeset (#744)
  • Loading branch information
mskelton committed Jul 7, 2022
1 parent 7febb59 commit 84e46d1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-queens-add.md
@@ -0,0 +1,5 @@
---
"@changesets/cli": patch
---

Ignored packages are no longer listed when adding a changeset.
14 changes: 14 additions & 0 deletions packages/cli/src/commands/add/__tests__/add.ts
Expand Up @@ -204,4 +204,18 @@ describe("Changesets", () => {
})
);
});
it("should not include ignored packages in the prompt", async () => {
const cwd = await f.copy("internal-dependencies");

mockUserResponses({ releases: { "pkg-a": "patch" } });
await addChangeset(
cwd,
{ empty: false },
{ ...defaultConfig, ignore: ["pkg-b"] }
);

// @ts-ignore
const { choices } = askCheckboxPlus.mock.calls[0][1][0];
expect(choices).toEqual(["pkg-a", "pkg-c"]);
});
});
13 changes: 8 additions & 5 deletions packages/cli/src/commands/add/index.ts
Expand Up @@ -23,7 +23,9 @@ export default async function add(
{ empty, open }: { empty?: boolean; open?: boolean },
config: Config
) {
const packages = await getPackages(cwd);
const packages = (await getPackages(cwd)).packages.filter(
pkg => !config.ignore.includes(pkg.packageJson.name)
);
const changesetBase = path.resolve(cwd, ".changeset");

let newChangeset: UnwrapPromise<ReturnType<typeof createChangeset>>;
Expand All @@ -39,10 +41,11 @@ export default async function add(
ref: config.baseBranch
});
const changePackagesName = changedPackages
.filter(a => a)
.map(pkg => pkg.packageJson.name);
newChangeset = await createChangeset(changePackagesName, packages.packages);
printConfirmationMessage(newChangeset, packages.packages.length > 1);
.map(pkg => pkg.packageJson.name)
.filter(pkgName => config.ignore.includes(pkgName));

This comment has been minimized.

Copy link
@NicoKam

NicoKam Jul 13, 2022

Contributor

@mskelton Not include???

This comment has been minimized.

Copy link
@mskelton

mskelton Jul 13, 2022

Author Contributor

I'm confused what your question is. Also, this is a commit from a merged pull request.


newChangeset = await createChangeset(changePackagesName, packages);

This comment has been minimized.

Copy link
@walt1992

walt1992 Jul 13, 2022

@mskelton
I guess this change might cause error below as well

馃  error TypeError: Cannot read properties of undefined (reading 'packageJson')
馃  error     at createChangeset (/Users/ms.park/Desktop/workspace/payment.ohou.se/node_modules/@changesets/cli/dist/cli.cjs.dev.js:415:75)
馃  error     at add (/Users/ms.park/Desktop/workspace/payment.ohou.se/node_modules/@changesets/cli/dist/cli.cjs.dev.js:507:26)
馃  error     at async run$2 (/Users/ms.park/Desktop/workspace/payment.ohou.se/node_modules/@changesets/cli/dist/cli.cjs.dev.js:1254:5)
error Command failed with exit code 1.
printConfirmationMessage(newChangeset, packages.length > 1);

if (!newChangeset.confirmed) {
newChangeset = {
Expand Down

0 comments on commit 84e46d1

Please sign in to comment.