Socket
Socket
Sign inDemoInstall

nx-cloud

Package Overview
Dependencies
Maintainers
2
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nx-cloud - npm Package Compare versions

Comparing version 16.3.0-beta.10 to 16.3.0

37

lib/core/api/error-reporter.api.js

@@ -1,36 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorReporterApi = void 0;
const axios_1 = require("../../utilities/axios");
const { output } = require('../../utilities/nx-imports-light');
class ErrorReporterApi {
constructor(options) {
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
reportError(message) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', {
message,
}));
}
catch (e) {
output.warn({
title: `Unable to record the following error: '${message}'`,
bodyLines: [e.message],
});
}
});
}
}
exports.ErrorReporterApi = ErrorReporterApi;
//# sourceMappingURL=error-reporter.api.js.map
const a0_0x3ad2=['Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','warn','apply','reportError','__awaiter','__esModule','post','apiAxiosInstance','next','../../utilities/nx-imports-light','value','message','done','createApiAxiosInstance','/nx-cloud/report-client-error','axiosMultipleTries','ErrorReporterApi','defineProperty'];(function(_0x35707e,_0x3ad201){const _0x5dfe86=function(_0x23ea7f){while(--_0x23ea7f){_0x35707e['push'](_0x35707e['shift']());}};_0x5dfe86(++_0x3ad201);}(a0_0x3ad2,0x144));const a0_0x5dfe=function(_0x35707e,_0x3ad201){_0x35707e=_0x35707e-0x0;let _0x5dfe86=a0_0x3ad2[_0x35707e];return _0x5dfe86;};'use strict';var __awaiter=this&&this[a0_0x5dfe('0x4')]||function(_0x5804ca,_0x17ba92,_0x44556b,_0x15535d){function _0x5d75d3(_0x1ec40a){return _0x1ec40a instanceof _0x44556b?_0x1ec40a:new _0x44556b(function(_0x5e5f67){_0x5e5f67(_0x1ec40a);});}return new(_0x44556b||(_0x44556b=Promise))(function(_0x242fa7,_0x4bdeca){function _0x30561b(_0x45a5a8){try{_0x4b71e1(_0x15535d[a0_0x5dfe('0x8')](_0x45a5a8));}catch(_0x1c86c4){_0x4bdeca(_0x1c86c4);}}function _0x3aac8f(_0x260068){try{_0x4b71e1(_0x15535d['throw'](_0x260068));}catch(_0x306b57){_0x4bdeca(_0x306b57);}}function _0x4b71e1(_0x123f4b){_0x123f4b[a0_0x5dfe('0xc')]?_0x242fa7(_0x123f4b[a0_0x5dfe('0xa')]):_0x5d75d3(_0x123f4b[a0_0x5dfe('0xa')])['then'](_0x30561b,_0x3aac8f);}_0x4b71e1((_0x15535d=_0x15535d[a0_0x5dfe('0x2')](_0x5804ca,_0x17ba92||[]))[a0_0x5dfe('0x8')]());});};Object[a0_0x5dfe('0x11')](exports,a0_0x5dfe('0x5'),{'value':!![]});exports[a0_0x5dfe('0x10')]=void 0x0;const axios_1=require('../../utilities/axios');const {output}=require(a0_0x5dfe('0x9'));class ErrorReporterApi{constructor(_0x5c1e74){this[a0_0x5dfe('0x7')]=(0x0,axios_1[a0_0x5dfe('0xd')])(_0x5c1e74);}[a0_0x5dfe('0x3')](_0xbbd030){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x5dfe('0xf')])(()=>this[a0_0x5dfe('0x7')][a0_0x5dfe('0x6')](a0_0x5dfe('0xe'),{'message':_0xbbd030}));}catch(_0xc9b13d){output[a0_0x5dfe('0x1')]({'title':a0_0x5dfe('0x0')+_0xbbd030+'\x27','bodyLines':[_0xc9b13d[a0_0x5dfe('0xb')]]});}});}}exports[a0_0x5dfe('0x10')]=ErrorReporterApi;

@@ -1,74 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunGroupApi = void 0;
const axios_1 = require("../../utilities/axios");
const metric_logger_1 = require("../../utilities/metric-logger");
const { output } = require('../../utilities/nx-imports-light');
class RunGroupApi {
constructor(options) {
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
createRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv, stopAgentsOnFailure, agentCount, stopAgentsAfter, commitSha, commitRef) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
try {
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
branch,
runGroup,
ciExecutionId,
ciExecutionEnv,
stopAgentsOnFailure,
agentCount,
stopAgentsAfter,
commitSha,
}));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
output.error({
title: e.message,
});
process.exit(1);
}
});
}
completeRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
try {
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
branch,
runGroup,
ciExecutionId,
ciExecutionEnv,
}));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
output.error({
title: e.message,
});
process.exit(1);
}
});
}
}
exports.RunGroupApi = RunGroupApi;
//# sourceMappingURL=run-group.api.js.map
const a1_0x8e7c=['createApiAxiosInstance','post','response','exit','next','__awaiter','mapRespToPerfEntry','/nx-cloud/executions/complete-run-group','createMetricRecorder','message','RunGroupApi','RUNNER_FAILURE_PERF_ENTRY','../../utilities/nx-imports-light','/nx-cloud/executions/create-run-group','error','value','createRunGroup','throw','axiosMultipleTries','__esModule','completeRunGroup','then','defineProperty','recordMetric','apiAxiosInstance','axiosException'];(function(_0x12a493,_0x8e7cb0){const _0x7cfee7=function(_0x139a88){while(--_0x139a88){_0x12a493['push'](_0x12a493['shift']());}};_0x7cfee7(++_0x8e7cb0);}(a1_0x8e7c,0xb2));const a1_0x7cfe=function(_0x12a493,_0x8e7cb0){_0x12a493=_0x12a493-0x0;let _0x7cfee7=a1_0x8e7c[_0x12a493];return _0x7cfee7;};'use strict';var __awaiter=this&&this[a1_0x7cfe('0x9')]||function(_0x5513d8,_0x51409d,_0xa0551,_0x424767){function _0x26c4b4(_0x3494d4){return _0x3494d4 instanceof _0xa0551?_0x3494d4:new _0xa0551(function(_0x4bef66){_0x4bef66(_0x3494d4);});}return new(_0xa0551||(_0xa0551=Promise))(function(_0x15948f,_0x521351){function _0x3674ba(_0x3ce40c){try{_0x30d981(_0x424767[a1_0x7cfe('0x8')](_0x3ce40c));}catch(_0x3982a1){_0x521351(_0x3982a1);}}function _0x1c7254(_0x4bc3ce){try{_0x30d981(_0x424767[a1_0x7cfe('0x15')](_0x4bc3ce));}catch(_0x3bfa02){_0x521351(_0x3bfa02);}}function _0x30d981(_0x254ad8){_0x254ad8['done']?_0x15948f(_0x254ad8[a1_0x7cfe('0x13')]):_0x26c4b4(_0x254ad8[a1_0x7cfe('0x13')])[a1_0x7cfe('0x19')](_0x3674ba,_0x1c7254);}_0x30d981((_0x424767=_0x424767['apply'](_0x5513d8,_0x51409d||[]))[a1_0x7cfe('0x8')]());});};Object[a1_0x7cfe('0x0')](exports,a1_0x7cfe('0x17'),{'value':!![]});exports[a1_0x7cfe('0xe')]=void 0x0;const axios_1=require('../../utilities/axios');const metric_logger_1=require('../../utilities/metric-logger');const {output}=require(a1_0x7cfe('0x10'));class RunGroupApi{constructor(_0x33a8b1){this[a1_0x7cfe('0x2')]=(0x0,axios_1[a1_0x7cfe('0x4')])(_0x33a8b1);}[a1_0x7cfe('0x14')](_0x433c1b,_0x2733a4,_0xbaec0,_0x5d7ca7,_0x275fbc,_0x8bee52,_0x4a54f8,_0x411b4f,_0x19513b){var _0x362f09;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x196454=(0x0,metric_logger_1[a1_0x7cfe('0xc')])(a1_0x7cfe('0x14'));try{const _0x21b376=yield(0x0,axios_1[a1_0x7cfe('0x16')])(()=>this[a1_0x7cfe('0x2')][a1_0x7cfe('0x5')](a1_0x7cfe('0x11'),{'branch':_0x433c1b,'runGroup':_0x2733a4,'ciExecutionId':_0xbaec0,'ciExecutionEnv':_0x5d7ca7,'stopAgentsOnFailure':_0x275fbc,'agentCount':_0x8bee52,'stopAgentsAfter':_0x4a54f8,'commitSha':_0x411b4f}));_0x196454[a1_0x7cfe('0x1')]((0x0,metric_logger_1[a1_0x7cfe('0xa')])(_0x21b376));}catch(_0x2fc28d){_0x196454['recordMetric'](((_0x362f09=_0x2fc28d===null||_0x2fc28d===void 0x0?void 0x0:_0x2fc28d[a1_0x7cfe('0x3')])===null||_0x362f09===void 0x0?void 0x0:_0x362f09[a1_0x7cfe('0x6')])?(0x0,metric_logger_1[a1_0x7cfe('0xa')])(_0x2fc28d['axiosException'][a1_0x7cfe('0x6')]):metric_logger_1[a1_0x7cfe('0xf')]);output[a1_0x7cfe('0x12')]({'title':_0x2fc28d[a1_0x7cfe('0xd')]});process[a1_0x7cfe('0x7')](0x1);}});}[a1_0x7cfe('0x18')](_0x4c69c3,_0x4cbb8b,_0x1c94db,_0x1db02f){var _0x2f3391;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x59281b=(0x0,metric_logger_1[a1_0x7cfe('0xc')])(a1_0x7cfe('0x18'));try{const _0x5c8f32=yield(0x0,axios_1[a1_0x7cfe('0x16')])(()=>this[a1_0x7cfe('0x2')]['post'](a1_0x7cfe('0xb'),{'branch':_0x4c69c3,'runGroup':_0x4cbb8b,'ciExecutionId':_0x1c94db,'ciExecutionEnv':_0x1db02f}));_0x59281b['recordMetric']((0x0,metric_logger_1[a1_0x7cfe('0xa')])(_0x5c8f32));}catch(_0x524536){_0x59281b[a1_0x7cfe('0x1')](((_0x2f3391=_0x524536===null||_0x524536===void 0x0?void 0x0:_0x524536[a1_0x7cfe('0x3')])===null||_0x2f3391===void 0x0?void 0x0:_0x2f3391['response'])?(0x0,metric_logger_1[a1_0x7cfe('0xa')])(_0x524536[a1_0x7cfe('0x3')][a1_0x7cfe('0x6')]):metric_logger_1[a1_0x7cfe('0xf')]);output['error']({'title':_0x524536[a1_0x7cfe('0xd')]});process[a1_0x7cfe('0x7')](0x1);}});}}exports[a1_0x7cfe('0xe')]=RunGroupApi;

@@ -1,93 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudEnabledLifeCycle = void 0;
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
const read_task_terminal_output_1 = require("../../terminal-output/read-task-terminal-output");
class CloudEnabledLifeCycle {
constructor(runContext, cacheDirectory, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
this.runContext = runContext;
this.cacheDirectory = cacheDirectory;
this.collectTerminalOutput = collectTerminalOutput;
this.cacheableOperations = cacheableOperations;
this.outputObfuscator = outputObfuscator;
this.tasks = tasks;
}
scheduleTask(task) {
this.runContext.scheduledTasks.push(task);
}
// this gets called for every tasks that starts.
startTask(task) {
this.tasks.push({
taskId: task.id,
startTime: new Date().toISOString(),
target: task.target.target,
projectName: task.target.project,
hash: task.hash,
hashDetails: this.cleanUpHashDetails(task.hashDetails),
params: (0, serializer_overrides_1.serializeOverrides)(task),
uploadedToStorage: false,
});
}
endTasks(tasks) {
// this can be called multiple times changing this time.
for (let t of tasks) {
let cacheStatus;
const taskIsRemoteCacheHit = t.status === 'remote-cache';
const taskIsLocalCacheHitPreNx135 = t.status === 'cache';
const taskIsLocalCacheHit = t.status === 'local-cache' ||
t.status === 'local-cache-kept-existing' ||
taskIsLocalCacheHitPreNx135;
if (this.runContext.statuses[t.task.hash]) {
cacheStatus = this.runContext.statuses[t.task.hash];
}
else if (taskIsRemoteCacheHit) {
cacheStatus = 'remote-cache-hit';
}
else if (taskIsLocalCacheHit) {
cacheStatus = 'local-cache-hit';
}
else {
cacheStatus = 'cache-miss';
}
this.updateStartedTask(t, cacheStatus);
}
}
endCommand() { }
updateStartedTask(result, cacheStatus) {
const startedTask = this.tasks.find((t) => t.taskId === result.task.id);
if (!startedTask) {
throw new Error(`Cannot find task ${result.task.id}`);
}
if ((result === null || result === void 0 ? void 0 : result.startTime) && (result === null || result === void 0 ? void 0 : result.endTime)) {
startedTask.startTime = new Date(result.startTime).toISOString();
startedTask.endTime = new Date(result.endTime).toISOString();
}
else {
startedTask.endTime = new Date().toISOString();
}
startedTask.status = result.code;
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
startedTask.cacheStatus = cacheStatus;
if (this.collectTerminalOutput) {
startedTask.terminalOutput = this.getTerminalOutput(result.task.hash, startedTask.cacheStatus, result.code);
}
}
getTerminalOutput(hash, cacheStatus, code) {
return (0, read_task_terminal_output_1.readTaskTerminalOutput)(this.cacheDirectory, this.outputObfuscator, hash, cacheStatus, code);
}
cleanUpHashDetails(hashDetails) {
const nodes = {};
Object.keys(hashDetails.nodes)
.filter((k) => !k.startsWith('npm:'))
.forEach((k) => {
nodes[k] = hashDetails.nodes[k];
});
return {
nodes,
runtime: hashDetails.runtime,
implicitDeps: hashDetails.implicitDeps,
};
}
}
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
const a0_0x40dc=['readTaskTerminalOutput','task','outputObfuscator','filter','remote-cache-hit','cache','../../../utilities/serializer-overrides','CloudEnabledLifeCycle','hash','remote-cache','startTime','cleanUpHashDetails','code','toISOString','statuses','project','updateStartedTask','forEach','__esModule','cacheableOperations','npm:','defineProperty','endTime','startsWith','push','implicitDeps','runContext','scheduleTask','status','hashDetails','scheduledTasks','obfuscate','local-cache-hit','local-cache-kept-existing','startTask','find','tasks','params','keys','cacheDirectory','nodes','taskId','terminalOutput','target','cache-miss','getTerminalOutput'];(function(_0x1d968c,_0x40dc40){const _0x2e60c7=function(_0x1bfde9){while(--_0x1bfde9){_0x1d968c['push'](_0x1d968c['shift']());}};_0x2e60c7(++_0x40dc40);}(a0_0x40dc,0xe0));const a0_0x2e60=function(_0x1d968c,_0x40dc40){_0x1d968c=_0x1d968c-0x0;let _0x2e60c7=a0_0x40dc[_0x1d968c];return _0x2e60c7;};'use strict';Object[a0_0x2e60('0x1b')](exports,a0_0x2e60('0x18'),{'value':!![]});exports[a0_0x2e60('0xd')]=void 0x0;const serializer_overrides_1=require(a0_0x2e60('0xc'));const read_task_terminal_output_1=require('../../terminal-output/read-task-terminal-output');class CloudEnabledLifeCycle{constructor(_0xd228c9,_0x1b0403,_0xcecb42,_0x5157b5,_0x54ecca,_0x379cd9){this[a0_0x2e60('0x20')]=_0xd228c9;this[a0_0x2e60('0x2d')]=_0x1b0403;this['collectTerminalOutput']=_0xcecb42;this[a0_0x2e60('0x19')]=_0x5157b5;this[a0_0x2e60('0x8')]=_0x54ecca;this[a0_0x2e60('0x2a')]=_0x379cd9;}[a0_0x2e60('0x21')](_0x17ff1d){this[a0_0x2e60('0x20')][a0_0x2e60('0x24')][a0_0x2e60('0x1e')](_0x17ff1d);}[a0_0x2e60('0x28')](_0x2e6a99){this['tasks'][a0_0x2e60('0x1e')]({'taskId':_0x2e6a99['id'],'startTime':new Date()[a0_0x2e60('0x13')](),'target':_0x2e6a99['target'][a0_0x2e60('0x3')],'projectName':_0x2e6a99[a0_0x2e60('0x3')][a0_0x2e60('0x15')],'hash':_0x2e6a99[a0_0x2e60('0xe')],'hashDetails':this['cleanUpHashDetails'](_0x2e6a99[a0_0x2e60('0x23')]),'params':(0x0,serializer_overrides_1['serializeOverrides'])(_0x2e6a99),'uploadedToStorage':![]});}['endTasks'](_0x38f526){for(let _0x51707f of _0x38f526){let _0x4de91f;const _0x22f157=_0x51707f['status']===a0_0x2e60('0xf');const _0x26c07f=_0x51707f[a0_0x2e60('0x22')]===a0_0x2e60('0xb');const _0x5c1e52=_0x51707f[a0_0x2e60('0x22')]==='local-cache'||_0x51707f[a0_0x2e60('0x22')]===a0_0x2e60('0x27')||_0x26c07f;if(this['runContext'][a0_0x2e60('0x14')][_0x51707f[a0_0x2e60('0x7')]['hash']]){_0x4de91f=this['runContext'][a0_0x2e60('0x14')][_0x51707f[a0_0x2e60('0x7')][a0_0x2e60('0xe')]];}else if(_0x22f157){_0x4de91f=a0_0x2e60('0xa');}else if(_0x5c1e52){_0x4de91f=a0_0x2e60('0x26');}else{_0x4de91f=a0_0x2e60('0x4');}this[a0_0x2e60('0x16')](_0x51707f,_0x4de91f);}}['endCommand'](){}[a0_0x2e60('0x16')](_0x3bc856,_0x5bbec1){const _0x1bb265=this[a0_0x2e60('0x2a')][a0_0x2e60('0x29')](_0x574270=>_0x574270[a0_0x2e60('0x1')]===_0x3bc856['task']['id']);if(!_0x1bb265){throw new Error('Cannot\x20find\x20task\x20'+_0x3bc856[a0_0x2e60('0x7')]['id']);}if((_0x3bc856===null||_0x3bc856===void 0x0?void 0x0:_0x3bc856[a0_0x2e60('0x10')])&&(_0x3bc856===null||_0x3bc856===void 0x0?void 0x0:_0x3bc856[a0_0x2e60('0x1c')])){_0x1bb265['startTime']=new Date(_0x3bc856[a0_0x2e60('0x10')])[a0_0x2e60('0x13')]();_0x1bb265[a0_0x2e60('0x1c')]=new Date(_0x3bc856['endTime'])[a0_0x2e60('0x13')]();}else{_0x1bb265[a0_0x2e60('0x1c')]=new Date()[a0_0x2e60('0x13')]();}_0x1bb265[a0_0x2e60('0x22')]=_0x3bc856[a0_0x2e60('0x12')];_0x1bb265[a0_0x2e60('0x2b')]=this[a0_0x2e60('0x8')][a0_0x2e60('0x25')](_0x1bb265[a0_0x2e60('0x2b')]);_0x1bb265['cacheStatus']=_0x5bbec1;if(this['collectTerminalOutput']){_0x1bb265[a0_0x2e60('0x2')]=this[a0_0x2e60('0x5')](_0x3bc856[a0_0x2e60('0x7')]['hash'],_0x1bb265['cacheStatus'],_0x3bc856['code']);}}[a0_0x2e60('0x5')](_0x38ee67,_0x33a7cc,_0x1751a9){return(0x0,read_task_terminal_output_1[a0_0x2e60('0x6')])(this[a0_0x2e60('0x2d')],this[a0_0x2e60('0x8')],_0x38ee67,_0x33a7cc,_0x1751a9);}[a0_0x2e60('0x11')](_0x1ffe50){const _0x18dee3={};Object[a0_0x2e60('0x2c')](_0x1ffe50[a0_0x2e60('0x0')])[a0_0x2e60('0x9')](_0x5e156c=>!_0x5e156c[a0_0x2e60('0x1d')](a0_0x2e60('0x1a')))[a0_0x2e60('0x17')](_0x5883ea=>{_0x18dee3[_0x5883ea]=_0x1ffe50[a0_0x2e60('0x0')][_0x5883ea];});return{'nodes':_0x18dee3,'runtime':_0x1ffe50['runtime'],'implicitDeps':_0x1ffe50[a0_0x2e60('0x1f')]};}}exports[a0_0x2e60('0xd')]=CloudEnabledLifeCycle;

