@williamthorsen/nmr 0.3.0 → 0.4.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/dist/esm/.cache CHANGED
@@ -1 +1 @@
1
- 75a615bf272a9fdadb44845d2a33161432fe36543278a1abdfa819bdeb581654
1
+ e3d8619d797a79c02e27201b2f6171de0f5455f74ba2ba53b42079ea580c5d8d
@@ -0,0 +1,6 @@
1
+ export type ScriptValue = string | string[];
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;
6
+ export declare const rootScripts: ScriptRegistry;
@@ -0,0 +1,65 @@
1
+ const commonWorkspaceScripts = {
2
+ build: ["compile", "generate-typings"],
3
+ check: ["typecheck", "fmt:check", "lint:check", "test"],
4
+ "check:strict": ["typecheck", "fmt:check", "lint:strict", "test:coverage"],
5
+ clean: "pnpm exec rimraf dist/*",
6
+ compile: "tsx ../../config/build.ts",
7
+ fmt: "prettier --list-different --write .",
8
+ "fmt:check": "prettier --check .",
9
+ "generate-typings": "tsc --project tsconfig.generate-typings.json",
10
+ lint: "eslint --fix .",
11
+ "lint:check": "eslint .",
12
+ "lint:strict": "strict-lint",
13
+ typecheck: "tsgo --noEmit",
14
+ "view-coverage": "open coverage/index.html"
15
+ };
16
+ const integrationTestScripts = {
17
+ test: "pnpm exec vitest --config=vitest.standalone.config.ts",
18
+ "test:coverage": "pnpm exec vitest --config=vitest.standalone.config.ts --coverage",
19
+ "test:integration": "pnpm exec vitest --config=vitest.integration.config.ts",
20
+ "test:watch": "pnpm exec vitest --config=vitest.standalone.config.ts --watch"
21
+ };
22
+ const standardTestScripts = {
23
+ test: "pnpm exec vitest",
24
+ "test:coverage": "pnpm exec vitest --coverage",
25
+ "test:watch": "pnpm exec vitest --watch"
26
+ };
27
+ const rootScripts = {
28
+ audit: ["audit:prod", "audit:dev"],
29
+ "audit:dev": "pnpm dlx audit-ci@^6 --config .audit-ci/config.dev.json5",
30
+ "audit:prod": "pnpm dlx audit-ci@^6 --config .audit-ci/config.prod.json5",
31
+ build: "pnpm --recursive exec nmr build",
32
+ check: ["typecheck", "fmt:check", "lint:check", "test"],
33
+ "check:strict": ["typecheck", "fmt:check", "audit", "lint:strict", "test:coverage"],
34
+ ci: ["build", "check:strict"],
35
+ clean: "pnpm --recursive exec nmr clean",
36
+ fmt: `sh -c 'prettier --list-different --write "\${@:-.}"' --`,
37
+ "fmt:all": ["fmt", "fmt:sh"],
38
+ "fmt:check": `sh -c 'prettier --check "\${@:-.}"' --`,
39
+ "fmt:sh": "shfmt --write **/*.sh",
40
+ lint: "nmr root:lint && pnpm --recursive exec nmr lint",
41
+ "lint:check": "nmr root:lint:check && pnpm --recursive exec nmr lint:check",
42
+ "lint:strict": "nmr root:lint:strict && pnpm --recursive exec nmr lint:strict",
43
+ outdated: "pnpm outdated --compatible --recursive",
44
+ "outdated:latest": "pnpm outdated --recursive",
45
+ "report-overrides": "nmr-report-overrides",
46
+ "root:check": ["root:typecheck", "fmt:check", "root:lint:check", "root:test"],
47
+ "root:lint": "eslint --fix --ignore-pattern 'packages/**' .",
48
+ "root:lint:check": "eslint --ignore-pattern 'packages/**' .",
49
+ "root:lint:strict": "strict-lint --ignore-pattern 'packages/**' .",
50
+ "root:test": "vitest --config ./vitest.root.config.ts",
51
+ "root:typecheck": "tsgo --noEmit",
52
+ "sync-pnpm-version": "nmr-sync-pnpm-version",
53
+ test: "nmr root:test && pnpm --recursive exec nmr test",
54
+ "test:coverage": "nmr root:test && pnpm --recursive exec nmr test:coverage",
55
+ "test:watch": "vitest --watch",
56
+ typecheck: "nmr root:typecheck && pnpm --recursive exec nmr typecheck",
57
+ update: "pnpm update --recursive",
58
+ "update:latest": "pnpm update --latest --recursive"
59
+ };
60
+ export {
61
+ commonWorkspaceScripts,
62
+ integrationTestScripts,
63
+ rootScripts,
64
+ standardTestScripts
65
+ };
@@ -37,8 +37,8 @@ function getDefaultRootScripts() {
37
37
  "audit:prod": "pnpm dlx audit-ci@^6 --config .audit-ci/config.prod.json5",
38
38
  build: "pnpm --recursive exec nmr build",
39
39
  check: ["typecheck", "fmt:check", "lint:check", "test"],
40
- "check:strict": ["typecheck", "fmt:check", "lint:strict", "test:coverage", "audit"],
41
- ci: ["check:strict", "build"],
40
+ "check:strict": ["typecheck", "fmt:check", "audit", "lint:strict", "test:coverage"],
41
+ ci: ["build", "check:strict"],
42
42
  fmt: `sh -c 'prettier --list-different --write "\${@:-.}"' --`,
43
43
  "fmt:check": `sh -c 'prettier --check "\${@:-.}"' --`,
44
44
  lint: "nmr root:lint && pnpm --recursive exec nmr lint",
@@ -0,0 +1,4 @@
1
+ import type { ScriptRegistry } from './default-scripts.js';
2
+ export type { ScriptRegistry, ScriptValue } from './default-scripts.js';
3
+ export declare function getDefaultWorkspaceScripts(useIntTests: boolean): ScriptRegistry;
4
+ export declare function getDefaultRootScripts(): ScriptRegistry;
@@ -0,0 +1,14 @@
1
+ import { commonWorkspaceScripts, integrationTestScripts, rootScripts, standardTestScripts } from "./default-scripts.js";
2
+ function getDefaultWorkspaceScripts(useIntTests) {
3
+ return {
4
+ ...commonWorkspaceScripts,
5
+ ...useIntTests ? integrationTestScripts : standardTestScripts
6
+ };
7
+ }
8
+ function getDefaultRootScripts() {
9
+ return { ...rootScripts };
10
+ }
11
+ export {
12
+ getDefaultRootScripts,
13
+ getDefaultWorkspaceScripts
14
+ };
@@ -1,5 +1,5 @@
1
1
  import type { NmrConfig } from './config.js';
2
- import type { ScriptRegistry, ScriptValue } from './registries.js';
2
+ import type { ScriptRegistry, ScriptValue } from './resolve-scripts.js';
3
3
  export interface ResolvedScript {
4
4
  command: string;
5
5
  source: 'default' | 'package';
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { isObject } from "./helpers/type-guards.js";
4
- import { getDefaultRootScripts, getDefaultWorkspaceScripts } from "./registries.js";
4
+ import { getDefaultRootScripts, getDefaultWorkspaceScripts } from "./resolve-scripts.js";
5
5
  function expandScript(script) {
6
6
  if (typeof script === "string") {
7
7
  return script;
@@ -42,12 +42,16 @@ function buildRootRegistry(config) {
42
42
  ...config.rootScripts
43
43
  };
44
44
  }
45
+ function isSelfReferential(script, commandName) {
46
+ const prefix = `nmr ${commandName}`;
47
+ return script === prefix || script.startsWith(`${prefix} `);
48
+ }
45
49
  function resolveScript(commandName, registry, packageDir) {
46
50
  if (packageDir) {
47
51
  const pkgScripts = readPackageJsonScripts(packageDir);
48
52
  if (pkgScripts && commandName in pkgScripts) {
49
53
  const override = pkgScripts[commandName];
50
- if (override !== void 0) {
54
+ if (override !== void 0 && !isSelfReferential(override, commandName)) {
51
55
  return { command: override, source: "package" };
52
56
  }
53
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@williamthorsen/nmr",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "description": "Context-aware script runner for PNPM monorepos",
6
6
  "keywords": [