@nrwl/nx-cloud 15.1.0-beta.3 → 15.1.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/lib/core/api/error-reporter.api.js +1 -36
- package/lib/core/api/run-group.api.js +1 -68
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -92
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -305
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -117
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -167
- package/lib/core/runners/cloud-enabled/id-generator.js +1 -16
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -80
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -293
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -143
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -241
- 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,36 +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.ErrorReporterApi = void 0;
|
|
13
|
-
const axios_1 = require("../../utilities/axios");
|
|
14
|
-
const { output } = require('../../utilities/nx-imports');
|
|
15
|
-
class ErrorReporterApi {
|
|
16
|
-
constructor(options) {
|
|
17
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
18
|
-
}
|
|
19
|
-
reportError(message) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
try {
|
|
22
|
-
yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', {
|
|
23
|
-
message,
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
output.warn({
|
|
28
|
-
title: `Unable to record the following error: '${message}'`,
|
|
29
|
-
bodyLines: [e.message],
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.ErrorReporterApi = ErrorReporterApi;
|
|
36
|
-
//# sourceMappingURL=error-reporter.api.js.map
|
|
1
|
+
const a0_0x2f9e=['then','__awaiter','message','../../utilities/axios','done','defineProperty','axiosMultipleTries','../../utilities/nx-imports','ErrorReporterApi','reportError','createApiAxiosInstance','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','__esModule','post','apiAxiosInstance','throw','apply','/nx-cloud/report-client-error','next','value'];(function(_0x588a66,_0x2f9e7a){const _0x4c75ed=function(_0x2a2170){while(--_0x2a2170){_0x588a66['push'](_0x588a66['shift']());}};_0x4c75ed(++_0x2f9e7a);}(a0_0x2f9e,0x1d8));const a0_0x4c75=function(_0x588a66,_0x2f9e7a){_0x588a66=_0x588a66-0x0;let _0x4c75ed=a0_0x2f9e[_0x588a66];return _0x4c75ed;};'use strict';var __awaiter=this&&this[a0_0x4c75('0x9')]||function(_0x379205,_0x3cb440,_0x5a5cef,_0x24755d){function _0x2f6a03(_0x25bd72){return _0x25bd72 instanceof _0x5a5cef?_0x25bd72:new _0x5a5cef(function(_0x598812){_0x598812(_0x25bd72);});}return new(_0x5a5cef||(_0x5a5cef=Promise))(function(_0x31c04e,_0x1b9549){function _0xdeb211(_0x4fd3d3){try{_0x56e1d5(_0x24755d[a0_0x4c75('0x6')](_0x4fd3d3));}catch(_0x303142){_0x1b9549(_0x303142);}}function _0x974dee(_0xe7b556){try{_0x56e1d5(_0x24755d[a0_0x4c75('0x3')](_0xe7b556));}catch(_0x5b1a02){_0x1b9549(_0x5b1a02);}}function _0x56e1d5(_0x58972e){_0x58972e[a0_0x4c75('0xc')]?_0x31c04e(_0x58972e[a0_0x4c75('0x7')]):_0x2f6a03(_0x58972e[a0_0x4c75('0x7')])[a0_0x4c75('0x8')](_0xdeb211,_0x974dee);}_0x56e1d5((_0x24755d=_0x24755d[a0_0x4c75('0x4')](_0x379205,_0x3cb440||[]))['next']());});};Object[a0_0x4c75('0xd')](exports,a0_0x4c75('0x0'),{'value':!![]});exports[a0_0x4c75('0x10')]=void 0x0;const axios_1=require(a0_0x4c75('0xb'));const {output}=require(a0_0x4c75('0xf'));class ErrorReporterApi{constructor(_0x1b5ef6){this[a0_0x4c75('0x2')]=(0x0,axios_1[a0_0x4c75('0x12')])(_0x1b5ef6);}[a0_0x4c75('0x11')](_0x1ae080){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x4c75('0xe')])(()=>this[a0_0x4c75('0x2')][a0_0x4c75('0x1')](a0_0x4c75('0x5'),{'message':_0x1ae080}));}catch(_0x2f04bb){output['warn']({'title':a0_0x4c75('0x13')+_0x1ae080+'\x27','bodyLines':[_0x2f04bb[a0_0x4c75('0xa')]]});}});}}exports[a0_0x4c75('0x10')]=ErrorReporterApi;
|
|
@@ -1,68 +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.RunGroupApi = void 0;
|
|
13
|
-
const axios_1 = require("../../utilities/axios");
|
|
14
|
-
const metric_logger_1 = require("../../utilities/metric-logger");
|
|
15
|
-
const { output } = require('../../utilities/nx-imports');
|
|
16
|
-
class RunGroupApi {
|
|
17
|
-
constructor(options) {
|
|
18
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
19
|
-
}
|
|
20
|
-
createRunGroup(branch, runGroup, stopAgentsOnFailure, agentCount, stopAgentsAfter) {
|
|
21
|
-
var _a;
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
24
|
-
try {
|
|
25
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
|
|
26
|
-
branch,
|
|
27
|
-
runGroup,
|
|
28
|
-
stopAgentsOnFailure,
|
|
29
|
-
agentCount,
|
|
30
|
-
stopAgentsAfter,
|
|
31
|
-
}));
|
|
32
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
36
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
37
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
38
|
-
output.error({
|
|
39
|
-
title: e.message,
|
|
40
|
-
});
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
completeRunGroup(runGroup) {
|
|
46
|
-
var _a;
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
49
|
-
try {
|
|
50
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
51
|
-
runGroup: runGroup,
|
|
52
|
-
}));
|
|
53
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
57
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
58
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
59
|
-
output.error({
|
|
60
|
-
title: e.message,
|
|
61
|
-
});
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.RunGroupApi = RunGroupApi;
|
|
68
|
-
//# sourceMappingURL=run-group.api.js.map
|
|
1
|
+
const a1_0x5b78=['defineProperty','completeRunGroup','message','/nx-cloud/executions/complete-run-group','RUNNER_FAILURE_PERF_ENTRY','recordMetric','RunGroupApi','post','createMetricRecorder','mapRespToPerfEntry','next','createRunGroup','__esModule','../../utilities/metric-logger','../../utilities/nx-imports','value','__awaiter','../../utilities/axios','done','then','error','exit','axiosException','axiosMultipleTries','apply','response','apiAxiosInstance','createApiAxiosInstance','throw'];(function(_0x420f89,_0x5b7826){const _0x24823e=function(_0x250ebe){while(--_0x250ebe){_0x420f89['push'](_0x420f89['shift']());}};_0x24823e(++_0x5b7826);}(a1_0x5b78,0x179));const a1_0x2482=function(_0x420f89,_0x5b7826){_0x420f89=_0x420f89-0x0;let _0x24823e=a1_0x5b78[_0x420f89];return _0x24823e;};'use strict';var __awaiter=this&&this[a1_0x2482('0x10')]||function(_0x1750a1,_0x2eb290,_0x4be0b2,_0x3e1fac){function _0x174cd0(_0x83e327){return _0x83e327 instanceof _0x4be0b2?_0x83e327:new _0x4be0b2(function(_0x2cba98){_0x2cba98(_0x83e327);});}return new(_0x4be0b2||(_0x4be0b2=Promise))(function(_0x55cd7e,_0x1d1cbb){function _0x478405(_0x5b90f4){try{_0xe5d0bd(_0x3e1fac[a1_0x2482('0xa')](_0x5b90f4));}catch(_0xcada7b){_0x1d1cbb(_0xcada7b);}}function _0x29a06f(_0x5355ce){try{_0xe5d0bd(_0x3e1fac[a1_0x2482('0x1c')](_0x5355ce));}catch(_0x2c3dfc){_0x1d1cbb(_0x2c3dfc);}}function _0xe5d0bd(_0x59e965){_0x59e965[a1_0x2482('0x12')]?_0x55cd7e(_0x59e965[a1_0x2482('0xf')]):_0x174cd0(_0x59e965[a1_0x2482('0xf')])[a1_0x2482('0x13')](_0x478405,_0x29a06f);}_0xe5d0bd((_0x3e1fac=_0x3e1fac[a1_0x2482('0x18')](_0x1750a1,_0x2eb290||[]))[a1_0x2482('0xa')]());});};Object[a1_0x2482('0x0')](exports,a1_0x2482('0xc'),{'value':!![]});exports[a1_0x2482('0x6')]=void 0x0;const axios_1=require(a1_0x2482('0x11'));const metric_logger_1=require(a1_0x2482('0xd'));const {output}=require(a1_0x2482('0xe'));class RunGroupApi{constructor(_0x32ab61){this[a1_0x2482('0x1a')]=(0x0,axios_1[a1_0x2482('0x1b')])(_0x32ab61);}['createRunGroup'](_0x2275af,_0x50120f,_0x590ee8,_0x5a5d52,_0x561f9c){var _0x1a0e66;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x26f8ac=(0x0,metric_logger_1['createMetricRecorder'])(a1_0x2482('0xb'));try{const _0x479a35=yield(0x0,axios_1[a1_0x2482('0x17')])(()=>this['apiAxiosInstance']['post']('/nx-cloud/executions/create-run-group',{'branch':_0x2275af,'runGroup':_0x50120f,'stopAgentsOnFailure':_0x590ee8,'agentCount':_0x5a5d52,'stopAgentsAfter':_0x561f9c}));_0x26f8ac[a1_0x2482('0x5')]((0x0,metric_logger_1[a1_0x2482('0x9')])(_0x479a35));}catch(_0x4048f4){_0x26f8ac[a1_0x2482('0x5')](((_0x1a0e66=_0x4048f4===null||_0x4048f4===void 0x0?void 0x0:_0x4048f4[a1_0x2482('0x16')])===null||_0x1a0e66===void 0x0?void 0x0:_0x1a0e66[a1_0x2482('0x19')])?(0x0,metric_logger_1[a1_0x2482('0x9')])(_0x4048f4[a1_0x2482('0x16')][a1_0x2482('0x19')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x2482('0x14')]({'title':_0x4048f4[a1_0x2482('0x2')]});process[a1_0x2482('0x15')](0x1);}});}[a1_0x2482('0x1')](_0x5e6e7d){var _0x11e004;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3e51aa=(0x0,metric_logger_1[a1_0x2482('0x8')])('createRunGroup');try{const _0x42064c=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a1_0x2482('0x1a')][a1_0x2482('0x7')](a1_0x2482('0x3'),{'runGroup':_0x5e6e7d}));_0x3e51aa[a1_0x2482('0x5')]((0x0,metric_logger_1[a1_0x2482('0x9')])(_0x42064c));}catch(_0x2f42b7){_0x3e51aa[a1_0x2482('0x5')](((_0x11e004=_0x2f42b7===null||_0x2f42b7===void 0x0?void 0x0:_0x2f42b7[a1_0x2482('0x16')])===null||_0x11e004===void 0x0?void 0x0:_0x11e004['response'])?(0x0,metric_logger_1[a1_0x2482('0x9')])(_0x2f42b7[a1_0x2482('0x16')]['response']):metric_logger_1[a1_0x2482('0x4')]);output[a1_0x2482('0x14')]({'title':_0x2f42b7[a1_0x2482('0x2')]});process[a1_0x2482('0x15')](0x1);}});}}exports[a1_0x2482('0x6')]=RunGroupApi;
|
|
@@ -1,92 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CloudEnabledLifeCycle = void 0;
|
|
4
|
-
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
5
|
-
const read_task_terminal_output_1 = require("../../terminal-output/read-task-terminal-output");
|
|
6
|
-
class CloudEnabledLifeCycle {
|
|
7
|
-
constructor(runContext, cacheDirectory, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
|
|
8
|
-
this.runContext = runContext;
|
|
9
|
-
this.cacheDirectory = cacheDirectory;
|
|
10
|
-
this.collectTerminalOutput = collectTerminalOutput;
|
|
11
|
-
this.cacheableOperations = cacheableOperations;
|
|
12
|
-
this.outputObfuscator = outputObfuscator;
|
|
13
|
-
this.tasks = tasks;
|
|
14
|
-
}
|
|
15
|
-
scheduleTask(task) {
|
|
16
|
-
this.runContext.scheduledTasks.push(task);
|
|
17
|
-
}
|
|
18
|
-
// this gets called for every tasks that starts.
|
|
19
|
-
startTask(task) {
|
|
20
|
-
this.tasks.push({
|
|
21
|
-
taskId: task.id,
|
|
22
|
-
startTime: new Date().toISOString(),
|
|
23
|
-
target: task.target.target,
|
|
24
|
-
projectName: task.target.project,
|
|
25
|
-
hash: task.hash,
|
|
26
|
-
hashDetails: this.cleanUpHashDetails(task.hashDetails),
|
|
27
|
-
params: (0, serializer_overrides_1.serializeOverrides)(task),
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
endTasks(tasks) {
|
|
31
|
-
// this can be called multiple times changing this time.
|
|
32
|
-
for (let t of tasks) {
|
|
33
|
-
let cacheStatus;
|
|
34
|
-
const taskIsRemoteCacheHit = t.status === 'remote-cache';
|
|
35
|
-
const taskIsLocalCacheHitPreNx135 = t.status === 'cache';
|
|
36
|
-
const taskIsLocalCacheHit = t.status === 'local-cache' ||
|
|
37
|
-
t.status === 'local-cache-kept-existing' ||
|
|
38
|
-
taskIsLocalCacheHitPreNx135;
|
|
39
|
-
if (this.runContext.statuses[t.task.hash]) {
|
|
40
|
-
cacheStatus = this.runContext.statuses[t.task.hash];
|
|
41
|
-
}
|
|
42
|
-
else if (taskIsRemoteCacheHit) {
|
|
43
|
-
cacheStatus = 'remote-cache-hit';
|
|
44
|
-
}
|
|
45
|
-
else if (taskIsLocalCacheHit) {
|
|
46
|
-
cacheStatus = 'local-cache-hit';
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
cacheStatus = 'cache-miss';
|
|
50
|
-
}
|
|
51
|
-
this.updateStartedTask(t, cacheStatus);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
endCommand() { }
|
|
55
|
-
updateStartedTask(result, cacheStatus) {
|
|
56
|
-
const startedTask = this.tasks.find((t) => t.taskId === result.task.id);
|
|
57
|
-
if (!startedTask) {
|
|
58
|
-
throw new Error(`Cannot find task ${result.task.id}`);
|
|
59
|
-
}
|
|
60
|
-
if ((result === null || result === void 0 ? void 0 : result.startTime) && (result === null || result === void 0 ? void 0 : result.endTime)) {
|
|
61
|
-
startedTask.startTime = new Date(result.startTime).toISOString();
|
|
62
|
-
startedTask.endTime = new Date(result.endTime).toISOString();
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
startedTask.endTime = new Date().toISOString();
|
|
66
|
-
}
|
|
67
|
-
startedTask.status = result.code;
|
|
68
|
-
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
|
|
69
|
-
startedTask.cacheStatus = cacheStatus;
|
|
70
|
-
if (this.collectTerminalOutput) {
|
|
71
|
-
startedTask.terminalOutput = this.getTerminalOutput(result.task.hash, startedTask.cacheStatus, result.code);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
getTerminalOutput(hash, cacheStatus, code) {
|
|
75
|
-
return (0, read_task_terminal_output_1.readTaskTerminalOutput)(this.cacheDirectory, this.outputObfuscator, hash, cacheStatus, code);
|
|
76
|
-
}
|
|
77
|
-
cleanUpHashDetails(hashDetails) {
|
|
78
|
-
const nodes = {};
|
|
79
|
-
Object.keys(hashDetails.nodes)
|
|
80
|
-
.filter((k) => !k.startsWith('npm:'))
|
|
81
|
-
.forEach((k) => {
|
|
82
|
-
nodes[k] = hashDetails.nodes[k];
|
|
83
|
-
});
|
|
84
|
-
return {
|
|
85
|
-
nodes,
|
|
86
|
-
runtime: hashDetails.runtime,
|
|
87
|
-
implicitDeps: hashDetails.implicitDeps,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
|
|
92
|
-
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
|
|
1
|
+
const a0_0x45c1=['outputObfuscator','toISOString','task','local-cache-hit','readTaskTerminalOutput','cacheDirectory','updateStartedTask','collectTerminalOutput','cache-miss','startTask','startTime','../../terminal-output/read-task-terminal-output','hash','hashDetails','local-cache-kept-existing','scheduleTask','cacheableOperations','filter','../../../utilities/serializer-overrides','params','nodes','endTime','project','getTerminalOutput','keys','runContext','cacheStatus','terminalOutput','startsWith','push','Cannot\x20find\x20task\x20','remote-cache-hit','obfuscate','runtime','CloudEnabledLifeCycle','find','local-cache','code','tasks','implicitDeps','cleanUpHashDetails','serializeOverrides','target','status'];(function(_0x205435,_0x45c1d1){const _0x251fa3=function(_0x4d542e){while(--_0x4d542e){_0x205435['push'](_0x205435['shift']());}};_0x251fa3(++_0x45c1d1);}(a0_0x45c1,0xeb));const a0_0x251f=function(_0x205435,_0x45c1d1){_0x205435=_0x205435-0x0;let _0x251fa3=a0_0x45c1[_0x205435];return _0x251fa3;};'use strict';Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a0_0x251f('0x13')]=void 0x0;const serializer_overrides_1=require(a0_0x251f('0x3'));const read_task_terminal_output_1=require(a0_0x251f('0x28'));class CloudEnabledLifeCycle{constructor(_0xc460dc,_0x1d9880,_0x1b0d15,_0x2dff86,_0x561e86,_0x1bbfce){this[a0_0x251f('0xa')]=_0xc460dc;this[a0_0x251f('0x22')]=_0x1d9880;this[a0_0x251f('0x24')]=_0x1b0d15;this[a0_0x251f('0x1')]=_0x2dff86;this[a0_0x251f('0x1d')]=_0x561e86;this[a0_0x251f('0x17')]=_0x1bbfce;}[a0_0x251f('0x0')](_0x3a119c){this[a0_0x251f('0xa')]['scheduledTasks'][a0_0x251f('0xe')](_0x3a119c);}[a0_0x251f('0x26')](_0x18e64f){this[a0_0x251f('0x17')]['push']({'taskId':_0x18e64f['id'],'startTime':new Date()[a0_0x251f('0x1e')](),'target':_0x18e64f[a0_0x251f('0x1b')][a0_0x251f('0x1b')],'projectName':_0x18e64f[a0_0x251f('0x1b')][a0_0x251f('0x7')],'hash':_0x18e64f[a0_0x251f('0x29')],'hashDetails':this[a0_0x251f('0x19')](_0x18e64f[a0_0x251f('0x2a')]),'params':(0x0,serializer_overrides_1[a0_0x251f('0x1a')])(_0x18e64f)});}['endTasks'](_0x4867c4){for(let _0x4252a0 of _0x4867c4){let _0x195dac;const _0x398904=_0x4252a0[a0_0x251f('0x1c')]==='remote-cache';const _0x43f5c9=_0x4252a0['status']==='cache';const _0x9c5afc=_0x4252a0[a0_0x251f('0x1c')]===a0_0x251f('0x15')||_0x4252a0[a0_0x251f('0x1c')]===a0_0x251f('0x2b')||_0x43f5c9;if(this['runContext']['statuses'][_0x4252a0[a0_0x251f('0x1f')]['hash']]){_0x195dac=this[a0_0x251f('0xa')]['statuses'][_0x4252a0[a0_0x251f('0x1f')][a0_0x251f('0x29')]];}else if(_0x398904){_0x195dac=a0_0x251f('0x10');}else if(_0x9c5afc){_0x195dac=a0_0x251f('0x20');}else{_0x195dac=a0_0x251f('0x25');}this[a0_0x251f('0x23')](_0x4252a0,_0x195dac);}}['endCommand'](){}[a0_0x251f('0x23')](_0x1fb175,_0x4e3563){const _0x228c6f=this[a0_0x251f('0x17')][a0_0x251f('0x14')](_0x44a7cb=>_0x44a7cb['taskId']===_0x1fb175[a0_0x251f('0x1f')]['id']);if(!_0x228c6f){throw new Error(a0_0x251f('0xf')+_0x1fb175[a0_0x251f('0x1f')]['id']);}if((_0x1fb175===null||_0x1fb175===void 0x0?void 0x0:_0x1fb175['startTime'])&&(_0x1fb175===null||_0x1fb175===void 0x0?void 0x0:_0x1fb175[a0_0x251f('0x6')])){_0x228c6f[a0_0x251f('0x27')]=new Date(_0x1fb175['startTime'])['toISOString']();_0x228c6f[a0_0x251f('0x6')]=new Date(_0x1fb175[a0_0x251f('0x6')])['toISOString']();}else{_0x228c6f[a0_0x251f('0x6')]=new Date()['toISOString']();}_0x228c6f['status']=_0x1fb175[a0_0x251f('0x16')];_0x228c6f['params']=this['outputObfuscator'][a0_0x251f('0x11')](_0x228c6f[a0_0x251f('0x4')]);_0x228c6f['cacheStatus']=_0x4e3563;if(this[a0_0x251f('0x24')]){_0x228c6f[a0_0x251f('0xc')]=this[a0_0x251f('0x8')](_0x1fb175[a0_0x251f('0x1f')]['hash'],_0x228c6f[a0_0x251f('0xb')],_0x1fb175[a0_0x251f('0x16')]);}}['getTerminalOutput'](_0x306e52,_0x3ea24e,_0x4193e8){return(0x0,read_task_terminal_output_1[a0_0x251f('0x21')])(this[a0_0x251f('0x22')],this[a0_0x251f('0x1d')],_0x306e52,_0x3ea24e,_0x4193e8);}[a0_0x251f('0x19')](_0x959d2d){const _0x9e4975={};Object[a0_0x251f('0x9')](_0x959d2d['nodes'])[a0_0x251f('0x2')](_0x1fb876=>!_0x1fb876[a0_0x251f('0xd')]('npm:'))['forEach'](_0x2d08b5=>{_0x9e4975[_0x2d08b5]=_0x959d2d[a0_0x251f('0x5')][_0x2d08b5];});return{'nodes':_0x9e4975,'runtime':_0x959d2d[a0_0x251f('0x12')],'implicitDeps':_0x959d2d[a0_0x251f('0x18')]};}}exports[a0_0x251f('0x13')]=CloudEnabledLifeCycle;
|
|
@@ -1,305 +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.cloudEnabledTasksRunner = void 0;
|
|
13
|
-
const message_reporter_1 = require("../../terminal-output/message-reporter");
|
|
14
|
-
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
|
|
15
|
-
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
|
|
16
|
-
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
|
|
17
|
-
const file_storage_1 = require("../../file-storage/file-storage");
|
|
18
|
-
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
|
|
19
|
-
const environment_1 = require("../../../utilities/environment");
|
|
20
|
-
const cloud_remote_cache_1 = require("./cloud-remote-cache");
|
|
21
|
-
const cloud_run_api_1 = require("./cloud-run.api");
|
|
22
|
-
const fs_1 = require("fs");
|
|
23
|
-
const path = require("path");
|
|
24
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
25
|
-
const error_reporter_api_1 = require("../../api/error-reporter.api");
|
|
26
|
-
const path_1 = require("path");
|
|
27
|
-
const fs_extra_1 = require("fs-extra");
|
|
28
|
-
const id_generator_1 = require("./id-generator");
|
|
29
|
-
const { tasksRunner, output, Cache } = require('../../../utilities/nx-imports');
|
|
30
|
-
function createApi(errors, options, runContext) {
|
|
31
|
-
const machineInfo = (0, environment_1.getMachineInfo)(options);
|
|
32
|
-
return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
|
|
33
|
-
}
|
|
34
|
-
function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
|
|
35
|
-
const hashes = JSON.stringify(taskExecutions.map((t) => ({
|
|
36
|
-
taskId: t.taskId,
|
|
37
|
-
hash: t.hash,
|
|
38
|
-
})));
|
|
39
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
40
|
-
output.note({
|
|
41
|
-
title: `Executed tasks with hashes: ${hashes}`,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
(0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
|
|
45
|
-
}
|
|
46
|
-
/*
|
|
47
|
-
* It can happen that a task is executed multiple times on an agent, say for DTE1 and DTE2.
|
|
48
|
-
* When it runs for DTE2, it will be a local cache hit, so it will be marked as completed.
|
|
49
|
-
* However, Nx won't upload an artifact to S3 in this case. Usually this isn't a problem,
|
|
50
|
-
* cause the first DTE would have uploaded it. But if you are using a DTE, with a read-only token,
|
|
51
|
-
* the uploaded artifact will have a different scoped hash.
|
|
52
|
-
*
|
|
53
|
-
* To address this: we are finding all local cache hits, and upload everything that has a put url.
|
|
54
|
-
*/
|
|
55
|
-
function storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory) {
|
|
56
|
-
const hashes = taskExecutions
|
|
57
|
-
.filter((t) => t.cacheStatus === 'local-cache-hit')
|
|
58
|
-
.map((t) => t.hash);
|
|
59
|
-
hashes.forEach((hash) => remoteCache.store(hash, nxCacheDirectory));
|
|
60
|
-
}
|
|
61
|
-
function onComplete({ daemon, lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner, encryptionKey, fileStorage, uploadInCurrentProcess, runContext, }) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const runEndTime = new Date().toISOString();
|
|
64
|
-
const branch = (0, environment_1.getBranch)();
|
|
65
|
-
const runData = {
|
|
66
|
-
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
|
|
67
|
-
startTime: runStartTime,
|
|
68
|
-
endTime: runEndTime,
|
|
69
|
-
distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
|
|
70
|
-
branch: branch,
|
|
71
|
-
scan: true,
|
|
72
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
73
|
-
// only set sha if branch is set because we invoke a separate process,
|
|
74
|
-
// which adds a few millis
|
|
75
|
-
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
|
|
76
|
-
inner: inner,
|
|
77
|
-
};
|
|
78
|
-
if (uploadInCurrentProcess) {
|
|
79
|
-
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
|
|
80
|
-
const nxCacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
|
|
81
|
-
storeTaskHashes(taskExecutions, nxCacheDirectory, environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
|
|
82
|
-
storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory);
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
yield remoteCache.waitForStoreRequestsToComplete();
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
output.error({
|
|
89
|
-
title: `Nx Cloud wasn't able to store artifacts.`,
|
|
90
|
-
});
|
|
91
|
-
messages.printMessages();
|
|
92
|
-
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
yield api.endRun(runData, taskExecutions);
|
|
96
|
-
}
|
|
97
|
-
catch (e) {
|
|
98
|
-
output.error({
|
|
99
|
-
title: `Nx Cloud wasn't able to record its run.`,
|
|
100
|
-
});
|
|
101
|
-
messages.printMessages();
|
|
102
|
-
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
103
|
-
}
|
|
104
|
-
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
try {
|
|
108
|
-
const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken;
|
|
109
|
-
const linkId = (0, id_generator_1.generateUniqueLinkId)();
|
|
110
|
-
yield daemon.processInBackground('@nrwl/nx-cloud/lib/daemon/process-run-end', {
|
|
111
|
-
encryptionKey,
|
|
112
|
-
runnerOptions: Object.assign(Object.assign({}, options), { accessToken }),
|
|
113
|
-
uploads: fileStorage.uploads,
|
|
114
|
-
runEnd: {
|
|
115
|
-
runData,
|
|
116
|
-
taskExecutions,
|
|
117
|
-
linkId,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
runContext.runUrl = `${options.url || 'https://nx.app'}/runs/${linkId}`;
|
|
121
|
-
}
|
|
122
|
-
catch (e) {
|
|
123
|
-
output.warn({
|
|
124
|
-
title: `Nx Cloud Problems`,
|
|
125
|
-
bodyLines: [e.message || e.toString()],
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// this workaround is required because prior to Nx 13.3 we printed
|
|
130
|
-
// the end message after the runner completes, so we need to wait for the
|
|
131
|
-
// message to appear in the right place
|
|
132
|
-
if (versionOfNxBefore133) {
|
|
133
|
-
setTimeout(() => {
|
|
134
|
-
messages.printMessages();
|
|
135
|
-
if (!messages.anyErrors && !inner) {
|
|
136
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
137
|
-
}
|
|
138
|
-
}, 0);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
messages.printMessages();
|
|
142
|
-
if (!messages.anyErrors && !inner) {
|
|
143
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
|
|
149
|
-
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, (0, environment_1.getNxCacheDirectory)(options), options.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
|
|
150
|
-
try {
|
|
151
|
-
const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
|
|
152
|
-
if (!CompositeLifeCycle)
|
|
153
|
-
return cloudEnabledLifeCycle;
|
|
154
|
-
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
|
|
155
|
-
}
|
|
156
|
-
catch (e) {
|
|
157
|
-
return cloudEnabledLifeCycle;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options) {
|
|
161
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
let hashes = tasks.map((t) => t.hash).filter((h) => !!h);
|
|
163
|
-
const c = new Cache(options);
|
|
164
|
-
if (!options.skipNxCache) {
|
|
165
|
-
// filter out the urls that don't have artifact stored locally
|
|
166
|
-
const promises = yield Promise.all(hashes.map((hash) => {
|
|
167
|
-
const tdCommit = (0, path_1.join)(c.cachePath, `${hash}.commit`);
|
|
168
|
-
return (0, fs_extra_1.pathExists)(tdCommit);
|
|
169
|
-
}));
|
|
170
|
-
const missingHashes = [];
|
|
171
|
-
for (let i = 0; i < promises.length; ++i) {
|
|
172
|
-
if (promises[i]) {
|
|
173
|
-
missingHashes.push(hashes[i]);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
hashes = missingHashes;
|
|
177
|
-
}
|
|
178
|
-
if (hashes.length > 0) {
|
|
179
|
-
const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
|
|
180
|
-
for (const hash of hashes) {
|
|
181
|
-
runContext.requests[hash] = startRunRequest;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
function isConnectedToPrivateCloud(options) {
|
|
187
|
-
if (!options.url)
|
|
188
|
-
return false;
|
|
189
|
-
if (options.url.endsWith('api.nrwl.io'))
|
|
190
|
-
return false;
|
|
191
|
-
if (options.url.endsWith('.nx.app'))
|
|
192
|
-
return false;
|
|
193
|
-
if (options.url.indexOf('localhost') > -1)
|
|
194
|
-
return false;
|
|
195
|
-
return true;
|
|
196
|
-
}
|
|
197
|
-
function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
|
|
198
|
-
var _a;
|
|
199
|
-
const runContext = {
|
|
200
|
-
statuses: {},
|
|
201
|
-
scheduledTasks: [],
|
|
202
|
-
requests: {},
|
|
203
|
-
allTasks: tasks,
|
|
204
|
-
};
|
|
205
|
-
const versionOfNxBefore133 = options.lifeCycle === undefined;
|
|
206
|
-
const taskExecutions = [];
|
|
207
|
-
const messages = new message_reporter_1.MessageReporter(options);
|
|
208
|
-
const api = createApi(messages, options, runContext);
|
|
209
|
-
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions);
|
|
210
|
-
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
|
|
211
|
-
const runStartTime = new Date().toISOString();
|
|
212
|
-
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
|
|
213
|
-
const encryptionKey = environment_1.ENCRYPTION_KEY || options.encryptionKey;
|
|
214
|
-
const encryption = new e2e_encryption_1.E2EEncryption(encryptionKey);
|
|
215
|
-
const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
|
|
216
|
-
const uploadInCurrentProcess = !!environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION ||
|
|
217
|
-
!((_a = context.daemon) === null || _a === void 0 ? void 0 : _a.enabled()) ||
|
|
218
|
-
isConnectedToPrivateCloud(options);
|
|
219
|
-
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, false, uploadInCurrentProcess);
|
|
220
|
-
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
|
|
221
|
-
// we don't await for it cause this step is optional
|
|
222
|
-
fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options);
|
|
223
|
-
// have to reset it so we don't capture inner tasks
|
|
224
|
-
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
|
|
225
|
-
const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
|
|
226
|
-
// observable -> legacy
|
|
227
|
-
if (res.subscribe) {
|
|
228
|
-
const { Subject } = require('rxjs/internal/Subject');
|
|
229
|
-
const wrappedRes = new Subject();
|
|
230
|
-
res.subscribe({
|
|
231
|
-
next: (value) => wrappedRes.next(value),
|
|
232
|
-
error: (err) => wrappedRes.error(err),
|
|
233
|
-
complete: () => __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
yield onComplete({
|
|
235
|
-
daemon: context.daemon,
|
|
236
|
-
lifeCycle,
|
|
237
|
-
options,
|
|
238
|
-
remoteCache,
|
|
239
|
-
api,
|
|
240
|
-
outputObfuscator,
|
|
241
|
-
runStartTime,
|
|
242
|
-
messages,
|
|
243
|
-
endOfRunMessage,
|
|
244
|
-
taskExecutions,
|
|
245
|
-
versionOfNxBefore133,
|
|
246
|
-
inner,
|
|
247
|
-
encryptionKey,
|
|
248
|
-
fileStorage,
|
|
249
|
-
uploadInCurrentProcess,
|
|
250
|
-
runContext,
|
|
251
|
-
});
|
|
252
|
-
wrappedRes.complete();
|
|
253
|
-
}),
|
|
254
|
-
});
|
|
255
|
-
return wrappedRes;
|
|
256
|
-
// promise
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
return res
|
|
260
|
-
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
261
|
-
yield onComplete({
|
|
262
|
-
daemon: context.daemon,
|
|
263
|
-
lifeCycle,
|
|
264
|
-
options,
|
|
265
|
-
remoteCache,
|
|
266
|
-
api,
|
|
267
|
-
outputObfuscator,
|
|
268
|
-
runStartTime,
|
|
269
|
-
messages,
|
|
270
|
-
endOfRunMessage,
|
|
271
|
-
taskExecutions,
|
|
272
|
-
versionOfNxBefore133,
|
|
273
|
-
inner,
|
|
274
|
-
encryptionKey,
|
|
275
|
-
fileStorage,
|
|
276
|
-
uploadInCurrentProcess,
|
|
277
|
-
runContext,
|
|
278
|
-
});
|
|
279
|
-
return r;
|
|
280
|
-
}))
|
|
281
|
-
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
282
|
-
yield onComplete({
|
|
283
|
-
daemon: context.daemon,
|
|
284
|
-
lifeCycle,
|
|
285
|
-
options,
|
|
286
|
-
remoteCache,
|
|
287
|
-
api,
|
|
288
|
-
outputObfuscator,
|
|
289
|
-
runStartTime,
|
|
290
|
-
messages,
|
|
291
|
-
endOfRunMessage,
|
|
292
|
-
taskExecutions,
|
|
293
|
-
versionOfNxBefore133,
|
|
294
|
-
inner,
|
|
295
|
-
encryptionKey,
|
|
296
|
-
fileStorage,
|
|
297
|
-
uploadInCurrentProcess,
|
|
298
|
-
runContext,
|
|
299
|
-
});
|
|
300
|
-
throw e;
|
|
301
|
-
}));
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
|
|
305
|
-
//# sourceMappingURL=cloud-enabled.runner.js.map
|
|
1
|
+
const a1_0x4068=['Executed\x20tasks\x20with\x20hashes:\x20','./id-generator','error','apply','hash','OutputObfuscator','skipNxCache','.commit','store','printMessages','FileStorage','maskedProperties','./cloud-run.api','map','runUrl','filter','anyErrors','fs-extra','generateUniqueLinkId','getBranch','cachePath','join','endsWith','value','../../terminal-output/end-of-run-message','done','extractGitSha','getNxCacheDirectory','message','accessToken','stringify','indexOf','../../../utilities/nx-imports','getMachineInfo','obfuscate','defineProperty','toString','ENCRYPTION_KEY','/runs/','url','endRun','rxjs/internal/Subject','taskId','EndOfRunMessage','../../../utilities/metric-logger','cloudEnabledTasksRunner','scan','../../file-storage/e2e-encryption','waitForStoreRequestsToComplete','E2EEncryption','then','../../file-storage/file-storage','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','MessageReporter','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','__awaiter','push','../../api/error-reporter.api','cacheableOperations','@nrwl/nx-cloud/lib/daemon/process-run-end','path','daemon','exit','warn','./cloud-remote-cache','subscribe','.nx.app','api.nrwl.io','assign','next','startRun','note','cacheStatus','https://nx.app','CloudRemoteCache','forEach','lifeCycle','ErrorReporterApi','VERBOSE_LOGGING','complete','length','tasks-hashes-','../../../utilities/environment','writeFileSync','uploads','./cloud-enabled-life-cycle','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','throw','local-cache-hit','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','requests','toISOString'];(function(_0x3e827d,_0x406831){const _0x500bcf=function(_0x2fd1ad){while(--_0x2fd1ad){_0x3e827d['push'](_0x3e827d['shift']());}};_0x500bcf(++_0x406831);}(a1_0x4068,0x16a));const a1_0x500b=function(_0x3e827d,_0x406831){_0x3e827d=_0x3e827d-0x0;let _0x500bcf=a1_0x4068[_0x3e827d];return _0x500bcf;};'use strict';var __awaiter=this&&this[a1_0x500b('0x3d')]||function(_0x39f253,_0x55f415,_0x254bb3,_0x2eb5ed){function _0x31e6a6(_0x3f5e53){return _0x3f5e53 instanceof _0x254bb3?_0x3f5e53:new _0x254bb3(function(_0x502195){_0x502195(_0x3f5e53);});}return new(_0x254bb3||(_0x254bb3=Promise))(function(_0x2d25f7,_0x2fc6e2){function _0x1910f6(_0x3b5c3d){try{_0x15309c(_0x2eb5ed[a1_0x500b('0x4b')](_0x3b5c3d));}catch(_0xc10340){_0x2fc6e2(_0xc10340);}}function _0x9151d4(_0xc7afa3){try{_0x15309c(_0x2eb5ed[a1_0x500b('0x1')](_0xc7afa3));}catch(_0x535f8c){_0x2fc6e2(_0x535f8c);}}function _0x15309c(_0x2739f2){_0x2739f2[a1_0x500b('0x1f')]?_0x2d25f7(_0x2739f2[a1_0x500b('0x1d')]):_0x31e6a6(_0x2739f2[a1_0x500b('0x1d')])[a1_0x500b('0x38')](_0x1910f6,_0x9151d4);}_0x15309c((_0x2eb5ed=_0x2eb5ed[a1_0x500b('0x9')](_0x39f253,_0x55f415||[]))[a1_0x500b('0x4b')]());});};Object[a1_0x500b('0x29')](exports,'__esModule',{'value':!![]});exports['cloudEnabledTasksRunner']=void 0x0;const message_reporter_1=require('../../terminal-output/message-reporter');const end_of_run_message_1=require(a1_0x500b('0x1e'));const output_obfuscator_1=require('../../terminal-output/output-obfuscator');const cloud_enabled_life_cycle_1=require(a1_0x500b('0x5b'));const file_storage_1=require(a1_0x500b('0x39'));const e2e_encryption_1=require(a1_0x500b('0x35'));const environment_1=require(a1_0x500b('0x58'));const cloud_remote_cache_1=require(a1_0x500b('0x46'));const cloud_run_api_1=require(a1_0x500b('0x12'));const fs_1=require('fs');const path=require(a1_0x500b('0x42'));const metric_logger_1=require(a1_0x500b('0x32'));const error_reporter_api_1=require(a1_0x500b('0x3f'));const path_1=require(a1_0x500b('0x42'));const fs_extra_1=require(a1_0x500b('0x17'));const id_generator_1=require(a1_0x500b('0x7'));const {tasksRunner,output,Cache}=require(a1_0x500b('0x26'));function createApi(_0x20e02d,_0x25d7fa,_0x22df8e){const _0x43246e=(0x0,environment_1[a1_0x500b('0x27')])(_0x25d7fa);return new cloud_run_api_1['CloudRunApi'](_0x20e02d,_0x22df8e,_0x25d7fa,_0x43246e);}function storeTaskHashes(_0x442c6a,_0x490662,_0x4b33ff){const _0x8dc119=JSON[a1_0x500b('0x24')](_0x442c6a[a1_0x500b('0x13')](_0x3ab608=>({'taskId':_0x3ab608[a1_0x500b('0x30')],'hash':_0x3ab608['hash']})));if(environment_1[a1_0x500b('0x54')]){output[a1_0x500b('0x4d')]({'title':a1_0x500b('0x6')+_0x8dc119});}(0x0,fs_1[a1_0x500b('0x59')])(path[a1_0x500b('0x1b')](_0x490662,a1_0x500b('0x57')+_0x4b33ff),_0x8dc119);}function storeLocalCacheHits(_0x2b0d92,_0x206945,_0x31e54d){const _0x17d498=_0x2b0d92[a1_0x500b('0x15')](_0x4b3ef2=>_0x4b3ef2[a1_0x500b('0x4e')]===a1_0x500b('0x2'))[a1_0x500b('0x13')](_0x2ce884=>_0x2ce884[a1_0x500b('0xa')]);_0x17d498[a1_0x500b('0x51')](_0xf769b8=>_0x206945[a1_0x500b('0xe')](_0xf769b8,_0x31e54d));}function onComplete({daemon,lifeCycle,options,remoteCache,api,outputObfuscator,runStartTime,messages,endOfRunMessage,taskExecutions,versionOfNxBefore133,inner,encryptionKey,fileStorage,uploadInCurrentProcess,runContext}){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x190c96=new Date()[a1_0x500b('0x5')]();const _0xee220e=(0x0,environment_1[a1_0x500b('0x19')])();const _0x3f6499={'command':outputObfuscator[a1_0x500b('0x28')]((0x0,environment_1['parseCommand'])()),'startTime':runStartTime,'endTime':_0x190c96,'distributedExecutionId':environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],'branch':_0xee220e,'scan':!![],'runGroup':(0x0,environment_1['getRunGroup'])(),'sha':_0xee220e?(0x0,environment_1[a1_0x500b('0x20')])():undefined,'inner':inner};if(uploadInCurrentProcess){if(environment_1[a1_0x500b('0x3a')]){const _0x579d30=(0x0,environment_1[a1_0x500b('0x21')])(options);storeTaskHashes(taskExecutions,_0x579d30,environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID']);storeLocalCacheHits(taskExecutions,remoteCache,_0x579d30);}try{yield remoteCache[a1_0x500b('0x36')]();}catch(_0x286cfc){output[a1_0x500b('0x8')]({'title':a1_0x500b('0x3')});messages[a1_0x500b('0xf')]();process[a1_0x500b('0x44')](environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']);}try{yield api[a1_0x500b('0x2e')](_0x3f6499,taskExecutions);}catch(_0x2ab4b1){output[a1_0x500b('0x8')]({'title':'Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.'});messages['printMessages']();process[a1_0x500b('0x44')](environment_1[a1_0x500b('0x3c')]);}yield(0x0,metric_logger_1['submitRunMetrics'])(options);}else{try{const _0x3762f6=environment_1['ACCESS_TOKEN']?environment_1['ACCESS_TOKEN']:options[a1_0x500b('0x23')];const _0x2a3e28=(0x0,id_generator_1[a1_0x500b('0x18')])();yield daemon['processInBackground'](a1_0x500b('0x41'),{'encryptionKey':encryptionKey,'runnerOptions':Object[a1_0x500b('0x4a')](Object[a1_0x500b('0x4a')]({},options),{'accessToken':_0x3762f6}),'uploads':fileStorage[a1_0x500b('0x5a')],'runEnd':{'runData':_0x3f6499,'taskExecutions':taskExecutions,'linkId':_0x2a3e28}});runContext[a1_0x500b('0x14')]=(options[a1_0x500b('0x2d')]||a1_0x500b('0x4f'))+a1_0x500b('0x2c')+_0x2a3e28;}catch(_0x204b57){output[a1_0x500b('0x45')]({'title':'Nx\x20Cloud\x20Problems','bodyLines':[_0x204b57[a1_0x500b('0x22')]||_0x204b57[a1_0x500b('0x2a')]()]});}}if(versionOfNxBefore133){setTimeout(()=>{messages['printMessages']();if(!messages['anyErrors']&&!inner){endOfRunMessage['printCacheHitsMessage']();}},0x0);}else{messages[a1_0x500b('0xf')]();if(!messages[a1_0x500b('0x16')]&&!inner){endOfRunMessage['printCacheHitsMessage']();}}});}function createLifeCycle(_0x432cd5,_0x2b5727,_0x231323,_0x5a1d73){const _0x56fbaa=new cloud_enabled_life_cycle_1['CloudEnabledLifeCycle'](_0x432cd5,(0x0,environment_1['getNxCacheDirectory'])(_0x2b5727),_0x2b5727[a1_0x500b('0x34')]===undefined?!![]:_0x2b5727[a1_0x500b('0x34')],_0x2b5727[a1_0x500b('0x40')]||[],_0x231323,_0x5a1d73);try{const {CompositeLifeCycle}=require(a1_0x500b('0x26'));if(!CompositeLifeCycle)return _0x56fbaa;return new CompositeLifeCycle([_0x2b5727['lifeCycle'],_0x56fbaa]);}catch(_0x15c37d){return _0x56fbaa;}}function fetchUrlsForKnownHashesUpfront(_0x403538,_0x37c2ca,_0x40351a,_0x1f7577){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x2b2137=_0x40351a[a1_0x500b('0x13')](_0x391303=>_0x391303[a1_0x500b('0xa')])[a1_0x500b('0x15')](_0xe05753=>!!_0xe05753);const _0x57c7bc=new Cache(_0x1f7577);if(!_0x1f7577[a1_0x500b('0xc')]){const _0x55ddec=yield Promise['all'](_0x2b2137[a1_0x500b('0x13')](_0x1c2b83=>{const _0x5ee90c=(0x0,path_1[a1_0x500b('0x1b')])(_0x57c7bc[a1_0x500b('0x1a')],_0x1c2b83+a1_0x500b('0xd'));return(0x0,fs_extra_1['pathExists'])(_0x5ee90c);}));const _0x2504d3=[];for(let _0x504881=0x0;_0x504881<_0x55ddec[a1_0x500b('0x56')];++_0x504881){if(_0x55ddec[_0x504881]){_0x2504d3[a1_0x500b('0x3e')](_0x2b2137[_0x504881]);}}_0x2b2137=_0x2504d3;}if(_0x2b2137[a1_0x500b('0x56')]>0x0){const _0x2e6a05=_0x403538[a1_0x500b('0x4c')](environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],_0x2b2137);for(const _0x15ae00 of _0x2b2137){_0x37c2ca[a1_0x500b('0x4')][_0x15ae00]=_0x2e6a05;}}});}function isConnectedToPrivateCloud(_0x5ebc53){if(!_0x5ebc53[a1_0x500b('0x2d')])return![];if(_0x5ebc53[a1_0x500b('0x2d')][a1_0x500b('0x1c')](a1_0x500b('0x49')))return![];if(_0x5ebc53['url'][a1_0x500b('0x1c')](a1_0x500b('0x48')))return![];if(_0x5ebc53[a1_0x500b('0x2d')][a1_0x500b('0x25')]('localhost')>-0x1)return![];return!![];}function cloudEnabledTasksRunner(_0x4d3251,_0xcc0922,_0xa8daa,_0x2f40ca=![]){var _0x1312a5;const _0x2022d4={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x4d3251};const _0x1e7fb6=_0xcc0922[a1_0x500b('0x52')]===undefined;const _0x31abf8=[];const _0x42fd9c=new message_reporter_1[(a1_0x500b('0x3b'))](_0xcc0922);const _0x5af8d4=createApi(_0x42fd9c,_0xcc0922,_0x2022d4);const _0x53a51a=new end_of_run_message_1[(a1_0x500b('0x31'))](_0x2022d4,_0x31abf8);const _0x3fb6db=new output_obfuscator_1[(a1_0x500b('0xb'))](_0xcc0922[a1_0x500b('0x11')]);const _0x360ab8=new Date()['toISOString']();const _0x3335ae=createLifeCycle(_0x2022d4,_0xcc0922,_0x3fb6db,_0x31abf8);const _0x36b7a3=environment_1[a1_0x500b('0x2b')]||_0xcc0922['encryptionKey'];const _0x3e2529=new e2e_encryption_1[(a1_0x500b('0x37'))](_0x36b7a3);const _0x1565d5=new error_reporter_api_1[(a1_0x500b('0x53'))](_0xcc0922);const _0x35a7d8=!!environment_1[a1_0x500b('0x3a')]||!((_0x1312a5=_0xa8daa[a1_0x500b('0x43')])===null||_0x1312a5===void 0x0?void 0x0:_0x1312a5['enabled']())||isConnectedToPrivateCloud(_0xcc0922);const _0x5b7e76=new file_storage_1[(a1_0x500b('0x10'))](_0x3e2529,_0x1565d5,![],_0x35a7d8);const _0x4bc6d2=new cloud_remote_cache_1[(a1_0x500b('0x50'))](_0x42fd9c,_0x5af8d4,_0x2022d4,_0x5b7e76);fetchUrlsForKnownHashesUpfront(_0x5af8d4,_0x2022d4,_0x4d3251,_0xcc0922);delete process['env'][a1_0x500b('0x0')];const _0x4654c4=tasksRunner(_0x4d3251,Object[a1_0x500b('0x4a')](Object[a1_0x500b('0x4a')]({},_0xcc0922),{'remoteCache':_0x4bc6d2,'lifeCycle':_0x3335ae}),_0xa8daa);if(_0x4654c4[a1_0x500b('0x47')]){const {Subject}=require(a1_0x500b('0x2f'));const _0x4a083e=new Subject();_0x4654c4[a1_0x500b('0x47')]({'next':_0xd87ef6=>_0x4a083e['next'](_0xd87ef6),'error':_0x124129=>_0x4a083e[a1_0x500b('0x8')](_0x124129),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0xa8daa['daemon'],'lifeCycle':_0x3335ae,'options':_0xcc0922,'remoteCache':_0x4bc6d2,'api':_0x5af8d4,'outputObfuscator':_0x3fb6db,'runStartTime':_0x360ab8,'messages':_0x42fd9c,'endOfRunMessage':_0x53a51a,'taskExecutions':_0x31abf8,'versionOfNxBefore133':_0x1e7fb6,'inner':_0x2f40ca,'encryptionKey':_0x36b7a3,'fileStorage':_0x5b7e76,'uploadInCurrentProcess':_0x35a7d8,'runContext':_0x2022d4});_0x4a083e[a1_0x500b('0x55')]();})});return _0x4a083e;}else{return _0x4654c4[a1_0x500b('0x38')](_0x52bf86=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0xa8daa[a1_0x500b('0x43')],'lifeCycle':_0x3335ae,'options':_0xcc0922,'remoteCache':_0x4bc6d2,'api':_0x5af8d4,'outputObfuscator':_0x3fb6db,'runStartTime':_0x360ab8,'messages':_0x42fd9c,'endOfRunMessage':_0x53a51a,'taskExecutions':_0x31abf8,'versionOfNxBefore133':_0x1e7fb6,'inner':_0x2f40ca,'encryptionKey':_0x36b7a3,'fileStorage':_0x5b7e76,'uploadInCurrentProcess':_0x35a7d8,'runContext':_0x2022d4});return _0x52bf86;}))['catch'](_0x447298=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0xa8daa[a1_0x500b('0x43')],'lifeCycle':_0x3335ae,'options':_0xcc0922,'remoteCache':_0x4bc6d2,'api':_0x5af8d4,'outputObfuscator':_0x3fb6db,'runStartTime':_0x360ab8,'messages':_0x42fd9c,'endOfRunMessage':_0x53a51a,'taskExecutions':_0x31abf8,'versionOfNxBefore133':_0x1e7fb6,'inner':_0x2f40ca,'encryptionKey':_0x36b7a3,'fileStorage':_0x5b7e76,'uploadInCurrentProcess':_0x35a7d8,'runContext':_0x2022d4});throw _0x447298;}));}}exports[a1_0x500b('0x33')]=cloudEnabledTasksRunner;
|