@nrwl/nx-cloud 14.7.0-beta.1 → 15.0.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 -156
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -288
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -113
- 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 -79
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -263
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -143
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -220
- 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/lib/utilities/nx-imports.js +3 -0
- package/lib/utilities/nx-imports.js.map +1 -1
- package/package.json +2 -2
- package/project.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_0x5898=['then','reportError','post','__esModule','ErrorReporterApi','axiosMultipleTries','done','../../utilities/nx-imports','next','apply','value','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','apiAxiosInstance'];(function(_0x42528d,_0x5898e7){const _0x4afb46=function(_0x561246){while(--_0x561246){_0x42528d['push'](_0x42528d['shift']());}};_0x4afb46(++_0x5898e7);}(a0_0x5898,0x17a));const a0_0x4afb=function(_0x42528d,_0x5898e7){_0x42528d=_0x42528d-0x0;let _0x4afb46=a0_0x5898[_0x42528d];return _0x4afb46;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x35d600,_0x2ada5f,_0x243740,_0x13b142){function _0x275743(_0x20637d){return _0x20637d instanceof _0x243740?_0x20637d:new _0x243740(function(_0x339889){_0x339889(_0x20637d);});}return new(_0x243740||(_0x243740=Promise))(function(_0x1457df,_0x5713ac){function _0x31a50e(_0x193cf4){try{_0x356438(_0x13b142[a0_0x4afb('0x7')](_0x193cf4));}catch(_0x714921){_0x5713ac(_0x714921);}}function _0xe18289(_0x4239d1){try{_0x356438(_0x13b142['throw'](_0x4239d1));}catch(_0x94ba4a){_0x5713ac(_0x94ba4a);}}function _0x356438(_0x2d40a8){_0x2d40a8[a0_0x4afb('0x5')]?_0x1457df(_0x2d40a8[a0_0x4afb('0x9')]):_0x275743(_0x2d40a8[a0_0x4afb('0x9')])[a0_0x4afb('0xc')](_0x31a50e,_0xe18289);}_0x356438((_0x13b142=_0x13b142[a0_0x4afb('0x8')](_0x35d600,_0x2ada5f||[]))[a0_0x4afb('0x7')]());});};Object['defineProperty'](exports,a0_0x4afb('0x2'),{'value':!![]});exports[a0_0x4afb('0x3')]=void 0x0;const axios_1=require('../../utilities/axios');const {output}=require(a0_0x4afb('0x6'));class ErrorReporterApi{constructor(_0x12731c){this[a0_0x4afb('0xb')]=(0x0,axios_1['createApiAxiosInstance'])(_0x12731c);}[a0_0x4afb('0x0')](_0x5888de){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x4afb('0x4')])(()=>this['apiAxiosInstance'][a0_0x4afb('0x1')]('/nx-cloud/report-client-error',{'message':_0x5888de}));}catch(_0x155826){output['warn']({'title':a0_0x4afb('0xa')+_0x5888de+'\x27','bodyLines':[_0x155826['message']]});}});}}exports['ErrorReporterApi']=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_0x3818=['next','error','createMetricRecorder','throw','createRunGroup','message','../../utilities/axios','axiosException','defineProperty','RUNNER_FAILURE_PERF_ENTRY','__esModule','RunGroupApi','post','mapRespToPerfEntry','exit','createApiAxiosInstance','completeRunGroup','recordMetric','response','done','value','/nx-cloud/executions/complete-run-group','apiAxiosInstance','../../utilities/nx-imports','then','axiosMultipleTries'];(function(_0x1478e9,_0x3818d3){const _0x1e6c9b=function(_0x48cca3){while(--_0x48cca3){_0x1478e9['push'](_0x1478e9['shift']());}};_0x1e6c9b(++_0x3818d3);}(a1_0x3818,0xba));const a1_0x1e6c=function(_0x1478e9,_0x3818d3){_0x1478e9=_0x1478e9-0x0;let _0x1e6c9b=a1_0x3818[_0x1478e9];return _0x1e6c9b;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x59b23f,_0x2f85cd,_0x1ae04d,_0x2fd741){function _0x38707c(_0x177799){return _0x177799 instanceof _0x1ae04d?_0x177799:new _0x1ae04d(function(_0x13852a){_0x13852a(_0x177799);});}return new(_0x1ae04d||(_0x1ae04d=Promise))(function(_0x45fcce,_0xb615dc){function _0xc20d07(_0x5c4a90){try{_0x13a7bb(_0x2fd741['next'](_0x5c4a90));}catch(_0x472990){_0xb615dc(_0x472990);}}function _0x38c0ee(_0x4320d4){try{_0x13a7bb(_0x2fd741[a1_0x1e6c('0x19')](_0x4320d4));}catch(_0x3b627e){_0xb615dc(_0x3b627e);}}function _0x13a7bb(_0x367e48){_0x367e48[a1_0x1e6c('0xf')]?_0x45fcce(_0x367e48[a1_0x1e6c('0x10')]):_0x38707c(_0x367e48['value'])[a1_0x1e6c('0x14')](_0xc20d07,_0x38c0ee);}_0x13a7bb((_0x2fd741=_0x2fd741['apply'](_0x59b23f,_0x2f85cd||[]))[a1_0x1e6c('0x16')]());});};Object[a1_0x1e6c('0x4')](exports,a1_0x1e6c('0x6'),{'value':!![]});exports[a1_0x1e6c('0x7')]=void 0x0;const axios_1=require(a1_0x1e6c('0x2'));const metric_logger_1=require('../../utilities/metric-logger');const {output}=require(a1_0x1e6c('0x13'));class RunGroupApi{constructor(_0x49c118){this['apiAxiosInstance']=(0x0,axios_1[a1_0x1e6c('0xb')])(_0x49c118);}[a1_0x1e6c('0x0')](_0x1fb76a,_0x252d6b,_0x29ffc5,_0x18279c,_0xb60d99){var _0xf12e9f;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x291586=(0x0,metric_logger_1[a1_0x1e6c('0x18')])(a1_0x1e6c('0x0'));try{const _0xe23801=yield(0x0,axios_1[a1_0x1e6c('0x15')])(()=>this[a1_0x1e6c('0x12')][a1_0x1e6c('0x8')]('/nx-cloud/executions/create-run-group',{'branch':_0x1fb76a,'runGroup':_0x252d6b,'stopAgentsOnFailure':_0x29ffc5,'agentCount':_0x18279c,'stopAgentsAfter':_0xb60d99}));_0x291586[a1_0x1e6c('0xd')]((0x0,metric_logger_1[a1_0x1e6c('0x9')])(_0xe23801));}catch(_0x35028c){_0x291586[a1_0x1e6c('0xd')](((_0xf12e9f=_0x35028c===null||_0x35028c===void 0x0?void 0x0:_0x35028c[a1_0x1e6c('0x3')])===null||_0xf12e9f===void 0x0?void 0x0:_0xf12e9f[a1_0x1e6c('0xe')])?(0x0,metric_logger_1[a1_0x1e6c('0x9')])(_0x35028c['axiosException'][a1_0x1e6c('0xe')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x1e6c('0x17')]({'title':_0x35028c['message']});process['exit'](0x1);}});}[a1_0x1e6c('0xc')](_0x13d2a3){var _0x213f3f;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5bdc42=(0x0,metric_logger_1['createMetricRecorder'])('createRunGroup');try{const _0x14b755=yield(0x0,axios_1[a1_0x1e6c('0x15')])(()=>this[a1_0x1e6c('0x12')][a1_0x1e6c('0x8')](a1_0x1e6c('0x11'),{'runGroup':_0x13d2a3}));_0x5bdc42[a1_0x1e6c('0xd')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x14b755));}catch(_0x405450){_0x5bdc42['recordMetric'](((_0x213f3f=_0x405450===null||_0x405450===void 0x0?void 0x0:_0x405450[a1_0x1e6c('0x3')])===null||_0x213f3f===void 0x0?void 0x0:_0x213f3f[a1_0x1e6c('0xe')])?(0x0,metric_logger_1[a1_0x1e6c('0x9')])(_0x405450['axiosException'][a1_0x1e6c('0xe')]):metric_logger_1[a1_0x1e6c('0x5')]);output[a1_0x1e6c('0x17')]({'title':_0x405450[a1_0x1e6c('0x1')]});process[a1_0x1e6c('0xa')](0x1);}});}}exports['RunGroupApi']=RunGroupApi;
|
|
@@ -1,156 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CloudEnabledLifeCycle = void 0;
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const environment_1 = require("../../../utilities/environment");
|
|
8
|
-
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
9
|
-
const { workspaceRoot } = require('../../../utilities/nx-imports');
|
|
10
|
-
class CloudEnabledLifeCycle {
|
|
11
|
-
constructor(runContext, cacheDirectory, skipNxCache, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
|
|
12
|
-
this.runContext = runContext;
|
|
13
|
-
this.cacheDirectory = cacheDirectory;
|
|
14
|
-
this.skipNxCache = skipNxCache;
|
|
15
|
-
this.collectTerminalOutput = collectTerminalOutput;
|
|
16
|
-
this.cacheableOperations = cacheableOperations;
|
|
17
|
-
this.outputObfuscator = outputObfuscator;
|
|
18
|
-
this.tasks = tasks;
|
|
19
|
-
}
|
|
20
|
-
scheduleTask(task) {
|
|
21
|
-
this.runContext.scheduledTasks.push(task);
|
|
22
|
-
}
|
|
23
|
-
startTask(task) {
|
|
24
|
-
this.tasks.push({
|
|
25
|
-
taskId: task.id,
|
|
26
|
-
startTime: new Date().toISOString(),
|
|
27
|
-
target: task.target.target,
|
|
28
|
-
projectName: task.target.project,
|
|
29
|
-
hash: task.hash,
|
|
30
|
-
hashDetails: this.cleanUpHashDetails(task.hashDetails),
|
|
31
|
-
params: (0, serializer_overrides_1.serializeOverrides)(task),
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
// Used for older version for Nx. Remove in Dec 2022
|
|
35
|
-
endTask(task, code) {
|
|
36
|
-
let cacheStatus;
|
|
37
|
-
if (this.runContext.statuses[task.hash]) {
|
|
38
|
-
cacheStatus = this.runContext.statuses[task.hash];
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
if (this.cacheableOperations.indexOf(task.target.target) > -1 &&
|
|
42
|
-
!this.skipNxCache) {
|
|
43
|
-
cacheStatus = 'local-cache-hit';
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
cacheStatus = 'cache-miss';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
this.updateStartedTask(task, code, cacheStatus);
|
|
50
|
-
}
|
|
51
|
-
endTasks(tasks) {
|
|
52
|
-
for (let t of tasks) {
|
|
53
|
-
let cacheStatus;
|
|
54
|
-
const taskIsRemoteCacheHit = t.status === 'remote-cache';
|
|
55
|
-
const taskIsLocalCacheHitPreNx135 = t.status === 'cache';
|
|
56
|
-
const taskIsLocalCacheHit = t.status === 'local-cache' ||
|
|
57
|
-
t.status === 'local-cache-kept-existing' ||
|
|
58
|
-
taskIsLocalCacheHitPreNx135;
|
|
59
|
-
if (this.runContext.statuses[t.task.hash]) {
|
|
60
|
-
cacheStatus = this.runContext.statuses[t.task.hash];
|
|
61
|
-
}
|
|
62
|
-
else if (taskIsRemoteCacheHit) {
|
|
63
|
-
cacheStatus = 'remote-cache-hit';
|
|
64
|
-
}
|
|
65
|
-
else if (taskIsLocalCacheHit) {
|
|
66
|
-
cacheStatus = 'local-cache-hit';
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
if (this.cacheableOperations.indexOf(t.task.target.target) > -1 &&
|
|
70
|
-
!this.skipNxCache) {
|
|
71
|
-
cacheStatus = 'local-cache-hit';
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
cacheStatus = 'cache-miss';
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
this.updateStartedTask(t.task, t.code, cacheStatus);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
endCommand() { }
|
|
81
|
-
updateStartedTask(task, code, cacheStatus) {
|
|
82
|
-
const startedTask = this.tasks.find((t) => t.taskId === task.id);
|
|
83
|
-
if (!startedTask) {
|
|
84
|
-
throw new Error(`Cannot find task ${task.id}`);
|
|
85
|
-
}
|
|
86
|
-
startedTask.endTime = new Date().toISOString();
|
|
87
|
-
startedTask.status = code;
|
|
88
|
-
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
|
|
89
|
-
startedTask.cacheStatus = cacheStatus;
|
|
90
|
-
if (this.collectTerminalOutput) {
|
|
91
|
-
startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
getTerminalOutput(hash, cacheStatus, code) {
|
|
95
|
-
let dir;
|
|
96
|
-
if (this.cacheDirectory) {
|
|
97
|
-
if (this.cacheDirectory.startsWith('./')) {
|
|
98
|
-
dir = (0, path_1.join)(workspaceRoot, this.cacheDirectory);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
dir = this.cacheDirectory;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
dir = (0, path_1.join)(workspaceRoot, 'node_modules', '.cache', 'nx');
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
const taskOutput = this.readTerminalOutputFile(dir, hash);
|
|
109
|
-
const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
|
|
110
|
-
if (environment_1.NX_CLOUD_UNLIMITED_OUTPUT)
|
|
111
|
-
return taskOutputSanitized;
|
|
112
|
-
const maxCharacters = cacheStatus === 'cache-miss'
|
|
113
|
-
? code === 0
|
|
114
|
-
? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
|
|
115
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
|
|
116
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
|
|
117
|
-
return taskOutputSanitized.length > maxCharacters
|
|
118
|
-
? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
|
|
119
|
-
: taskOutputSanitized;
|
|
120
|
-
}
|
|
121
|
-
catch (e) {
|
|
122
|
-
return '';
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
cleanUpHashDetails(hashDetails) {
|
|
126
|
-
const nodes = {};
|
|
127
|
-
Object.keys(hashDetails.nodes)
|
|
128
|
-
.filter((k) => !k.startsWith('npm:'))
|
|
129
|
-
.forEach((k) => {
|
|
130
|
-
nodes[k] = hashDetails.nodes[k];
|
|
131
|
-
});
|
|
132
|
-
return {
|
|
133
|
-
nodes,
|
|
134
|
-
runtime: hashDetails.runtime,
|
|
135
|
-
implicitDeps: hashDetails.implicitDeps,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
readTerminalOutputFile(dir, hash) {
|
|
139
|
-
try {
|
|
140
|
-
return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
|
|
141
|
-
}
|
|
142
|
-
catch (_a) {
|
|
143
|
-
try {
|
|
144
|
-
return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
|
|
145
|
-
}
|
|
146
|
-
catch (_b) {
|
|
147
|
-
return '';
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
|
|
153
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
|
|
154
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
|
|
155
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 20000;
|
|
156
|
-
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
|
|
1
|
+
const a0_0x5451=['cache-miss','params','startsWith','indexOf','cacheStatus','find','target','task','remote-cache-hit','skipNxCache','status','MAX_CHARACTERS_FAILED_TASK','join','../../../utilities/nx-imports','terminalOutputs','scheduleTask','outputObfuscator','path','statuses','NX_CLOUD_UNLIMITED_OUTPUT','length','terminalOutput','obfuscate','collectTerminalOutput','push','__esModule','code','local-cache-hit','cache','runtime','getTerminalOutput','project','cacheDirectory','toString','remote-cache','updateStartedTask','slice','hashDetails','endTime','toISOString','startTask','hash','runContext','MAX_CHARACTERS_SUCCESSFUL_TASK','npm:','TRUNCATED\x0a\x0a','MAX_CHARACTERS_CACHED_TASK','../../../utilities/serializer-overrides','cleanUpHashDetails','cacheableOperations','node_modules','.cache','endTask','defineProperty','nodes','tasks','CloudEnabledLifeCycle','readFileSync'];(function(_0x1a5b28,_0x54510f){const _0x73bdc5=function(_0xea9194){while(--_0xea9194){_0x1a5b28['push'](_0x1a5b28['shift']());}};_0x73bdc5(++_0x54510f);}(a0_0x5451,0xd2));const a0_0x73bd=function(_0x1a5b28,_0x54510f){_0x1a5b28=_0x1a5b28-0x0;let _0x73bdc5=a0_0x5451[_0x1a5b28];return _0x73bdc5;};'use strict';Object[a0_0x73bd('0x11')](exports,a0_0x73bd('0x2f'),{'value':!![]});exports[a0_0x73bd('0x14')]=void 0x0;const path=require(a0_0x73bd('0x27'));const path_1=require('path');const fs_1=require('fs');const environment_1=require('../../../utilities/environment');const serializer_overrides_1=require(a0_0x73bd('0xb'));const {workspaceRoot}=require(a0_0x73bd('0x23'));class CloudEnabledLifeCycle{constructor(_0x3f2baf,_0x4b7acd,_0x30224e,_0x3919e1,_0x1908b4,_0x4f066c,_0x198000){this[a0_0x73bd('0x6')]=_0x3f2baf;this[a0_0x73bd('0x36')]=_0x4b7acd;this[a0_0x73bd('0x1f')]=_0x30224e;this[a0_0x73bd('0x2d')]=_0x3919e1;this[a0_0x73bd('0xd')]=_0x1908b4;this['outputObfuscator']=_0x4f066c;this[a0_0x73bd('0x13')]=_0x198000;}[a0_0x73bd('0x25')](_0x33347a){this[a0_0x73bd('0x6')]['scheduledTasks']['push'](_0x33347a);}[a0_0x73bd('0x4')](_0x26d352){this[a0_0x73bd('0x13')][a0_0x73bd('0x2e')]({'taskId':_0x26d352['id'],'startTime':new Date()[a0_0x73bd('0x3')](),'target':_0x26d352[a0_0x73bd('0x1c')][a0_0x73bd('0x1c')],'projectName':_0x26d352[a0_0x73bd('0x1c')][a0_0x73bd('0x35')],'hash':_0x26d352[a0_0x73bd('0x5')],'hashDetails':this[a0_0x73bd('0xc')](_0x26d352[a0_0x73bd('0x1')]),'params':(0x0,serializer_overrides_1['serializeOverrides'])(_0x26d352)});}[a0_0x73bd('0x10')](_0x36c25c,_0x132162){let _0x221964;if(this[a0_0x73bd('0x6')][a0_0x73bd('0x28')][_0x36c25c[a0_0x73bd('0x5')]]){_0x221964=this[a0_0x73bd('0x6')][a0_0x73bd('0x28')][_0x36c25c[a0_0x73bd('0x5')]];}else{if(this['cacheableOperations']['indexOf'](_0x36c25c[a0_0x73bd('0x1c')]['target'])>-0x1&&!this[a0_0x73bd('0x1f')]){_0x221964=a0_0x73bd('0x31');}else{_0x221964=a0_0x73bd('0x16');}}this['updateStartedTask'](_0x36c25c,_0x132162,_0x221964);}['endTasks'](_0x389f3d){for(let _0x34becd of _0x389f3d){let _0x542bbe;const _0xad8f23=_0x34becd[a0_0x73bd('0x20')]===a0_0x73bd('0x38');const _0x64c5d9=_0x34becd[a0_0x73bd('0x20')]===a0_0x73bd('0x32');const _0x38ef77=_0x34becd[a0_0x73bd('0x20')]==='local-cache'||_0x34becd['status']==='local-cache-kept-existing'||_0x64c5d9;if(this[a0_0x73bd('0x6')][a0_0x73bd('0x28')][_0x34becd[a0_0x73bd('0x1d')][a0_0x73bd('0x5')]]){_0x542bbe=this[a0_0x73bd('0x6')][a0_0x73bd('0x28')][_0x34becd[a0_0x73bd('0x1d')][a0_0x73bd('0x5')]];}else if(_0xad8f23){_0x542bbe=a0_0x73bd('0x1e');}else if(_0x38ef77){_0x542bbe=a0_0x73bd('0x31');}else{if(this[a0_0x73bd('0xd')][a0_0x73bd('0x19')](_0x34becd['task']['target'][a0_0x73bd('0x1c')])>-0x1&&!this['skipNxCache']){_0x542bbe=a0_0x73bd('0x31');}else{_0x542bbe=a0_0x73bd('0x16');}}this[a0_0x73bd('0x39')](_0x34becd[a0_0x73bd('0x1d')],_0x34becd[a0_0x73bd('0x30')],_0x542bbe);}}['endCommand'](){}['updateStartedTask'](_0x26a26a,_0x3bcc3f,_0x5b1dae){const _0x6884ca=this['tasks'][a0_0x73bd('0x1b')](_0x455783=>_0x455783['taskId']===_0x26a26a['id']);if(!_0x6884ca){throw new Error('Cannot\x20find\x20task\x20'+_0x26a26a['id']);}_0x6884ca[a0_0x73bd('0x2')]=new Date()['toISOString']();_0x6884ca[a0_0x73bd('0x20')]=_0x3bcc3f;_0x6884ca[a0_0x73bd('0x17')]=this['outputObfuscator'][a0_0x73bd('0x2c')](_0x6884ca['params']);_0x6884ca[a0_0x73bd('0x1a')]=_0x5b1dae;if(this['collectTerminalOutput']){_0x6884ca[a0_0x73bd('0x2b')]=this[a0_0x73bd('0x34')](_0x26a26a['hash'],_0x6884ca[a0_0x73bd('0x1a')],_0x3bcc3f);}}[a0_0x73bd('0x34')](_0x5d562f,_0x5204fd,_0x3ae114){let _0x3d592f;if(this[a0_0x73bd('0x36')]){if(this[a0_0x73bd('0x36')][a0_0x73bd('0x18')]('./')){_0x3d592f=(0x0,path_1[a0_0x73bd('0x22')])(workspaceRoot,this[a0_0x73bd('0x36')]);}else{_0x3d592f=this[a0_0x73bd('0x36')];}}else{_0x3d592f=(0x0,path_1[a0_0x73bd('0x22')])(workspaceRoot,a0_0x73bd('0xe'),a0_0x73bd('0xf'),'nx');}try{const _0x2d4514=this['readTerminalOutputFile'](_0x3d592f,_0x5d562f);const _0x3cd0e8=this[a0_0x73bd('0x26')][a0_0x73bd('0x2c')](_0x2d4514);if(environment_1[a0_0x73bd('0x29')])return _0x3cd0e8;const _0x443051=_0x5204fd==='cache-miss'?_0x3ae114===0x0?CloudEnabledLifeCycle[a0_0x73bd('0x7')]:CloudEnabledLifeCycle['MAX_CHARACTERS_FAILED_TASK']:CloudEnabledLifeCycle[a0_0x73bd('0xa')];return _0x3cd0e8[a0_0x73bd('0x2a')]>_0x443051?a0_0x73bd('0x9')+_0x3cd0e8[a0_0x73bd('0x0')](_0x3cd0e8[a0_0x73bd('0x2a')]-_0x443051):_0x3cd0e8;}catch(_0x3e2cc4){return'';}}[a0_0x73bd('0xc')](_0x17d97e){const _0x19ae6e={};Object['keys'](_0x17d97e['nodes'])['filter'](_0x520c57=>!_0x520c57[a0_0x73bd('0x18')](a0_0x73bd('0x8')))['forEach'](_0x41b51f=>{_0x19ae6e[_0x41b51f]=_0x17d97e[a0_0x73bd('0x12')][_0x41b51f];});return{'nodes':_0x19ae6e,'runtime':_0x17d97e[a0_0x73bd('0x33')],'implicitDeps':_0x17d97e['implicitDeps']};}['readTerminalOutputFile'](_0x5a3f69,_0x1dbd84){try{return(0x0,fs_1[a0_0x73bd('0x15')])(path[a0_0x73bd('0x22')](_0x5a3f69,a0_0x73bd('0x24'),_0x1dbd84))[a0_0x73bd('0x37')]();}catch(_0x578f8b){try{return(0x0,fs_1['readFileSync'])(path[a0_0x73bd('0x22')](_0x5a3f69,_0x1dbd84,'terminalOutput'))[a0_0x73bd('0x37')]();}catch(_0x1d33ad){return'';}}}}exports[a0_0x73bd('0x14')]=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x73bd('0x21')]=0x30d40;CloudEnabledLifeCycle[a0_0x73bd('0x7')]=0x4e20;CloudEnabledLifeCycle[a0_0x73bd('0xa')]=0x4e20;
|
|
@@ -1,288 +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
|
-
function onComplete({ daemon, lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner, encryptionKey, fileStorage, uploadInCurrentProcess, runContext, }) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const runEndTime = new Date().toISOString();
|
|
49
|
-
const branch = (0, environment_1.getBranch)();
|
|
50
|
-
const runData = {
|
|
51
|
-
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
|
|
52
|
-
startTime: runStartTime,
|
|
53
|
-
endTime: runEndTime,
|
|
54
|
-
distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
|
|
55
|
-
branch: branch,
|
|
56
|
-
scan: true,
|
|
57
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
58
|
-
// only set sha if branch is set because we invoke a separate process,
|
|
59
|
-
// which adds a few millis
|
|
60
|
-
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
|
|
61
|
-
inner: inner,
|
|
62
|
-
};
|
|
63
|
-
if (uploadInCurrentProcess) {
|
|
64
|
-
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
|
|
65
|
-
storeTaskHashes(taskExecutions, options.cacheDirectory || './node_modules/.cache/nx', environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
yield remoteCache.waitForStoreRequestsToComplete();
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
output.error({
|
|
72
|
-
title: `Nx Cloud wasn't able to store artifacts.`,
|
|
73
|
-
});
|
|
74
|
-
messages.printMessages();
|
|
75
|
-
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
76
|
-
}
|
|
77
|
-
try {
|
|
78
|
-
yield api.endRun(runData, taskExecutions);
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
output.error({
|
|
82
|
-
title: `Nx Cloud wasn't able to record its run.`,
|
|
83
|
-
});
|
|
84
|
-
messages.printMessages();
|
|
85
|
-
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
86
|
-
}
|
|
87
|
-
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
try {
|
|
91
|
-
const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken;
|
|
92
|
-
const linkId = (0, id_generator_1.generateUniqueLinkId)();
|
|
93
|
-
yield daemon.processInBackground('@nrwl/nx-cloud/lib/daemon/process-run-end', {
|
|
94
|
-
encryptionKey,
|
|
95
|
-
runnerOptions: Object.assign(Object.assign({}, options), { accessToken }),
|
|
96
|
-
uploads: fileStorage.uploads,
|
|
97
|
-
runEnd: {
|
|
98
|
-
runData,
|
|
99
|
-
taskExecutions,
|
|
100
|
-
linkId,
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
runContext.runUrl = `${options.url || 'https://nx.app'}/runs/${linkId}`;
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
output.warn({
|
|
107
|
-
title: `Nx Cloud Problems`,
|
|
108
|
-
bodyLines: [e.message || e.toString()],
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// this workaround is required because prior to Nx 13.3 we printed
|
|
113
|
-
// the end message after the runner completes, so we need to wait for the
|
|
114
|
-
// message to appear in the right place
|
|
115
|
-
if (versionOfNxBefore133) {
|
|
116
|
-
setTimeout(() => {
|
|
117
|
-
messages.printMessages();
|
|
118
|
-
if (!messages.anyErrors && !inner) {
|
|
119
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
120
|
-
}
|
|
121
|
-
}, 0);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
messages.printMessages();
|
|
125
|
-
if (!messages.anyErrors && !inner) {
|
|
126
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
|
|
132
|
-
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, options.cacheDirectory, !!options.skipNxCache, options.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
|
|
133
|
-
try {
|
|
134
|
-
const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
|
|
135
|
-
if (!CompositeLifeCycle)
|
|
136
|
-
return cloudEnabledLifeCycle;
|
|
137
|
-
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
|
|
138
|
-
}
|
|
139
|
-
catch (e) {
|
|
140
|
-
return cloudEnabledLifeCycle;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options) {
|
|
144
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
let hashes = tasks.map((t) => t.hash).filter((h) => !!h);
|
|
146
|
-
const c = new Cache(options);
|
|
147
|
-
if (!options.skipNxCache) {
|
|
148
|
-
// filter out the urls that don't have artifact stored locally
|
|
149
|
-
const promises = yield Promise.all(hashes.map((hash) => {
|
|
150
|
-
const tdCommit = (0, path_1.join)(c.cachePath, `${hash}.commit`);
|
|
151
|
-
return (0, fs_extra_1.pathExists)(tdCommit);
|
|
152
|
-
}));
|
|
153
|
-
const missingHashes = [];
|
|
154
|
-
for (let i = 0; i < promises.length; ++i) {
|
|
155
|
-
if (promises[i]) {
|
|
156
|
-
missingHashes.push(hashes[i]);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
hashes = missingHashes;
|
|
160
|
-
}
|
|
161
|
-
if (hashes.length > 0) {
|
|
162
|
-
const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
|
|
163
|
-
for (const hash of hashes) {
|
|
164
|
-
runContext.requests[hash] = startRunRequest;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
function isConnectedToPrivateCloud(options) {
|
|
170
|
-
if (!options.url)
|
|
171
|
-
return false;
|
|
172
|
-
if (options.url.endsWith('api.nrwl.io'))
|
|
173
|
-
return false;
|
|
174
|
-
if (options.url.endsWith('.nx.app'))
|
|
175
|
-
return false;
|
|
176
|
-
if (options.url.indexOf('localhost') > -1)
|
|
177
|
-
return false;
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
|
|
181
|
-
var _a;
|
|
182
|
-
const runContext = {
|
|
183
|
-
statuses: {},
|
|
184
|
-
scheduledTasks: [],
|
|
185
|
-
requests: {},
|
|
186
|
-
allTasks: tasks,
|
|
187
|
-
};
|
|
188
|
-
const versionOfNxBefore133 = options.lifeCycle === undefined;
|
|
189
|
-
const taskExecutions = [];
|
|
190
|
-
const messages = new message_reporter_1.MessageReporter(options);
|
|
191
|
-
const api = createApi(messages, options, runContext);
|
|
192
|
-
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions);
|
|
193
|
-
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
|
|
194
|
-
const runStartTime = new Date().toISOString();
|
|
195
|
-
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
|
|
196
|
-
const encryptionKey = environment_1.ENCRYPTION_KEY || options.encryptionKey;
|
|
197
|
-
const encryption = new e2e_encryption_1.E2EEncryption(encryptionKey);
|
|
198
|
-
const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
|
|
199
|
-
const uploadInCurrentProcess = !!environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION ||
|
|
200
|
-
!((_a = context.daemon) === null || _a === void 0 ? void 0 : _a.enabled()) ||
|
|
201
|
-
isConnectedToPrivateCloud(options);
|
|
202
|
-
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, false, uploadInCurrentProcess);
|
|
203
|
-
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
|
|
204
|
-
// we don't await for it cause this step is optional
|
|
205
|
-
fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options);
|
|
206
|
-
// have to reset it so we don't capture inner tasks
|
|
207
|
-
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
|
|
208
|
-
const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
|
|
209
|
-
// observable -> legacy
|
|
210
|
-
if (res.subscribe) {
|
|
211
|
-
const { Subject } = require('rxjs/internal/Subject');
|
|
212
|
-
const wrappedRes = new Subject();
|
|
213
|
-
res.subscribe({
|
|
214
|
-
next: (value) => wrappedRes.next(value),
|
|
215
|
-
error: (err) => wrappedRes.error(err),
|
|
216
|
-
complete: () => __awaiter(this, void 0, void 0, function* () {
|
|
217
|
-
yield onComplete({
|
|
218
|
-
daemon: context.daemon,
|
|
219
|
-
lifeCycle,
|
|
220
|
-
options,
|
|
221
|
-
remoteCache,
|
|
222
|
-
api,
|
|
223
|
-
outputObfuscator,
|
|
224
|
-
runStartTime,
|
|
225
|
-
messages,
|
|
226
|
-
endOfRunMessage,
|
|
227
|
-
taskExecutions,
|
|
228
|
-
versionOfNxBefore133,
|
|
229
|
-
inner,
|
|
230
|
-
encryptionKey,
|
|
231
|
-
fileStorage,
|
|
232
|
-
uploadInCurrentProcess,
|
|
233
|
-
runContext,
|
|
234
|
-
});
|
|
235
|
-
wrappedRes.complete();
|
|
236
|
-
}),
|
|
237
|
-
});
|
|
238
|
-
return wrappedRes;
|
|
239
|
-
// promise
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
return res
|
|
243
|
-
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
yield onComplete({
|
|
245
|
-
daemon: context.daemon,
|
|
246
|
-
lifeCycle,
|
|
247
|
-
options,
|
|
248
|
-
remoteCache,
|
|
249
|
-
api,
|
|
250
|
-
outputObfuscator,
|
|
251
|
-
runStartTime,
|
|
252
|
-
messages,
|
|
253
|
-
endOfRunMessage,
|
|
254
|
-
taskExecutions,
|
|
255
|
-
versionOfNxBefore133,
|
|
256
|
-
inner,
|
|
257
|
-
encryptionKey,
|
|
258
|
-
fileStorage,
|
|
259
|
-
uploadInCurrentProcess,
|
|
260
|
-
runContext,
|
|
261
|
-
});
|
|
262
|
-
return r;
|
|
263
|
-
}))
|
|
264
|
-
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
265
|
-
yield onComplete({
|
|
266
|
-
daemon: context.daemon,
|
|
267
|
-
lifeCycle,
|
|
268
|
-
options,
|
|
269
|
-
remoteCache,
|
|
270
|
-
api,
|
|
271
|
-
outputObfuscator,
|
|
272
|
-
runStartTime,
|
|
273
|
-
messages,
|
|
274
|
-
endOfRunMessage,
|
|
275
|
-
taskExecutions,
|
|
276
|
-
versionOfNxBefore133,
|
|
277
|
-
inner,
|
|
278
|
-
encryptionKey,
|
|
279
|
-
fileStorage,
|
|
280
|
-
uploadInCurrentProcess,
|
|
281
|
-
runContext,
|
|
282
|
-
});
|
|
283
|
-
throw e;
|
|
284
|
-
}));
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
|
|
288
|
-
//# sourceMappingURL=cloud-enabled.runner.js.map
|
|
1
|
+
const a1_0x3af8=['__esModule','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','subscribe','Executed\x20tasks\x20with\x20hashes:\x20','catch','map','./cloud-remote-cache','./id-generator','/runs/','next','../../../utilities/nx-imports','Nx\x20Cloud\x20Problems','requests','join','obfuscate','exit','cacheableOperations','toISOString','submitRunMetrics','error','filter','VERBOSE_LOGGING','api.nrwl.io','lifeCycle','taskId','EndOfRunMessage','url','CloudRemoteCache','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','../../file-storage/e2e-encryption','indexOf','getBranch','CloudEnabledLifeCycle','../../../utilities/metric-logger','rxjs/internal/Subject','anyErrors','cacheDirectory','printCacheHitsMessage','waitForStoreRequestsToComplete','runUrl','env','parseCommand','E2EEncryption','push','daemon','path','cachePath','../../file-storage/file-storage','.commit','accessToken','apply','cloudEnabledTasksRunner','../../terminal-output/end-of-run-message','extractGitSha','writeFileSync','tasks-hashes-','../../terminal-output/message-reporter','processInBackground','hash','localhost','skipNxCache','./node_modules/.cache/nx','pathExists','../../terminal-output/output-obfuscator','maskedProperties','enabled','ACCESS_TOKEN','../../../utilities/environment','scan','done','startRun','encryptionKey','__awaiter','note','./cloud-enabled-life-cycle','endsWith','printMessages','length','assign','then','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION'];(function(_0x198371,_0x3af8a9){const _0x4e66e5=function(_0x348588){while(--_0x348588){_0x198371['push'](_0x198371['shift']());}};_0x4e66e5(++_0x3af8a9);}(a1_0x3af8,0xcf));const a1_0x4e66=function(_0x198371,_0x3af8a9){_0x198371=_0x198371-0x0;let _0x4e66e5=a1_0x3af8[_0x198371];return _0x4e66e5;};'use strict';var __awaiter=this&&this[a1_0x4e66('0x1b')]||function(_0xd14e5b,_0x1b3ade,_0x5e7e94,_0x28687b){function _0x409961(_0x1ed129){return _0x1ed129 instanceof _0x5e7e94?_0x1ed129:new _0x5e7e94(function(_0x54e226){_0x54e226(_0x1ed129);});}return new(_0x5e7e94||(_0x5e7e94=Promise))(function(_0xdcbd87,_0x15783d){function _0x2e4cf7(_0x815e9a){try{_0x370b43(_0x28687b[a1_0x4e66('0x2d')](_0x815e9a));}catch(_0x674f33){_0x15783d(_0x674f33);}}function _0x1f224d(_0x383908){try{_0x370b43(_0x28687b['throw'](_0x383908));}catch(_0x673d01){_0x15783d(_0x673d01);}}function _0x370b43(_0x42cc07){_0x42cc07[a1_0x4e66('0x18')]?_0xdcbd87(_0x42cc07['value']):_0x409961(_0x42cc07['value'])[a1_0x4e66('0x22')](_0x2e4cf7,_0x1f224d);}_0x370b43((_0x28687b=_0x28687b[a1_0x4e66('0x5')](_0xd14e5b,_0x1b3ade||[]))[a1_0x4e66('0x2d')]());});};Object['defineProperty'](exports,a1_0x4e66('0x24'),{'value':!![]});exports[a1_0x4e66('0x6')]=void 0x0;const message_reporter_1=require(a1_0x4e66('0xb'));const end_of_run_message_1=require(a1_0x4e66('0x7'));const output_obfuscator_1=require(a1_0x4e66('0x12'));const cloud_enabled_life_cycle_1=require(a1_0x4e66('0x1d'));const file_storage_1=require(a1_0x4e66('0x2'));const e2e_encryption_1=require(a1_0x4e66('0x41'));const environment_1=require(a1_0x4e66('0x16'));const cloud_remote_cache_1=require(a1_0x4e66('0x2a'));const cloud_run_api_1=require('./cloud-run.api');const fs_1=require('fs');const path=require(a1_0x4e66('0x0'));const metric_logger_1=require(a1_0x4e66('0x45'));const error_reporter_api_1=require('../../api/error-reporter.api');const path_1=require(a1_0x4e66('0x0'));const fs_extra_1=require('fs-extra');const id_generator_1=require(a1_0x4e66('0x2b'));const {tasksRunner,output,Cache}=require(a1_0x4e66('0x2e'));function createApi(_0x39c45e,_0x521377,_0x523ad2){const _0x4b9261=(0x0,environment_1['getMachineInfo'])(_0x521377);return new cloud_run_api_1['CloudRunApi'](_0x39c45e,_0x523ad2,_0x521377,_0x4b9261);}function storeTaskHashes(_0xb190d2,_0x44c9a8,_0x39b19c){const _0x316be5=JSON['stringify'](_0xb190d2[a1_0x4e66('0x29')](_0x269a93=>({'taskId':_0x269a93[a1_0x4e66('0x3c')],'hash':_0x269a93[a1_0x4e66('0xd')]})));if(environment_1[a1_0x4e66('0x39')]){output[a1_0x4e66('0x1c')]({'title':a1_0x4e66('0x27')+_0x316be5});}(0x0,fs_1[a1_0x4e66('0x9')])(path[a1_0x4e66('0x31')](_0x44c9a8,a1_0x4e66('0xa')+_0x39b19c),_0x316be5);}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 _0x45320b=new Date()['toISOString']();const _0x20fac4=(0x0,environment_1[a1_0x4e66('0x43')])();const _0x472e4a={'command':outputObfuscator[a1_0x4e66('0x32')]((0x0,environment_1[a1_0x4e66('0x4d')])()),'startTime':runStartTime,'endTime':_0x45320b,'distributedExecutionId':environment_1[a1_0x4e66('0x40')],'branch':_0x20fac4,'scan':!![],'runGroup':(0x0,environment_1['getRunGroup'])(),'sha':_0x20fac4?(0x0,environment_1[a1_0x4e66('0x8')])():undefined,'inner':inner};if(uploadInCurrentProcess){if(environment_1[a1_0x4e66('0x23')]){storeTaskHashes(taskExecutions,options[a1_0x4e66('0x48')]||a1_0x4e66('0x10'),environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID']);}try{yield remoteCache[a1_0x4e66('0x4a')]();}catch(_0x534d1f){output['error']({'title':'Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.'});messages[a1_0x4e66('0x1f')]();process[a1_0x4e66('0x33')](environment_1[a1_0x4e66('0x25')]);}try{yield api['endRun'](_0x472e4a,taskExecutions);}catch(_0x59bddd){output[a1_0x4e66('0x37')]({'title':'Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.'});messages[a1_0x4e66('0x1f')]();process['exit'](environment_1[a1_0x4e66('0x25')]);}yield(0x0,metric_logger_1[a1_0x4e66('0x36')])(options);}else{try{const _0x41467d=environment_1['ACCESS_TOKEN']?environment_1[a1_0x4e66('0x15')]:options[a1_0x4e66('0x4')];const _0x34ae83=(0x0,id_generator_1['generateUniqueLinkId'])();yield daemon[a1_0x4e66('0xc')]('@nrwl/nx-cloud/lib/daemon/process-run-end',{'encryptionKey':encryptionKey,'runnerOptions':Object[a1_0x4e66('0x21')](Object[a1_0x4e66('0x21')]({},options),{'accessToken':_0x41467d}),'uploads':fileStorage['uploads'],'runEnd':{'runData':_0x472e4a,'taskExecutions':taskExecutions,'linkId':_0x34ae83}});runContext[a1_0x4e66('0x4b')]=(options[a1_0x4e66('0x3e')]||'https://nx.app')+a1_0x4e66('0x2c')+_0x34ae83;}catch(_0x544aba){output['warn']({'title':a1_0x4e66('0x2f'),'bodyLines':[_0x544aba['message']||_0x544aba['toString']()]});}}if(versionOfNxBefore133){setTimeout(()=>{messages[a1_0x4e66('0x1f')]();if(!messages[a1_0x4e66('0x47')]&&!inner){endOfRunMessage[a1_0x4e66('0x49')]();}},0x0);}else{messages[a1_0x4e66('0x1f')]();if(!messages[a1_0x4e66('0x47')]&&!inner){endOfRunMessage[a1_0x4e66('0x49')]();}}});}function createLifeCycle(_0x2051d9,_0x18ac3b,_0x13ccee,_0x36a370){const _0x57b15a=new cloud_enabled_life_cycle_1[(a1_0x4e66('0x44'))](_0x2051d9,_0x18ac3b[a1_0x4e66('0x48')],!!_0x18ac3b[a1_0x4e66('0xf')],_0x18ac3b[a1_0x4e66('0x17')]===undefined?!![]:_0x18ac3b[a1_0x4e66('0x17')],_0x18ac3b[a1_0x4e66('0x34')]||[],_0x13ccee,_0x36a370);try{const {CompositeLifeCycle}=require(a1_0x4e66('0x2e'));if(!CompositeLifeCycle)return _0x57b15a;return new CompositeLifeCycle([_0x18ac3b[a1_0x4e66('0x3b')],_0x57b15a]);}catch(_0x18aca5){return _0x57b15a;}}function fetchUrlsForKnownHashesUpfront(_0x2c1180,_0x1e701c,_0x485abb,_0x120d22){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x459feb=_0x485abb[a1_0x4e66('0x29')](_0x5c2236=>_0x5c2236[a1_0x4e66('0xd')])[a1_0x4e66('0x38')](_0x110044=>!!_0x110044);const _0x4a0269=new Cache(_0x120d22);if(!_0x120d22[a1_0x4e66('0xf')]){const _0x119d97=yield Promise['all'](_0x459feb['map'](_0x5c5ddd=>{const _0x5a9fca=(0x0,path_1[a1_0x4e66('0x31')])(_0x4a0269[a1_0x4e66('0x1')],_0x5c5ddd+a1_0x4e66('0x3'));return(0x0,fs_extra_1[a1_0x4e66('0x11')])(_0x5a9fca);}));const _0x4a3f86=[];for(let _0x560fbc=0x0;_0x560fbc<_0x119d97[a1_0x4e66('0x20')];++_0x560fbc){if(_0x119d97[_0x560fbc]){_0x4a3f86[a1_0x4e66('0x4f')](_0x459feb[_0x560fbc]);}}_0x459feb=_0x4a3f86;}if(_0x459feb[a1_0x4e66('0x20')]>0x0){const _0x5b6e4c=_0x2c1180[a1_0x4e66('0x19')](environment_1[a1_0x4e66('0x40')],_0x459feb);for(const _0x3de7ec of _0x459feb){_0x1e701c[a1_0x4e66('0x30')][_0x3de7ec]=_0x5b6e4c;}}});}function isConnectedToPrivateCloud(_0x513630){if(!_0x513630[a1_0x4e66('0x3e')])return![];if(_0x513630[a1_0x4e66('0x3e')][a1_0x4e66('0x1e')](a1_0x4e66('0x3a')))return![];if(_0x513630[a1_0x4e66('0x3e')]['endsWith']('.nx.app'))return![];if(_0x513630['url'][a1_0x4e66('0x42')](a1_0x4e66('0xe'))>-0x1)return![];return!![];}function cloudEnabledTasksRunner(_0x7ea89e,_0x3d0cee,_0x21b343,_0x559dae=![]){var _0x5320db;const _0x2fdce6={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x7ea89e};const _0x3de525=_0x3d0cee[a1_0x4e66('0x3b')]===undefined;const _0x56e706=[];const _0x377122=new message_reporter_1['MessageReporter'](_0x3d0cee);const _0x3f6e29=createApi(_0x377122,_0x3d0cee,_0x2fdce6);const _0x108d14=new end_of_run_message_1[(a1_0x4e66('0x3d'))](_0x2fdce6,_0x56e706);const _0x4ffc3b=new output_obfuscator_1['OutputObfuscator'](_0x3d0cee[a1_0x4e66('0x13')]);const _0x6447df=new Date()[a1_0x4e66('0x35')]();const _0x4c8d13=createLifeCycle(_0x2fdce6,_0x3d0cee,_0x4ffc3b,_0x56e706);const _0x4511b2=environment_1['ENCRYPTION_KEY']||_0x3d0cee[a1_0x4e66('0x1a')];const _0x1c4770=new e2e_encryption_1[(a1_0x4e66('0x4e'))](_0x4511b2);const _0x36a2b1=new error_reporter_api_1['ErrorReporterApi'](_0x3d0cee);const _0x186675=!!environment_1[a1_0x4e66('0x23')]||!((_0x5320db=_0x21b343['daemon'])===null||_0x5320db===void 0x0?void 0x0:_0x5320db[a1_0x4e66('0x14')]())||isConnectedToPrivateCloud(_0x3d0cee);const _0x3feabf=new file_storage_1['FileStorage'](_0x1c4770,_0x36a2b1,![],_0x186675);const _0x7d41d2=new cloud_remote_cache_1[(a1_0x4e66('0x3f'))](_0x377122,_0x3f6e29,_0x2fdce6,_0x3feabf);fetchUrlsForKnownHashesUpfront(_0x3f6e29,_0x2fdce6,_0x7ea89e,_0x3d0cee);delete process[a1_0x4e66('0x4c')][a1_0x4e66('0x40')];const _0x344633=tasksRunner(_0x7ea89e,Object[a1_0x4e66('0x21')](Object[a1_0x4e66('0x21')]({},_0x3d0cee),{'remoteCache':_0x7d41d2,'lifeCycle':_0x4c8d13}),_0x21b343);if(_0x344633['subscribe']){const {Subject}=require(a1_0x4e66('0x46'));const _0x19e1b0=new Subject();_0x344633[a1_0x4e66('0x26')]({'next':_0x333d93=>_0x19e1b0[a1_0x4e66('0x2d')](_0x333d93),'error':_0x16bcd0=>_0x19e1b0[a1_0x4e66('0x37')](_0x16bcd0),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0x21b343[a1_0x4e66('0x50')],'lifeCycle':_0x4c8d13,'options':_0x3d0cee,'remoteCache':_0x7d41d2,'api':_0x3f6e29,'outputObfuscator':_0x4ffc3b,'runStartTime':_0x6447df,'messages':_0x377122,'endOfRunMessage':_0x108d14,'taskExecutions':_0x56e706,'versionOfNxBefore133':_0x3de525,'inner':_0x559dae,'encryptionKey':_0x4511b2,'fileStorage':_0x3feabf,'uploadInCurrentProcess':_0x186675,'runContext':_0x2fdce6});_0x19e1b0['complete']();})});return _0x19e1b0;}else{return _0x344633['then'](_0x165824=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0x21b343[a1_0x4e66('0x50')],'lifeCycle':_0x4c8d13,'options':_0x3d0cee,'remoteCache':_0x7d41d2,'api':_0x3f6e29,'outputObfuscator':_0x4ffc3b,'runStartTime':_0x6447df,'messages':_0x377122,'endOfRunMessage':_0x108d14,'taskExecutions':_0x56e706,'versionOfNxBefore133':_0x3de525,'inner':_0x559dae,'encryptionKey':_0x4511b2,'fileStorage':_0x3feabf,'uploadInCurrentProcess':_0x186675,'runContext':_0x2fdce6});return _0x165824;}))[a1_0x4e66('0x28')](_0x532b50=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0x21b343[a1_0x4e66('0x50')],'lifeCycle':_0x4c8d13,'options':_0x3d0cee,'remoteCache':_0x7d41d2,'api':_0x3f6e29,'outputObfuscator':_0x4ffc3b,'runStartTime':_0x6447df,'messages':_0x377122,'endOfRunMessage':_0x108d14,'taskExecutions':_0x56e706,'versionOfNxBefore133':_0x3de525,'inner':_0x559dae,'encryptionKey':_0x4511b2,'fileStorage':_0x3feabf,'uploadInCurrentProcess':_0x186675,'runContext':_0x2fdce6});throw _0x532b50;}));}}exports['cloudEnabledTasksRunner']=cloudEnabledTasksRunner;
|