@@ -1,321 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloudEnabledTasksRunner = void 0;
const message_reporter_1 = require("../../terminal-output/message-reporter");
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
const file_storage_1 = require("../../file-storage/file-storage");
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
const environment_1 = require("../../../utilities/environment");
const cloud_remote_cache_1 = require("./cloud-remote-cache");
const cloud_run_api_1 = require("./cloud-run.api");
const fs_1 = require("fs");
const path = require("path");
const path_1 = require("path");
const metric_logger_1 = require("../../../utilities/metric-logger");
const error_reporter_api_1 = require("../../api/error-reporter.api");
const fs_extra_1 = require("fs-extra");
const id_generator_1 = require("./id-generator");
const remove_trailing_slash_1 = require("../../../utilities/remove-trailing-slash");
const { output } = require('../../../utilities/nx-imports-light');
const { tasksRunner, cacheDirectory, } = require('../../../utilities/nx-imports');
function createApi(errors, options, runContext) {
const machineInfo = (0, environment_1.getMachineInfo)();
return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
}
function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
const hashes = JSON.stringify(taskExecutions.map((t) => ({
taskId: t.taskId,
hash: t.hash,
})));
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Executed tasks with hashes: ${hashes}`,
});
}
(0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
}
/*
* It can happen that a task is executed multiple times on an agent, say for DTE1 and DTE2.
* When it runs for DTE2, it will be a local cache hit, so it will be marked as completed.
* However, Nx won't upload an artifact to S3 in this case. Usually this isn't a problem,
* cause the first DTE would have uploaded it. But if you are using a DTE, with a read-only token,
* the uploaded artifact will have a different scoped hash.
*
* To address this: we are finding all local cache hits, and upload everything that has a put url.
*/
function storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory) {
const hashes = taskExecutions
.filter((t) => t.cacheStatus === 'local-cache-hit')
.map((t) => t.hash);
hashes.forEach((hash) => remoteCache.store(hash, nxCacheDirectory));
}
function onComplete({ daemon, options, fileStorage, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner, encryptionKey, storeInCurrentProcess, distributedExecutionId, runContext, }) {
return __awaiter(this, void 0, void 0, function* () {
const runEndTime = new Date().toISOString();
const branch = (0, environment_1.getBranch)();
const runData = {
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
startTime: runStartTime,
endTime: runEndTime,
distributedExecutionId,
branch: branch,
runGroup: (0, environment_1.getRunGroup)(),
// only set sha if branch is set because we invoke a separate process,
// which adds a few millis
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
inner: inner,
};
const ciExecutionContext = {
branch: branch,
runGroup: (0, environment_1.getRunGroup)(),
ciExecutionId: (0, environment_1.getCIExecutionId)(),
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
};
if (storeInCurrentProcess) {
if ((0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
storeTaskHashes(taskExecutions, cacheDirectory, distributedExecutionId);
storeLocalCacheHits(taskExecutions, remoteCache, cacheDirectory);
}
try {
yield remoteCache.waitForStoreRequestsToComplete();
}
catch (e) {
output.error({
title: `Nx Cloud wasn't able to store artifacts.`,
});
messages.printMessages();
return false;
}
for (const hash of fileStorage.storedHashes) {
const matchingTask = taskExecutions.find((t) => t.hash === hash);
if (!matchingTask) {
throw new Error(`Task with hash ${hash} isn't recorded`);
}
matchingTask.uploadedToStorage = true;
}
try {
yield api.endRun(runData, taskExecutions, ciExecutionContext);
}
catch (e) {
output.error({
title: `Nx Cloud wasn't able to record its run.`,
});
messages.printMessages();
return false;
}
yield (0, metric_logger_1.submitRunMetrics)(options);
}
else {
try {
const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken;
const linkId = (0, id_generator_1.generateUniqueLinkId)();
const processRunEndFullPath = require.resolve('nx-cloud/lib/daemon/process-run-end');
yield daemon.processInBackground(processRunEndFullPath, {
encryptionKey,
runnerOptions: Object.assign(Object.assign({}, options), { accessToken }),
delayedStoreRequests: remoteCache.delayedStoreRequests,
ciExecutionContext,
runEnd: {
runData,
taskExecutions,
linkId,
},
});
runContext.runUrl = `${(0, remove_trailing_slash_1.removeTrailingSlash)(options.url || 'https://nx.app')}/runs/${linkId}`;
}
catch (e) {
output.warn({
title: `Nx Cloud Problems`,
bodyLines: [e.message || e.toString()],
});
return false;
}
}
// this workaround is required because prior to Nx 13.3 we printed
// the end message after the runner completes, so we need to wait for the
// message to appear in the right place
if (versionOfNxBefore133) {
setTimeout(() => {
messages.printMessages();
if (!messages.anyErrors && !inner) {
endOfRunMessage.printCacheHitsMessage();
}
}, 0);
}
else {
messages.printMessages();
if (!messages.anyErrors && !inner) {
endOfRunMessage.printCacheHitsMessage();
}
}
return true;
});
}
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, cacheDirectory, true, options.cacheableOperations || [], outputObfuscator, tasks);
try {
const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
if (!CompositeLifeCycle)
return cloudEnabledLifeCycle;
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
}
catch (e) {
return cloudEnabledLifeCycle;
}
}
function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId) {
return __awaiter(this, void 0, void 0, function* () {
if (options.skipNxCache)
return;
let hashes = tasks.map((t) => t.hash).filter((h) => !!h);
// filter out the urls that don't have artifact stored locally
const exists = yield Promise.all(hashes.map((hash) => {
const tdCommit = (0, path_1.join)(cacheDirectory, `${hash}.commit`);
return (0, fs_extra_1.pathExists)(tdCommit);
}));
const missingHashes = [];
for (let i = 0; i < exists.length; ++i) {
if (!exists[i]) {
missingHashes.push(hashes[i]);
}
}
if (missingHashes.length > 0) {
const startRunRequest = api.startRun(distributedExecutionId, missingHashes);
for (const hash of missingHashes) {
runContext.requests[hash] = startRunRequest;
}
}
});
}
function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
var _a;
const distributedExecutionId = process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
const runContext = {
statuses: {},
scheduledTasks: [],
requests: {},
allTasks: tasks,
};
const versionOfNxBefore133 = options.lifeCycle === undefined;
const taskExecutions = [];
const messages = new message_reporter_1.MessageReporter(options);
const api = createApi(messages, options, runContext);
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions, distributedExecutionId);
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
const runStartTime = new Date().toISOString();
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
const encryptionKey = environment_1.ENCRYPTION_KEY || options.encryptionKey;
const encryption = new e2e_encryption_1.E2EEncryption(encryptionKey);
const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
const storeInCurrentProcess = (0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId) ||
!((_a = context.daemon) === null || _a === void 0 ? void 0 : _a.enabled());
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, options, 'cloud-enabled-runner');
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess);
// we don't await for it cause this step is optional
fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId);
// have to reset it so we don't capture inner tasks
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
// observable -> legacy
if (res.subscribe) {
const { Subject } = require('rxjs/internal/Subject');
const wrappedRes = new Subject();
res.subscribe({
next: (value) => wrappedRes.next(value),
error: (err) => wrappedRes.error(err),
complete: () => __awaiter(this, void 0, void 0, function* () {
const success = yield onComplete({
daemon: context.daemon,
options,
fileStorage,
remoteCache,
api,
outputObfuscator,
runStartTime,
messages,
endOfRunMessage,
taskExecutions,
versionOfNxBefore133,
inner,
encryptionKey,
storeInCurrentProcess,
runContext,
distributedExecutionId,
});
if (!success &&
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
wrappedRes.complete();
}),
});
return wrappedRes;
// promise
}
else {
return res
.then((r) => __awaiter(this, void 0, void 0, function* () {
const success = yield onComplete({
daemon: context.daemon,
options,
fileStorage,
remoteCache,
api,
outputObfuscator,
runStartTime,
messages,
endOfRunMessage,
taskExecutions,
versionOfNxBefore133,
inner,
encryptionKey,
storeInCurrentProcess,
runContext,
distributedExecutionId,
});
if (!success &&
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
return r;
}))
.catch((e) => __awaiter(this, void 0, void 0, function* () {
const success = yield onComplete({
daemon: context.daemon,
options,
fileStorage,
remoteCache,
api,
outputObfuscator,
runStartTime,
messages,
endOfRunMessage,
taskExecutions,
versionOfNxBefore133,
inner,
encryptionKey,
storeInCurrentProcess,
runContext,
distributedExecutionId,
});
if (!success &&
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
throw e;
}));
}
}
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
//# sourceMappingURL=cloud-enabled.runner.js.map
const a1_0x40ce=['uploadedToStorage','nx-cloud/lib/daemon/process-run-end','exit','resolve','rxjs/internal/Subject','../../terminal-output/message-reporter','printMessages','https://nx.app','value','writeFileSync','../../../utilities/environment','ACCESS_TOKEN','catch','note','__awaiter','FileStorage','cacheStatus','filter','url','subscribe','MessageReporter','throw','../../../utilities/metric-logger','submitRunMetrics','forEach','apply','join','./cloud-enabled-life-cycle','lifeCycle','runUrl','removeTrailingSlash','../../../utilities/nx-imports-light','local-cache-hit','\x20isn\x27t\x20recorded','encryptionKey','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','VERBOSE_LOGGING','CloudEnabledLifeCycle','error','waitForStoreRequestsToComplete','map','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','getCIExecutionId','anyErrors','ErrorReporterApi','getBranch','./cloud-remote-cache','Executed\x20tasks\x20with\x20hashes:\x20','endRun','ENCRYPTION_KEY','cacheableOperations','../../terminal-output/end-of-run-message','delayedStoreRequests','__esModule','EndOfRunMessage','../../terminal-output/output-obfuscator','accessToken','defineProperty','all','getRunGroup','fs-extra','toString','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','length','skipNxCache','warn','parseCommand','getCIExecutionEnv','path','maskedProperties','CloudRemoteCache','pathExists','../../api/error-reporter.api','toISOString','hash','find','enabled','store','cloud-enabled-runner','./id-generator','cloudEnabledTasksRunner','tasks-hashes-','E2EEncryption','daemon','next','env','storedHashes','extractGitSha','printCacheHitsMessage','../../../utilities/remove-trailing-slash','complete','processInBackground','assign','agentRunningInDistributedExecution','requests','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','getMachineInfo'];(function(_0x3b9822,_0x40ce92){const _0x3221e1=function(_0x2d8151){while(--_0x2d8151){_0x3b9822['push'](_0x3b9822['shift']());}};_0x3221e1(++_0x40ce92);}(a1_0x40ce,0x73));const a1_0x3221=function(_0x3b9822,_0x40ce92){_0x3b9822=_0x3b9822-0x0;let _0x3221e1=a1_0x40ce[_0x3b9822];return _0x3221e1;};'use strict';var __awaiter=this&&this[a1_0x3221('0x5d')]||function(_0x5c87ed,_0x35c33f,_0x4ef2f1,_0x3a250c){function _0x4e37bd(_0x34f308){return _0x34f308 instanceof _0x4ef2f1?_0x34f308:new _0x4ef2f1(function(_0x1fbe75){_0x1fbe75(_0x34f308);});}return new(_0x4ef2f1||(_0x4ef2f1=Promise))(function(_0x27b509,_0x2faf7c){function _0x448672(_0x187a83){try{_0x2fd4de(_0x3a250c['next'](_0x187a83));}catch(_0x2d1f0f){_0x2faf7c(_0x2d1f0f);}}function _0x39f5ba(_0x279d6b){try{_0x2fd4de(_0x3a250c[a1_0x3221('0x3')](_0x279d6b));}catch(_0x2c2162){_0x2faf7c(_0x2c2162);}}function _0x2fd4de(_0x3ea5c1){_0x3ea5c1['done']?_0x27b509(_0x3ea5c1[a1_0x3221('0x57')]):_0x4e37bd(_0x3ea5c1[a1_0x3221('0x57')])['then'](_0x448672,_0x39f5ba);}_0x2fd4de((_0x3a250c=_0x3a250c[a1_0x3221('0x7')](_0x5c87ed,_0x35c33f||[]))[a1_0x3221('0x42')]());});};Object[a1_0x3221('0x27')](exports,a1_0x3221('0x23'),{'value':!![]});exports[a1_0x3221('0x3e')]=void 0x0;const message_reporter_1=require(a1_0x3221('0x54'));const end_of_run_message_1=require(a1_0x3221('0x21'));const output_obfuscator_1=require(a1_0x3221('0x25'));const cloud_enabled_life_cycle_1=require(a1_0x3221('0x9'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require('../../file-storage/e2e-encryption');const environment_1=require(a1_0x3221('0x59'));const cloud_remote_cache_1=require(a1_0x3221('0x1c'));const cloud_run_api_1=require('./cloud-run.api');const fs_1=require('fs');const path=require('path');const path_1=require(a1_0x3221('0x32'));const metric_logger_1=require(a1_0x3221('0x4'));const error_reporter_api_1=require(a1_0x3221('0x36'));const fs_extra_1=require(a1_0x3221('0x2a'));const id_generator_1=require(a1_0x3221('0x3d'));const remove_trailing_slash_1=require(a1_0x3221('0x47'));const {output}=require(a1_0x3221('0xd'));const {tasksRunner,cacheDirectory}=require('../../../utilities/nx-imports');function createApi(_0x1d8d12,_0x4e023d,_0xbdfc84){const _0x53be0c=(0x0,environment_1[a1_0x3221('0x4e')])();return new cloud_run_api_1['CloudRunApi'](_0x1d8d12,_0xbdfc84,_0x4e023d,_0x53be0c);}function storeTaskHashes(_0x4446f9,_0x349ba1,_0x105679){const _0x1a0a07=JSON['stringify'](_0x4446f9[a1_0x3221('0x16')](_0x239eb6=>({'taskId':_0x239eb6['taskId'],'hash':_0x239eb6[a1_0x3221('0x38')]})));if(environment_1[a1_0x3221('0x12')]){output[a1_0x3221('0x5c')]({'title':a1_0x3221('0x1d')+_0x1a0a07});}(0x0,fs_1[a1_0x3221('0x58')])(path[a1_0x3221('0x8')](_0x349ba1,a1_0x3221('0x3f')+_0x105679),_0x1a0a07);}function storeLocalCacheHits(_0x487b0a,_0x1ff21f,_0x279ef9){const _0x7723e5=_0x487b0a[a1_0x3221('0x60')](_0x30cd7e=>_0x30cd7e[a1_0x3221('0x5f')]===a1_0x3221('0xe'))[a1_0x3221('0x16')](_0x1d5419=>_0x1d5419[a1_0x3221('0x38')]);_0x7723e5[a1_0x3221('0x6')](_0x16eba0=>_0x1ff21f[a1_0x3221('0x3b')](_0x16eba0,_0x279ef9));}function onComplete({daemon,options,fileStorage,remoteCache,api,outputObfuscator,runStartTime,messages,endOfRunMessage,taskExecutions,versionOfNxBefore133,inner,encryptionKey,storeInCurrentProcess,distributedExecutionId,runContext}){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5d0196=new Date()[a1_0x3221('0x37')]();const _0x53c320=(0x0,environment_1[a1_0x3221('0x1b')])();const _0x5d3567={'command':outputObfuscator['obfuscate']((0x0,environment_1[a1_0x3221('0x30')])()),'startTime':runStartTime,'endTime':_0x5d0196,'distributedExecutionId':distributedExecutionId,'branch':_0x53c320,'runGroup':(0x0,environment_1[a1_0x3221('0x29')])(),'sha':_0x53c320?(0x0,environment_1[a1_0x3221('0x45')])():undefined,'inner':inner};const _0x1de899={'branch':_0x53c320,'runGroup':(0x0,environment_1[a1_0x3221('0x29')])(),'ciExecutionId':(0x0,environment_1[a1_0x3221('0x18')])(),'ciExecutionEnv':(0x0,environment_1[a1_0x3221('0x31')])()};if(storeInCurrentProcess){if((0x0,environment_1['agentRunningInDistributedExecution'])(distributedExecutionId)){storeTaskHashes(taskExecutions,cacheDirectory,distributedExecutionId);storeLocalCacheHits(taskExecutions,remoteCache,cacheDirectory);}try{yield remoteCache[a1_0x3221('0x15')]();}catch(_0x41ea07){output[a1_0x3221('0x14')]({'title':a1_0x3221('0x11')});messages['printMessages']();return![];}for(const _0x295f6c of fileStorage[a1_0x3221('0x44')]){const _0x183001=taskExecutions[a1_0x3221('0x39')](_0xa5fb94=>_0xa5fb94['hash']===_0x295f6c);if(!_0x183001){throw new Error('Task\x20with\x20hash\x20'+_0x295f6c+a1_0x3221('0xf'));}_0x183001[a1_0x3221('0x4f')]=!![];}try{yield api[a1_0x3221('0x1e')](_0x5d3567,taskExecutions,_0x1de899);}catch(_0x4ab51c){output[a1_0x3221('0x14')]({'title':a1_0x3221('0x17')});messages[a1_0x3221('0x55')]();return![];}yield(0x0,metric_logger_1[a1_0x3221('0x5')])(options);}else{try{const _0x43ab29=environment_1[a1_0x3221('0x5a')]?environment_1[a1_0x3221('0x5a')]:options[a1_0x3221('0x26')];const _0x27b56f=(0x0,id_generator_1['generateUniqueLinkId'])();const _0x160e02=require[a1_0x3221('0x52')](a1_0x3221('0x50'));yield daemon[a1_0x3221('0x49')](_0x160e02,{'encryptionKey':encryptionKey,'runnerOptions':Object[a1_0x3221('0x4a')](Object[a1_0x3221('0x4a')]({},options),{'accessToken':_0x43ab29}),'delayedStoreRequests':remoteCache[a1_0x3221('0x22')],'ciExecutionContext':_0x1de899,'runEnd':{'runData':_0x5d3567,'taskExecutions':taskExecutions,'linkId':_0x27b56f}});runContext[a1_0x3221('0xb')]=(0x0,remove_trailing_slash_1[a1_0x3221('0xc')])(options[a1_0x3221('0x0')]||a1_0x3221('0x56'))+'/runs/'+_0x27b56f;}catch(_0x11ad66){output[a1_0x3221('0x2f')]({'title':'Nx\x20Cloud\x20Problems','bodyLines':[_0x11ad66['message']||_0x11ad66[a1_0x3221('0x2b')]()]});return![];}}if(versionOfNxBefore133){setTimeout(()=>{messages[a1_0x3221('0x55')]();if(!messages[a1_0x3221('0x19')]&&!inner){endOfRunMessage[a1_0x3221('0x46')]();}},0x0);}else{messages['printMessages']();if(!messages[a1_0x3221('0x19')]&&!inner){endOfRunMessage[a1_0x3221('0x46')]();}}return!![];});}function createLifeCycle(_0x360aa7,_0x29485f,_0x337ccd,_0x27eb2d){const _0x402b1d=new cloud_enabled_life_cycle_1[(a1_0x3221('0x13'))](_0x360aa7,cacheDirectory,!![],_0x29485f[a1_0x3221('0x20')]||[],_0x337ccd,_0x27eb2d);try{const {CompositeLifeCycle}=require('../../../utilities/nx-imports');if(!CompositeLifeCycle)return _0x402b1d;return new CompositeLifeCycle([_0x29485f[a1_0x3221('0xa')],_0x402b1d]);}catch(_0x19998e){return _0x402b1d;}}function fetchUrlsForKnownHashesUpfront(_0x1a22b9,_0x53d6bb,_0x4cd8a2,_0x518617,_0x21e613){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x518617[a1_0x3221('0x2e')])return;let _0x3f0341=_0x4cd8a2[a1_0x3221('0x16')](_0xca6eb8=>_0xca6eb8[a1_0x3221('0x38')])[a1_0x3221('0x60')](_0x1c0560=>!!_0x1c0560);const _0x592427=yield Promise[a1_0x3221('0x28')](_0x3f0341[a1_0x3221('0x16')](_0x12b411=>{const _0x4cc6c1=(0x0,path_1[a1_0x3221('0x8')])(cacheDirectory,_0x12b411+'.commit');return(0x0,fs_extra_1[a1_0x3221('0x35')])(_0x4cc6c1);}));const _0x5c995d=[];for(let _0x3af057=0x0;_0x3af057<_0x592427[a1_0x3221('0x2d')];++_0x3af057){if(!_0x592427[_0x3af057]){_0x5c995d['push'](_0x3f0341[_0x3af057]);}}if(_0x5c995d[a1_0x3221('0x2d')]>0x0){const _0x2397f=_0x1a22b9['startRun'](_0x21e613,_0x5c995d);for(const _0x3eb3be of _0x5c995d){_0x53d6bb[a1_0x3221('0x4c')][_0x3eb3be]=_0x2397f;}}});}function cloudEnabledTasksRunner(_0xb9ccd3,_0x14f338,_0x3fdbb6,_0x155b1d=![]){var _0x7db61f;const _0x2589b0=process[a1_0x3221('0x43')]['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'];const _0x2f67f2={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0xb9ccd3};const _0x3b5a9d=_0x14f338[a1_0x3221('0xa')]===undefined;const _0x2feb7e=[];const _0x49e5f6=new message_reporter_1[(a1_0x3221('0x2'))](_0x14f338);const _0x240e73=createApi(_0x49e5f6,_0x14f338,_0x2f67f2);const _0x293502=new end_of_run_message_1[(a1_0x3221('0x24'))](_0x2f67f2,_0x2feb7e,_0x2589b0);const _0x1d9384=new output_obfuscator_1['OutputObfuscator'](_0x14f338[a1_0x3221('0x33')]);const _0x324298=new Date()[a1_0x3221('0x37')]();const _0x5c5dac=createLifeCycle(_0x2f67f2,_0x14f338,_0x1d9384,_0x2feb7e);const _0x3285af=environment_1[a1_0x3221('0x1f')]||_0x14f338[a1_0x3221('0x10')];const _0x75e757=new e2e_encryption_1[(a1_0x3221('0x40'))](_0x3285af);const _0x5719b9=new error_reporter_api_1[(a1_0x3221('0x1a'))](_0x14f338);const _0x1a9d06=(0x0,environment_1['agentRunningInDistributedExecution'])(_0x2589b0)||!((_0x7db61f=_0x3fdbb6[a1_0x3221('0x41')])===null||_0x7db61f===void 0x0?void 0x0:_0x7db61f[a1_0x3221('0x3a')]());const _0x41ed98=new file_storage_1[(a1_0x3221('0x5e'))](_0x75e757,_0x5719b9,_0x14f338,a1_0x3221('0x3c'));const _0xe4b029=new cloud_remote_cache_1[(a1_0x3221('0x34'))](_0x49e5f6,_0x240e73,_0x2f67f2,_0x41ed98,_0x2589b0,_0x1a9d06);fetchUrlsForKnownHashesUpfront(_0x240e73,_0x2f67f2,_0xb9ccd3,_0x14f338,_0x2589b0);delete process['env'][a1_0x3221('0x2c')];const _0x5d7b9a=tasksRunner(_0xb9ccd3,Object[a1_0x3221('0x4a')](Object['assign']({},_0x14f338),{'remoteCache':_0xe4b029,'lifeCycle':_0x5c5dac}),_0x3fdbb6);if(_0x5d7b9a[a1_0x3221('0x1')]){const {Subject}=require(a1_0x3221('0x53'));const _0x140a74=new Subject();_0x5d7b9a[a1_0x3221('0x1')]({'next':_0x44cd5e=>_0x140a74[a1_0x3221('0x42')](_0x44cd5e),'error':_0x41fa40=>_0x140a74['error'](_0x41fa40),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x118b5a=yield onComplete({'daemon':_0x3fdbb6['daemon'],'options':_0x14f338,'fileStorage':_0x41ed98,'remoteCache':_0xe4b029,'api':_0x240e73,'outputObfuscator':_0x1d9384,'runStartTime':_0x324298,'messages':_0x49e5f6,'endOfRunMessage':_0x293502,'taskExecutions':_0x2feb7e,'versionOfNxBefore133':_0x3b5a9d,'inner':_0x155b1d,'encryptionKey':_0x3285af,'storeInCurrentProcess':_0x1a9d06,'runContext':_0x2f67f2,'distributedExecutionId':_0x2589b0});if(!_0x118b5a&&(0x0,environment_1[a1_0x3221('0x4b')])(_0x2589b0)){process[a1_0x3221('0x51')](environment_1[a1_0x3221('0x4d')]);}_0x140a74[a1_0x3221('0x48')]();})});return _0x140a74;}else{return _0x5d7b9a['then'](_0xf5a427=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x5b6724=yield onComplete({'daemon':_0x3fdbb6[a1_0x3221('0x41')],'options':_0x14f338,'fileStorage':_0x41ed98,'remoteCache':_0xe4b029,'api':_0x240e73,'outputObfuscator':_0x1d9384,'runStartTime':_0x324298,'messages':_0x49e5f6,'endOfRunMessage':_0x293502,'taskExecutions':_0x2feb7e,'versionOfNxBefore133':_0x3b5a9d,'inner':_0x155b1d,'encryptionKey':_0x3285af,'storeInCurrentProcess':_0x1a9d06,'runContext':_0x2f67f2,'distributedExecutionId':_0x2589b0});if(!_0x5b6724&&(0x0,environment_1[a1_0x3221('0x4b')])(_0x2589b0)){process[a1_0x3221('0x51')](environment_1[a1_0x3221('0x4d')]);}return _0xf5a427;}))[a1_0x3221('0x5b')](_0x4469c6=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x4a223e=yield onComplete({'daemon':_0x3fdbb6['daemon'],'options':_0x14f338,'fileStorage':_0x41ed98,'remoteCache':_0xe4b029,'api':_0x240e73,'outputObfuscator':_0x1d9384,'runStartTime':_0x324298,'messages':_0x49e5f6,'endOfRunMessage':_0x293502,'taskExecutions':_0x2feb7e,'versionOfNxBefore133':_0x3b5a9d,'inner':_0x155b1d,'encryptionKey':_0x3285af,'storeInCurrentProcess':_0x1a9d06,'runContext':_0x2f67f2,'distributedExecutionId':_0x2589b0});if(!_0x4a223e&&(0x0,environment_1[a1_0x3221('0x4b')])(_0x2589b0)){process[a1_0x3221('0x51')](environment_1[a1_0x3221('0x4d')]);}throw _0x4469c6;}));}}exports[a1_0x3221('0x3e')]=cloudEnabledTasksRunner;

