rman 2.27.2 → 2.29.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/builtins/platforms/node/node-dependency-updater.d.ts +7 -0
- package/builtins/platforms/node/node-dependency-updater.js +32 -1
- package/commands/deps.command.js +49 -16
- package/constants.js +1 -1
- package/core/interfaces/dependency-updater.d.ts +12 -1
- package/core/interfaces/run-step.d.ts +6 -0
- package/package.json +1 -1
- package/services/run.service.d.ts +4 -1
- package/services/run.service.js +43 -12
|
@@ -26,6 +26,11 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
|
|
|
26
26
|
* Another package manager is not asked - its dry run is not the same question - and a note says so.
|
|
27
27
|
*/
|
|
28
28
|
verify(ctx: DependencyUpdater.Context): Promise<string | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* The upgrades an `ERESOLVE` names at the version they move to - the one under `Could not resolve
|
|
31
|
+
* dependency:` when it is one of them, else every one the output mentions.
|
|
32
|
+
*/
|
|
33
|
+
blame(refusal: string, plan: readonly DependencyUpdater.Entry[]): DependencyUpdater.Blame[];
|
|
29
34
|
/** One decision per dependency name `pkg` declares, whether or not it may move - one that may not
|
|
30
35
|
* still states rules the others have to keep. */
|
|
31
36
|
protected collect(pkg: Package, settings: DependencyUpdater.Settings, options: DependencyUpdater.Options, inRepo: ReadonlySet<string>): NodeDependencyUpdater.Decision[];
|
|
@@ -86,6 +91,8 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
|
|
|
86
91
|
* move. */
|
|
87
92
|
protected resolvedDeclared(d: NodeDependencyUpdater.Decision): string | undefined;
|
|
88
93
|
/** What `d` declares in `field` once it has moved. */
|
|
94
|
+
/** Whether `line` names `token` (`name@version`) whole - not `1.2.3` inside `1.2.30`. */
|
|
95
|
+
protected mentions(line: string, token: string): boolean;
|
|
89
96
|
protected rangeFor(d: NodeDependencyUpdater.Decision, field: string): string;
|
|
90
97
|
/** The in-repo packages `pkg` declares a dependency on. */
|
|
91
98
|
protected siblingsOf(pkg: Package, repoPackages: ReadonlyMap<string, Package>): Package[];
|
|
@@ -131,7 +131,33 @@ export class NodeDependencyUpdater {
|
|
|
131
131
|
.filter(line => /^npm (error|ERR!)/.test(line) && !/complete log|_logs/.test(line))
|
|
132
132
|
.map(line => line.replace(/^npm (error|ERR!)\s?/, ' '))
|
|
133
133
|
.filter(line => line.trim());
|
|
134
|
-
return lines.
|
|
134
|
+
return lines.join('\n') || ` npm install --dry-run exited ${result.code}`;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The upgrades an `ERESOLVE` names at the version they move to - the one under `Could not resolve
|
|
138
|
+
* dependency:` when it is one of them, else every one the output mentions.
|
|
139
|
+
*/
|
|
140
|
+
/* **The version is what makes the name evidence.** `@hookform/resolvers@6.0.0` appears in the
|
|
141
|
+
* output only because this run moved it there; the name alone also appears on every line about the
|
|
142
|
+
* tree around it. The `Could not resolve dependency:` line is npm's own verdict - measured on the
|
|
143
|
+
* `@hookform/resolvers` case it reads `peerOptional effect@"^4.0.0" from @hookform/resolvers@6.0.0`
|
|
144
|
+
* - so a move it names is the one to hold, and the others it merely passes through stay. That line
|
|
145
|
+
* sat past the 20 lines `verify` used to keep, which is why it now keeps them all. */
|
|
146
|
+
blame(refusal, plan) {
|
|
147
|
+
const moves = plan.flatMap(entry => {
|
|
148
|
+
const d = this.planned.get(entry);
|
|
149
|
+
return entry.status === 'update' && d ? [{ entry, token: `${d.name}@${d.candidates[d.index]}` }] : [];
|
|
150
|
+
});
|
|
151
|
+
const lines = refusal.split('\n').map(line => line.trim());
|
|
152
|
+
const at = lines.indexOf('Could not resolve dependency:');
|
|
153
|
+
const verdict = at >= 0 ? lines.slice(at + 1).find(Boolean) : undefined;
|
|
154
|
+
const named = verdict ? moves.filter(m => this.mentions(verdict, m.token)) : [];
|
|
155
|
+
if (named.length)
|
|
156
|
+
return named.map(m => ({ entry: m.entry, reason: `npm cannot install it: ${verdict}` }));
|
|
157
|
+
return moves.flatMap(m => {
|
|
158
|
+
const line = lines.find(l => this.mentions(l, m.token));
|
|
159
|
+
return line ? [{ entry: m.entry, reason: `npm cannot install it: ${verdict ?? line}` }] : [];
|
|
160
|
+
});
|
|
135
161
|
}
|
|
136
162
|
/** One decision per dependency name `pkg` declares, whether or not it may move - one that may not
|
|
137
163
|
* still states rules the others have to keep. */
|
|
@@ -455,6 +481,11 @@ export class NodeDependencyUpdater {
|
|
|
455
481
|
.sort(semver.rcompare)[0];
|
|
456
482
|
}
|
|
457
483
|
/** What `d` declares in `field` once it has moved. */
|
|
484
|
+
/** Whether `line` names `token` (`name@version`) whole - not `1.2.3` inside `1.2.30`. */
|
|
485
|
+
mentions(line, token) {
|
|
486
|
+
const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
487
|
+
return new RegExp(`(^|[\\s"'(])${escaped}(?![\\w.+-])`).test(line);
|
|
488
|
+
}
|
|
458
489
|
rangeFor(d, field) {
|
|
459
490
|
const declared = d.fields.get(field) ?? '';
|
|
460
491
|
if (d.index < 0 || !d.movable.includes(field))
|
package/commands/deps.command.js
CHANGED
|
@@ -115,10 +115,11 @@ const depsCommand = registerCommand(app => {
|
|
|
115
115
|
for (const [updater, packages] of byUpdater)
|
|
116
116
|
plans.set(updater, await updater.getPlan(ctx, packages));
|
|
117
117
|
const all = [...plans.values()].flat();
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
else
|
|
118
|
+
/** Under `-u --json` the document waits for the resolver, so it holds what was really written. */
|
|
119
|
+
if (!args.json)
|
|
121
120
|
printPlan(all, repository.dirname);
|
|
121
|
+
else if (!args.upgrade)
|
|
122
|
+
console.log(JSON.stringify(jsonPlan(all), undefined, 2));
|
|
122
123
|
const errors = all.filter(e => e.status === 'error');
|
|
123
124
|
const updates = all.filter(e => e.status === 'update');
|
|
124
125
|
if (!args.upgrade) {
|
|
@@ -128,23 +129,55 @@ const depsCommand = registerCommand(app => {
|
|
|
128
129
|
throw logged(`${errors.length} dependency lookup(s) failed - see above.`);
|
|
129
130
|
return;
|
|
130
131
|
}
|
|
131
|
-
const applied =
|
|
132
|
-
|
|
132
|
+
const applied = new Map();
|
|
133
|
+
const apply = async (updater, plan) => {
|
|
133
134
|
if (plan.some(e => e.status === 'update'))
|
|
134
|
-
applied.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
applied.set(updater, await updater.applyPlan(ctx, plan));
|
|
136
|
+
else
|
|
137
|
+
applied.delete(updater);
|
|
138
|
+
};
|
|
139
|
+
for (const [updater, plan] of plans)
|
|
140
|
+
await apply(updater, plan);
|
|
141
|
+
/* A refusal the updater can pin on some of the moves holds those back and asks again with the
|
|
142
|
+
* rest - each round holds at least one, so it ends. One it cannot pin puts everything back. */
|
|
143
|
+
const held = [];
|
|
144
|
+
if (applied.size && args.verify !== false) {
|
|
138
145
|
for (const [updater, packages] of byUpdater) {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
const plan = plans.get(updater);
|
|
147
|
+
while (applied.has(updater)) {
|
|
148
|
+
const refused = await updater.verify?.(ctx, packages);
|
|
149
|
+
if (!refused)
|
|
150
|
+
break;
|
|
151
|
+
const blamed = updater.blame?.(refused, plan).filter(b => b.entry.status === 'update') ?? [];
|
|
152
|
+
applied.get(updater).restore();
|
|
153
|
+
applied.delete(updater);
|
|
154
|
+
if (!blamed.length) {
|
|
155
|
+
for (const a of applied.values())
|
|
156
|
+
a.restore();
|
|
157
|
+
const shown = refused.split('\n');
|
|
158
|
+
const text = shown.slice(0, 40).join('\n') + (shown.length > 40 ? '\n ...' : '');
|
|
159
|
+
throw logged(`The upgraded manifests do not install, so they were put back:\n${text}`);
|
|
160
|
+
}
|
|
161
|
+
for (const b of blamed) {
|
|
162
|
+
Object.assign(b.entry, { status: 'held', target: undefined, bump: undefined, reason: b.reason });
|
|
163
|
+
held.push(b);
|
|
164
|
+
}
|
|
165
|
+
await apply(updater, plan);
|
|
166
|
+
}
|
|
145
167
|
}
|
|
146
168
|
}
|
|
147
|
-
|
|
169
|
+
const files = [...applied.values()].flatMap(a => a.files);
|
|
170
|
+
if (args.json)
|
|
171
|
+
console.log(JSON.stringify(jsonPlan(all), undefined, 2));
|
|
172
|
+
else {
|
|
173
|
+
if (held.length) {
|
|
174
|
+
console.log(colors.yellow('\nHeld back - the resolver refused them:'));
|
|
175
|
+
for (const { entry, reason } of held) {
|
|
176
|
+
console.log(` ${colors.cyan(entry.package.name)} ${entry.name} ${entry.current} ${colors.gray(reason)}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (held.length && !files.length)
|
|
180
|
+
console.log(colors.yellow('Nothing upgraded.'));
|
|
148
181
|
for (const file of files)
|
|
149
182
|
console.log(colors.green('updated'), path.relative(repository.dirname, file));
|
|
150
183
|
}
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.29.0';
|
|
@@ -20,6 +20,12 @@ export interface DependencyUpdater {
|
|
|
20
20
|
* Omit it when the ecosystem has no resolver to ask; the plan's own checks then stand alone.
|
|
21
21
|
*/
|
|
22
22
|
verify?(ctx: DependencyUpdater.Context, packages: readonly Package[]): Promise<string | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* The `'update'` entries of `plan` that `refusal` - what `verify` returned - is about, each with
|
|
25
|
+
* the reason to show for it. The command holds those back and tries the rest again; an empty
|
|
26
|
+
* answer, or none at all, puts every write back.
|
|
27
|
+
*/
|
|
28
|
+
blame?(refusal: string, plan: readonly DependencyUpdater.Entry[]): DependencyUpdater.Blame[];
|
|
23
29
|
}
|
|
24
30
|
export declare namespace DependencyUpdater {
|
|
25
31
|
/** What one call is handed. */
|
|
@@ -62,7 +68,7 @@ export declare namespace DependencyUpdater {
|
|
|
62
68
|
*
|
|
63
69
|
* - `'update'`: `target` is the new range; `reason` says why it is lower than `latest`, if it is.
|
|
64
70
|
* - `'held'`: a newer version exists and is allowed, but another dependency's rule refuses it -
|
|
65
|
-
* `reason` names that rule.
|
|
71
|
+
* `reason` names that rule - or, under `--upgrade`, the ecosystem's resolver refused it.
|
|
66
72
|
* - `'skipped'`: a newer version exists, and the package's own settings leave it out - a major
|
|
67
73
|
* under `target: minor`, or one younger than `minAge`. `reason` says which.
|
|
68
74
|
* - `'up-to-date'`: nothing newer exists.
|
|
@@ -97,6 +103,11 @@ export declare namespace DependencyUpdater {
|
|
|
97
103
|
bump?: string;
|
|
98
104
|
reason?: string;
|
|
99
105
|
}
|
|
106
|
+
/** One entry a resolver's refusal is about, and the reason to show for it. */
|
|
107
|
+
interface Blame {
|
|
108
|
+
entry: Entry;
|
|
109
|
+
reason: string;
|
|
110
|
+
}
|
|
100
111
|
/** What `applyPlan` wrote. */
|
|
101
112
|
interface Applied {
|
|
102
113
|
/** Every file it changed, absolute. */
|
|
@@ -57,6 +57,12 @@ export interface RunStepContext {
|
|
|
57
57
|
* always covers the repository.
|
|
58
58
|
*/
|
|
59
59
|
scopedTo?: Package;
|
|
60
|
+
/**
|
|
61
|
+
* The `vars` this step's slot sees - what a `${{ vars.x }}` written in the same place resolves
|
|
62
|
+
* to: the top-level `vars`, then each `vars` block on the way down to the script (`run.vars`,
|
|
63
|
+
* `run.<script>.vars`, or `version.vars` in a version hook), merged per key, closest last.
|
|
64
|
+
*/
|
|
65
|
+
vars: Record<string, unknown>;
|
|
60
66
|
/**
|
|
61
67
|
* The repository's locally installed binaries, already carrying this run's `cwd` and log level -
|
|
62
68
|
* handed over rather than imported, for the reason `CommandContext.runBin` is.
|
package/package.json
CHANGED
|
@@ -162,6 +162,9 @@ export declare namespace RunService {
|
|
|
162
162
|
cwd: string;
|
|
163
163
|
/** The package the run was narrowed to by the directory it started in - `RunStepContext.scopedTo`. */
|
|
164
164
|
scopedTo?: Package;
|
|
165
|
+
/** Where this script sits in the config (`['run', 'build']`) - what `RunStepContext.vars` is
|
|
166
|
+
* scoped to. Unset for a run with no script of its own, whose steps see the top-level `vars`. */
|
|
167
|
+
at?: readonly string[];
|
|
165
168
|
topo: boolean;
|
|
166
169
|
bail: boolean;
|
|
167
170
|
logLevel: LogLevel;
|
|
@@ -310,7 +313,7 @@ export declare namespace RunService {
|
|
|
310
313
|
* `onCommand` is told what the step is spawning, for as long as it runs - the argv while a child
|
|
311
314
|
* is up, `undefined` when it returns.
|
|
312
315
|
*/
|
|
313
|
-
export function createStepContext(pkg: Package, cwd: string, onCommand?: (command: string | undefined) => void, onLine?: (line: string, stream?: 'stdout' | 'stderr') => void, scopedTo?: Package): RunStepContext;
|
|
316
|
+
export function createStepContext(pkg: Package, cwd: string, onCommand?: (command: string | undefined) => void, onLine?: (line: string, stream?: 'stdout' | 'stderr') => void, scopedTo?: Package, at?: readonly string[]): RunStepContext;
|
|
314
317
|
/**
|
|
315
318
|
* `.rmanrc` conditional execution, GitHub Actions-`if`-flavored but a small closed grammar
|
|
316
319
|
* instead of a full expression language (less to get wrong, still covers what's asked for) -
|
package/services/run.service.js
CHANGED
|
@@ -60,7 +60,10 @@ export class RunService extends Service {
|
|
|
60
60
|
const rootSkipped = !!cwdScope ||
|
|
61
61
|
!repository.monorepo ||
|
|
62
62
|
rootCfg.skip === true ||
|
|
63
|
-
!(await passesIf(repository, repository.rootPackage, rootCfg.if, repository.dirname, ifStatusCache, cwdScope
|
|
63
|
+
!(await passesIf(repository, repository.rootPackage, rootCfg.if, repository.dirname, ifStatusCache, cwdScope, [
|
|
64
|
+
'run',
|
|
65
|
+
script,
|
|
66
|
+
]));
|
|
64
67
|
const rootSteps = rootSkipped ? [] : getScriptSteps(repository.rootPackage, script);
|
|
65
68
|
/** Filtered on the slot, not on `'pre' + script`: the step labels are `before`/`exec`/`after`
|
|
66
69
|
* now - the same words the config uses - rather than npm's `pre<script>` naming, which moved
|
|
@@ -76,6 +79,7 @@ export class RunService extends Service {
|
|
|
76
79
|
steps,
|
|
77
80
|
cwd: repository.dirname,
|
|
78
81
|
scopedTo: cwdScope,
|
|
82
|
+
at: ['run', script],
|
|
79
83
|
topo: false,
|
|
80
84
|
bail: resolveBail(options.bail, repository.rootPackage, script, true),
|
|
81
85
|
logLevel: resolveLogLevel(options.logLevel, repository.rootPackage, script, logLevelDefault),
|
|
@@ -88,7 +92,7 @@ export class RunService extends Service {
|
|
|
88
92
|
const pkgCfg = RunService.getConfig(pkg, script);
|
|
89
93
|
if (pkgCfg.skip === true)
|
|
90
94
|
continue;
|
|
91
|
-
if (!(await passesIf(repository, pkg, pkgCfg.if, pkg.dirname, ifStatusCache, cwdScope)))
|
|
95
|
+
if (!(await passesIf(repository, pkg, pkgCfg.if, pkg.dirname, ifStatusCache, cwdScope, ['run', script])))
|
|
92
96
|
continue;
|
|
93
97
|
const steps = getScriptSteps(pkg, script);
|
|
94
98
|
if (!steps.length)
|
|
@@ -100,6 +104,7 @@ export class RunService extends Service {
|
|
|
100
104
|
steps,
|
|
101
105
|
cwd: pkg.dirname,
|
|
102
106
|
scopedTo: cwdScope,
|
|
107
|
+
at: ['run', script],
|
|
103
108
|
topo: resolveBool(options.topo, pkg, script, 'topo', topo),
|
|
104
109
|
bail: resolveBail(options.bail, pkg, script, true),
|
|
105
110
|
logLevel: resolveLogLevel(options.logLevel, pkg, script, logLevelDefault),
|
|
@@ -174,7 +179,7 @@ export class RunService extends Service {
|
|
|
174
179
|
* one must not mark the package finished.
|
|
175
180
|
*/
|
|
176
181
|
part) => {
|
|
177
|
-
const { pkg, cwd, bail: pkgBail, logLevel: pkgLogLevel, label: pkgLabel, scopedTo } = plan;
|
|
182
|
+
const { pkg, cwd, bail: pkgBail, logLevel: pkgLogLevel, label: pkgLabel, scopedTo, at } = plan;
|
|
178
183
|
const from = part?.from ?? 0;
|
|
179
184
|
/** Only the first part starts the clock: the row's elapsed time is the package's, and a
|
|
180
185
|
* package waiting at a `topo` barrier is waiting as part of its own run. */
|
|
@@ -188,7 +193,8 @@ export class RunService extends Service {
|
|
|
188
193
|
/** Asked when the step's turn comes, not when the plan is made - a condition may read
|
|
189
194
|
* what the steps before it left behind. A step that says no is passed over in silence:
|
|
190
195
|
* it is not a failure, and announcing it on every package would bury the steps that ran. */
|
|
191
|
-
if (step.if !== undefined &&
|
|
196
|
+
if (step.if !== undefined &&
|
|
197
|
+
!(await passesIf(pkg.repository, pkg, step.if, cwd, stepIfCache, scopedTo, at))) {
|
|
192
198
|
continue;
|
|
193
199
|
}
|
|
194
200
|
ctx.currentStep = step.name;
|
|
@@ -227,7 +233,7 @@ export class RunService extends Service {
|
|
|
227
233
|
* run step should.
|
|
228
234
|
*/
|
|
229
235
|
if (step.run)
|
|
230
|
-
await runFunctionStep(step.run, pkg, cwd, onLine, onCommand, scopedTo);
|
|
236
|
+
await runFunctionStep(step.run, pkg, cwd, onLine, onCommand, scopedTo, at);
|
|
231
237
|
else {
|
|
232
238
|
await exec(step.command, {
|
|
233
239
|
cwd,
|
|
@@ -593,10 +599,12 @@ export class RunService extends Service {
|
|
|
593
599
|
* (`{ command }` / `{ run }`) reaches here too and only one place knows the three spellings.
|
|
594
600
|
* `topo` cannot be set on this path - `normalizeScriptValue` refuses it for a version hook. */
|
|
595
601
|
const step = toStep(slot, value);
|
|
596
|
-
if (step.if !== undefined &&
|
|
602
|
+
if (step.if !== undefined &&
|
|
603
|
+
!(await passesIf(pkg.repository, pkg, step.if, pkg.dirname, new Map(), undefined, [script]))) {
|
|
597
604
|
continue;
|
|
605
|
+
}
|
|
598
606
|
if (step.run) {
|
|
599
|
-
await step.run(createStepContext(pkg, pkg.dirname));
|
|
607
|
+
await step.run(createStepContext(pkg, pkg.dirname, undefined, undefined, undefined, [script]));
|
|
600
608
|
continue;
|
|
601
609
|
}
|
|
602
610
|
await exec(step.command, { cwd: pkg.dirname, stdio: 'inherit', app: pkg.repository.app });
|
|
@@ -732,13 +740,14 @@ export class RunService extends Service {
|
|
|
732
740
|
* whole of a build, because that is all the slot knows; what a reader wants is the `tsc -b
|
|
733
741
|
* <tsconfig>` it is sitting in. A function step is the shape every shared config uses, so this is
|
|
734
742
|
* the common case rather than an edge one. */
|
|
735
|
-
function createStepContext(pkg, cwd, onCommand, onLine, scopedTo) {
|
|
743
|
+
function createStepContext(pkg, cwd, onCommand, onLine, scopedTo, at = []) {
|
|
736
744
|
const logLevel = resolveRootLogLevel(pkg.repository);
|
|
737
745
|
return {
|
|
738
746
|
pkg,
|
|
739
747
|
repository: pkg.repository,
|
|
740
748
|
cwd,
|
|
741
749
|
scopedTo,
|
|
750
|
+
vars: scopedVars(pkg, at),
|
|
742
751
|
runBin: async (bin, argv, opts) => {
|
|
743
752
|
onCommand?.([bin, ...argv].join(' '));
|
|
744
753
|
const result = await runBin(bin, argv, { cwd, logLevel, app: pkg.repository.app, onLine, ...opts });
|
|
@@ -919,8 +928,8 @@ const STEP_OBJECT_KEYS = ['command', 'topo', 'if'];
|
|
|
919
928
|
* nowhere at all. Written to `onLine` on stderr, ahead of the step's `end` - the order a shell step
|
|
920
929
|
* already produces.
|
|
921
930
|
*/
|
|
922
|
-
async function runFunctionStep(run, pkg, cwd, onLine, onCommand, scopedTo) {
|
|
923
|
-
const context = RunService.createStepContext(pkg, cwd, onCommand, onLine, scopedTo);
|
|
931
|
+
async function runFunctionStep(run, pkg, cwd, onLine, onCommand, scopedTo, at = []) {
|
|
932
|
+
const context = RunService.createStepContext(pkg, cwd, onCommand, onLine, scopedTo, at);
|
|
924
933
|
try {
|
|
925
934
|
await RunService.withCapturedConsole(onLine, () => run(context));
|
|
926
935
|
}
|
|
@@ -952,9 +961,9 @@ function format(args) {
|
|
|
952
961
|
* not a string, which the caller reads as "no condition given", so a function reaching it would be
|
|
953
962
|
* a condition that silently always passed.
|
|
954
963
|
*/
|
|
955
|
-
async function passesIf(repository, pkg, raw, cwd, statusCache, scopedTo) {
|
|
964
|
+
async function passesIf(repository, pkg, raw, cwd, statusCache, scopedTo, at = []) {
|
|
956
965
|
if (typeof raw === 'function') {
|
|
957
|
-
return !!(await raw(RunService.createStepContext(pkg, cwd, undefined, undefined, scopedTo)));
|
|
966
|
+
return !!(await raw(RunService.createStepContext(pkg, cwd, undefined, undefined, scopedTo, at)));
|
|
958
967
|
}
|
|
959
968
|
const node = RunService.parseIfExpr(raw);
|
|
960
969
|
return node ? RunService.evaluateIf(repository, pkg, node, statusCache) : true;
|
|
@@ -1167,3 +1176,25 @@ export function resolveLogLevel(cliValue, pkg, script, fallback) {
|
|
|
1167
1176
|
const v = RunService.getConfig(pkg, script).logLevel;
|
|
1168
1177
|
return typeof v === 'string' && LOG_LEVELS.includes(v) ? v : fallback;
|
|
1169
1178
|
}
|
|
1179
|
+
/**
|
|
1180
|
+
* The `vars` a step at config path `at` (`['run', 'build']`) sees: the top-level block, then each
|
|
1181
|
+
* one on the way down, merged per key with the closest last - the scope `${{ vars }}` has there.
|
|
1182
|
+
*/
|
|
1183
|
+
/* **A function step could not see a scoped `vars` at all**, while a shell step in the same slot
|
|
1184
|
+
* could: `@panates/rman-preset` moved `copyFiles` into `run.build.vars`, its `${{ vars.copyFiles }}`
|
|
1185
|
+
* would have resolved, and its `after` function - reading `pkg.config.vars` - found nothing, so
|
|
1186
|
+
* README and LICENSE stopped reaching the build directory. `pkg.config` keeps every `vars` block it
|
|
1187
|
+
* resolved, so this reads them back rather than repeating the interpolator's walk. */
|
|
1188
|
+
function scopedVars(pkg, at) {
|
|
1189
|
+
const blockOf = (node) => {
|
|
1190
|
+
const vars = node && typeof node === 'object' ? node.vars : undefined;
|
|
1191
|
+
return vars && typeof vars === 'object' ? vars : {};
|
|
1192
|
+
};
|
|
1193
|
+
let node = pkg.config;
|
|
1194
|
+
let vars = { ...blockOf(node) };
|
|
1195
|
+
for (const key of at) {
|
|
1196
|
+
node = node && typeof node === 'object' ? node[key] : undefined;
|
|
1197
|
+
vars = { ...vars, ...blockOf(node) };
|
|
1198
|
+
}
|
|
1199
|
+
return vars;
|
|
1200
|
+
}
|