Skip to content

Commit 19f5e5c

Browse files
committed
[breaking] Switch from minimatch to micromatch
1 parent 0cc1721 commit 19f5e5c

9 files changed

+76
-60
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "major",
3+
"comment": "[BREAKING] Switch from `minimatch` to `micromatch`. Patterns should work the same, except that paths MUST use forward slashes. (This applies to `scope`, `ignorePatterns`, `groups`, and `changelog.groups`.)",
4+
"packageName": "beachball",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

docs/concepts/groups.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ For cases where it's necessary to bump packages together, `beachball` also provi
2828

2929
Groups can be added to the [configuration file](../overview/configuration). See the [`VersionGroupOptions` source](https://github.com/microsoft/beachball/blob/master/src/types/ChangelogOptions.ts) for full details.
3030

31-
| Name | Type | Description |
32-
| ----------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
33-
| `name` | `string` | Name of the version group |
34-
| `include` | `string \| string[] \| true` | minimatch pattern(s) for package paths to include in this group. Patterns are relative to the repo root and must use forward slashes. If `true`, include all packages except those matching `exclude`. |
35-
| `exclude` | `string \| string[]` | minimatch pattern(s) for package paths to include in this group. Patterns are relative to the repo root and must use forward slashes. |
36-
| `disallowedChangeTypes` | `ChangeType[] \| null` | Disallow these change types for the group. |
31+
| Name | Type | Description |
32+
| ----------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
33+
| `name` | `string` | Name of the version group |
34+
| `include` | `string \| string[] \| true` | micromatch pattern(s) for package paths to include in this group. Patterns are relative to the repo root and must use forward slashes. If `true`, include all packages except those matching `exclude`. |
35+
| `exclude` | `string \| string[]` | micromatch pattern(s) for package paths to include in this group. Patterns are relative to the repo root and must use forward slashes. |
36+
| `disallowedChangeTypes` | `ChangeType[] \| null` | Disallow these change types for the group. |
3737

3838
Example:
3939

@@ -58,12 +58,12 @@ If you only want to publish or record changes for certain packages, you should u
5858

5959
To show changes for multiple packages in one change file, use the `changelog.groups` option. See the [`ChangelogGroupOptions` source](https://github.com/microsoft/beachball/blob/master/src/types/ChangelogOptions.ts) for full details.
6060

61-
| Name | Type | Description |
62-
| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
63-
| `masterPackageName` | `string` | The main package which a group of changes bubbles up to. |
64-
| `include` | `string \| string[] \| true` | minimatch pattern(s) for package paths to include in this group. Patterns are relative to the repo root and must use forward slashes. If `true`, include all packages except those matching `exclude`. |
65-
| `exclude` | `string \| string[]` | minimatch pattern(s) for package paths to exclude from this group. Patterns are relative to the repo root and must use forward slashes. |
66-
| `changelogPath` | `string` | Put the grouped changelog file under this directory. Can be relative to the root, or absolute. |
61+
| Name | Type | Description |
62+
| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
63+
| `masterPackageName` | `string` | The main package which a group of changes bubbles up to. |
64+
| `include` | `string \| string[] \| true` | micromatch pattern(s) for package paths to include in this group. Patterns are relative to the repo root and must use forward slashes. If `true`, include all packages except those matching `exclude`. |
65+
| `exclude` | `string \| string[]` | micromatch pattern(s) for package paths to exclude from this group. Patterns are relative to the repo root and must use forward slashes. |
66+
| `changelogPath` | `string` | Put the grouped changelog file under this directory. Can be relative to the root, or absolute. |
6767

6868
In this example, changelogs for all packages under `packages/*` (except `packages/baz`) are written to a `CHANGELOG.md` at the repo root (`.`), with `foo` as the master package. (To replace `foo`'s usual changelog with a grouped one, you'd specify `changelogPath` as the path to `foo` instead, e.g. `packages/foo`.)
6969

docs/overview/configuration.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -60,34 +60,34 @@ For the latest full list of supported options, see `RepoOptions` [in this file](
6060

6161
"Applies to" indicates where the settings can be specified: repo-level config or package-level config.
6262

63-
| Option | Type | Default | Applies to | Description |
64-
| ----------------------- | ------------------------------ | -------------- | ------------- | ------------------------------------------------------------------------------------------------ |
65-
| `access` | `'public'` or `'restricted'` | `'restricted'` | repo | publish access level for scoped package names (e.g. `@foo/bar`) |
66-
| `branch` | `string` | [see notes][5] | repo | target branch; [see notes][5] |
67-
| `bumpDeps` | `boolean` | `true` | repo | bump dependent packages during publish (if B is bumped, and A depends on B, also bump A) |
68-
| `changeFilePrompt` | [`ChangeFilePromptOptions`][1] | | repo | customize the prompt for change files (can be used to add custom fields) |
69-
| `changehint` | `string` | | repo | hint message for when change files are not detected but required |
70-
| `changeDir` | `string` | `change` | repo | directory where change files are stored (relative to repo root) |
71-
| `changelog` | [`ChangelogOptions`][2] | | repo | changelog rendering and grouping options |
72-
| `defaultNpmTag` | `string` | `'latest'` | repo, package | the default dist-tag used for NPM publish |
73-
| `disallowedChangeTypes` | `string[]` | | repo, package | what change types are disallowed |
74-
| `fetch` | `boolean` | `true` | repo | fetch from remote before doing diff comparisons |
75-
| `generateChangelog` | `boolean \| 'md' \| 'json'` | `true` | repo | whether to generate `CHANGELOG.md/json` (`'md'` or `'json'` to generate only that type) |
76-
| `gitTags` | `boolean` | `true` | repo, package | whether to create git tags for published packages (eg: foo_v1.0.1) |
77-
| `groups` | [`VersionGroupOptions[]`][3] | | repo | bump these packages together ([see details][3]) |
78-
| `groupChanges` | `boolean` | `false` | repo | write multiple changes to a single changefile |
79-
| `hooks` | [`HooksOptions`][4] | | repo | hooks for custom pre/post publish actions |
80-
| `ignorePatterns` | `string[]` | | repo | ignore changes in these files (minimatch patterns with forward slashes; negations not supported) |
81-
| `package` | `string` | | repo | specifies which package the command relates to (overrides change detection based on `git diff`) |
82-
| `prereleasePrefix` | `string` | | repo | prerelease prefix for packages that are specified to receive a prerelease bump |
83-
| `publish` | `boolean` | `true` | repo | whether to publish to npm registry |
84-
| `push` | `boolean` | `true` | repo | whether to push to the remote git branch |
85-
| `registry` | `string` | | repo | target NPM registry to publish |
86-
| `retries` | `number` | `3` | repo | number of retries for a package publish before failing |
87-
| `scope` | `string[]` | | repo | only consider package paths matching these patterns ([see details](#scoping)) |
88-
| `shouldPublish` | `false \| undefined` | | package | manually disable publishing of a package by beachball (does not work to force publishing) |
89-
| `tag` | `string` | `'latest'` | repo, package | dist-tag for npm when published |
90-
| `transform` | [`TransformOptions`][4] | | repo | transformations for change files |
63+
| Option | Type | Default | Applies to | Description |
64+
| ----------------------- | ------------------------------ | -------------- | ------------- | ------------------------------------------------------------------------------------------------- |
65+
| `access` | `'public'` or `'restricted'` | `'restricted'` | repo | publish access level for scoped package names (e.g. `@foo/bar`) |
66+
| `branch` | `string` | [see notes][5] | repo | target branch; [see notes][5] |
67+
| `bumpDeps` | `boolean` | `true` | repo | bump dependent packages during publish (if B is bumped, and A depends on B, also bump A) |
68+
| `changeFilePrompt` | [`ChangeFilePromptOptions`][1] | | repo | customize the prompt for change files (can be used to add custom fields) |
69+
| `changehint` | `string` | | repo | hint message for when change files are not detected but required |
70+
| `changeDir` | `string` | `change` | repo | directory where change files are stored (relative to repo root) |
71+
| `changelog` | [`ChangelogOptions`][2] | | repo | changelog rendering and grouping options |
72+
| `defaultNpmTag` | `string` | `'latest'` | repo, package | the default dist-tag used for NPM publish |
73+
| `disallowedChangeTypes` | `string[]` | | repo, package | what change types are disallowed |
74+
| `fetch` | `boolean` | `true` | repo | fetch from remote before doing diff comparisons |
75+
| `generateChangelog` | `boolean \| 'md' \| 'json'` | `true` | repo | whether to generate `CHANGELOG.md/json` (`'md'` or `'json'` to generate only that type) |
76+
| `gitTags` | `boolean` | `true` | repo, package | whether to create git tags for published packages (eg: foo_v1.0.1) |
77+
| `groups` | [`VersionGroupOptions[]`][3] | | repo | bump these packages together ([see details][3]) |
78+
| `groupChanges` | `boolean` | `false` | repo | write multiple changes to a single changefile |
79+
| `hooks` | [`HooksOptions`][4] | | repo | hooks for custom pre/post publish actions |
80+
| `ignorePatterns` | `string[]` | | repo | ignore changes in these files (micromatch patterns with forward slashes; negations not supported) |
81+
| `package` | `string` | | repo | specifies which package the command relates to (overrides change detection based on `git diff`) |
82+
| `prereleasePrefix` | `string` | | repo | prerelease prefix for packages that are specified to receive a prerelease bump |
83+
| `publish` | `boolean` | `true` | repo | whether to publish to npm registry |
84+
| `push` | `boolean` | `true` | repo | whether to push to the remote git branch |
85+
| `registry` | `string` | | repo | target NPM registry to publish |
86+
| `retries` | `number` | `3` | repo | number of retries for a package publish before failing |
87+
| `scope` | `string[]` | | repo | only consider package paths matching these patterns ([see details](#scoping)) |
88+
| `shouldPublish` | `false \| undefined` | | package | manually disable publishing of a package by beachball (does not work to force publishing) |
89+
| `tag` | `string` | `'latest'` | repo, package | dist-tag for npm when published |
90+
| `transform` | [`TransformOptions`][4] | | repo | transformations for change files |
9191

9292
[1]: https://github.com/microsoft/beachball/blob/master/src/types/ChangeFilePrompt.ts
9393
[2]: https://github.com/microsoft/beachball/blob/master/src/types/ChangelogOptions.ts

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"execa": "^5.0.0",
5050
"fs-extra": "^11.1.1",
5151
"lodash": "^4.17.15",
52-
"minimatch": "^3.0.4",
52+
"micromatch": "^4.0.0",
5353
"p-graph": "^1.1.2",
5454
"p-limit": "^3.0.2",
5555
"prompts": "^2.4.2",
@@ -64,7 +64,7 @@
6464
"@jest/globals": "^29.0.0",
6565
"@types/fs-extra": "^11.0.0",
6666
"@types/lodash": "^4.14.191",
67-
"@types/minimatch": "^5.0.0",
67+
"@types/micromatch": "^4.0.0",
6868
"@types/node": "^20.0.0",
6969
"@types/prompts": "^2.4.2",
7070
"@types/semver": "^7.3.13",

src/changefile/getChangedPackages.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'fs-extra';
22
import path from 'path';
3-
import minimatch from 'minimatch';
3+
import micromatch from 'micromatch';
44
import type { ChangeFileInfo, ChangeInfoMultiple } from '../types/ChangeInfo';
55
import { getChangePath } from '../paths';
66
import { getChanges, getStagedChanges, git } from 'workspace-tools';
@@ -89,7 +89,7 @@ function getAllChangedPackages(options: BeachballOptions, packageInfos: PackageI
8989
// Also ignore the CHANGELOG files and change files because they're generated by beachball.
9090
const ignorePatterns = [...(options.ignorePatterns || []), `${changeDir}/*.json`, 'CHANGELOG.{md,json}'];
9191
const nonIgnoredChanges = changes.filter(moddedFile => {
92-
const ignorePattern = ignorePatterns.find(pattern => minimatch(moddedFile, pattern, { matchBase: true }));
92+
const ignorePattern = ignorePatterns.find(pattern => micromatch.isMatch(moddedFile, pattern, { matchBase: true }));
9393
ignorePattern && logIgnored(moddedFile, `ignored by pattern "${ignorePattern}"`);
9494
return !ignorePattern;
9595
});

0 commit comments

Comments
 (0)