@nrwl/nx-cloud 14.1.3-beta.2 → 14.1.3
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/lib/core/api/error-reporter.api.js +1 -36
- package/lib/core/api/run-group.api.js +1 -65
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -138
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -169
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -113
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -166
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -79
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -243
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -131
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -206
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +1 -37
- package/lib/core/runners/distributed-execution/task-graph-creator.js +1 -77
- package/package.json +1 -1
|
@@ -1,131 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createStartRequest = exports.DistributedExecutionApi = void 0;
|
|
13
|
-
const axios_1 = require("../../../utilities/axios");
|
|
14
|
-
const environment_1 = require("../../../utilities/environment");
|
|
15
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
16
|
-
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
17
|
-
const { output, unparse } = require('../../../utilities/nx-imports');
|
|
18
|
-
class DistributedExecutionApi {
|
|
19
|
-
constructor(options) {
|
|
20
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
21
|
-
}
|
|
22
|
-
start(params) {
|
|
23
|
-
var _a;
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('dteStart');
|
|
26
|
-
let resp;
|
|
27
|
-
try {
|
|
28
|
-
resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/start', params));
|
|
29
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
33
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
34
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
if (!resp.data.enabled) {
|
|
38
|
-
throw new Error(`Workspace is disabled. Cannot perform distributed task executions.`);
|
|
39
|
-
}
|
|
40
|
-
if (resp.data.error) {
|
|
41
|
-
throw new Error(resp.data.error);
|
|
42
|
-
}
|
|
43
|
-
return resp.data.id;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
status(id) {
|
|
47
|
-
var _a;
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('dteStatus');
|
|
50
|
-
try {
|
|
51
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/status', {
|
|
52
|
-
id,
|
|
53
|
-
}));
|
|
54
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
55
|
-
return resp.data;
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
59
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
60
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
61
|
-
output.error({
|
|
62
|
-
title: e.message,
|
|
63
|
-
});
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
completeRunGroupWithError(runGroup, error) {
|
|
69
|
-
var _a;
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
|
|
72
|
-
try {
|
|
73
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
74
|
-
runGroup: runGroup,
|
|
75
|
-
criticalErrorMessage: error,
|
|
76
|
-
}), 3);
|
|
77
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
81
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
82
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.DistributedExecutionApi = DistributedExecutionApi;
|
|
88
|
-
function createStartRequest(runGroup, task, options) {
|
|
89
|
-
const tasksToExecute = task.map((arr) => {
|
|
90
|
-
return arr.map((t) => {
|
|
91
|
-
return {
|
|
92
|
-
taskId: t.id,
|
|
93
|
-
hash: t.hash,
|
|
94
|
-
projectName: t.target.project,
|
|
95
|
-
target: t.target.target,
|
|
96
|
-
configuration: t.target.configuration || null,
|
|
97
|
-
params: (0, serializer_overrides_1.serializeOverrides)(t),
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
const request = {
|
|
102
|
-
command: (0, environment_1.parseCommand)(),
|
|
103
|
-
branch: (0, environment_1.getBranch)(),
|
|
104
|
-
runGroup,
|
|
105
|
-
tasks: tasksToExecute,
|
|
106
|
-
maxParallel: calculateMaxParallel(options),
|
|
107
|
-
};
|
|
108
|
-
if (environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT) {
|
|
109
|
-
request.agentCount = environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT;
|
|
110
|
-
}
|
|
111
|
-
if (!environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE) {
|
|
112
|
-
request.stopAgentsOnFailure = false;
|
|
113
|
-
}
|
|
114
|
-
return request;
|
|
115
|
-
}
|
|
116
|
-
exports.createStartRequest = createStartRequest;
|
|
117
|
-
function calculateMaxParallel(options) {
|
|
118
|
-
if (options.parallel === 'false' || options.parallel === false) {
|
|
119
|
-
return 1;
|
|
120
|
-
}
|
|
121
|
-
else if (options.parallel === 'true' || options.parallel === true) {
|
|
122
|
-
return Number(options.maxParallel || 3);
|
|
123
|
-
}
|
|
124
|
-
else if (options.parallel === undefined) {
|
|
125
|
-
return options.maxParallel ? Number(options.maxParallel) : 3;
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
return Number(options.parallel) || 3;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=distributed-execution.api.js.map
|
|
1
|
+
const a6_0x3407=['serializeOverrides','value','agentCount','data','response','error','mapRespToPerfEntry','throw','__awaiter','/nx-cloud/executions/start','axiosException','parseCommand','post','target','createApiAxiosInstance','axiosMultipleTries','../../../utilities/metric-logger','start','hash','../../../utilities/nx-imports','configuration','/nx-cloud/executions/status','getBranch','recordMetric','dteStatus','completeRunGroup','createMetricRecorder','completeRunGroupWithError','dteStart','map','NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE','defineProperty','apiAxiosInstance','status','done','message','parallel','apply','../../../utilities/axios','maxParallel','then','RUNNER_FAILURE_PERF_ENTRY','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.','/nx-cloud/executions/complete-run-group','DistributedExecutionApi','stopAgentsOnFailure','true','createStartRequest','next'];(function(_0x1cde6a,_0x3407e0){const _0x1d59bf=function(_0x1474f5){while(--_0x1474f5){_0x1cde6a['push'](_0x1cde6a['shift']());}};_0x1d59bf(++_0x3407e0);}(a6_0x3407,0xdd));const a6_0x1d59=function(_0x1cde6a,_0x3407e0){_0x1cde6a=_0x1cde6a-0x0;let _0x1d59bf=a6_0x3407[_0x1cde6a];return _0x1d59bf;};'use strict';var __awaiter=this&&this[a6_0x1d59('0x25')]||function(_0xed6e40,_0x188052,_0x3f7946,_0x3f9142){function _0x489ad7(_0x1729e0){return _0x1729e0 instanceof _0x3f7946?_0x1729e0:new _0x3f7946(function(_0x103d27){_0x103d27(_0x1729e0);});}return new(_0x3f7946||(_0x3f7946=Promise))(function(_0x6d6530,_0x57fa57){function _0x2013fa(_0xc2c36b){try{_0x19a652(_0x3f9142[a6_0x1d59('0x1c')](_0xc2c36b));}catch(_0x2a4d82){_0x57fa57(_0x2a4d82);}}function _0x2dded7(_0x51cbe8){try{_0x19a652(_0x3f9142[a6_0x1d59('0x24')](_0x51cbe8));}catch(_0x383763){_0x57fa57(_0x383763);}}function _0x19a652(_0x481e75){_0x481e75[a6_0x1d59('0xd')]?_0x6d6530(_0x481e75[a6_0x1d59('0x1e')]):_0x489ad7(_0x481e75['value'])[a6_0x1d59('0x13')](_0x2013fa,_0x2dded7);}_0x19a652((_0x3f9142=_0x3f9142[a6_0x1d59('0x10')](_0xed6e40,_0x188052||[]))[a6_0x1d59('0x1c')]());});};Object[a6_0x1d59('0xa')](exports,'__esModule',{'value':!![]});exports[a6_0x1d59('0x1b')]=exports[a6_0x1d59('0x18')]=void 0x0;const axios_1=require(a6_0x1d59('0x11'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a6_0x1d59('0x2d'));const serializer_overrides_1=require('../../../utilities/serializer-overrides');const {output,unparse}=require(a6_0x1d59('0x30'));class DistributedExecutionApi{constructor(_0x29e654){this[a6_0x1d59('0xb')]=(0x0,axios_1[a6_0x1d59('0x2b')])(_0x29e654);}[a6_0x1d59('0x2e')](_0xb0d83a){var _0x3985ce;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5ccd54=(0x0,metric_logger_1[a6_0x1d59('0x5')])(a6_0x1d59('0x7'));let _0x2e9d4b;try{_0x2e9d4b=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a6_0x1d59('0xb')]['post'](a6_0x1d59('0x26'),_0xb0d83a));_0x5ccd54[a6_0x1d59('0x2')]((0x0,metric_logger_1[a6_0x1d59('0x23')])(_0x2e9d4b));}catch(_0x4fe3d8){_0x5ccd54[a6_0x1d59('0x2')](((_0x3985ce=_0x4fe3d8===null||_0x4fe3d8===void 0x0?void 0x0:_0x4fe3d8['axiosException'])===null||_0x3985ce===void 0x0?void 0x0:_0x3985ce[a6_0x1d59('0x21')])?(0x0,metric_logger_1[a6_0x1d59('0x23')])(_0x4fe3d8[a6_0x1d59('0x27')]['response']):metric_logger_1[a6_0x1d59('0x14')]);throw _0x4fe3d8;}if(!_0x2e9d4b[a6_0x1d59('0x20')]['enabled']){throw new Error(a6_0x1d59('0x16'));}if(_0x2e9d4b[a6_0x1d59('0x20')][a6_0x1d59('0x22')]){throw new Error(_0x2e9d4b[a6_0x1d59('0x20')][a6_0x1d59('0x22')]);}return _0x2e9d4b['data']['id'];});}[a6_0x1d59('0xc')](_0x2e3d92){var _0x18e400;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1e9b33=(0x0,metric_logger_1[a6_0x1d59('0x5')])(a6_0x1d59('0x3'));try{const _0x9e251c=yield(0x0,axios_1[a6_0x1d59('0x2c')])(()=>this[a6_0x1d59('0xb')][a6_0x1d59('0x29')](a6_0x1d59('0x0'),{'id':_0x2e3d92}));_0x1e9b33[a6_0x1d59('0x2')]((0x0,metric_logger_1[a6_0x1d59('0x23')])(_0x9e251c));return _0x9e251c[a6_0x1d59('0x20')];}catch(_0x338035){_0x1e9b33['recordMetric'](((_0x18e400=_0x338035===null||_0x338035===void 0x0?void 0x0:_0x338035[a6_0x1d59('0x27')])===null||_0x18e400===void 0x0?void 0x0:_0x18e400[a6_0x1d59('0x21')])?(0x0,metric_logger_1[a6_0x1d59('0x23')])(_0x338035['axiosException']['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a6_0x1d59('0x22')]({'title':_0x338035[a6_0x1d59('0xe')]});process['exit'](0x1);}});}[a6_0x1d59('0x6')](_0x141803,_0x5d6417){var _0x39b516;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x12b507=(0x0,metric_logger_1[a6_0x1d59('0x5')])(a6_0x1d59('0x4'));try{const _0x32a64d=yield(0x0,axios_1[a6_0x1d59('0x2c')])(()=>this[a6_0x1d59('0xb')]['post'](a6_0x1d59('0x17'),{'runGroup':_0x141803,'criticalErrorMessage':_0x5d6417}),0x3);_0x12b507[a6_0x1d59('0x2')]((0x0,metric_logger_1[a6_0x1d59('0x23')])(_0x32a64d));}catch(_0x43c5de){_0x12b507['recordMetric'](((_0x39b516=_0x43c5de===null||_0x43c5de===void 0x0?void 0x0:_0x43c5de['axiosException'])===null||_0x39b516===void 0x0?void 0x0:_0x39b516[a6_0x1d59('0x21')])?(0x0,metric_logger_1[a6_0x1d59('0x23')])(_0x43c5de['axiosException'][a6_0x1d59('0x21')]):metric_logger_1[a6_0x1d59('0x14')]);}});}}exports['DistributedExecutionApi']=DistributedExecutionApi;function createStartRequest(_0x48e609,_0x52027f,_0x14170c){const _0x440d6e=_0x52027f[a6_0x1d59('0x8')](_0x2ab164=>{return _0x2ab164['map'](_0x4727b2=>{return{'taskId':_0x4727b2['id'],'hash':_0x4727b2[a6_0x1d59('0x2f')],'projectName':_0x4727b2['target']['project'],'target':_0x4727b2[a6_0x1d59('0x2a')][a6_0x1d59('0x2a')],'configuration':_0x4727b2['target'][a6_0x1d59('0x31')]||null,'params':(0x0,serializer_overrides_1[a6_0x1d59('0x1d')])(_0x4727b2)};});});const _0x5614d4={'command':(0x0,environment_1[a6_0x1d59('0x28')])(),'branch':(0x0,environment_1[a6_0x1d59('0x1')])(),'runGroup':_0x48e609,'tasks':_0x440d6e,'maxParallel':calculateMaxParallel(_0x14170c)};if(environment_1[a6_0x1d59('0x15')]){_0x5614d4[a6_0x1d59('0x1f')]=environment_1[a6_0x1d59('0x15')];}if(!environment_1[a6_0x1d59('0x9')]){_0x5614d4[a6_0x1d59('0x19')]=![];}return _0x5614d4;}exports[a6_0x1d59('0x1b')]=createStartRequest;function calculateMaxParallel(_0x43c836){if(_0x43c836[a6_0x1d59('0xf')]==='false'||_0x43c836[a6_0x1d59('0xf')]===![]){return 0x1;}else if(_0x43c836[a6_0x1d59('0xf')]===a6_0x1d59('0x1a')||_0x43c836[a6_0x1d59('0xf')]===!![]){return Number(_0x43c836[a6_0x1d59('0x12')]||0x3);}else if(_0x43c836[a6_0x1d59('0xf')]===undefined){return _0x43c836[a6_0x1d59('0x12')]?Number(_0x43c836[a6_0x1d59('0x12')]):0x3;}else{return Number(_0x43c836['parallel'])||0x3;}}
|
|
@@ -1,206 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.nxCloudDistributedTasksRunner = void 0;
|
|
13
|
-
const stripJsonComments = require("strip-json-comments");
|
|
14
|
-
const fs_1 = require("fs");
|
|
15
|
-
const distributed_execution_api_1 = require("./distributed-execution.api");
|
|
16
|
-
const file_storage_1 = require("../../file-storage/file-storage");
|
|
17
|
-
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
|
|
18
|
-
const waiter_1 = require("../../../utilities/waiter");
|
|
19
|
-
const environment_1 = require("../../../utilities/environment");
|
|
20
|
-
const print_run_group_error_1 = require("../../error/print-run-group-error");
|
|
21
|
-
const create_no_new_messages_timeout_1 = require("../../../utilities/create-no-new-messages-timeout");
|
|
22
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
23
|
-
const error_reporter_api_1 = require("../../api/error-reporter.api");
|
|
24
|
-
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
25
|
-
const task_graph_creator_1 = require("./task-graph-creator");
|
|
26
|
-
const split_task_graph_into_stages_1 = require("./split-task-graph-into-stages");
|
|
27
|
-
const { output, workspaceRoot, getOutputs, Cache, } = require('../../../utilities/nx-imports');
|
|
28
|
-
class NoopLifeCycle {
|
|
29
|
-
scheduleTask(task) { }
|
|
30
|
-
startTask(task) { }
|
|
31
|
-
endTask(task, code) { }
|
|
32
|
-
}
|
|
33
|
-
function runDistributedExecution(api, options, context, fileStorage, cache, runGroup, taskGraph) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const id = yield api.start((0, distributed_execution_api_1.createStartRequest)(runGroup, (0, split_task_graph_into_stages_1.splitTasksIntoStages)(taskGraph), options));
|
|
36
|
-
return yield processTasks(api, fileStorage, cache, options, id, Object.values(taskGraph.tasks), context);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function processTasks(api, fileStorage, cache, options, executionId, tasks, context) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const processedTasks = {};
|
|
42
|
-
const failIfNumberOfCompletedTasksDoesNotChangeIn30Mins = (0, create_no_new_messages_timeout_1.createNoNewMessagesTimeout)();
|
|
43
|
-
const waiter = new waiter_1.Waiter();
|
|
44
|
-
while (true) {
|
|
45
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
46
|
-
output.note({
|
|
47
|
-
title: 'Waiting...',
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
yield waiter.wait();
|
|
51
|
-
const r = yield api.status(executionId);
|
|
52
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
53
|
-
output.note({
|
|
54
|
-
title: `Status update`,
|
|
55
|
-
bodyLines: [
|
|
56
|
-
`executionId: ${executionId}`,
|
|
57
|
-
`executionStatus: ${r.executionStatus}`,
|
|
58
|
-
`number of completed tasks: ${r.completedTasks.length}`,
|
|
59
|
-
`error: ${r.criticalErrorMessage}`,
|
|
60
|
-
],
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
if (r.criticalErrorMessage) {
|
|
64
|
-
output.error({
|
|
65
|
-
title: 'Distributed Execution Terminated',
|
|
66
|
-
bodyLines: ['Error:', r.criticalErrorMessage],
|
|
67
|
-
});
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
failIfNumberOfCompletedTasksDoesNotChangeIn30Mins(r.completedTasks.length);
|
|
71
|
-
for (const t of r.completedTasks) {
|
|
72
|
-
if (processedTasks[t.taskId])
|
|
73
|
-
continue;
|
|
74
|
-
yield processTask(fileStorage, cache, context, options, tasks, t);
|
|
75
|
-
waiter.reset();
|
|
76
|
-
processedTasks[t.taskId] = true;
|
|
77
|
-
}
|
|
78
|
-
if (r.executionStatus === 'COMPLETED') {
|
|
79
|
-
return { commandStatus: r.commandStatus, runUrl: r.runUrl };
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
function processTask(fileStorage, cache, context, options, tasks, completedTask) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
87
|
-
output.note({
|
|
88
|
-
title: `Processing task ${completedTask.taskId}`,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
const matchingTask = tasks.find((tt) => completedTask.taskId === tt.id);
|
|
92
|
-
if (!matchingTask) {
|
|
93
|
-
throw new Error(`Found unknown task: ${completedTask.taskId}`);
|
|
94
|
-
}
|
|
95
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
96
|
-
output.note({
|
|
97
|
-
title: `Retrieving artifacts from ${completedTask.url}`,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
yield fileStorage.retrieve(completedTask.hash, completedTask.url, options.cacheDirectory || './node_modules/.cache/nx');
|
|
101
|
-
const cachedResult = yield cache.get(Object.assign(Object.assign({}, matchingTask), { hash: completedTask.hash }));
|
|
102
|
-
const outputs = getOutputs(context.projectGraph.nodes, matchingTask);
|
|
103
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
104
|
-
output.note({
|
|
105
|
-
title: `Extracting artifacts`,
|
|
106
|
-
bodyLines: outputs,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
yield cache.copyFilesFromCache(completedTask.hash, cachedResult, outputs);
|
|
110
|
-
output.logCommand(getCommand(matchingTask));
|
|
111
|
-
process.stdout.write(cachedResult.terminalOutput);
|
|
112
|
-
output.addVerticalSeparator();
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
function getCommand(task) {
|
|
116
|
-
const config = task.target.configuration
|
|
117
|
-
? `:${task.target.configuration}`
|
|
118
|
-
: '';
|
|
119
|
-
return [
|
|
120
|
-
'nx',
|
|
121
|
-
'run',
|
|
122
|
-
`${task.target.project}:${task.target.target}${config}`,
|
|
123
|
-
(0, serializer_overrides_1.serializeOverrides)(task),
|
|
124
|
-
].join(' ');
|
|
125
|
-
}
|
|
126
|
-
const nxCloudDistributedTasksRunner = (tasks, options, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
128
|
-
output.note({
|
|
129
|
-
title: 'Starting distributed command execution',
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
options.lifeCycle = new NoopLifeCycle();
|
|
133
|
-
const runGroup = (0, environment_1.getRunGroup)();
|
|
134
|
-
if (!runGroup) {
|
|
135
|
-
(0, print_run_group_error_1.printRunGroupError)();
|
|
136
|
-
return process.exit(1);
|
|
137
|
-
}
|
|
138
|
-
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
|
|
139
|
-
const errorReporter = new error_reporter_api_1.ErrorReporterApi(options);
|
|
140
|
-
const fileStorage = new file_storage_1.FileStorage(encryption, errorReporter, true);
|
|
141
|
-
const cache = new Cache(options);
|
|
142
|
-
const api = new distributed_execution_api_1.DistributedExecutionApi(options);
|
|
143
|
-
try {
|
|
144
|
-
const taskGraph = getTaskGraph(context, tasks, options);
|
|
145
|
-
const r = yield runDistributedExecution(api, options, context, fileStorage, cache, runGroup, taskGraph);
|
|
146
|
-
if (r.commandStatus === 0) {
|
|
147
|
-
output.success({
|
|
148
|
-
title: 'Successfully completed running the command.',
|
|
149
|
-
bodyLines: [`See run details at ${r.runUrl}`],
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
output.error({
|
|
154
|
-
title: 'Command execution failed.',
|
|
155
|
-
bodyLines: [`See run details at ${r.runUrl}`],
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
159
|
-
process.exit(r.commandStatus);
|
|
160
|
-
}
|
|
161
|
-
catch (e) {
|
|
162
|
-
output.error({
|
|
163
|
-
title: 'Unable to complete a run.',
|
|
164
|
-
bodyLines: [e.message],
|
|
165
|
-
});
|
|
166
|
-
if (e.axiosException) {
|
|
167
|
-
console.log(e.axiosException);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
console.log(e);
|
|
171
|
-
}
|
|
172
|
-
try {
|
|
173
|
-
yield api.completeRunGroupWithError(runGroup, `Main job terminated with an error: "${e.message}"`);
|
|
174
|
-
}
|
|
175
|
-
finally {
|
|
176
|
-
process.exit(1);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
exports.nxCloudDistributedTasksRunner = nxCloudDistributedTasksRunner;
|
|
181
|
-
function getTaskGraph(context, tasks, options) {
|
|
182
|
-
if (context.taskGraph) {
|
|
183
|
-
return context.taskGraph;
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString()));
|
|
187
|
-
return new task_graph_creator_1.TaskGraphCreator(context.projectGraph, getDefaultDependencyConfigs(nxjson, options)).createTaskGraph(tasks);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
function getDefaultDependencyConfigs(nxJson, runnerOptions) {
|
|
191
|
-
var _a, _b;
|
|
192
|
-
const defaults = (_a = nxJson.targetDependencies) !== null && _a !== void 0 ? _a : {};
|
|
193
|
-
const strictlyOrderedTargets = runnerOptions
|
|
194
|
-
? (_b = runnerOptions.strictlyOrderedTargets) !== null && _b !== void 0 ? _b : ['build']
|
|
195
|
-
: [];
|
|
196
|
-
// Strictly Ordered Targets depend on their dependencies
|
|
197
|
-
for (const target of strictlyOrderedTargets) {
|
|
198
|
-
defaults[target] = defaults[target] || [];
|
|
199
|
-
defaults[target].push({
|
|
200
|
-
target,
|
|
201
|
-
projects: 'dependencies',
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return defaults;
|
|
205
|
-
}
|
|
206
|
-
//# sourceMappingURL=distributed-execution.runner.js.map
|
|
1
|
+
const a7_0x375d=['url','../../../utilities/metric-logger','defineProperty','terminalOutput','executionId:\x20','target','../../../utilities/create-no-new-messages-timeout','./split-task-graph-into-stages','projectGraph','Processing\x20task\x20','find','splitTasksIntoStages','Error:','commandStatus','write','logCommand','scheduleTask','Distributed\x20Execution\x20Terminated','nodes','executionStatus','Retrieving\x20artifacts\x20from\x20','run','serializeOverrides','hash','../../api/error-reporter.api','encryptionKey','./distributed-execution.api','start','wait','Command\x20execution\x20failed.','next','completeRunGroupWithError','note','taskId','retrieve','cacheDirectory','error:\x20','push','stdout','success','throw','targetDependencies','assign','Extracting\x20artifacts','../../../utilities/nx-imports','DistributedExecutionApi','__awaiter','then','../../../utilities/environment','createTaskGraph','VERBOSE_LOGGING','../../error/print-run-group-error','ErrorReporterApi','Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','../../../utilities/waiter','strictlyOrderedTargets','endTask','printRunGroupError','createStartRequest','runUrl','parse','apply','../../../utilities/serializer-overrides','nxCloudDistributedTasksRunner','status','addVerticalSeparator','done','project','submitRunMetrics','taskGraph','lifeCycle','get','value','length','Waiter','log','Starting\x20distributed\x20command\x20execution','../../file-storage/file-storage','tasks','axiosException','exit','getRunGroup','FileStorage','Unable\x20to\x20complete\x20a\x20run.','values','message','error','criticalErrorMessage','/nx.json','See\x20run\x20details\x20at\x20','completedTasks','./task-graph-creator'];(function(_0x1ecb14,_0x375ddc){const _0x43d3f=function(_0x339209){while(--_0x339209){_0x1ecb14['push'](_0x1ecb14['shift']());}};_0x43d3f(++_0x375ddc);}(a7_0x375d,0xe5));const a7_0x43d3=function(_0x1ecb14,_0x375ddc){_0x1ecb14=_0x1ecb14-0x0;let _0x43d3f=a7_0x375d[_0x1ecb14];return _0x43d3f;};'use strict';var __awaiter=this&&this[a7_0x43d3('0x1')]||function(_0xd67633,_0x47f7f1,_0x130e7f,_0x2841a7){function _0x341ba2(_0x369102){return _0x369102 instanceof _0x130e7f?_0x369102:new _0x130e7f(function(_0x5b44f0){_0x5b44f0(_0x369102);});}return new(_0x130e7f||(_0x130e7f=Promise))(function(_0x293ae7,_0x5f558a){function _0x4a8d9b(_0x37c331){try{_0x2388a1(_0x2841a7[a7_0x43d3('0x4d')](_0x37c331));}catch(_0x9b03e2){_0x5f558a(_0x9b03e2);}}function _0x3bd8de(_0x33adaf){try{_0x2388a1(_0x2841a7[a7_0x43d3('0x57')](_0x33adaf));}catch(_0x32de5b){_0x5f558a(_0x32de5b);}}function _0x2388a1(_0x48fd62){_0x48fd62[a7_0x43d3('0x15')]?_0x293ae7(_0x48fd62[a7_0x43d3('0x1b')]):_0x341ba2(_0x48fd62['value'])[a7_0x43d3('0x2')](_0x4a8d9b,_0x3bd8de);}_0x2388a1((_0x2841a7=_0x2841a7[a7_0x43d3('0x10')](_0xd67633,_0x47f7f1||[]))[a7_0x43d3('0x4d')]());});};Object[a7_0x43d3('0x31')](exports,'__esModule',{'value':!![]});exports[a7_0x43d3('0x12')]=void 0x0;const stripJsonComments=require('strip-json-comments');const fs_1=require('fs');const distributed_execution_api_1=require(a7_0x43d3('0x49'));const file_storage_1=require(a7_0x43d3('0x20'));const e2e_encryption_1=require('../../file-storage/e2e-encryption');const waiter_1=require(a7_0x43d3('0x9'));const environment_1=require(a7_0x43d3('0x3'));const print_run_group_error_1=require(a7_0x43d3('0x6'));const create_no_new_messages_timeout_1=require(a7_0x43d3('0x35'));const metric_logger_1=require(a7_0x43d3('0x30'));const error_reporter_api_1=require(a7_0x43d3('0x47'));const serializer_overrides_1=require(a7_0x43d3('0x11'));const task_graph_creator_1=require(a7_0x43d3('0x2e'));const split_task_graph_into_stages_1=require(a7_0x43d3('0x36'));const {output,workspaceRoot,getOutputs,Cache}=require(a7_0x43d3('0x5b'));class NoopLifeCycle{[a7_0x43d3('0x3f')](_0x2cea6b){}['startTask'](_0x1a5f32){}[a7_0x43d3('0xb')](_0xbb22ae,_0x5e8138){}}function runDistributedExecution(_0x4db44e,_0x44c72e,_0x3041d9,_0x32db1a,_0x78b4ff,_0x316e4f,_0x4adef6){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x32f782=yield _0x4db44e[a7_0x43d3('0x4a')]((0x0,distributed_execution_api_1[a7_0x43d3('0xd')])(_0x316e4f,(0x0,split_task_graph_into_stages_1[a7_0x43d3('0x3a')])(_0x4adef6),_0x44c72e));return yield processTasks(_0x4db44e,_0x32db1a,_0x78b4ff,_0x44c72e,_0x32f782,Object[a7_0x43d3('0x27')](_0x4adef6[a7_0x43d3('0x21')]),_0x3041d9);});}function processTasks(_0x1c7541,_0x5c6057,_0x34e15a,_0x59b2a1,_0x462fb4,_0x34447b,_0x4c8201){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3b5cfb={};const _0x5aa5ba=(0x0,create_no_new_messages_timeout_1['createNoNewMessagesTimeout'])();const _0x43d9b9=new waiter_1[(a7_0x43d3('0x1d'))]();while(!![]){if(environment_1[a7_0x43d3('0x5')]){output[a7_0x43d3('0x4f')]({'title':'Waiting...'});}yield _0x43d9b9[a7_0x43d3('0x4b')]();const _0x5b9c2b=yield _0x1c7541[a7_0x43d3('0x13')](_0x462fb4);if(environment_1['VERBOSE_LOGGING']){output[a7_0x43d3('0x4f')]({'title':'Status\x20update','bodyLines':[a7_0x43d3('0x33')+_0x462fb4,'executionStatus:\x20'+_0x5b9c2b['executionStatus'],'number\x20of\x20completed\x20tasks:\x20'+_0x5b9c2b[a7_0x43d3('0x2d')]['length'],a7_0x43d3('0x53')+_0x5b9c2b['criticalErrorMessage']]});}if(_0x5b9c2b[a7_0x43d3('0x2a')]){output[a7_0x43d3('0x29')]({'title':a7_0x43d3('0x40'),'bodyLines':[a7_0x43d3('0x3b'),_0x5b9c2b['criticalErrorMessage']]});process[a7_0x43d3('0x23')](0x1);}_0x5aa5ba(_0x5b9c2b['completedTasks'][a7_0x43d3('0x1c')]);for(const _0x5e5aa9 of _0x5b9c2b[a7_0x43d3('0x2d')]){if(_0x3b5cfb[_0x5e5aa9[a7_0x43d3('0x50')]])continue;yield processTask(_0x5c6057,_0x34e15a,_0x4c8201,_0x59b2a1,_0x34447b,_0x5e5aa9);_0x43d9b9['reset']();_0x3b5cfb[_0x5e5aa9[a7_0x43d3('0x50')]]=!![];}if(_0x5b9c2b[a7_0x43d3('0x42')]==='COMPLETED'){return{'commandStatus':_0x5b9c2b[a7_0x43d3('0x3c')],'runUrl':_0x5b9c2b[a7_0x43d3('0xe')]};}}});}function processTask(_0x323cb3,_0x2cf516,_0xdfe5e6,_0x24fc8a,_0x28318d,_0x382690){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a7_0x43d3('0x5')]){output[a7_0x43d3('0x4f')]({'title':a7_0x43d3('0x38')+_0x382690[a7_0x43d3('0x50')]});}const _0x2becdf=_0x28318d[a7_0x43d3('0x39')](_0x51a7db=>_0x382690['taskId']===_0x51a7db['id']);if(!_0x2becdf){throw new Error('Found\x20unknown\x20task:\x20'+_0x382690[a7_0x43d3('0x50')]);}if(environment_1[a7_0x43d3('0x5')]){output['note']({'title':a7_0x43d3('0x43')+_0x382690['url']});}yield _0x323cb3[a7_0x43d3('0x51')](_0x382690[a7_0x43d3('0x46')],_0x382690[a7_0x43d3('0x2f')],_0x24fc8a[a7_0x43d3('0x52')]||'./node_modules/.cache/nx');const _0x5e31d6=yield _0x2cf516[a7_0x43d3('0x1a')](Object[a7_0x43d3('0x59')](Object[a7_0x43d3('0x59')]({},_0x2becdf),{'hash':_0x382690[a7_0x43d3('0x46')]}));const _0x2190ad=getOutputs(_0xdfe5e6[a7_0x43d3('0x37')][a7_0x43d3('0x41')],_0x2becdf);if(environment_1['VERBOSE_LOGGING']){output[a7_0x43d3('0x4f')]({'title':a7_0x43d3('0x5a'),'bodyLines':_0x2190ad});}yield _0x2cf516['copyFilesFromCache'](_0x382690['hash'],_0x5e31d6,_0x2190ad);output[a7_0x43d3('0x3e')](getCommand(_0x2becdf));process[a7_0x43d3('0x55')][a7_0x43d3('0x3d')](_0x5e31d6[a7_0x43d3('0x32')]);output[a7_0x43d3('0x14')]();});}function getCommand(_0x159854){const _0x34526d=_0x159854[a7_0x43d3('0x34')]['configuration']?':'+_0x159854[a7_0x43d3('0x34')]['configuration']:'';return['nx',a7_0x43d3('0x44'),_0x159854[a7_0x43d3('0x34')][a7_0x43d3('0x16')]+':'+_0x159854[a7_0x43d3('0x34')]['target']+_0x34526d,(0x0,serializer_overrides_1[a7_0x43d3('0x45')])(_0x159854)]['join']('\x20');}const nxCloudDistributedTasksRunner=(_0x29ca14,_0x84d231,_0x4229b8)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(environment_1[a7_0x43d3('0x5')]){output[a7_0x43d3('0x4f')]({'title':a7_0x43d3('0x1f')});}_0x84d231[a7_0x43d3('0x19')]=new NoopLifeCycle();const _0x5a5f80=(0x0,environment_1[a7_0x43d3('0x24')])();if(!_0x5a5f80){(0x0,print_run_group_error_1[a7_0x43d3('0xc')])();return process[a7_0x43d3('0x23')](0x1);}const _0x41c1ff=new e2e_encryption_1['E2EEncryption'](environment_1['ENCRYPTION_KEY']||_0x84d231[a7_0x43d3('0x48')]);const _0x419505=new error_reporter_api_1[(a7_0x43d3('0x7'))](_0x84d231);const _0x433fde=new file_storage_1[(a7_0x43d3('0x25'))](_0x41c1ff,_0x419505,!![]);const _0x546861=new Cache(_0x84d231);const _0x3d9ecb=new distributed_execution_api_1[(a7_0x43d3('0x0'))](_0x84d231);try{const _0x2f26cf=getTaskGraph(_0x4229b8,_0x29ca14,_0x84d231);const _0x39117d=yield runDistributedExecution(_0x3d9ecb,_0x84d231,_0x4229b8,_0x433fde,_0x546861,_0x5a5f80,_0x2f26cf);if(_0x39117d[a7_0x43d3('0x3c')]===0x0){output[a7_0x43d3('0x56')]({'title':'Successfully\x20completed\x20running\x20the\x20command.','bodyLines':[a7_0x43d3('0x2c')+_0x39117d[a7_0x43d3('0xe')]]});}else{output['error']({'title':a7_0x43d3('0x4c'),'bodyLines':[a7_0x43d3('0x2c')+_0x39117d[a7_0x43d3('0xe')]]});}yield(0x0,metric_logger_1[a7_0x43d3('0x17')])(_0x84d231);process[a7_0x43d3('0x23')](_0x39117d[a7_0x43d3('0x3c')]);}catch(_0x30628d){output[a7_0x43d3('0x29')]({'title':a7_0x43d3('0x26'),'bodyLines':[_0x30628d[a7_0x43d3('0x28')]]});if(_0x30628d[a7_0x43d3('0x22')]){console[a7_0x43d3('0x1e')](_0x30628d[a7_0x43d3('0x22')]);}else{console[a7_0x43d3('0x1e')](_0x30628d);}try{yield _0x3d9ecb[a7_0x43d3('0x4e')](_0x5a5f80,a7_0x43d3('0x8')+_0x30628d[a7_0x43d3('0x28')]+'\x22');}finally{process[a7_0x43d3('0x23')](0x1);}}});exports[a7_0x43d3('0x12')]=nxCloudDistributedTasksRunner;function getTaskGraph(_0x8eb455,_0x128698,_0x254048){if(_0x8eb455[a7_0x43d3('0x18')]){return _0x8eb455[a7_0x43d3('0x18')];}else{const _0x4d9244=JSON[a7_0x43d3('0xf')](stripJsonComments((0x0,fs_1['readFileSync'])(workspaceRoot+a7_0x43d3('0x2b'))['toString']()));return new task_graph_creator_1['TaskGraphCreator'](_0x8eb455['projectGraph'],getDefaultDependencyConfigs(_0x4d9244,_0x254048))[a7_0x43d3('0x4')](_0x128698);}}function getDefaultDependencyConfigs(_0x21e48f,_0x15e7ac){var _0x527733,_0x33b5ca;const _0x56fdd6=(_0x527733=_0x21e48f[a7_0x43d3('0x58')])!==null&&_0x527733!==void 0x0?_0x527733:{};const _0x4b24cc=_0x15e7ac?(_0x33b5ca=_0x15e7ac[a7_0x43d3('0xa')])!==null&&_0x33b5ca!==void 0x0?_0x33b5ca:['build']:[];for(const _0x5ecc82 of _0x4b24cc){_0x56fdd6[_0x5ecc82]=_0x56fdd6[_0x5ecc82]||[];_0x56fdd6[_0x5ecc82][a7_0x43d3('0x54')]({'target':_0x5ecc82,'projects':'dependencies'});}return _0x56fdd6;}
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.splitTasksIntoStages = void 0;
|
|
4
|
-
function splitTasksIntoStages(taskGraph) {
|
|
5
|
-
const stages = [];
|
|
6
|
-
const notStagedTaskIds = new Set(Object.values(taskGraph.tasks).map((t) => t.id));
|
|
7
|
-
let stageIndex = 0;
|
|
8
|
-
// Loop through tasks and try to stage them. As tasks are staged, they are removed from the loop
|
|
9
|
-
while (notStagedTaskIds.size > 0) {
|
|
10
|
-
const currentStage = (stages[stageIndex] = []);
|
|
11
|
-
for (const taskId of notStagedTaskIds) {
|
|
12
|
-
let ready = true;
|
|
13
|
-
for (const dependency of taskGraph.dependencies[taskId]) {
|
|
14
|
-
if (notStagedTaskIds.has(dependency)) {
|
|
15
|
-
// dependency has not been staged yet, this task is not ready to be staged.
|
|
16
|
-
ready = false;
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// Some dependency still has not been staged, skip it for now, it will be processed again
|
|
21
|
-
if (!ready) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
// All the dependencies have been staged, let's stage it.
|
|
25
|
-
const task = taskGraph.tasks[taskId];
|
|
26
|
-
currentStage.push(task);
|
|
27
|
-
}
|
|
28
|
-
// Remove the entire new stage of tasks from the list
|
|
29
|
-
for (const task of currentStage) {
|
|
30
|
-
notStagedTaskIds.delete(task.id);
|
|
31
|
-
}
|
|
32
|
-
stageIndex++;
|
|
33
|
-
}
|
|
34
|
-
return stages;
|
|
35
|
-
}
|
|
36
|
-
exports.splitTasksIntoStages = splitTasksIntoStages;
|
|
37
|
-
//# sourceMappingURL=split-task-graph-into-stages.js.map
|
|
1
|
+
const a8_0x30a7=['has','map','push','size','dependencies','values','splitTasksIntoStages','tasks','__esModule'];(function(_0x4e2c90,_0x30a7db){const _0x1e07d2=function(_0x4e65b2){while(--_0x4e65b2){_0x4e2c90['push'](_0x4e2c90['shift']());}};_0x1e07d2(++_0x30a7db);}(a8_0x30a7,0x1ac));const a8_0x1e07=function(_0x4e2c90,_0x30a7db){_0x4e2c90=_0x4e2c90-0x0;let _0x1e07d2=a8_0x30a7[_0x4e2c90];return _0x1e07d2;};'use strict';Object['defineProperty'](exports,a8_0x1e07('0x3'),{'value':!![]});exports[a8_0x1e07('0x1')]=void 0x0;function splitTasksIntoStages(_0x33f846){const _0x568278=[];const _0x12e4a9=new Set(Object[a8_0x1e07('0x0')](_0x33f846[a8_0x1e07('0x2')])[a8_0x1e07('0x5')](_0x1389f7=>_0x1389f7['id']));let _0x1794c8=0x0;while(_0x12e4a9[a8_0x1e07('0x7')]>0x0){const _0x256384=_0x568278[_0x1794c8]=[];for(const _0x3f2eff of _0x12e4a9){let _0x318d7e=!![];for(const _0x11ae8f of _0x33f846[a8_0x1e07('0x8')][_0x3f2eff]){if(_0x12e4a9[a8_0x1e07('0x4')](_0x11ae8f)){_0x318d7e=![];break;}}if(!_0x318d7e){continue;}const _0x14527f=_0x33f846[a8_0x1e07('0x2')][_0x3f2eff];_0x256384[a8_0x1e07('0x6')](_0x14527f);}for(const _0xf1e01c of _0x256384){_0x12e4a9['delete'](_0xf1e01c['id']);}_0x1794c8++;}return _0x568278;}exports[a8_0x1e07('0x1')]=splitTasksIntoStages;
|
|
@@ -1,77 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TaskGraphCreator = void 0;
|
|
4
|
-
const { getDependencyConfigs } = require('../../../utilities/nx-imports');
|
|
5
|
-
/**
|
|
6
|
-
* This is only used for versions of Nx prior to 14 where the task graph
|
|
7
|
-
* wasn't part of the context so we have to recreate it
|
|
8
|
-
*/
|
|
9
|
-
class TaskGraphCreator {
|
|
10
|
-
constructor(projectGraph, defaultTargetDependencies) {
|
|
11
|
-
this.projectGraph = projectGraph;
|
|
12
|
-
this.defaultTargetDependencies = defaultTargetDependencies;
|
|
13
|
-
}
|
|
14
|
-
createTaskGraph(tasks) {
|
|
15
|
-
const graph = {
|
|
16
|
-
roots: [],
|
|
17
|
-
tasks: {},
|
|
18
|
-
dependencies: {},
|
|
19
|
-
};
|
|
20
|
-
for (const task of tasks) {
|
|
21
|
-
this.addTaskToGraph(task, graph);
|
|
22
|
-
const dependencyConfigs = getDependencyConfigs(task.target, this.defaultTargetDependencies, this.projectGraph);
|
|
23
|
-
if (!dependencyConfigs) {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
this.addTaskDependencies(task, dependencyConfigs, tasks, graph);
|
|
27
|
-
}
|
|
28
|
-
graph.roots = Object.keys(graph.dependencies).filter((k) => graph.dependencies[k].length === 0);
|
|
29
|
-
return graph;
|
|
30
|
-
}
|
|
31
|
-
addTaskDependencies(task, dependencyConfigs, tasks, graph) {
|
|
32
|
-
for (const dependencyConfig of dependencyConfigs) {
|
|
33
|
-
if (dependencyConfig.projects === 'self') {
|
|
34
|
-
for (const t of tasks) {
|
|
35
|
-
if (t.target.project === task.target.project &&
|
|
36
|
-
t.target.target === dependencyConfig.target) {
|
|
37
|
-
graph.dependencies[task.id].push(t.id);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else if (dependencyConfig.projects === 'dependencies') {
|
|
42
|
-
const seen = new Set();
|
|
43
|
-
this.addDependencies(task.target.project, dependencyConfig.target, tasks, graph, task.id, seen);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
addDependencies(project, target, tasks, graph, taskId, seen) {
|
|
48
|
-
seen.add(project);
|
|
49
|
-
const dependencies = this.projectGraph.dependencies[project];
|
|
50
|
-
if (dependencies) {
|
|
51
|
-
const projectDependencies = dependencies.map((dependency) => dependency.target);
|
|
52
|
-
for (const projectDependency of projectDependencies) {
|
|
53
|
-
if (seen.has(projectDependency)) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
const dependency = this.findTask({ project: projectDependency, target }, tasks);
|
|
57
|
-
if (dependency) {
|
|
58
|
-
if (graph.dependencies[taskId].indexOf(dependency.id) === -1) {
|
|
59
|
-
graph.dependencies[taskId].push(dependency.id);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
this.addDependencies(projectDependency, target, tasks, graph, taskId, seen);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
findTask({ project, target }, tasks) {
|
|
69
|
-
return tasks.find((t) => t.target.project === project && t.target.target === target);
|
|
70
|
-
}
|
|
71
|
-
addTaskToGraph(task, graph) {
|
|
72
|
-
graph.tasks[task.id] = task;
|
|
73
|
-
graph.dependencies[task.id] = [];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.TaskGraphCreator = TaskGraphCreator;
|
|
77
|
-
//# sourceMappingURL=task-graph-creator.js.map
|
|
1
|
+
const a9_0x4ad9=['push','../../../utilities/nx-imports','add','addDependencies','TaskGraphCreator','__esModule','target','createTaskGraph','dependencies','length','projects','defineProperty','defaultTargetDependencies','project','tasks','addTaskToGraph','projectGraph','filter','roots','self','map','keys','find','addTaskDependencies','findTask'];(function(_0x230844,_0x4ad9ab){const _0x2292bd=function(_0x600a7f){while(--_0x600a7f){_0x230844['push'](_0x230844['shift']());}};_0x2292bd(++_0x4ad9ab);}(a9_0x4ad9,0xf7));const a9_0x2292=function(_0x230844,_0x4ad9ab){_0x230844=_0x230844-0x0;let _0x2292bd=a9_0x4ad9[_0x230844];return _0x2292bd;};'use strict';Object[a9_0x2292('0xe')](exports,a9_0x2292('0x8'),{'value':!![]});exports[a9_0x2292('0x7')]=void 0x0;const {getDependencyConfigs}=require(a9_0x2292('0x4'));class TaskGraphCreator{constructor(_0x217409,_0x431248){this[a9_0x2292('0x13')]=_0x217409;this[a9_0x2292('0xf')]=_0x431248;}[a9_0x2292('0xa')](_0x39cccc){const _0x511b19={'roots':[],'tasks':{},'dependencies':{}};for(const _0x1342a8 of _0x39cccc){this[a9_0x2292('0x12')](_0x1342a8,_0x511b19);const _0x222527=getDependencyConfigs(_0x1342a8[a9_0x2292('0x9')],this[a9_0x2292('0xf')],this[a9_0x2292('0x13')]);if(!_0x222527){continue;}this['addTaskDependencies'](_0x1342a8,_0x222527,_0x39cccc,_0x511b19);}_0x511b19[a9_0x2292('0x15')]=Object[a9_0x2292('0x18')](_0x511b19[a9_0x2292('0xb')])[a9_0x2292('0x14')](_0x9b6841=>_0x511b19['dependencies'][_0x9b6841][a9_0x2292('0xc')]===0x0);return _0x511b19;}[a9_0x2292('0x1')](_0x387092,_0x4a816a,_0x1ec83a,_0x4a9acb){for(const _0x5b65da of _0x4a816a){if(_0x5b65da['projects']===a9_0x2292('0x16')){for(const _0x3eddd9 of _0x1ec83a){if(_0x3eddd9[a9_0x2292('0x9')][a9_0x2292('0x10')]===_0x387092['target'][a9_0x2292('0x10')]&&_0x3eddd9[a9_0x2292('0x9')]['target']===_0x5b65da[a9_0x2292('0x9')]){_0x4a9acb[a9_0x2292('0xb')][_0x387092['id']]['push'](_0x3eddd9['id']);}}}else if(_0x5b65da[a9_0x2292('0xd')]===a9_0x2292('0xb')){const _0x15d55b=new Set();this[a9_0x2292('0x6')](_0x387092[a9_0x2292('0x9')][a9_0x2292('0x10')],_0x5b65da['target'],_0x1ec83a,_0x4a9acb,_0x387092['id'],_0x15d55b);}}}[a9_0x2292('0x6')](_0x500d50,_0x52e52d,_0x2361b9,_0x4aae72,_0x424e67,_0x2f8ba6){_0x2f8ba6[a9_0x2292('0x5')](_0x500d50);const _0x3af6e4=this[a9_0x2292('0x13')][a9_0x2292('0xb')][_0x500d50];if(_0x3af6e4){const _0x474957=_0x3af6e4[a9_0x2292('0x17')](_0x14a6a4=>_0x14a6a4[a9_0x2292('0x9')]);for(const _0x36b7e5 of _0x474957){if(_0x2f8ba6['has'](_0x36b7e5)){continue;}const _0x9cc211=this[a9_0x2292('0x2')]({'project':_0x36b7e5,'target':_0x52e52d},_0x2361b9);if(_0x9cc211){if(_0x4aae72[a9_0x2292('0xb')][_0x424e67]['indexOf'](_0x9cc211['id'])===-0x1){_0x4aae72['dependencies'][_0x424e67][a9_0x2292('0x3')](_0x9cc211['id']);}}else{this[a9_0x2292('0x6')](_0x36b7e5,_0x52e52d,_0x2361b9,_0x4aae72,_0x424e67,_0x2f8ba6);}}}}[a9_0x2292('0x2')]({project,target},_0x27ada7){return _0x27ada7[a9_0x2292('0x0')](_0x5a2f66=>_0x5a2f66['target'][a9_0x2292('0x10')]===project&&_0x5a2f66['target']['target']===target);}[a9_0x2292('0x12')](_0x4a8516,_0xce4311){_0xce4311[a9_0x2292('0x11')][_0x4a8516['id']]=_0x4a8516;_0xce4311['dependencies'][_0x4a8516['id']]=[];}}exports[a9_0x2292('0x7')]=TaskGraphCreator;
|