@nrwl/nx-cloud 14.0.6-beta.1 → 14.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/api/error-reporter.api.js +1 -36
- package/lib/core/api/run-group.api.js +1 -65
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -141
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -169
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -113
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -166
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -79
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -240
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -130
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -309
- package/lib/utilities/nx-imports.js +9 -3
- package/lib/utilities/nx-imports.js.map +1 -1
- 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_0x5ce5=['/nx-cloud/report-client-error','createApiAxiosInstance','apiAxiosInstance','done','reportError','__awaiter','post','defineProperty','../../utilities/axios','__esModule','then','warn','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','value'];(function(_0x49e78c,_0x5ce549){const _0xe2debe=function(_0x3d87d4){while(--_0x3d87d4){_0x49e78c['push'](_0x49e78c['shift']());}};_0xe2debe(++_0x5ce549);}(a0_0x5ce5,0x19a));const a0_0xe2de=function(_0x49e78c,_0x5ce549){_0x49e78c=_0x49e78c-0x0;let _0xe2debe=a0_0x5ce5[_0x49e78c];return _0xe2debe;};'use strict';var __awaiter=this&&this[a0_0xe2de('0x1')]||function(_0x3d67d0,_0x3f619e,_0x216d74,_0x1a51a1){function _0x5db3ea(_0x4c6cec){return _0x4c6cec instanceof _0x216d74?_0x4c6cec:new _0x216d74(function(_0x9f850e){_0x9f850e(_0x4c6cec);});}return new(_0x216d74||(_0x216d74=Promise))(function(_0x4ed480,_0x3b1d35){function _0x24cbbd(_0xda2f4f){try{_0x4ee61f(_0x1a51a1['next'](_0xda2f4f));}catch(_0x4bb9f3){_0x3b1d35(_0x4bb9f3);}}function _0x3a59a1(_0x15caa4){try{_0x4ee61f(_0x1a51a1['throw'](_0x15caa4));}catch(_0x231ccb){_0x3b1d35(_0x231ccb);}}function _0x4ee61f(_0x37a0e1){_0x37a0e1[a0_0xe2de('0xd')]?_0x4ed480(_0x37a0e1[a0_0xe2de('0x9')]):_0x5db3ea(_0x37a0e1[a0_0xe2de('0x9')])[a0_0xe2de('0x6')](_0x24cbbd,_0x3a59a1);}_0x4ee61f((_0x1a51a1=_0x1a51a1['apply'](_0x3d67d0,_0x3f619e||[]))['next']());});};Object[a0_0xe2de('0x3')](exports,a0_0xe2de('0x5'),{'value':!![]});exports['ErrorReporterApi']=void 0x0;const axios_1=require(a0_0xe2de('0x4'));const {output}=require('../../utilities/nx-imports');class ErrorReporterApi{constructor(_0x1ca038){this[a0_0xe2de('0xc')]=(0x0,axios_1[a0_0xe2de('0xb')])(_0x1ca038);}[a0_0xe2de('0x0')](_0x958016){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a0_0xe2de('0xc')][a0_0xe2de('0x2')](a0_0xe2de('0xa'),{'message':_0x958016}));}catch(_0x2e817f){output[a0_0xe2de('0x7')]({'title':a0_0xe2de('0x8')+_0x958016+'\x27','bodyLines':[_0x2e817f['message']]});}});}}exports['ErrorReporterApi']=ErrorReporterApi;
|
|
@@ -1,65 +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) {
|
|
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: branch,
|
|
27
|
-
runGroup: runGroup,
|
|
28
|
-
}));
|
|
29
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
33
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
34
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
35
|
-
output.error({
|
|
36
|
-
title: e.message,
|
|
37
|
-
});
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
completeRunGroup(runGroup) {
|
|
43
|
-
var _a;
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
46
|
-
try {
|
|
47
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
48
|
-
runGroup: runGroup,
|
|
49
|
-
}));
|
|
50
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
54
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
55
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
56
|
-
output.error({
|
|
57
|
-
title: e.message,
|
|
58
|
-
});
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.RunGroupApi = RunGroupApi;
|
|
65
|
-
//# sourceMappingURL=run-group.api.js.map
|
|
1
|
+
const a1_0x5f3d=['mapRespToPerfEntry','then','axiosException','apiAxiosInstance','response','createApiAxiosInstance','value','__esModule','createMetricRecorder','next','throw','error','../../utilities/metric-logger','recordMetric','RunGroupApi','__awaiter','/nx-cloud/executions/create-run-group','exit','../../utilities/nx-imports','createRunGroup','/nx-cloud/executions/complete-run-group','../../utilities/axios','post','message','done'];(function(_0x23ba1c,_0x5f3d11){const _0x3818e7=function(_0xa7a3ee){while(--_0xa7a3ee){_0x23ba1c['push'](_0x23ba1c['shift']());}};_0x3818e7(++_0x5f3d11);}(a1_0x5f3d,0xfa));const a1_0x3818=function(_0x23ba1c,_0x5f3d11){_0x23ba1c=_0x23ba1c-0x0;let _0x3818e7=a1_0x5f3d[_0x23ba1c];return _0x3818e7;};'use strict';var __awaiter=this&&this[a1_0x3818('0xf')]||function(_0x3e893b,_0x1cae12,_0x41c268,_0x28d70d){function _0x399494(_0x50faa9){return _0x50faa9 instanceof _0x41c268?_0x50faa9:new _0x41c268(function(_0x429200){_0x429200(_0x50faa9);});}return new(_0x41c268||(_0x41c268=Promise))(function(_0x543f3c,_0x188800){function _0xb2135(_0x52285a){try{_0x3c4ad3(_0x28d70d[a1_0x3818('0x9')](_0x52285a));}catch(_0x32f7f4){_0x188800(_0x32f7f4);}}function _0x57784e(_0x5d90ca){try{_0x3c4ad3(_0x28d70d[a1_0x3818('0xa')](_0x5d90ca));}catch(_0x2c1b6a){_0x188800(_0x2c1b6a);}}function _0x3c4ad3(_0xc581ac){_0xc581ac[a1_0x3818('0x18')]?_0x543f3c(_0xc581ac[a1_0x3818('0x6')]):_0x399494(_0xc581ac[a1_0x3818('0x6')])[a1_0x3818('0x1')](_0xb2135,_0x57784e);}_0x3c4ad3((_0x28d70d=_0x28d70d['apply'](_0x3e893b,_0x1cae12||[]))['next']());});};Object['defineProperty'](exports,a1_0x3818('0x7'),{'value':!![]});exports[a1_0x3818('0xe')]=void 0x0;const axios_1=require(a1_0x3818('0x15'));const metric_logger_1=require(a1_0x3818('0xc'));const {output}=require(a1_0x3818('0x12'));class RunGroupApi{constructor(_0x1773cd){this[a1_0x3818('0x3')]=(0x0,axios_1[a1_0x3818('0x5')])(_0x1773cd);}[a1_0x3818('0x13')](_0x180640,_0x1dc063){var _0x1ac459;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x34eae9=(0x0,metric_logger_1[a1_0x3818('0x8')])(a1_0x3818('0x13'));try{const _0x5d6e90=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a1_0x3818('0x3')][a1_0x3818('0x16')](a1_0x3818('0x10'),{'branch':_0x180640,'runGroup':_0x1dc063}));_0x34eae9[a1_0x3818('0xd')]((0x0,metric_logger_1[a1_0x3818('0x0')])(_0x5d6e90));}catch(_0xc745c0){_0x34eae9[a1_0x3818('0xd')](((_0x1ac459=_0xc745c0===null||_0xc745c0===void 0x0?void 0x0:_0xc745c0[a1_0x3818('0x2')])===null||_0x1ac459===void 0x0?void 0x0:_0x1ac459[a1_0x3818('0x4')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0xc745c0[a1_0x3818('0x2')]['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x3818('0xb')]({'title':_0xc745c0[a1_0x3818('0x17')]});process[a1_0x3818('0x11')](0x1);}});}['completeRunGroup'](_0x223bdb){var _0x579df6;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4916c7=(0x0,metric_logger_1['createMetricRecorder'])(a1_0x3818('0x13'));try{const _0x2c974a=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a1_0x3818('0x3')][a1_0x3818('0x16')](a1_0x3818('0x14'),{'runGroup':_0x223bdb}));_0x4916c7[a1_0x3818('0xd')]((0x0,metric_logger_1[a1_0x3818('0x0')])(_0x2c974a));}catch(_0x313167){_0x4916c7[a1_0x3818('0xd')](((_0x579df6=_0x313167===null||_0x313167===void 0x0?void 0x0:_0x313167[a1_0x3818('0x2')])===null||_0x579df6===void 0x0?void 0x0:_0x579df6[a1_0x3818('0x4')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x313167[a1_0x3818('0x2')][a1_0x3818('0x4')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x3818('0xb')]({'title':_0x313167[a1_0x3818('0x17')]});process['exit'](0x1);}});}}exports[a1_0x3818('0xe')]=RunGroupApi;
|
|
@@ -1,141 +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 { workspaceRoot, unparse } = require('../../../utilities/nx-imports');
|
|
9
|
-
class CloudEnabledLifeCycle {
|
|
10
|
-
constructor(runContext, cacheDirectory, skipNxCache, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
|
|
11
|
-
this.runContext = runContext;
|
|
12
|
-
this.cacheDirectory = cacheDirectory;
|
|
13
|
-
this.skipNxCache = skipNxCache;
|
|
14
|
-
this.collectTerminalOutput = collectTerminalOutput;
|
|
15
|
-
this.cacheableOperations = cacheableOperations;
|
|
16
|
-
this.outputObfuscator = outputObfuscator;
|
|
17
|
-
this.tasks = tasks;
|
|
18
|
-
}
|
|
19
|
-
scheduleTask(task) {
|
|
20
|
-
this.runContext.scheduledTasks.push(task);
|
|
21
|
-
}
|
|
22
|
-
startTask(task) {
|
|
23
|
-
const overrides = Object.assign({}, (task.overrides || {}));
|
|
24
|
-
if (task.target.configuration) {
|
|
25
|
-
overrides['configuration'] = task.target.configuration;
|
|
26
|
-
}
|
|
27
|
-
this.tasks.push({
|
|
28
|
-
taskId: task.id,
|
|
29
|
-
startTime: new Date().toISOString(),
|
|
30
|
-
target: task.target.target,
|
|
31
|
-
projectName: task.target.project,
|
|
32
|
-
hash: task.hash,
|
|
33
|
-
hashDetails: this.cleanUpHashDetails(task.hashDetails),
|
|
34
|
-
params: unparse(overrides).join(' '),
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
// Used for older version for Nx. Remove in Dec 2022
|
|
38
|
-
endTask(task, code) {
|
|
39
|
-
let cacheStatus;
|
|
40
|
-
if (this.runContext.statuses[task.hash]) {
|
|
41
|
-
cacheStatus = this.runContext.statuses[task.hash];
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
if (this.cacheableOperations.indexOf(task.target.target) > -1 &&
|
|
45
|
-
!this.skipNxCache) {
|
|
46
|
-
cacheStatus = 'local-cache-hit';
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
cacheStatus = 'cache-miss';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
this.updateStartedTask(task, code, cacheStatus);
|
|
53
|
-
}
|
|
54
|
-
endTasks(tasks) {
|
|
55
|
-
for (let t of tasks) {
|
|
56
|
-
const status = t.status === 'remote-cache'
|
|
57
|
-
? 'remote-cache-hit'
|
|
58
|
-
: t.status === 'local-cache' ||
|
|
59
|
-
t.status === 'local-cache-kept-existing'
|
|
60
|
-
? 'local-cache-hit'
|
|
61
|
-
: 'cache-miss';
|
|
62
|
-
this.updateStartedTask(t.task, t.code, status);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
endCommand() { }
|
|
66
|
-
updateStartedTask(task, code, cacheStatus) {
|
|
67
|
-
const startedTask = this.tasks.find((t) => t.taskId === task.id);
|
|
68
|
-
if (!startedTask) {
|
|
69
|
-
throw new Error(`Cannot find task ${task.id}`);
|
|
70
|
-
}
|
|
71
|
-
startedTask.endTime = new Date().toISOString();
|
|
72
|
-
startedTask.status = code;
|
|
73
|
-
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
|
|
74
|
-
startedTask.cacheStatus = cacheStatus;
|
|
75
|
-
if (this.collectTerminalOutput) {
|
|
76
|
-
startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
getTerminalOutput(hash, cacheStatus, code) {
|
|
80
|
-
let dir;
|
|
81
|
-
if (this.cacheDirectory) {
|
|
82
|
-
if (this.cacheDirectory.startsWith('./')) {
|
|
83
|
-
dir = (0, path_1.join)(workspaceRoot, this.cacheDirectory);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
dir = this.cacheDirectory;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
dir = (0, path_1.join)(workspaceRoot, 'node_modules', '.cache', 'nx');
|
|
91
|
-
}
|
|
92
|
-
try {
|
|
93
|
-
const taskOutput = this.readTerminalOutputFile(dir, hash);
|
|
94
|
-
const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
|
|
95
|
-
if (environment_1.NX_CLOUD_UNLIMITED_OUTPUT)
|
|
96
|
-
return taskOutputSanitized;
|
|
97
|
-
const maxCharacters = cacheStatus === 'cache-miss'
|
|
98
|
-
? code === 0
|
|
99
|
-
? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
|
|
100
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
|
|
101
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
|
|
102
|
-
return taskOutputSanitized.length > maxCharacters
|
|
103
|
-
? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
|
|
104
|
-
: taskOutputSanitized;
|
|
105
|
-
}
|
|
106
|
-
catch (e) {
|
|
107
|
-
return '';
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
cleanUpHashDetails(hashDetails) {
|
|
111
|
-
const nodes = {};
|
|
112
|
-
Object.keys(hashDetails.nodes)
|
|
113
|
-
.filter((k) => !k.startsWith('npm:'))
|
|
114
|
-
.forEach((k) => {
|
|
115
|
-
nodes[k] = hashDetails.nodes[k];
|
|
116
|
-
});
|
|
117
|
-
return {
|
|
118
|
-
nodes,
|
|
119
|
-
runtime: hashDetails.runtime,
|
|
120
|
-
implicitDeps: hashDetails.implicitDeps,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
readTerminalOutputFile(dir, hash) {
|
|
124
|
-
try {
|
|
125
|
-
return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
|
|
126
|
-
}
|
|
127
|
-
catch (_a) {
|
|
128
|
-
try {
|
|
129
|
-
return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
|
|
130
|
-
}
|
|
131
|
-
catch (_b) {
|
|
132
|
-
return '';
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
|
|
138
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
|
|
139
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
|
|
140
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 20000;
|
|
141
|
-
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
|
|
1
|
+
const a0_0xcc69=['obfuscate','implicitDeps','cacheStatus','toISOString','keys','../../../utilities/environment','terminalOutput','code','length','local-cache','find','readFileSync','hashDetails','startsWith','tasks','hash','startTask','push','getTerminalOutput','defineProperty','cache-miss','scheduledTasks','status','cacheDirectory','cacheableOperations','assign','MAX_CHARACTERS_SUCCESSFUL_TASK','updateStartedTask','outputObfuscator','__esModule','endTasks','readTerminalOutputFile','configuration','node_modules','endCommand','runtime','runContext','skipNxCache','params','join','MAX_CHARACTERS_FAILED_TASK','npm:','cleanUpHashDetails','collectTerminalOutput','CloudEnabledLifeCycle','statuses','nodes','MAX_CHARACTERS_CACHED_TASK','toString','remote-cache-hit','path','filter','NX_CLOUD_UNLIMITED_OUTPUT','local-cache-hit','overrides','target','terminalOutputs'];(function(_0x4390b7,_0xcc698f){const _0x1d2d4a=function(_0x706813){while(--_0x706813){_0x4390b7['push'](_0x4390b7['shift']());}};_0x1d2d4a(++_0xcc698f);}(a0_0xcc69,0x180));const a0_0x1d2d=function(_0x4390b7,_0xcc698f){_0x4390b7=_0x4390b7-0x0;let _0x1d2d4a=a0_0xcc69[_0x4390b7];return _0x1d2d4a;};'use strict';Object[a0_0x1d2d('0x22')](exports,a0_0x1d2d('0x2c'),{'value':!![]});exports['CloudEnabledLifeCycle']=void 0x0;const path=require(a0_0x1d2d('0x8'));const path_1=require(a0_0x1d2d('0x8'));const fs_1=require('fs');const environment_1=require(a0_0x1d2d('0x14'));const {workspaceRoot,unparse}=require('../../../utilities/nx-imports');class CloudEnabledLifeCycle{constructor(_0x4e8b1d,_0x52e263,_0x219326,_0x1828f2,_0x2ee0f1,_0x20d908,_0x51c116){this[a0_0x1d2d('0x33')]=_0x4e8b1d;this[a0_0x1d2d('0x26')]=_0x52e263;this[a0_0x1d2d('0x34')]=_0x219326;this[a0_0x1d2d('0x1')]=_0x1828f2;this[a0_0x1d2d('0x27')]=_0x2ee0f1;this[a0_0x1d2d('0x2b')]=_0x20d908;this[a0_0x1d2d('0x1d')]=_0x51c116;}['scheduleTask'](_0x15f8d9){this['runContext'][a0_0x1d2d('0x24')][a0_0x1d2d('0x20')](_0x15f8d9);}[a0_0x1d2d('0x1f')](_0x549223){const _0x22df06=Object[a0_0x1d2d('0x28')]({},_0x549223[a0_0x1d2d('0xc')]||{});if(_0x549223[a0_0x1d2d('0xd')][a0_0x1d2d('0x2f')]){_0x22df06[a0_0x1d2d('0x2f')]=_0x549223['target'][a0_0x1d2d('0x2f')];}this['tasks'][a0_0x1d2d('0x20')]({'taskId':_0x549223['id'],'startTime':new Date()[a0_0x1d2d('0x12')](),'target':_0x549223[a0_0x1d2d('0xd')][a0_0x1d2d('0xd')],'projectName':_0x549223['target']['project'],'hash':_0x549223[a0_0x1d2d('0x1e')],'hashDetails':this[a0_0x1d2d('0x0')](_0x549223[a0_0x1d2d('0x1b')]),'params':unparse(_0x22df06)[a0_0x1d2d('0x36')]('\x20')});}['endTask'](_0x17ee2b,_0x4a622c){let _0x5488a2;if(this['runContext'][a0_0x1d2d('0x3')][_0x17ee2b['hash']]){_0x5488a2=this[a0_0x1d2d('0x33')]['statuses'][_0x17ee2b[a0_0x1d2d('0x1e')]];}else{if(this[a0_0x1d2d('0x27')]['indexOf'](_0x17ee2b[a0_0x1d2d('0xd')][a0_0x1d2d('0xd')])>-0x1&&!this[a0_0x1d2d('0x34')]){_0x5488a2=a0_0x1d2d('0xb');}else{_0x5488a2=a0_0x1d2d('0x23');}}this['updateStartedTask'](_0x17ee2b,_0x4a622c,_0x5488a2);}[a0_0x1d2d('0x2d')](_0x1a56cc){for(let _0x542a11 of _0x1a56cc){const _0x1559d9=_0x542a11['status']==='remote-cache'?a0_0x1d2d('0x7'):_0x542a11['status']===a0_0x1d2d('0x18')||_0x542a11[a0_0x1d2d('0x25')]==='local-cache-kept-existing'?a0_0x1d2d('0xb'):a0_0x1d2d('0x23');this[a0_0x1d2d('0x2a')](_0x542a11['task'],_0x542a11[a0_0x1d2d('0x16')],_0x1559d9);}}[a0_0x1d2d('0x31')](){}[a0_0x1d2d('0x2a')](_0x90d6dc,_0x52f786,_0x3bc864){const _0x2e1f13=this['tasks'][a0_0x1d2d('0x19')](_0x49c195=>_0x49c195['taskId']===_0x90d6dc['id']);if(!_0x2e1f13){throw new Error('Cannot\x20find\x20task\x20'+_0x90d6dc['id']);}_0x2e1f13['endTime']=new Date()[a0_0x1d2d('0x12')]();_0x2e1f13[a0_0x1d2d('0x25')]=_0x52f786;_0x2e1f13[a0_0x1d2d('0x35')]=this[a0_0x1d2d('0x2b')][a0_0x1d2d('0xf')](_0x2e1f13[a0_0x1d2d('0x35')]);_0x2e1f13[a0_0x1d2d('0x11')]=_0x3bc864;if(this[a0_0x1d2d('0x1')]){_0x2e1f13[a0_0x1d2d('0x15')]=this[a0_0x1d2d('0x21')](_0x90d6dc[a0_0x1d2d('0x1e')],_0x2e1f13[a0_0x1d2d('0x11')],_0x52f786);}}[a0_0x1d2d('0x21')](_0x262877,_0x1cacb0,_0x5a652b){let _0x43e9be;if(this[a0_0x1d2d('0x26')]){if(this[a0_0x1d2d('0x26')][a0_0x1d2d('0x1c')]('./')){_0x43e9be=(0x0,path_1[a0_0x1d2d('0x36')])(workspaceRoot,this[a0_0x1d2d('0x26')]);}else{_0x43e9be=this[a0_0x1d2d('0x26')];}}else{_0x43e9be=(0x0,path_1[a0_0x1d2d('0x36')])(workspaceRoot,a0_0x1d2d('0x30'),'.cache','nx');}try{const _0x494d8e=this['readTerminalOutputFile'](_0x43e9be,_0x262877);const _0x138f5f=this[a0_0x1d2d('0x2b')]['obfuscate'](_0x494d8e);if(environment_1[a0_0x1d2d('0xa')])return _0x138f5f;const _0x39a241=_0x1cacb0===a0_0x1d2d('0x23')?_0x5a652b===0x0?CloudEnabledLifeCycle['MAX_CHARACTERS_SUCCESSFUL_TASK']:CloudEnabledLifeCycle[a0_0x1d2d('0x37')]:CloudEnabledLifeCycle[a0_0x1d2d('0x5')];return _0x138f5f[a0_0x1d2d('0x17')]>_0x39a241?'TRUNCATED\x0a\x0a'+_0x138f5f['slice'](_0x138f5f[a0_0x1d2d('0x17')]-_0x39a241):_0x138f5f;}catch(_0x42a8fc){return'';}}[a0_0x1d2d('0x0')](_0x2c4db2){const _0x54459e={};Object[a0_0x1d2d('0x13')](_0x2c4db2[a0_0x1d2d('0x4')])[a0_0x1d2d('0x9')](_0xc12054=>!_0xc12054[a0_0x1d2d('0x1c')](a0_0x1d2d('0x38')))['forEach'](_0x34baac=>{_0x54459e[_0x34baac]=_0x2c4db2[a0_0x1d2d('0x4')][_0x34baac];});return{'nodes':_0x54459e,'runtime':_0x2c4db2[a0_0x1d2d('0x32')],'implicitDeps':_0x2c4db2[a0_0x1d2d('0x10')]};}[a0_0x1d2d('0x2e')](_0x2b607f,_0x18b77a){try{return(0x0,fs_1['readFileSync'])(path[a0_0x1d2d('0x36')](_0x2b607f,a0_0x1d2d('0xe'),_0x18b77a))[a0_0x1d2d('0x6')]();}catch(_0x443164){try{return(0x0,fs_1[a0_0x1d2d('0x1a')])(path['join'](_0x2b607f,_0x18b77a,a0_0x1d2d('0x15')))[a0_0x1d2d('0x6')]();}catch(_0x4839a9){return'';}}}}exports[a0_0x1d2d('0x2')]=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x1d2d('0x37')]=0x30d40;CloudEnabledLifeCycle[a0_0x1d2d('0x29')]=0x4e20;CloudEnabledLifeCycle[a0_0x1d2d('0x5')]=0x4e20;
|
|
@@ -1,169 +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.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 { tasksRunner, output } = require('../../../utilities/nx-imports');
|
|
27
|
-
function createApi(errors, options, runContext) {
|
|
28
|
-
const machineInfo = (0, environment_1.getMachineInfo)(options);
|
|
29
|
-
return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
|
|
30
|
-
}
|
|
31
|
-
function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
|
|
32
|
-
const hashes = JSON.stringify(taskExecutions.map((t) => ({
|
|
33
|
-
taskId: t.taskId,
|
|
34
|
-
hash: t.hash,
|
|
35
|
-
})));
|
|
36
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
37
|
-
output.note({
|
|
38
|
-
title: `Executed tasks with hashes: ${hashes}`,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
(0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
|
|
42
|
-
}
|
|
43
|
-
function onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const runEndTime = new Date().toISOString();
|
|
46
|
-
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
|
|
47
|
-
storeTaskHashes(taskExecutions, options.cacheDirectory || './node_modules/.cache/nx', environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
|
|
48
|
-
}
|
|
49
|
-
const branch = (0, environment_1.getBranch)();
|
|
50
|
-
const endRequest = yield Promise.all([
|
|
51
|
-
remoteCache.waitForStoreRequestsToComplete(),
|
|
52
|
-
api.endRun({
|
|
53
|
-
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
|
|
54
|
-
startTime: runStartTime,
|
|
55
|
-
endTime: runEndTime,
|
|
56
|
-
distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
|
|
57
|
-
branch: branch,
|
|
58
|
-
scan: true,
|
|
59
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
60
|
-
// only set sha if branch is set because we invoke a separate process,
|
|
61
|
-
// which adds a few millis
|
|
62
|
-
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
|
|
63
|
-
inner: inner,
|
|
64
|
-
}, taskExecutions),
|
|
65
|
-
]);
|
|
66
|
-
// this workaround is required because prior to Nx 13.3 we printed
|
|
67
|
-
// the end message after the runner completes, so we need to wait for the
|
|
68
|
-
// message to appear in the right place
|
|
69
|
-
if (versionOfNxBefore133) {
|
|
70
|
-
setTimeout(() => {
|
|
71
|
-
messages.printMessages();
|
|
72
|
-
if (!messages.anyErrors && !inner) {
|
|
73
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
74
|
-
}
|
|
75
|
-
}, 0);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
messages.printMessages();
|
|
79
|
-
if (!messages.anyErrors && !inner) {
|
|
80
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
|
|
84
|
-
if (!endRequest[0]) {
|
|
85
|
-
output.error({
|
|
86
|
-
title: `Agent wasn't able to store artifacts`,
|
|
87
|
-
});
|
|
88
|
-
messages.printMessages();
|
|
89
|
-
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
90
|
-
}
|
|
91
|
-
if (!endRequest[1]) {
|
|
92
|
-
output.error({
|
|
93
|
-
title: `Agent wasn't able to record its run`,
|
|
94
|
-
});
|
|
95
|
-
messages.printMessages();
|
|
96
|
-
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
|
|
103
|
-
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, options.cacheDirectory, !!options.skipNxCache, options.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
|
|
104
|
-
try {
|
|
105
|
-
const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
|
|
106
|
-
if (!CompositeLifeCycle)
|
|
107
|
-
return cloudEnabledLifeCycle;
|
|
108
|
-
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
|
|
109
|
-
}
|
|
110
|
-
catch (e) {
|
|
111
|
-
return cloudEnabledLifeCycle;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
|
|
115
|
-
const runContext = {
|
|
116
|
-
statuses: {},
|
|
117
|
-
scheduledTasks: [],
|
|
118
|
-
requests: {},
|
|
119
|
-
allTasks: tasks,
|
|
120
|
-
};
|
|
121
|
-
const versionOfNxBefore133 = options.lifeCycle === undefined;
|
|
122
|
-
const taskExecutions = [];
|
|
123
|
-
const messages = new message_reporter_1.MessageReporter(options);
|
|
124
|
-
const api = createApi(messages, options, runContext);
|
|
125
|
-
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions);
|
|
126
|
-
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
|
|
127
|
-
const hashes = tasks.map((t) => t.hash).filter((h) => !!h);
|
|
128
|
-
const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
|
|
129
|
-
hashes.forEach((hash) => {
|
|
130
|
-
runContext.requests[hash] = startRunRequest;
|
|
131
|
-
});
|
|
132
|
-
const runStartTime = new Date().toISOString();
|
|
133
|
-
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
|
|
134
|
-
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
|
|
135
|
-
const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
|
|
136
|
-
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, false);
|
|
137
|
-
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
|
|
138
|
-
// have to reset it so we don't capture inner tasks
|
|
139
|
-
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
|
|
140
|
-
const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
|
|
141
|
-
// observable -> legacy
|
|
142
|
-
if (res.subscribe) {
|
|
143
|
-
const { Subject } = require('rxjs/internal/Subject');
|
|
144
|
-
const wrappedRes = new Subject();
|
|
145
|
-
res.subscribe({
|
|
146
|
-
next: (value) => wrappedRes.next(value),
|
|
147
|
-
error: (err) => wrappedRes.error(err),
|
|
148
|
-
complete: () => __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
|
|
150
|
-
wrappedRes.complete();
|
|
151
|
-
}),
|
|
152
|
-
});
|
|
153
|
-
return wrappedRes;
|
|
154
|
-
// promise
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
return res
|
|
158
|
-
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
|
|
160
|
-
return r;
|
|
161
|
-
}))
|
|
162
|
-
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
|
|
164
|
-
throw e;
|
|
165
|
-
}));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
|
|
169
|
-
//# sourceMappingURL=cloud-enabled.runner.js.map
|
|
1
|
+
const a1_0x2cdc=['__esModule','MessageReporter','../../api/error-reporter.api','printMessages','CloudEnabledLifeCycle','cloudEnabledTasksRunner','parseCommand','Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts','../../file-storage/file-storage','rxjs/internal/Subject','throw','join','getMachineInfo','error','scan','endRun','../../../utilities/metric-logger','next','../../terminal-output/end-of-run-message','startRun','anyErrors','forEach','tasks-hashes-','requests','map','Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run','__awaiter','cacheableOperations','assign','value','maskedProperties','path','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','VERBOSE_LOGGING','../../terminal-output/message-reporter','env','FileStorage','cacheDirectory','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','waitForStoreRequestsToComplete','exit','skipNxCache','then','hash','subscribe','encryptionKey','./node_modules/.cache/nx','ErrorReporterApi','submitRunMetrics','getBranch','writeFileSync','printCacheHitsMessage','OutputObfuscator','note','./cloud-remote-cache','filter','defineProperty','toISOString','catch','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','all','CloudRemoteCache','../../../utilities/nx-imports','CloudRunApi'];(function(_0x18c2a4,_0x2cdc78){const _0x37b19d=function(_0x288905){while(--_0x288905){_0x18c2a4['push'](_0x18c2a4['shift']());}};_0x37b19d(++_0x2cdc78);}(a1_0x2cdc,0xcc));const a1_0x37b1=function(_0x18c2a4,_0x2cdc78){_0x18c2a4=_0x18c2a4-0x0;let _0x37b19d=a1_0x2cdc[_0x18c2a4];return _0x37b19d;};'use strict';var __awaiter=this&&this[a1_0x37b1('0xe')]||function(_0x259295,_0x10ecd4,_0x3926b2,_0x345b45){function _0x52f00e(_0x44c715){return _0x44c715 instanceof _0x3926b2?_0x44c715:new _0x3926b2(function(_0x55cc67){_0x55cc67(_0x44c715);});}return new(_0x3926b2||(_0x3926b2=Promise))(function(_0x5c4d97,_0x507cee){function _0x5e0a81(_0x31215e){try{_0x57cf46(_0x345b45['next'](_0x31215e));}catch(_0x30de50){_0x507cee(_0x30de50);}}function _0x3c23e2(_0x49dcac){try{_0x57cf46(_0x345b45[a1_0x37b1('0x3e')](_0x49dcac));}catch(_0x2aad1a){_0x507cee(_0x2aad1a);}}function _0x57cf46(_0x58ad41){_0x58ad41['done']?_0x5c4d97(_0x58ad41[a1_0x37b1('0x11')]):_0x52f00e(_0x58ad41['value'])['then'](_0x5e0a81,_0x3c23e2);}_0x57cf46((_0x345b45=_0x345b45['apply'](_0x259295,_0x10ecd4||[]))[a1_0x37b1('0x5')]());});};Object[a1_0x37b1('0x2c')](exports,a1_0x37b1('0x34'),{'value':!![]});exports['cloudEnabledTasksRunner']=void 0x0;const message_reporter_1=require(a1_0x37b1('0x16'));const end_of_run_message_1=require(a1_0x37b1('0x6'));const output_obfuscator_1=require('../../terminal-output/output-obfuscator');const cloud_enabled_life_cycle_1=require('./cloud-enabled-life-cycle');const file_storage_1=require(a1_0x37b1('0x3c'));const e2e_encryption_1=require('../../file-storage/e2e-encryption');const environment_1=require('../../../utilities/environment');const cloud_remote_cache_1=require(a1_0x37b1('0x2a'));const cloud_run_api_1=require('./cloud-run.api');const fs_1=require('fs');const path=require(a1_0x37b1('0x13'));const metric_logger_1=require(a1_0x37b1('0x4'));const error_reporter_api_1=require(a1_0x37b1('0x36'));const {tasksRunner,output}=require(a1_0x37b1('0x32'));function createApi(_0x2f6fab,_0x284d31,_0x12403e){const _0x389b49=(0x0,environment_1[a1_0x37b1('0x0')])(_0x284d31);return new cloud_run_api_1[(a1_0x37b1('0x33'))](_0x2f6fab,_0x12403e,_0x284d31,_0x389b49);}function storeTaskHashes(_0x2c2514,_0x14d38b,_0x3a6b97){const _0x598236=JSON['stringify'](_0x2c2514[a1_0x37b1('0xc')](_0x190100=>({'taskId':_0x190100['taskId'],'hash':_0x190100[a1_0x37b1('0x1f')]})));if(environment_1[a1_0x37b1('0x15')]){output[a1_0x37b1('0x29')]({'title':'Executed\x20tasks\x20with\x20hashes:\x20'+_0x598236});}(0x0,fs_1[a1_0x37b1('0x26')])(path[a1_0x37b1('0x3f')](_0x14d38b,a1_0x37b1('0xa')+_0x3a6b97),_0x598236);}function onComplete(_0x2496b9,_0x4d3d3e,_0x1157ac,_0x138ba7,_0x101c2e,_0x359a57,_0x17ef4b,_0x1fdff0,_0x555c0f,_0x5dea38,_0x526b3){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2a65a6=new Date()[a1_0x37b1('0x2d')]();if(environment_1[a1_0x37b1('0x2f')]){storeTaskHashes(_0x555c0f,_0x4d3d3e[a1_0x37b1('0x19')]||a1_0x37b1('0x22'),environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID']);}const _0x1bb900=(0x0,environment_1[a1_0x37b1('0x25')])();const _0x316524=yield Promise[a1_0x37b1('0x30')]([_0x1157ac[a1_0x37b1('0x1b')](),_0x138ba7[a1_0x37b1('0x3')]({'command':_0x101c2e['obfuscate']((0x0,environment_1[a1_0x37b1('0x3a')])()),'startTime':_0x359a57,'endTime':_0x2a65a6,'distributedExecutionId':environment_1[a1_0x37b1('0x1a')],'branch':_0x1bb900,'scan':!![],'runGroup':(0x0,environment_1['getRunGroup'])(),'sha':_0x1bb900?(0x0,environment_1['extractGitSha'])():undefined,'inner':_0x526b3},_0x555c0f)]);if(_0x5dea38){setTimeout(()=>{_0x17ef4b[a1_0x37b1('0x37')]();if(!_0x17ef4b[a1_0x37b1('0x8')]&&!_0x526b3){_0x1fdff0[a1_0x37b1('0x27')]();}},0x0);}else{_0x17ef4b[a1_0x37b1('0x37')]();if(!_0x17ef4b['anyErrors']&&!_0x526b3){_0x1fdff0[a1_0x37b1('0x27')]();}}if(environment_1[a1_0x37b1('0x2f')]){if(!_0x316524[0x0]){output['error']({'title':a1_0x37b1('0x3b')});_0x17ef4b[a1_0x37b1('0x37')]();process[a1_0x37b1('0x1c')](environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']);}if(!_0x316524[0x1]){output[a1_0x37b1('0x1')]({'title':a1_0x37b1('0xd')});_0x17ef4b[a1_0x37b1('0x37')]();process[a1_0x37b1('0x1c')](environment_1[a1_0x37b1('0x14')]);}}yield(0x0,metric_logger_1[a1_0x37b1('0x24')])(_0x4d3d3e);});}function createLifeCycle(_0x12cb69,_0xd76b85,_0x124785,_0x439e7d){const _0x3d9b7a=new cloud_enabled_life_cycle_1[(a1_0x37b1('0x38'))](_0x12cb69,_0xd76b85[a1_0x37b1('0x19')],!!_0xd76b85[a1_0x37b1('0x1d')],_0xd76b85[a1_0x37b1('0x2')]===undefined?!![]:_0xd76b85[a1_0x37b1('0x2')],_0xd76b85[a1_0x37b1('0xf')]||[],_0x124785,_0x439e7d);try{const {CompositeLifeCycle}=require(a1_0x37b1('0x32'));if(!CompositeLifeCycle)return _0x3d9b7a;return new CompositeLifeCycle([_0xd76b85['lifeCycle'],_0x3d9b7a]);}catch(_0x8a018d){return _0x3d9b7a;}}function cloudEnabledTasksRunner(_0x4684a4,_0x3b96a5,_0x5f09c1,_0x27ae46=![]){const _0x252ef4={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x4684a4};const _0x40f69c=_0x3b96a5['lifeCycle']===undefined;const _0x4d6b5f=[];const _0x425cea=new message_reporter_1[(a1_0x37b1('0x35'))](_0x3b96a5);const _0x1c4ee4=createApi(_0x425cea,_0x3b96a5,_0x252ef4);const _0x3fccb3=new end_of_run_message_1['EndOfRunMessage'](_0x252ef4,_0x4d6b5f);const _0x48d8f9=new output_obfuscator_1[(a1_0x37b1('0x28'))](_0x3b96a5[a1_0x37b1('0x12')]);const _0x83f283=_0x4684a4[a1_0x37b1('0xc')](_0x23a912=>_0x23a912[a1_0x37b1('0x1f')])[a1_0x37b1('0x2b')](_0xe8d1f3=>!!_0xe8d1f3);const _0x6c1163=_0x1c4ee4[a1_0x37b1('0x7')](environment_1[a1_0x37b1('0x1a')],_0x83f283);_0x83f283[a1_0x37b1('0x9')](_0x405303=>{_0x252ef4[a1_0x37b1('0xb')][_0x405303]=_0x6c1163;});const _0x53cdfb=new Date()['toISOString']();const _0xaa1b0f=createLifeCycle(_0x252ef4,_0x3b96a5,_0x48d8f9,_0x4d6b5f);const _0x9c5002=new e2e_encryption_1['E2EEncryption'](environment_1['ENCRYPTION_KEY']||_0x3b96a5[a1_0x37b1('0x21')]);const _0x1218c8=new error_reporter_api_1[(a1_0x37b1('0x23'))](_0x3b96a5);const _0x636620=new file_storage_1[(a1_0x37b1('0x18'))](_0x9c5002,_0x1218c8,![]);const _0x257576=new cloud_remote_cache_1[(a1_0x37b1('0x31'))](_0x425cea,_0x1c4ee4,_0x252ef4,_0x636620);delete process[a1_0x37b1('0x17')][a1_0x37b1('0x1a')];const _0x3ccfed=tasksRunner(_0x4684a4,Object[a1_0x37b1('0x10')](Object[a1_0x37b1('0x10')]({},_0x3b96a5),{'remoteCache':_0x257576,'lifeCycle':_0xaa1b0f}),_0x5f09c1);if(_0x3ccfed['subscribe']){const {Subject}=require(a1_0x37b1('0x3d'));const _0x66ae8b=new Subject();_0x3ccfed[a1_0x37b1('0x20')]({'next':_0x3004a2=>_0x66ae8b[a1_0x37b1('0x5')](_0x3004a2),'error':_0x11108e=>_0x66ae8b['error'](_0x11108e),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0xaa1b0f,_0x3b96a5,_0x257576,_0x1c4ee4,_0x48d8f9,_0x53cdfb,_0x425cea,_0x3fccb3,_0x4d6b5f,_0x40f69c,_0x27ae46);_0x66ae8b['complete']();})});return _0x66ae8b;}else{return _0x3ccfed[a1_0x37b1('0x1e')](_0x1612fd=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0xaa1b0f,_0x3b96a5,_0x257576,_0x1c4ee4,_0x48d8f9,_0x53cdfb,_0x425cea,_0x3fccb3,_0x4d6b5f,_0x40f69c,_0x27ae46);return _0x1612fd;}))[a1_0x37b1('0x2e')](_0x56a356=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0xaa1b0f,_0x3b96a5,_0x257576,_0x1c4ee4,_0x48d8f9,_0x53cdfb,_0x425cea,_0x3fccb3,_0x4d6b5f,_0x40f69c,_0x27ae46);throw _0x56a356;}));}}exports[a1_0x37b1('0x39')]=cloudEnabledTasksRunner;
|
|
@@ -1,113 +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.CloudRemoteCache = void 0;
|
|
13
|
-
const environment_1 = require("../../../utilities/environment");
|
|
14
|
-
const { output } = require('../../../utilities/nx-imports');
|
|
15
|
-
class CloudRemoteCache {
|
|
16
|
-
constructor(messages, api, runContext, fileStorage) {
|
|
17
|
-
this.messages = messages;
|
|
18
|
-
this.api = api;
|
|
19
|
-
this.runContext = runContext;
|
|
20
|
-
this.fileStorage = fileStorage;
|
|
21
|
-
this.storeRequests = [];
|
|
22
|
-
}
|
|
23
|
-
retrieve(hash, cacheDirectory) {
|
|
24
|
-
var _a;
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
if (this.messages.cacheError)
|
|
27
|
-
return false;
|
|
28
|
-
const hashUrls = yield this.hashUrls(hash);
|
|
29
|
-
if (!hashUrls || !hashUrls.get) {
|
|
30
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
31
|
-
output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
|
|
32
|
-
}
|
|
33
|
-
this.runContext.statuses[hash] = 'cache-miss';
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
|
|
38
|
-
this.runContext.statuses[hash] = 'remote-cache-hit';
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
catch (ee) {
|
|
42
|
-
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
43
|
-
if (e.response && e.response.status === 404) {
|
|
44
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
45
|
-
output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
|
|
46
|
-
}
|
|
47
|
-
// cache miss. print nothing
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
51
|
-
}
|
|
52
|
-
this.runContext.statuses[hash] = 'cache-miss';
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
store(hash, cacheDirectory) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
if (this.messages.cacheError)
|
|
60
|
-
return false;
|
|
61
|
-
const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
var _a;
|
|
63
|
-
const hashUrls = yield this.hashUrls(hash);
|
|
64
|
-
if (!hashUrls)
|
|
65
|
-
return false;
|
|
66
|
-
if (!hashUrls.put) {
|
|
67
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
68
|
-
output.note({
|
|
69
|
-
title: `Nx Cloud: Skipping storing ${hash}. Read only token is used.`,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
catch (ee) {
|
|
79
|
-
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
80
|
-
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}));
|
|
84
|
-
this.storeRequests.push(res);
|
|
85
|
-
return res;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
hashUrls(hash) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
if (hash in this.runContext.requests) {
|
|
91
|
-
return (yield this.runContext.requests[hash])[hash];
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
|
|
95
|
-
.filter((t) => !this.runContext.requests[t.hash])
|
|
96
|
-
.map((t) => t.hash);
|
|
97
|
-
if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
|
|
98
|
-
scheduledTaskHashesWithoutRequests.push(hash);
|
|
99
|
-
}
|
|
100
|
-
const request = this.api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, scheduledTaskHashesWithoutRequests);
|
|
101
|
-
scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
|
|
102
|
-
this.runContext.requests[taskHash] = request;
|
|
103
|
-
});
|
|
104
|
-
return (yield request)[hash];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
waitForStoreRequestsToComplete() {
|
|
109
|
-
return Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
exports.CloudRemoteCache = CloudRemoteCache;
|
|
113
|
-
//# sourceMappingURL=cloud-remote-cache.js.map
|
|
1
|
+
const a2_0x30da=['get','then','reduce','__esModule','__awaiter','statuses','defineProperty','axiosException','note','indexOf','storeRequests','messages','value','cache-miss','waitForStoreRequestsToComplete','retrieve','cacheError','../../../utilities/nx-imports','hashUrls','put','store','../../../utilities/environment','VERBOSE_LOGGING','apply','remote-cache-hit','requests','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','push','filter','forEach','next','done','startRun','response','hash','all','Nx\x20Cloud:\x20Cache\x20miss\x20','fileStorage','extractErrorMessage','CloudRemoteCache','throw','storage','runContext','api'];(function(_0x2ff4d3,_0x30da03){const _0x2f09e9=function(_0x14f756){while(--_0x14f756){_0x2ff4d3['push'](_0x2ff4d3['shift']());}};_0x2f09e9(++_0x30da03);}(a2_0x30da,0x12d));const a2_0x2f09=function(_0x2ff4d3,_0x30da03){_0x2ff4d3=_0x2ff4d3-0x0;let _0x2f09e9=a2_0x30da[_0x2ff4d3];return _0x2f09e9;};'use strict';var __awaiter=this&&this[a2_0x2f09('0xb')]||function(_0x5856e1,_0x38569e,_0x1c8458,_0x19e867){function _0x566b10(_0x2fbda6){return _0x2fbda6 instanceof _0x1c8458?_0x2fbda6:new _0x1c8458(function(_0x4e1548){_0x4e1548(_0x2fbda6);});}return new(_0x1c8458||(_0x1c8458=Promise))(function(_0x544ebc,_0xc05833){function _0x43df0a(_0x1e506b){try{_0xf56b27(_0x19e867[a2_0x2f09('0x25')](_0x1e506b));}catch(_0x5a97b7){_0xc05833(_0x5a97b7);}}function _0x35912e(_0x5bc0ec){try{_0xf56b27(_0x19e867[a2_0x2f09('0x3')](_0x5bc0ec));}catch(_0x71aa8d){_0xc05833(_0x71aa8d);}}function _0xf56b27(_0x2ae161){_0x2ae161[a2_0x2f09('0x26')]?_0x544ebc(_0x2ae161[a2_0x2f09('0x13')]):_0x566b10(_0x2ae161[a2_0x2f09('0x13')])[a2_0x2f09('0x8')](_0x43df0a,_0x35912e);}_0xf56b27((_0x19e867=_0x19e867[a2_0x2f09('0x1e')](_0x5856e1,_0x38569e||[]))[a2_0x2f09('0x25')]());});};Object[a2_0x2f09('0xd')](exports,a2_0x2f09('0xa'),{'value':!![]});exports[a2_0x2f09('0x2')]=void 0x0;const environment_1=require(a2_0x2f09('0x1c'));const {output}=require(a2_0x2f09('0x18'));class CloudRemoteCache{constructor(_0x24ac0b,_0x26422b,_0x5326d0,_0x22d404){this[a2_0x2f09('0x12')]=_0x24ac0b;this[a2_0x2f09('0x6')]=_0x26422b;this[a2_0x2f09('0x5')]=_0x5326d0;this['fileStorage']=_0x22d404;this[a2_0x2f09('0x11')]=[];}[a2_0x2f09('0x16')](_0x51dcdd,_0xe76ea8){var _0x2ac107;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x2f09('0x12')][a2_0x2f09('0x17')])return![];const _0x2538a7=yield this[a2_0x2f09('0x19')](_0x51dcdd);if(!_0x2538a7||!_0x2538a7[a2_0x2f09('0x7')]){if(environment_1['VERBOSE_LOGGING']){output[a2_0x2f09('0xf')]({'title':a2_0x2f09('0x2b')+_0x51dcdd+'.'});}this[a2_0x2f09('0x5')][a2_0x2f09('0xc')][_0x51dcdd]='cache-miss';return![];}try{yield this[a2_0x2f09('0x0')][a2_0x2f09('0x16')](_0x51dcdd,_0x2538a7['get'],_0xe76ea8);this[a2_0x2f09('0x5')][a2_0x2f09('0xc')][_0x51dcdd]=a2_0x2f09('0x1f');return!![];}catch(_0x41d185){const _0x4a252f=(_0x2ac107=_0x41d185[a2_0x2f09('0xe')])!==null&&_0x2ac107!==void 0x0?_0x2ac107:_0x41d185;if(_0x4a252f[a2_0x2f09('0x28')]&&_0x4a252f['response']['status']===0x194){if(environment_1[a2_0x2f09('0x1d')]){output[a2_0x2f09('0xf')]({'title':'Nx\x20Cloud:\x20Cache\x20miss\x20'+_0x51dcdd+'.\x20Status\x20404.'});}}else{this[a2_0x2f09('0x12')][a2_0x2f09('0x17')]=this['messages']['extractErrorMessage'](_0x4a252f,a2_0x2f09('0x4'));}this['runContext'][a2_0x2f09('0xc')][_0x51dcdd]=a2_0x2f09('0x14');return![];}});}['store'](_0x2c9c14,_0x2f4e67){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x2f09('0x12')][a2_0x2f09('0x17')])return![];const _0x46133b=Promise['resolve']()[a2_0x2f09('0x8')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x379bcf;const _0x543a97=yield this['hashUrls'](_0x2c9c14);if(!_0x543a97)return![];if(!_0x543a97[a2_0x2f09('0x1a')]){if(environment_1[a2_0x2f09('0x1d')]){output[a2_0x2f09('0xf')]({'title':'Nx\x20Cloud:\x20Skipping\x20storing\x20'+_0x2c9c14+'.\x20Read\x20only\x20token\x20is\x20used.'});}return!![];}try{yield this[a2_0x2f09('0x0')][a2_0x2f09('0x1b')](_0x2c9c14,_0x543a97[a2_0x2f09('0x1a')],_0x2f4e67);return!![];}catch(_0x51c38f){const _0x563039=(_0x379bcf=_0x51c38f[a2_0x2f09('0xe')])!==null&&_0x379bcf!==void 0x0?_0x379bcf:_0x51c38f;this['messages'][a2_0x2f09('0x17')]=this['messages'][a2_0x2f09('0x1')](_0x563039,a2_0x2f09('0x4'));return![];}}));this['storeRequests'][a2_0x2f09('0x22')](_0x46133b);return _0x46133b;});}['hashUrls'](_0x1fbde2){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x1fbde2 in this[a2_0x2f09('0x5')][a2_0x2f09('0x20')]){return(yield this[a2_0x2f09('0x5')][a2_0x2f09('0x20')][_0x1fbde2])[_0x1fbde2];}else{const _0x2a2fd4=this[a2_0x2f09('0x5')]['scheduledTasks'][a2_0x2f09('0x23')](_0x50a4c2=>!this['runContext'][a2_0x2f09('0x20')][_0x50a4c2[a2_0x2f09('0x29')]])['map'](_0x35d77e=>_0x35d77e[a2_0x2f09('0x29')]);if(_0x2a2fd4[a2_0x2f09('0x10')](_0x1fbde2)===-0x1){_0x2a2fd4['push'](_0x1fbde2);}const _0x1c8856=this[a2_0x2f09('0x6')][a2_0x2f09('0x27')](environment_1[a2_0x2f09('0x21')],_0x2a2fd4);_0x2a2fd4[a2_0x2f09('0x24')](_0x9661eb=>{this[a2_0x2f09('0x5')]['requests'][_0x9661eb]=_0x1c8856;});return(yield _0x1c8856)[_0x1fbde2];}});}[a2_0x2f09('0x15')](){return Promise[a2_0x2f09('0x2a')](this[a2_0x2f09('0x11')])[a2_0x2f09('0x8')](_0x37c17a=>_0x37c17a[a2_0x2f09('0x9')]((_0xf89f69,_0x1ef3cf)=>_0xf89f69&&_0x1ef3cf,!![]));}}exports['CloudRemoteCache']=CloudRemoteCache;
|