Skip to content

Commit

Permalink
[breaking] Switch from minimatch to micromatch
Browse files Browse the repository at this point in the history
  • Loading branch information
ecraig12345 committed Nov 26, 2024
1 parent 3b19f1e commit f8663ba
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 60 deletions.
7 changes: 7 additions & 0 deletions change/beachball-7087c042-3375-4bcb-9949-32856b4e48b0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "major",
"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`.)",
"packageName": "beachball",
"email": "[email protected]",
"dependentChangeType": "patch"
}
24 changes: 12 additions & 12 deletions docs/concepts/groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ For cases where it's necessary to bump packages together, `beachball` also provi

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.

| Name | Type | Description |
| ----------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `name` | `string` | Name of the version group |
| `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`. |
| `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. |
| `disallowedChangeTypes` | `ChangeType[] \| null` | Disallow these change types for the group. |
| Name | Type | Description |
| ----------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | `string` | Name of the version group |
| `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`. |
| `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. |
| `disallowedChangeTypes` | `ChangeType[] \| null` | Disallow these change types for the group. |

Example:

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

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.

| Name | Type | Description |
| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `masterPackageName` | `string` | The main package which a group of changes bubbles up to. |
| `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`. |
| `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. |
| `changelogPath` | `string` | Put the grouped changelog file under this directory. Can be relative to the root, or absolute. |
| Name | Type | Description |
| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `masterPackageName` | `string` | The main package which a group of changes bubbles up to. |
| `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`. |
| `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. |
| `changelogPath` | `string` | Put the grouped changelog file under this directory. Can be relative to the root, or absolute. |

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`.)

Expand Down
56 changes: 28 additions & 28 deletions docs/overview/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,34 @@ For the latest full list of supported options, see `RepoOptions` [in this file](

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

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

[1]: https://github.com/microsoft/beachball/blob/master/src/types/ChangeFilePrompt.ts
[2]: https://github.com/microsoft/beachball/blob/master/src/types/ChangelogOptions.ts
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"execa": "^5.0.0",
"fs-extra": "^11.1.1",
"lodash": "^4.17.15",
"minimatch": "^3.0.4",
"micromatch": "^4.0.0",
"p-graph": "^1.1.2",
"p-limit": "^3.0.2",
"prompts": "^2.4.2",
Expand All @@ -64,7 +64,7 @@
"@jest/globals": "^29.0.0",
"@types/fs-extra": "^11.0.0",
"@types/lodash": "^4.14.191",
"@types/minimatch": "^5.0.0",
"@types/micromatch": "^4.0.0",
"@types/node": "^20.0.0",
"@types/prompts": "^2.4.2",
"@types/semver": "^7.3.13",
Expand Down
4 changes: 2 additions & 2 deletions src/changefile/getChangedPackages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs-extra';
import path from 'path';
import minimatch from 'minimatch';
import micromatch from 'micromatch';
import type { ChangeFileInfo, ChangeInfoMultiple } from '../types/ChangeInfo';
import { getChangePath } from '../paths';
import { getChanges, getStagedChanges, git } from 'workspace-tools';
Expand Down Expand Up @@ -89,7 +89,7 @@ function getAllChangedPackages(options: BeachballOptions, packageInfos: PackageI
// Also ignore the CHANGELOG files and change files because they're generated by beachball.
const ignorePatterns = [...(options.ignorePatterns || []), `${changeDir}/*.json`, 'CHANGELOG.{md,json}'];
const nonIgnoredChanges = changes.filter(moddedFile => {
const ignorePattern = ignorePatterns.find(pattern => minimatch(moddedFile, pattern, { matchBase: true }));
const ignorePattern = ignorePatterns.find(pattern => micromatch.isMatch(moddedFile, pattern, { matchBase: true }));
ignorePattern && logIgnored(moddedFile, `ignored by pattern "${ignorePattern}"`);
return !ignorePattern;
});
Expand Down
Loading

0 comments on commit f8663ba

Please sign in to comment.