@@ -1,133 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudRemoteCache = void 0;
const environment_1 = require("../../../utilities/environment");
const { output } = require('../../../utilities/nx-imports-light');
class CloudRemoteCache {
constructor(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess) {
this.messages = messages;
this.api = api;
this.runContext = runContext;
this.fileStorage = fileStorage;
this.distributedExecutionId = distributedExecutionId;
this.storeInCurrentProcess = storeInCurrentProcess;
this.storeRequests = [];
this.delayedStoreRequests = [];
}
retrieve(hash, cacheDirectory) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
if (this.messages.cacheError)
return false;
const hashUrls = yield this.hashUrls(hash);
if (!hashUrls || !hashUrls.get) {
if (environment_1.VERBOSE_LOGGING) {
output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
}
this.runContext.statuses[hash] = 'cache-miss';
return false;
}
try {
yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
this.runContext.statuses[hash] = 'remote-cache-hit';
return true;
}
catch (ee) {
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
// TODO: vsavkin remove this handling Oct 2023
// 404 indicates that something is broken, but older versions
// of the api can result in such errors
// we ignore them for now
if (e.response && e.response.status === 404) {
if (environment_1.VERBOSE_LOGGING) {
output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
}
// cache miss. print nothing
}
else {
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
}
this.runContext.statuses[hash] = 'cache-miss';
return false;
}
});
}
store(hash, cacheDirectory) {
return __awaiter(this, void 0, void 0, function* () {
if (this.messages.cacheError)
return false;
const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
var _a;
const hashUrls = yield this.hashUrls(hash);
if (!hashUrls)
return false;
if (!hashUrls.put) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Nx Cloud: Skipping storing ${hash}.`,
bodyLines: [
`There are several reasons why this can happen.`,
`Maybe you are using a read-only token or the artifact has already being uploaded.`,
],
});
}
return true;
}
if (!this.storeInCurrentProcess) {
this.delayedStoreRequests.push({ hash: hash, url: hashUrls.put });
return true;
}
try {
yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
return true;
}
catch (ee) {
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
return false;
}
}));
this.storeRequests.push(res);
return res;
});
}
hashUrls(hash) {
return __awaiter(this, void 0, void 0, function* () {
if (hash in this.runContext.requests) {
return (yield this.runContext.requests[hash])[hash];
}
else {
const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
.filter((t) => !this.runContext.requests[t.hash])
.map((t) => t.hash);
if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
scheduledTaskHashesWithoutRequests.push(hash);
}
const request = this.api.startRun(this.distributedExecutionId, scheduledTaskHashesWithoutRequests);
scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
this.runContext.requests[taskHash] = request;
});
return (yield request)[hash];
}
});
}
waitForStoreRequestsToComplete() {
return __awaiter(this, void 0, void 0, function* () {
const res = yield Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
if (!res) {
throw new Error(`Error when storing artifacts`);
}
});
}
}
exports.CloudRemoteCache = CloudRemoteCache;
//# sourceMappingURL=cloud-remote-cache.js.map
const a2_0x377c=['fileStorage','Nx\x20Cloud:\x20Skipping\x20storing\x20','../../../utilities/environment','push','get','delayedStoreRequests','retrieve','statuses','filter','indexOf','done','CloudRemoteCache','value','extractErrorMessage','next','reduce','../../../utilities/nx-imports-light','cacheError','Maybe\x20you\x20are\x20using\x20a\x20read-only\x20token\x20or\x20the\x20artifact\x20has\x20already\x20being\x20uploaded.','distributedExecutionId','resolve','api','cache-miss','response','storage','messages','throw','put','axiosException','__esModule','requests','VERBOSE_LOGGING','note','__awaiter','storeRequests','then','forEach','Nx\x20Cloud:\x20Cache\x20miss\x20','store','storeInCurrentProcess','remote-cache-hit','map','hashUrls','runContext','hash'];(function(_0x7f96d,_0x377c27){const _0x148702=function(_0x19eac2){while(--_0x19eac2){_0x7f96d['push'](_0x7f96d['shift']());}};_0x148702(++_0x377c27);}(a2_0x377c,0x66));const a2_0x1487=function(_0x7f96d,_0x377c27){_0x7f96d=_0x7f96d-0x0;let _0x148702=a2_0x377c[_0x7f96d];return _0x148702;};'use strict';var __awaiter=this&&this[a2_0x1487('0x15')]||function(_0x487d38,_0x4c4f0b,_0x3f255d,_0x5f238d){function _0x15be2b(_0x2369a4){return _0x2369a4 instanceof _0x3f255d?_0x2369a4:new _0x3f255d(function(_0x9b5c33){_0x9b5c33(_0x2369a4);});}return new(_0x3f255d||(_0x3f255d=Promise))(function(_0x22e016,_0x2b2aab){function _0x20500d(_0x2a73ad){try{_0x36f8cd(_0x5f238d[a2_0x1487('0x2')](_0x2a73ad));}catch(_0x31257b){_0x2b2aab(_0x31257b);}}function _0x4cbfc9(_0x34aa83){try{_0x36f8cd(_0x5f238d[a2_0x1487('0xe')](_0x34aa83));}catch(_0x1c9b91){_0x2b2aab(_0x1c9b91);}}function _0x36f8cd(_0x30635e){_0x30635e[a2_0x1487('0x2b')]?_0x22e016(_0x30635e[a2_0x1487('0x0')]):_0x15be2b(_0x30635e[a2_0x1487('0x0')])[a2_0x1487('0x17')](_0x20500d,_0x4cbfc9);}_0x36f8cd((_0x5f238d=_0x5f238d['apply'](_0x487d38,_0x4c4f0b||[]))['next']());});};Object['defineProperty'](exports,a2_0x1487('0x11'),{'value':!![]});exports['CloudRemoteCache']=void 0x0;const environment_1=require(a2_0x1487('0x23'));const {output}=require(a2_0x1487('0x4'));class CloudRemoteCache{constructor(_0x321475,_0x4a90d7,_0x41d167,_0x4c32b2,_0x302bb7,_0x1285b4){this[a2_0x1487('0xd')]=_0x321475;this[a2_0x1487('0x9')]=_0x4a90d7;this['runContext']=_0x41d167;this[a2_0x1487('0x21')]=_0x4c32b2;this[a2_0x1487('0x7')]=_0x302bb7;this[a2_0x1487('0x1b')]=_0x1285b4;this[a2_0x1487('0x16')]=[];this[a2_0x1487('0x26')]=[];}[a2_0x1487('0x27')](_0x4e7228,_0x2ef9e4){var _0x1eecc9;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a2_0x1487('0x5')])return![];const _0x5afab1=yield this[a2_0x1487('0x1e')](_0x4e7228);if(!_0x5afab1||!_0x5afab1['get']){if(environment_1[a2_0x1487('0x13')]){output[a2_0x1487('0x14')]({'title':a2_0x1487('0x19')+_0x4e7228+'.'});}this[a2_0x1487('0x1f')]['statuses'][_0x4e7228]=a2_0x1487('0xa');return![];}try{yield this[a2_0x1487('0x21')][a2_0x1487('0x27')](_0x4e7228,_0x5afab1[a2_0x1487('0x25')],_0x2ef9e4);this['runContext'][a2_0x1487('0x28')][_0x4e7228]=a2_0x1487('0x1c');return!![];}catch(_0x215b01){const _0x2e7f20=(_0x1eecc9=_0x215b01[a2_0x1487('0x10')])!==null&&_0x1eecc9!==void 0x0?_0x1eecc9:_0x215b01;if(_0x2e7f20['response']&&_0x2e7f20[a2_0x1487('0xb')]['status']===0x194){if(environment_1['VERBOSE_LOGGING']){output['note']({'title':'Nx\x20Cloud:\x20Cache\x20miss\x20'+_0x4e7228+'.\x20Status\x20404.'});}}else{this['messages'][a2_0x1487('0x5')]=this[a2_0x1487('0xd')][a2_0x1487('0x1')](_0x2e7f20,a2_0x1487('0xc'));}this[a2_0x1487('0x1f')][a2_0x1487('0x28')][_0x4e7228]='cache-miss';return![];}});}['store'](_0x12a3a2,_0xf68b6a){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x1487('0xd')][a2_0x1487('0x5')])return![];const _0x2256a0=Promise[a2_0x1487('0x8')]()[a2_0x1487('0x17')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x38495b;const _0x40e832=yield this['hashUrls'](_0x12a3a2);if(!_0x40e832)return![];if(!_0x40e832['put']){if(environment_1[a2_0x1487('0x13')]){output[a2_0x1487('0x14')]({'title':a2_0x1487('0x22')+_0x12a3a2+'.','bodyLines':['There\x20are\x20several\x20reasons\x20why\x20this\x20can\x20happen.',a2_0x1487('0x6')]});}return!![];}if(!this[a2_0x1487('0x1b')]){this[a2_0x1487('0x26')]['push']({'hash':_0x12a3a2,'url':_0x40e832[a2_0x1487('0xf')]});return!![];}try{yield this[a2_0x1487('0x21')][a2_0x1487('0x1a')](_0x12a3a2,_0x40e832['put'],_0xf68b6a);return!![];}catch(_0x484a66){const _0x394bee=(_0x38495b=_0x484a66[a2_0x1487('0x10')])!==null&&_0x38495b!==void 0x0?_0x38495b:_0x484a66;this[a2_0x1487('0xd')][a2_0x1487('0x5')]=this[a2_0x1487('0xd')]['extractErrorMessage'](_0x394bee,a2_0x1487('0xc'));return![];}}));this['storeRequests']['push'](_0x2256a0);return _0x2256a0;});}['hashUrls'](_0x1fcc0f){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x1fcc0f in this[a2_0x1487('0x1f')][a2_0x1487('0x12')]){return(yield this[a2_0x1487('0x1f')][a2_0x1487('0x12')][_0x1fcc0f])[_0x1fcc0f];}else{const _0x2e8e3c=this[a2_0x1487('0x1f')]['scheduledTasks'][a2_0x1487('0x29')](_0x528c90=>!this[a2_0x1487('0x1f')][a2_0x1487('0x12')][_0x528c90[a2_0x1487('0x20')]])[a2_0x1487('0x1d')](_0x6bef0c=>_0x6bef0c[a2_0x1487('0x20')]);if(_0x2e8e3c[a2_0x1487('0x2a')](_0x1fcc0f)===-0x1){_0x2e8e3c[a2_0x1487('0x24')](_0x1fcc0f);}const _0x517376=this[a2_0x1487('0x9')]['startRun'](this[a2_0x1487('0x7')],_0x2e8e3c);_0x2e8e3c[a2_0x1487('0x18')](_0x5740a3=>{this[a2_0x1487('0x1f')]['requests'][_0x5740a3]=_0x517376;});return(yield _0x517376)[_0x1fcc0f];}});}['waitForStoreRequestsToComplete'](){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2a31ad=yield Promise['all'](this['storeRequests'])[a2_0x1487('0x17')](_0x8b6ade=>_0x8b6ade[a2_0x1487('0x3')]((_0x27de5b,_0x1b6286)=>_0x27de5b&&_0x1b6286,!![]));if(!_0x2a31ad){throw new Error('Error\x20when\x20storing\x20artifacts');}});}}exports[a2_0x1487('0x2c')]=CloudRemoteCache;

@@ -1,174 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudRunApi = void 0;
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const fs_1 = require("fs");
const zlib_1 = require("zlib");
const util_1 = require("util");
const metric_logger_1 = require("../../../utilities/metric-logger");
const is_private_cloud_1 = require("../../../utilities/is-private-cloud");
const { output } = require('../../../utilities/nx-imports-light');
class CloudRunApi {
constructor(messages, runContext, options, machineInfo) {
this.messages = messages;
this.runContext = runContext;
this.machineInfo = machineInfo;
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
startRun(distributedExecutionId, hashes) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
// API is not working, don't make the end request
if (this.messages.apiError)
return {};
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
try {
const request = {
meta: {
nxCloudVersion: this.nxCloudVersion(),
},
branch: (0, environment_1.getBranch)(),
runGroup: (0, environment_1.getRunGroup)(),
ciExecutionId: (0, environment_1.getCIExecutionId)(),
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
distributedExecutionId,
hashes,
};
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'RunStart',
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
});
}
const resp = yield (0, axios_1.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request)));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
if (resp.data && resp.data.message) {
this.messages.message = resp.data.message;
}
if (!resp.data || !resp.data.urls) {
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
return {};
}
return resp.data.urls;
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
return {};
}
});
}
createReqBody(run, tasks, ciExecutionContext, linkId) {
if ((0, is_private_cloud_1.isConnectedToPrivateCloud)()) {
for (let t of tasks) {
delete t.uploadedToStorage;
}
}
const uncompressedReqBody = Object.assign(Object.assign({ meta: {
nxCloudVersion: this.nxCloudVersion(),
}, tasks,
run,
linkId }, ((0, is_private_cloud_1.isConnectedToPrivateCloud)() ? {} : ciExecutionContext)), { machineInfo: this.machineInfo });
return JSON.stringify(uncompressedReqBody);
}
endRun(run, tasks, ciExecutionContext, linkId) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
// API is not working, don't make the end request
if (this.messages.apiError)
return false;
let uncompressedBodyString = this.createReqBody(run, tasks, ciExecutionContext, linkId);
// if the req body is > 20mb, remove hashDetails
if (uncompressedBodyString.length > 20 * 1000 * 1000) {
uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))), ciExecutionContext, linkId);
}
const uncompressedBuffer = Buffer.from(uncompressedBodyString);
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
try {
if (environment_1.VERBOSE_LOGGING) {
const t = tasks.map((tt) => {
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
? `${tt.terminalOutput.slice(0, 20)}...`
: undefined });
});
output.note({
title: 'RunEnd. Completed tasks',
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
});
}
const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
})));
if (resp) {
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
this.runContext.runUrl = resp.data.runUrl;
return true;
}
if (resp.data && resp.data.status) {
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
}
else if (resp.data && typeof resp.data === 'string') {
if (resp.data !== 'success') {
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
}
}
else {
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
}
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Invalid end run response',
bodyLines: [JSON.stringify(resp.data, null, 2)],
});
}
}
else {
output.error({
title: 'Nx Cloud: Unknown Error Occurred',
bodyLines: [
'Run completion responded with `undefined`.',
'Run Details:',
JSON.stringify(run, null, 2),
'Stack Trace:',
JSON.stringify(new Error().stack, null, 2),
],
});
}
return false;
}
catch (ee) {
recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
return false;
}
});
}
nxCloudVersion() {
try {
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
return (v.devDependencies['nx-cloud'] || v.devDependencies['@nrwl/nx-cloud']);
}
catch (e) {
return 'unknown';
}
}
}
exports.CloudRunApi = CloudRunApi;
//# sourceMappingURL=cloud-run.api.js.map
const a3_0x1498=['../../../utilities/axios','headers','readFileSync','response','RunStart\x20duration','runUrl','getBranch','api','getRunGroup','error','package.json','RunEnd\x20duration','slice','extractErrorMessage','apiAxiosInstance','createReqBody','unknown','message','../../../utilities/environment','nx-cloud','from','printDuration','urls','mapRespToPerfEntry','stack','terminalOutput','Invalid\x20Nx\x20Cloud\x20response:\x20','data','isConnectedToPrivateCloud','apply','nxCloudVersion','success','getCIExecutionEnv','throw','next','status','stringify','defaults','Invalid\x20end\x20run\x20response','recordMetric','endRun','note','__awaiter','CloudRunApi','machineInfo','parse','/nx-cloud/runs/start','../../../utilities/nx-imports-light','apiError','assign','createMetricRecorder','map','devDependencies','Invalid\x20end\x20run\x20response:\x20','axiosException','zlib','toString','createApiAxiosInstance','done','then','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','post','VERBOSE_LOGGING','...','startRun','defineProperty','getCIExecutionId','messages','application/octet-stream','gzip','Run\x20Details:','util','Run\x20completion\x20responded\x20with\x20`undefined`.','runContext','__esModule','axiosMultipleTries','string'];(function(_0x1b6668,_0x1498d5){const _0x205c2d=function(_0x2581cd){while(--_0x2581cd){_0x1b6668['push'](_0x1b6668['shift']());}};_0x205c2d(++_0x1498d5);}(a3_0x1498,0xd7));const a3_0x205c=function(_0x1b6668,_0x1498d5){_0x1b6668=_0x1b6668-0x0;let _0x205c2d=a3_0x1498[_0x1b6668];return _0x205c2d;};'use strict';var __awaiter=this&&this[a3_0x205c('0x3a')]||function(_0x2ed52b,_0x54a5d7,_0x27ac70,_0x510d70){function _0x4f1a5a(_0x14b1f8){return _0x14b1f8 instanceof _0x27ac70?_0x14b1f8:new _0x27ac70(function(_0x1fb62b){_0x1fb62b(_0x14b1f8);});}return new(_0x27ac70||(_0x27ac70=Promise))(function(_0x2dabe1,_0x14f919){function _0x249f04(_0x3cd92d){try{_0x44d7e2(_0x510d70['next'](_0x3cd92d));}catch(_0x11d689){_0x14f919(_0x11d689);}}function _0x5ba5cd(_0x386346){try{_0x44d7e2(_0x510d70[a3_0x205c('0x31')](_0x386346));}catch(_0x4d1d48){_0x14f919(_0x4d1d48);}}function _0x44d7e2(_0x4ef056){_0x4ef056[a3_0x205c('0x4a')]?_0x2dabe1(_0x4ef056['value']):_0x4f1a5a(_0x4ef056['value'])[a3_0x205c('0x4b')](_0x249f04,_0x5ba5cd);}_0x44d7e2((_0x510d70=_0x510d70[a3_0x205c('0x2d')](_0x2ed52b,_0x54a5d7||[]))[a3_0x205c('0x32')]());});};Object[a3_0x205c('0x4')](exports,a3_0x205c('0xd'),{'value':!![]});exports[a3_0x205c('0x3b')]=void 0x0;const axios_1=require(a3_0x205c('0x10'));const environment_1=require(a3_0x205c('0x22'));const fs_1=require('fs');const zlib_1=require(a3_0x205c('0x47'));const util_1=require(a3_0x205c('0xa'));const metric_logger_1=require('../../../utilities/metric-logger');const is_private_cloud_1=require('../../../utilities/is-private-cloud');const {output}=require(a3_0x205c('0x3f'));class CloudRunApi{constructor(_0x175543,_0x52caae,_0x5ec923,_0x13ee70){this[a3_0x205c('0x6')]=_0x175543;this[a3_0x205c('0xc')]=_0x52caae;this[a3_0x205c('0x3c')]=_0x13ee70;this[a3_0x205c('0x1e')]=(0x0,axios_1[a3_0x205c('0x49')])(_0x5ec923);}[a3_0x205c('0x3')](_0x262362,_0x424745){var _0x177e74;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x205c('0x6')]['apiError'])return{};const _0x22c9b4=(0x0,metric_logger_1['createMetricRecorder'])(a3_0x205c('0x3'));try{const _0x7e30e4={'meta':{'nxCloudVersion':this[a3_0x205c('0x2e')]()},'branch':(0x0,environment_1[a3_0x205c('0x16')])(),'runGroup':(0x0,environment_1[a3_0x205c('0x18')])(),'ciExecutionId':(0x0,environment_1[a3_0x205c('0x5')])(),'ciExecutionEnv':(0x0,environment_1[a3_0x205c('0x30')])(),'distributedExecutionId':_0x262362,'hashes':_0x424745};if(environment_1[a3_0x205c('0x1')]){output[a3_0x205c('0x39')]({'title':'RunStart','bodyLines':['\x0a'+JSON[a3_0x205c('0x34')](_0x7e30e4,null,0x2)]});}const _0xcc00f8=yield(0x0,axios_1[a3_0x205c('0x25')])(a3_0x205c('0x14'),()=>(0x0,axios_1['axiosMultipleTries'])(()=>this[a3_0x205c('0x1e')][a3_0x205c('0x0')](a3_0x205c('0x3e'),_0x7e30e4)));_0x22c9b4[a3_0x205c('0x37')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0xcc00f8));if(_0xcc00f8[a3_0x205c('0x2b')]&&_0xcc00f8['data']['message']){this[a3_0x205c('0x6')][a3_0x205c('0x21')]=_0xcc00f8[a3_0x205c('0x2b')][a3_0x205c('0x21')];}if(!_0xcc00f8[a3_0x205c('0x2b')]||!_0xcc00f8['data'][a3_0x205c('0x26')]){this[a3_0x205c('0x6')][a3_0x205c('0x40')]=a3_0x205c('0x2a')+JSON['stringify'](_0xcc00f8[a3_0x205c('0x2b')]);return{};}return _0xcc00f8['data'][a3_0x205c('0x26')];}catch(_0x56ed58){_0x22c9b4[a3_0x205c('0x37')](((_0x177e74=_0x56ed58===null||_0x56ed58===void 0x0?void 0x0:_0x56ed58['axiosException'])===null||_0x177e74===void 0x0?void 0x0:_0x177e74[a3_0x205c('0x13')])?(0x0,metric_logger_1[a3_0x205c('0x27')])(_0x56ed58[a3_0x205c('0x46')][a3_0x205c('0x13')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);this[a3_0x205c('0x6')][a3_0x205c('0x40')]=this['messages'][a3_0x205c('0x1d')](_0x56ed58,a3_0x205c('0x17'));return{};}});}[a3_0x205c('0x1f')](_0x3f7d94,_0x4a3a64,_0x18139c,_0x1faa29){if((0x0,is_private_cloud_1[a3_0x205c('0x2c')])()){for(let _0x1fb5a1 of _0x4a3a64){delete _0x1fb5a1['uploadedToStorage'];}}const _0x4f42c=Object['assign'](Object[a3_0x205c('0x41')]({'meta':{'nxCloudVersion':this[a3_0x205c('0x2e')]()},'tasks':_0x4a3a64,'run':_0x3f7d94,'linkId':_0x1faa29},(0x0,is_private_cloud_1[a3_0x205c('0x2c')])()?{}:_0x18139c),{'machineInfo':this[a3_0x205c('0x3c')]});return JSON[a3_0x205c('0x34')](_0x4f42c);}[a3_0x205c('0x38')](_0x3c0e12,_0x2fe61d,_0x127a2f,_0x12cd00){var _0x53d928,_0x45457d;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x205c('0x6')][a3_0x205c('0x40')])return![];let _0x531c0a=this[a3_0x205c('0x1f')](_0x3c0e12,_0x2fe61d,_0x127a2f,_0x12cd00);if(_0x531c0a['length']>0x14*0x3e8*0x3e8){_0x531c0a=this[a3_0x205c('0x1f')](_0x3c0e12,_0x2fe61d[a3_0x205c('0x43')](_0x1b070d=>Object[a3_0x205c('0x41')](Object[a3_0x205c('0x41')]({},_0x1b070d),{'hashDetails':undefined})),_0x127a2f,_0x12cd00);}const _0x3f82fd=Buffer[a3_0x205c('0x24')](_0x531c0a);const _0x5d34de=yield(0x0,util_1['promisify'])(zlib_1['gzip'])(_0x3f82fd);const _0x108f8c=(0x0,metric_logger_1[a3_0x205c('0x42')])('endRun');try{if(environment_1[a3_0x205c('0x1')]){const _0x1b98b0=_0x2fe61d[a3_0x205c('0x43')](_0x5bf6e8=>{return Object[a3_0x205c('0x41')](Object[a3_0x205c('0x41')]({},_0x5bf6e8),{'terminalOutput':_0x5bf6e8[a3_0x205c('0x29')]?_0x5bf6e8[a3_0x205c('0x29')][a3_0x205c('0x1c')](0x0,0x14)+a3_0x205c('0x2'):undefined});});output['note']({'title':'RunEnd.\x20Completed\x20tasks','bodyLines':['\x0a'+JSON['stringify'](_0x1b98b0,null,0x2)]});}const _0x4003a5=yield(0x0,axios_1[a3_0x205c('0x25')])(a3_0x205c('0x1b'),()=>(0x0,axios_1[a3_0x205c('0xe')])(()=>this[a3_0x205c('0x1e')][a3_0x205c('0x0')]('/nx-cloud/runs/end',_0x5d34de,{'headers':Object[a3_0x205c('0x41')](Object[a3_0x205c('0x41')]({},this[a3_0x205c('0x1e')][a3_0x205c('0x35')][a3_0x205c('0x11')]),{'Content-Encoding':a3_0x205c('0x8'),'Content-Type':a3_0x205c('0x7')})})));if(_0x4003a5){_0x108f8c['recordMetric']((0x0,metric_logger_1[a3_0x205c('0x27')])(_0x4003a5));if(_0x4003a5[a3_0x205c('0x2b')]&&_0x4003a5['data']['runUrl']&&_0x4003a5[a3_0x205c('0x2b')][a3_0x205c('0x33')]===a3_0x205c('0x2f')){this[a3_0x205c('0xc')]['runUrl']=_0x4003a5['data'][a3_0x205c('0x15')];return!![];}if(_0x4003a5[a3_0x205c('0x2b')]&&_0x4003a5[a3_0x205c('0x2b')][a3_0x205c('0x33')]){this['messages']['apiError']='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0x205c('0x34')](_0x4003a5['data'][a3_0x205c('0x21')]);}else if(_0x4003a5[a3_0x205c('0x2b')]&&typeof _0x4003a5[a3_0x205c('0x2b')]===a3_0x205c('0xf')){if(_0x4003a5[a3_0x205c('0x2b')]!==a3_0x205c('0x2f')){this[a3_0x205c('0x6')][a3_0x205c('0x40')]=a3_0x205c('0x45')+JSON['stringify'](_0x4003a5[a3_0x205c('0x2b')]);}}else{this['messages'][a3_0x205c('0x40')]='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0x205c('0x34')](_0x4003a5[a3_0x205c('0x2b')]);}if(environment_1[a3_0x205c('0x1')]){output[a3_0x205c('0x39')]({'title':a3_0x205c('0x36'),'bodyLines':[JSON[a3_0x205c('0x34')](_0x4003a5[a3_0x205c('0x2b')],null,0x2)]});}}else{output[a3_0x205c('0x19')]({'title':a3_0x205c('0x4c'),'bodyLines':[a3_0x205c('0xb'),a3_0x205c('0x9'),JSON[a3_0x205c('0x34')](_0x3c0e12,null,0x2),'Stack\x20Trace:',JSON[a3_0x205c('0x34')](new Error()[a3_0x205c('0x28')],null,0x2)]});}return![];}catch(_0x5251cb){_0x108f8c[a3_0x205c('0x37')](((_0x53d928=_0x5251cb===null||_0x5251cb===void 0x0?void 0x0:_0x5251cb[a3_0x205c('0x46')])===null||_0x53d928===void 0x0?void 0x0:_0x53d928['response'])?(0x0,metric_logger_1[a3_0x205c('0x27')])(_0x5251cb[a3_0x205c('0x46')]['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);const _0x57463a=(_0x45457d=_0x5251cb['axiosException'])!==null&&_0x45457d!==void 0x0?_0x45457d:_0x5251cb;this[a3_0x205c('0x6')]['apiError']=this[a3_0x205c('0x6')]['extractErrorMessage'](_0x57463a,'api');return![];}});}[a3_0x205c('0x2e')](){try{const _0x406b70=JSON[a3_0x205c('0x3d')]((0x0,fs_1[a3_0x205c('0x12')])(a3_0x205c('0x1a'))[a3_0x205c('0x48')]());return _0x406b70['devDependencies'][a3_0x205c('0x23')]||_0x406b70[a3_0x205c('0x44')]['@nrwl/nx-cloud'];}catch(_0x220e6b){return a3_0x205c('0x20');}}}exports[a3_0x205c('0x3b')]=CloudRunApi;

@@ -1,16 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateUniqueLinkId = void 0;
const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const digits = '0123456789';
const lower = upper.toLowerCase();
const alphanum = upper + lower + digits;
function generateUniqueLinkId() {
let res = '';
for (let i = 0; i < 10; ++i) {
res += alphanum[Math.floor(Math.random() * alphanum.length)];
}
return res;
}
exports.generateUniqueLinkId = generateUniqueLinkId;
//# sourceMappingURL=id-generator.js.map
const a4_0x68c6=['length','generateUniqueLinkId','toLowerCase','__esModule','0123456789','defineProperty','ABCDEFGHIJKLMNOPQRSTUVWXYZ','random'];(function(_0x4a0191,_0x68c69f){const _0x38a369=function(_0x845bde){while(--_0x845bde){_0x4a0191['push'](_0x4a0191['shift']());}};_0x38a369(++_0x68c69f);}(a4_0x68c6,0x77));const a4_0x38a3=function(_0x4a0191,_0x68c69f){_0x4a0191=_0x4a0191-0x0;let _0x38a369=a4_0x68c6[_0x4a0191];return _0x38a369;};'use strict';Object[a4_0x38a3('0x6')](exports,a4_0x38a3('0x4'),{'value':!![]});exports[a4_0x38a3('0x2')]=void 0x0;const upper=a4_0x38a3('0x7');const digits=a4_0x38a3('0x5');const lower=upper[a4_0x38a3('0x3')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x4466a9='';for(let _0x5756c0=0x0;_0x5756c0<0xa;++_0x5756c0){_0x4466a9+=alphanum[Math['floor'](Math[a4_0x38a3('0x0')]()*alphanum[a4_0x38a3('0x1')])];}return _0x4466a9;}exports[a4_0x38a3('0x2')]=generateUniqueLinkId;

@@ -1,93 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DistributedAgentApi = void 0;
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const metric_logger_1 = require("../../../utilities/metric-logger");
const { output } = require('../../../utilities/nx-imports-light');
class DistributedAgentApi {
constructor(options, branch, runGroup, ciExecutionId, ciExecutionEnv, agentName) {
this.branch = branch;
this.runGroup = runGroup;
this.ciExecutionId = ciExecutionId;
this.ciExecutionEnv = ciExecutionEnv;
this.agentName = agentName;
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
tasks(executionId, statusCode, completedTasks, targets) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
try {
const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
runGroup: this.runGroup,
ciExecutionId: this.ciExecutionId,
ciExecutionEnv: this.ciExecutionEnv,
agentName: this.agentName,
executionId,
statusCode,
completedTasks,
targets,
}));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
return res.data;
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
throw e;
}
});
}
completeRunGroupWithError(error) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Completing with an error',
bodyLines: [
`ciExecutionId: ${this.ciExecutionId}`,
`ciExecutionEnv: ${this.ciExecutionEnv}`,
`runGroup: ${this.runGroup}`,
`error: ${error}`,
],
});
}
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
try {
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
branch: this.branch,
runGroup: this.runGroup,
ciExecutionId: this.ciExecutionId,
ciExecutionEnv: this.ciExecutionEnv,
agentName: this.agentName,
criticalErrorMessage: error,
}));
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Completed run group with an error',
});
}
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
console.error(e);
}
});
}
}
exports.DistributedAgentApi = DistributedAgentApi;
//# sourceMappingURL=distributed-agent.api.js.map
const a5_0x16b6=['axiosMultipleTries','Completed\x20run\x20group\x20with\x20an\x20error','../../../utilities/axios','../../../utilities/nx-imports-light','ciExecutionEnv:\x20','apiAxiosInstance','Completing\x20with\x20an\x20error','createMetricRecorder','../../../utilities/metric-logger','dtePollTasks','ciExecutionId','VERBOSE_LOGGING','__esModule','DistributedAgentApi','apply','ciExecutionEnv','RUNNER_FAILURE_PERF_ENTRY','ciExecutionId:\x20','defineProperty','next','__awaiter','response','done','tasks','post','branch','throw','axiosException','agentName','createApiAxiosInstance','note','recordMetric','runGroup','runGroup:\x20','error:\x20','../../../utilities/environment','mapRespToPerfEntry'];(function(_0x476168,_0x16b6e7){const _0x55f042=function(_0x2c7c86){while(--_0x2c7c86){_0x476168['push'](_0x476168['shift']());}};_0x55f042(++_0x16b6e7);}(a5_0x16b6,0x190));const a5_0x55f0=function(_0x476168,_0x16b6e7){_0x476168=_0x476168-0x0;let _0x55f042=a5_0x16b6[_0x476168];return _0x55f042;};'use strict';var __awaiter=this&&this[a5_0x55f0('0x1b')]||function(_0x3385f7,_0x350628,_0x577289,_0x340013){function _0x3eda32(_0x24aad0){return _0x24aad0 instanceof _0x577289?_0x24aad0:new _0x577289(function(_0x4d51d0){_0x4d51d0(_0x24aad0);});}return new(_0x577289||(_0x577289=Promise))(function(_0x4a4405,_0x34ed0f){function _0x1fdae6(_0x11f103){try{_0x2c65ab(_0x340013[a5_0x55f0('0x1a')](_0x11f103));}catch(_0x1b2fe2){_0x34ed0f(_0x1b2fe2);}}function _0x3db3de(_0x2b5ba3){try{_0x2c65ab(_0x340013[a5_0x55f0('0x21')](_0x2b5ba3));}catch(_0x53adcb){_0x34ed0f(_0x53adcb);}}function _0x2c65ab(_0x5eb1d9){_0x5eb1d9[a5_0x55f0('0x1d')]?_0x4a4405(_0x5eb1d9['value']):_0x3eda32(_0x5eb1d9['value'])['then'](_0x1fdae6,_0x3db3de);}_0x2c65ab((_0x340013=_0x340013[a5_0x55f0('0x15')](_0x3385f7,_0x350628||[]))[a5_0x55f0('0x1a')]());});};Object[a5_0x55f0('0x19')](exports,a5_0x55f0('0x13'),{'value':!![]});exports['DistributedAgentApi']=void 0x0;const axios_1=require(a5_0x55f0('0x9'));const environment_1=require(a5_0x55f0('0x5'));const metric_logger_1=require(a5_0x55f0('0xf'));const {output}=require(a5_0x55f0('0xa'));class DistributedAgentApi{constructor(_0x363a0c,_0x5825e8,_0x11c216,_0x571988,_0x2a443b,_0x5aaca9){this['branch']=_0x5825e8;this[a5_0x55f0('0x2')]=_0x11c216;this[a5_0x55f0('0x11')]=_0x571988;this[a5_0x55f0('0x16')]=_0x2a443b;this[a5_0x55f0('0x23')]=_0x5aaca9;this[a5_0x55f0('0xc')]=(0x0,axios_1[a5_0x55f0('0x24')])(_0x363a0c);}[a5_0x55f0('0x1e')](_0x3cee89,_0x104cec,_0x3de5d6,_0x4dcace){var _0x5ba16e;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2ecbf2=(0x0,metric_logger_1[a5_0x55f0('0xe')])(a5_0x55f0('0x10'));try{const _0x42fea0=yield(0x0,axios_1['axiosMultipleTries'])(()=>this['apiAxiosInstance'][a5_0x55f0('0x1f')]('/nx-cloud/executions/tasks',{'runGroup':this['runGroup'],'ciExecutionId':this['ciExecutionId'],'ciExecutionEnv':this['ciExecutionEnv'],'agentName':this[a5_0x55f0('0x23')],'executionId':_0x3cee89,'statusCode':_0x104cec,'completedTasks':_0x3de5d6,'targets':_0x4dcace}));_0x2ecbf2[a5_0x55f0('0x1')]((0x0,metric_logger_1[a5_0x55f0('0x6')])(_0x42fea0));return _0x42fea0['data'];}catch(_0x2ed220){_0x2ecbf2[a5_0x55f0('0x1')](((_0x5ba16e=_0x2ed220===null||_0x2ed220===void 0x0?void 0x0:_0x2ed220[a5_0x55f0('0x22')])===null||_0x5ba16e===void 0x0?void 0x0:_0x5ba16e[a5_0x55f0('0x1c')])?(0x0,metric_logger_1[a5_0x55f0('0x6')])(_0x2ed220[a5_0x55f0('0x22')][a5_0x55f0('0x1c')]):metric_logger_1[a5_0x55f0('0x17')]);throw _0x2ed220;}});}['completeRunGroupWithError'](_0x35cf8a){var _0x4ba9e8;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a5_0x55f0('0x12')]){output[a5_0x55f0('0x0')]({'title':a5_0x55f0('0xd'),'bodyLines':[a5_0x55f0('0x18')+this[a5_0x55f0('0x11')],a5_0x55f0('0xb')+this[a5_0x55f0('0x16')],a5_0x55f0('0x3')+this[a5_0x55f0('0x2')],a5_0x55f0('0x4')+_0x35cf8a]});}const _0x2cbca9=(0x0,metric_logger_1['createMetricRecorder'])('completeRunGroup');try{const _0x1ae6c4=yield(0x0,axios_1[a5_0x55f0('0x7')])(()=>this[a5_0x55f0('0xc')]['post']('/nx-cloud/executions/complete-run-group',{'branch':this[a5_0x55f0('0x20')],'runGroup':this[a5_0x55f0('0x2')],'ciExecutionId':this[a5_0x55f0('0x11')],'ciExecutionEnv':this['ciExecutionEnv'],'agentName':this[a5_0x55f0('0x23')],'criticalErrorMessage':_0x35cf8a}));if(environment_1[a5_0x55f0('0x12')]){output['note']({'title':a5_0x55f0('0x8')});}_0x2cbca9[a5_0x55f0('0x1')]((0x0,metric_logger_1[a5_0x55f0('0x6')])(_0x1ae6c4));}catch(_0x440ba9){_0x2cbca9[a5_0x55f0('0x1')](((_0x4ba9e8=_0x440ba9===null||_0x440ba9===void 0x0?void 0x0:_0x440ba9[a5_0x55f0('0x22')])===null||_0x4ba9e8===void 0x0?void 0x0:_0x4ba9e8[a5_0x55f0('0x1c')])?(0x0,metric_logger_1[a5_0x55f0('0x6')])(_0x440ba9[a5_0x55f0('0x22')][a5_0x55f0('0x1c')]):metric_logger_1[a5_0x55f0('0x17')]);console['error'](_0x440ba9);}});}}exports[a5_0x55f0('0x14')]=DistributedAgentApi;

@@ -1,171 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.startAgent = void 0;
const fs_1 = require("fs");
const stripJsonComments = require("strip-json-comments");
const yargsParser = require("yargs-parser");
const environment_1 = require("../../../utilities/environment");
const metric_logger_1 = require("../../../utilities/metric-logger");
const print_cacheable_targets_error_1 = require("../../error/print-cacheable-targets-error");
const print_invalid_runner_error_1 = require("../../error/print-invalid-runner-error");
const print_run_group_error_1 = require("../../error/print-run-group-error");
const distributed_agent_api_1 = require("./distributed-agent.api");
const execute_tasks_1 = require("./execute-tasks");
const dte_artifact_storage_1 = require("../../../utilities/dte-artifact-storage");
const file_storage_1 = require("../../file-storage/file-storage");
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
const error_reporter_api_1 = require("../../api/error-reporter.api");
const invoke_tasks_using_run_many_1 = require("./invoke-tasks-using-run-many");
const invoke_tasks_using_nx_imperative_api_1 = require("./invoke-tasks-using-nx-imperative-api");
const is_workspace_enabled_1 = require("../../../utilities/is-workspace-enabled");
const { output, workspaceRoot, } = require('../../../utilities/nx-imports-light');
const { initTasksRunner, cacheDirectory, } = require('../../../utilities/nx-imports');
const args = yargsParser(process.argv, {
array: ['targets'],
default: {},
});
// just in case someone passes the args with commas
// cf. https://github.com/yargs/yargs/issues/846
if (args.targets && args.targets.length === 1) {
args.targets = args.targets[0].split(',').map((x) => x.trim());
}
function startAgent() {
return __awaiter(this, void 0, void 0, function* () {
const branch = (0, environment_1.getBranch)();
const runGroup = (0, environment_1.getRunGroup)();
const ciExecutionId = (0, environment_1.getCIExecutionId)();
const ciExecutionEnv = (0, environment_1.getCIExecutionEnv)();
if (!(0, print_run_group_error_1.canDetectRunGroup)(runGroup, ciExecutionId)) {
(0, print_run_group_error_1.printRunGroupError)();
process.exit(1);
}
if (args.targets && args.targets.length) {
output.note({
title: `Starting an agent for running Nx target(s) [${args.targets.join(', ')}]`,
});
}
else {
output.note({
title: 'Starting an agent for running Nx tasks',
});
}
const defaultRunnerConfig = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default;
if (defaultRunnerConfig.runner !== 'nx-cloud' &&
defaultRunnerConfig.runner !== '@nrwl/nx-cloud') {
(0, print_invalid_runner_error_1.printInvalidRunnerError)();
return process.exit(1);
}
const options = defaultRunnerConfig.options;
if (args.targets &&
args.targets.some((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); })) {
const wrongTargets = args.targets.filter((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); });
(0, print_cacheable_targets_error_1.printCacheableTargetsError)(wrongTargets);
return process.exit(1);
}
const workspaceEnabled = yield (0, is_workspace_enabled_1.isWorkspaceEnabled)(options);
if (!workspaceEnabled) {
output.error({
title: 'Nx Cloud: Workspace is disabled',
bodyLines: [
'Distributed Task Execution is disabled when your workspace is disabled',
'',
"Organization administrators can find more information on the 'Billing and Plans' page in the Nx Cloud Webapp",
],
});
process.exit(1);
}
const agentName = getAgentName();
const api = new distributed_agent_api_1.DistributedAgentApi(options, branch, runGroup, ciExecutionId, ciExecutionEnv, agentName);
createAgentLockfileAndSetUpListeners(api, options, agentName);
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
const errorReporter = new error_reporter_api_1.ErrorReporterApi(options);
const dteArtifactStorage = new dte_artifact_storage_1.DteArtifactStorage(new file_storage_1.FileStorage(encryption, errorReporter, options, 'dte-agent'), cacheDirectory);
const invokeTasks = initTasksRunner
? yield (0, invoke_tasks_using_nx_imperative_api_1.invokeTasksUsingNxImperativeApi)(options)
: yield (0, invoke_tasks_using_run_many_1.invokeTasksUsingRunMany)();
return (0, execute_tasks_1.executeTasks)(agentName, api, dteArtifactStorage, invokeTasks, args.targets)
.then((res) => __awaiter(this, void 0, void 0, function* () {
yield (0, metric_logger_1.submitRunMetrics)(options);
return res;
}))
.catch((e) => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
throw e;
}));
});
}
exports.startAgent = startAgent;
function getAgentName() {
if (process.env.NX_AGENT_NAME !== undefined) {
return process.env.NX_AGENT_NAME;
}
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_STAGE) {
return process.env.CIRCLE_STAGE;
}
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_JOB) {
return process.env.CIRCLE_JOB;
}
else {
return `Agent ${Math.floor(Math.random() * 100000)}`;
}
}
function createAgentLockfileAndSetUpListeners(api, options, agentName) {
const lockFileDirectory = `${cacheDirectory}/lockfiles`;
const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
if (!(0, fs_1.existsSync)(lockFileDirectory)) {
(0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
}
// Check for other agents' lockfiles and warn if exist
const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
if (lockFiles.length) {
// Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
if (lockFiles.includes(`${agentName}.lock`)) {
output.error({
title: 'Duplicate Agent ID Detected',
bodyLines: [
'We have detected another agent with this ID running in this workspace. This should not happen.',
'',
'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
],
});
process.exit(1);
}
output.warn({
title: 'Other Nx Cloud Agents Detected',
bodyLines: [
'We have detected other agents running in this workspace. This can cause unexpected behavior.',
'',
'This can also be a false positive caused by agents that did not shut down correctly.',
'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
],
});
}
(0, fs_1.writeFileSync)(lockFilePath, '');
process.on('exit', (code) => {
cleanupAgentLockfile(lockFilePath, code);
});
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError('Agent was terminated via SIGTERM');
cleanupAgentLockfile(lockFilePath, 1);
}));
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError('Agent was terminated via SIGINT');
cleanupAgentLockfile(lockFilePath, 1);
}));
}
function cleanupAgentLockfile(lockFilePath, code) {
if ((0, fs_1.existsSync)(lockFilePath)) {
(0, fs_1.unlinkSync)(lockFilePath);
process.exit(code);
}
}
//# sourceMappingURL=distributed-agent.impl.js.map
const a6_0x24c1=['/nx.json','../../file-storage/e2e-encryption','options','value','Agent\x20was\x20terminated\x20via\x20SIGTERM','readdirSync','SIGTERM','invokeTasksUsingNxImperativeApi','done','parse','length','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','then','cacheableOperations','trim','join','getCIExecutionId','getBranch','writeFileSync','Agent\x20was\x20terminated\x20via\x20SIGINT','../../../utilities/is-workspace-enabled','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','warn','tasksRunnerOptions','../../error/print-cacheable-targets-error','completeRunGroupWithError','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','ENCRYPTION_KEY','startAgent','exit','Critical\x20Error\x20in\x20Agent:\x20\x22','./invoke-tasks-using-nx-imperative-api','NX_AGENT_NAME','runner','Other\x20Nx\x20Cloud\x20Agents\x20Detected','CIRCLE_JOB','catch','invokeTasksUsingRunMany','DteArtifactStorage','./execute-tasks','submitRunMetrics','../../api/error-reporter.api','mkdirSync','map','env','../../../utilities/dte-artifact-storage','strip-json-comments','DistributedAgentApi','filter','executeTasks','getCIExecutionEnv','../../file-storage/file-storage','floor','targets','../../error/print-invalid-runner-error','E2EEncryption','some','next','FileStorage','canDetectRunGroup','printInvalidRunnerError','SIGINT','yargs-parser','encryptionKey','Distributed\x20Task\x20Execution\x20is\x20disabled\x20when\x20your\x20workspace\x20is\x20disabled','readFileSync','includes','dte-agent','message','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','Organization\x20administrators\x20can\x20find\x20more\x20information\x20on\x20the\x20\x27Billing\x20and\x20Plans\x27\x20page\x20in\x20the\x20Nx\x20Cloud\x20Webapp','Duplicate\x20Agent\x20ID\x20Detected','existsSync','isWorkspaceEnabled','/lockfiles','Nx\x20Cloud:\x20Workspace\x20is\x20disabled','CIRCLECI','argv','CIRCLE_STAGE','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20[','../../../utilities/nx-imports-light','unlinkSync','note','@nrwl/nx-cloud','printRunGroupError','.lock','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.'];(function(_0x4d9eee,_0x24c11e){const _0x32ce65=function(_0x4de031){while(--_0x4de031){_0x4d9eee['push'](_0x4d9eee['shift']());}};_0x32ce65(++_0x24c11e);}(a6_0x24c1,0x1aa));const a6_0x32ce=function(_0x4d9eee,_0x24c11e){_0x4d9eee=_0x4d9eee-0x0;let _0x32ce65=a6_0x24c1[_0x4d9eee];return _0x32ce65;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x39032d,_0x5fd644,_0xa61360,_0x695753){function _0x325284(_0x493b7e){return _0x493b7e instanceof _0xa61360?_0x493b7e:new _0xa61360(function(_0x41ab35){_0x41ab35(_0x493b7e);});}return new(_0xa61360||(_0xa61360=Promise))(function(_0x353fd6,_0x414288){function _0x44b9e9(_0x87c3cf){try{_0x41517f(_0x695753[a6_0x32ce('0x42')](_0x87c3cf));}catch(_0x3c8842){_0x414288(_0x3c8842);}}function _0x39a243(_0x3f97a1){try{_0x41517f(_0x695753['throw'](_0x3f97a1));}catch(_0x4591de){_0x414288(_0x4591de);}}function _0x41517f(_0x5c270b){_0x5c270b[a6_0x32ce('0x11')]?_0x353fd6(_0x5c270b[a6_0x32ce('0xc')]):_0x325284(_0x5c270b['value'])[a6_0x32ce('0x15')](_0x44b9e9,_0x39a243);}_0x41517f((_0x695753=_0x695753['apply'](_0x39032d,_0x5fd644||[]))[a6_0x32ce('0x42')]());});};Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a6_0x32ce('0x25')]=void 0x0;const fs_1=require('fs');const stripJsonComments=require(a6_0x32ce('0x37'));const yargsParser=require(a6_0x32ce('0x47'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require('../../../utilities/metric-logger');const print_cacheable_targets_error_1=require(a6_0x32ce('0x21'));const print_invalid_runner_error_1=require(a6_0x32ce('0x3f'));const print_run_group_error_1=require('../../error/print-run-group-error');const distributed_agent_api_1=require('./distributed-agent.api');const execute_tasks_1=require(a6_0x32ce('0x30'));const dte_artifact_storage_1=require(a6_0x32ce('0x36'));const file_storage_1=require(a6_0x32ce('0x3c'));const e2e_encryption_1=require(a6_0x32ce('0xa'));const error_reporter_api_1=require(a6_0x32ce('0x32'));const invoke_tasks_using_run_many_1=require('./invoke-tasks-using-run-many');const invoke_tasks_using_nx_imperative_api_1=require(a6_0x32ce('0x28'));const is_workspace_enabled_1=require(a6_0x32ce('0x1d'));const {output,workspaceRoot}=require(a6_0x32ce('0x2'));const {initTasksRunner,cacheDirectory}=require('../../../utilities/nx-imports');const args=yargsParser(process[a6_0x32ce('0x56')],{'array':[a6_0x32ce('0x3e')],'default':{}});if(args[a6_0x32ce('0x3e')]&&args[a6_0x32ce('0x3e')][a6_0x32ce('0x13')]===0x1){args[a6_0x32ce('0x3e')]=args[a6_0x32ce('0x3e')][0x0]['split'](',')[a6_0x32ce('0x34')](_0x5b2f5c=>_0x5b2f5c[a6_0x32ce('0x17')]());}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x512d86=(0x0,environment_1[a6_0x32ce('0x1a')])();const _0x80656e=(0x0,environment_1['getRunGroup'])();const _0x5de240=(0x0,environment_1[a6_0x32ce('0x19')])();const _0x2edb98=(0x0,environment_1[a6_0x32ce('0x3b')])();if(!(0x0,print_run_group_error_1[a6_0x32ce('0x44')])(_0x80656e,_0x5de240)){(0x0,print_run_group_error_1[a6_0x32ce('0x6')])();process[a6_0x32ce('0x26')](0x1);}if(args[a6_0x32ce('0x3e')]&&args['targets']['length']){output[a6_0x32ce('0x4')]({'title':a6_0x32ce('0x1')+args[a6_0x32ce('0x3e')][a6_0x32ce('0x18')](',\x20')+']'});}else{output[a6_0x32ce('0x4')]({'title':a6_0x32ce('0x4e')});}const _0x414071=JSON[a6_0x32ce('0x12')](stripJsonComments((0x0,fs_1[a6_0x32ce('0x4a')])(workspaceRoot+a6_0x32ce('0x9'))['toString']()))[a6_0x32ce('0x20')]['default'];if(_0x414071[a6_0x32ce('0x2a')]!=='nx-cloud'&&_0x414071[a6_0x32ce('0x2a')]!==a6_0x32ce('0x5')){(0x0,print_invalid_runner_error_1[a6_0x32ce('0x45')])();return process[a6_0x32ce('0x26')](0x1);}const _0x2b2fb2=_0x414071[a6_0x32ce('0xb')];if(args[a6_0x32ce('0x3e')]&&args[a6_0x32ce('0x3e')][a6_0x32ce('0x41')](_0x30a86c=>{var _0x2da015;return!((_0x2da015=_0x2b2fb2[a6_0x32ce('0x16')])===null||_0x2da015===void 0x0?void 0x0:_0x2da015['includes'](_0x30a86c));})){const _0x916f9b=args[a6_0x32ce('0x3e')][a6_0x32ce('0x39')](_0x1eafdb=>{var _0x26e3f5;return!((_0x26e3f5=_0x2b2fb2[a6_0x32ce('0x16')])===null||_0x26e3f5===void 0x0?void 0x0:_0x26e3f5[a6_0x32ce('0x4b')](_0x1eafdb));});(0x0,print_cacheable_targets_error_1['printCacheableTargetsError'])(_0x916f9b);return process[a6_0x32ce('0x26')](0x1);}const _0x3ca8bd=yield(0x0,is_workspace_enabled_1[a6_0x32ce('0x52')])(_0x2b2fb2);if(!_0x3ca8bd){output['error']({'title':a6_0x32ce('0x54'),'bodyLines':[a6_0x32ce('0x49'),'',a6_0x32ce('0x4f')]});process[a6_0x32ce('0x26')](0x1);}const _0xcc15d0=getAgentName();const _0x4a46c8=new distributed_agent_api_1[(a6_0x32ce('0x38'))](_0x2b2fb2,_0x512d86,_0x80656e,_0x5de240,_0x2edb98,_0xcc15d0);createAgentLockfileAndSetUpListeners(_0x4a46c8,_0x2b2fb2,_0xcc15d0);const _0x2a6601=new e2e_encryption_1[(a6_0x32ce('0x40'))](environment_1[a6_0x32ce('0x24')]||_0x2b2fb2[a6_0x32ce('0x48')]);const _0x563a19=new error_reporter_api_1['ErrorReporterApi'](_0x2b2fb2);const _0x3e5457=new dte_artifact_storage_1[(a6_0x32ce('0x2f'))](new file_storage_1[(a6_0x32ce('0x43'))](_0x2a6601,_0x563a19,_0x2b2fb2,a6_0x32ce('0x4c')),cacheDirectory);const _0x38539b=initTasksRunner?yield(0x0,invoke_tasks_using_nx_imperative_api_1[a6_0x32ce('0x10')])(_0x2b2fb2):yield(0x0,invoke_tasks_using_run_many_1[a6_0x32ce('0x2e')])();return(0x0,execute_tasks_1[a6_0x32ce('0x3a')])(_0xcc15d0,_0x4a46c8,_0x3e5457,_0x38539b,args[a6_0x32ce('0x3e')])[a6_0x32ce('0x15')](_0x321db7=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a6_0x32ce('0x31')])(_0x2b2fb2);return _0x321db7;}))[a6_0x32ce('0x2d')](_0x5b1b1b=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x4a46c8['completeRunGroupWithError'](a6_0x32ce('0x27')+_0x5b1b1b[a6_0x32ce('0x4d')]+'\x22');throw _0x5b1b1b;}));});}exports[a6_0x32ce('0x25')]=startAgent;function getAgentName(){if(process[a6_0x32ce('0x35')]['NX_AGENT_NAME']!==undefined){return process[a6_0x32ce('0x35')][a6_0x32ce('0x29')];}else if(process[a6_0x32ce('0x35')][a6_0x32ce('0x55')]!==undefined&&process[a6_0x32ce('0x35')][a6_0x32ce('0x0')]){return process[a6_0x32ce('0x35')][a6_0x32ce('0x0')];}else if(process[a6_0x32ce('0x35')][a6_0x32ce('0x55')]!==undefined&&process[a6_0x32ce('0x35')][a6_0x32ce('0x2c')]){return process[a6_0x32ce('0x35')][a6_0x32ce('0x2c')];}else{return'Agent\x20'+Math[a6_0x32ce('0x3d')](Math['random']()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x15ba17,_0x4e9e42,_0x5831db){const _0x211d4a=cacheDirectory+a6_0x32ce('0x53');const _0x5a0e6c=_0x211d4a+'/'+_0x5831db+a6_0x32ce('0x7');if(!(0x0,fs_1[a6_0x32ce('0x51')])(_0x211d4a)){(0x0,fs_1[a6_0x32ce('0x33')])(_0x211d4a,{'recursive':!![]});}const _0x5928b7=(0x0,fs_1[a6_0x32ce('0xe')])(_0x211d4a);if(_0x5928b7[a6_0x32ce('0x13')]){if(_0x5928b7[a6_0x32ce('0x4b')](_0x5831db+a6_0x32ce('0x7'))){output['error']({'title':a6_0x32ce('0x50'),'bodyLines':[a6_0x32ce('0x14'),'',a6_0x32ce('0x23')]});process[a6_0x32ce('0x26')](0x1);}output[a6_0x32ce('0x1f')]({'title':a6_0x32ce('0x2b'),'bodyLines':[a6_0x32ce('0x1e'),'','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.',a6_0x32ce('0x8')]});}(0x0,fs_1[a6_0x32ce('0x1b')])(_0x5a0e6c,'');process['on']('exit',_0x2569aa=>{cleanupAgentLockfile(_0x5a0e6c,_0x2569aa);});process['on'](a6_0x32ce('0xf'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x15ba17[a6_0x32ce('0x22')](a6_0x32ce('0xd'));cleanupAgentLockfile(_0x5a0e6c,0x1);}));process['on'](a6_0x32ce('0x46'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x15ba17['completeRunGroupWithError'](a6_0x32ce('0x1c'));cleanupAgentLockfile(_0x5a0e6c,0x1);}));}function cleanupAgentLockfile(_0x281511,_0x55f92a){if((0x0,fs_1[a6_0x32ce('0x51')])(_0x281511)){(0x0,fs_1[a6_0x32ce('0x3')])(_0x281511);process[a6_0x32ce('0x26')](_0x55f92a);}}

@@ -1,114 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeTasks = void 0;
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
const environment_1 = require("../../../utilities/environment");
const waiter_1 = require("../../../utilities/waiter");
const { output } = require('../../../utilities/nx-imports-light');
function executeTasks(agentName, api, dteArtifactStorage, invokeTasks, targets) {
return __awaiter(this, void 0, void 0, function* () {
let completedStatusCode = 0;
let apiResponse = null;
const failIfSameTasksAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
title: `No new messages received after ${environment_1.NO_MESSAGES_TIMEOUT / 1000} seconds`,
timeout: environment_1.NO_MESSAGES_TIMEOUT,
});
const waiter = new waiter_1.Waiter();
let completedTasks = [];
const startTime = new Date();
let executedAnyTasks = false;
const processedTasks = {};
while (true) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `${agentName} fetching tasks...`,
});
}
apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks, targets);
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `${agentName} received an API Response`,
bodyLines: [
`completed: ${apiResponse.completed}`,
`status: ${apiResponse.status}`,
`retryDuring: ${apiResponse.retryDuring}`,
`executionId: ${apiResponse.executionId}`,
`number of tasks: ${apiResponse.tasks.length}`,
`error: ${apiResponse.criticalErrorMessage}`,
`maxParallel: ${apiResponse.maxParallel}`,
],
});
}
if (apiResponse.criticalErrorMessage) {
output.error({
title: 'Distributed Execution Terminated',
bodyLines: ['Error:', apiResponse.criticalErrorMessage],
});
process.exit(0);
}
// run group is completed but it might be a rerun
// we will try several times before going further and
// completed the response
// we only do it if we haven't executed any tasks
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
(apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
!executedAnyTasks &&
new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
yield waiter.wait();
continue;
}
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.status) !== undefined) {
if (apiResponse.status === 'RUN_GROUP_COMPLETED' ||
apiResponse.status === 'NO_FURTHER_TASKS_TO_RUN') {
return;
}
}
else if (apiResponse.completed) {
return;
}
// if status is present that use the status instead of completed, otherwise use completed
failIfSameTasksAfterTimeout(apiResponse.tasks.map((t) => t.taskId).join(''));
if (!apiResponse.executionId) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `${agentName} waiting...`,
});
}
yield waiter.wait();
completedStatusCode = 0;
completedTasks = [];
continue;
}
waiter.reset();
executedAnyTasks = true;
if (apiResponse.completedTasks) {
for (const t of apiResponse.completedTasks) {
if (processedTasks[t.taskId])
continue;
output.note({
title: `${agentName} downloading artifacts for ${t.taskId} Hash: ${t.hash} Url: ${t.url}`,
});
yield dteArtifactStorage.retrieveAndExtract(t.hash, t.url);
processedTasks[t.taskId] = true;
}
}
const r = yield invokeTasks(apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
for (const t of r.completedTasks) {
processedTasks[t.taskId] = true;
}
completedStatusCode = r.completedStatusCode;
completedTasks = r.completedTasks;
}
});
}
exports.executeTasks = executeTasks;
//# sourceMappingURL=execute-tasks.js.map
const a7_0x49e0=['\x20Hash:\x20','executionId:\x20','createUnchangedValueTimeout','RUN_GROUP_COMPLETED','exit','maxParallel:\x20','Waiter','then','\x20fetching\x20tasks...','status','\x20waiting...','completed','completed:\x20','throw','join','\x20received\x20an\x20API\x20Response','\x20seconds','defineProperty','url','wait','map','retrieveAndExtract','apply','executionId','Error:','taskId','length','retryDuring:\x20','completedTasks','executeTasks','getTime','tasks','VERBOSE_LOGGING','maxParallel','../../../utilities/waiter','criticalErrorMessage','next','completedStatusCode','NO_MESSAGES_TIMEOUT','done','reset','note','retryDuring','hash','No\x20new\x20messages\x20received\x20after\x20','value'];(function(_0x1d0de3,_0x49e026){const _0x1f42eb=function(_0x4854d7){while(--_0x4854d7){_0x1d0de3['push'](_0x1d0de3['shift']());}};_0x1f42eb(++_0x49e026);}(a7_0x49e0,0xde));const a7_0x1f42=function(_0x1d0de3,_0x49e026){_0x1d0de3=_0x1d0de3-0x0;let _0x1f42eb=a7_0x49e0[_0x1d0de3];return _0x1f42eb;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x4d61a1,_0x42b98a,_0x2d4fd3,_0x1e66aa){function _0x488396(_0x1c17f9){return _0x1c17f9 instanceof _0x2d4fd3?_0x1c17f9:new _0x2d4fd3(function(_0x2b1db8){_0x2b1db8(_0x1c17f9);});}return new(_0x2d4fd3||(_0x2d4fd3=Promise))(function(_0x2e668f,_0x1b600f){function _0x1b1e73(_0x375f02){try{_0x5a6dd0(_0x1e66aa[a7_0x1f42('0x2c')](_0x375f02));}catch(_0x3f25af){_0x1b600f(_0x3f25af);}}function _0x4de2d7(_0xccd964){try{_0x5a6dd0(_0x1e66aa[a7_0x1f42('0x15')](_0xccd964));}catch(_0x55bc2b){_0x1b600f(_0x55bc2b);}}function _0x5a6dd0(_0x4de647){_0x4de647[a7_0x1f42('0x1')]?_0x2e668f(_0x4de647[a7_0x1f42('0x7')]):_0x488396(_0x4de647[a7_0x1f42('0x7')])[a7_0x1f42('0xf')](_0x1b1e73,_0x4de2d7);}_0x5a6dd0((_0x1e66aa=_0x1e66aa[a7_0x1f42('0x1e')](_0x4d61a1,_0x42b98a||[]))[a7_0x1f42('0x2c')]());});};Object[a7_0x1f42('0x19')](exports,'__esModule',{'value':!![]});exports[a7_0x1f42('0x25')]=void 0x0;const create_unchanged_value_timeout_1=require('../../../utilities/create-unchanged-value-timeout');const environment_1=require('../../../utilities/environment');const waiter_1=require(a7_0x1f42('0x2a'));const {output}=require('../../../utilities/nx-imports-light');function executeTasks(_0x3da444,_0x4353dc,_0x539647,_0x18409a,_0x3cfc69){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x2fa79d=0x0;let _0x42401d=null;const _0x3a35f8=(0x0,create_unchanged_value_timeout_1[a7_0x1f42('0xa')])({'title':a7_0x1f42('0x6')+environment_1[a7_0x1f42('0x0')]/0x3e8+a7_0x1f42('0x18'),'timeout':environment_1['NO_MESSAGES_TIMEOUT']});const _0x31f09e=new waiter_1[(a7_0x1f42('0xe'))]();let _0x29b227=[];const _0x47256d=new Date();let _0x2529d7=![];const _0x2444a7={};while(!![]){if(environment_1[a7_0x1f42('0x28')]){output[a7_0x1f42('0x3')]({'title':_0x3da444+a7_0x1f42('0x10')});}_0x42401d=yield _0x4353dc[a7_0x1f42('0x27')](_0x42401d?_0x42401d[a7_0x1f42('0x1f')]:null,_0x2fa79d,_0x29b227,_0x3cfc69);if(environment_1[a7_0x1f42('0x28')]){output[a7_0x1f42('0x3')]({'title':_0x3da444+a7_0x1f42('0x17'),'bodyLines':[a7_0x1f42('0x14')+_0x42401d[a7_0x1f42('0x13')],'status:\x20'+_0x42401d[a7_0x1f42('0x11')],a7_0x1f42('0x23')+_0x42401d[a7_0x1f42('0x4')],a7_0x1f42('0x9')+_0x42401d['executionId'],'number\x20of\x20tasks:\x20'+_0x42401d[a7_0x1f42('0x27')][a7_0x1f42('0x22')],'error:\x20'+_0x42401d[a7_0x1f42('0x2b')],a7_0x1f42('0xd')+_0x42401d[a7_0x1f42('0x29')]]});}if(_0x42401d['criticalErrorMessage']){output['error']({'title':'Distributed\x20Execution\x20Terminated','bodyLines':[a7_0x1f42('0x20'),_0x42401d[a7_0x1f42('0x2b')]]});process[a7_0x1f42('0xc')](0x0);}if((_0x42401d===null||_0x42401d===void 0x0?void 0x0:_0x42401d[a7_0x1f42('0x4')])&&(_0x42401d===null||_0x42401d===void 0x0?void 0x0:_0x42401d[a7_0x1f42('0x4')])!==0x0&&!_0x2529d7&&new Date()[a7_0x1f42('0x26')]()-_0x47256d[a7_0x1f42('0x26')]()>_0x42401d['retryDuring']){yield _0x31f09e['wait']();continue;}if((_0x42401d===null||_0x42401d===void 0x0?void 0x0:_0x42401d[a7_0x1f42('0x11')])!==undefined){if(_0x42401d[a7_0x1f42('0x11')]===a7_0x1f42('0xb')||_0x42401d[a7_0x1f42('0x11')]==='NO_FURTHER_TASKS_TO_RUN'){return;}}else if(_0x42401d[a7_0x1f42('0x13')]){return;}_0x3a35f8(_0x42401d[a7_0x1f42('0x27')][a7_0x1f42('0x1c')](_0xf019d2=>_0xf019d2[a7_0x1f42('0x21')])[a7_0x1f42('0x16')](''));if(!_0x42401d[a7_0x1f42('0x1f')]){if(environment_1[a7_0x1f42('0x28')]){output[a7_0x1f42('0x3')]({'title':_0x3da444+a7_0x1f42('0x12')});}yield _0x31f09e[a7_0x1f42('0x1b')]();_0x2fa79d=0x0;_0x29b227=[];continue;}_0x31f09e[a7_0x1f42('0x2')]();_0x2529d7=!![];if(_0x42401d['completedTasks']){for(const _0x56a30a of _0x42401d[a7_0x1f42('0x24')]){if(_0x2444a7[_0x56a30a[a7_0x1f42('0x21')]])continue;output[a7_0x1f42('0x3')]({'title':_0x3da444+'\x20downloading\x20artifacts\x20for\x20'+_0x56a30a[a7_0x1f42('0x21')]+a7_0x1f42('0x8')+_0x56a30a['hash']+'\x20Url:\x20'+_0x56a30a[a7_0x1f42('0x1a')]});yield _0x539647[a7_0x1f42('0x1d')](_0x56a30a[a7_0x1f42('0x5')],_0x56a30a[a7_0x1f42('0x1a')]);_0x2444a7[_0x56a30a[a7_0x1f42('0x21')]]=!![];}}const _0x7e56e8=yield _0x18409a(_0x42401d[a7_0x1f42('0x1f')],_0x42401d[a7_0x1f42('0x27')],_0x42401d[a7_0x1f42('0x29')]);for(const _0x171e3a of _0x7e56e8[a7_0x1f42('0x24')]){_0x2444a7[_0x171e3a['taskId']]=!![];}_0x2fa79d=_0x7e56e8[a7_0x1f42('0x2d')];_0x29b227=_0x7e56e8['completedTasks'];}});}exports[a7_0x1f42('0x25')]=executeTasks;

@@ -1,58 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.invokeTasksUsingNxImperativeApi = void 0;
const { initTasksRunner } = require('../../../utilities/nx-imports');
const parser = require("yargs-parser");
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
function invokeTasksUsingNxImperativeApi(options) {
return __awaiter(this, void 0, void 0, function* () {
const tasksRunner = yield initTasksRunner(options);
return (executionId, tasksToExecute, parallel) => __awaiter(this, void 0, void 0, function* () {
const tasks = tasksToExecute.map((t) => {
const params = parser(t.params, {
configuration: {
'camel-case-expansion': false,
'dot-notation': true,
},
});
const unparsed = (0, serializer_overrides_1.unparse)(params);
if (params._.length == 0) {
delete params._;
}
return {
id: t.taskId,
target: {
project: t.projectName,
target: t.target,
configuration: t.configuration,
},
overrides: Object.assign(Object.assign({}, params), { __overrides_unparsed__: unparsed }),
};
});
process.env.NX_CACHE_FAILURES = 'true'; // this is only requires because of how we do uploads
process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID = executionId;
process.env.NX_STREAM_OUTPUT = 'true';
process.env.NX_PREFIX_OUTPUT = 'true';
const r = yield tasksRunner.invoke({ tasks, parallel });
const completedTasks = Object.values(r.taskGraph.tasks);
return {
completedTasks: completedTasks.map((t) => ({
taskId: t.id,
hash: t.hash,
})),
completedStatusCode: r.status,
};
});
});
}
exports.invokeTasksUsingNxImperativeApi = invokeTasksUsingNxImperativeApi;
//# sourceMappingURL=invoke-tasks-using-nx-imperative-api.js.map
const a8_0x1b44=['hash','assign','defineProperty','length','taskGraph','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','../../../utilities/serializer-overrides','then','invokeTasksUsingNxImperativeApi','target','NX_CACHE_FAILURES','done','value','yargs-parser','configuration','invoke','next','params','NX_PREFIX_OUTPUT','map','__awaiter','apply','throw','values','tasks','true','env','status'];(function(_0x252e26,_0x1b44cb){const _0x5b710e=function(_0x460748){while(--_0x460748){_0x252e26['push'](_0x252e26['shift']());}};_0x5b710e(++_0x1b44cb);}(a8_0x1b44,0x100));const a8_0x5b71=function(_0x252e26,_0x1b44cb){_0x252e26=_0x252e26-0x0;let _0x5b710e=a8_0x1b44[_0x252e26];return _0x5b710e;};'use strict';var __awaiter=this&&this[a8_0x5b71('0x10')]||function(_0x521c33,_0x500ee4,_0x4c26e,_0x3e893d){function _0x20d463(_0x37462d){return _0x37462d instanceof _0x4c26e?_0x37462d:new _0x4c26e(function(_0x4ea2bf){_0x4ea2bf(_0x37462d);});}return new(_0x4c26e||(_0x4c26e=Promise))(function(_0x270862,_0x45606d){function _0xb3d201(_0x40e9cf){try{_0x5662a0(_0x3e893d[a8_0x5b71('0xc')](_0x40e9cf));}catch(_0x161621){_0x45606d(_0x161621);}}function _0x28deba(_0x3caf0b){try{_0x5662a0(_0x3e893d[a8_0x5b71('0x12')](_0x3caf0b));}catch(_0x1079c9){_0x45606d(_0x1079c9);}}function _0x5662a0(_0x55bc28){_0x55bc28[a8_0x5b71('0x7')]?_0x270862(_0x55bc28[a8_0x5b71('0x8')]):_0x20d463(_0x55bc28[a8_0x5b71('0x8')])[a8_0x5b71('0x3')](_0xb3d201,_0x28deba);}_0x5662a0((_0x3e893d=_0x3e893d[a8_0x5b71('0x11')](_0x521c33,_0x500ee4||[]))[a8_0x5b71('0xc')]());});};Object[a8_0x5b71('0x1a')](exports,'__esModule',{'value':!![]});exports[a8_0x5b71('0x4')]=void 0x0;const {initTasksRunner}=require('../../../utilities/nx-imports');const parser=require(a8_0x5b71('0x9'));const serializer_overrides_1=require(a8_0x5b71('0x2'));function invokeTasksUsingNxImperativeApi(_0x2b69f4){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x389615=yield initTasksRunner(_0x2b69f4);return(_0x3d1644,_0xcfe968,_0x4c7a35)=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x5c7136=_0xcfe968[a8_0x5b71('0xf')](_0xdddd30=>{const _0x34dcd1=parser(_0xdddd30[a8_0x5b71('0xd')],{'configuration':{'camel-case-expansion':![],'dot-notation':!![]}});const _0x2a2bb1=(0x0,serializer_overrides_1['unparse'])(_0x34dcd1);if(_0x34dcd1['_'][a8_0x5b71('0x1b')]==0x0){delete _0x34dcd1['_'];}return{'id':_0xdddd30['taskId'],'target':{'project':_0xdddd30['projectName'],'target':_0xdddd30[a8_0x5b71('0x5')],'configuration':_0xdddd30[a8_0x5b71('0xa')]},'overrides':Object['assign'](Object[a8_0x5b71('0x19')]({},_0x34dcd1),{'__overrides_unparsed__':_0x2a2bb1})};});process[a8_0x5b71('0x16')][a8_0x5b71('0x6')]=a8_0x5b71('0x15');process[a8_0x5b71('0x16')][a8_0x5b71('0x1')]=_0x3d1644;process[a8_0x5b71('0x16')]['NX_STREAM_OUTPUT']='true';process[a8_0x5b71('0x16')][a8_0x5b71('0xe')]=a8_0x5b71('0x15');const _0x1dfeac=yield _0x389615[a8_0x5b71('0xb')]({'tasks':_0x5c7136,'parallel':_0x4c7a35});const _0x29c01f=Object[a8_0x5b71('0x13')](_0x1dfeac[a8_0x5b71('0x0')][a8_0x5b71('0x14')]);return{'completedTasks':_0x29c01f[a8_0x5b71('0xf')](_0x51c636=>({'taskId':_0x51c636['id'],'hash':_0x51c636[a8_0x5b71('0x18')]})),'completedStatusCode':_0x1dfeac[a8_0x5b71('0x17')]};});});}exports[a8_0x5b71('0x4')]=invokeTasksUsingNxImperativeApi;

@@ -1,97 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.invokeTasksUsingRunMany = void 0;
const environment_1 = require("../../../utilities/environment");
const child_process_1 = require("child_process");
const fs_1 = require("fs");
const { output } = require('../../../utilities/nx-imports-light');
const { cacheDirectory } = require('../../../utilities/nx-imports');
function invokeTasksUsingRunMany() {
return __awaiter(this, void 0, void 0, function* () {
const readCompleted = completedTasksReader();
return function invokeTasksUsingRunMany(executionId, tasksToExecute, parallel) {
return __awaiter(this, void 0, void 0, function* () {
let completedStatusCode = 0;
const completedTasks = [];
for (const g of groupByTarget(tasksToExecute)) {
const config = g.configuration
? `--configuration=${g.configuration}`
: ``;
const parallelStr = parallel > 1 ? ` --parallel --max-parallel=${parallel}` : ``;
// TODO use pnpx or yarn when needed
const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallelStr}`;
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Executing: '${command}'`,
});
}
try {
(0, child_process_1.execSync)(command, {
stdio: ['ignore', 'inherit', 'inherit'],
env: Object.assign(Object.assign({}, process.env), { NX_CACHE_FAILURES: 'true', NX_CLOUD_DISTRIBUTED_EXECUTION_ID: executionId, NX_STREAM_OUTPUT: 'true', NX_PREFIX_OUTPUT: 'true' }),
});
completedTasks.push(...readCompleted(executionId));
}
catch (e) {
if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
throw e;
}
else {
completedStatusCode = 1;
completedTasks.push(...readCompleted(executionId));
}
}
}
return { completedStatusCode, completedTasks };
});
};
});
}
exports.invokeTasksUsingRunMany = invokeTasksUsingRunMany;
function groupByTarget(tasks) {
const res = [];
tasks.forEach((t) => {
const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
if (r) {
r.projects.push(t.projectName);
}
else {
res.push({
target: t.target,
projects: [t.projectName],
params: t.params,
configuration: t.configuration,
});
}
});
return res;
}
function completedTasksReader() {
return (distributedExecutionId) => {
const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
let completedTasks;
try {
const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
// remove it such that if the next command crashes we don't read an obsolete file
(0, fs_1.unlinkSync)(taskHashesFile);
}
catch (e) {
throw new Error(errorMessage);
}
if (completedTasks.length == 0) {
throw new Error(errorMessage);
}
return completedTasks;
};
}
//# sourceMappingURL=invoke-tasks-using-run-many.js.map
const a9_0x56bd=['__awaiter','true','../../../utilities/nx-imports-light','configuration','forEach','apply','find','invokeTasksUsingRunMany','length','projects','--configuration=','\x20--parallel\x20--max-parallel=','../../../utilities/nx-imports','toString','parse','value','done','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','then','next','ignore','unlinkSync','defineProperty','__esModule','throw','params','VERBOSE_LOGGING','execSync','target','assign','child_process','Executing:\x20\x27','../../../utilities/environment','push','projectName','inherit','status','note'];(function(_0x45be45,_0x56bd72){const _0x54fc3b=function(_0x133537){while(--_0x133537){_0x45be45['push'](_0x45be45['shift']());}};_0x54fc3b(++_0x56bd72);}(a9_0x56bd,0x189));const a9_0x54fc=function(_0x45be45,_0x56bd72){_0x45be45=_0x45be45-0x0;let _0x54fc3b=a9_0x56bd[_0x45be45];return _0x54fc3b;};'use strict';var __awaiter=this&&this[a9_0x54fc('0x19')]||function(_0x3c224c,_0x76e2ad,_0x162314,_0x2e6f0b){function _0x55dde3(_0x487660){return _0x487660 instanceof _0x162314?_0x487660:new _0x162314(function(_0x1b4f4a){_0x1b4f4a(_0x487660);});}return new(_0x162314||(_0x162314=Promise))(function(_0x4969a8,_0xf910a4){function _0x4451b2(_0xb5ac90){try{_0x5bf0e4(_0x2e6f0b[a9_0x54fc('0x6')](_0xb5ac90));}catch(_0x459dad){_0xf910a4(_0x459dad);}}function _0x473a23(_0x5400a5){try{_0x5bf0e4(_0x2e6f0b[a9_0x54fc('0xb')](_0x5400a5));}catch(_0x4b709f){_0xf910a4(_0x4b709f);}}function _0x5bf0e4(_0x2d486c){_0x2d486c[a9_0x54fc('0x3')]?_0x4969a8(_0x2d486c[a9_0x54fc('0x2')]):_0x55dde3(_0x2d486c[a9_0x54fc('0x2')])[a9_0x54fc('0x5')](_0x4451b2,_0x473a23);}_0x5bf0e4((_0x2e6f0b=_0x2e6f0b[a9_0x54fc('0x1e')](_0x3c224c,_0x76e2ad||[]))[a9_0x54fc('0x6')]());});};Object[a9_0x54fc('0x9')](exports,a9_0x54fc('0xa'),{'value':!![]});exports[a9_0x54fc('0x20')]=void 0x0;const environment_1=require(a9_0x54fc('0x13'));const child_process_1=require(a9_0x54fc('0x11'));const fs_1=require('fs');const {output}=require(a9_0x54fc('0x1b'));const {cacheDirectory}=require(a9_0x54fc('0x25'));function invokeTasksUsingRunMany(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x292adc=completedTasksReader();return function _0x56ad0a(_0x220367,_0x2036a6,_0x233796){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x578385=0x0;const _0x45f973=[];for(const _0x264eac of groupByTarget(_0x2036a6)){const _0x534156=_0x264eac[a9_0x54fc('0x1c')]?a9_0x54fc('0x23')+_0x264eac[a9_0x54fc('0x1c')]:'';const _0xd31c3b=_0x233796>0x1?a9_0x54fc('0x24')+_0x233796:'';const _0x3b717e='npx\x20nx\x20run-many\x20--target='+_0x264eac[a9_0x54fc('0xf')]+'\x20'+_0x534156+'\x20--projects='+_0x264eac[a9_0x54fc('0x22')]['join'](',')+'\x20'+_0x264eac[a9_0x54fc('0xc')]+_0xd31c3b;if(environment_1[a9_0x54fc('0xd')]){output[a9_0x54fc('0x18')]({'title':a9_0x54fc('0x12')+_0x3b717e+'\x27'});}try{(0x0,child_process_1[a9_0x54fc('0xe')])(_0x3b717e,{'stdio':[a9_0x54fc('0x7'),a9_0x54fc('0x16'),a9_0x54fc('0x16')],'env':Object['assign'](Object[a9_0x54fc('0x10')]({},process['env']),{'NX_CACHE_FAILURES':a9_0x54fc('0x1a'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x220367,'NX_STREAM_OUTPUT':a9_0x54fc('0x1a'),'NX_PREFIX_OUTPUT':'true'})});_0x45f973[a9_0x54fc('0x14')](..._0x292adc(_0x220367));}catch(_0x6d9770){if(_0x6d9770[a9_0x54fc('0x17')]===environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']){throw _0x6d9770;}else{_0x578385=0x1;_0x45f973[a9_0x54fc('0x14')](..._0x292adc(_0x220367));}}}return{'completedStatusCode':_0x578385,'completedTasks':_0x45f973};});};});}exports[a9_0x54fc('0x20')]=invokeTasksUsingRunMany;function groupByTarget(_0x1f8ab2){const _0x2662b7=[];_0x1f8ab2[a9_0x54fc('0x1d')](_0x4bdefa=>{const _0x5f3ac9=_0x2662b7[a9_0x54fc('0x1f')](_0xf01d1e=>_0xf01d1e[a9_0x54fc('0xf')]===_0x4bdefa[a9_0x54fc('0xf')]&&_0xf01d1e[a9_0x54fc('0x1c')]===_0x4bdefa[a9_0x54fc('0x1c')]);if(_0x5f3ac9){_0x5f3ac9['projects'][a9_0x54fc('0x14')](_0x4bdefa[a9_0x54fc('0x15')]);}else{_0x2662b7[a9_0x54fc('0x14')]({'target':_0x4bdefa[a9_0x54fc('0xf')],'projects':[_0x4bdefa[a9_0x54fc('0x15')]],'params':_0x4bdefa[a9_0x54fc('0xc')],'configuration':_0x4bdefa[a9_0x54fc('0x1c')]});}});return _0x2662b7;}function completedTasksReader(){return _0x1712e5=>{const _0x4ee0c7=a9_0x54fc('0x4')+_0x1712e5+').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.';let _0x2b521e;try{const _0x218f86=cacheDirectory+'/tasks-hashes-'+_0x1712e5;_0x2b521e=JSON[a9_0x54fc('0x1')]((0x0,fs_1['readFileSync'])(_0x218f86)[a9_0x54fc('0x0')]());(0x0,fs_1[a9_0x54fc('0x8')])(_0x218f86);}catch(_0x4bf7c6){throw new Error(_0x4ee0c7);}if(_0x2b521e[a9_0x54fc('0x21')]==0x0){throw new Error(_0x4ee0c7);}return _0x2b521e;};}

@@ -1,154 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createStartRequest = exports.DistributedExecutionApi = void 0;
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const metric_logger_1 = require("../../../utilities/metric-logger");
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
const { output } = require('../../../utilities/nx-imports-light');
class DistributedExecutionApi {
constructor(options) {
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
start(params) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const recorder = (0, metric_logger_1.createMetricRecorder)('dteStart');
let resp;
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Starting a distributed execution',
bodyLines: [JSON.stringify(params, null, 2)],
});
}
try {
resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/start', params));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
throw e;
}
if (!resp.data.enabled) {
throw new Error(`Workspace is disabled. Cannot perform distributed task executions.`);
}
if (resp.data.error) {
throw new Error(resp.data.error);
}
return resp.data.id;
});
}
status(id) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const recorder = (0, metric_logger_1.createMetricRecorder)('dteStatus');
try {
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/status', {
id,
}));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
return resp.data;
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
output.error({
title: e.message,
});
process.exit(1);
}
});
}
completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, error) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Completing with an error',
bodyLines: [
`ciExecutionId: ${ciExecutionId}`,
`ciExecutionEnv: ${ciExecutionEnv}`,
`runGroup: ${runGroup}`,
`error: ${error}`,
],
});
}
try {
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
branch,
runGroup,
ciExecutionId,
ciExecutionEnv,
criticalErrorMessage: error,
}), 3);
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
}
});
}
}
exports.DistributedExecutionApi = DistributedExecutionApi;
function createStartRequest(branch, runGroup, ciExecutionId, ciExecutionEnv, task, options, commitSha) {
const tasksToExecute = task.map((arr) => {
return arr.map((t) => {
return {
taskId: t.id,
hash: t.hash,
projectName: t.target.project,
target: t.target.target,
configuration: t.target.configuration || null,
params: (0, serializer_overrides_1.serializeOverrides)(t),
};
});
});
const request = {
command: (0, environment_1.parseCommand)(),
branch,
runGroup,
ciExecutionId,
ciExecutionEnv,
tasks: tasksToExecute,
maxParallel: calculateMaxParallel(options),
commitSha,
};
if (environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT) {
request.agentCount = environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT;
}
if (!environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE) {
request.stopAgentsOnFailure = false;
}
return request;
}
exports.createStartRequest = createStartRequest;
function calculateMaxParallel(options) {
if (options.parallel === 'false' || options.parallel === false) {
return 1;
}
else if (options.parallel === 'true' || options.parallel === true) {
return Number(options.maxParallel || 3);
}
else if (options.parallel === undefined) {
return options.maxParallel ? Number(options.maxParallel) : 3;
}
else {
return Number(options.parallel) || 3;
}
}
//# sourceMappingURL=distributed-execution.api.js.map
const a10_0x2fc3=['completeRunGroupWithError','response','done','createMetricRecorder','parallel','../../../utilities/serializer-overrides','note','data','ciExecutionId:\x20','maxParallel','__awaiter','ciExecutionEnv:\x20','../../../utilities/nx-imports-light','../../../utilities/axios','VERBOSE_LOGGING','createApiAxiosInstance','Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.','then','../../../utilities/metric-logger','project','RUNNER_FAILURE_PERF_ENTRY','mapRespToPerfEntry','axiosException','../../../utilities/environment','DistributedExecutionApi','map','completeRunGroup','axiosMultipleTries','false','error','NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE','recordMetric','next','error:\x20','dteStatus','configuration','enabled','target','runGroup:\x20','agentCount','/nx-cloud/executions/start','value','apiAxiosInstance','defineProperty','throw','serializeOverrides','stopAgentsOnFailure','createStartRequest','post','dteStart','message','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','hash'];(function(_0x15e2e8,_0x2fc389){const _0x286c80=function(_0x26b387){while(--_0x26b387){_0x15e2e8['push'](_0x15e2e8['shift']());}};_0x286c80(++_0x2fc389);}(a10_0x2fc3,0xbf));const a10_0x286c=function(_0x15e2e8,_0x2fc389){_0x15e2e8=_0x15e2e8-0x0;let _0x286c80=a10_0x2fc3[_0x15e2e8];return _0x286c80;};'use strict';var __awaiter=this&&this[a10_0x286c('0x1f')]||function(_0xc51bb5,_0x4f2fe4,_0x20f491,_0x169768){function _0x37f194(_0xcbb544){return _0xcbb544 instanceof _0x20f491?_0xcbb544:new _0x20f491(function(_0x1ee696){_0x1ee696(_0xcbb544);});}return new(_0x20f491||(_0x20f491=Promise))(function(_0xf32f98,_0x44737f){function _0x15dbf0(_0x2d0527){try{_0x4b41ed(_0x169768[a10_0x286c('0x0')](_0x2d0527));}catch(_0x3e44ce){_0x44737f(_0x3e44ce);}}function _0x485887(_0x524294){try{_0x4b41ed(_0x169768[a10_0x286c('0xc')](_0x524294));}catch(_0x402185){_0x44737f(_0x402185);}}function _0x4b41ed(_0xb5d64c){_0xb5d64c[a10_0x286c('0x17')]?_0xf32f98(_0xb5d64c['value']):_0x37f194(_0xb5d64c[a10_0x286c('0x9')])[a10_0x286c('0x26')](_0x15dbf0,_0x485887);}_0x4b41ed((_0x169768=_0x169768['apply'](_0xc51bb5,_0x4f2fe4||[]))['next']());});};Object[a10_0x286c('0xb')](exports,'__esModule',{'value':!![]});exports['createStartRequest']=exports['DistributedExecutionApi']=void 0x0;const axios_1=require(a10_0x286c('0x22'));const environment_1=require(a10_0x286c('0x2c'));const metric_logger_1=require(a10_0x286c('0x27'));const serializer_overrides_1=require(a10_0x286c('0x1a'));const {output}=require(a10_0x286c('0x21'));class DistributedExecutionApi{constructor(_0x2f809c){this[a10_0x286c('0xa')]=(0x0,axios_1[a10_0x286c('0x24')])(_0x2f809c);}['start'](_0x2da6aa){var _0x48d76b;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1b0bac=(0x0,metric_logger_1[a10_0x286c('0x18')])(a10_0x286c('0x11'));let _0x8d952d;if(environment_1[a10_0x286c('0x23')]){output['note']({'title':'Starting\x20a\x20distributed\x20execution','bodyLines':[JSON['stringify'](_0x2da6aa,null,0x2)]});}try{_0x8d952d=yield(0x0,axios_1[a10_0x286c('0x30')])(()=>this[a10_0x286c('0xa')]['post'](a10_0x286c('0x8'),_0x2da6aa));_0x1b0bac[a10_0x286c('0x34')]((0x0,metric_logger_1[a10_0x286c('0x2a')])(_0x8d952d));}catch(_0x4abfe8){_0x1b0bac[a10_0x286c('0x34')](((_0x48d76b=_0x4abfe8===null||_0x4abfe8===void 0x0?void 0x0:_0x4abfe8['axiosException'])===null||_0x48d76b===void 0x0?void 0x0:_0x48d76b['response'])?(0x0,metric_logger_1[a10_0x286c('0x2a')])(_0x4abfe8[a10_0x286c('0x2b')][a10_0x286c('0x16')]):metric_logger_1[a10_0x286c('0x29')]);throw _0x4abfe8;}if(!_0x8d952d[a10_0x286c('0x1c')][a10_0x286c('0x4')]){throw new Error(a10_0x286c('0x25'));}if(_0x8d952d[a10_0x286c('0x1c')][a10_0x286c('0x32')]){throw new Error(_0x8d952d[a10_0x286c('0x1c')][a10_0x286c('0x32')]);}return _0x8d952d[a10_0x286c('0x1c')]['id'];});}['status'](_0x1013b0){var _0x3d1362;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4fdf9d=(0x0,metric_logger_1[a10_0x286c('0x18')])(a10_0x286c('0x2'));try{const _0x322782=yield(0x0,axios_1[a10_0x286c('0x30')])(()=>this[a10_0x286c('0xa')][a10_0x286c('0x10')]('/nx-cloud/executions/status',{'id':_0x1013b0}));_0x4fdf9d[a10_0x286c('0x34')]((0x0,metric_logger_1[a10_0x286c('0x2a')])(_0x322782));return _0x322782['data'];}catch(_0x28abd1){_0x4fdf9d['recordMetric'](((_0x3d1362=_0x28abd1===null||_0x28abd1===void 0x0?void 0x0:_0x28abd1[a10_0x286c('0x2b')])===null||_0x3d1362===void 0x0?void 0x0:_0x3d1362[a10_0x286c('0x16')])?(0x0,metric_logger_1[a10_0x286c('0x2a')])(_0x28abd1['axiosException'][a10_0x286c('0x16')]):metric_logger_1[a10_0x286c('0x29')]);output['error']({'title':_0x28abd1[a10_0x286c('0x12')]});process['exit'](0x1);}});}[a10_0x286c('0x15')](_0x1761e3,_0xdd39bb,_0x289dec,_0x5310b8,_0xff4b26){var _0xcc7658;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x550184=(0x0,metric_logger_1[a10_0x286c('0x18')])(a10_0x286c('0x2f'));if(environment_1[a10_0x286c('0x23')]){output[a10_0x286c('0x1b')]({'title':'Completing\x20with\x20an\x20error','bodyLines':[a10_0x286c('0x1d')+_0x289dec,a10_0x286c('0x20')+_0x5310b8,a10_0x286c('0x6')+_0xdd39bb,a10_0x286c('0x1')+_0xff4b26]});}try{const _0x252a5c=yield(0x0,axios_1[a10_0x286c('0x30')])(()=>this[a10_0x286c('0xa')][a10_0x286c('0x10')]('/nx-cloud/executions/complete-run-group',{'branch':_0x1761e3,'runGroup':_0xdd39bb,'ciExecutionId':_0x289dec,'ciExecutionEnv':_0x5310b8,'criticalErrorMessage':_0xff4b26}),0x3);_0x550184[a10_0x286c('0x34')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x252a5c));}catch(_0x548b0b){_0x550184['recordMetric'](((_0xcc7658=_0x548b0b===null||_0x548b0b===void 0x0?void 0x0:_0x548b0b[a10_0x286c('0x2b')])===null||_0xcc7658===void 0x0?void 0x0:_0xcc7658[a10_0x286c('0x16')])?(0x0,metric_logger_1[a10_0x286c('0x2a')])(_0x548b0b[a10_0x286c('0x2b')][a10_0x286c('0x16')]):metric_logger_1[a10_0x286c('0x29')]);}});}}exports[a10_0x286c('0x2d')]=DistributedExecutionApi;function createStartRequest(_0x189c60,_0x3072d2,_0x461e7c,_0x431644,_0xd1b92c,_0x380335,_0x2d9669){const _0x345d11=_0xd1b92c[a10_0x286c('0x2e')](_0x1d57b1=>{return _0x1d57b1[a10_0x286c('0x2e')](_0x2778ff=>{return{'taskId':_0x2778ff['id'],'hash':_0x2778ff[a10_0x286c('0x14')],'projectName':_0x2778ff[a10_0x286c('0x5')][a10_0x286c('0x28')],'target':_0x2778ff[a10_0x286c('0x5')][a10_0x286c('0x5')],'configuration':_0x2778ff[a10_0x286c('0x5')][a10_0x286c('0x3')]||null,'params':(0x0,serializer_overrides_1[a10_0x286c('0xd')])(_0x2778ff)};});});const _0xbdb4fd={'command':(0x0,environment_1['parseCommand'])(),'branch':_0x189c60,'runGroup':_0x3072d2,'ciExecutionId':_0x461e7c,'ciExecutionEnv':_0x431644,'tasks':_0x345d11,'maxParallel':calculateMaxParallel(_0x380335),'commitSha':_0x2d9669};if(environment_1[a10_0x286c('0x13')]){_0xbdb4fd[a10_0x286c('0x7')]=environment_1[a10_0x286c('0x13')];}if(!environment_1[a10_0x286c('0x33')]){_0xbdb4fd[a10_0x286c('0xe')]=![];}return _0xbdb4fd;}exports[a10_0x286c('0xf')]=createStartRequest;function calculateMaxParallel(_0x4327a9){if(_0x4327a9[a10_0x286c('0x19')]===a10_0x286c('0x31')||_0x4327a9['parallel']===![]){return 0x1;}else if(_0x4327a9[a10_0x286c('0x19')]==='true'||_0x4327a9[a10_0x286c('0x19')]===!![]){return Number(_0x4327a9[a10_0x286c('0x1e')]||0x3);}else if(_0x4327a9[a10_0x286c('0x19')]===undefined){return _0x4327a9['maxParallel']?Number(_0x4327a9[a10_0x286c('0x1e')]):0x3;}else{return Number(_0x4327a9[a10_0x286c('0x19')])||0x3;}}

@@ -1,121 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.nxCloudDistributedTasksRunner = void 0;
const environment_1 = require("../../../utilities/environment");
const metric_logger_1 = require("../../../utilities/metric-logger");
const error_reporter_api_1 = require("../../api/error-reporter.api");
const print_run_group_error_1 = require("../../error/print-run-group-error");
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
const file_storage_1 = require("../../file-storage/file-storage");
const distributed_execution_api_1 = require("./distributed-execution.api");
const split_task_graph_into_stages_1 = require("./split-task-graph-into-stages");
const task_graph_creator_1 = require("./task-graph-creator");
const process_tasks_1 = require("./process-tasks");
const dte_artifact_storage_1 = require("../../../utilities/dte-artifact-storage");
const { output } = require('../../../utilities/nx-imports-light');
const { cacheDirectory } = require('../../../utilities/nx-imports');
class NoopLifeCycle {
scheduleTask(task) { }
startTask(task) { }
endTasks(tasks) { }
}
const nxCloudDistributedTasksRunner = (tasks, options, context) => __awaiter(void 0, void 0, void 0, function* () {
if (options.skipNxCache) {
output.warn({
title: `--skip-nx-cache is ignored when using distributed tasks execution (DTE).`,
bodyLine: [`DTE needs the cache to share files between agents.`],
});
}
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Starting distributed command execution',
});
}
options.lifeCycle = new NoopLifeCycle();
const branch = (0, environment_1.getBranch)();
const runGroup = (0, environment_1.getRunGroup)();
const ciExecutionId = (0, environment_1.getCIExecutionId)();
const ciExecutionEnv = (0, environment_1.getCIExecutionEnv)();
const commitSha = (0, environment_1.extractGitSha)();
const commitRef = (0, environment_1.extractGitRef)();
if (!(0, print_run_group_error_1.canDetectRunGroup)(runGroup, ciExecutionId)) {
(0, print_run_group_error_1.printRunGroupError)();
process.exit(1);
}
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
const errorReporter = new error_reporter_api_1.ErrorReporterApi(options);
const dteArtifactStorage = new dte_artifact_storage_1.DteArtifactStorage(new file_storage_1.FileStorage(encryption, errorReporter, options, 'dte-main'), cacheDirectory);
const api = new distributed_execution_api_1.DistributedExecutionApi(options);
attachSignalListenersToCompleteRunGroupOnError(api, branch, runGroup, ciExecutionId, ciExecutionEnv);
try {
const taskGraph = getTaskGraph(context, tasks, options);
const r = yield runDistributedExecution(api, options, dteArtifactStorage, branch, runGroup, ciExecutionId, ciExecutionEnv, taskGraph, commitSha, commitRef);
if (r.commandStatus === 0) {
output.success({
title: 'Successfully completed running the command.',
bodyLines: [`See run details at ${r.runUrl}`],
});
}
else {
output.error({
title: 'Command execution failed.',
bodyLines: [`See run details at ${r.runUrl}`],
});
}
yield (0, metric_logger_1.submitRunMetrics)(options);
process.exit(r.commandStatus);
}
catch (e) {
output.error({
title: 'Unable to complete a run.',
bodyLines: [e.message],
});
if (e.axiosException) {
console.log(e.axiosException);
}
else {
console.log(e);
}
try {
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, `Main job terminated with an error: "${e.message}"`);
}
finally {
process.exit(1);
}
}
});
exports.nxCloudDistributedTasksRunner = nxCloudDistributedTasksRunner;
function getTaskGraph(context, tasks, options) {
if (context.taskGraph) {
return context.taskGraph;
}
else {
return (0, task_graph_creator_1.createTaskGraphCompat)(options, context.projectGraph, tasks);
}
}
function attachSignalListenersToCompleteRunGroupOnError(api, branch, runGroup, ciExecutionId, ciExecutionEnv) {
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, 'Main job was terminated via SIGINT');
process.exit(1);
}));
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, 'Main job was terminated via SIGTERM');
process.exit(1);
}));
}
function runDistributedExecution(api, options, dteArtifactStorage, branch, runGroup, ciExecutionId, ciExecutionEnv, taskGraph, commitSha, commitRef) {
return __awaiter(this, void 0, void 0, function* () {
const id = yield api.start((0, distributed_execution_api_1.createStartRequest)(branch, runGroup, ciExecutionId, ciExecutionEnv, (0, split_task_graph_into_stages_1.splitTasksIntoStages)(taskGraph), options, commitSha));
return yield (0, process_tasks_1.processTasks)(api, dteArtifactStorage, id, Object.values(taskGraph.tasks));
});
}
//# sourceMappingURL=distributed-execution.runner.js.map
const a11_0x5508=['Starting\x20distributed\x20command\x20execution','projectGraph','SIGTERM','./distributed-execution.api','extractGitSha','completeRunGroupWithError','defineProperty','ENCRYPTION_KEY','value','../../../utilities/metric-logger','log','message','canDetectRunGroup','../../../utilities/environment','dte-main','Successfully\x20completed\x20running\x20the\x20command.','splitTasksIntoStages','throw','commandStatus','--skip-nx-cache\x20is\x20ignored\x20when\x20using\x20distributed\x20tasks\x20execution\x20(DTE).','submitRunMetrics','Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','__awaiter','Command\x20execution\x20failed.','lifeCycle','tasks','E2EEncryption','../../file-storage/file-storage','taskGraph','Main\x20job\x20was\x20terminated\x20via\x20SIGINT','warn','axiosException','../../../utilities/nx-imports-light','values','exit','../../../utilities/dte-artifact-storage','getCIExecutionEnv','apply','SIGINT','FileStorage','processTasks','error','getBranch','extractGitRef','VERBOSE_LOGGING','getCIExecutionId','start','done','DistributedExecutionApi','See\x20run\x20details\x20at\x20','scheduleTask','../../error/print-run-group-error','nxCloudDistributedTasksRunner','Unable\x20to\x20complete\x20a\x20run.','DTE\x20needs\x20the\x20cache\x20to\x20share\x20files\x20between\x20agents.','endTasks','skipNxCache','./task-graph-creator','success','./process-tasks','../../../utilities/nx-imports','../../api/error-reporter.api','ErrorReporterApi','createTaskGraphCompat','note','then','encryptionKey'];(function(_0x55bb2b,_0x55080a){const _0x5437ea=function(_0x2e2d85){while(--_0x2e2d85){_0x55bb2b['push'](_0x55bb2b['shift']());}};_0x5437ea(++_0x55080a);}(a11_0x5508,0x1cc));const a11_0x5437=function(_0x55bb2b,_0x55080a){_0x55bb2b=_0x55bb2b-0x0;let _0x5437ea=a11_0x5508[_0x55bb2b];return _0x5437ea;};'use strict';var __awaiter=this&&this[a11_0x5437('0x1f')]||function(_0x33244e,_0x4ba0ca,_0x2512c2,_0x4d2416){function _0x208f8f(_0x4c1c34){return _0x4c1c34 instanceof _0x2512c2?_0x4c1c34:new _0x2512c2(function(_0x2a9b74){_0x2a9b74(_0x4c1c34);});}return new(_0x2512c2||(_0x2512c2=Promise))(function(_0x13725b,_0x2158db){function _0x43455d(_0x25a1c4){try{_0x4cf7be(_0x4d2416['next'](_0x25a1c4));}catch(_0x442e00){_0x2158db(_0x442e00);}}function _0x9ce150(_0x154c3a){try{_0x4cf7be(_0x4d2416[a11_0x5437('0x1a')](_0x154c3a));}catch(_0x2e88b0){_0x2158db(_0x2e88b0);}}function _0x4cf7be(_0x18ddfc){_0x18ddfc[a11_0x5437('0x38')]?_0x13725b(_0x18ddfc[a11_0x5437('0x11')]):_0x208f8f(_0x18ddfc[a11_0x5437('0x11')])[a11_0x5437('0x7')](_0x43455d,_0x9ce150);}_0x4cf7be((_0x4d2416=_0x4d2416[a11_0x5437('0x2e')](_0x33244e,_0x4ba0ca||[]))['next']());});};Object[a11_0x5437('0xf')](exports,'__esModule',{'value':!![]});exports[a11_0x5437('0x3d')]=void 0x0;const environment_1=require(a11_0x5437('0x16'));const metric_logger_1=require(a11_0x5437('0x12'));const error_reporter_api_1=require(a11_0x5437('0x3'));const print_run_group_error_1=require(a11_0x5437('0x3c'));const e2e_encryption_1=require('../../file-storage/e2e-encryption');const file_storage_1=require(a11_0x5437('0x24'));const distributed_execution_api_1=require(a11_0x5437('0xc'));const split_task_graph_into_stages_1=require('./split-task-graph-into-stages');const task_graph_creator_1=require(a11_0x5437('0x42'));const process_tasks_1=require(a11_0x5437('0x1'));const dte_artifact_storage_1=require(a11_0x5437('0x2c'));const {output}=require(a11_0x5437('0x29'));const {cacheDirectory}=require(a11_0x5437('0x2'));class NoopLifeCycle{[a11_0x5437('0x3b')](_0x295cdc){}['startTask'](_0x47ff41){}[a11_0x5437('0x40')](_0x742e76){}}const nxCloudDistributedTasksRunner=(_0x2a531a,_0x476d77,_0x5bf5af)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(_0x476d77[a11_0x5437('0x41')]){output[a11_0x5437('0x27')]({'title':a11_0x5437('0x1c'),'bodyLine':[a11_0x5437('0x3f')]});}if(environment_1[a11_0x5437('0x35')]){output[a11_0x5437('0x6')]({'title':a11_0x5437('0x9')});}_0x476d77[a11_0x5437('0x21')]=new NoopLifeCycle();const _0x4f50d8=(0x0,environment_1[a11_0x5437('0x33')])();const _0x236c29=(0x0,environment_1['getRunGroup'])();const _0x5273a2=(0x0,environment_1[a11_0x5437('0x36')])();const _0x20449f=(0x0,environment_1[a11_0x5437('0x2d')])();const _0x29cf90=(0x0,environment_1[a11_0x5437('0xd')])();const _0x4464d9=(0x0,environment_1[a11_0x5437('0x34')])();if(!(0x0,print_run_group_error_1[a11_0x5437('0x15')])(_0x236c29,_0x5273a2)){(0x0,print_run_group_error_1['printRunGroupError'])();process[a11_0x5437('0x2b')](0x1);}const _0x174128=new e2e_encryption_1[(a11_0x5437('0x23'))](environment_1[a11_0x5437('0x10')]||_0x476d77[a11_0x5437('0x8')]);const _0x43665b=new error_reporter_api_1[(a11_0x5437('0x4'))](_0x476d77);const _0x17ffdf=new dte_artifact_storage_1['DteArtifactStorage'](new file_storage_1[(a11_0x5437('0x30'))](_0x174128,_0x43665b,_0x476d77,a11_0x5437('0x17')),cacheDirectory);const _0x26cf85=new distributed_execution_api_1[(a11_0x5437('0x39'))](_0x476d77);attachSignalListenersToCompleteRunGroupOnError(_0x26cf85,_0x4f50d8,_0x236c29,_0x5273a2,_0x20449f);try{const _0xf6ecb6=getTaskGraph(_0x5bf5af,_0x2a531a,_0x476d77);const _0xeca5bf=yield runDistributedExecution(_0x26cf85,_0x476d77,_0x17ffdf,_0x4f50d8,_0x236c29,_0x5273a2,_0x20449f,_0xf6ecb6,_0x29cf90,_0x4464d9);if(_0xeca5bf[a11_0x5437('0x1b')]===0x0){output[a11_0x5437('0x0')]({'title':a11_0x5437('0x18'),'bodyLines':[a11_0x5437('0x3a')+_0xeca5bf['runUrl']]});}else{output['error']({'title':a11_0x5437('0x20'),'bodyLines':[a11_0x5437('0x3a')+_0xeca5bf['runUrl']]});}yield(0x0,metric_logger_1[a11_0x5437('0x1d')])(_0x476d77);process[a11_0x5437('0x2b')](_0xeca5bf['commandStatus']);}catch(_0x37ca7f){output[a11_0x5437('0x32')]({'title':a11_0x5437('0x3e'),'bodyLines':[_0x37ca7f['message']]});if(_0x37ca7f[a11_0x5437('0x28')]){console[a11_0x5437('0x13')](_0x37ca7f['axiosException']);}else{console['log'](_0x37ca7f);}try{yield _0x26cf85[a11_0x5437('0xe')](_0x4f50d8,_0x236c29,_0x5273a2,_0x20449f,a11_0x5437('0x1e')+_0x37ca7f[a11_0x5437('0x14')]+'\x22');}finally{process[a11_0x5437('0x2b')](0x1);}}});exports[a11_0x5437('0x3d')]=nxCloudDistributedTasksRunner;function getTaskGraph(_0x431653,_0x2ae076,_0x160dec){if(_0x431653[a11_0x5437('0x25')]){return _0x431653[a11_0x5437('0x25')];}else{return(0x0,task_graph_creator_1[a11_0x5437('0x5')])(_0x160dec,_0x431653[a11_0x5437('0xa')],_0x2ae076);}}function attachSignalListenersToCompleteRunGroupOnError(_0x2634e0,_0x221a72,_0xa3269b,_0x294a6c,_0x30f510){process['on'](a11_0x5437('0x2f'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x2634e0[a11_0x5437('0xe')](_0x221a72,_0xa3269b,_0x294a6c,_0x30f510,a11_0x5437('0x26'));process[a11_0x5437('0x2b')](0x1);}));process['on'](a11_0x5437('0xb'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x2634e0['completeRunGroupWithError'](_0x221a72,_0xa3269b,_0x294a6c,_0x30f510,'Main\x20job\x20was\x20terminated\x20via\x20SIGTERM');process[a11_0x5437('0x2b')](0x1);}));}function runDistributedExecution(_0x5e148f,_0x326aca,_0x4eeaf6,_0x43e430,_0x4bff29,_0x51a3ea,_0x4d354b,_0x3f78c0,_0x2977e0,_0x5d5987){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2afcc7=yield _0x5e148f[a11_0x5437('0x37')]((0x0,distributed_execution_api_1['createStartRequest'])(_0x43e430,_0x4bff29,_0x51a3ea,_0x4d354b,(0x0,split_task_graph_into_stages_1[a11_0x5437('0x19')])(_0x3f78c0),_0x326aca,_0x2977e0));return yield(0x0,process_tasks_1[a11_0x5437('0x31')])(_0x5e148f,_0x4eeaf6,_0x2afcc7,Object[a11_0x5437('0x2a')](_0x3f78c0[a11_0x5437('0x22')]));});}

@@ -1,45 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.processTask = void 0;
const environment_1 = require("../../../utilities/environment");
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
const { output } = require('../../../utilities/nx-imports-light');
function processTask(dteArtifactStorage, tasks, completedTask) {
return __awaiter(this, void 0, void 0, function* () {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Processing task ${completedTask.taskId}`,
});
}
const matchingTask = tasks.find((tt) => completedTask.taskId === tt.id);
if (!matchingTask) {
throw new Error(`Found unknown task: ${completedTask.taskId}`);
}
const terminalOutput = yield dteArtifactStorage.retrieveAndExtract(completedTask.hash, completedTask.url);
output.logCommand(getCommand(matchingTask));
process.stdout.write(terminalOutput);
output.addVerticalSeparator();
});
}
exports.processTask = processTask;
function getCommand(task) {
const config = task.target.configuration
? `:${task.target.configuration}`
: '';
return [
'nx',
'run',
`${task.target.project}:${task.target.target}${config}`,
(0, serializer_overrides_1.serializeOverrides)(task),
].join(' ');
}
//# sourceMappingURL=process-task.js.map
const a12_0x5b9f=['apply','project','processTask','url','logCommand','done','find','../../../utilities/environment','note','VERBOSE_LOGGING','taskId','stdout','run','../../../utilities/nx-imports-light','target','then','join','write','value','retrieveAndExtract','next','__esModule','Found\x20unknown\x20task:\x20'];(function(_0x58e290,_0x5b9f7e){const _0x38fdc9=function(_0x4b3611){while(--_0x4b3611){_0x58e290['push'](_0x58e290['shift']());}};_0x38fdc9(++_0x5b9f7e);}(a12_0x5b9f,0x1d9));const a12_0x38fd=function(_0x58e290,_0x5b9f7e){_0x58e290=_0x58e290-0x0;let _0x38fdc9=a12_0x5b9f[_0x58e290];return _0x38fdc9;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x24d277,_0x56717d,_0x4fb0f3,_0x5e1cd1){function _0x589c44(_0x2c4e3e){return _0x2c4e3e instanceof _0x4fb0f3?_0x2c4e3e:new _0x4fb0f3(function(_0xab6c9e){_0xab6c9e(_0x2c4e3e);});}return new(_0x4fb0f3||(_0x4fb0f3=Promise))(function(_0x41e59c,_0x19d4f3){function _0x4dfdf5(_0xaf139d){try{_0x343a02(_0x5e1cd1['next'](_0xaf139d));}catch(_0x258211){_0x19d4f3(_0x258211);}}function _0x30af97(_0x4c478f){try{_0x343a02(_0x5e1cd1['throw'](_0x4c478f));}catch(_0x255831){_0x19d4f3(_0x255831);}}function _0x343a02(_0x3d7aee){_0x3d7aee[a12_0x38fd('0xf')]?_0x41e59c(_0x3d7aee['value']):_0x589c44(_0x3d7aee[a12_0x38fd('0x5')])[a12_0x38fd('0x2')](_0x4dfdf5,_0x30af97);}_0x343a02((_0x5e1cd1=_0x5e1cd1[a12_0x38fd('0xa')](_0x24d277,_0x56717d||[]))[a12_0x38fd('0x7')]());});};Object['defineProperty'](exports,a12_0x38fd('0x8'),{'value':!![]});exports[a12_0x38fd('0xc')]=void 0x0;const environment_1=require(a12_0x38fd('0x11'));const serializer_overrides_1=require('../../../utilities/serializer-overrides');const {output}=require(a12_0x38fd('0x0'));function processTask(_0x11384f,_0x58c72e,_0x3607d5){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a12_0x38fd('0x13')]){output[a12_0x38fd('0x12')]({'title':'Processing\x20task\x20'+_0x3607d5['taskId']});}const _0x1756e3=_0x58c72e[a12_0x38fd('0x10')](_0x5254a3=>_0x3607d5['taskId']===_0x5254a3['id']);if(!_0x1756e3){throw new Error(a12_0x38fd('0x9')+_0x3607d5[a12_0x38fd('0x14')]);}const _0x4988d7=yield _0x11384f[a12_0x38fd('0x6')](_0x3607d5['hash'],_0x3607d5[a12_0x38fd('0xd')]);output[a12_0x38fd('0xe')](getCommand(_0x1756e3));process[a12_0x38fd('0x15')][a12_0x38fd('0x4')](_0x4988d7);output['addVerticalSeparator']();});}exports['processTask']=processTask;function getCommand(_0x4c42a3){const _0x36f0fb=_0x4c42a3['target']['configuration']?':'+_0x4c42a3['target']['configuration']:'';return['nx',a12_0x38fd('0x16'),_0x4c42a3[a12_0x38fd('0x1')][a12_0x38fd('0xb')]+':'+_0x4c42a3[a12_0x38fd('0x1')][a12_0x38fd('0x1')]+_0x36f0fb,(0x0,serializer_overrides_1['serializeOverrides'])(_0x4c42a3)][a12_0x38fd('0x3')]('\x20');}

