Skip to content

Commit d5c16d6

Browse files
authored
Add includedWorkspaces configuration option (#33)
* includedWorkspaces option * workspace-filtering test * build plugin * remove comments * add comments * Add docs to README.md
1 parent 1cd5e9b commit d5c16d6

File tree

7 files changed

+357
-121
lines changed

7 files changed

+357
-121
lines changed

README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Since Yarn 4.10.0, Yarn natively supports catalogs for managing dependency versi
1212
- **Supporting hierarchical catalog inheritance** (e.g., `stable/canary` inherits from `stable`)
1313
- **Providing validation** to ensure consistent catalog usage across workspaces
1414
- **Auto-applying default catalogs** when adding dependencies
15-
- **Ignoring specific workspaces** from catalog enforcement
15+
- **Filtering workspaces** with opt-in (`includedWorkspaces`) and opt-out (`ignoredWorkspaces`) options
1616

1717
## Requirements
1818

@@ -32,9 +32,10 @@ yarn plugin import https://raw.githubusercontent.com/toss/yarn-plugin-catalogs/m
3232
# catalogs.yml
3333

3434
options:
35-
default: [stable] # Optional: Default catalog groups for 'yarn add'
36-
validation: warn # Optional: 'warn' | 'strict' | 'off'
37-
ignoredWorkspaces: [] # Optional: Workspaces to ignore
35+
default: [stable] # Optional: Default catalog groups for 'yarn add'
36+
validation: warn # Optional: 'warn' | 'strict' | 'off'
37+
includedWorkspaces: [] # Optional: Workspaces to include
38+
ignoredWorkspaces: [] # Optional: Workspaces to ignore
3839

3940
list:
4041
root: # Special alias for the root catalog (accessed via catalog:)
@@ -243,9 +244,33 @@ list:
243244

244245
If your `package.json` has more `catalog:stable` dependencies than `catalog:beta`, running `yarn add next` will automatically use `catalog:stable`.
245246

246-
### Ignoring Workspaces
247+
### Workspace Filtering
247248

248-
Disable catalog enforcement for specific workspaces using glob patterns:
249+
Control which workspaces are included in catalog protocol processing using `includedWorkspaces` and `ignoredWorkspaces` options.
250+
251+
#### Including Workspaces
252+
253+
Use `includedWorkspaces` to specify which workspaces should be processed for catalogs. Only matching workspaces will receive catalog validation and default catalog auto-application:
254+
255+
```yaml
256+
# In catalogs.yml
257+
options:
258+
includedWorkspaces: [apps-*, packages]
259+
260+
list:
261+
stable:
262+
react: npm:18.0.0
263+
```
264+
265+
When `includedWorkspaces` is specified:
266+
- Only matching workspaces receive validation warnings/errors
267+
- Only matching workspaces have default catalogs auto-applied
268+
269+
If `includedWorkspaces` is not specified, all workspaces are included by default.
270+
271+
#### Ignoring Workspaces
272+
273+
Use `ignoredWorkspaces` to exclude specific workspaces from catalog processing:
249274

250275
```yaml
251276
# In catalogs.yml
@@ -260,7 +285,8 @@ list:
260285
Ignored workspaces:
261286
- Won't receive validation warnings/errors
262287
- Won't have default catalogs auto-applied
263-
- Can still use `catalog:` protocol if needed
288+
289+
`ignoredWorkspaces` takes precedence over `includedWorkspaces`.
264290

265291
### Validation
266292

bundles/@yarnpkg/plugin-catalogs.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sources/__tests__/ignored-workspaces.test.ts

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)