@nu-art/build-and-install 0.204.170 → 0.300.1
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/core/params/params.d.ts +3 -2
- package/core/params/params.js +10 -2
- package/package.json +1 -1
- package/v2/phase/consts.js +1 -0
- package/v2/phase/types.d.ts +1 -0
- package/v2/phase-runner/PhaseRunner.d.ts +2 -8
- package/v2/phase-runner/PhaseRunner.js +79 -105
- package/v2/phase-runner/kaki.d.ts +0 -0
- package/v2/phase-runner/kaki.js +1 -0
package/core/params/params.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare const BaiParam_DeployBackend: BaseCliParam<'deployBackend', strin
|
|
|
30
30
|
export declare const BaiParam_DeployFrontend: BaseCliParam<'deployFrontend', string>;
|
|
31
31
|
export declare const BaiParam_NoGit: BaseCliParam<'noGit', boolean>;
|
|
32
32
|
export declare const BaiParam_Debug: BaseCliParam<'debug', boolean>;
|
|
33
|
+
export declare const BaiParam_DebugLifecycle: BaseCliParam<'debugLifecycle', boolean>;
|
|
33
34
|
export declare const BaiParam_Verbose: BaseCliParam<'verbose', boolean>;
|
|
34
35
|
export declare const BaiParam_QuickDeploy: BaseCliParam<'quickDeploy', boolean>;
|
|
35
36
|
export declare const BaiParam_Publish: BaseCliParam<'publish', string>;
|
|
@@ -38,5 +39,5 @@ export declare const BaiParam_CloseScreenOnExit: BaseCliParam<'closeOnExit', boo
|
|
|
38
39
|
export declare const BaiParam_EncounterManager: BaseCliParam<'encounterManager', boolean>;
|
|
39
40
|
export declare const BaiParam_EncounterManagerListen: BaseCliParam<'encounterManagerListen', boolean>;
|
|
40
41
|
export declare const BaiParam_UsePackage: BaseCliParam<'usePackage', string[]>;
|
|
41
|
-
export declare const AllBaiParams: (BaseCliParam<"help", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"printEnv", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"installPackages", boolean> | BaseCliParam<"installGlobals", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"runWithThunderstorm", boolean> | BaseCliParam<"withCommando", boolean> | BaseCliParam<"noThunderstorm", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"test", string> | BaseCliParam<"launch", string> | BaseCliParam<"launchFrontend", boolean> | BaseCliParam<"launchBackend", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"deployBackend", string> | BaseCliParam<"deployFrontend", string> | BaseCliParam<"noGit", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", string> | BaseCliParam<"allLogs", boolean> | BaseCliParam<"closeOnExit", boolean> | BaseCliParam<"encounterManager", boolean> | BaseCliParam<"encounterManagerListen", boolean> | BaseCliParam<"usePackage", string[]>)[];
|
|
42
|
-
export declare const RuntimeParams: import("@nu-art/commando/cli-params/types").CliParams<(BaseCliParam<"help", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"printEnv", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"installPackages", boolean> | BaseCliParam<"installGlobals", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"runWithThunderstorm", boolean> | BaseCliParam<"withCommando", boolean> | BaseCliParam<"noThunderstorm", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"test", string> | BaseCliParam<"launch", string> | BaseCliParam<"launchFrontend", boolean> | BaseCliParam<"launchBackend", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"deployBackend", string> | BaseCliParam<"deployFrontend", string> | BaseCliParam<"noGit", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", string> | BaseCliParam<"allLogs", boolean> | BaseCliParam<"closeOnExit", boolean> | BaseCliParam<"encounterManager", boolean> | BaseCliParam<"encounterManagerListen", boolean> | BaseCliParam<"usePackage", string[]>)[]>;
|
|
42
|
+
export declare const AllBaiParams: (BaseCliParam<"help", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"printEnv", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"installPackages", boolean> | BaseCliParam<"installGlobals", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"runWithThunderstorm", boolean> | BaseCliParam<"withCommando", boolean> | BaseCliParam<"noThunderstorm", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"test", string> | BaseCliParam<"launch", string> | BaseCliParam<"launchFrontend", boolean> | BaseCliParam<"launchBackend", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"deployBackend", string> | BaseCliParam<"deployFrontend", string> | BaseCliParam<"noGit", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugLifecycle", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", string> | BaseCliParam<"allLogs", boolean> | BaseCliParam<"closeOnExit", boolean> | BaseCliParam<"encounterManager", boolean> | BaseCliParam<"encounterManagerListen", boolean> | BaseCliParam<"usePackage", string[]>)[];
|
|
43
|
+
export declare const RuntimeParams: import("@nu-art/commando/cli-params/types").CliParams<(BaseCliParam<"help", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"printEnv", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"installPackages", boolean> | BaseCliParam<"installGlobals", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"runWithThunderstorm", boolean> | BaseCliParam<"withCommando", boolean> | BaseCliParam<"noThunderstorm", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"test", string> | BaseCliParam<"launch", string> | BaseCliParam<"launchFrontend", boolean> | BaseCliParam<"launchBackend", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"deployBackend", string> | BaseCliParam<"deployFrontend", string> | BaseCliParam<"noGit", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugLifecycle", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", string> | BaseCliParam<"allLogs", boolean> | BaseCliParam<"closeOnExit", boolean> | BaseCliParam<"encounterManager", boolean> | BaseCliParam<"encounterManagerListen", boolean> | BaseCliParam<"usePackage", string[]>)[]>;
|
package/core/params/params.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RuntimeParams = exports.AllBaiParams = exports.BaiParam_UsePackage = exports.BaiParam_EncounterManagerListen = exports.BaiParam_EncounterManager = exports.BaiParam_CloseScreenOnExit = exports.BaiParam_AllLogs = exports.BaiParam_Publish = exports.BaiParam_QuickDeploy = exports.BaiParam_Verbose = exports.BaiParam_Debug = exports.BaiParam_NoGit = exports.BaiParam_DeployFrontend = exports.BaiParam_DeployBackend = exports.BaiParam_Deploy = exports.BaiParam_DebugBackend = exports.BaiParam_LaunchBackend = exports.BaiParam_LaunchFrontend = exports.BaiParam_Launch = exports.BaiParam_Test = exports.BaiParam_Watch = exports.BaiParam_Lint = exports.BaiParam_NoThunderstorm = exports.BaiParam_WithCommando = exports.BaiParam_RunWithThunderstorm = exports.BaiParam_DryRun = exports.BaiParam_NoBuild = exports.BaiParam_GenerateDocs = exports.BaiParam_Generate = exports.BaiParam_Purge = exports.BaiParam_Clean = exports.BaiParam_InstallGlobals = exports.BaiParam_InstallPackages = exports.BaiParam_Install = exports.BaiParam_Setup = exports.BaiParam_SetEnv = exports.BaiParam_continue = exports.BaiParam_PrintEnv = exports.BaiParam_CheckCyclicImports = exports.BaiParam_DependencyTree = exports.BaiParam_Help = void 0;
|
|
3
|
+
exports.RuntimeParams = exports.AllBaiParams = exports.BaiParam_UsePackage = exports.BaiParam_EncounterManagerListen = exports.BaiParam_EncounterManager = exports.BaiParam_CloseScreenOnExit = exports.BaiParam_AllLogs = exports.BaiParam_Publish = exports.BaiParam_QuickDeploy = exports.BaiParam_Verbose = exports.BaiParam_DebugLifecycle = exports.BaiParam_Debug = exports.BaiParam_NoGit = exports.BaiParam_DeployFrontend = exports.BaiParam_DeployBackend = exports.BaiParam_Deploy = exports.BaiParam_DebugBackend = exports.BaiParam_LaunchBackend = exports.BaiParam_LaunchFrontend = exports.BaiParam_Launch = exports.BaiParam_Test = exports.BaiParam_Watch = exports.BaiParam_Lint = exports.BaiParam_NoThunderstorm = exports.BaiParam_WithCommando = exports.BaiParam_RunWithThunderstorm = exports.BaiParam_DryRun = exports.BaiParam_NoBuild = exports.BaiParam_GenerateDocs = exports.BaiParam_Generate = exports.BaiParam_Purge = exports.BaiParam_Clean = exports.BaiParam_InstallGlobals = exports.BaiParam_InstallPackages = exports.BaiParam_Install = exports.BaiParam_Setup = exports.BaiParam_SetEnv = exports.BaiParam_continue = exports.BaiParam_PrintEnv = exports.BaiParam_CheckCyclicImports = exports.BaiParam_DependencyTree = exports.BaiParam_Help = void 0;
|
|
4
4
|
const CLIParamsResolver_1 = require("@nu-art/commando/cli-params/CLIParamsResolver");
|
|
5
5
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
6
6
|
//util regex function
|
|
@@ -229,6 +229,13 @@ exports.BaiParam_Debug = {
|
|
|
229
229
|
type: 'boolean',
|
|
230
230
|
description: 'Will print the parameters the script is running with'
|
|
231
231
|
};
|
|
232
|
+
exports.BaiParam_DebugLifecycle = {
|
|
233
|
+
keys: ['--debug-lifecycle', '-dl'],
|
|
234
|
+
keyName: 'debugLifecycle',
|
|
235
|
+
group: 'Other',
|
|
236
|
+
type: 'boolean',
|
|
237
|
+
description: 'Will only print the run config and die'
|
|
238
|
+
};
|
|
232
239
|
exports.BaiParam_Verbose = {
|
|
233
240
|
keys: ['--verbose', '-d'],
|
|
234
241
|
keyName: 'verbose',
|
|
@@ -328,7 +335,8 @@ exports.AllBaiParams = [
|
|
|
328
335
|
exports.BaiParam_AllLogs,
|
|
329
336
|
exports.BaiParam_CloseScreenOnExit,
|
|
330
337
|
exports.BaiParam_EncounterManager,
|
|
331
|
-
exports.BaiParam_EncounterManagerListen, exports.BaiParam_UsePackage
|
|
338
|
+
exports.BaiParam_EncounterManagerListen, exports.BaiParam_UsePackage,
|
|
339
|
+
exports.BaiParam_DebugLifecycle
|
|
332
340
|
];
|
|
333
341
|
const params = CLIParamsResolver_1.CLIParamsResolver.create(...exports.AllBaiParams).resolveParamValue();
|
|
334
342
|
exports.RuntimeParams = params;
|
package/package.json
CHANGED
package/v2/phase/consts.js
CHANGED
|
@@ -66,6 +66,7 @@ exports.phase_Install = {
|
|
|
66
66
|
key: exports.phaseKey_Install,
|
|
67
67
|
name: 'Install',
|
|
68
68
|
method: 'install',
|
|
69
|
+
breakPhases: true,
|
|
69
70
|
filter: () => params_1.RuntimeParams.install || params_1.RuntimeParams.installPackages || params_1.RuntimeParams.installGlobals,
|
|
70
71
|
};
|
|
71
72
|
exports.phaseKey_ResolveConfigs = 'resolve-configs';
|
package/v2/phase/types.d.ts
CHANGED
|
@@ -29,16 +29,10 @@ export declare class PhaseRunner extends BaseUnit implements UnitPhaseImplemento
|
|
|
29
29
|
private buildUnitDependencyTree;
|
|
30
30
|
private phaseFilters;
|
|
31
31
|
private executeImpl;
|
|
32
|
+
executePhaseTest<P extends Phase<string>>(phase: P, unit: BaseUnit, index: number): Promise<void>;
|
|
32
33
|
registerUnits(units: BaseUnit | BaseUnit[]): void;
|
|
33
|
-
private
|
|
34
|
+
private willUnitRunForPhase;
|
|
34
35
|
getUnits(): BaseUnit<import("../unit/core").BaseUnit_Config, import("../unit/core").BaseUnit_RuntimeConfig>[];
|
|
35
|
-
/**
|
|
36
|
-
* Determines whether to run the phase.</br>
|
|
37
|
-
* returns true if phase ran, false otherwise
|
|
38
|
-
* @param phase
|
|
39
|
-
* @private
|
|
40
|
-
*/
|
|
41
|
-
private executePhase;
|
|
42
36
|
/**
|
|
43
37
|
* Will add a phase to the start of the phase array.
|
|
44
38
|
* @param phase
|
|
@@ -50,7 +50,6 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
50
50
|
* @private
|
|
51
51
|
*/
|
|
52
52
|
this.killCounter = 0;
|
|
53
|
-
//######################### Internal Logic #########################
|
|
54
53
|
this.phaseFilters = {
|
|
55
54
|
[types_1.PhaseRunnerMode_Normal]: async (phase) => {
|
|
56
55
|
return !(0, ts_common_1.exists)(phase.filter) || (await phase.filter());
|
|
@@ -72,6 +71,18 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
72
71
|
return dependencyKeys.includes(phase.key);
|
|
73
72
|
}
|
|
74
73
|
};
|
|
74
|
+
this.willUnitRunForPhase = async (phase, unit) => {
|
|
75
|
+
// Unit filter did not pass
|
|
76
|
+
if ((0, ts_common_1.exists)(unit.config.filter) && !unit.config.filter())
|
|
77
|
+
return false;
|
|
78
|
+
// Unit doesn't implement the phase method
|
|
79
|
+
if (!(0, ts_common_1.exists)(unit[phase.method]))
|
|
80
|
+
return false;
|
|
81
|
+
// If phase implements unit filter and unit doesn't pass
|
|
82
|
+
if ((0, ts_common_1.exists)(phase.unitFilter) && !(await phase.unitFilter(unit)))
|
|
83
|
+
return false;
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
75
86
|
this.getPhases = () => [...this.phases];
|
|
76
87
|
if ((0, ts_common_1.exists)(PhaseRunner.instance))
|
|
77
88
|
throw new ts_common_1.MUSTNeverHappenException('phase runner instance must be unique');
|
|
@@ -210,23 +221,57 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
210
221
|
dependencyTree.push(resolvingUnits);
|
|
211
222
|
}
|
|
212
223
|
this.unitDependencyTree = dependencyTree;
|
|
213
|
-
const toPrint = dependencyTree.map(row => row.map(unit => unit.config.label));
|
|
214
|
-
this.logDebug('Unit Dependency Tree:', toPrint);
|
|
215
224
|
}
|
|
216
225
|
async executeImpl() {
|
|
226
|
+
const phasesBlocks = [];
|
|
227
|
+
let phasesBlock = [];
|
|
228
|
+
let lastPhase;
|
|
217
229
|
for (const phase of this.phases) {
|
|
230
|
+
if (lastPhase === null || lastPhase === void 0 ? void 0 : lastPhase.terminateAfterPhase)
|
|
231
|
+
continue;
|
|
218
232
|
try {
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
233
|
+
const willExecutePhase = await this.phaseFilter(phase);
|
|
234
|
+
if (!willExecutePhase) {
|
|
235
|
+
this.logDebug(`Will not execute phase: ${phase.name}, did not pass filter`);
|
|
236
|
+
lastPhase = undefined;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
lastPhase = phase;
|
|
240
|
+
this.logInfo(`Will execute phase: ${phase.name}`);
|
|
241
|
+
if (phase.breakPhases) {
|
|
242
|
+
phasesBlocks.push(phasesBlock);
|
|
243
|
+
phasesBlocks.push([phase]);
|
|
244
|
+
phasesBlock = [];
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
phasesBlock.push(phase);
|
|
248
|
+
// await this.executePhase(phase);
|
|
223
249
|
}
|
|
224
250
|
catch (e) {
|
|
225
251
|
this.logError(`Error running phase: ${phase.name}`, e);
|
|
226
252
|
}
|
|
227
253
|
}
|
|
254
|
+
if (phasesBlock.length)
|
|
255
|
+
phasesBlocks.push(phasesBlock);
|
|
256
|
+
const executionQueue = phasesBlocks.map((_phasesBlock, index) => {
|
|
257
|
+
return async () => {
|
|
258
|
+
return (0, ts_common_1.Promise_all_sequentially)(this.unitDependencyTree.map(unitGroup => () => {
|
|
259
|
+
return Promise.all(unitGroup.map(unit => (0, ts_common_1.Promise_all_sequentially)(_phasesBlock.map(phase => () => this.executePhaseTest(phase, unit, index)))));
|
|
260
|
+
}));
|
|
261
|
+
};
|
|
262
|
+
});
|
|
263
|
+
await (0, ts_common_1.Promise_all_sequentially)(executionQueue);
|
|
228
264
|
this.killed = false;
|
|
229
265
|
}
|
|
266
|
+
async executePhaseTest(phase, unit, index) {
|
|
267
|
+
var _a, _b;
|
|
268
|
+
if (!params_1.RuntimeParams.dryRun)
|
|
269
|
+
return (_b = (_a = unit)[phase.method]) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
270
|
+
if (!(await this.willUnitRunForPhase(phase, unit)))
|
|
271
|
+
unit.logVerbose(`will NOT run phase #${index}: ${phase.name}`);
|
|
272
|
+
else
|
|
273
|
+
unit.logWarning(`running phase #${index}: ${phase.name}`);
|
|
274
|
+
}
|
|
230
275
|
//######################### Unit Logic #########################
|
|
231
276
|
registerUnits(units) {
|
|
232
277
|
this.units.push(...(0, ts_common_1.asArray)(units));
|
|
@@ -242,98 +287,15 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
242
287
|
});
|
|
243
288
|
PhaseRunnerDispatcher_1.dispatcher_UnitChange.dispatch(this.units);
|
|
244
289
|
}
|
|
245
|
-
async getUnitsForPhase(phase) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
// Unit doesn't implement the phase method
|
|
252
|
-
if (!(0, ts_common_1.exists)(unit[phase.method]))
|
|
253
|
-
return null;
|
|
254
|
-
// If phase implements unit filter and unit doesn't pass
|
|
255
|
-
if ((0, ts_common_1.exists)(phase.unitFilter) && !(await phase.unitFilter(unit)))
|
|
256
|
-
return null;
|
|
257
|
-
return unit;
|
|
258
|
-
}));
|
|
259
|
-
return (0, ts_common_1.filterInstances)(filteredRow);
|
|
260
|
-
})).then(rows => rows.filter(row => row.length)));
|
|
261
|
-
}
|
|
290
|
+
// private async getUnitsForPhase<P extends Phase<string>>(phase: P) {
|
|
291
|
+
// return filterInstances(await Promise.all(this.unitDependencyTree.map(async row => {
|
|
292
|
+
// const filteredRow = await Promise.all(row.filter((unit) => this.willUnitRunForPhase(phase, unit)));
|
|
293
|
+
// return filterInstances(filteredRow);
|
|
294
|
+
// })).then(rows => rows.filter(row => row.length)));
|
|
295
|
+
// }
|
|
262
296
|
getUnits() {
|
|
263
297
|
return this.units;
|
|
264
298
|
}
|
|
265
|
-
//######################### Phase Logic #########################
|
|
266
|
-
/**
|
|
267
|
-
* Determines whether to run the phase.</br>
|
|
268
|
-
* returns true if phase ran, false otherwise
|
|
269
|
-
* @param phase
|
|
270
|
-
* @private
|
|
271
|
-
*/
|
|
272
|
-
async executePhase(phase) {
|
|
273
|
-
var _a;
|
|
274
|
-
const willExecutePhase = await this.phaseFilter(phase);
|
|
275
|
-
if (!willExecutePhase) {
|
|
276
|
-
this.logDebug(`Will not execute phase: ${phase.name}, did not pass filter`);
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
const units = await this.getUnitsForPhase(phase);
|
|
280
|
-
if (!units.length) {
|
|
281
|
-
this.logDebug(`Will not execute phase: ${phase.name}, no units to execute`);
|
|
282
|
-
return false;
|
|
283
|
-
}
|
|
284
|
-
this.logDebug(`Executing phase: ${phase.name}`);
|
|
285
|
-
PhaseRunnerDispatcher_1.dispatcher_PhaseChange.dispatch(phase);
|
|
286
|
-
const phaseIndex = this.phases.indexOf(phase);
|
|
287
|
-
let runningPhaseIndex = this.phases.findIndex(phase => phase.key === this.runningStatus.phaseKey);
|
|
288
|
-
const inContinueMode = this.phaseFilter === this.phaseFilters[types_1.PhaseRunnerMode_Continue];
|
|
289
|
-
//Run all units at the same time
|
|
290
|
-
if (!phase.runUnitsInDependency) {
|
|
291
|
-
//The current phase is (or is after) the running status phase
|
|
292
|
-
if (phaseIndex >= runningPhaseIndex) {
|
|
293
|
-
this.runningStatus = { phaseKey: phase.key, packageDependencyIndex: 0 };
|
|
294
|
-
await this.setRunningStatus();
|
|
295
|
-
//Return to normal mode, if in continue
|
|
296
|
-
if (inContinueMode)
|
|
297
|
-
this.phaseFilter = this.phaseFilters[types_1.PhaseRunnerMode_Normal];
|
|
298
|
-
}
|
|
299
|
-
const unitsToRun = (0, ts_common_1.flatArray)(units);
|
|
300
|
-
await Promise.all(unitsToRun.map(unit => unit[phase.method]()));
|
|
301
|
-
if (this.killed)
|
|
302
|
-
return true;
|
|
303
|
-
return true;
|
|
304
|
-
}
|
|
305
|
-
//Run units according to dependency tree
|
|
306
|
-
for (const row of units) {
|
|
307
|
-
if (this.killed)
|
|
308
|
-
break;
|
|
309
|
-
const index = units.indexOf(row);
|
|
310
|
-
const runningStatusRowIndex = (_a = this.runningStatus.packageDependencyIndex) !== null && _a !== void 0 ? _a : 0;
|
|
311
|
-
//Skip running status holds a larger index for the same phase
|
|
312
|
-
if ((phaseIndex === runningPhaseIndex) && index < runningStatusRowIndex)
|
|
313
|
-
continue;
|
|
314
|
-
// this.logDebug(`Phase Index ${phaseIndex}, Row Index ${index}`);
|
|
315
|
-
// this.logDebug(`RunningStatus Phase Index: ${runningPhaseIndex}, RunningStatus Row Index: ${runningStatusRowIndex}`);
|
|
316
|
-
if (phaseIndex > runningPhaseIndex) {
|
|
317
|
-
//Index of the current phase is larger, update the running status
|
|
318
|
-
this.runningStatus = { phaseKey: phase.key, packageDependencyIndex: 0 };
|
|
319
|
-
runningPhaseIndex = phaseIndex;
|
|
320
|
-
await this.setRunningStatus();
|
|
321
|
-
//Return to normal mode, if in continue
|
|
322
|
-
if (inContinueMode)
|
|
323
|
-
this.phaseFilter = this.phaseFilters[types_1.PhaseRunnerMode_Normal];
|
|
324
|
-
}
|
|
325
|
-
else if (phaseIndex === runningPhaseIndex && index >= runningStatusRowIndex) {
|
|
326
|
-
//Index of the row is larger for the same phase, update running status
|
|
327
|
-
this.runningStatus = { phaseKey: phase.key, packageDependencyIndex: index };
|
|
328
|
-
await this.setRunningStatus();
|
|
329
|
-
//Return to normal mode, if in continue
|
|
330
|
-
if (inContinueMode)
|
|
331
|
-
this.phaseFilter = this.phaseFilters[types_1.PhaseRunnerMode_Normal];
|
|
332
|
-
}
|
|
333
|
-
await Promise.all(row.map(unit => unit[phase.method]()));
|
|
334
|
-
}
|
|
335
|
-
return true;
|
|
336
|
-
}
|
|
337
299
|
prependPhase(phase, beforePhase) {
|
|
338
300
|
if (!beforePhase) {
|
|
339
301
|
this.phases.unshift(phase);
|
|
@@ -393,21 +355,30 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
393
355
|
//######################### Public Functions #########################
|
|
394
356
|
async execute() {
|
|
395
357
|
return new MemStorage_1.MemStorage().init(async () => {
|
|
358
|
+
process.on('SIGINT', () => {
|
|
359
|
+
this.killRunner();
|
|
360
|
+
});
|
|
396
361
|
try {
|
|
397
|
-
|
|
398
|
-
this.
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
362
|
+
try {
|
|
363
|
+
await this.init();
|
|
364
|
+
}
|
|
365
|
+
catch (e) {
|
|
366
|
+
this.logError('Error initializing Runner', e);
|
|
367
|
+
throw e;
|
|
368
|
+
}
|
|
369
|
+
try {
|
|
370
|
+
await this.buildUnitDependencyTree();
|
|
371
|
+
}
|
|
372
|
+
catch (e) {
|
|
373
|
+
this.logError('Error building execution Tree', e);
|
|
374
|
+
throw e;
|
|
375
|
+
}
|
|
402
376
|
await this.executeImpl();
|
|
403
377
|
this.killed = true;
|
|
404
378
|
this.logInfo('Completed successfully');
|
|
405
379
|
ts_common_1.StaticLogger.logInfo('-----------', '---------------------------------- Process Completed successfully ----------------------------------');
|
|
406
|
-
if (params_1.RuntimeParams.closeOnExit)
|
|
407
|
-
process.exit(0);
|
|
408
380
|
}
|
|
409
|
-
|
|
410
|
-
// this.logError('Finished with Errors: ', error);
|
|
381
|
+
finally {
|
|
411
382
|
if (params_1.RuntimeParams.closeOnExit)
|
|
412
383
|
process.exit(1);
|
|
413
384
|
}
|
|
@@ -470,6 +441,9 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
470
441
|
this.logDebug('Filtered Units:', this.units.map(unit => unit.config.label));
|
|
471
442
|
const dependencyTree = this.unitDependencyTree.map(row => row.map(unit => unit.config.label));
|
|
472
443
|
this.logInfo('Unit Dependencies Tree:', dependencyTree);
|
|
444
|
+
this.logInfo('Phases:', this.phases.map(phase => phase.name));
|
|
445
|
+
if (params_1.RuntimeParams.debugLifecycle)
|
|
446
|
+
process.exit(0);
|
|
473
447
|
}
|
|
474
448
|
}
|
|
475
449
|
exports.PhaseRunner = PhaseRunner;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|