@williamthorsen/nmr 0.15.0 → 0.17.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/AGENTS.md +1 -1
- package/README.md +43 -54
- package/dist/esm/.cache +1 -1
- package/dist/esm/cli-build.js +5 -4
- package/dist/esm/cli-ensure-prepublish-hooks.js +37 -56
- package/dist/esm/cli-report-overrides.js +7 -5
- package/dist/esm/cli-sync-agent-files.js +19 -28
- package/dist/esm/cli-sync-pnpm-version.js +7 -5
- package/dist/esm/cli.js +13 -13
- package/dist/esm/commands/build.d.ts +2 -8
- package/dist/esm/commands/build.js +270 -118
- package/dist/esm/commands/ensure-prepublish-hooks.js +66 -69
- package/dist/esm/commands/report-overrides.js +10 -13
- package/dist/esm/commands/sync-agent-files.js +46 -52
- package/dist/esm/commands/sync-pnpm-version.js +35 -42
- package/dist/esm/config.js +59 -57
- package/dist/esm/context.d.ts +1 -1
- package/dist/esm/context.js +70 -72
- package/dist/esm/default-scripts.js +63 -67
- package/dist/esm/help.d.ts +1 -1
- package/dist/esm/help.js +65 -68
- package/dist/esm/helpers/code-quality-pnpm-action.js +20 -24
- package/dist/esm/helpers/hook-name.js +2 -5
- package/dist/esm/helpers/package-json.js +46 -41
- package/dist/esm/helpers/type-guards.js +2 -5
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +1 -4
- package/dist/esm/resolve-scripts.d.ts +2 -2
- package/dist/esm/resolve-scripts.js +7 -11
- package/dist/esm/resolver.d.ts +3 -2
- package/dist/esm/resolver.js +85 -83
- package/dist/esm/runCli.js +135 -145
- package/dist/esm/runner.js +35 -34
- package/dist/esm/scripts.d.ts +2 -2
- package/dist/esm/scripts.js +1 -5
- package/dist/esm/tests/consistency.d.ts +1 -1
- package/dist/esm/tests/consistency.js +45 -54
- package/dist/esm/tests/helpers/get-runtime-version-from-asdf.js +11 -14
- package/dist/esm/tests/helpers/get-string-from-yaml-file.js +10 -13
- package/dist/esm/tests/helpers/get-value-at-path.js +30 -30
- package/package.json +5 -3
package/dist/esm/help.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { NmrConfig } from './config.
|
|
1
|
+
import type { NmrConfig } from './config.js';
|
|
2
2
|
export declare function generateHelp(config: NmrConfig, packageDir: string | undefined, useRoot: boolean): string;
|
package/dist/esm/help.js
CHANGED
|
@@ -1,79 +1,76 @@
|
|
|
1
1
|
import { isHookName } from "./helpers/hook-name.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
formatRegistry(rootRegistry, rootMarked, lines);
|
|
34
|
-
if (hadOverride) {
|
|
35
|
-
lines.push("", "* Overridden by package.json");
|
|
36
|
-
}
|
|
37
|
-
return lines.join("\n");
|
|
2
|
+
import { buildRootRegistry, buildWorkspaceRegistry, describeScript, isSelfReferential, readPackageJsonScripts, } from "./resolver.js";
|
|
3
|
+
export function generateHelp(config, packageDir, useRoot) {
|
|
4
|
+
const lines = [
|
|
5
|
+
'Usage: nmr [flags] <command> [args...]',
|
|
6
|
+
'',
|
|
7
|
+
'Flags:',
|
|
8
|
+
' -F, --filter <pattern> Run command in matching packages',
|
|
9
|
+
' -R, --recursive Run command in all packages',
|
|
10
|
+
' -w, --workspace-root Run root command regardless of cwd',
|
|
11
|
+
' -q, --quiet Suppress output on success; show full output on failure',
|
|
12
|
+
' -?, --help Show this help',
|
|
13
|
+
'',
|
|
14
|
+
'Workspace commands:',
|
|
15
|
+
];
|
|
16
|
+
const overrides = packageDir === undefined ? {} : collectOverrides(packageDir);
|
|
17
|
+
let hadOverride = false;
|
|
18
|
+
const workspaceRegistry = filterHooks(buildWorkspaceRegistry(config, false));
|
|
19
|
+
const workspaceMarked = !useRoot ? applyOverrides(workspaceRegistry, overrides) : new Set();
|
|
20
|
+
if (workspaceMarked.size > 0)
|
|
21
|
+
hadOverride = true;
|
|
22
|
+
formatRegistry(workspaceRegistry, workspaceMarked, lines);
|
|
23
|
+
lines.push('', 'Root commands:');
|
|
24
|
+
const rootRegistry = filterHooks(buildRootRegistry(config));
|
|
25
|
+
const rootMarked = useRoot ? applyOverrides(rootRegistry, overrides) : new Set();
|
|
26
|
+
if (rootMarked.size > 0)
|
|
27
|
+
hadOverride = true;
|
|
28
|
+
formatRegistry(rootRegistry, rootMarked, lines);
|
|
29
|
+
if (hadOverride) {
|
|
30
|
+
lines.push('', '* Overridden by package.json');
|
|
31
|
+
}
|
|
32
|
+
return lines.join('\n');
|
|
38
33
|
}
|
|
39
34
|
function collectOverrides(packageDir) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
const scripts = readPackageJsonScripts(packageDir);
|
|
36
|
+
if (!scripts)
|
|
37
|
+
return {};
|
|
38
|
+
const filtered = {};
|
|
39
|
+
for (const [name, value] of Object.entries(scripts)) {
|
|
40
|
+
if (isHookName(name))
|
|
41
|
+
continue;
|
|
42
|
+
if (isSelfReferential(value, name))
|
|
43
|
+
continue;
|
|
44
|
+
filtered[name] = value;
|
|
45
|
+
}
|
|
46
|
+
return filtered;
|
|
49
47
|
}
|
|
50
48
|
function applyOverrides(registry, overrides) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
const marked = new Set();
|
|
50
|
+
for (const [name, value] of Object.entries(overrides)) {
|
|
51
|
+
if (name in registry) {
|
|
52
|
+
registry[name] = value;
|
|
53
|
+
marked.add(name);
|
|
54
|
+
}
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
return marked;
|
|
56
|
+
return marked;
|
|
59
57
|
}
|
|
60
58
|
function filterHooks(registry) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
const filtered = {};
|
|
60
|
+
for (const [key, value] of Object.entries(registry)) {
|
|
61
|
+
if (!isHookName(key))
|
|
62
|
+
filtered[key] = value;
|
|
63
|
+
}
|
|
64
|
+
return filtered;
|
|
66
65
|
}
|
|
67
66
|
function formatRegistry(registry, marked, lines) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
}
|
|
67
|
+
const keys = Object.keys(registry);
|
|
68
|
+
if (keys.length === 0)
|
|
69
|
+
return;
|
|
70
|
+
const maxKeyLen = Math.max(...keys.map((k) => k.length));
|
|
71
|
+
const pad = Math.max(maxKeyLen + 1 + 2, 20);
|
|
72
|
+
for (const [key, value] of Object.entries(registry)) {
|
|
73
|
+
const marker = marked.has(key) ? '*' : ' ';
|
|
74
|
+
lines.push(` ${(key + marker).padEnd(pad)} ${describeScript(value)}`);
|
|
75
|
+
}
|
|
76
76
|
}
|
|
77
|
-
export {
|
|
78
|
-
generateHelp
|
|
79
|
-
};
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import { isScalar, visit } from
|
|
2
|
-
import { z } from
|
|
3
|
-
const CodeQualityPnpmWorkflowSchema = z.looseObject({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { isScalar, visit } from 'yaml';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const CodeQualityPnpmWorkflowSchema = z.looseObject({
|
|
4
|
+
jobs: z.looseObject({
|
|
5
|
+
'code-quality': z.looseObject({
|
|
6
|
+
with: z.looseObject({
|
|
7
|
+
'pnpm-version': z.string(),
|
|
8
|
+
}),
|
|
9
|
+
}),
|
|
10
|
+
}),
|
|
11
11
|
});
|
|
12
|
-
function getPnpmVersionNodes(doc) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
export function getPnpmVersionNodes(doc) {
|
|
13
|
+
const nodes = [];
|
|
14
|
+
visit(doc, {
|
|
15
|
+
Pair(_, pair) {
|
|
16
|
+
if (isScalar(pair.key) && pair.key.value === 'pnpm-version' && isScalar(pair.value)) {
|
|
17
|
+
nodes.push(pair.value);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
return nodes;
|
|
22
22
|
}
|
|
23
|
-
export {
|
|
24
|
-
CodeQualityPnpmWorkflowSchema,
|
|
25
|
-
getPnpmVersionNodes
|
|
26
|
-
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
function isHookName(key) {
|
|
2
|
-
|
|
1
|
+
export function isHookName(key) {
|
|
2
|
+
return (key.length > 4 && key.endsWith(':pre')) || (key.length > 5 && key.endsWith(':post'));
|
|
3
3
|
}
|
|
4
|
-
export {
|
|
5
|
-
isHookName
|
|
6
|
-
};
|
|
@@ -1,46 +1,51 @@
|
|
|
1
|
-
import { readFileSync } from
|
|
2
|
-
import path from
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
import { isObject } from "./type-guards.js";
|
|
4
|
-
function readPackageJson(dir) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
const pkg = {};
|
|
11
|
-
if (typeof parsed.name === "string") pkg.name = parsed.name;
|
|
12
|
-
if (parsed.private === true) pkg.private = true;
|
|
13
|
-
if (typeof parsed.version === "string") pkg.version = parsed.version;
|
|
14
|
-
if (typeof parsed.packageManager === "string") pkg.packageManager = parsed.packageManager;
|
|
15
|
-
if (isObject(parsed.scripts)) {
|
|
16
|
-
const scripts = {};
|
|
17
|
-
for (const [key, val] of Object.entries(parsed.scripts)) {
|
|
18
|
-
if (typeof val === "string") scripts[key] = val;
|
|
4
|
+
export function readPackageJson(dir) {
|
|
5
|
+
const content = readFileSync(path.join(dir, 'package.json'), 'utf8');
|
|
6
|
+
const parsed = JSON.parse(content);
|
|
7
|
+
if (!isObject(parsed)) {
|
|
8
|
+
throw new TypeError(`Invalid package.json in ${dir}: expected an object`);
|
|
19
9
|
}
|
|
20
|
-
pkg
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
const pkg = {};
|
|
11
|
+
if (typeof parsed.name === 'string')
|
|
12
|
+
pkg.name = parsed.name;
|
|
13
|
+
if (parsed.private === true)
|
|
14
|
+
pkg.private = true;
|
|
15
|
+
if (typeof parsed.version === 'string')
|
|
16
|
+
pkg.version = parsed.version;
|
|
17
|
+
if (typeof parsed.packageManager === 'string')
|
|
18
|
+
pkg.packageManager = parsed.packageManager;
|
|
19
|
+
if (isObject(parsed.scripts)) {
|
|
20
|
+
const scripts = {};
|
|
21
|
+
for (const [key, val] of Object.entries(parsed.scripts)) {
|
|
22
|
+
if (typeof val === 'string')
|
|
23
|
+
scripts[key] = val;
|
|
24
|
+
}
|
|
25
|
+
pkg.scripts = scripts;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
if (isObject(parsed.pnpm)) {
|
|
28
|
+
const pnpm = parsed.pnpm;
|
|
29
|
+
if (isObject(pnpm.overrides)) {
|
|
30
|
+
const overrides = {};
|
|
31
|
+
for (const [key, val] of Object.entries(pnpm.overrides)) {
|
|
32
|
+
if (typeof val === 'string')
|
|
33
|
+
overrides[key] = val;
|
|
34
|
+
}
|
|
35
|
+
pkg.pnpm = { overrides };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return pkg;
|
|
33
39
|
}
|
|
34
|
-
function getPnpmOverrides(pkg) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
export function getPnpmOverrides(pkg) {
|
|
41
|
+
if (!isObject(pkg.pnpm))
|
|
42
|
+
return undefined;
|
|
43
|
+
const overrides = pkg.pnpm.overrides;
|
|
44
|
+
if (!isObject(overrides))
|
|
45
|
+
return undefined;
|
|
46
|
+
for (const value of Object.values(overrides)) {
|
|
47
|
+
if (typeof value !== 'string')
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return overrides;
|
|
42
51
|
}
|
|
43
|
-
export {
|
|
44
|
-
getPnpmOverrides,
|
|
45
|
-
readPackageJson
|
|
46
|
-
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { NmrConfig } from './config.
|
|
2
|
-
export { defineConfig } from './config.
|
|
3
|
-
export type { ResolvedContext } from './context.
|
|
1
|
+
export type { NmrConfig } from './config.js';
|
|
2
|
+
export { defineConfig } from './config.js';
|
|
3
|
+
export type { ResolvedContext } from './context.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ScriptRegistry } from './default-scripts.
|
|
2
|
-
export type { ScriptRegistry, ScriptValue } from './default-scripts.
|
|
1
|
+
import type { ScriptRegistry } from './default-scripts.js';
|
|
2
|
+
export type { ScriptRegistry, ScriptValue } from './default-scripts.js';
|
|
3
3
|
export declare function getDefaultWorkspaceScripts(useIntTests: boolean): ScriptRegistry;
|
|
4
4
|
export declare function getDefaultRootScripts(): ScriptRegistry;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { commonWorkspaceScripts, integrationTestScripts, rootScripts, standardTestScripts } from "./default-scripts.js";
|
|
2
|
-
function getDefaultWorkspaceScripts(useIntTests) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export function getDefaultWorkspaceScripts(useIntTests) {
|
|
3
|
+
return {
|
|
4
|
+
...commonWorkspaceScripts,
|
|
5
|
+
...(useIntTests ? integrationTestScripts : standardTestScripts),
|
|
6
|
+
};
|
|
7
7
|
}
|
|
8
|
-
function getDefaultRootScripts() {
|
|
9
|
-
|
|
8
|
+
export function getDefaultRootScripts() {
|
|
9
|
+
return { ...rootScripts };
|
|
10
10
|
}
|
|
11
|
-
export {
|
|
12
|
-
getDefaultRootScripts,
|
|
13
|
-
getDefaultWorkspaceScripts
|
|
14
|
-
};
|
package/dist/esm/resolver.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { NmrConfig } from './config.
|
|
2
|
-
import type { ScriptRegistry, ScriptValue } from './resolve-scripts.
|
|
1
|
+
import type { NmrConfig } from './config.js';
|
|
2
|
+
import type { ScriptRegistry, ScriptValue } from './resolve-scripts.js';
|
|
3
3
|
export declare function applyDevBin(command: string, devBin: Record<string, string> | undefined, monorepoRoot: string): string;
|
|
4
4
|
export interface ResolvedScript {
|
|
5
5
|
command: string;
|
|
@@ -8,6 +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;
|
|
11
12
|
export declare function buildWorkspaceRegistry(config: NmrConfig, useIntTests: boolean): ScriptRegistry;
|
|
12
13
|
export declare function buildRootRegistry(config: NmrConfig): ScriptRegistry;
|
|
13
14
|
export declare function isSelfReferential(script: string, commandName: string): boolean;
|
package/dist/esm/resolver.js
CHANGED
|
@@ -1,98 +1,100 @@
|
|
|
1
|
-
import { readFileSync } from
|
|
2
|
-
import path from
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
import { isObject } from "./helpers/type-guards.js";
|
|
4
4
|
import { getDefaultRootScripts, getDefaultWorkspaceScripts } from "./resolve-scripts.js";
|
|
5
|
-
function applyDevBin(command, devBin, monorepoRoot) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
export function applyDevBin(command, devBin, monorepoRoot) {
|
|
6
|
+
if (!devBin) {
|
|
7
|
+
return command;
|
|
8
|
+
}
|
|
9
|
+
const spaceIndex = command.indexOf(' ');
|
|
10
|
+
const firstToken = spaceIndex === -1 ? command : command.slice(0, spaceIndex);
|
|
11
|
+
const rest = spaceIndex === -1 ? '' : command.slice(spaceIndex);
|
|
12
|
+
const replacement = devBin[firstToken];
|
|
13
|
+
if (replacement === undefined) {
|
|
14
|
+
return command;
|
|
15
|
+
}
|
|
16
|
+
const resolvedReplacement = resolveReplacementPaths(replacement, monorepoRoot);
|
|
17
|
+
return resolvedReplacement + rest;
|
|
18
18
|
}
|
|
19
19
|
function resolveReplacementPaths(replacement, monorepoRoot) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const tokens = replacement.split(' ');
|
|
21
|
+
return tokens
|
|
22
|
+
.map((token, index) => {
|
|
23
|
+
if (index === 0)
|
|
24
|
+
return token;
|
|
25
|
+
if (token.startsWith('-'))
|
|
26
|
+
return token;
|
|
27
|
+
if (!token.includes('/'))
|
|
28
|
+
return token;
|
|
29
|
+
return path.resolve(monorepoRoot, token);
|
|
30
|
+
})
|
|
31
|
+
.join(' ');
|
|
27
32
|
}
|
|
28
|
-
function expandScript(script, workspaceRoot) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
export function expandScript(script, workspaceRoot) {
|
|
34
|
+
if (typeof script === 'string') {
|
|
35
|
+
return script;
|
|
36
|
+
}
|
|
37
|
+
const flag = workspaceRoot ? '-w ' : '';
|
|
38
|
+
return script.map((s) => `nmr ${flag}${s}`).join(' && ');
|
|
34
39
|
}
|
|
35
|
-
function describeScript(script) {
|
|
36
|
-
|
|
40
|
+
export function describeScript(script) {
|
|
41
|
+
return typeof script === 'string' ? script : `[${script.join(', ')}]`;
|
|
37
42
|
}
|
|
38
|
-
function readPackageJsonScripts(packageDir) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
export function readPackageJsonScripts(packageDir) {
|
|
44
|
+
try {
|
|
45
|
+
const raw = readFileSync(path.join(packageDir, 'package.json'), 'utf8');
|
|
46
|
+
const parsed = JSON.parse(raw);
|
|
47
|
+
if (!isObject(parsed))
|
|
48
|
+
return undefined;
|
|
49
|
+
const scripts = parsed.scripts;
|
|
50
|
+
if (!isObject(scripts))
|
|
51
|
+
return undefined;
|
|
52
|
+
const result = {};
|
|
53
|
+
for (const [key, val] of Object.entries(scripts)) {
|
|
54
|
+
if (typeof val === 'string')
|
|
55
|
+
result[key] = val;
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
48
58
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
53
64
|
}
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
65
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
...getDefaultWorkspaceScripts(useIntTests),
|
|
60
|
-
...config.workspaceScripts
|
|
61
|
-
};
|
|
66
|
+
export function hasIntegrationTestConfig(packageDir) {
|
|
67
|
+
return existsSync(path.join(packageDir, 'vitest.integration.config.ts'));
|
|
62
68
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
export function buildWorkspaceRegistry(config, useIntTests) {
|
|
70
|
+
return {
|
|
71
|
+
...getDefaultWorkspaceScripts(useIntTests),
|
|
72
|
+
...config.workspaceScripts,
|
|
73
|
+
};
|
|
68
74
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
export function buildRootRegistry(config) {
|
|
76
|
+
return {
|
|
77
|
+
...getDefaultRootScripts(),
|
|
78
|
+
...config.rootScripts,
|
|
79
|
+
};
|
|
72
80
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
export function isSelfReferential(script, commandName) {
|
|
82
|
+
const prefix = `nmr ${commandName}`;
|
|
83
|
+
return script === prefix || script.startsWith(`${prefix} `);
|
|
84
|
+
}
|
|
85
|
+
export function resolveScript(commandName, registry, packageDir, workspaceRoot) {
|
|
86
|
+
if (packageDir) {
|
|
87
|
+
const pkgScripts = readPackageJsonScripts(packageDir);
|
|
88
|
+
if (pkgScripts && commandName in pkgScripts) {
|
|
89
|
+
const override = pkgScripts[commandName];
|
|
90
|
+
if (override !== undefined && !isSelfReferential(override, commandName)) {
|
|
91
|
+
return { command: override, source: 'package' };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const registryEntry = registry[commandName];
|
|
96
|
+
if (registryEntry === undefined) {
|
|
97
|
+
return undefined;
|
|
81
98
|
}
|
|
82
|
-
|
|
83
|
-
const registryEntry = registry[commandName];
|
|
84
|
-
if (registryEntry === void 0) {
|
|
85
|
-
return void 0;
|
|
86
|
-
}
|
|
87
|
-
return { command: expandScript(registryEntry, workspaceRoot), source: "default" };
|
|
99
|
+
return { command: expandScript(registryEntry, workspaceRoot), source: 'default' };
|
|
88
100
|
}
|
|
89
|
-
export {
|
|
90
|
-
applyDevBin,
|
|
91
|
-
buildRootRegistry,
|
|
92
|
-
buildWorkspaceRegistry,
|
|
93
|
-
describeScript,
|
|
94
|
-
expandScript,
|
|
95
|
-
isSelfReferential,
|
|
96
|
-
readPackageJsonScripts,
|
|
97
|
-
resolveScript
|
|
98
|
-
};
|