Skip to content

Commit

Permalink
Add error message when running changesets in a repo with workspaces …
Browse files Browse the repository at this point in the history
…configured but no packages yet

* Small error message added when running changesets in a mono repo without packages

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

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>

* Update .changeset/afraid-ways-buy.md

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
JakeGinnivan and Andarist committed Oct 29, 2022
1 parent 8d0115e commit 4d4d67b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-ways-buy.md
@@ -0,0 +1,5 @@
---
"@changesets/cli": patch
---

Add error message when running changesets in a repo with workspaces configured but no packages yet
12 changes: 9 additions & 3 deletions packages/cli/src/commands/add/index.ts
Expand Up @@ -20,7 +20,13 @@ export default async function add(
{ empty, open }: { empty?: boolean; open?: boolean },
config: Config
) {
const packages = (await getPackages(cwd)).packages.filter((pkg) =>
const packages = await getPackages(cwd);
if (packages.packages.length === 0) {
throw new Error(
`No packages found. You might have ${packages.tool} workspaces configured but no packages yet?`
);
}
const listablePackages = packages.packages.filter((pkg) =>
isListablePackage(config, pkg.packageJson)
);
const changesetBase = path.resolve(cwd, ".changeset");
Expand All @@ -41,8 +47,8 @@ export default async function add(
.filter((pkg) => isListablePackage(config, pkg.packageJson))
.map((pkg) => pkg.packageJson.name);

newChangeset = await createChangeset(changedPackagesName, packages);
printConfirmationMessage(newChangeset, packages.length > 1);
newChangeset = await createChangeset(changedPackagesName, listablePackages);
printConfirmationMessage(newChangeset, listablePackages.length > 1);

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

0 comments on commit 4d4d67b

Please sign in to comment.