Skip to content

Commit

Permalink
feat(config): allow to provide glob expressions for linked and ignore…
Browse files Browse the repository at this point in the history
… packages (#458)

* feat(config): allow to provide glob expressions for linked and ignore packages

* refactor(config): use micromatch instead of minimatch

* refactor(config): address feedback

* refactor(config): to simplify glob matching logic

* Fixed Array.isArray calls changing the type of the tested value to `any[]`

* Create thirty-fans-rhyme.md

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-authored-by: Mitchell Hamilton <mitchell@hamil.town>
  • Loading branch information
3 people committed Oct 6, 2020
1 parent a60c0e1 commit e33e4ca
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 96 deletions.
6 changes: 6 additions & 0 deletions .changeset/thirty-fans-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@changesets/config": minor
"@changesets/cli": minor
---

Allow glob expressions to be provided for the `linked` and `ignore` options
2 changes: 2 additions & 0 deletions docs/config-file-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ There are two caveats to this.

These restrictions exist to ensure your repository or published code do not end up in a broken state. For a more detailed intricacies of publishing, check out our guide on [problems publishing in monorepos](./problems-publishing-in-monorepos).

> NOTE: you can also provide glob expressions to match the packages, according to the [micromatch](https://www.npmjs.com/package/micromatch) format.
## `linked` (array of package names)

This option can be used to declare that packages should 'share' a version, instead of being versioned completely independently. As an example, if you have a `@changesets/button` component and a `@changesets/theme` component and you want to make sure that when one gets bumped to `2.0.0`, the other is also bumped to `2.0.0`. To achieve this you would have the config:
Expand Down
18 changes: 18 additions & 0 deletions docs/linked-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ I now have another changeset with a major for `pkg-a` and I do a release, the re

- `pkg-a` is at `3.0.0`
- `pkg-b` is at `2.0.0`

## Using glob expressions

Sometimes you want to link many or all packages within your project (for example in a monorepository setup), in which case you would need to keep the list of linked packages up-to-date.

To make it simpler to maintain that list, you can provide glob expressions in the linked list that would match and resolve to all the packages that you wish to include.

For example:

```json
{
"linked": [["pkg-*"]]
}
```

It will match all packages starting with `pkg-`.

**The glob expressions must be defined according to the [micromatch](https://www.npmjs.com/package/micromatch) format.**
4 changes: 3 additions & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
"@changesets/logger": "^0.0.5",
"@changesets/types": "^3.1.0",
"@manypkg/get-packages": "^1.0.1",
"fs-extra": "^7.0.1"
"fs-extra": "^7.0.1",
"micromatch": "^4.0.2"
},
"devDependencies": {
"@types/micromatch": "^4.0.1",
"fixturez": "^1.1.0",
"jest-in-case": "^1.0.2"
}
Expand Down

0 comments on commit e33e4ca

Please sign in to comment.