@nrwl/nx-cloud 15.0.1-beta.1 → 15.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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_0x18e0=['value','axiosMultipleTries','../../utilities/axios','../../utilities/nx-imports','__awaiter','defineProperty','then','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','__esModule','apiAxiosInstance','reportError','throw','done','next','post','ErrorReporterApi','createApiAxiosInstance','warn'];(function(_0x13ba74,_0x18e099){const _0x9db988=function(_0x1f64c0){while(--_0x1f64c0){_0x13ba74['push'](_0x13ba74['shift']());}};_0x9db988(++_0x18e099);}(a0_0x18e0,0xb6));const a0_0x9db9=function(_0x13ba74,_0x18e099){_0x13ba74=_0x13ba74-0x0;let _0x9db988=a0_0x18e0[_0x13ba74];return _0x9db988;};'use strict';var __awaiter=this&&this[a0_0x9db9('0x2')]||function(_0x477e3e,_0x108b1b,_0x59402b,_0x4c104a){function _0x108a2d(_0x13ce98){return _0x13ce98 instanceof _0x59402b?_0x13ce98:new _0x59402b(function(_0x524be1){_0x524be1(_0x13ce98);});}return new(_0x59402b||(_0x59402b=Promise))(function(_0x130498,_0x54a535){function _0x1e6a1a(_0x51f6b0){try{_0x2c1ffb(_0x4c104a[a0_0x9db9('0xb')](_0x51f6b0));}catch(_0xdaee21){_0x54a535(_0xdaee21);}}function _0x2261e4(_0x4229b6){try{_0x2c1ffb(_0x4c104a[a0_0x9db9('0x9')](_0x4229b6));}catch(_0x46ade7){_0x54a535(_0x46ade7);}}function _0x2c1ffb(_0x4e90d8){_0x4e90d8[a0_0x9db9('0xa')]?_0x130498(_0x4e90d8[a0_0x9db9('0x10')]):_0x108a2d(_0x4e90d8[a0_0x9db9('0x10')])[a0_0x9db9('0x4')](_0x1e6a1a,_0x2261e4);}_0x2c1ffb((_0x4c104a=_0x4c104a['apply'](_0x477e3e,_0x108b1b||[]))[a0_0x9db9('0xb')]());});};Object[a0_0x9db9('0x3')](exports,a0_0x9db9('0x6'),{'value':!![]});exports[a0_0x9db9('0xd')]=void 0x0;const axios_1=require(a0_0x9db9('0x0'));const {output}=require(a0_0x9db9('0x1'));class ErrorReporterApi{constructor(_0x419fcb){this[a0_0x9db9('0x7')]=(0x0,axios_1[a0_0x9db9('0xe')])(_0x419fcb);}[a0_0x9db9('0x8')](_0xbb2b57){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x9db9('0x11')])(()=>this[a0_0x9db9('0x7')][a0_0x9db9('0xc')]('/nx-cloud/report-client-error',{'message':_0xbb2b57}));}catch(_0x55bf47){output[a0_0x9db9('0xf')]({'title':a0_0x9db9('0x5')+_0xbb2b57+'\x27','bodyLines':[_0x55bf47['message']]});}});}}exports[a0_0x9db9('0xd')]=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_0x536d=['/nx-cloud/executions/create-run-group','exit','error','axiosMultipleTries','createMetricRecorder','apiAxiosInstance','response','/nx-cloud/executions/complete-run-group','RunGroupApi','createApiAxiosInstance','throw','then','value','axiosException','done','__esModule','recordMetric','__awaiter','../../utilities/axios','../../utilities/metric-logger','createRunGroup','apply','defineProperty','message','../../utilities/nx-imports','mapRespToPerfEntry','RUNNER_FAILURE_PERF_ENTRY','next'];(function(_0xbde8c9,_0x536d5d){const _0x4fb77f=function(_0x423483){while(--_0x423483){_0xbde8c9['push'](_0xbde8c9['shift']());}};_0x4fb77f(++_0x536d5d);}(a1_0x536d,0x95));const a1_0x4fb7=function(_0xbde8c9,_0x536d5d){_0xbde8c9=_0xbde8c9-0x0;let _0x4fb77f=a1_0x536d[_0xbde8c9];return _0x4fb77f;};'use strict';var __awaiter=this&&this[a1_0x4fb7('0x8')]||function(_0x2744f7,_0x5a7c64,_0x4c1684,_0x5db065){function _0x20efd1(_0x2a0205){return _0x2a0205 instanceof _0x4c1684?_0x2a0205:new _0x4c1684(function(_0x3d157e){_0x3d157e(_0x2a0205);});}return new(_0x4c1684||(_0x4c1684=Promise))(function(_0x4793f7,_0x20530f){function _0x30a6d0(_0x20cb11){try{_0x17af0a(_0x5db065[a1_0x4fb7('0x12')](_0x20cb11));}catch(_0xbda311){_0x20530f(_0xbda311);}}function _0x5673f1(_0x399461){try{_0x17af0a(_0x5db065[a1_0x4fb7('0x1')](_0x399461));}catch(_0x2ebe9b){_0x20530f(_0x2ebe9b);}}function _0x17af0a(_0x4a4f9b){_0x4a4f9b[a1_0x4fb7('0x5')]?_0x4793f7(_0x4a4f9b[a1_0x4fb7('0x3')]):_0x20efd1(_0x4a4f9b[a1_0x4fb7('0x3')])[a1_0x4fb7('0x2')](_0x30a6d0,_0x5673f1);}_0x17af0a((_0x5db065=_0x5db065[a1_0x4fb7('0xc')](_0x2744f7,_0x5a7c64||[]))[a1_0x4fb7('0x12')]());});};Object[a1_0x4fb7('0xd')](exports,a1_0x4fb7('0x6'),{'value':!![]});exports['RunGroupApi']=void 0x0;const axios_1=require(a1_0x4fb7('0x9'));const metric_logger_1=require(a1_0x4fb7('0xa'));const {output}=require(a1_0x4fb7('0xf'));class RunGroupApi{constructor(_0x563b95){this['apiAxiosInstance']=(0x0,axios_1[a1_0x4fb7('0x0')])(_0x563b95);}[a1_0x4fb7('0xb')](_0x789cdf,_0x222578,_0x587950,_0x5639f9,_0x55d864){var _0xe39d2f;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2e1904=(0x0,metric_logger_1[a1_0x4fb7('0x17')])(a1_0x4fb7('0xb'));try{const _0x2884c3=yield(0x0,axios_1[a1_0x4fb7('0x16')])(()=>this['apiAxiosInstance']['post'](a1_0x4fb7('0x13'),{'branch':_0x789cdf,'runGroup':_0x222578,'stopAgentsOnFailure':_0x587950,'agentCount':_0x5639f9,'stopAgentsAfter':_0x55d864}));_0x2e1904[a1_0x4fb7('0x7')]((0x0,metric_logger_1[a1_0x4fb7('0x10')])(_0x2884c3));}catch(_0x55f46b){_0x2e1904['recordMetric'](((_0xe39d2f=_0x55f46b===null||_0x55f46b===void 0x0?void 0x0:_0x55f46b[a1_0x4fb7('0x4')])===null||_0xe39d2f===void 0x0?void 0x0:_0xe39d2f[a1_0x4fb7('0x19')])?(0x0,metric_logger_1[a1_0x4fb7('0x10')])(_0x55f46b['axiosException'][a1_0x4fb7('0x19')]):metric_logger_1[a1_0x4fb7('0x11')]);output[a1_0x4fb7('0x15')]({'title':_0x55f46b['message']});process['exit'](0x1);}});}['completeRunGroup'](_0x3ff3cb){var _0x19a12b;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x53d089=(0x0,metric_logger_1[a1_0x4fb7('0x17')])(a1_0x4fb7('0xb'));try{const _0x35cb40=yield(0x0,axios_1[a1_0x4fb7('0x16')])(()=>this[a1_0x4fb7('0x18')]['post'](a1_0x4fb7('0x1a'),{'runGroup':_0x3ff3cb}));_0x53d089['recordMetric']((0x0,metric_logger_1[a1_0x4fb7('0x10')])(_0x35cb40));}catch(_0x23d91d){_0x53d089[a1_0x4fb7('0x7')](((_0x19a12b=_0x23d91d===null||_0x23d91d===void 0x0?void 0x0:_0x23d91d[a1_0x4fb7('0x4')])===null||_0x19a12b===void 0x0?void 0x0:_0x19a12b[a1_0x4fb7('0x19')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x23d91d[a1_0x4fb7('0x4')][a1_0x4fb7('0x19')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x4fb7('0x15')]({'title':_0x23d91d[a1_0x4fb7('0xe')]});process[a1_0x4fb7('0x14')](0x1);}});}}exports[a1_0x4fb7('0x1b')]=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_0x3d97=['join','defineProperty','CloudEnabledLifeCycle','params','../../../utilities/nx-imports','task','forEach','TRUNCATED\x0a\x0a','local-cache-hit','readTerminalOutputFile','cache-miss','local-cache-kept-existing','NX_CLOUD_UNLIMITED_OUTPUT','__esModule','MAX_CHARACTERS_CACHED_TASK','endTasks','indexOf','MAX_CHARACTERS_FAILED_TASK','scheduledTasks','tasks','cache','skipNxCache','outputObfuscator','nodes','cacheStatus','terminalOutput','target','startTask','../../../utilities/environment','code','readFileSync','status','project','endCommand','taskId','hash','toString','cleanUpHashDetails','implicitDeps','serializeOverrides','MAX_CHARACTERS_SUCCESSFUL_TASK','scheduleTask','.cache','../../../utilities/serializer-overrides','filter','local-cache','endTime','runContext','obfuscate','length','cacheableOperations','runtime','remote-cache','cacheDirectory','toISOString','updateStartedTask','collectTerminalOutput','getTerminalOutput','startsWith','remote-cache-hit','statuses','push','node_modules'];(function(_0x3db1c5,_0x3d9757){const _0x502b37=function(_0x45466d){while(--_0x45466d){_0x3db1c5['push'](_0x3db1c5['shift']());}};_0x502b37(++_0x3d9757);}(a0_0x3d97,0x167));const a0_0x502b=function(_0x3db1c5,_0x3d9757){_0x3db1c5=_0x3db1c5-0x0;let _0x502b37=a0_0x3d97[_0x3db1c5];return _0x502b37;};'use strict';Object[a0_0x502b('0x14')](exports,a0_0x502b('0x20'),{'value':!![]});exports['CloudEnabledLifeCycle']=void 0x0;const path=require('path');const path_1=require('path');const fs_1=require('fs');const environment_1=require(a0_0x502b('0x2f'));const serializer_overrides_1=require(a0_0x502b('0x3e'));const {workspaceRoot}=require(a0_0x502b('0x17'));class CloudEnabledLifeCycle{constructor(_0x581531,_0x1a319d,_0x3f337f,_0x1fb08f,_0x597a57,_0x4df392,_0x42bdcf){this[a0_0x502b('0x3')]=_0x581531;this[a0_0x502b('0x9')]=_0x1a319d;this['skipNxCache']=_0x3f337f;this[a0_0x502b('0xc')]=_0x1fb08f;this[a0_0x502b('0x6')]=_0x597a57;this[a0_0x502b('0x29')]=_0x4df392;this[a0_0x502b('0x26')]=_0x42bdcf;}[a0_0x502b('0x3c')](_0x5dceb7){this[a0_0x502b('0x3')][a0_0x502b('0x25')][a0_0x502b('0x11')](_0x5dceb7);}[a0_0x502b('0x2e')](_0x2d7b06){this[a0_0x502b('0x26')][a0_0x502b('0x11')]({'taskId':_0x2d7b06['id'],'startTime':new Date()[a0_0x502b('0xa')](),'target':_0x2d7b06['target'][a0_0x502b('0x2d')],'projectName':_0x2d7b06['target'][a0_0x502b('0x33')],'hash':_0x2d7b06[a0_0x502b('0x36')],'hashDetails':this[a0_0x502b('0x38')](_0x2d7b06['hashDetails']),'params':(0x0,serializer_overrides_1[a0_0x502b('0x3a')])(_0x2d7b06)});}['endTask'](_0x2f7f8a,_0x22dfb0){let _0xbe1b9f;if(this[a0_0x502b('0x3')][a0_0x502b('0x10')][_0x2f7f8a[a0_0x502b('0x36')]]){_0xbe1b9f=this[a0_0x502b('0x3')][a0_0x502b('0x10')][_0x2f7f8a[a0_0x502b('0x36')]];}else{if(this[a0_0x502b('0x6')][a0_0x502b('0x23')](_0x2f7f8a[a0_0x502b('0x2d')][a0_0x502b('0x2d')])>-0x1&&!this[a0_0x502b('0x28')]){_0xbe1b9f=a0_0x502b('0x1b');}else{_0xbe1b9f='cache-miss';}}this['updateStartedTask'](_0x2f7f8a,_0x22dfb0,_0xbe1b9f);}[a0_0x502b('0x22')](_0x3141b8){for(let _0x3d437d of _0x3141b8){let _0x50e305;const _0xa409ee=_0x3d437d[a0_0x502b('0x32')]===a0_0x502b('0x8');const _0xe36737=_0x3d437d[a0_0x502b('0x32')]===a0_0x502b('0x27');const _0x6cbdf6=_0x3d437d[a0_0x502b('0x32')]===a0_0x502b('0x1')||_0x3d437d[a0_0x502b('0x32')]===a0_0x502b('0x1e')||_0xe36737;if(this[a0_0x502b('0x3')][a0_0x502b('0x10')][_0x3d437d['task'][a0_0x502b('0x36')]]){_0x50e305=this['runContext'][a0_0x502b('0x10')][_0x3d437d[a0_0x502b('0x18')][a0_0x502b('0x36')]];}else if(_0xa409ee){_0x50e305=a0_0x502b('0xf');}else if(_0x6cbdf6){_0x50e305='local-cache-hit';}else{if(this[a0_0x502b('0x6')][a0_0x502b('0x23')](_0x3d437d[a0_0x502b('0x18')][a0_0x502b('0x2d')]['target'])>-0x1&&!this[a0_0x502b('0x28')]){_0x50e305=a0_0x502b('0x1b');}else{_0x50e305=a0_0x502b('0x1d');}}this[a0_0x502b('0xb')](_0x3d437d[a0_0x502b('0x18')],_0x3d437d[a0_0x502b('0x30')],_0x50e305);}}[a0_0x502b('0x34')](){}[a0_0x502b('0xb')](_0x197681,_0x4f2dd6,_0x539023){const _0x9fbb4d=this[a0_0x502b('0x26')]['find'](_0x28e5a9=>_0x28e5a9[a0_0x502b('0x35')]===_0x197681['id']);if(!_0x9fbb4d){throw new Error('Cannot\x20find\x20task\x20'+_0x197681['id']);}_0x9fbb4d[a0_0x502b('0x2')]=new Date()[a0_0x502b('0xa')]();_0x9fbb4d[a0_0x502b('0x32')]=_0x4f2dd6;_0x9fbb4d['params']=this[a0_0x502b('0x29')][a0_0x502b('0x4')](_0x9fbb4d[a0_0x502b('0x16')]);_0x9fbb4d[a0_0x502b('0x2b')]=_0x539023;if(this[a0_0x502b('0xc')]){_0x9fbb4d[a0_0x502b('0x2c')]=this[a0_0x502b('0xd')](_0x197681[a0_0x502b('0x36')],_0x9fbb4d[a0_0x502b('0x2b')],_0x4f2dd6);}}[a0_0x502b('0xd')](_0x3c63fc,_0x19cb92,_0x1d488e){let _0x5eb819;if(this[a0_0x502b('0x9')]){if(this[a0_0x502b('0x9')][a0_0x502b('0xe')]('./')){_0x5eb819=(0x0,path_1[a0_0x502b('0x13')])(workspaceRoot,this[a0_0x502b('0x9')]);}else{_0x5eb819=this[a0_0x502b('0x9')];}}else{_0x5eb819=(0x0,path_1[a0_0x502b('0x13')])(workspaceRoot,a0_0x502b('0x12'),a0_0x502b('0x3d'),'nx');}try{const _0x30fed5=this[a0_0x502b('0x1c')](_0x5eb819,_0x3c63fc);const _0x48d164=this['outputObfuscator'][a0_0x502b('0x4')](_0x30fed5);if(environment_1[a0_0x502b('0x1f')])return _0x48d164;const _0x1a5a22=_0x19cb92==='cache-miss'?_0x1d488e===0x0?CloudEnabledLifeCycle[a0_0x502b('0x3b')]:CloudEnabledLifeCycle['MAX_CHARACTERS_FAILED_TASK']:CloudEnabledLifeCycle[a0_0x502b('0x21')];return _0x48d164[a0_0x502b('0x5')]>_0x1a5a22?a0_0x502b('0x1a')+_0x48d164['slice'](_0x48d164['length']-_0x1a5a22):_0x48d164;}catch(_0x1d4e41){return'';}}[a0_0x502b('0x38')](_0x41ac90){const _0x46a9bc={};Object['keys'](_0x41ac90['nodes'])[a0_0x502b('0x0')](_0x28e159=>!_0x28e159['startsWith']('npm:'))[a0_0x502b('0x19')](_0x27f151=>{_0x46a9bc[_0x27f151]=_0x41ac90[a0_0x502b('0x2a')][_0x27f151];});return{'nodes':_0x46a9bc,'runtime':_0x41ac90[a0_0x502b('0x7')],'implicitDeps':_0x41ac90[a0_0x502b('0x39')]};}['readTerminalOutputFile'](_0x48439a,_0x198c9e){try{return(0x0,fs_1[a0_0x502b('0x31')])(path[a0_0x502b('0x13')](_0x48439a,'terminalOutputs',_0x198c9e))['toString']();}catch(_0x41a160){try{return(0x0,fs_1['readFileSync'])(path[a0_0x502b('0x13')](_0x48439a,_0x198c9e,a0_0x502b('0x2c')))[a0_0x502b('0x37')]();}catch(_0x472939){return'';}}}}exports[a0_0x502b('0x15')]=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x502b('0x24')]=0x30d40;CloudEnabledLifeCycle['MAX_CHARACTERS_SUCCESSFUL_TASK']=0x4e20;CloudEnabledLifeCycle[a0_0x502b('0x21')]=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_0x2069=['./cloud-enabled-life-cycle','printMessages','encryptionKey','message','catch','cachePath','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','./cloud-run.api','exit','filter','api.nrwl.io','then','../../terminal-output/output-obfuscator','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','anyErrors','processInBackground','CloudRemoteCache','scan','apply','rxjs/internal/Subject','./id-generator','../../file-storage/file-storage','CloudEnabledLifeCycle','../../../utilities/metric-logger','printCacheHitsMessage','localhost','getRunGroup','toString','endRun','next','getMachineInfo','https://nx.app','cacheDirectory','indexOf','value','subscribe','requests','submitRunMetrics','getBranch','.nx.app','lifeCycle','parseCommand','VERBOSE_LOGGING','EndOfRunMessage','../../file-storage/e2e-encryption','throw','done','../../../utilities/nx-imports','daemon','generateUniqueLinkId','ACCESS_TOKEN','skipNxCache','complete','enabled','url','obfuscate','OutputObfuscator','fs-extra','ErrorReporterApi','__awaiter','E2EEncryption','join','../../api/error-reporter.api','runUrl','hash','push','.commit','CloudRunApi','ENCRYPTION_KEY','../../terminal-output/message-reporter','startRun','map','accessToken','../../../utilities/environment','all','tasks-hashes-','waitForStoreRequestsToComplete','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','FileStorage','/runs/','Nx\x20Cloud\x20Problems','warn','note','taskId','cloudEnabledTasksRunner','Executed\x20tasks\x20with\x20hashes:\x20','error','length','defineProperty','pathExists','toISOString','endsWith'];(function(_0x284b44,_0x206967){const _0x3386e3=function(_0x3b6455){while(--_0x3b6455){_0x284b44['push'](_0x284b44['shift']());}};_0x3386e3(++_0x206967);}(a1_0x2069,0x10d));const a1_0x3386=function(_0x284b44,_0x206967){_0x284b44=_0x284b44-0x0;let _0x3386e3=a1_0x2069[_0x284b44];return _0x3386e3;};'use strict';var __awaiter=this&&this[a1_0x3386('0x45')]||function(_0x5766d3,_0x5ed128,_0x4bb2aa,_0x38489c){function _0x9e2ed5(_0x16b7a6){return _0x16b7a6 instanceof _0x4bb2aa?_0x16b7a6:new _0x4bb2aa(function(_0x208895){_0x208895(_0x16b7a6);});}return new(_0x4bb2aa||(_0x4bb2aa=Promise))(function(_0x59c552,_0x448ae0){function _0x340ec2(_0x38f395){try{_0x56a326(_0x38489c[a1_0x3386('0x27')](_0x38f395));}catch(_0x3e9338){_0x448ae0(_0x3e9338);}}function _0xd1b9a8(_0x379599){try{_0x56a326(_0x38489c[a1_0x3386('0x37')](_0x379599));}catch(_0x58639f){_0x448ae0(_0x58639f);}}function _0x56a326(_0xf9344a){_0xf9344a[a1_0x3386('0x38')]?_0x59c552(_0xf9344a[a1_0x3386('0x2c')]):_0x9e2ed5(_0xf9344a[a1_0x3386('0x2c')])[a1_0x3386('0x15')](_0x340ec2,_0xd1b9a8);}_0x56a326((_0x38489c=_0x38489c[a1_0x3386('0x1c')](_0x5766d3,_0x5ed128||[]))[a1_0x3386('0x27')]());});};Object[a1_0x3386('0x6')](exports,'__esModule',{'value':!![]});exports[a1_0x3386('0x2')]=void 0x0;const message_reporter_1=require(a1_0x3386('0x4f'));const end_of_run_message_1=require('../../terminal-output/end-of-run-message');const output_obfuscator_1=require(a1_0x3386('0x16'));const cloud_enabled_life_cycle_1=require(a1_0x3386('0xa'));const file_storage_1=require(a1_0x3386('0x1f'));const e2e_encryption_1=require(a1_0x3386('0x36'));const environment_1=require(a1_0x3386('0x53'));const cloud_remote_cache_1=require('./cloud-remote-cache');const cloud_run_api_1=require(a1_0x3386('0x11'));const fs_1=require('fs');const path=require('path');const metric_logger_1=require(a1_0x3386('0x21'));const error_reporter_api_1=require(a1_0x3386('0x48'));const path_1=require('path');const fs_extra_1=require(a1_0x3386('0x43'));const id_generator_1=require(a1_0x3386('0x1e'));const {tasksRunner,output,Cache}=require(a1_0x3386('0x39'));function createApi(_0x304bac,_0x477705,_0x47887c){const _0xc2e06e=(0x0,environment_1[a1_0x3386('0x28')])(_0x477705);return new cloud_run_api_1[(a1_0x3386('0x4d'))](_0x304bac,_0x47887c,_0x477705,_0xc2e06e);}function storeTaskHashes(_0x366f62,_0x26e1dc,_0x350aa8){const _0x677720=JSON['stringify'](_0x366f62[a1_0x3386('0x51')](_0x10e4ff=>({'taskId':_0x10e4ff[a1_0x3386('0x1')],'hash':_0x10e4ff[a1_0x3386('0x4a')]})));if(environment_1[a1_0x3386('0x34')]){output[a1_0x3386('0x0')]({'title':a1_0x3386('0x3')+_0x677720});}(0x0,fs_1['writeFileSync'])(path[a1_0x3386('0x47')](_0x26e1dc,a1_0x3386('0x55')+_0x350aa8),_0x677720);}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 _0x1dbe14=new Date()[a1_0x3386('0x8')]();const _0xd22129=(0x0,environment_1[a1_0x3386('0x30')])();const _0x19efca={'command':outputObfuscator[a1_0x3386('0x41')]((0x0,environment_1[a1_0x3386('0x33')])()),'startTime':runStartTime,'endTime':_0x1dbe14,'distributedExecutionId':environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],'branch':_0xd22129,'scan':!![],'runGroup':(0x0,environment_1[a1_0x3386('0x24')])(),'sha':_0xd22129?(0x0,environment_1['extractGitSha'])():undefined,'inner':inner};if(uploadInCurrentProcess){if(environment_1['AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION']){storeTaskHashes(taskExecutions,options['cacheDirectory']||'./node_modules/.cache/nx',environment_1[a1_0x3386('0x17')]);}try{yield remoteCache[a1_0x3386('0x56')]();}catch(_0x42bc8e){output['error']({'title':a1_0x3386('0x58')});messages[a1_0x3386('0xb')]();process[a1_0x3386('0x12')](environment_1[a1_0x3386('0x57')]);}try{yield api[a1_0x3386('0x26')](_0x19efca,taskExecutions);}catch(_0x5437d5){output[a1_0x3386('0x4')]({'title':a1_0x3386('0x10')});messages[a1_0x3386('0xb')]();process[a1_0x3386('0x12')](environment_1[a1_0x3386('0x57')]);}yield(0x0,metric_logger_1[a1_0x3386('0x2f')])(options);}else{try{const _0x229343=environment_1[a1_0x3386('0x3c')]?environment_1[a1_0x3386('0x3c')]:options[a1_0x3386('0x52')];const _0x255d9b=(0x0,id_generator_1[a1_0x3386('0x3b')])();yield daemon[a1_0x3386('0x19')]('@nrwl/nx-cloud/lib/daemon/process-run-end',{'encryptionKey':encryptionKey,'runnerOptions':Object['assign'](Object['assign']({},options),{'accessToken':_0x229343}),'uploads':fileStorage['uploads'],'runEnd':{'runData':_0x19efca,'taskExecutions':taskExecutions,'linkId':_0x255d9b}});runContext[a1_0x3386('0x49')]=(options['url']||a1_0x3386('0x29'))+a1_0x3386('0x5a')+_0x255d9b;}catch(_0x27d5fc){output[a1_0x3386('0x5c')]({'title':a1_0x3386('0x5b'),'bodyLines':[_0x27d5fc[a1_0x3386('0xd')]||_0x27d5fc[a1_0x3386('0x25')]()]});}}if(versionOfNxBefore133){setTimeout(()=>{messages[a1_0x3386('0xb')]();if(!messages['anyErrors']&&!inner){endOfRunMessage[a1_0x3386('0x22')]();}},0x0);}else{messages[a1_0x3386('0xb')]();if(!messages[a1_0x3386('0x18')]&&!inner){endOfRunMessage[a1_0x3386('0x22')]();}}});}function createLifeCycle(_0x1bc10d,_0x15710c,_0x47f4ef,_0x30fa9a){const _0x278577=new cloud_enabled_life_cycle_1[(a1_0x3386('0x20'))](_0x1bc10d,_0x15710c[a1_0x3386('0x2a')],!!_0x15710c[a1_0x3386('0x3d')],_0x15710c[a1_0x3386('0x1b')]===undefined?!![]:_0x15710c[a1_0x3386('0x1b')],_0x15710c['cacheableOperations']||[],_0x47f4ef,_0x30fa9a);try{const {CompositeLifeCycle}=require(a1_0x3386('0x39'));if(!CompositeLifeCycle)return _0x278577;return new CompositeLifeCycle([_0x15710c[a1_0x3386('0x32')],_0x278577]);}catch(_0x361a78){return _0x278577;}}function fetchUrlsForKnownHashesUpfront(_0x1129b9,_0x26dd89,_0x74366c,_0x2872d3){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x52ad46=_0x74366c[a1_0x3386('0x51')](_0x49e3f5=>_0x49e3f5[a1_0x3386('0x4a')])[a1_0x3386('0x13')](_0x4b9c11=>!!_0x4b9c11);const _0xe48e0=new Cache(_0x2872d3);if(!_0x2872d3[a1_0x3386('0x3d')]){const _0x48a433=yield Promise[a1_0x3386('0x54')](_0x52ad46[a1_0x3386('0x51')](_0xc85f0b=>{const _0x23df08=(0x0,path_1['join'])(_0xe48e0[a1_0x3386('0xf')],_0xc85f0b+a1_0x3386('0x4c'));return(0x0,fs_extra_1[a1_0x3386('0x7')])(_0x23df08);}));const _0x2184d3=[];for(let _0x12df55=0x0;_0x12df55<_0x48a433['length'];++_0x12df55){if(_0x48a433[_0x12df55]){_0x2184d3[a1_0x3386('0x4b')](_0x52ad46[_0x12df55]);}}_0x52ad46=_0x2184d3;}if(_0x52ad46[a1_0x3386('0x5')]>0x0){const _0x3afc22=_0x1129b9[a1_0x3386('0x50')](environment_1[a1_0x3386('0x17')],_0x52ad46);for(const _0x40eeb2 of _0x52ad46){_0x26dd89[a1_0x3386('0x2e')][_0x40eeb2]=_0x3afc22;}}});}function isConnectedToPrivateCloud(_0x35dea1){if(!_0x35dea1['url'])return![];if(_0x35dea1['url'][a1_0x3386('0x9')](a1_0x3386('0x14')))return![];if(_0x35dea1[a1_0x3386('0x40')][a1_0x3386('0x9')](a1_0x3386('0x31')))return![];if(_0x35dea1[a1_0x3386('0x40')][a1_0x3386('0x2b')](a1_0x3386('0x23'))>-0x1)return![];return!![];}function cloudEnabledTasksRunner(_0x5a7105,_0x90db70,_0x5ccda8,_0x48f15d=![]){var _0x18370e;const _0x3d4e50={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x5a7105};const _0x2f495f=_0x90db70[a1_0x3386('0x32')]===undefined;const _0x47030a=[];const _0x1bb5e5=new message_reporter_1['MessageReporter'](_0x90db70);const _0x16654b=createApi(_0x1bb5e5,_0x90db70,_0x3d4e50);const _0x35d750=new end_of_run_message_1[(a1_0x3386('0x35'))](_0x3d4e50,_0x47030a);const _0x5226ae=new output_obfuscator_1[(a1_0x3386('0x42'))](_0x90db70['maskedProperties']);const _0x5a76ba=new Date()[a1_0x3386('0x8')]();const _0x5b3722=createLifeCycle(_0x3d4e50,_0x90db70,_0x5226ae,_0x47030a);const _0x113dd3=environment_1[a1_0x3386('0x4e')]||_0x90db70[a1_0x3386('0xc')];const _0x299988=new e2e_encryption_1[(a1_0x3386('0x46'))](_0x113dd3);const _0x4bbb4c=new error_reporter_api_1[(a1_0x3386('0x44'))](_0x90db70);const _0x17f8fa=!!environment_1['AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION']||!((_0x18370e=_0x5ccda8[a1_0x3386('0x3a')])===null||_0x18370e===void 0x0?void 0x0:_0x18370e[a1_0x3386('0x3f')]())||isConnectedToPrivateCloud(_0x90db70);const _0x3f519b=new file_storage_1[(a1_0x3386('0x59'))](_0x299988,_0x4bbb4c,![],_0x17f8fa);const _0x154494=new cloud_remote_cache_1[(a1_0x3386('0x1a'))](_0x1bb5e5,_0x16654b,_0x3d4e50,_0x3f519b);fetchUrlsForKnownHashesUpfront(_0x16654b,_0x3d4e50,_0x5a7105,_0x90db70);delete process['env'][a1_0x3386('0x17')];const _0x582dbf=tasksRunner(_0x5a7105,Object['assign'](Object['assign']({},_0x90db70),{'remoteCache':_0x154494,'lifeCycle':_0x5b3722}),_0x5ccda8);if(_0x582dbf[a1_0x3386('0x2d')]){const {Subject}=require(a1_0x3386('0x1d'));const _0xc48042=new Subject();_0x582dbf['subscribe']({'next':_0x9405b=>_0xc48042[a1_0x3386('0x27')](_0x9405b),'error':_0x48e5ce=>_0xc48042[a1_0x3386('0x4')](_0x48e5ce),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0x5ccda8[a1_0x3386('0x3a')],'lifeCycle':_0x5b3722,'options':_0x90db70,'remoteCache':_0x154494,'api':_0x16654b,'outputObfuscator':_0x5226ae,'runStartTime':_0x5a76ba,'messages':_0x1bb5e5,'endOfRunMessage':_0x35d750,'taskExecutions':_0x47030a,'versionOfNxBefore133':_0x2f495f,'inner':_0x48f15d,'encryptionKey':_0x113dd3,'fileStorage':_0x3f519b,'uploadInCurrentProcess':_0x17f8fa,'runContext':_0x3d4e50});_0xc48042[a1_0x3386('0x3e')]();})});return _0xc48042;}else{return _0x582dbf[a1_0x3386('0x15')](_0x53fa88=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0x5ccda8[a1_0x3386('0x3a')],'lifeCycle':_0x5b3722,'options':_0x90db70,'remoteCache':_0x154494,'api':_0x16654b,'outputObfuscator':_0x5226ae,'runStartTime':_0x5a76ba,'messages':_0x1bb5e5,'endOfRunMessage':_0x35d750,'taskExecutions':_0x47030a,'versionOfNxBefore133':_0x2f495f,'inner':_0x48f15d,'encryptionKey':_0x113dd3,'fileStorage':_0x3f519b,'uploadInCurrentProcess':_0x17f8fa,'runContext':_0x3d4e50});return _0x53fa88;}))[a1_0x3386('0xe')](_0x3a87c1=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0x5ccda8['daemon'],'lifeCycle':_0x5b3722,'options':_0x90db70,'remoteCache':_0x154494,'api':_0x16654b,'outputObfuscator':_0x5226ae,'runStartTime':_0x5a76ba,'messages':_0x1bb5e5,'endOfRunMessage':_0x35d750,'taskExecutions':_0x47030a,'versionOfNxBefore133':_0x2f495f,'inner':_0x48f15d,'encryptionKey':_0x113dd3,'fileStorage':_0x3f519b,'uploadInCurrentProcess':_0x17f8fa,'runContext':_0x3d4e50});throw _0x3a87c1;}));}}exports[a1_0x3386('0x2')]=cloudEnabledTasksRunner;
|