@nu-art/build-and-install 0.300.6 → 0.300.7
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/package.json
CHANGED
package/v2/phase/consts.js
CHANGED
|
@@ -58,6 +58,7 @@ exports.phase_Purge = {
|
|
|
58
58
|
exports.phaseKey_CopyPackageJSON = 'copy-package-json';
|
|
59
59
|
exports.phase_CopyPackageJSON = {
|
|
60
60
|
key: exports.phaseKey_CopyPackageJSON,
|
|
61
|
+
unitFilter: (unit) => 'copyPackageJson' in unit,
|
|
61
62
|
name: 'Copy Package JSON',
|
|
62
63
|
method: 'copyPackageJson',
|
|
63
64
|
};
|
|
@@ -22,16 +22,17 @@ export declare class PhaseRunner extends BaseUnit implements UnitPhaseImplemento
|
|
|
22
22
|
private defaultFileRoutes;
|
|
23
23
|
constructor(projectPath: RelativePath);
|
|
24
24
|
protected init(): Promise<void>;
|
|
25
|
-
private filterUnits;
|
|
26
25
|
private loadProject;
|
|
27
26
|
private prepareProjectParams;
|
|
28
27
|
private prepareDefaultFileRouts;
|
|
29
28
|
private buildUnitDependencyTree;
|
|
30
29
|
private phaseFilters;
|
|
31
30
|
private executeImpl;
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
executePhase<P extends Phase<string>>(phase: P, unit: BaseUnit, index: number): Promise<void>;
|
|
32
|
+
private executePhaseImpl;
|
|
33
|
+
private executePhaseDryRun;
|
|
34
34
|
private willUnitRunForPhase;
|
|
35
|
+
registerUnits(units: BaseUnit | BaseUnit[]): void;
|
|
35
36
|
getUnits(): BaseUnit<import("../unit/core").BaseUnit_Config, import("../unit/core").BaseUnit_RuntimeConfig>[];
|
|
36
37
|
/**
|
|
37
38
|
* Will add a phase to the start of the phase array.
|
|
@@ -72,14 +72,18 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
this.willUnitRunForPhase = async (phase, unit) => {
|
|
75
|
-
|
|
76
|
-
if ((0, ts_common_1.exists)(unit.config.filter) && !unit.config.filter())
|
|
77
|
-
return false;
|
|
75
|
+
var _a, _b;
|
|
78
76
|
// Unit doesn't implement the phase method
|
|
79
77
|
if (!(0, ts_common_1.exists)(unit[phase.method]))
|
|
80
78
|
return false;
|
|
81
|
-
// If phase implements unit filter
|
|
82
|
-
if ((0, ts_common_1.exists)(phase.unitFilter)
|
|
79
|
+
// If phase implements unit filter whether unit doesn't pass
|
|
80
|
+
if ((0, ts_common_1.exists)(phase.unitFilter))
|
|
81
|
+
return (await phase.unitFilter(unit));
|
|
82
|
+
// Runtime input is stronger than the unit default filter
|
|
83
|
+
if (params_1.RuntimeParams.usePackage)
|
|
84
|
+
return (((_a = params_1.RuntimeParams.usePackage) === null || _a === void 0 ? void 0 : _a.includes(unit.config.key)) || ((_b = params_1.RuntimeParams.usePackage) === null || _b === void 0 ? void 0 : _b.includes(unit.config.label)));
|
|
85
|
+
// Unit filter itself
|
|
86
|
+
if ((0, ts_common_1.exists)(unit.config.filter) && !await unit.config.filter())
|
|
83
87
|
return false;
|
|
84
88
|
return true;
|
|
85
89
|
};
|
|
@@ -123,7 +127,7 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
123
127
|
//Load project for use in the phase runner
|
|
124
128
|
(_a = this.projectConfig) !== null && _a !== void 0 ? _a : (this.projectConfig = await this.loadProject());
|
|
125
129
|
//Filter specific units
|
|
126
|
-
this.filterUnits();
|
|
130
|
+
// this.filterUnits();
|
|
127
131
|
this.logDebug('Runtime params:', params_1.RuntimeParams);
|
|
128
132
|
//Set runner params
|
|
129
133
|
//Set Project Params
|
|
@@ -142,22 +146,25 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
142
146
|
return unit.init();
|
|
143
147
|
}));
|
|
144
148
|
}
|
|
145
|
-
filterUnits() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
149
|
+
// private filterUnits() {
|
|
150
|
+
// const useUnits = RuntimeParams.usePackage;
|
|
151
|
+
// if (!useUnits || !useUnits.length)
|
|
152
|
+
// return;
|
|
153
|
+
//
|
|
154
|
+
// const unitsToRemove: BaseUnit[] = [];
|
|
155
|
+
// for (const unit of this.units) {
|
|
156
|
+
// if (unit === this)
|
|
157
|
+
// continue;
|
|
158
|
+
//
|
|
159
|
+
// if (!useUnits.includes(unit.config.key))
|
|
160
|
+
// unitsToRemove.push(unit);
|
|
161
|
+
// }
|
|
162
|
+
//
|
|
163
|
+
// if (!unitsToRemove.length)
|
|
164
|
+
// return;
|
|
165
|
+
//
|
|
166
|
+
// unitsToRemove.forEach(unit => removeItemFromArray(this.units, unit));
|
|
167
|
+
// }
|
|
161
168
|
async loadProject() {
|
|
162
169
|
if (!fs_1.default.existsSync(this.projectPath))
|
|
163
170
|
throw new ts_common_1.ImplementationMissingException(`Missing project config file, could not find in path: ${this.projectPath}`);
|
|
@@ -244,7 +251,7 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
244
251
|
continue;
|
|
245
252
|
}
|
|
246
253
|
lastPhase = phase;
|
|
247
|
-
this.
|
|
254
|
+
this.logVerbose(`Will execute phase: ${phase.name}`);
|
|
248
255
|
if (phase.breakPhases) {
|
|
249
256
|
phasesBlocks.push(phasesBlock);
|
|
250
257
|
phasesBlocks.push([phase]);
|
|
@@ -263,23 +270,33 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
263
270
|
if (params_1.RuntimeParams.debug)
|
|
264
271
|
this.logDebug('phasesBlock: ', phasesBlock);
|
|
265
272
|
const executionQueue = phasesBlocks.map((_phasesBlock, index) => {
|
|
273
|
+
this.logDebug(`Executing phases #${index}: ${_phasesBlock.map(p => p.name).join(', ')}`);
|
|
266
274
|
return async () => {
|
|
267
275
|
return (0, ts_common_1.Promise_all_sequentially)(this.unitDependencyTree.map(unitGroup => () => {
|
|
268
|
-
return Promise.all(unitGroup.map(unit => (0, ts_common_1.Promise_all_sequentially)(_phasesBlock.map(phase => () => this.
|
|
276
|
+
return Promise.all(unitGroup.map(unit => (0, ts_common_1.Promise_all_sequentially)(_phasesBlock.map(phase => () => this.executePhase(phase, unit, index)))));
|
|
269
277
|
}));
|
|
270
278
|
};
|
|
271
279
|
});
|
|
272
280
|
await (0, ts_common_1.Promise_all_sequentially)(executionQueue);
|
|
273
281
|
this.killed = false;
|
|
274
282
|
}
|
|
275
|
-
async
|
|
276
|
-
var _a, _b;
|
|
283
|
+
async executePhase(phase, unit, index) {
|
|
277
284
|
if (!params_1.RuntimeParams.dryRun)
|
|
278
|
-
return (
|
|
285
|
+
return this.executePhaseImpl(phase, unit, index);
|
|
286
|
+
return this.executePhaseDryRun(phase, unit, index);
|
|
287
|
+
}
|
|
288
|
+
async executePhaseImpl(phase, unit, index) {
|
|
289
|
+
var _a, _b;
|
|
290
|
+
if (!await this.willUnitRunForPhase(phase, unit))
|
|
291
|
+
return;
|
|
292
|
+
unit.logDebug(`Running phase #${index}: ${phase.name}`);
|
|
293
|
+
return (_b = (_a = unit)[phase.method]) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
294
|
+
}
|
|
295
|
+
async executePhaseDryRun(phase, unit, index) {
|
|
279
296
|
if (!(await this.willUnitRunForPhase(phase, unit)))
|
|
280
297
|
unit.logWarning(`will NOT run phase #${index}: ${phase.name}`);
|
|
281
298
|
else
|
|
282
|
-
unit.logWarning(`
|
|
299
|
+
unit.logWarning(`Running phase #${index}: ${phase.name}`);
|
|
283
300
|
}
|
|
284
301
|
//######################### Unit Logic #########################
|
|
285
302
|
registerUnits(units) {
|
|
@@ -296,12 +313,6 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
296
313
|
});
|
|
297
314
|
PhaseRunnerDispatcher_1.dispatcher_UnitChange.dispatch(this.units);
|
|
298
315
|
}
|
|
299
|
-
// private async getUnitsForPhase<P extends Phase<string>>(phase: P) {
|
|
300
|
-
// return filterInstances(await Promise.all(this.unitDependencyTree.map(async row => {
|
|
301
|
-
// const filteredRow = await Promise.all(row.filter((unit) => this.willUnitRunForPhase(phase, unit)));
|
|
302
|
-
// return filterInstances(filteredRow);
|
|
303
|
-
// })).then(rows => rows.filter(row => row.length)));
|
|
304
|
-
// }
|
|
305
316
|
getUnits() {
|
|
306
317
|
return this.units;
|
|
307
318
|
}
|
|
@@ -449,10 +460,10 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
449
460
|
this.logDebug('Runner Params:', RunnerParams_1.MemKey_RunnerParams.get());
|
|
450
461
|
this.logDebug('Project Config:', RunnerParams_1.MemKey_ProjectConfig.get());
|
|
451
462
|
this.logDebug('Default File Routes:', consts_1.MemKey_DefaultFiles.get());
|
|
463
|
+
this.logDebug('All Phases:', this.phases.map(phase => phase.name));
|
|
452
464
|
this.logDebug('Filtered Units:', this.units.map(unit => unit.config.label));
|
|
453
465
|
const dependencyTree = this.unitDependencyTree.map(row => row.map(unit => unit.config.label));
|
|
454
466
|
this.logInfo('Unit Dependencies Tree:', dependencyTree);
|
|
455
|
-
this.logInfo('Phases:', this.phases.map(phase => phase.name));
|
|
456
467
|
if (params_1.RuntimeParams.debugLifecycle)
|
|
457
468
|
process.exit(0);
|
|
458
469
|
}
|