@nrwl/nx-cloud 13.1.0-beta.1 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/api/run-group.api.js +1 -59
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -120
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -167
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -113
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -153
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -73
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -239
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -122
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -308
- package/lib/utilities/metric-logger.js +2 -2
- package/lib/utilities/metric-logger.js.map +1 -1
- package/lib/utilities/print-message.js +5 -1
- package/lib/utilities/print-message.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,59 +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 output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
14
|
-
const axios_1 = require("../../utilities/axios");
|
|
15
|
-
const metric_logger_1 = require("../../utilities/metric-logger");
|
|
16
|
-
class RunGroupApi {
|
|
17
|
-
constructor(options) {
|
|
18
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
19
|
-
}
|
|
20
|
-
createRunGroup(branch, runGroup) {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
23
|
-
try {
|
|
24
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
|
|
25
|
-
branch: branch,
|
|
26
|
-
runGroup: runGroup,
|
|
27
|
-
}), 3);
|
|
28
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
32
|
-
output_1.output.error({
|
|
33
|
-
title: e.message,
|
|
34
|
-
});
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
completeRunGroup(runGroup) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
42
|
-
try {
|
|
43
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
44
|
-
runGroup: runGroup,
|
|
45
|
-
}), 3);
|
|
46
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
50
|
-
output_1.output.error({
|
|
51
|
-
title: e.message,
|
|
52
|
-
});
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.RunGroupApi = RunGroupApi;
|
|
59
|
-
//# sourceMappingURL=run-group.api.js.map
|
|
1
|
+
const a0_0x1671=['output','RunGroupApi','value','completeRunGroup','then','RUNNER_FAILURE_PERF_ENTRY','__esModule','createRunGroup','apiAxiosInstance','error','mapRespToPerfEntry','defineProperty','../../utilities/metric-logger','@nrwl/workspace/src/utilities/output','recordMetric','axiosMultipleTries','/nx-cloud/executions/complete-run-group','exit','__awaiter','apply','next','throw','message','done','createMetricRecorder','post'];(function(_0x547691,_0x16710c){const _0x411523=function(_0x43064b){while(--_0x43064b){_0x547691['push'](_0x547691['shift']());}};_0x411523(++_0x16710c);}(a0_0x1671,0x1c7));const a0_0x4115=function(_0x547691,_0x16710c){_0x547691=_0x547691-0x0;let _0x411523=a0_0x1671[_0x547691];return _0x411523;};'use strict';var __awaiter=this&&this[a0_0x4115('0x5')]||function(_0x29593b,_0xed32c4,_0x2cd709,_0x16ff0d){function _0x1164b3(_0x317dec){return _0x317dec instanceof _0x2cd709?_0x317dec:new _0x2cd709(function(_0x55165a){_0x55165a(_0x317dec);});}return new(_0x2cd709||(_0x2cd709=Promise))(function(_0x4ea75b,_0x5189c5){function _0x4529f3(_0x23c93d){try{_0x42050d(_0x16ff0d[a0_0x4115('0x7')](_0x23c93d));}catch(_0x512140){_0x5189c5(_0x512140);}}function _0xcb660e(_0x311817){try{_0x42050d(_0x16ff0d[a0_0x4115('0x8')](_0x311817));}catch(_0x4d8e2f){_0x5189c5(_0x4d8e2f);}}function _0x42050d(_0x1ab97c){_0x1ab97c[a0_0x4115('0xa')]?_0x4ea75b(_0x1ab97c[a0_0x4115('0xf')]):_0x1164b3(_0x1ab97c['value'])[a0_0x4115('0x11')](_0x4529f3,_0xcb660e);}_0x42050d((_0x16ff0d=_0x16ff0d[a0_0x4115('0x6')](_0x29593b,_0xed32c4||[]))[a0_0x4115('0x7')]());});};Object[a0_0x4115('0x18')](exports,a0_0x4115('0x13'),{'value':!![]});exports['RunGroupApi']=void 0x0;const output_1=require(a0_0x4115('0x0'));const axios_1=require('../../utilities/axios');const metric_logger_1=require(a0_0x4115('0x19'));class RunGroupApi{constructor(_0x188de4){this[a0_0x4115('0x15')]=(0x0,axios_1['createApiAxiosInstance'])(_0x188de4);}[a0_0x4115('0x14')](_0x1d510d,_0x3361b5){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x33587b=(0x0,metric_logger_1['createMetricRecorder'])('createRunGroup');try{const _0x41a392=yield(0x0,axios_1[a0_0x4115('0x2')])(()=>this[a0_0x4115('0x15')][a0_0x4115('0xc')]('/nx-cloud/executions/create-run-group',{'branch':_0x1d510d,'runGroup':_0x3361b5}),0x3);_0x33587b['recordMetric']((0x0,metric_logger_1[a0_0x4115('0x17')])(_0x41a392));}catch(_0x3e8a5b){_0x33587b[a0_0x4115('0x1')](metric_logger_1[a0_0x4115('0x12')]);output_1[a0_0x4115('0xd')][a0_0x4115('0x16')]({'title':_0x3e8a5b[a0_0x4115('0x9')]});process[a0_0x4115('0x4')](0x1);}});}[a0_0x4115('0x10')](_0x6cd11a){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x724e19=(0x0,metric_logger_1[a0_0x4115('0xb')])(a0_0x4115('0x14'));try{const _0x11abd6=yield(0x0,axios_1[a0_0x4115('0x2')])(()=>this[a0_0x4115('0x15')][a0_0x4115('0xc')](a0_0x4115('0x3'),{'runGroup':_0x6cd11a}),0x3);_0x724e19['recordMetric']((0x0,metric_logger_1[a0_0x4115('0x17')])(_0x11abd6));}catch(_0x1d1146){_0x724e19[a0_0x4115('0x1')](metric_logger_1[a0_0x4115('0x12')]);output_1[a0_0x4115('0xd')][a0_0x4115('0x16')]({'title':_0x1d1146[a0_0x4115('0x9')]});process['exit'](0x1);}});}}exports[a0_0x4115('0xe')]=RunGroupApi;
|
|
@@ -1,120 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CloudEnabledLifeCycle = void 0;
|
|
4
|
-
const utils_1 = require("@nrwl/workspace/src/tasks-runner/utils");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const app_root_1 = require("@nrwl/workspace/src/utils/app-root");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const path = require("path");
|
|
9
|
-
class CloudEnabledLifeCycle {
|
|
10
|
-
constructor(runContext, cacheDirectory, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
|
|
11
|
-
this.runContext = runContext;
|
|
12
|
-
this.cacheDirectory = cacheDirectory;
|
|
13
|
-
this.collectTerminalOutput = collectTerminalOutput;
|
|
14
|
-
this.cacheableOperations = cacheableOperations;
|
|
15
|
-
this.outputObfuscator = outputObfuscator;
|
|
16
|
-
this.tasks = tasks;
|
|
17
|
-
}
|
|
18
|
-
scheduleTask(task) {
|
|
19
|
-
this.runContext.scheduledTasks.push(task);
|
|
20
|
-
}
|
|
21
|
-
startTask(task) {
|
|
22
|
-
const overrides = Object.assign({}, (task.overrides || {}));
|
|
23
|
-
if (task.target.configuration) {
|
|
24
|
-
overrides['configuration'] = task.target.configuration;
|
|
25
|
-
}
|
|
26
|
-
this.tasks.push({
|
|
27
|
-
taskId: task.id,
|
|
28
|
-
startTime: new Date().toISOString(),
|
|
29
|
-
target: task.target.target,
|
|
30
|
-
projectName: task.target.project,
|
|
31
|
-
hash: task.hash,
|
|
32
|
-
hashDetails: this.cleanUpHashDetails(task.hashDetails),
|
|
33
|
-
params: (0, utils_1.unparse)(overrides).join(' '),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
endTask(task, code) {
|
|
37
|
-
const startedTask = this.tasks.find((t) => t.taskId === task.id);
|
|
38
|
-
if (!startedTask) {
|
|
39
|
-
throw new Error(`Cannot find task ${task.id}`);
|
|
40
|
-
}
|
|
41
|
-
startedTask.endTime = new Date().toISOString();
|
|
42
|
-
startedTask.status = code;
|
|
43
|
-
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
|
|
44
|
-
if (this.runContext.statuses[task.hash]) {
|
|
45
|
-
startedTask.cacheStatus = this.runContext.statuses[task.hash];
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
if (this.cacheableOperations.indexOf(task.target.target) > -1) {
|
|
49
|
-
startedTask.cacheStatus = 'local-cache-hit';
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
startedTask.cacheStatus = 'cache-miss';
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (this.collectTerminalOutput) {
|
|
56
|
-
startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
endCommand() { }
|
|
60
|
-
getTerminalOutput(hash, cacheStatus, code) {
|
|
61
|
-
let dir;
|
|
62
|
-
if (this.cacheDirectory) {
|
|
63
|
-
if (this.cacheDirectory.startsWith('./')) {
|
|
64
|
-
dir = (0, path_1.join)(app_root_1.appRootPath, this.cacheDirectory);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
dir = this.cacheDirectory;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
dir = (0, path_1.join)(app_root_1.appRootPath, 'node_modules', '.cache', 'nx');
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
const taskOutput = this.readTerminalOutputFile(dir, hash);
|
|
75
|
-
const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
|
|
76
|
-
const maxCharacters = cacheStatus === 'cache-miss'
|
|
77
|
-
? code === 0
|
|
78
|
-
? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
|
|
79
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
|
|
80
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
|
|
81
|
-
return taskOutputSanitized.length > maxCharacters
|
|
82
|
-
? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
|
|
83
|
-
: taskOutputSanitized;
|
|
84
|
-
}
|
|
85
|
-
catch (e) {
|
|
86
|
-
return '';
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
cleanUpHashDetails(hashDetails) {
|
|
90
|
-
const nodes = {};
|
|
91
|
-
Object.keys(hashDetails.nodes)
|
|
92
|
-
.filter((k) => !k.startsWith('npm:'))
|
|
93
|
-
.forEach((k) => {
|
|
94
|
-
nodes[k] = hashDetails.nodes[k];
|
|
95
|
-
});
|
|
96
|
-
return {
|
|
97
|
-
nodes,
|
|
98
|
-
runtime: hashDetails.runtime,
|
|
99
|
-
implicitDeps: hashDetails.implicitDeps,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
readTerminalOutputFile(dir, hash) {
|
|
103
|
-
try {
|
|
104
|
-
return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
|
|
105
|
-
}
|
|
106
|
-
catch (_a) {
|
|
107
|
-
try {
|
|
108
|
-
return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
|
|
109
|
-
}
|
|
110
|
-
catch (_b) {
|
|
111
|
-
return '';
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
|
|
117
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
|
|
118
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
|
|
119
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 5000;
|
|
120
|
-
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
|
|
1
|
+
const a0_0x2ce0=['readFileSync','npm:','hashDetails','@nrwl/workspace/src/utils/app-root','node_modules','forEach','endTime','join','filter','CloudEnabledLifeCycle','terminalOutput','configuration','runtime','path','find','MAX_CHARACTERS_CACHED_TASK','target','@nrwl/workspace/src/tasks-runner/utils','push','cleanUpHashDetails','__esModule','implicitDeps','cacheableOperations','obfuscate','status','terminalOutputs','outputObfuscator','appRootPath','hash','runContext','params','unparse','tasks','endTask','startTask','cacheDirectory','indexOf','toISOString','slice','nodes','cache-miss','taskId','MAX_CHARACTERS_FAILED_TASK','MAX_CHARACTERS_SUCCESSFUL_TASK','length','cacheStatus','scheduleTask','defineProperty','endCommand','toString','statuses','TRUNCATED\x0a\x0a','getTerminalOutput','overrides','assign'];(function(_0xa73f1d,_0x2ce063){const _0x3a87e5=function(_0x86d32c){while(--_0x86d32c){_0xa73f1d['push'](_0xa73f1d['shift']());}};_0x3a87e5(++_0x2ce063);}(a0_0x2ce0,0x8f));const a0_0x3a87=function(_0xa73f1d,_0x2ce063){_0xa73f1d=_0xa73f1d-0x0;let _0x3a87e5=a0_0x2ce0[_0xa73f1d];return _0x3a87e5;};'use strict';Object[a0_0x3a87('0xe')](exports,a0_0x3a87('0x2a'),{'value':!![]});exports[a0_0x3a87('0x1f')]=void 0x0;const utils_1=require(a0_0x3a87('0x27'));const path_1=require('path');const app_root_1=require(a0_0x3a87('0x19'));const fs_1=require('fs');const path=require(a0_0x3a87('0x23'));class CloudEnabledLifeCycle{constructor(_0x4f9d77,_0xacc1bf,_0x5c3f23,_0x1e8b64,_0x512366,_0x4a01ce){this[a0_0x3a87('0x33')]=_0x4f9d77;this[a0_0x3a87('0x2')]=_0xacc1bf;this['collectTerminalOutput']=_0x5c3f23;this['cacheableOperations']=_0x1e8b64;this[a0_0x3a87('0x30')]=_0x512366;this[a0_0x3a87('0x36')]=_0x4a01ce;}[a0_0x3a87('0xd')](_0x1d4665){this[a0_0x3a87('0x33')]['scheduledTasks'][a0_0x3a87('0x28')](_0x1d4665);}[a0_0x3a87('0x1')](_0x2e6012){const _0x3f0774=Object[a0_0x3a87('0x15')]({},_0x2e6012[a0_0x3a87('0x14')]||{});if(_0x2e6012[a0_0x3a87('0x26')]['configuration']){_0x3f0774[a0_0x3a87('0x21')]=_0x2e6012['target']['configuration'];}this['tasks']['push']({'taskId':_0x2e6012['id'],'startTime':new Date()[a0_0x3a87('0x4')](),'target':_0x2e6012['target']['target'],'projectName':_0x2e6012[a0_0x3a87('0x26')]['project'],'hash':_0x2e6012['hash'],'hashDetails':this[a0_0x3a87('0x29')](_0x2e6012[a0_0x3a87('0x18')]),'params':(0x0,utils_1[a0_0x3a87('0x35')])(_0x3f0774)[a0_0x3a87('0x1d')]('\x20')});}[a0_0x3a87('0x0')](_0x122069,_0x3c9eea){const _0x5cb889=this[a0_0x3a87('0x36')][a0_0x3a87('0x24')](_0x440f28=>_0x440f28[a0_0x3a87('0x8')]===_0x122069['id']);if(!_0x5cb889){throw new Error('Cannot\x20find\x20task\x20'+_0x122069['id']);}_0x5cb889[a0_0x3a87('0x1c')]=new Date()['toISOString']();_0x5cb889[a0_0x3a87('0x2e')]=_0x3c9eea;_0x5cb889[a0_0x3a87('0x34')]=this[a0_0x3a87('0x30')][a0_0x3a87('0x2d')](_0x5cb889[a0_0x3a87('0x34')]);if(this['runContext']['statuses'][_0x122069[a0_0x3a87('0x32')]]){_0x5cb889[a0_0x3a87('0xc')]=this['runContext'][a0_0x3a87('0x11')][_0x122069[a0_0x3a87('0x32')]];}else{if(this[a0_0x3a87('0x2c')][a0_0x3a87('0x3')](_0x122069[a0_0x3a87('0x26')][a0_0x3a87('0x26')])>-0x1){_0x5cb889[a0_0x3a87('0xc')]='local-cache-hit';}else{_0x5cb889['cacheStatus']='cache-miss';}}if(this['collectTerminalOutput']){_0x5cb889[a0_0x3a87('0x20')]=this[a0_0x3a87('0x13')](_0x122069[a0_0x3a87('0x32')],_0x5cb889[a0_0x3a87('0xc')],_0x3c9eea);}}[a0_0x3a87('0xf')](){}[a0_0x3a87('0x13')](_0x75bdf4,_0x208509,_0x127c28){let _0x286452;if(this[a0_0x3a87('0x2')]){if(this[a0_0x3a87('0x2')]['startsWith']('./')){_0x286452=(0x0,path_1['join'])(app_root_1[a0_0x3a87('0x31')],this[a0_0x3a87('0x2')]);}else{_0x286452=this[a0_0x3a87('0x2')];}}else{_0x286452=(0x0,path_1[a0_0x3a87('0x1d')])(app_root_1[a0_0x3a87('0x31')],a0_0x3a87('0x1a'),'.cache','nx');}try{const _0x473e5f=this['readTerminalOutputFile'](_0x286452,_0x75bdf4);const _0x294edc=this[a0_0x3a87('0x30')]['obfuscate'](_0x473e5f);const _0x4f9fad=_0x208509===a0_0x3a87('0x7')?_0x127c28===0x0?CloudEnabledLifeCycle[a0_0x3a87('0xa')]:CloudEnabledLifeCycle[a0_0x3a87('0x9')]:CloudEnabledLifeCycle['MAX_CHARACTERS_CACHED_TASK'];return _0x294edc['length']>_0x4f9fad?a0_0x3a87('0x12')+_0x294edc[a0_0x3a87('0x5')](_0x294edc[a0_0x3a87('0xb')]-_0x4f9fad):_0x294edc;}catch(_0x55ab9f){return'';}}['cleanUpHashDetails'](_0x11ab9c){const _0x2385e6={};Object['keys'](_0x11ab9c[a0_0x3a87('0x6')])[a0_0x3a87('0x1e')](_0x269408=>!_0x269408['startsWith'](a0_0x3a87('0x17')))[a0_0x3a87('0x1b')](_0x2390ca=>{_0x2385e6[_0x2390ca]=_0x11ab9c[a0_0x3a87('0x6')][_0x2390ca];});return{'nodes':_0x2385e6,'runtime':_0x11ab9c[a0_0x3a87('0x22')],'implicitDeps':_0x11ab9c[a0_0x3a87('0x2b')]};}['readTerminalOutputFile'](_0xd96fc5,_0x4adb98){try{return(0x0,fs_1[a0_0x3a87('0x16')])(path[a0_0x3a87('0x1d')](_0xd96fc5,a0_0x3a87('0x2f'),_0x4adb98))[a0_0x3a87('0x10')]();}catch(_0x5b06aa){try{return(0x0,fs_1[a0_0x3a87('0x16')])(path[a0_0x3a87('0x1d')](_0xd96fc5,_0x4adb98,'terminalOutput'))[a0_0x3a87('0x10')]();}catch(_0x406a35){return'';}}}}exports['CloudEnabledLifeCycle']=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x3a87('0x9')]=0x30d40;CloudEnabledLifeCycle['MAX_CHARACTERS_SUCCESSFUL_TASK']=0x4e20;CloudEnabledLifeCycle[a0_0x3a87('0x25')]=0x1388;
|
|
@@ -1,167 +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 Subject_1 = require("rxjs/internal/Subject");
|
|
14
|
-
const message_reporter_1 = require("../../terminal-output/message-reporter");
|
|
15
|
-
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
|
|
16
|
-
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
|
|
17
|
-
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
|
|
18
|
-
const file_storage_1 = require("../../file-storage/file-storage");
|
|
19
|
-
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
|
|
20
|
-
const environment_1 = require("../../../utilities/environment");
|
|
21
|
-
const cloud_remote_cache_1 = require("./cloud-remote-cache");
|
|
22
|
-
const tasks_runner_v2_1 = require("@nrwl/workspace/src/tasks-runner/tasks-runner-v2");
|
|
23
|
-
const output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
24
|
-
const cloud_run_api_1 = require("./cloud-run.api");
|
|
25
|
-
const fs_1 = require("fs");
|
|
26
|
-
const path = require("path");
|
|
27
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
28
|
-
function createApi(errors, options, runContext) {
|
|
29
|
-
const machineInfo = (0, environment_1.getMachineInfo)(options);
|
|
30
|
-
return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
|
|
31
|
-
}
|
|
32
|
-
function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
|
|
33
|
-
const hashes = JSON.stringify(taskExecutions.map((t) => ({
|
|
34
|
-
taskId: t.taskId,
|
|
35
|
-
hash: t.hash,
|
|
36
|
-
})));
|
|
37
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
38
|
-
output_1.output.note({
|
|
39
|
-
title: `Executed tasks with hashes: ${hashes}`,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
(0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
|
|
43
|
-
}
|
|
44
|
-
function onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const runEndTime = new Date().toISOString();
|
|
47
|
-
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
|
|
48
|
-
storeTaskHashes(taskExecutions, options.cacheDirectory || './node_modules/.cache/nx', environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
|
|
49
|
-
}
|
|
50
|
-
const branch = (0, environment_1.getBranch)();
|
|
51
|
-
const endRequest = yield Promise.all([
|
|
52
|
-
remoteCache.waitForStoreRequestsToComplete(),
|
|
53
|
-
api.endRun({
|
|
54
|
-
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
|
|
55
|
-
startTime: runStartTime,
|
|
56
|
-
endTime: runEndTime,
|
|
57
|
-
distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
|
|
58
|
-
branch: branch,
|
|
59
|
-
scan: true,
|
|
60
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
61
|
-
// only set sha if branch is set because we invoke a separate process,
|
|
62
|
-
// which adds a few millis
|
|
63
|
-
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
|
|
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) {
|
|
73
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
74
|
-
}
|
|
75
|
-
}, 0);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
messages.printMessages();
|
|
79
|
-
if (!messages.anyErrors) {
|
|
80
|
-
endOfRunMessage.printCacheHitsMessage();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
|
|
84
|
-
if (!endRequest[0]) {
|
|
85
|
-
output_1.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_1.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.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
|
|
104
|
-
try {
|
|
105
|
-
const { CompositeLifeCycle, } = require('@nrwl/workspace/src/tasks-runner/life-cycle');
|
|
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) {
|
|
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();
|
|
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 fileStorage = new file_storage_1.FileStorage(encryption, environment_1.NUMBER_OF_TRIES);
|
|
136
|
-
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
|
|
137
|
-
// have to reset it so we don't capture inner tasks
|
|
138
|
-
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
|
|
139
|
-
const res = (0, tasks_runner_v2_1.tasksRunnerV2)(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
|
|
140
|
-
// observable -> legacy
|
|
141
|
-
if (res.subscribe) {
|
|
142
|
-
const wrappedRes = new Subject_1.Subject();
|
|
143
|
-
res.subscribe({
|
|
144
|
-
next: (value) => wrappedRes.next(value),
|
|
145
|
-
error: (err) => wrappedRes.error(err),
|
|
146
|
-
complete: () => __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133);
|
|
148
|
-
wrappedRes.complete();
|
|
149
|
-
}),
|
|
150
|
-
});
|
|
151
|
-
return wrappedRes;
|
|
152
|
-
// promise
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
return res
|
|
156
|
-
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133);
|
|
158
|
-
return r;
|
|
159
|
-
}))
|
|
160
|
-
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133);
|
|
162
|
-
throw e;
|
|
163
|
-
}));
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
|
|
167
|
-
//# sourceMappingURL=cloud-enabled.runner.js.map
|
|
1
|
+
const a1_0x2cc5=['ENCRYPTION_KEY','then','map','OutputObfuscator','NUMBER_OF_TRIES','throw','anyErrors','cloudEnabledTasksRunner','output','requests','../../terminal-output/output-obfuscator','./node_modules/.cache/nx','Executed\x20tasks\x20with\x20hashes:\x20','../../terminal-output/end-of-run-message','CloudRemoteCache','FileStorage','MessageReporter','complete','Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run','join','catch','assign','./cloud-enabled-life-cycle','EndOfRunMessage','Subject','stringify','next','done','getBranch','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','obfuscate','path','../../file-storage/file-storage','submitRunMetrics','./cloud-remote-cache','../../file-storage/e2e-encryption','__awaiter','Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts','@nrwl/workspace/src/tasks-runner/life-cycle','VERBOSE_LOGGING','hash','taskId','value','__esModule','scan','toISOString','exit','defineProperty','encryptionKey','extractGitSha','note','printMessages','getMachineInfo','subscribe','CloudRunApi','cacheableOperations','printCacheHitsMessage','error','lifeCycle','env','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','@nrwl/workspace/src/utilities/output','getRunGroup','endRun','rxjs/internal/Subject','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','cacheDirectory'];(function(_0x1a390e,_0x2cc557){const _0x263f83=function(_0x10630d){while(--_0x10630d){_0x1a390e['push'](_0x1a390e['shift']());}};_0x263f83(++_0x2cc557);}(a1_0x2cc5,0xd2));const a1_0x263f=function(_0x1a390e,_0x2cc557){_0x1a390e=_0x1a390e-0x0;let _0x263f83=a1_0x2cc5[_0x1a390e];return _0x263f83;};'use strict';var __awaiter=this&&this[a1_0x263f('0x1b')]||function(_0x48237f,_0x1408f3,_0x452698,_0x3d8548){function _0x2c84fd(_0x61af45){return _0x61af45 instanceof _0x452698?_0x61af45:new _0x452698(function(_0x9efb9c){_0x9efb9c(_0x61af45);});}return new(_0x452698||(_0x452698=Promise))(function(_0x12c1bf,_0x26e7f1){function _0x1cabcd(_0xa104fb){try{_0x4725c7(_0x3d8548[a1_0x263f('0x11')](_0xa104fb));}catch(_0x6eea88){_0x26e7f1(_0x6eea88);}}function _0x521e4e(_0x2c092d){try{_0x4725c7(_0x3d8548[a1_0x263f('0x3f')](_0x2c092d));}catch(_0x196d09){_0x26e7f1(_0x196d09);}}function _0x4725c7(_0x1b37e4){_0x1b37e4[a1_0x263f('0x12')]?_0x12c1bf(_0x1b37e4[a1_0x263f('0x21')]):_0x2c84fd(_0x1b37e4[a1_0x263f('0x21')])[a1_0x263f('0x3b')](_0x1cabcd,_0x521e4e);}_0x4725c7((_0x3d8548=_0x3d8548['apply'](_0x48237f,_0x1408f3||[]))[a1_0x263f('0x11')]());});};Object[a1_0x263f('0x26')](exports,a1_0x263f('0x22'),{'value':!![]});exports[a1_0x263f('0x41')]=void 0x0;const Subject_1=require(a1_0x263f('0x37'));const message_reporter_1=require('../../terminal-output/message-reporter');const end_of_run_message_1=require(a1_0x263f('0x4'));const output_obfuscator_1=require(a1_0x263f('0x1'));const cloud_enabled_life_cycle_1=require(a1_0x263f('0xd'));const file_storage_1=require(a1_0x263f('0x17'));const e2e_encryption_1=require(a1_0x263f('0x1a'));const environment_1=require('../../../utilities/environment');const cloud_remote_cache_1=require(a1_0x263f('0x19'));const tasks_runner_v2_1=require('@nrwl/workspace/src/tasks-runner/tasks-runner-v2');const output_1=require(a1_0x263f('0x34'));const cloud_run_api_1=require('./cloud-run.api');const fs_1=require('fs');const path=require(a1_0x263f('0x16'));const metric_logger_1=require('../../../utilities/metric-logger');function createApi(_0x5693a6,_0x1ca4f5,_0x9364db){const _0x2627d2=(0x0,environment_1[a1_0x263f('0x2b')])(_0x1ca4f5);return new cloud_run_api_1[(a1_0x263f('0x2d'))](_0x5693a6,_0x9364db,_0x1ca4f5,_0x2627d2);}function storeTaskHashes(_0x401f92,_0x9bcc45,_0x2d0ed6){const _0x196266=JSON[a1_0x263f('0x10')](_0x401f92[a1_0x263f('0x3c')](_0xb64f79=>({'taskId':_0xb64f79[a1_0x263f('0x20')],'hash':_0xb64f79[a1_0x263f('0x1f')]})));if(environment_1[a1_0x263f('0x1e')]){output_1[a1_0x263f('0x42')][a1_0x263f('0x29')]({'title':a1_0x263f('0x3')+_0x196266});}(0x0,fs_1['writeFileSync'])(path[a1_0x263f('0xa')](_0x9bcc45,'tasks-hashes-'+_0x2d0ed6),_0x196266);}function onComplete(_0xf9c9f5,_0x44b194,_0xdef9a,_0x102a04,_0x5bfbd3,_0x3a8109,_0xb4577b,_0x393296,_0x47362f,_0x13dbbe){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3dc5e4=new Date()['toISOString']();if(environment_1[a1_0x263f('0x33')]){storeTaskHashes(_0x47362f,_0x44b194[a1_0x263f('0x39')]||a1_0x263f('0x2'),environment_1[a1_0x263f('0x14')]);}const _0x3e690e=(0x0,environment_1[a1_0x263f('0x13')])();const _0x14e764=yield Promise['all']([_0xdef9a['waitForStoreRequestsToComplete'](),_0x102a04[a1_0x263f('0x36')]({'command':_0x5bfbd3[a1_0x263f('0x15')]((0x0,environment_1['parseCommand'])()),'startTime':_0x3a8109,'endTime':_0x3dc5e4,'distributedExecutionId':environment_1[a1_0x263f('0x14')],'branch':_0x3e690e,'scan':!![],'runGroup':(0x0,environment_1[a1_0x263f('0x35')])(),'sha':_0x3e690e?(0x0,environment_1[a1_0x263f('0x28')])():undefined},_0x47362f)]);if(_0x13dbbe){setTimeout(()=>{_0xb4577b[a1_0x263f('0x2a')]();if(!_0xb4577b['anyErrors']){_0x393296['printCacheHitsMessage']();}},0x0);}else{_0xb4577b[a1_0x263f('0x2a')]();if(!_0xb4577b[a1_0x263f('0x40')]){_0x393296[a1_0x263f('0x2f')]();}}if(environment_1[a1_0x263f('0x33')]){if(!_0x14e764[0x0]){output_1[a1_0x263f('0x42')][a1_0x263f('0x30')]({'title':a1_0x263f('0x1c')});_0xb4577b[a1_0x263f('0x2a')]();process[a1_0x263f('0x25')](environment_1[a1_0x263f('0x38')]);}if(!_0x14e764[0x1]){output_1[a1_0x263f('0x42')][a1_0x263f('0x30')]({'title':a1_0x263f('0x9')});_0xb4577b[a1_0x263f('0x2a')]();process[a1_0x263f('0x25')](environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']);}}yield(0x0,metric_logger_1[a1_0x263f('0x18')])(_0x44b194);});}function createLifeCycle(_0x41ef55,_0x304670,_0x371147,_0x2a8cdd){const _0x5f4663=new cloud_enabled_life_cycle_1['CloudEnabledLifeCycle'](_0x41ef55,_0x304670[a1_0x263f('0x39')],_0x304670['scan']===undefined?!![]:_0x304670[a1_0x263f('0x23')],_0x304670[a1_0x263f('0x2e')]||[],_0x371147,_0x2a8cdd);try{const {CompositeLifeCycle}=require(a1_0x263f('0x1d'));if(!CompositeLifeCycle)return _0x5f4663;return new CompositeLifeCycle([_0x304670[a1_0x263f('0x31')],_0x5f4663]);}catch(_0x270495){return _0x5f4663;}}function cloudEnabledTasksRunner(_0xef2bf1,_0x54f94f,_0x1d4b3f){const _0x216718={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0xef2bf1};const _0x351e57=_0x54f94f[a1_0x263f('0x31')]===undefined;const _0x147127=[];const _0x3246d4=new message_reporter_1[(a1_0x263f('0x7'))](_0x54f94f);const _0x54c27a=createApi(_0x3246d4,_0x54f94f,_0x216718);const _0xc06c52=new end_of_run_message_1[(a1_0x263f('0xe'))](_0x216718,_0x147127);const _0x4aaf9f=new output_obfuscator_1[(a1_0x263f('0x3d'))]();const _0x3e0f35=_0xef2bf1[a1_0x263f('0x3c')](_0x7b5c5c=>_0x7b5c5c[a1_0x263f('0x1f')])['filter'](_0x49b368=>!!_0x49b368);const _0x2b2679=_0x54c27a['startRun'](environment_1[a1_0x263f('0x14')],_0x3e0f35);_0x3e0f35['forEach'](_0x2d499b=>{_0x216718[a1_0x263f('0x0')][_0x2d499b]=_0x2b2679;});const _0x393db0=new Date()[a1_0x263f('0x24')]();const _0x58fdc7=createLifeCycle(_0x216718,_0x54f94f,_0x4aaf9f,_0x147127);const _0x51b68a=new e2e_encryption_1['E2EEncryption'](environment_1[a1_0x263f('0x3a')]||_0x54f94f[a1_0x263f('0x27')]);const _0x181b73=new file_storage_1[(a1_0x263f('0x6'))](_0x51b68a,environment_1[a1_0x263f('0x3e')]);const _0x3e07c9=new cloud_remote_cache_1[(a1_0x263f('0x5'))](_0x3246d4,_0x54c27a,_0x216718,_0x181b73);delete process[a1_0x263f('0x32')][a1_0x263f('0x14')];const _0x5ea0e1=(0x0,tasks_runner_v2_1['tasksRunnerV2'])(_0xef2bf1,Object[a1_0x263f('0xc')](Object[a1_0x263f('0xc')]({},_0x54f94f),{'remoteCache':_0x3e07c9,'lifeCycle':_0x58fdc7}),_0x1d4b3f);if(_0x5ea0e1['subscribe']){const _0x4c247e=new Subject_1[(a1_0x263f('0xf'))]();_0x5ea0e1[a1_0x263f('0x2c')]({'next':_0x3ba219=>_0x4c247e[a1_0x263f('0x11')](_0x3ba219),'error':_0x383f02=>_0x4c247e[a1_0x263f('0x30')](_0x383f02),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x58fdc7,_0x54f94f,_0x3e07c9,_0x54c27a,_0x4aaf9f,_0x393db0,_0x3246d4,_0xc06c52,_0x147127,_0x351e57);_0x4c247e[a1_0x263f('0x8')]();})});return _0x4c247e;}else{return _0x5ea0e1[a1_0x263f('0x3b')](_0x109fc1=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x58fdc7,_0x54f94f,_0x3e07c9,_0x54c27a,_0x4aaf9f,_0x393db0,_0x3246d4,_0xc06c52,_0x147127,_0x351e57);return _0x109fc1;}))[a1_0x263f('0xb')](_0x457b39=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x58fdc7,_0x54f94f,_0x3e07c9,_0x54c27a,_0x4aaf9f,_0x393db0,_0x3246d4,_0xc06c52,_0x147127,_0x351e57);throw _0x457b39;}));}}exports[a1_0x263f('0x41')]=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 output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
14
|
-
const environment_1 = require("../../../utilities/environment");
|
|
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_1.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_1.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_1.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_0x5423=['status','__awaiter','retrieve','@nrwl/workspace/src/utilities/output','../../../utilities/environment','cacheError','map','fileStorage','defineProperty','hash','response','hashUrls','reduce','Nx\x20Cloud:\x20Cache\x20miss\x20','startRun','VERBOSE_LOGGING','Nx\x20Cloud:\x20Skipping\x20storing\x20','.\x20Read\x20only\x20token\x20is\x20used.','scheduledTasks','storeRequests','storage','throw','runContext','waitForStoreRequestsToComplete','all','then','output','apply','store','axiosException','next','statuses','value','CloudRemoteCache','api','remote-cache-hit','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','messages','indexOf','extractErrorMessage','cache-miss','push','done','resolve','__esModule','requests','note'];(function(_0x44f0b5,_0x5423f5){const _0xedeb91=function(_0x20a8dc){while(--_0x20a8dc){_0x44f0b5['push'](_0x44f0b5['shift']());}};_0xedeb91(++_0x5423f5);}(a2_0x5423,0x185));const a2_0xedeb=function(_0x44f0b5,_0x5423f5){_0x44f0b5=_0x44f0b5-0x0;let _0xedeb91=a2_0x5423[_0x44f0b5];return _0xedeb91;};'use strict';var __awaiter=this&&this[a2_0xedeb('0x23')]||function(_0xbd2722,_0x1db8a2,_0x4c18a7,_0x4c123c){function _0x21f1b2(_0x942ac3){return _0x942ac3 instanceof _0x4c18a7?_0x942ac3:new _0x4c18a7(function(_0xba8509){_0xba8509(_0x942ac3);});}return new(_0x4c18a7||(_0x4c18a7=Promise))(function(_0x454df0,_0x4a786c){function _0x249ae7(_0x329e8d){try{_0x62442c(_0x4c123c['next'](_0x329e8d));}catch(_0x57ac6b){_0x4a786c(_0x57ac6b);}}function _0x1eb49e(_0x1195fa){try{_0x62442c(_0x4c123c[a2_0xedeb('0x8')](_0x1195fa));}catch(_0xbfd7cc){_0x4a786c(_0xbfd7cc);}}function _0x62442c(_0x105847){_0x105847[a2_0xedeb('0x1d')]?_0x454df0(_0x105847[a2_0xedeb('0x13')]):_0x21f1b2(_0x105847[a2_0xedeb('0x13')])[a2_0xedeb('0xc')](_0x249ae7,_0x1eb49e);}_0x62442c((_0x4c123c=_0x4c123c[a2_0xedeb('0xe')](_0xbd2722,_0x1db8a2||[]))[a2_0xedeb('0x11')]());});};Object[a2_0xedeb('0x2a')](exports,a2_0xedeb('0x1f'),{'value':!![]});exports[a2_0xedeb('0x14')]=void 0x0;const output_1=require(a2_0xedeb('0x25'));const environment_1=require(a2_0xedeb('0x26'));class CloudRemoteCache{constructor(_0x3410b9,_0x3920d1,_0x33d403,_0x35aaed){this['messages']=_0x3410b9;this[a2_0xedeb('0x15')]=_0x3920d1;this[a2_0xedeb('0x9')]=_0x33d403;this[a2_0xedeb('0x29')]=_0x35aaed;this[a2_0xedeb('0x6')]=[];}[a2_0xedeb('0x24')](_0x203441,_0x48859c){var _0x2bd3ed;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a2_0xedeb('0x27')])return![];const _0x1ce7fa=yield this[a2_0xedeb('0x2d')](_0x203441);if(!_0x1ce7fa||!_0x1ce7fa['get']){if(environment_1[a2_0xedeb('0x2')]){output_1[a2_0xedeb('0xd')][a2_0xedeb('0x21')]({'title':a2_0xedeb('0x0')+_0x203441+'.'});}this['runContext'][a2_0xedeb('0x12')][_0x203441]=a2_0xedeb('0x1b');return![];}try{yield this['fileStorage'][a2_0xedeb('0x24')](_0x203441,_0x1ce7fa['get'],_0x48859c);this[a2_0xedeb('0x9')]['statuses'][_0x203441]=a2_0xedeb('0x16');return!![];}catch(_0xc517ba){const _0xeaf3c0=(_0x2bd3ed=_0xc517ba[a2_0xedeb('0x10')])!==null&&_0x2bd3ed!==void 0x0?_0x2bd3ed:_0xc517ba;if(_0xeaf3c0[a2_0xedeb('0x2c')]&&_0xeaf3c0[a2_0xedeb('0x2c')][a2_0xedeb('0x22')]===0x194){if(environment_1['VERBOSE_LOGGING']){output_1[a2_0xedeb('0xd')]['note']({'title':a2_0xedeb('0x0')+_0x203441+'.\x20Status\x20404.'});}}else{this['messages'][a2_0xedeb('0x27')]=this[a2_0xedeb('0x18')][a2_0xedeb('0x1a')](_0xeaf3c0,a2_0xedeb('0x7'));}this[a2_0xedeb('0x9')]['statuses'][_0x203441]=a2_0xedeb('0x1b');return![];}});}[a2_0xedeb('0xf')](_0x1318db,_0x45ddd1){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0xedeb('0x18')][a2_0xedeb('0x27')])return![];const _0x27c9ae=Promise[a2_0xedeb('0x1e')]()['then'](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x50b1d9;const _0x33bcae=yield this[a2_0xedeb('0x2d')](_0x1318db);if(!_0x33bcae)return![];if(!_0x33bcae['put']){if(environment_1[a2_0xedeb('0x2')]){output_1['output'][a2_0xedeb('0x21')]({'title':a2_0xedeb('0x3')+_0x1318db+a2_0xedeb('0x4')});}return!![];}try{yield this[a2_0xedeb('0x29')][a2_0xedeb('0xf')](_0x1318db,_0x33bcae['put'],_0x45ddd1);return!![];}catch(_0x314f5b){const _0x35186b=(_0x50b1d9=_0x314f5b['axiosException'])!==null&&_0x50b1d9!==void 0x0?_0x50b1d9:_0x314f5b;this[a2_0xedeb('0x18')][a2_0xedeb('0x27')]=this['messages'][a2_0xedeb('0x1a')](_0x35186b,'storage');return![];}}));this[a2_0xedeb('0x6')]['push'](_0x27c9ae);return _0x27c9ae;});}[a2_0xedeb('0x2d')](_0x5e86ea){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x5e86ea in this['runContext'][a2_0xedeb('0x20')]){return(yield this['runContext']['requests'][_0x5e86ea])[_0x5e86ea];}else{const _0x3e8ce6=this[a2_0xedeb('0x9')][a2_0xedeb('0x5')]['filter'](_0x147497=>!this[a2_0xedeb('0x9')]['requests'][_0x147497['hash']])[a2_0xedeb('0x28')](_0x102674=>_0x102674[a2_0xedeb('0x2b')]);if(_0x3e8ce6[a2_0xedeb('0x19')](_0x5e86ea)===-0x1){_0x3e8ce6[a2_0xedeb('0x1c')](_0x5e86ea);}const _0x499bd8=this['api'][a2_0xedeb('0x1')](environment_1[a2_0xedeb('0x17')],_0x3e8ce6);_0x3e8ce6['forEach'](_0x2fa256=>{this[a2_0xedeb('0x9')][a2_0xedeb('0x20')][_0x2fa256]=_0x499bd8;});return(yield _0x499bd8)[_0x5e86ea];}});}[a2_0xedeb('0xa')](){return Promise[a2_0xedeb('0xb')](this[a2_0xedeb('0x6')])[a2_0xedeb('0xc')](_0x408319=>_0x408319[a2_0xedeb('0x2e')]((_0x94c8d2,_0x1b0fdd)=>_0x94c8d2&&_0x1b0fdd,!![]));}}exports[a2_0xedeb('0x14')]=CloudRemoteCache;
|