@nrwl/nx-cloud 14.1.2-beta.2 → 14.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/api/error-reporter.api.js +1 -36
- package/lib/core/api/run-group.api.js +1 -65
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -138
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -169
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -113
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -166
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -79
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -240
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -131
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -206
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +1 -37
- package/lib/core/runners/distributed-execution/task-graph-creator.js +1 -77
- package/lib/utilities/nx-imports.js +48 -37
- 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_0x1beb=['Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','message','/nx-cloud/report-client-error','ErrorReporterApi','value','next','done','post','reportError','../../utilities/axios','axiosMultipleTries','then','../../utilities/nx-imports','defineProperty','warn','throw'];(function(_0x2d50a3,_0x1bebbf){const _0x575fc5=function(_0x57e1cb){while(--_0x57e1cb){_0x2d50a3['push'](_0x2d50a3['shift']());}};_0x575fc5(++_0x1bebbf);}(a0_0x1beb,0x122));const a0_0x575f=function(_0x2d50a3,_0x1bebbf){_0x2d50a3=_0x2d50a3-0x0;let _0x575fc5=a0_0x1beb[_0x2d50a3];return _0x575fc5;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x10b13e,_0x5a909b,_0x1065d2,_0x7a235f){function _0x6bf88c(_0x4e61bb){return _0x4e61bb instanceof _0x1065d2?_0x4e61bb:new _0x1065d2(function(_0x119e06){_0x119e06(_0x4e61bb);});}return new(_0x1065d2||(_0x1065d2=Promise))(function(_0x155bab,_0x2f662c){function _0x4638f2(_0x50651f){try{_0x139812(_0x7a235f[a0_0x575f('0x3')](_0x50651f));}catch(_0x385747){_0x2f662c(_0x385747);}}function _0x5a1dc4(_0x5c30da){try{_0x139812(_0x7a235f[a0_0x575f('0xd')](_0x5c30da));}catch(_0x1e190c){_0x2f662c(_0x1e190c);}}function _0x139812(_0x5c1822){_0x5c1822[a0_0x575f('0x4')]?_0x155bab(_0x5c1822['value']):_0x6bf88c(_0x5c1822[a0_0x575f('0x2')])[a0_0x575f('0x9')](_0x4638f2,_0x5a1dc4);}_0x139812((_0x7a235f=_0x7a235f['apply'](_0x10b13e,_0x5a909b||[]))[a0_0x575f('0x3')]());});};Object[a0_0x575f('0xb')](exports,'__esModule',{'value':!![]});exports[a0_0x575f('0x1')]=void 0x0;const axios_1=require(a0_0x575f('0x7'));const {output}=require(a0_0x575f('0xa'));class ErrorReporterApi{constructor(_0x387762){this['apiAxiosInstance']=(0x0,axios_1['createApiAxiosInstance'])(_0x387762);}[a0_0x575f('0x6')](_0x292be8){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x575f('0x8')])(()=>this['apiAxiosInstance'][a0_0x575f('0x5')](a0_0x575f('0x0'),{'message':_0x292be8}));}catch(_0x3a3afc){output[a0_0x575f('0xc')]({'title':a0_0x575f('0xe')+_0x292be8+'\x27','bodyLines':[_0x3a3afc[a0_0x575f('0xf')]]});}});}}exports[a0_0x575f('0x1')]=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_0x14af=['next','../../utilities/metric-logger','done','axiosException','message','../../utilities/axios','/nx-cloud/executions/create-run-group','recordMetric','defineProperty','__esModule','error','post','RUNNER_FAILURE_PERF_ENTRY','apply','then','value','response','axiosMultipleTries','createMetricRecorder','mapRespToPerfEntry','RunGroupApi','createRunGroup','completeRunGroup','apiAxiosInstance','exit','/nx-cloud/executions/complete-run-group'];(function(_0x324d33,_0x14af82){const _0x3ab88b=function(_0x5ddacf){while(--_0x5ddacf){_0x324d33['push'](_0x324d33['shift']());}};_0x3ab88b(++_0x14af82);}(a1_0x14af,0x137));const a1_0x3ab8=function(_0x324d33,_0x14af82){_0x324d33=_0x324d33-0x0;let _0x3ab88b=a1_0x14af[_0x324d33];return _0x3ab88b;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x29d113,_0x54af2c,_0x2c375c,_0x1aa334){function _0x10eff2(_0x1eacad){return _0x1eacad instanceof _0x2c375c?_0x1eacad:new _0x2c375c(function(_0x5bd93){_0x5bd93(_0x1eacad);});}return new(_0x2c375c||(_0x2c375c=Promise))(function(_0x346835,_0x266509){function _0x46c6dc(_0xeebae4){try{_0x250410(_0x1aa334[a1_0x3ab8('0x1')](_0xeebae4));}catch(_0x48a5a5){_0x266509(_0x48a5a5);}}function _0x1cc5cd(_0x131c4f){try{_0x250410(_0x1aa334['throw'](_0x131c4f));}catch(_0x588274){_0x266509(_0x588274);}}function _0x250410(_0x34b06f){_0x34b06f[a1_0x3ab8('0x3')]?_0x346835(_0x34b06f[a1_0x3ab8('0x10')]):_0x10eff2(_0x34b06f[a1_0x3ab8('0x10')])[a1_0x3ab8('0xf')](_0x46c6dc,_0x1cc5cd);}_0x250410((_0x1aa334=_0x1aa334[a1_0x3ab8('0xe')](_0x29d113,_0x54af2c||[]))[a1_0x3ab8('0x1')]());});};Object[a1_0x3ab8('0x9')](exports,a1_0x3ab8('0xa'),{'value':!![]});exports[a1_0x3ab8('0x15')]=void 0x0;const axios_1=require(a1_0x3ab8('0x6'));const metric_logger_1=require(a1_0x3ab8('0x2'));const {output}=require('../../utilities/nx-imports');class RunGroupApi{constructor(_0x22c7cd){this[a1_0x3ab8('0x18')]=(0x0,axios_1['createApiAxiosInstance'])(_0x22c7cd);}[a1_0x3ab8('0x16')](_0x2d8efc,_0x307323){var _0x4cf3ab;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x11202f=(0x0,metric_logger_1['createMetricRecorder'])('createRunGroup');try{const _0x13c6fb=yield(0x0,axios_1[a1_0x3ab8('0x12')])(()=>this[a1_0x3ab8('0x18')]['post'](a1_0x3ab8('0x7'),{'branch':_0x2d8efc,'runGroup':_0x307323}));_0x11202f[a1_0x3ab8('0x8')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x13c6fb));}catch(_0x96f19b){_0x11202f[a1_0x3ab8('0x8')](((_0x4cf3ab=_0x96f19b===null||_0x96f19b===void 0x0?void 0x0:_0x96f19b[a1_0x3ab8('0x4')])===null||_0x4cf3ab===void 0x0?void 0x0:_0x4cf3ab['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x96f19b[a1_0x3ab8('0x4')][a1_0x3ab8('0x11')]):metric_logger_1[a1_0x3ab8('0xd')]);output[a1_0x3ab8('0xb')]({'title':_0x96f19b[a1_0x3ab8('0x5')]});process['exit'](0x1);}});}[a1_0x3ab8('0x17')](_0xcb69c8){var _0x39159d;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2813e0=(0x0,metric_logger_1[a1_0x3ab8('0x13')])(a1_0x3ab8('0x16'));try{const _0x12baae=yield(0x0,axios_1[a1_0x3ab8('0x12')])(()=>this[a1_0x3ab8('0x18')][a1_0x3ab8('0xc')](a1_0x3ab8('0x0'),{'runGroup':_0xcb69c8}));_0x2813e0[a1_0x3ab8('0x8')]((0x0,metric_logger_1[a1_0x3ab8('0x14')])(_0x12baae));}catch(_0x59b969){_0x2813e0[a1_0x3ab8('0x8')](((_0x39159d=_0x59b969===null||_0x59b969===void 0x0?void 0x0:_0x59b969[a1_0x3ab8('0x4')])===null||_0x39159d===void 0x0?void 0x0:_0x39159d[a1_0x3ab8('0x11')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x59b969['axiosException']['response']):metric_logger_1[a1_0x3ab8('0xd')]);output[a1_0x3ab8('0xb')]({'title':_0x59b969[a1_0x3ab8('0x5')]});process[a1_0x3ab8('0x19')](0x1);}});}}exports[a1_0x3ab8('0x15')]=RunGroupApi;
|
|
@@ -1,138 +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
|
-
const status = t.status === 'remote-cache'
|
|
54
|
-
? 'remote-cache-hit'
|
|
55
|
-
: t.status === 'local-cache' ||
|
|
56
|
-
t.status === 'local-cache-kept-existing'
|
|
57
|
-
? 'local-cache-hit'
|
|
58
|
-
: 'cache-miss';
|
|
59
|
-
this.updateStartedTask(t.task, t.code, status);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
endCommand() { }
|
|
63
|
-
updateStartedTask(task, code, cacheStatus) {
|
|
64
|
-
const startedTask = this.tasks.find((t) => t.taskId === task.id);
|
|
65
|
-
if (!startedTask) {
|
|
66
|
-
throw new Error(`Cannot find task ${task.id}`);
|
|
67
|
-
}
|
|
68
|
-
startedTask.endTime = new Date().toISOString();
|
|
69
|
-
startedTask.status = code;
|
|
70
|
-
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
|
|
71
|
-
startedTask.cacheStatus = cacheStatus;
|
|
72
|
-
if (this.collectTerminalOutput) {
|
|
73
|
-
startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
getTerminalOutput(hash, cacheStatus, code) {
|
|
77
|
-
let dir;
|
|
78
|
-
if (this.cacheDirectory) {
|
|
79
|
-
if (this.cacheDirectory.startsWith('./')) {
|
|
80
|
-
dir = (0, path_1.join)(workspaceRoot, this.cacheDirectory);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
dir = this.cacheDirectory;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
dir = (0, path_1.join)(workspaceRoot, 'node_modules', '.cache', 'nx');
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
const taskOutput = this.readTerminalOutputFile(dir, hash);
|
|
91
|
-
const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
|
|
92
|
-
if (environment_1.NX_CLOUD_UNLIMITED_OUTPUT)
|
|
93
|
-
return taskOutputSanitized;
|
|
94
|
-
const maxCharacters = cacheStatus === 'cache-miss'
|
|
95
|
-
? code === 0
|
|
96
|
-
? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
|
|
97
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
|
|
98
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
|
|
99
|
-
return taskOutputSanitized.length > maxCharacters
|
|
100
|
-
? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
|
|
101
|
-
: taskOutputSanitized;
|
|
102
|
-
}
|
|
103
|
-
catch (e) {
|
|
104
|
-
return '';
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
cleanUpHashDetails(hashDetails) {
|
|
108
|
-
const nodes = {};
|
|
109
|
-
Object.keys(hashDetails.nodes)
|
|
110
|
-
.filter((k) => !k.startsWith('npm:'))
|
|
111
|
-
.forEach((k) => {
|
|
112
|
-
nodes[k] = hashDetails.nodes[k];
|
|
113
|
-
});
|
|
114
|
-
return {
|
|
115
|
-
nodes,
|
|
116
|
-
runtime: hashDetails.runtime,
|
|
117
|
-
implicitDeps: hashDetails.implicitDeps,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
readTerminalOutputFile(dir, hash) {
|
|
121
|
-
try {
|
|
122
|
-
return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
|
|
123
|
-
}
|
|
124
|
-
catch (_a) {
|
|
125
|
-
try {
|
|
126
|
-
return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
|
|
127
|
-
}
|
|
128
|
-
catch (_b) {
|
|
129
|
-
return '';
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
|
|
135
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
|
|
136
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
|
|
137
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 20000;
|
|
138
|
-
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
|
|
1
|
+
const a0_0x4eb1=['cache-miss','collectTerminalOutput','runtime','scheduledTasks','slice','updateStartedTask','local-cache-hit','defineProperty','push','remote-cache-hit','status','terminalOutput','TRUNCATED\x0a\x0a','endTime','__esModule','local-cache-kept-existing','taskId','MAX_CHARACTERS_SUCCESSFUL_TASK','npm:','toISOString','nodes','path','remote-cache','local-cache','tasks','skipNxCache','getTerminalOutput','keys','../../../utilities/nx-imports','outputObfuscator','statuses','CloudEnabledLifeCycle','../../../utilities/environment','NX_CLOUD_UNLIMITED_OUTPUT','serializeOverrides','.cache','cacheStatus','hashDetails','join','cacheableOperations','terminalOutputs','startsWith','cleanUpHashDetails','params','toString','forEach','readFileSync','cacheDirectory','obfuscate','hash','endTask','code','length','Cannot\x20find\x20task\x20','node_modules','indexOf','MAX_CHARACTERS_FAILED_TASK','target','runContext','implicitDeps'];(function(_0x52deb8,_0x4eb1f3){const _0x4f5325=function(_0x34357a){while(--_0x34357a){_0x52deb8['push'](_0x52deb8['shift']());}};_0x4f5325(++_0x4eb1f3);}(a0_0x4eb1,0x1c0));const a0_0x4f53=function(_0x52deb8,_0x4eb1f3){_0x52deb8=_0x52deb8-0x0;let _0x4f5325=a0_0x4eb1[_0x52deb8];return _0x4f5325;};'use strict';Object[a0_0x4f53('0x27')](exports,a0_0x4f53('0x2e'),{'value':!![]});exports[a0_0x4f53('0x3')]=void 0x0;const path=require('path');const path_1=require(a0_0x4f53('0x35'));const fs_1=require('fs');const environment_1=require(a0_0x4f53('0x4'));const serializer_overrides_1=require('../../../utilities/serializer-overrides');const {workspaceRoot}=require(a0_0x4f53('0x0'));class CloudEnabledLifeCycle{constructor(_0x249d50,_0x5013fc,_0x2c9052,_0x5cb01b,_0x394ae4,_0x4bea77,_0x1ba0d6){this[a0_0x4f53('0x1e')]=_0x249d50;this[a0_0x4f53('0x13')]=_0x5013fc;this[a0_0x4f53('0x39')]=_0x2c9052;this[a0_0x4f53('0x21')]=_0x5cb01b;this[a0_0x4f53('0xb')]=_0x394ae4;this[a0_0x4f53('0x1')]=_0x4bea77;this[a0_0x4f53('0x38')]=_0x1ba0d6;}['scheduleTask'](_0x1a6d1e){this[a0_0x4f53('0x1e')][a0_0x4f53('0x23')][a0_0x4f53('0x28')](_0x1a6d1e);}['startTask'](_0x389faa){this[a0_0x4f53('0x38')][a0_0x4f53('0x28')]({'taskId':_0x389faa['id'],'startTime':new Date()[a0_0x4f53('0x33')](),'target':_0x389faa[a0_0x4f53('0x1d')]['target'],'projectName':_0x389faa[a0_0x4f53('0x1d')]['project'],'hash':_0x389faa[a0_0x4f53('0x15')],'hashDetails':this[a0_0x4f53('0xe')](_0x389faa[a0_0x4f53('0x9')]),'params':(0x0,serializer_overrides_1[a0_0x4f53('0x6')])(_0x389faa)});}[a0_0x4f53('0x16')](_0x1ec497,_0x3fdd58){let _0x46f99a;if(this[a0_0x4f53('0x1e')][a0_0x4f53('0x2')][_0x1ec497['hash']]){_0x46f99a=this[a0_0x4f53('0x1e')][a0_0x4f53('0x2')][_0x1ec497[a0_0x4f53('0x15')]];}else{if(this['cacheableOperations'][a0_0x4f53('0x1b')](_0x1ec497[a0_0x4f53('0x1d')][a0_0x4f53('0x1d')])>-0x1&&!this[a0_0x4f53('0x39')]){_0x46f99a=a0_0x4f53('0x26');}else{_0x46f99a=a0_0x4f53('0x20');}}this[a0_0x4f53('0x25')](_0x1ec497,_0x3fdd58,_0x46f99a);}['endTasks'](_0x4b1333){for(let _0x517bb6 of _0x4b1333){const _0x45ecc7=_0x517bb6['status']===a0_0x4f53('0x36')?a0_0x4f53('0x29'):_0x517bb6[a0_0x4f53('0x2a')]===a0_0x4f53('0x37')||_0x517bb6[a0_0x4f53('0x2a')]===a0_0x4f53('0x2f')?a0_0x4f53('0x26'):a0_0x4f53('0x20');this[a0_0x4f53('0x25')](_0x517bb6['task'],_0x517bb6[a0_0x4f53('0x17')],_0x45ecc7);}}['endCommand'](){}[a0_0x4f53('0x25')](_0x583991,_0x4d229e,_0x391ab1){const _0x42e94a=this['tasks']['find'](_0x327343=>_0x327343[a0_0x4f53('0x30')]===_0x583991['id']);if(!_0x42e94a){throw new Error(a0_0x4f53('0x19')+_0x583991['id']);}_0x42e94a[a0_0x4f53('0x2d')]=new Date()[a0_0x4f53('0x33')]();_0x42e94a[a0_0x4f53('0x2a')]=_0x4d229e;_0x42e94a[a0_0x4f53('0xf')]=this[a0_0x4f53('0x1')][a0_0x4f53('0x14')](_0x42e94a[a0_0x4f53('0xf')]);_0x42e94a[a0_0x4f53('0x8')]=_0x391ab1;if(this[a0_0x4f53('0x21')]){_0x42e94a['terminalOutput']=this['getTerminalOutput'](_0x583991[a0_0x4f53('0x15')],_0x42e94a[a0_0x4f53('0x8')],_0x4d229e);}}[a0_0x4f53('0x3a')](_0x535db1,_0x2674db,_0x29056d){let _0x55ba8c;if(this[a0_0x4f53('0x13')]){if(this[a0_0x4f53('0x13')]['startsWith']('./')){_0x55ba8c=(0x0,path_1['join'])(workspaceRoot,this[a0_0x4f53('0x13')]);}else{_0x55ba8c=this['cacheDirectory'];}}else{_0x55ba8c=(0x0,path_1[a0_0x4f53('0xa')])(workspaceRoot,a0_0x4f53('0x1a'),a0_0x4f53('0x7'),'nx');}try{const _0x3b0d3a=this['readTerminalOutputFile'](_0x55ba8c,_0x535db1);const _0x256b8b=this[a0_0x4f53('0x1')][a0_0x4f53('0x14')](_0x3b0d3a);if(environment_1[a0_0x4f53('0x5')])return _0x256b8b;const _0x5002e7=_0x2674db==='cache-miss'?_0x29056d===0x0?CloudEnabledLifeCycle[a0_0x4f53('0x31')]:CloudEnabledLifeCycle[a0_0x4f53('0x1c')]:CloudEnabledLifeCycle['MAX_CHARACTERS_CACHED_TASK'];return _0x256b8b['length']>_0x5002e7?a0_0x4f53('0x2c')+_0x256b8b[a0_0x4f53('0x24')](_0x256b8b[a0_0x4f53('0x18')]-_0x5002e7):_0x256b8b;}catch(_0x1d08c4){return'';}}['cleanUpHashDetails'](_0x22181d){const _0x2f0970={};Object[a0_0x4f53('0x3b')](_0x22181d[a0_0x4f53('0x34')])['filter'](_0x4c8f9b=>!_0x4c8f9b[a0_0x4f53('0xd')](a0_0x4f53('0x32')))[a0_0x4f53('0x11')](_0x5a21ba=>{_0x2f0970[_0x5a21ba]=_0x22181d['nodes'][_0x5a21ba];});return{'nodes':_0x2f0970,'runtime':_0x22181d[a0_0x4f53('0x22')],'implicitDeps':_0x22181d[a0_0x4f53('0x1f')]};}['readTerminalOutputFile'](_0x178b1f,_0x1b0597){try{return(0x0,fs_1['readFileSync'])(path[a0_0x4f53('0xa')](_0x178b1f,a0_0x4f53('0xc'),_0x1b0597))[a0_0x4f53('0x10')]();}catch(_0x89fada){try{return(0x0,fs_1[a0_0x4f53('0x12')])(path['join'](_0x178b1f,_0x1b0597,a0_0x4f53('0x2b')))[a0_0x4f53('0x10')]();}catch(_0x3ec30f){return'';}}}}exports[a0_0x4f53('0x3')]=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x4f53('0x1c')]=0x30d40;CloudEnabledLifeCycle[a0_0x4f53('0x31')]=0x4e20;CloudEnabledLifeCycle['MAX_CHARACTERS_CACHED_TASK']=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_0x2afc=['printCacheHitsMessage','lifeCycle','CloudRunApi','error','env','value','exit','map','toISOString','tasks-hashes-','__awaiter','../../../utilities/metric-logger','../../terminal-output/end-of-run-message','assign','FileStorage','../../terminal-output/message-reporter','throw','./cloud-enabled-life-cycle','OutputObfuscator','requests','EndOfRunMessage','cacheableOperations','complete','skipNxCache','waitForStoreRequestsToComplete','obfuscate','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','getBranch','cloudEnabledTasksRunner','anyErrors','CloudRemoteCache','../../../utilities/nx-imports','all','parseCommand','../../api/error-reporter.api','catch','filter','../../../utilities/environment','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','__esModule','VERBOSE_LOGGING','then','done','encryptionKey','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','MessageReporter','ENCRYPTION_KEY','./cloud-run.api','subscribe','endRun','Executed\x20tasks\x20with\x20hashes:\x20','./cloud-remote-cache','note','getRunGroup','cacheDirectory','printMessages','startRun','next','Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run'];(function(_0x37edbb,_0x2afc1c){const _0x2bdc5b=function(_0xfcea3b){while(--_0xfcea3b){_0x37edbb['push'](_0x37edbb['shift']());}};_0x2bdc5b(++_0x2afc1c);}(a1_0x2afc,0x14f));const a1_0x2bdc=function(_0x37edbb,_0x2afc1c){_0x37edbb=_0x37edbb-0x0;let _0x2bdc5b=a1_0x2afc[_0x37edbb];return _0x2bdc5b;};'use strict';var __awaiter=this&&this[a1_0x2bdc('0x1d')]||function(_0x393b52,_0x2d56d7,_0x3816ba,_0x1220c3){function _0x54b247(_0x7eab7f){return _0x7eab7f instanceof _0x3816ba?_0x7eab7f:new _0x3816ba(function(_0xbab909){_0xbab909(_0x7eab7f);});}return new(_0x3816ba||(_0x3816ba=Promise))(function(_0x48d6e6,_0xb53f75){function _0x2753f7(_0x8047c0){try{_0x84b806(_0x1220c3[a1_0x2bdc('0x11')](_0x8047c0));}catch(_0x281dcb){_0xb53f75(_0x281dcb);}}function _0x394224(_0x5f1319){try{_0x84b806(_0x1220c3[a1_0x2bdc('0x23')](_0x5f1319));}catch(_0x2f7131){_0xb53f75(_0x2f7131);}}function _0x84b806(_0xc8aea5){_0xc8aea5[a1_0x2bdc('0x2')]?_0x48d6e6(_0xc8aea5[a1_0x2bdc('0x18')]):_0x54b247(_0xc8aea5[a1_0x2bdc('0x18')])[a1_0x2bdc('0x1')](_0x2753f7,_0x394224);}_0x84b806((_0x1220c3=_0x1220c3['apply'](_0x393b52,_0x2d56d7||[]))[a1_0x2bdc('0x11')]());});};Object['defineProperty'](exports,a1_0x2bdc('0x3a'),{'value':!![]});exports['cloudEnabledTasksRunner']=void 0x0;const message_reporter_1=require(a1_0x2bdc('0x22'));const end_of_run_message_1=require(a1_0x2bdc('0x1f'));const output_obfuscator_1=require('../../terminal-output/output-obfuscator');const cloud_enabled_life_cycle_1=require(a1_0x2bdc('0x24'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require('../../file-storage/e2e-encryption');const environment_1=require(a1_0x2bdc('0x38'));const cloud_remote_cache_1=require(a1_0x2bdc('0xb'));const cloud_run_api_1=require(a1_0x2bdc('0x7'));const fs_1=require('fs');const path=require('path');const metric_logger_1=require(a1_0x2bdc('0x1e'));const error_reporter_api_1=require(a1_0x2bdc('0x35'));const {tasksRunner,output}=require(a1_0x2bdc('0x32'));function createApi(_0x1eef70,_0x32f271,_0x296b97){const _0x2e4340=(0x0,environment_1['getMachineInfo'])(_0x32f271);return new cloud_run_api_1[(a1_0x2bdc('0x15'))](_0x1eef70,_0x296b97,_0x32f271,_0x2e4340);}function storeTaskHashes(_0x20d710,_0x361159,_0xc00469){const _0x319e04=JSON['stringify'](_0x20d710[a1_0x2bdc('0x1a')](_0x5f1fcb=>({'taskId':_0x5f1fcb['taskId'],'hash':_0x5f1fcb['hash']})));if(environment_1[a1_0x2bdc('0x0')]){output[a1_0x2bdc('0xc')]({'title':a1_0x2bdc('0xa')+_0x319e04});}(0x0,fs_1['writeFileSync'])(path['join'](_0x361159,a1_0x2bdc('0x1c')+_0xc00469),_0x319e04);}function onComplete(_0x47a790,_0x11f6b7,_0x4fd319,_0x2f26c5,_0x6b7253,_0x439919,_0x362337,_0x3f4c3c,_0x4d606e,_0x189538,_0x9e91c8){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1c7431=new Date()[a1_0x2bdc('0x1b')]();if(environment_1[a1_0x2bdc('0x2d')]){storeTaskHashes(_0x4d606e,_0x11f6b7[a1_0x2bdc('0xe')]||'./node_modules/.cache/nx',environment_1[a1_0x2bdc('0x4')]);}const _0x2af036=(0x0,environment_1[a1_0x2bdc('0x2e')])();const _0x460728=yield Promise[a1_0x2bdc('0x33')]([_0x4fd319[a1_0x2bdc('0x2b')](),_0x2f26c5[a1_0x2bdc('0x9')]({'command':_0x6b7253[a1_0x2bdc('0x2c')]((0x0,environment_1[a1_0x2bdc('0x34')])()),'startTime':_0x439919,'endTime':_0x1c7431,'distributedExecutionId':environment_1[a1_0x2bdc('0x4')],'branch':_0x2af036,'scan':!![],'runGroup':(0x0,environment_1[a1_0x2bdc('0xd')])(),'sha':_0x2af036?(0x0,environment_1['extractGitSha'])():undefined,'inner':_0x9e91c8},_0x4d606e)]);if(_0x189538){setTimeout(()=>{_0x362337[a1_0x2bdc('0xf')]();if(!_0x362337[a1_0x2bdc('0x30')]&&!_0x9e91c8){_0x3f4c3c[a1_0x2bdc('0x13')]();}},0x0);}else{_0x362337[a1_0x2bdc('0xf')]();if(!_0x362337['anyErrors']&&!_0x9e91c8){_0x3f4c3c[a1_0x2bdc('0x13')]();}}if(environment_1[a1_0x2bdc('0x2d')]){if(!_0x460728[0x0]){output[a1_0x2bdc('0x16')]({'title':'Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts'});_0x362337[a1_0x2bdc('0xf')]();process['exit'](environment_1[a1_0x2bdc('0x39')]);}if(!_0x460728[0x1]){output[a1_0x2bdc('0x16')]({'title':a1_0x2bdc('0x12')});_0x362337[a1_0x2bdc('0xf')]();process[a1_0x2bdc('0x19')](environment_1[a1_0x2bdc('0x39')]);}}yield(0x0,metric_logger_1['submitRunMetrics'])(_0x11f6b7);});}function createLifeCycle(_0x58f728,_0x278af1,_0x3a73aa,_0x5a5fd7){const _0x351e4f=new cloud_enabled_life_cycle_1['CloudEnabledLifeCycle'](_0x58f728,_0x278af1[a1_0x2bdc('0xe')],!!_0x278af1[a1_0x2bdc('0x2a')],_0x278af1['scan']===undefined?!![]:_0x278af1['scan'],_0x278af1[a1_0x2bdc('0x28')]||[],_0x3a73aa,_0x5a5fd7);try{const {CompositeLifeCycle}=require(a1_0x2bdc('0x32'));if(!CompositeLifeCycle)return _0x351e4f;return new CompositeLifeCycle([_0x278af1[a1_0x2bdc('0x14')],_0x351e4f]);}catch(_0x23c42f){return _0x351e4f;}}function cloudEnabledTasksRunner(_0xd7d6e2,_0x1cff59,_0x1d614c,_0x22cfc3=![]){const _0x31be7a={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0xd7d6e2};const _0x1822fd=_0x1cff59['lifeCycle']===undefined;const _0x4e699a=[];const _0x20f22c=new message_reporter_1[(a1_0x2bdc('0x5'))](_0x1cff59);const _0x1a82a6=createApi(_0x20f22c,_0x1cff59,_0x31be7a);const _0x9fbe35=new end_of_run_message_1[(a1_0x2bdc('0x27'))](_0x31be7a,_0x4e699a);const _0x262c43=new output_obfuscator_1[(a1_0x2bdc('0x25'))](_0x1cff59['maskedProperties']);const _0x260f71=_0xd7d6e2[a1_0x2bdc('0x1a')](_0x2272b5=>_0x2272b5['hash'])[a1_0x2bdc('0x37')](_0x19a3b6=>!!_0x19a3b6);const _0x82a0a9=_0x1a82a6[a1_0x2bdc('0x10')](environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],_0x260f71);_0x260f71['forEach'](_0x4c0a84=>{_0x31be7a[a1_0x2bdc('0x26')][_0x4c0a84]=_0x82a0a9;});const _0x43e156=new Date()[a1_0x2bdc('0x1b')]();const _0x530591=createLifeCycle(_0x31be7a,_0x1cff59,_0x262c43,_0x4e699a);const _0x2d5e0c=new e2e_encryption_1['E2EEncryption'](environment_1[a1_0x2bdc('0x6')]||_0x1cff59[a1_0x2bdc('0x3')]);const _0x38529f=new error_reporter_api_1['ErrorReporterApi'](_0x1cff59);const _0x20e320=new file_storage_1[(a1_0x2bdc('0x21'))](_0x2d5e0c,_0x38529f,![]);const _0x3cc530=new cloud_remote_cache_1[(a1_0x2bdc('0x31'))](_0x20f22c,_0x1a82a6,_0x31be7a,_0x20e320);delete process[a1_0x2bdc('0x17')]['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'];const _0x20c08=tasksRunner(_0xd7d6e2,Object[a1_0x2bdc('0x20')](Object[a1_0x2bdc('0x20')]({},_0x1cff59),{'remoteCache':_0x3cc530,'lifeCycle':_0x530591}),_0x1d614c);if(_0x20c08[a1_0x2bdc('0x8')]){const {Subject}=require('rxjs/internal/Subject');const _0x1e1217=new Subject();_0x20c08[a1_0x2bdc('0x8')]({'next':_0x28ed6d=>_0x1e1217['next'](_0x28ed6d),'error':_0x5a7e14=>_0x1e1217[a1_0x2bdc('0x16')](_0x5a7e14),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x530591,_0x1cff59,_0x3cc530,_0x1a82a6,_0x262c43,_0x43e156,_0x20f22c,_0x9fbe35,_0x4e699a,_0x1822fd,_0x22cfc3);_0x1e1217[a1_0x2bdc('0x29')]();})});return _0x1e1217;}else{return _0x20c08['then'](_0x5386e3=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x530591,_0x1cff59,_0x3cc530,_0x1a82a6,_0x262c43,_0x43e156,_0x20f22c,_0x9fbe35,_0x4e699a,_0x1822fd,_0x22cfc3);return _0x5386e3;}))[a1_0x2bdc('0x36')](_0x2014c6=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x530591,_0x1cff59,_0x3cc530,_0x1a82a6,_0x262c43,_0x43e156,_0x20f22c,_0x9fbe35,_0x4e699a,_0x1822fd,_0x22cfc3);throw _0x2014c6;}));}}exports[a1_0x2bdc('0x2f')]=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_0x1cd7=['done','map','statuses','hashUrls','storeRequests','Nx\x20Cloud:\x20Cache\x20miss\x20','get','messages','fileStorage','push','Nx\x20Cloud:\x20Skipping\x20storing\x20','__awaiter','extractErrorMessage','requests','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','defineProperty','store','VERBOSE_LOGGING','api','__esModule','startRun','then','note','resolve','remote-cache-hit','waitForStoreRequestsToComplete','cacheError','apply','../../../utilities/environment','next','indexOf','axiosException','retrieve','storage','CloudRemoteCache','reduce','runContext','status','hash','response','value','../../../utilities/nx-imports','scheduledTasks','cache-miss'];(function(_0x1b9b49,_0x1cd711){const _0x445577=function(_0x27e548){while(--_0x27e548){_0x1b9b49['push'](_0x1b9b49['shift']());}};_0x445577(++_0x1cd711);}(a2_0x1cd7,0xd8));const a2_0x4455=function(_0x1b9b49,_0x1cd711){_0x1b9b49=_0x1b9b49-0x0;let _0x445577=a2_0x1cd7[_0x1b9b49];return _0x445577;};'use strict';var __awaiter=this&&this[a2_0x4455('0xf')]||function(_0x301ebf,_0x1a0843,_0x4ef03f,_0xe752ff){function _0x4365f9(_0x593437){return _0x593437 instanceof _0x4ef03f?_0x593437:new _0x4ef03f(function(_0x1ae45f){_0x1ae45f(_0x593437);});}return new(_0x4ef03f||(_0x4ef03f=Promise))(function(_0x198f21,_0x32a175){function _0x59bb89(_0x563177){try{_0x3ffbc5(_0xe752ff['next'](_0x563177));}catch(_0x2d9edb){_0x32a175(_0x2d9edb);}}function _0x5b1b74(_0x17ef58){try{_0x3ffbc5(_0xe752ff['throw'](_0x17ef58));}catch(_0x5a6dd1){_0x32a175(_0x5a6dd1);}}function _0x3ffbc5(_0x287909){_0x287909[a2_0x4455('0x4')]?_0x198f21(_0x287909[a2_0x4455('0x0')]):_0x4365f9(_0x287909[a2_0x4455('0x0')])['then'](_0x59bb89,_0x5b1b74);}_0x3ffbc5((_0xe752ff=_0xe752ff[a2_0x4455('0x1f')](_0x301ebf,_0x1a0843||[]))[a2_0x4455('0x21')]());});};Object[a2_0x4455('0x13')](exports,a2_0x4455('0x17'),{'value':!![]});exports[a2_0x4455('0x26')]=void 0x0;const environment_1=require(a2_0x4455('0x20'));const {output}=require(a2_0x4455('0x1'));class CloudRemoteCache{constructor(_0x3f8c7a,_0x35b030,_0xb1df1f,_0xb3e8ba){this[a2_0x4455('0xb')]=_0x3f8c7a;this[a2_0x4455('0x16')]=_0x35b030;this['runContext']=_0xb1df1f;this[a2_0x4455('0xc')]=_0xb3e8ba;this[a2_0x4455('0x8')]=[];}[a2_0x4455('0x24')](_0x4ede31,_0x4834db){var _0x8e290e;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x4455('0xb')][a2_0x4455('0x1e')])return![];const _0x199c2b=yield this['hashUrls'](_0x4ede31);if(!_0x199c2b||!_0x199c2b[a2_0x4455('0xa')]){if(environment_1['VERBOSE_LOGGING']){output[a2_0x4455('0x1a')]({'title':a2_0x4455('0x9')+_0x4ede31+'.'});}this['runContext'][a2_0x4455('0x6')][_0x4ede31]=a2_0x4455('0x3');return![];}try{yield this[a2_0x4455('0xc')]['retrieve'](_0x4ede31,_0x199c2b[a2_0x4455('0xa')],_0x4834db);this[a2_0x4455('0x28')][a2_0x4455('0x6')][_0x4ede31]=a2_0x4455('0x1c');return!![];}catch(_0xea0a3e){const _0x5934e3=(_0x8e290e=_0xea0a3e[a2_0x4455('0x23')])!==null&&_0x8e290e!==void 0x0?_0x8e290e:_0xea0a3e;if(_0x5934e3[a2_0x4455('0x2b')]&&_0x5934e3[a2_0x4455('0x2b')][a2_0x4455('0x29')]===0x194){if(environment_1[a2_0x4455('0x15')]){output[a2_0x4455('0x1a')]({'title':a2_0x4455('0x9')+_0x4ede31+'.\x20Status\x20404.'});}}else{this[a2_0x4455('0xb')][a2_0x4455('0x1e')]=this['messages'][a2_0x4455('0x10')](_0x5934e3,a2_0x4455('0x25'));}this[a2_0x4455('0x28')][a2_0x4455('0x6')][_0x4ede31]=a2_0x4455('0x3');return![];}});}['store'](_0x1ea256,_0x250007){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x4455('0xb')][a2_0x4455('0x1e')])return![];const _0x1ef349=Promise[a2_0x4455('0x1b')]()[a2_0x4455('0x19')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x34af5d;const _0x1190f1=yield this[a2_0x4455('0x7')](_0x1ea256);if(!_0x1190f1)return![];if(!_0x1190f1['put']){if(environment_1[a2_0x4455('0x15')]){output[a2_0x4455('0x1a')]({'title':a2_0x4455('0xe')+_0x1ea256+'.\x20Read\x20only\x20token\x20is\x20used.'});}return!![];}try{yield this['fileStorage'][a2_0x4455('0x14')](_0x1ea256,_0x1190f1['put'],_0x250007);return!![];}catch(_0x530007){const _0x541689=(_0x34af5d=_0x530007[a2_0x4455('0x23')])!==null&&_0x34af5d!==void 0x0?_0x34af5d:_0x530007;this['messages'][a2_0x4455('0x1e')]=this[a2_0x4455('0xb')][a2_0x4455('0x10')](_0x541689,a2_0x4455('0x25'));return![];}}));this['storeRequests']['push'](_0x1ef349);return _0x1ef349;});}['hashUrls'](_0xa323ff){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0xa323ff in this['runContext'][a2_0x4455('0x11')]){return(yield this[a2_0x4455('0x28')]['requests'][_0xa323ff])[_0xa323ff];}else{const _0x486d18=this[a2_0x4455('0x28')][a2_0x4455('0x2')]['filter'](_0x4b2ec0=>!this['runContext'][a2_0x4455('0x11')][_0x4b2ec0[a2_0x4455('0x2a')]])[a2_0x4455('0x5')](_0x2a0ec7=>_0x2a0ec7[a2_0x4455('0x2a')]);if(_0x486d18[a2_0x4455('0x22')](_0xa323ff)===-0x1){_0x486d18[a2_0x4455('0xd')](_0xa323ff);}const _0x54df7a=this[a2_0x4455('0x16')][a2_0x4455('0x18')](environment_1[a2_0x4455('0x12')],_0x486d18);_0x486d18['forEach'](_0x5e28dd=>{this[a2_0x4455('0x28')][a2_0x4455('0x11')][_0x5e28dd]=_0x54df7a;});return(yield _0x54df7a)[_0xa323ff];}});}[a2_0x4455('0x1d')](){return Promise['all'](this[a2_0x4455('0x8')])[a2_0x4455('0x19')](_0x11aae2=>_0x11aae2[a2_0x4455('0x27')]((_0x5125c6,_0x1f636f)=>_0x5125c6&&_0x1f636f,!![]));}}exports[a2_0x4455('0x26')]=CloudRemoteCache;
|