@@ -1,67 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.processTasks = void 0;
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
const environment_1 = require("../../../utilities/environment");
const waiter_1 = require("../../../utilities/waiter");
const process_task_1 = require("./process-task");
const { output } = require('../../../utilities/nx-imports-light');
function processTasks(api, dteArtifactStorage, executionId, tasks) {
return __awaiter(this, void 0, void 0, function* () {
const processedTasks = {};
const failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
title: `No new completed tasks after ${environment_1.NO_COMPLETED_TASKS_TIMEOUT / 1000} seconds.`,
timeout: environment_1.NO_COMPLETED_TASKS_TIMEOUT,
});
const waiter = new waiter_1.Waiter();
while (true) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Waiting...',
});
}
yield waiter.wait();
const r = yield api.status(executionId);
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Status update`,
bodyLines: [
`executionId: ${executionId}`,
`executionStatus: ${r.executionStatus}`,
`number of completed tasks: ${r.completedTasks.length}`,
`error: ${r.criticalErrorMessage}`,
],
});
}
if (r.criticalErrorMessage) {
output.error({
title: 'Distributed Execution Terminated',
bodyLines: ['Error:', r.criticalErrorMessage],
});
process.exit(1);
}
failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout(r.completedTasks.length);
for (const t of r.completedTasks) {
if (processedTasks[t.taskId])
continue;
yield (0, process_task_1.processTask)(dteArtifactStorage, tasks, t);
waiter.reset();
processedTasks[t.taskId] = true;
}
if (r.executionStatus === 'COMPLETED') {
return { commandStatus: r.commandStatus, runUrl: r.runUrl };
}
}
});
}
exports.processTasks = processTasks;
//# sourceMappingURL=process-tasks.js.map
const a13_0x6105=['then','Waiting...','commandStatus','Distributed\x20Execution\x20Terminated','wait','COMPLETED','processTasks','Waiter','../../../utilities/nx-imports-light','runUrl','../../../utilities/create-unchanged-value-timeout','number\x20of\x20completed\x20tasks:\x20','next','taskId','executionId:\x20','defineProperty','executionStatus','No\x20new\x20completed\x20tasks\x20after\x20','note','NO_COMPLETED_TASKS_TIMEOUT','createUnchangedValueTimeout','VERBOSE_LOGGING','exit','throw','error','__esModule','criticalErrorMessage','Status\x20update','./process-task','processTask','../../../utilities/environment','value','status','executionStatus:\x20','length','Error:','error:\x20','completedTasks'];(function(_0x3b31c8,_0x61056a){const _0x2bf84e=function(_0x4a5fb8){while(--_0x4a5fb8){_0x3b31c8['push'](_0x3b31c8['shift']());}};_0x2bf84e(++_0x61056a);}(a13_0x6105,0x15c));const a13_0x2bf8=function(_0x3b31c8,_0x61056a){_0x3b31c8=_0x3b31c8-0x0;let _0x2bf84e=a13_0x6105[_0x3b31c8];return _0x2bf84e;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x518053,_0x4619ed,_0x2bf8b8,_0x2e7d58){function _0x5a8002(_0x3b759d){return _0x3b759d instanceof _0x2bf8b8?_0x3b759d:new _0x2bf8b8(function(_0x5ba271){_0x5ba271(_0x3b759d);});}return new(_0x2bf8b8||(_0x2bf8b8=Promise))(function(_0x418e24,_0x38293d){function _0x427083(_0x16a204){try{_0xa15985(_0x2e7d58[a13_0x2bf8('0x6')](_0x16a204));}catch(_0x4fefbd){_0x38293d(_0x4fefbd);}}function _0x482f2a(_0x477706){try{_0xa15985(_0x2e7d58[a13_0x2bf8('0x11')](_0x477706));}catch(_0x144e85){_0x38293d(_0x144e85);}}function _0xa15985(_0x522309){_0x522309['done']?_0x418e24(_0x522309[a13_0x2bf8('0x19')]):_0x5a8002(_0x522309[a13_0x2bf8('0x19')])[a13_0x2bf8('0x20')](_0x427083,_0x482f2a);}_0xa15985((_0x2e7d58=_0x2e7d58['apply'](_0x518053,_0x4619ed||[]))['next']());});};Object[a13_0x2bf8('0x9')](exports,a13_0x2bf8('0x13'),{'value':!![]});exports[a13_0x2bf8('0x0')]=void 0x0;const create_unchanged_value_timeout_1=require(a13_0x2bf8('0x4'));const environment_1=require(a13_0x2bf8('0x18'));const waiter_1=require('../../../utilities/waiter');const process_task_1=require(a13_0x2bf8('0x16'));const {output}=require(a13_0x2bf8('0x2'));function processTasks(_0x474a0b,_0x46231f,_0x278532,_0x11a430){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4e26ef={};const _0x4d9797=(0x0,create_unchanged_value_timeout_1[a13_0x2bf8('0xe')])({'title':a13_0x2bf8('0xb')+environment_1[a13_0x2bf8('0xd')]/0x3e8+'\x20seconds.','timeout':environment_1[a13_0x2bf8('0xd')]});const _0x3001ae=new waiter_1[(a13_0x2bf8('0x1'))]();while(!![]){if(environment_1[a13_0x2bf8('0xf')]){output[a13_0x2bf8('0xc')]({'title':a13_0x2bf8('0x21')});}yield _0x3001ae[a13_0x2bf8('0x24')]();const _0x3683a4=yield _0x474a0b[a13_0x2bf8('0x1a')](_0x278532);if(environment_1[a13_0x2bf8('0xf')]){output[a13_0x2bf8('0xc')]({'title':a13_0x2bf8('0x15'),'bodyLines':[a13_0x2bf8('0x8')+_0x278532,a13_0x2bf8('0x1b')+_0x3683a4['executionStatus'],a13_0x2bf8('0x5')+_0x3683a4[a13_0x2bf8('0x1f')][a13_0x2bf8('0x1c')],a13_0x2bf8('0x1e')+_0x3683a4[a13_0x2bf8('0x14')]]});}if(_0x3683a4[a13_0x2bf8('0x14')]){output[a13_0x2bf8('0x12')]({'title':a13_0x2bf8('0x23'),'bodyLines':[a13_0x2bf8('0x1d'),_0x3683a4[a13_0x2bf8('0x14')]]});process[a13_0x2bf8('0x10')](0x1);}_0x4d9797(_0x3683a4[a13_0x2bf8('0x1f')][a13_0x2bf8('0x1c')]);for(const _0x1e937b of _0x3683a4[a13_0x2bf8('0x1f')]){if(_0x4e26ef[_0x1e937b[a13_0x2bf8('0x7')]])continue;yield(0x0,process_task_1[a13_0x2bf8('0x17')])(_0x46231f,_0x11a430,_0x1e937b);_0x3001ae['reset']();_0x4e26ef[_0x1e937b[a13_0x2bf8('0x7')]]=!![];}if(_0x3683a4[a13_0x2bf8('0xa')]===a13_0x2bf8('0x25')){return{'commandStatus':_0x3683a4[a13_0x2bf8('0x22')],'runUrl':_0x3683a4[a13_0x2bf8('0x3')]};}}});}exports[a13_0x2bf8('0x0')]=processTasks;

@@ -1,37 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.splitTasksIntoStages = void 0;
function splitTasksIntoStages(taskGraph) {
const stages = [];
const notStagedTaskIds = new Set(Object.values(taskGraph.tasks).map((t) => t.id));
let stageIndex = 0;
// Loop through tasks and try to stage them. As tasks are staged, they are removed from the loop
while (notStagedTaskIds.size > 0) {
const currentStage = (stages[stageIndex] = []);
for (const taskId of notStagedTaskIds) {
let ready = true;
for (const dependency of taskGraph.dependencies[taskId]) {
if (notStagedTaskIds.has(dependency)) {
// dependency has not been staged yet, this task is not ready to be staged.
ready = false;
break;
}
}
// Some dependency still has not been staged, skip it for now, it will be processed again
if (!ready) {
continue;
}
// All the dependencies have been staged, let's stage it.
const task = taskGraph.tasks[taskId];
currentStage.push(task);
}
// Remove the entire new stage of tasks from the list
for (const task of currentStage) {
notStagedTaskIds.delete(task.id);
}
stageIndex++;
}
return stages;
}
exports.splitTasksIntoStages = splitTasksIntoStages;
//# sourceMappingURL=split-task-graph-into-stages.js.map
const a14_0x1c3a=['size','values','__esModule','push','defineProperty','dependencies','splitTasksIntoStages','has','tasks','map'];(function(_0x588ccf,_0x1c3a96){const _0x503767=function(_0xd70ea9){while(--_0xd70ea9){_0x588ccf['push'](_0x588ccf['shift']());}};_0x503767(++_0x1c3a96);}(a14_0x1c3a,0x1d8));const a14_0x5037=function(_0x588ccf,_0x1c3a96){_0x588ccf=_0x588ccf-0x0;let _0x503767=a14_0x1c3a[_0x588ccf];return _0x503767;};'use strict';Object[a14_0x5037('0x2')](exports,a14_0x5037('0x0'),{'value':!![]});exports[a14_0x5037('0x4')]=void 0x0;function splitTasksIntoStages(_0x2553e0){const _0x2d2162=[];const _0x3fdb3f=new Set(Object[a14_0x5037('0x9')](_0x2553e0[a14_0x5037('0x6')])[a14_0x5037('0x7')](_0x23449b=>_0x23449b['id']));let _0x28727b=0x0;while(_0x3fdb3f[a14_0x5037('0x8')]>0x0){const _0x2b2ad5=_0x2d2162[_0x28727b]=[];for(const _0x24c94a of _0x3fdb3f){let _0x33691f=!![];for(const _0x45b287 of _0x2553e0[a14_0x5037('0x3')][_0x24c94a]){if(_0x3fdb3f[a14_0x5037('0x5')](_0x45b287)){_0x33691f=![];break;}}if(!_0x33691f){continue;}const _0x2b2384=_0x2553e0[a14_0x5037('0x6')][_0x24c94a];_0x2b2ad5[a14_0x5037('0x1')](_0x2b2384);}for(const _0x534c1f of _0x2b2ad5){_0x3fdb3f['delete'](_0x534c1f['id']);}_0x28727b++;}return _0x2d2162;}exports[a14_0x5037('0x4')]=splitTasksIntoStages;

@@ -1,101 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskGraphCreator = exports.createTaskGraphCompat = void 0;
const stripJsonComments = require("strip-json-comments");
const fs_1 = require("fs");
const { workspaceRoot } = require('../../../utilities/nx-imports-light');
const { getDependencyConfigs } = require('../../../utilities/nx-imports');
function createTaskGraphCompat(options, projectGraph, tasks) {
const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString()));
return new TaskGraphCreator(projectGraph, getDefaultDependencyConfigs(nxjson, options)).createTaskGraph(tasks);
}
exports.createTaskGraphCompat = createTaskGraphCompat;
function getDefaultDependencyConfigs(nxJson, runnerOptions) {
var _a, _b;
const defaults = (_a = nxJson.targetDependencies) !== null && _a !== void 0 ? _a : {};
const strictlyOrderedTargets = runnerOptions
? (_b = runnerOptions.strictlyOrderedTargets) !== null && _b !== void 0 ? _b : ['build']
: [];
// Strictly Ordered Targets depend on their dependencies
for (const target of strictlyOrderedTargets) {
defaults[target] = defaults[target] || [];
defaults[target].push({
target,
projects: 'dependencies',
});
}
return defaults;
}
/**
* This is only used for versions of Nx prior to 14 where the task graph
* wasn't part of the context so we have to recreate it
*/
class TaskGraphCreator {
constructor(projectGraph, defaultTargetDependencies) {
this.projectGraph = projectGraph;
this.defaultTargetDependencies = defaultTargetDependencies;
}
createTaskGraph(tasks) {
const graph = {
roots: [],
tasks: {},
dependencies: {},
};
for (const task of tasks) {
this.addTaskToGraph(task, graph);
const dependencyConfigs = getDependencyConfigs(task.target, this.defaultTargetDependencies, this.projectGraph);
if (!dependencyConfigs) {
continue;
}
this.addTaskDependencies(task, dependencyConfigs, tasks, graph);
}
graph.roots = Object.keys(graph.dependencies).filter((k) => graph.dependencies[k].length === 0);
return graph;
}
addTaskDependencies(task, dependencyConfigs, tasks, graph) {
for (const dependencyConfig of dependencyConfigs) {
if (dependencyConfig.projects === 'self') {
for (const t of tasks) {
if (t.target.project === task.target.project &&
t.target.target === dependencyConfig.target) {
graph.dependencies[task.id].push(t.id);
}
}
}
else if (dependencyConfig.projects === 'dependencies') {
const seen = new Set();
this.addDependencies(task.target.project, dependencyConfig.target, tasks, graph, task.id, seen);
}
}
}
addDependencies(project, target, tasks, graph, taskId, seen) {
seen.add(project);
const dependencies = this.projectGraph.dependencies[project];
if (dependencies) {
const projectDependencies = dependencies.map((dependency) => dependency.target);
for (const projectDependency of projectDependencies) {
if (seen.has(projectDependency)) {
continue;
}
const dependency = this.findTask({ project: projectDependency, target }, tasks);
if (dependency) {
if (graph.dependencies[taskId].indexOf(dependency.id) === -1) {
graph.dependencies[taskId].push(dependency.id);
}
}
else {
this.addDependencies(projectDependency, target, tasks, graph, taskId, seen);
}
}
}
}
findTask({ project, target }, tasks) {
return tasks.find((t) => t.target.project === project && t.target.target === target);
}
addTaskToGraph(task, graph) {
graph.tasks[task.id] = task;
graph.dependencies[task.id] = [];
}
}
exports.TaskGraphCreator = TaskGraphCreator;
//# sourceMappingURL=task-graph-creator.js.map
const a15_0x46ff=['target','addDependencies','dependencies','has','add','addTaskToGraph','tasks','targetDependencies','defaultTargetDependencies','TaskGraphCreator','addTaskDependencies','../../../utilities/nx-imports','projectGraph','filter','find','toString','build','projects','project','findTask','createTaskGraphCompat','indexOf','strip-json-comments','readFileSync','push','../../../utilities/nx-imports-light','createTaskGraph','/nx.json','__esModule','defineProperty'];(function(_0x500cac,_0x46ff5e){const _0x1a1a9c=function(_0x869841){while(--_0x869841){_0x500cac['push'](_0x500cac['shift']());}};_0x1a1a9c(++_0x46ff5e);}(a15_0x46ff,0x1b4));const a15_0x1a1a=function(_0x500cac,_0x46ff5e){_0x500cac=_0x500cac-0x0;let _0x1a1a9c=a15_0x46ff[_0x500cac];return _0x1a1a9c;};'use strict';Object[a15_0x1a1a('0xd')](exports,a15_0x1a1a('0xc'),{'value':!![]});exports[a15_0x1a1a('0x17')]=exports[a15_0x1a1a('0x4')]=void 0x0;const stripJsonComments=require(a15_0x1a1a('0x6'));const fs_1=require('fs');const {workspaceRoot}=require(a15_0x1a1a('0x9'));const {getDependencyConfigs}=require(a15_0x1a1a('0x19'));function createTaskGraphCompat(_0x7e8df5,_0x480ec6,_0xee3def){const _0x282b56=JSON['parse'](stripJsonComments((0x0,fs_1[a15_0x1a1a('0x7')])(workspaceRoot+a15_0x1a1a('0xb'))[a15_0x1a1a('0x1d')]()));return new TaskGraphCreator(_0x480ec6,getDefaultDependencyConfigs(_0x282b56,_0x7e8df5))[a15_0x1a1a('0xa')](_0xee3def);}exports[a15_0x1a1a('0x4')]=createTaskGraphCompat;function getDefaultDependencyConfigs(_0x4d5b66,_0x42b90c){var _0x335fa2,_0x102ab8;const _0x40e508=(_0x335fa2=_0x4d5b66[a15_0x1a1a('0x15')])!==null&&_0x335fa2!==void 0x0?_0x335fa2:{};const _0x2ad297=_0x42b90c?(_0x102ab8=_0x42b90c['strictlyOrderedTargets'])!==null&&_0x102ab8!==void 0x0?_0x102ab8:[a15_0x1a1a('0x0')]:[];for(const _0x36fa96 of _0x2ad297){_0x40e508[_0x36fa96]=_0x40e508[_0x36fa96]||[];_0x40e508[_0x36fa96][a15_0x1a1a('0x8')]({'target':_0x36fa96,'projects':a15_0x1a1a('0x10')});}return _0x40e508;}class TaskGraphCreator{constructor(_0x94ab9a,_0x43eb16){this[a15_0x1a1a('0x1a')]=_0x94ab9a;this[a15_0x1a1a('0x16')]=_0x43eb16;}[a15_0x1a1a('0xa')](_0x174a18){const _0x1b253a={'roots':[],'tasks':{},'dependencies':{}};for(const _0x2c4a8b of _0x174a18){this[a15_0x1a1a('0x13')](_0x2c4a8b,_0x1b253a);const _0x52b0ab=getDependencyConfigs(_0x2c4a8b['target'],this[a15_0x1a1a('0x16')],this[a15_0x1a1a('0x1a')]);if(!_0x52b0ab){continue;}this[a15_0x1a1a('0x18')](_0x2c4a8b,_0x52b0ab,_0x174a18,_0x1b253a);}_0x1b253a['roots']=Object['keys'](_0x1b253a[a15_0x1a1a('0x10')])[a15_0x1a1a('0x1b')](_0x5a8908=>_0x1b253a[a15_0x1a1a('0x10')][_0x5a8908]['length']===0x0);return _0x1b253a;}['addTaskDependencies'](_0xcc485f,_0x2cecf7,_0x180424,_0x13c192){for(const _0x8a9d3 of _0x2cecf7){if(_0x8a9d3[a15_0x1a1a('0x1')]==='self'){for(const _0x35876b of _0x180424){if(_0x35876b['target'][a15_0x1a1a('0x2')]===_0xcc485f[a15_0x1a1a('0xe')]['project']&&_0x35876b['target'][a15_0x1a1a('0xe')]===_0x8a9d3[a15_0x1a1a('0xe')]){_0x13c192[a15_0x1a1a('0x10')][_0xcc485f['id']][a15_0x1a1a('0x8')](_0x35876b['id']);}}}else if(_0x8a9d3[a15_0x1a1a('0x1')]==='dependencies'){const _0xf603b7=new Set();this[a15_0x1a1a('0xf')](_0xcc485f[a15_0x1a1a('0xe')][a15_0x1a1a('0x2')],_0x8a9d3['target'],_0x180424,_0x13c192,_0xcc485f['id'],_0xf603b7);}}}['addDependencies'](_0x1ecd13,_0x15e6c6,_0x1a1d67,_0x2d52ae,_0x103f68,_0x40845b){_0x40845b[a15_0x1a1a('0x12')](_0x1ecd13);const _0x20c187=this[a15_0x1a1a('0x1a')]['dependencies'][_0x1ecd13];if(_0x20c187){const _0x2db00c=_0x20c187['map'](_0x391629=>_0x391629[a15_0x1a1a('0xe')]);for(const _0x384395 of _0x2db00c){if(_0x40845b[a15_0x1a1a('0x11')](_0x384395)){continue;}const _0x1d7ec4=this[a15_0x1a1a('0x3')]({'project':_0x384395,'target':_0x15e6c6},_0x1a1d67);if(_0x1d7ec4){if(_0x2d52ae['dependencies'][_0x103f68][a15_0x1a1a('0x5')](_0x1d7ec4['id'])===-0x1){_0x2d52ae[a15_0x1a1a('0x10')][_0x103f68][a15_0x1a1a('0x8')](_0x1d7ec4['id']);}}else{this[a15_0x1a1a('0xf')](_0x384395,_0x15e6c6,_0x1a1d67,_0x2d52ae,_0x103f68,_0x40845b);}}}}[a15_0x1a1a('0x3')]({project,target},_0x385019){return _0x385019[a15_0x1a1a('0x1c')](_0x1eb516=>_0x1eb516['target'][a15_0x1a1a('0x2')]===project&&_0x1eb516[a15_0x1a1a('0xe')]['target']===target);}['addTaskToGraph'](_0x565ecf,_0x47566b){_0x47566b[a15_0x1a1a('0x14')][_0x565ecf['id']]=_0x565ecf;_0x47566b[a15_0x1a1a('0x10')][_0x565ecf['id']]=[];}}exports[a15_0x1a1a('0x17')]=TaskGraphCreator;

4

package.json
{
"name": "nx-cloud",
"version": "16.3.0-beta.10",
"version": "16.3.0",
"description": "Distributed caching and task execution for Lerna and Nx",

@@ -32,4 +32,4 @@ "keywords": [

"open": "~8.4.0",
"@nrwl/nx-cloud": "16.3.0-beta.10"
"@nrwl/nx-cloud": "16.3.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc