@williamthorsen/nmr 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,33 +3,23 @@
3
3
  Context-aware script runner for pnpm monorepos. Ships an `nmr` (node-monorepo run) binary that provides centralized, consistent script execution across workspace packages and the monorepo root.
4
4
 
5
5
  <!-- section:release-notes -->
6
- ## Release notes — v0.20.0 (2026-07-28)
6
+ ## Release notes — v0.21.0 (2026-07-30)
7
7
 
8
8
  ### 🎉 Features
9
9
 
10
- - 🚨 **Breaking:** Migrate to code-quality workflow v7 and retire the version-restatement apparatus (#503)
10
+ - Add a shared Vitest config export (#526)
11
11
 
12
- Migrates the code-quality workflow from `@v6` to `@v7`, which no longer requires the Node version to be specified in two places, and removes the test that previously checked for drift. Also removed are the `nmr sync-pnpm-version` command and drift-related exported functions.
12
+ Adds a shared Vitest configuration that can be used by repos that use `nmr`. Tests are now sorted into three named categories (unit, integration, and app), so that a run can target or skip a single category. A second variant excludes all tests in workspace packages, allowing the monorepo's own root-level tests to be run separately.
13
13
 
14
- Taking this upgrade requires migrating the repo's code-quality workflow to `@v7` and deleting its version-alignment test in the same change.
14
+ - 🚨 **Breaking:** Retire the Vitest config-file variants from nmr's defaults (#533)
15
15
 
16
- - 🚨 **Breaking:** Resolve workspace packages with pnpm's pattern semantics (#509)
17
-
18
- nmr now excludes packages matched by a `!`-prefixed pattern in `pnpm-workspace.yaml` from the packages it operates on. Deep globs such as `packages/**` now match nested packages, and running a command from inside a nested package targets that package rather than an enclosing ancestor. Exclusion patterns must be quoted to take effect. nmr now requires Node.js 24.16 or later.
19
-
20
- - Report pnpm overrides when reviewing dependencies (#514)
21
-
22
- From the monorepo root, `nmr upgrade` now reports the repo's active pnpm dependency overrides alongside the upgrade report, making clear when a pin is the reason an expected upgrade is absent. Repos that wired up this override report themselves with an install-time hook can now remove that hook.
23
-
24
- - Trim the bundled agent guidance to a cheatsheet (#516)
25
-
26
- Trims the agent guidance nmr installs into consuming repos from 100 lines to 10. Only the bare essentials are now injected into context. Agents are instructed to consult the package's README for details.
16
+ Packages no longer need extra Vitest config files to keep integration tests out of the default test run. Integration tests are now recognized by an `*.int.test.ts` suffix, and every package gets the same five commands: `test`, `test:all`, `test:coverage`, `test:integration`, and `test:watch`. The same five commands work from the monorepo root. A Vitest run that collects no test files now passes instead of failing. Consumers should migrate the Vitest config when upgrading.
27
17
 
28
18
  ### 🐛 Bug fixes
29
19
 
30
- - Anchor script execution to the resolved registry's directory (#517)
20
+ - Apply ignore rules from any working directory when formatting (#535)
31
21
 
32
- Fixes an issue where `nmr --workspace-root`, run from inside a workspace package, either failed outright or silently acted on the wrong directory. Commands now behave the same regardless of the directory they are invoked from: root commands act on the monorepo root, and package commands on their own package. Two changes for existing users: `nmr --workspace-root clean` now sweeps every workspace package instead of cleaning only the current one, and relative paths passed to a script now resolve against the directory the script runs in.
22
+ Fixes an issue where `nmr fmt` and `nmr fmt:check` did not apply a pattern from a package's `.gitignore` or `.prettierignore` when the run started at the monorepo root, so files a package excluded could fail a root-level format gate while passing a package-scoped one. Untracked files that git does not ignore are now formatted alongside tracked ones, and a run started outside a git repository now fails instead of reporting a clean pass over nothing. Trailing arguments to `nmr fmt` are git pathspecs rather than Prettier flags; one that matches no formattable file now fails instead of exiting silently.
33
23
  <!-- /section:release-notes -->
34
24
 
35
25
  ## Installation
@@ -75,11 +65,11 @@ nmr detects where you are and selects the right scripts automatically — see [c
75
65
 
76
66
  nmr's key feature is that the same command runs different scripts depending on where you invoke it. It walks up from your current directory to find `pnpm-workspace.yaml`, then checks whether your CWD is inside a workspace package directory.
77
67
 
78
- | Where you run `nmr` | Registry used | Working directory | `nmr test` runs |
79
- | --------------------------------- | ----------------- | ----------------- | --------------------------------------------- |
80
- | Monorepo root | Root scripts | Monorepo root | Root tests + `pnpm --recursive exec nmr test` |
81
- | Inside a workspace package | Workspace scripts | The package root | `pnpm exec vitest` (for that package only) |
82
- | Anywhere, with `--workspace-root` | Root scripts | Monorepo root | Root tests + `pnpm --recursive exec nmr test` |
68
+ | Where you run `nmr` | Registry used | Working directory | `nmr test` runs |
69
+ | --------------------------------- | ----------------- | ----------------- | --------------------------------------------------------------- |
70
+ | Monorepo root | Root scripts | Monorepo root | Root tests + `pnpm --recursive exec nmr test` |
71
+ | Inside a workspace package | Workspace scripts | The package root | `pnpm exec vitest --project '!integration'` (that package only) |
72
+ | Anywhere, with `--workspace-root` | Root scripts | Monorepo root | Root tests + `pnpm --recursive exec nmr test` |
83
73
 
84
74
  Relative paths in a script resolve against that working directory, not the invocation directory.
85
75
 
@@ -259,38 +249,48 @@ These scripts are available out of the box. Repo-wide config (tier 2) and per-pa
259
249
 
260
250
  ### Workspace scripts
261
251
 
262
- | Command | Runs |
263
- | --------------- | -------------------------------------------------------- |
264
- | `build` | `compile` |
265
- | `check` | `typecheck`, `fmt:check`, `lint:check`, `test` |
266
- | `check:strict` | `typecheck`, `fmt:check`, `lint:strict`, `test:coverage` |
267
- | `clean` | `nmr-clean` |
268
- | `compile` | `nmr-compile` |
269
- | `fix` | `lint`, `fmt` |
270
- | `fix:check` | `fmt:check`, `lint:check` |
271
- | `fmt` | `prettier --list-different --write .` |
272
- | `fmt:check` | `prettier --check .` |
273
- | `lint` | `eslint --fix .` |
274
- | `lint:check` | `eslint .` |
275
- | `lint:strict` | `strict-lint` |
276
- | `test` | `pnpm exec vitest` |
277
- | `test:coverage` | `pnpm exec vitest --coverage` |
278
- | `test:watch` | `pnpm exec vitest --watch` |
279
- | `typecheck` | `tsgo --noEmit` |
280
- | `upgrade` | `nmr-taze --include-locked` |
281
- | `view-coverage` | `open coverage/index.html` |
282
-
283
- #### Integration test variant
284
-
285
- A package gets this variant automatically when it contains a `vitest.integration.config.ts` file: `test` and `test:coverage` run the standalone (non-integration) suite, and integration tests run only when invoked explicitly. Activation is detected per package, so it applies under the recursive `nmr ci` fan-out. Opting in requires **both** `vitest.integration.config.ts` and `vitest.standalone.config.ts`, since the standalone scripts reference the latter.
286
-
287
- | Command | Runs |
288
- | ------------------ | ------------------------------------------------------------------ |
289
- | `test` | `pnpm exec vitest --config=vitest.standalone.config.ts` |
290
- | `test:all` | `pnpm exec vitest` |
291
- | `test:coverage` | `pnpm exec vitest --config=vitest.standalone.config.ts --coverage` |
292
- | `test:integration` | `pnpm exec vitest --config=vitest.integration.config.ts` |
293
- | `test:watch` | `pnpm exec vitest --config=vitest.standalone.config.ts --watch` |
252
+ | Command | Runs |
253
+ | ------------------ | -------------------------------------------------------- |
254
+ | `build` | `compile` |
255
+ | `check` | `typecheck`, `fmt:check`, `lint:check`, `test` |
256
+ | `check:strict` | `typecheck`, `fmt:check`, `lint:strict`, `test:coverage` |
257
+ | `clean` | `nmr-clean` |
258
+ | `compile` | `nmr-compile` |
259
+ | `fix` | `lint`, `fmt` |
260
+ | `fix:check` | `fmt:check`, `lint:check` |
261
+ | `fmt` | `nmr-fmt --write` |
262
+ | `fmt:check` | `nmr-fmt --check` |
263
+ | `lint` | `eslint --fix .` |
264
+ | `lint:check` | `eslint .` |
265
+ | `lint:strict` | `strict-lint` |
266
+ | `test` | `pnpm exec vitest --project '!integration'` |
267
+ | `test:all` | `pnpm exec vitest` |
268
+ | `test:coverage` | `pnpm exec vitest --project '!integration' --coverage` |
269
+ | `test:integration` | `pnpm exec vitest --project integration` |
270
+ | `test:watch` | `pnpm exec vitest --project '!integration' --watch` |
271
+ | `typecheck` | `tsgo --noEmit` |
272
+ | `upgrade` | `nmr-taze --include-locked` |
273
+ | `view-coverage` | `open coverage/index.html` |
274
+
275
+ `fmt` and `fmt:check` select their files through git rather than by walking the directory, which is what makes a package-level run and a root-level run apply the same ignore rules — see [file selection](#file-selection).
276
+
277
+ #### Test selections
278
+
279
+ Every package resolves the same five test commands. Nothing is detected on disk: the commands select [Vitest projects](#shared-vitest-config), so a package separates its integration tests by naming them `*.int.test.ts`, not by carrying extra config files.
280
+
281
+ | To run | Command |
282
+ | ----------------------------------- | ------------------ |
283
+ | Everything except integration tests | `test` |
284
+ | Integration tests alone | `test:integration` |
285
+ | Every project | `test:all` |
286
+
287
+ `test` negates `integration` rather than naming the code-only projects, so a category added later joins the default run instead of being dropped from it.
288
+
289
+ `test:coverage` and `test:watch` are the same selection as `test` in a different mode. There are no `test:integration --coverage` equivalents because none are needed: everything after a command name is forwarded untouched, so `nmr test:integration --coverage` already works.
290
+
291
+ To narrow to a single project, go through `test:all`: `nmr test:all --project app`. Narrowing through `test` does not work, because a second `--project` widens the filter rather than restricting it.
292
+
293
+ A run that collects no test files passes. That is what lets `nmr test:integration` fan out across a monorepo in which most packages have no integration tests, and it means a package with no tests at all needs no `"test": ""` override.
294
294
 
295
295
  ### Root scripts
296
296
 
@@ -318,11 +318,19 @@ A package gets this variant automatically when it contains a `vitest.integration
318
318
 
319
319
  #### Test
320
320
 
321
- | Command | Runs |
322
- | --------------- | ---------------------------------------------------------- |
323
- | `test` | `nmr root:test && pnpm --recursive exec nmr test` |
324
- | `test:coverage` | `nmr root:test && pnpm --recursive exec nmr test:coverage` |
325
- | `test:watch` | `vitest --watch` |
321
+ The same five names the workspace registry carries, so a command means the same thing from the monorepo root as from inside a package. Each fans out to root-level files and every workspace package.
322
+
323
+ | Command | Runs |
324
+ | ------------------ | ------------------------------------------------------------------------- |
325
+ | `test` | `nmr root:test && pnpm --recursive exec nmr test` |
326
+ | `test:all` | `nmr root:test:all && pnpm --recursive exec nmr test:all` |
327
+ | `test:coverage` | `nmr root:test && pnpm --recursive exec nmr test:coverage` |
328
+ | `test:integration` | `nmr root:test:integration && pnpm --recursive exec nmr test:integration` |
329
+ | `test:watch` | `vitest --project '!integration' --watch` |
330
+
331
+ `test:coverage` chains `root:test` rather than a `root:test:coverage`, because the root config reports no coverage of its own; packages cover their own sources.
332
+
333
+ `test:watch` is the exception to the fan-out shape, and deliberately omits `--config`: bare `vitest` at the monorepo root resolves the root `vitest.config.ts`, whose projects then cover the whole tree in one process. A chain like the others would never advance past its first watcher. To watch root-level files alone, run `nmr root:test --watch`.
326
334
 
327
335
  #### Typecheck
328
336
 
@@ -340,12 +348,18 @@ A package gets this variant automatically when it contains a `vitest.integration
340
348
 
341
349
  #### Format
342
350
 
343
- | Command | Runs |
344
- | ----------- | ------------------------------------- |
345
- | `fmt` | `prettier --list-different --write .` |
346
- | `fmt:all` | `fmt`, `fmt:sh` |
347
- | `fmt:check` | `prettier --check .` |
348
- | `fmt:sh` | `shfmt --write **/*.sh` |
351
+ | Command | Runs |
352
+ | ----------- | ----------------------- |
353
+ | `fmt` | `nmr-fmt --write` |
354
+ | `fmt:all` | `fmt`, `fmt:sh` |
355
+ | `fmt:check` | `nmr-fmt --check` |
356
+ | `fmt:sh` | `shfmt --write **/*.sh` |
357
+
358
+ #### File selection
359
+
360
+ `fmt` and `fmt:check` format the files git reports: tracked files, plus untracked files git does not ignore. Prettier reads `.gitignore` and `.prettierignore` from the working directory alone, so a pattern in `packages/<pkg>/.gitignore` never reaches a run started at the monorepo root. git knows the whole hierarchy, including `.git/info/exclude` and `core.excludesFile`, and every `.prettierignore` in the tree is discovered from the repository root, so package-level exclusions apply from any directory as well.
361
+
362
+ A file git ignores is never formatted, even when named directly. Trailing arguments are git pathspecs rather than Prettier flags, so `nmr fmt:check packages/nmr` narrows the run, while an unrecognized option and a pathspec matching no formattable file both fail it. Running outside a git repository fails rather than reporting a clean run.
349
363
 
350
364
  #### Audit
351
365
 
@@ -367,15 +381,17 @@ See [dependency upgrades](#dependency-upgrades) for the workflow and its configu
367
381
 
368
382
  These scripts operate on root-level code only (not workspace packages):
369
383
 
370
- | Command | Runs |
371
- | ------------------ | ------------------------------------------------------------- |
372
- | `root:check` | `root:typecheck`, `fmt:check`, `root:lint:check`, `root:test` |
373
- | `root:lint` | `eslint --fix --ignore-pattern 'packages/**' .` |
374
- | `root:lint:check` | `eslint --ignore-pattern 'packages/**' .` |
375
- | `root:lint:strict` | `strict-lint --ignore-pattern 'packages/**' .` |
376
- | `root:test` | `vitest --config ./vitest.root.config.ts` |
377
- | `root:typecheck` | `tsgo --noEmit` |
378
- | `root:upgrade` | `nmr-taze --include-locked` |
384
+ | Command | Runs |
385
+ | ----------------------- | ------------------------------------------------------------------ |
386
+ | `root:check` | `root:typecheck`, `fmt:check`, `root:lint:check`, `root:test` |
387
+ | `root:lint` | `eslint --fix --ignore-pattern 'packages/**' .` |
388
+ | `root:lint:check` | `eslint --ignore-pattern 'packages/**' .` |
389
+ | `root:lint:strict` | `strict-lint --ignore-pattern 'packages/**' .` |
390
+ | `root:test` | `vitest --config ./vitest.root.config.ts --project '!integration'` |
391
+ | `root:test:all` | `vitest --config ./vitest.root.config.ts` |
392
+ | `root:test:integration` | `vitest --config ./vitest.root.config.ts --project integration` |
393
+ | `root:typecheck` | `tsgo --noEmit` |
394
+ | `root:upgrade` | `nmr-taze --include-locked` |
379
395
 
380
396
  #### Utilities
381
397
 
@@ -484,6 +500,23 @@ Compile a single package's `src` tree to `dist/esm` with the TypeScript compiler
484
500
  nmr-compile
485
501
  ```
486
502
 
503
+ ### `nmr-fmt`
504
+
505
+ Format, or check the formatting of, the files git reports for the working directory. Exactly one of `--check` and `--write` is required; a bare invocation prints usage and exits non-zero rather than defaulting to a mutation. `--write` also lists the files it rewrote. This is what `fmt` and `fmt:check` resolve to, in both registries.
506
+
507
+ The selection is tracked files plus untracked files git does not ignore, scoped to the working directory, with every `.prettierignore` in the tree discovered from the repository root and passed to Prettier explicitly — see [file selection](#file-selection) for what that buys. Paths the index names but the filesystem does not have (a file deleted but not yet staged) and submodule gitlinks are both dropped, so neither reaches Prettier.
508
+
509
+ Trailing arguments are git pathspecs, not Prettier flags: they narrow the selection, an unrecognized option is rejected rather than forwarded, and pathspecs that match no formattable file fail rather than passing quietly.
510
+
511
+ `prettier` is an optional peer dependency (`>=3.9.5 <4`); the consuming repo provides it, and it is resolved through the module graph rather than from `PATH`, so the copy that runs is the one the repo declares and not whichever `prettier` happens to come first. A repository's formatter has to be the one its editor and pre-commit hook also run, which is why nmr takes it from the consumer instead of bundling a copy. It is optional because a repo can use nmr purely as a script runner; one that formats without a resolvable Prettier gets a message naming the package and the range.
512
+
513
+ The floor is a currency policy, not a capability boundary. What the design requires is `--ignore-path` honouring every flag rather than only the last, so a repository-root ignore file passed alongside a package-level one is not silently dropped — Prettier has done that since 3.0.0, while 2.x honoured only the final flag. The floor sits at the current release because every consuming repo tracks it; lowering it to `>=3.0.0` would cost correctness nothing.
514
+
515
+ ```bash
516
+ nmr-fmt --check
517
+ nmr-fmt --write packages/nmr
518
+ ```
519
+
487
520
  ### `nmr-taze`
488
521
 
489
522
  Run the [taze](https://github.com/antfu-collective/taze) dependency-upgrade tool, forwarding every argument to it untouched. This is what `root:upgrade` resolves to, and what the root `upgrade` script ends with — see [dependency upgrades](#dependency-upgrades) for the workflow.
@@ -542,3 +575,90 @@ for (const packageDir of getWorkspacePackageDirs(monorepoRoot)) {
542
575
  One divergence from pnpm: a directory counts as a package only if it holds a `package.json`, not a `package.yaml` or `package.json5`.
543
576
 
544
577
  Quote exclusion patterns in the manifest — `- '!packages/legacy'`. An unquoted `!` opens a YAML tag rather than a string, so the entry never reaches nmr (or pnpm) as a pattern.
578
+
579
+ ## Shared Vitest config
580
+
581
+ Every repo consuming nmr otherwise writes and maintains its own Vitest config. The `@williamthorsen/nmr/vitest` subpath publishes that config as a factory, so a repo declares only what it customizes:
582
+
583
+ ```ts
584
+ // vitest.config.ts
585
+ import { defineVitestConfig } from '@williamthorsen/nmr/vitest';
586
+
587
+ export default defineVitestConfig();
588
+ ```
589
+
590
+ `vitest` is a peer dependency (`>=4.0.0 <5`), declared optional — the consuming repo provides it, and repos that never import this subpath are unaffected.
591
+
592
+ ### Test categories
593
+
594
+ The config declares three projects, named for what the tests cover:
595
+
596
+ | Project | Matches | Covers |
597
+ | ------------- | -------------------------------------- | ---------------------------------------- |
598
+ | `unit` | every test file the others don't claim | source code |
599
+ | `integration` | `*.int.test.{ts,tsx}` | behavior beyond source code |
600
+ | `app` | `*.app.test.{ts,tsx}` | the app's own tooling, e.g. drift checks |
601
+
602
+ All three match only under a `__tests__` directory. Select them at run time with `--project`, which accepts negation:
603
+
604
+ ```bash
605
+ vitest --project '!integration' # everything except integration tests
606
+ vitest --project integration # integration tests alone
607
+ vitest # every project
608
+ ```
609
+
610
+ `unit` is defined by subtracting the other categories rather than by an allow-list of suffixes, so a file such as `parser.smoke.test.ts` runs under `unit` instead of being silently dropped.
611
+
612
+ ### Customizing by scope
613
+
614
+ Vitest applies some options at the root of a `projects` config and others per project, and placing one at the wrong level is silent rather than loud. The factory therefore takes two separate override surfaces instead of one merged config:
615
+
616
+ ```ts
617
+ export default defineVitestConfig({
618
+ // Vite-level options, plus the test options Vitest honours only at the root.
619
+ root: { resolve: { conditions: ['development'] } },
620
+ // Applied to every project.
621
+ project: { setupFiles: ['./vitest.setup.ts'] },
622
+ });
623
+ ```
624
+
625
+ `root` is typed to accept only the options that work at the root, so writing a per-project option there is a compile error rather than a setting that never runs. Both surfaces merge into the generated config rather than replacing it, so overriding one coverage field leaves the rest intact.
626
+
627
+ Arrays concatenate rather than replace. `exclude` and `setupFiles` therefore add to what the config already declares, and neither seam can narrow `include` or drop a default exclusion. Adding an `include` pattern through `project` widens all three projects at once, so a file matching it is collected by each and runs three times.
628
+
629
+ ### Root-scoped tests
630
+
631
+ A monorepo's own root-level tests need a second config, because the package config is found by walking up from a package directory:
632
+
633
+ ```ts
634
+ // vitest.root.config.ts
635
+ import { defineRootVitestConfig } from '@williamthorsen/nmr/vitest';
636
+
637
+ export default defineRootVitestConfig();
638
+ ```
639
+
640
+ This variant reads `pnpm-workspace.yaml` and excludes every workspace package from all three projects, so a root run covers only root-level files. It reports no coverage of its own — packages cover their own sources.
641
+
642
+ The monorepo root is located by walking up from the working directory, and every project is pinned to it, so the exclusions hold wherever the run is invoked from. Pass `startDir` to locate it from somewhere else:
643
+
644
+ ```ts
645
+ export default defineRootVitestConfig({ startDir: import.meta.dirname });
646
+ ```
647
+
648
+ ### Migrating from the config-file variants
649
+
650
+ nmr once selected a package's test scripts by looking for a `vitest.integration.config.ts` on disk, which meant three config files per package that separated its integration tests. Those files are no longer consulted. **Migrate the config and the scripts together**: one without the other leaves the repo in one of the two states below.
651
+
652
+ 1. Replace the repo's root `vitest.config.ts` with `defineVitestConfig()`, and its root-scoped config with `defineRootVitestConfig()`.
653
+ 2. Delete every `vitest.integration.config.ts` and `vitest.standalone.config.ts`, plus any per-package `vitest.config.ts` that only re-exports an ancestor. Vitest resolves config by walking up from the run root, so those are redundant.
654
+ 3. Rename integration tests to `*.int.test.ts` and tooling or drift tests to `*.app.test.ts`.
655
+ 4. Drop any hand-copied `test*` entries from `package.json`, which now shadow the defaults.
656
+
657
+ Until step 1 is done, an upgraded nmr behaves as follows against a config that declares no projects:
658
+
659
+ | Command | Result |
660
+ | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
661
+ | `nmr test` / `test:coverage` | **Succeeds, and runs integration tests too.** The separation is lost with no error, because `--project '!integration'` matches nothing to exclude. |
662
+ | `nmr test:integration` | **Fails** with `No projects matched the filter "integration"`. |
663
+
664
+ The second is the reliable signal that migration is incomplete. The first is silent, so do not treat a green `nmr test` as evidence that the move succeeded.
package/bin/nmr-fmt.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ try {
3
+ await import('../dist/esm/cli-fmt.js');
4
+ } catch (error) {
5
+ if (error.code === 'ERR_MODULE_NOT_FOUND') {
6
+ process.stderr.write('nmr-fmt: build output not found — run `pnpm run build` first\n');
7
+ } else {
8
+ process.stderr.write(`nmr-fmt: failed to load: ${error.message}\n`);
9
+ }
10
+ process.exit(1);
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import process from 'node:process';
2
+ import { runFmt } from "./commands/fmt.js";
3
+ process.exitCode = runFmt(process.argv.slice(2), process.cwd());
@@ -2,7 +2,7 @@ import { rm } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { loadConfig } from "../config.js";
4
4
  import { findContainingPackageDir } from "../context.js";
5
- import { applyDevBin, buildWorkspaceRegistry, hasIntegrationTestConfig, resolveScript } from "../resolver.js";
5
+ import { applyDevBin, buildWorkspaceRegistry, resolveScript } from "../resolver.js";
6
6
  import { runCommand } from "../runner.js";
7
7
  import { findMonorepoRoot, getWorkspacePackageDirs } from "../workspace.js";
8
8
  import { resolveBuildCachePath } from "./build.js";
@@ -34,8 +34,8 @@ export async function runClean(cwd = process.cwd()) {
34
34
  }
35
35
  async function sweepWorkspace(monorepoRoot, workspacePackageDirs) {
36
36
  const config = await loadConfig(monorepoRoot);
37
+ const registry = buildWorkspaceRegistry(config);
37
38
  for (const packageDir of workspacePackageDirs) {
38
- const registry = buildWorkspaceRegistry(config, hasIntegrationTestConfig(packageDir));
39
39
  const resolved = resolveScript(CLEAN_COMMAND, registry, packageDir, false);
40
40
  if (resolved === undefined || resolved.command === '') {
41
41
  continue;
@@ -0,0 +1,23 @@
1
+ export type FormatMode = 'check' | 'write';
2
+ export interface FormatTargets {
3
+ files: string[];
4
+ ignorePaths: string[];
5
+ }
6
+ export type ResolveTargetsResult = {
7
+ ok: true;
8
+ targets: FormatTargets;
9
+ } | {
10
+ ok: false;
11
+ error: string;
12
+ };
13
+ export declare function runFmt(argv: string[], cwd?: string): number;
14
+ export declare function resolveFormatTargets(cwd: string, pathspecs?: string[]): ResolveTargetsResult;
15
+ export interface RunPrettierOptions {
16
+ cliPath: string;
17
+ mode: FormatMode;
18
+ files: string[];
19
+ ignorePaths: string[];
20
+ cwd: string;
21
+ budgetBytes?: number;
22
+ }
23
+ export declare function runPrettier(options: RunPrettierOptions): number;
@@ -0,0 +1,172 @@
1
+ import { Buffer } from 'node:buffer';
2
+ import { spawnSync } from 'node:child_process';
3
+ import { readFileSync, statSync } from 'node:fs';
4
+ import { createRequire } from 'node:module';
5
+ import path from 'node:path';
6
+ import process from 'node:process';
7
+ import { reportError } from '@williamthorsen/nmr-core';
8
+ import { isObject } from "../helpers/type-guards.js";
9
+ const IGNORE_FILENAME = '.prettierignore';
10
+ const LIST_FILES_ARGS = ['ls-files', '-z', '--cached', '--others', '--exclude-standard'];
11
+ const IGNORE_FILE_PATHSPEC = `*${IGNORE_FILENAME}`;
12
+ const PRETTIER_PACKAGE = 'prettier';
13
+ const PRETTIER_RANGE = '>=3.9.5 <4';
14
+ const ARGUMENT_BUDGET_BYTES = 100_000;
15
+ const USAGE = 'Usage: nmr-fmt (--check | --write) [pathspec...]';
16
+ const MODE_ARGS = {
17
+ check: ['--check'],
18
+ write: ['--list-different', '--write'],
19
+ };
20
+ export function runFmt(argv, cwd = process.cwd()) {
21
+ const parsed = parseFmtArgs(argv);
22
+ if (!parsed.ok) {
23
+ reportError(`nmr-fmt: ${parsed.error}`);
24
+ process.stderr.write(`${USAGE}\n`);
25
+ return 1;
26
+ }
27
+ const resolved = resolveFormatTargets(cwd, parsed.pathspecs);
28
+ if (!resolved.ok) {
29
+ reportError(`nmr-fmt: ${resolved.error}`);
30
+ return 1;
31
+ }
32
+ const { files, ignorePaths } = resolved.targets;
33
+ if (files.length === 0) {
34
+ if (parsed.pathspecs.length > 0) {
35
+ reportError(`nmr-fmt: no formattable files matched: ${parsed.pathspecs.join(', ')}`);
36
+ return 1;
37
+ }
38
+ return 0;
39
+ }
40
+ const cli = resolvePrettierCli();
41
+ if (!cli.ok) {
42
+ reportError(`nmr-fmt: ${cli.error}`);
43
+ return 1;
44
+ }
45
+ return runPrettier({ cliPath: cli.cliPath, mode: parsed.mode, files, ignorePaths, cwd });
46
+ }
47
+ export function resolveFormatTargets(cwd, pathspecs = []) {
48
+ const toplevel = runGit(['rev-parse', '--show-toplevel'], cwd);
49
+ if (!toplevel.ok)
50
+ return toplevel;
51
+ const repositoryRoot = toplevel.stdout.trim();
52
+ const listed = runGit([...LIST_FILES_ARGS, '--', ...pathspecs], cwd);
53
+ if (!listed.ok)
54
+ return listed;
55
+ const ignoreFiles = runGit([...LIST_FILES_ARGS, '--', IGNORE_FILE_PATHSPEC], repositoryRoot);
56
+ if (!ignoreFiles.ok)
57
+ return ignoreFiles;
58
+ const discovered = splitNulSeparated(ignoreFiles.stdout)
59
+ .filter((file) => path.basename(file) === IGNORE_FILENAME)
60
+ .map((file) => path.resolve(repositoryRoot, file));
61
+ return {
62
+ ok: true,
63
+ targets: {
64
+ files: dedupe(splitNulSeparated(listed.stdout))
65
+ .filter((file) => isFormattableFile(cwd, file))
66
+ .toSorted(),
67
+ ignorePaths: dedupe([path.join(repositoryRoot, IGNORE_FILENAME), ...discovered]),
68
+ },
69
+ };
70
+ }
71
+ function isFormattableFile(cwd, file) {
72
+ return statSync(path.resolve(cwd, file), { throwIfNoEntry: false })?.isFile() === true;
73
+ }
74
+ function parseFmtArgs(argv) {
75
+ let mode;
76
+ const pathspecs = [];
77
+ for (const arg of argv) {
78
+ if (arg === '--check' || arg === '--write') {
79
+ const requested = arg === '--check' ? 'check' : 'write';
80
+ if (mode !== undefined && mode !== requested) {
81
+ return { ok: false, error: 'Pass --check or --write, not both.' };
82
+ }
83
+ mode = requested;
84
+ continue;
85
+ }
86
+ if (arg.startsWith('-')) {
87
+ return { ok: false, error: `Unknown option: ${arg}` };
88
+ }
89
+ pathspecs.push(arg);
90
+ }
91
+ if (mode === undefined) {
92
+ return { ok: false, error: 'Pass --check or --write.' };
93
+ }
94
+ return { ok: true, mode, pathspecs };
95
+ }
96
+ function resolvePrettierCli() {
97
+ const missing = {
98
+ ok: false,
99
+ error: `\`${PRETTIER_PACKAGE}\` (${PRETTIER_RANGE}) could not be resolved. Install it in this repository.`,
100
+ };
101
+ let manifestPath;
102
+ try {
103
+ manifestPath = createRequire(import.meta.url).resolve(`${PRETTIER_PACKAGE}/package.json`);
104
+ }
105
+ catch {
106
+ return missing;
107
+ }
108
+ const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
109
+ if (!isObject(manifest))
110
+ return missing;
111
+ const bin = isObject(manifest.bin) ? manifest.bin[PRETTIER_PACKAGE] : manifest.bin;
112
+ if (typeof bin !== 'string')
113
+ return missing;
114
+ return { ok: true, cliPath: path.resolve(path.dirname(manifestPath), bin) };
115
+ }
116
+ export function runPrettier(options) {
117
+ const { cliPath, mode, files, ignorePaths, cwd, budgetBytes = ARGUMENT_BUDGET_BYTES } = options;
118
+ const prettierArgs = [
119
+ cliPath,
120
+ '--ignore-unknown',
121
+ ...ignorePaths.flatMap((ignorePath) => ['--ignore-path', ignorePath]),
122
+ ...MODE_ARGS[mode],
123
+ ];
124
+ let firstFailure = 0;
125
+ for (const batch of batchWithinBudget(files, budgetBytes)) {
126
+ const result = spawnSync(process.execPath, [...prettierArgs, ...batch], { cwd, stdio: 'inherit' });
127
+ if (result.error) {
128
+ reportError(`nmr-fmt: could not run \`${PRETTIER_PACKAGE}\` (${result.error.message}).`);
129
+ return 1;
130
+ }
131
+ const status = result.status ?? 1;
132
+ if (status !== 0 && firstFailure === 0) {
133
+ firstFailure = status;
134
+ }
135
+ }
136
+ return firstFailure;
137
+ }
138
+ function batchWithinBudget(files, budget) {
139
+ const batches = [];
140
+ let batch = [];
141
+ let size = 0;
142
+ for (const file of files) {
143
+ const cost = Buffer.byteLength(file) + 1;
144
+ if (batch.length > 0 && size + cost > budget) {
145
+ batches.push(batch);
146
+ batch = [];
147
+ size = 0;
148
+ }
149
+ batch.push(file);
150
+ size += cost;
151
+ }
152
+ if (batch.length > 0)
153
+ batches.push(batch);
154
+ return batches;
155
+ }
156
+ function runGit(args, cwd) {
157
+ const result = spawnSync('git', args, { cwd, encoding: 'utf8' });
158
+ if (result.error) {
159
+ return { ok: false, error: result.error.message };
160
+ }
161
+ if (result.status !== 0) {
162
+ const stderr = result.stderr.trim();
163
+ return { ok: false, error: stderr || `\`git ${args.join(' ')}\` failed with exit code ${result.status}.` };
164
+ }
165
+ return { ok: true, stdout: result.stdout };
166
+ }
167
+ function splitNulSeparated(output) {
168
+ return output.split('\0').filter((entry) => entry !== '');
169
+ }
170
+ function dedupe(items) {
171
+ return [...new Set(items)];
172
+ }
@@ -1,6 +1,4 @@
1
1
  export type ScriptValue = string | string[];
2
2
  export type ScriptRegistry = Record<string, ScriptValue>;
3
- export declare const commonWorkspaceScripts: ScriptRegistry;
4
- export declare const integrationTestScripts: ScriptRegistry;
5
- export declare const standardTestScripts: ScriptRegistry;
3
+ export declare const workspaceScripts: ScriptRegistry;
6
4
  export declare const rootScripts: ScriptRegistry;
@@ -1,4 +1,4 @@
1
- export const commonWorkspaceScripts = {
1
+ export const workspaceScripts = {
2
2
  build: ['compile'],
3
3
  check: ['typecheck', 'fmt:check', 'lint:check', 'test'],
4
4
  'check:strict': ['typecheck', 'fmt:check', 'lint:strict', 'test:coverage'],
@@ -6,27 +6,20 @@ export const commonWorkspaceScripts = {
6
6
  compile: 'nmr-compile',
7
7
  fix: ['lint', 'fmt'],
8
8
  'fix:check': ['fmt:check', 'lint:check'],
9
- fmt: 'prettier --list-different --write .',
10
- 'fmt:check': 'prettier --check .',
9
+ fmt: 'nmr-fmt --write',
10
+ 'fmt:check': 'nmr-fmt --check',
11
11
  lint: 'eslint --fix .',
12
12
  'lint:check': 'eslint .',
13
13
  'lint:strict': 'strict-lint',
14
+ test: "pnpm exec vitest --project '!integration'",
15
+ 'test:all': 'pnpm exec vitest',
16
+ 'test:coverage': "pnpm exec vitest --project '!integration' --coverage",
17
+ 'test:integration': 'pnpm exec vitest --project integration',
18
+ 'test:watch': "pnpm exec vitest --project '!integration' --watch",
14
19
  typecheck: 'tsgo --noEmit',
15
20
  upgrade: 'nmr-taze --include-locked',
16
21
  'view-coverage': 'open coverage/index.html',
17
22
  };
18
- export const integrationTestScripts = {
19
- test: 'pnpm exec vitest --config=vitest.standalone.config.ts',
20
- 'test:all': 'pnpm exec vitest',
21
- 'test:coverage': 'pnpm exec vitest --config=vitest.standalone.config.ts --coverage',
22
- 'test:integration': 'pnpm exec vitest --config=vitest.integration.config.ts',
23
- 'test:watch': 'pnpm exec vitest --config=vitest.standalone.config.ts --watch',
24
- };
25
- export const standardTestScripts = {
26
- test: 'pnpm exec vitest',
27
- 'test:coverage': 'pnpm exec vitest --coverage',
28
- 'test:watch': 'pnpm exec vitest --watch',
29
- };
30
23
  export const rootScripts = {
31
24
  audit: ['audit:prod', 'audit:dev'],
32
25
  'audit:dev': 'pnpm exec v11y --dev',
@@ -39,9 +32,9 @@ export const rootScripts = {
39
32
  clean: 'nmr-clean',
40
33
  fix: ['lint', 'fmt'],
41
34
  'fix:check': ['fmt:check', 'lint:check'],
42
- fmt: 'sh -c \'prettier --list-different --write "${@:-.}"\' --',
35
+ fmt: 'nmr-fmt --write',
43
36
  'fmt:all': ['fmt', 'fmt:sh'],
44
- 'fmt:check': 'sh -c \'prettier --check "${@:-.}"\' --',
37
+ 'fmt:check': 'nmr-fmt --check',
45
38
  'fmt:sh': 'shfmt --write **/*.sh',
46
39
  lint: 'nmr root:lint && pnpm --recursive exec nmr lint',
47
40
  'lint:check': 'nmr root:lint:check && pnpm --recursive exec nmr lint:check',
@@ -51,13 +44,17 @@ export const rootScripts = {
51
44
  'root:lint': "eslint --fix --ignore-pattern 'packages/**' .",
52
45
  'root:lint:check': "eslint --ignore-pattern 'packages/**' .",
53
46
  'root:lint:strict': "strict-lint --ignore-pattern 'packages/**' .",
54
- 'root:test': 'vitest --config ./vitest.root.config.ts',
47
+ 'root:test': "vitest --config ./vitest.root.config.ts --project '!integration'",
48
+ 'root:test:all': 'vitest --config ./vitest.root.config.ts',
49
+ 'root:test:integration': 'vitest --config ./vitest.root.config.ts --project integration',
55
50
  'root:typecheck': 'tsgo --noEmit',
56
51
  'root:upgrade': 'nmr-taze --include-locked',
57
52
  'sync-agent-files': 'nmr-sync-agent-files',
58
53
  test: 'nmr root:test && pnpm --recursive exec nmr test',
54
+ 'test:all': 'nmr root:test:all && pnpm --recursive exec nmr test:all',
59
55
  'test:coverage': 'nmr root:test && pnpm --recursive exec nmr test:coverage',
60
- 'test:watch': 'vitest --watch',
56
+ 'test:integration': 'nmr root:test:integration && pnpm --recursive exec nmr test:integration',
57
+ 'test:watch': "vitest --project '!integration' --watch",
61
58
  typecheck: 'nmr root:typecheck && pnpm --recursive exec nmr typecheck',
62
59
  upgrade: 'nmr-report-overrides && nmr-taze --include-locked --recursive',
63
60
  };
package/dist/esm/help.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isHookName } from "./helpers/hook-name.js";
2
- import { buildRootRegistry, buildWorkspaceRegistry, describeScript, hasIntegrationTestConfig, isSelfReferential, readPackageJsonScripts, } from "./resolver.js";
2
+ import { buildRootRegistry, buildWorkspaceRegistry, describeScript, isSelfReferential, readPackageJsonScripts, } from "./resolver.js";
3
3
  export function generateHelp(config, packageDir, useRoot) {
4
4
  const lines = [
5
5
  'Usage: nmr [flags] <command> [args...]',
@@ -16,8 +16,7 @@ export function generateHelp(config, packageDir, useRoot) {
16
16
  ];
17
17
  const overrides = packageDir === undefined ? {} : collectOverrides(packageDir);
18
18
  let hadOverride = false;
19
- const useIntTests = !useRoot && packageDir !== undefined && hasIntegrationTestConfig(packageDir);
20
- const workspaceRegistry = filterHooks(buildWorkspaceRegistry(config, useIntTests));
19
+ const workspaceRegistry = filterHooks(buildWorkspaceRegistry(config));
21
20
  const workspaceMarked = !useRoot ? applyOverrides(workspaceRegistry, overrides) : new Set();
22
21
  if (workspaceMarked.size > 0)
23
22
  hadOverride = true;
@@ -1,4 +1,4 @@
1
1
  import type { ScriptRegistry } from './default-scripts.js';
2
2
  export type { ScriptRegistry, ScriptValue } from './default-scripts.js';
3
- export declare function getDefaultWorkspaceScripts(useIntTests: boolean): ScriptRegistry;
3
+ export declare function getDefaultWorkspaceScripts(): ScriptRegistry;
4
4
  export declare function getDefaultRootScripts(): ScriptRegistry;
@@ -1,9 +1,6 @@
1
- import { commonWorkspaceScripts, integrationTestScripts, rootScripts, standardTestScripts } from "./default-scripts.js";
2
- export function getDefaultWorkspaceScripts(useIntTests) {
3
- return {
4
- ...commonWorkspaceScripts,
5
- ...(useIntTests ? integrationTestScripts : standardTestScripts),
6
- };
1
+ import { rootScripts, workspaceScripts } from "./default-scripts.js";
2
+ export function getDefaultWorkspaceScripts() {
3
+ return { ...workspaceScripts };
7
4
  }
8
5
  export function getDefaultRootScripts() {
9
6
  return { ...rootScripts };
@@ -8,8 +8,7 @@ export interface ResolvedScript {
8
8
  export declare function expandScript(script: ScriptValue, workspaceRoot: boolean): string;
9
9
  export declare function describeScript(script: ScriptValue): string;
10
10
  export declare function readPackageJsonScripts(packageDir: string): Record<string, string> | undefined;
11
- export declare function hasIntegrationTestConfig(packageDir: string): boolean;
12
- export declare function buildWorkspaceRegistry(config: NmrConfig, useIntTests: boolean): ScriptRegistry;
11
+ export declare function buildWorkspaceRegistry(config: NmrConfig): ScriptRegistry;
13
12
  export declare function buildRootRegistry(config: NmrConfig): ScriptRegistry;
14
13
  export declare function isSelfReferential(script: string, commandName: string): boolean;
15
14
  export declare function resolveScript(commandName: string, registry: ScriptRegistry, packageDir: string | undefined, workspaceRoot: boolean): ResolvedScript | undefined;
@@ -1,4 +1,4 @@
1
- import { existsSync, readFileSync } from 'node:fs';
1
+ import { readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { isObject } from "./helpers/type-guards.js";
4
4
  import { getDefaultRootScripts, getDefaultWorkspaceScripts } from "./resolve-scripts.js";
@@ -63,12 +63,9 @@ export function readPackageJsonScripts(packageDir) {
63
63
  throw error;
64
64
  }
65
65
  }
66
- export function hasIntegrationTestConfig(packageDir) {
67
- return existsSync(path.join(packageDir, 'vitest.integration.config.ts'));
68
- }
69
- export function buildWorkspaceRegistry(config, useIntTests) {
66
+ export function buildWorkspaceRegistry(config) {
70
67
  return {
71
- ...getDefaultWorkspaceScripts(useIntTests),
68
+ ...getDefaultWorkspaceScripts(),
72
69
  ...config.workspaceScripts,
73
70
  };
74
71
  }
@@ -3,7 +3,7 @@ import { readPackageVersion, reportError } from '@williamthorsen/nmr-core';
3
3
  import { resolveContext } from "./context.js";
4
4
  import { generateHelp } from "./help.js";
5
5
  import { isHookName } from "./helpers/hook-name.js";
6
- import { applyDevBin, buildRootRegistry, buildWorkspaceRegistry, hasIntegrationTestConfig, resolveScript, } from "./resolver.js";
6
+ import { applyDevBin, buildRootRegistry, buildWorkspaceRegistry, resolveScript } from "./resolver.js";
7
7
  import { runCommand } from "./runner.js";
8
8
  const VERSION = readPackageVersion(import.meta.url);
9
9
  export async function runCli(options) {
@@ -39,9 +39,7 @@ export async function runCli(options) {
39
39
  const exitCode = runCommand(delegateCmd, context.monorepoRoot, { ...runOptions, env: childEnv });
40
40
  return { exitCode };
41
41
  }
42
- const registry = useRoot
43
- ? buildRootRegistry(context.config)
44
- : buildWorkspaceRegistry(context.config, hasIntegrationTestConfig(anchorDir));
42
+ const registry = useRoot ? buildRootRegistry(context.config) : buildWorkspaceRegistry(context.config);
45
43
  const resolved = resolveScript(command, registry, anchorDir, parsed.workspaceRoot);
46
44
  if (!resolved) {
47
45
  if (env.NMR_RUN_IF_PRESENT === '1') {
@@ -0,0 +1,15 @@
1
+ import type { ViteUserConfig } from 'vitest/config';
2
+ import type { InlineConfig, ProjectConfig } from 'vitest/node';
3
+ export type RootTestOptions = Omit<InlineConfig, keyof ProjectConfig>;
4
+ export type RootOverrides = Omit<ViteUserConfig, 'test'> & {
5
+ test?: RootTestOptions;
6
+ };
7
+ export interface VitestConfigOptions {
8
+ root?: RootOverrides;
9
+ project?: ProjectConfig;
10
+ }
11
+ export interface RootVitestConfigOptions extends VitestConfigOptions {
12
+ startDir?: string;
13
+ }
14
+ export declare function defineVitestConfig(options?: VitestConfigOptions): ViteUserConfig;
15
+ export declare function defineRootVitestConfig(options?: RootVitestConfigOptions): ViteUserConfig;
@@ -0,0 +1,62 @@
1
+ import path from 'node:path';
2
+ import { defaultExclude, mergeConfig } from 'vitest/config';
3
+ import { findMonorepoRoot, getWorkspacePackageDirs } from "./workspace.js";
4
+ const APP_PATTERNS = ['**/__tests__/**/*.app.test.{ts,tsx}'];
5
+ const INTEGRATION_PATTERNS = ['**/__tests__/**/*.int.test.{ts,tsx}'];
6
+ const ALL_TEST_PATTERNS = ['**/__tests__/**/*.test.{ts,tsx}'];
7
+ const COVERAGE_EXCLUDE = [
8
+ '**/__{mocks,tests}__/*',
9
+ '**/index.ts',
10
+ '**/mock*.{ts,tsx}',
11
+ '**/*.d.ts',
12
+ '**/*.types.ts',
13
+ ];
14
+ const PACKAGE_COVERAGE_INCLUDE = ['**/src/**/*.{ts,tsx}'];
15
+ export function defineVitestConfig(options = {}) {
16
+ return buildConfig(options, { coverageInclude: PACKAGE_COVERAGE_INCLUDE });
17
+ }
18
+ export function defineRootVitestConfig(options = {}) {
19
+ const monorepoRoot = findMonorepoRoot(options.startDir);
20
+ return buildConfig(options, {
21
+ coverageInclude: [],
22
+ projectExclude: getWorkspaceExcludePatterns(monorepoRoot),
23
+ projectRoot: monorepoRoot,
24
+ });
25
+ }
26
+ function buildConfig(options, { coverageInclude, projectExclude = [], projectRoot }) {
27
+ const config = {
28
+ test: {
29
+ coverage: {
30
+ enabled: false,
31
+ exclude: COVERAGE_EXCLUDE,
32
+ include: coverageInclude,
33
+ provider: 'v8',
34
+ },
35
+ passWithNoTests: true,
36
+ projects: buildProjects(options.project, projectExclude, projectRoot),
37
+ silent: 'passed-only',
38
+ watch: false,
39
+ },
40
+ };
41
+ return options.root ? mergeConfig(config, options.root) : config;
42
+ }
43
+ function buildProjects(overrides, extraExclude, projectRoot) {
44
+ const categories = [
45
+ { exclude: [], include: APP_PATTERNS, name: 'app' },
46
+ { exclude: [], include: INTEGRATION_PATTERNS, name: 'integration' },
47
+ { exclude: [...APP_PATTERNS, ...INTEGRATION_PATTERNS], include: ALL_TEST_PATTERNS, name: 'unit' },
48
+ ];
49
+ return categories.map(({ exclude, include, name }) => {
50
+ const project = {
51
+ extends: true,
52
+ ...(projectRoot !== undefined && { root: projectRoot }),
53
+ test: { exclude: [...defaultExclude, ...exclude, ...extraExclude], include, name },
54
+ };
55
+ return overrides ? mergeConfig(project, { test: overrides }) : project;
56
+ });
57
+ }
58
+ function getWorkspaceExcludePatterns(monorepoRoot) {
59
+ return getWorkspacePackageDirs(monorepoRoot)
60
+ .map((dir) => `${path.relative(monorepoRoot, dir).split(path.sep).join('/')}/**`)
61
+ .toSorted();
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@williamthorsen/nmr",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "private": false,
5
5
  "description": "Context-aware script runner for pnpm monorepos",
6
6
  "keywords": [
@@ -34,6 +34,10 @@
34
34
  "types": "./dist/esm/taze.d.ts",
35
35
  "default": "./dist/esm/taze.js"
36
36
  },
37
+ "./vitest": {
38
+ "types": "./dist/esm/vitest.d.ts",
39
+ "default": "./dist/esm/vitest.js"
40
+ },
37
41
  "./workspace": {
38
42
  "types": "./dist/esm/workspace.d.ts",
39
43
  "default": "./dist/esm/workspace.js"
@@ -44,6 +48,7 @@
44
48
  "nmr": "bin/nmr.js",
45
49
  "nmr-clean": "bin/nmr-clean.js",
46
50
  "nmr-compile": "bin/nmr-compile.js",
51
+ "nmr-fmt": "bin/nmr-fmt.js",
47
52
  "nmr-report-overrides": "bin/nmr-report-overrides.js",
48
53
  "nmr-sync-agent-files": "bin/nmr-sync-agent-files.js",
49
54
  "nmr-taze": "bin/nmr-taze.js"
@@ -56,12 +61,27 @@
56
61
  "dependencies": {
57
62
  "glob": "13.0.6",
58
63
  "jiti": "2.7.0",
59
- "taze": "19.15.1",
64
+ "taze": "19.16.0",
60
65
  "yaml": "2.9.0",
61
- "@williamthorsen/nmr-core": "0.7.2"
66
+ "@williamthorsen/nmr-core": "0.7.3"
67
+ },
68
+ "devDependencies": {
69
+ "prettier": "3.9.6",
70
+ "tinyglobby": "0.2.17",
71
+ "vitest": "4.1.10"
62
72
  },
63
73
  "peerDependencies": {
64
- "typescript": ">=5.7.0 <7"
74
+ "prettier": ">=3.9.5 <4",
75
+ "typescript": ">=5.7.0 <7",
76
+ "vitest": ">=4.0.0 <5"
77
+ },
78
+ "peerDependenciesMeta": {
79
+ "prettier": {
80
+ "optional": true
81
+ },
82
+ "vitest": {
83
+ "optional": true
84
+ }
65
85
  },
66
86
  "engines": {
67
87
  "node": ">=24.16.0"