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.1.0 to 16.1.1-beta.0

37

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

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

const a0_0x3ea8=['axiosMultipleTries','apply','throw','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','/nx-cloud/report-client-error','done','defineProperty','apiAxiosInstance','../../utilities/axios','message','createApiAxiosInstance','value','next','post','then'];(function(_0x1ae3b7,_0x3ea81e){const _0x21f63e=function(_0x56183d){while(--_0x56183d){_0x1ae3b7['push'](_0x1ae3b7['shift']());}};_0x21f63e(++_0x3ea81e);}(a0_0x3ea8,0xd5));const a0_0x21f6=function(_0x1ae3b7,_0x3ea81e){_0x1ae3b7=_0x1ae3b7-0x0;let _0x21f63e=a0_0x3ea8[_0x1ae3b7];return _0x21f63e;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0xb94f50,_0x2be1c8,_0x196cca,_0x1e9be1){function _0x51e6b8(_0x337b2d){return _0x337b2d instanceof _0x196cca?_0x337b2d:new _0x196cca(function(_0x321687){_0x321687(_0x337b2d);});}return new(_0x196cca||(_0x196cca=Promise))(function(_0x10997e,_0x42658c){function _0x2f5527(_0x2ed92d){try{_0x217bb3(_0x1e9be1[a0_0x21f6('0x9')](_0x2ed92d));}catch(_0x4f896e){_0x42658c(_0x4f896e);}}function _0x21804a(_0x506e8f){try{_0x217bb3(_0x1e9be1[a0_0x21f6('0xe')](_0x506e8f));}catch(_0x589d55){_0x42658c(_0x589d55);}}function _0x217bb3(_0x3b2993){_0x3b2993[a0_0x21f6('0x2')]?_0x10997e(_0x3b2993[a0_0x21f6('0x8')]):_0x51e6b8(_0x3b2993[a0_0x21f6('0x8')])[a0_0x21f6('0xb')](_0x2f5527,_0x21804a);}_0x217bb3((_0x1e9be1=_0x1e9be1[a0_0x21f6('0xd')](_0xb94f50,_0x2be1c8||[]))['next']());});};Object[a0_0x21f6('0x3')](exports,'__esModule',{'value':!![]});exports['ErrorReporterApi']=void 0x0;const axios_1=require(a0_0x21f6('0x5'));const {output}=require('../../utilities/nx-imports');class ErrorReporterApi{constructor(_0x5416f9){this[a0_0x21f6('0x4')]=(0x0,axios_1[a0_0x21f6('0x7')])(_0x5416f9);}['reportError'](_0x4b7e85){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x21f6('0xc')])(()=>this['apiAxiosInstance'][a0_0x21f6('0xa')](a0_0x21f6('0x1'),{'message':_0x4b7e85}));}catch(_0x4cf78f){output['warn']({'title':a0_0x21f6('0x0')+_0x4b7e85+'\x27','bodyLines':[_0x4cf78f[a0_0x21f6('0x6')]]});}});}}exports['ErrorReporterApi']=ErrorReporterApi;
"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');
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

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

const a1_0x1476=['__awaiter','post','axiosException','axiosMultipleTries','message','exit','value','../../utilities/metric-logger','response','createRunGroup','next','apiAxiosInstance','../../utilities/nx-imports','recordMetric','then','RunGroupApi','createMetricRecorder','completeRunGroup','mapRespToPerfEntry','createApiAxiosInstance','defineProperty','error','/nx-cloud/executions/create-run-group','/nx-cloud/executions/complete-run-group','../../utilities/axios','throw'];(function(_0x50585c,_0x147654){const _0x5ef8bd=function(_0x3431e1){while(--_0x3431e1){_0x50585c['push'](_0x50585c['shift']());}};_0x5ef8bd(++_0x147654);}(a1_0x1476,0x1b5));const a1_0x5ef8=function(_0x50585c,_0x147654){_0x50585c=_0x50585c-0x0;let _0x5ef8bd=a1_0x1476[_0x50585c];return _0x5ef8bd;};'use strict';var __awaiter=this&&this[a1_0x5ef8('0x5')]||function(_0x51fa7e,_0x214b7,_0x3c6de2,_0x416abd){function _0x39a661(_0x4dd17c){return _0x4dd17c instanceof _0x3c6de2?_0x4dd17c:new _0x3c6de2(function(_0x11c7ab){_0x11c7ab(_0x4dd17c);});}return new(_0x3c6de2||(_0x3c6de2=Promise))(function(_0x14ae81,_0x3dec30){function _0x4124b7(_0x750f5d){try{_0x1fec0b(_0x416abd[a1_0x5ef8('0xf')](_0x750f5d));}catch(_0x267c0c){_0x3dec30(_0x267c0c);}}function _0xf1c6bc(_0x41fcc3){try{_0x1fec0b(_0x416abd[a1_0x5ef8('0x4')](_0x41fcc3));}catch(_0x34ef9a){_0x3dec30(_0x34ef9a);}}function _0x1fec0b(_0x2025a7){_0x2025a7['done']?_0x14ae81(_0x2025a7[a1_0x5ef8('0xb')]):_0x39a661(_0x2025a7[a1_0x5ef8('0xb')])[a1_0x5ef8('0x13')](_0x4124b7,_0xf1c6bc);}_0x1fec0b((_0x416abd=_0x416abd['apply'](_0x51fa7e,_0x214b7||[]))[a1_0x5ef8('0xf')]());});};Object[a1_0x5ef8('0x19')](exports,'__esModule',{'value':!![]});exports[a1_0x5ef8('0x14')]=void 0x0;const axios_1=require(a1_0x5ef8('0x3'));const metric_logger_1=require(a1_0x5ef8('0xc'));const {output}=require(a1_0x5ef8('0x11'));class RunGroupApi{constructor(_0x2dd79a){this[a1_0x5ef8('0x10')]=(0x0,axios_1[a1_0x5ef8('0x18')])(_0x2dd79a);}[a1_0x5ef8('0xe')](_0xb286ca,_0x55b4ff,_0x41e902,_0x391644,_0x58e9a7,_0x164e72,_0x4f8a89,_0x1031d7,_0x344af4){var _0x29bccc;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4c42ea=(0x0,metric_logger_1[a1_0x5ef8('0x15')])(a1_0x5ef8('0xe'));try{const _0x35f415=yield(0x0,axios_1[a1_0x5ef8('0x8')])(()=>this['apiAxiosInstance'][a1_0x5ef8('0x6')](a1_0x5ef8('0x1'),{'branch':_0xb286ca,'runGroup':_0x55b4ff,'ciExecutionId':_0x41e902,'ciExecutionEnv':_0x391644,'stopAgentsOnFailure':_0x58e9a7,'agentCount':_0x164e72,'stopAgentsAfter':_0x4f8a89,'commitSha':_0x1031d7}));_0x4c42ea[a1_0x5ef8('0x12')]((0x0,metric_logger_1[a1_0x5ef8('0x17')])(_0x35f415));}catch(_0x25e513){_0x4c42ea[a1_0x5ef8('0x12')](((_0x29bccc=_0x25e513===null||_0x25e513===void 0x0?void 0x0:_0x25e513[a1_0x5ef8('0x7')])===null||_0x29bccc===void 0x0?void 0x0:_0x29bccc[a1_0x5ef8('0xd')])?(0x0,metric_logger_1[a1_0x5ef8('0x17')])(_0x25e513['axiosException'][a1_0x5ef8('0xd')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x5ef8('0x0')]({'title':_0x25e513[a1_0x5ef8('0x9')]});process[a1_0x5ef8('0xa')](0x1);}});}[a1_0x5ef8('0x16')](_0x41c3d0,_0x537873,_0x44e950,_0x42be96){var _0x4babcb;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x558b37=(0x0,metric_logger_1[a1_0x5ef8('0x15')])(a1_0x5ef8('0x16'));try{const _0x30d863=yield(0x0,axios_1[a1_0x5ef8('0x8')])(()=>this['apiAxiosInstance'][a1_0x5ef8('0x6')](a1_0x5ef8('0x2'),{'branch':_0x41c3d0,'runGroup':_0x537873,'ciExecutionId':_0x44e950,'ciExecutionEnv':_0x42be96}));_0x558b37[a1_0x5ef8('0x12')]((0x0,metric_logger_1[a1_0x5ef8('0x17')])(_0x30d863));}catch(_0x5d43dd){_0x558b37[a1_0x5ef8('0x12')](((_0x4babcb=_0x5d43dd===null||_0x5d43dd===void 0x0?void 0x0:_0x5d43dd[a1_0x5ef8('0x7')])===null||_0x4babcb===void 0x0?void 0x0:_0x4babcb[a1_0x5ef8('0xd')])?(0x0,metric_logger_1[a1_0x5ef8('0x17')])(_0x5d43dd['axiosException'][a1_0x5ef8('0xd')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x5ef8('0x0')]({'title':_0x5d43dd[a1_0x5ef8('0x9')]});process[a1_0x5ef8('0xa')](0x1);}});}}exports[a1_0x5ef8('0x14')]=RunGroupApi;
"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');
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

6

lib/core/commands/record-output.js

@@ -140,4 +140,2 @@ "use strict";

runGroup: params.runGroup,
ciExecutionId: params.ciExecutionId,
ciExecutionEnv: params.ciExecutionEnv,
// only set sha if branch is set because we invoke a separate process,

@@ -147,2 +145,6 @@ // which adds a few millis

},
branch: params.branch,
runGroup: params.runGroup,
ciExecutionId: params.ciExecutionId,
ciExecutionEnv: params.ciExecutionEnv,
machineInfo: (0, environment_1.getMachineInfo)(taskRunnerOptions),

@@ -149,0 +151,0 @@ };

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

const a0_0x7f2c=['tasks','endTime','../../terminal-output/read-task-terminal-output','cacheStatus','nodes','obfuscate','updateStartedTask','find','readTaskTerminalOutput','implicitDeps','__esModule','runContext','remote-cache-hit','taskId','statuses','local-cache-hit','scheduledTasks','runtime','CloudEnabledLifeCycle','hash','project','startTime','code','cleanUpHashDetails','Cannot\x20find\x20task\x20','filter','scheduleTask','cacheDirectory','startTask','push','forEach','endTasks','cache-miss','keys','collectTerminalOutput','cache','outputObfuscator','target','getTerminalOutput','status','local-cache-kept-existing','toISOString','params','startsWith','../../../utilities/serializer-overrides','task'];(function(_0x92d719,_0x7f2cd9){const _0x24d8b1=function(_0x50c583){while(--_0x50c583){_0x92d719['push'](_0x92d719['shift']());}};_0x24d8b1(++_0x7f2cd9);}(a0_0x7f2c,0x8a));const a0_0x24d8=function(_0x92d719,_0x7f2cd9){_0x92d719=_0x92d719-0x0;let _0x24d8b1=a0_0x7f2c[_0x92d719];return _0x24d8b1;};'use strict';Object['defineProperty'](exports,a0_0x24d8('0xa'),{'value':!![]});exports[a0_0x24d8('0x12')]=void 0x0;const serializer_overrides_1=require(a0_0x24d8('0x2c'));const read_task_terminal_output_1=require(a0_0x24d8('0x2'));class CloudEnabledLifeCycle{constructor(_0x292d47,_0x3b566f,_0x38427f,_0x291f54,_0x436385,_0x19dab4){this[a0_0x24d8('0xb')]=_0x292d47;this[a0_0x24d8('0x1b')]=_0x3b566f;this[a0_0x24d8('0x22')]=_0x38427f;this['cacheableOperations']=_0x291f54;this[a0_0x24d8('0x24')]=_0x436385;this['tasks']=_0x19dab4;}[a0_0x24d8('0x1a')](_0x2943b7){this[a0_0x24d8('0xb')][a0_0x24d8('0x10')][a0_0x24d8('0x1d')](_0x2943b7);}[a0_0x24d8('0x1c')](_0x8559bb){this[a0_0x24d8('0x0')]['push']({'taskId':_0x8559bb['id'],'startTime':new Date()[a0_0x24d8('0x29')](),'target':_0x8559bb[a0_0x24d8('0x25')][a0_0x24d8('0x25')],'projectName':_0x8559bb[a0_0x24d8('0x25')][a0_0x24d8('0x14')],'hash':_0x8559bb[a0_0x24d8('0x13')],'hashDetails':this[a0_0x24d8('0x17')](_0x8559bb['hashDetails']),'params':(0x0,serializer_overrides_1['serializeOverrides'])(_0x8559bb),'uploadedToStorage':![]});}[a0_0x24d8('0x1f')](_0x40d38d){for(let _0x2e1323 of _0x40d38d){let _0x35ad9d;const _0x3138cd=_0x2e1323[a0_0x24d8('0x27')]==='remote-cache';const _0x19287f=_0x2e1323['status']===a0_0x24d8('0x23');const _0x38e6df=_0x2e1323[a0_0x24d8('0x27')]==='local-cache'||_0x2e1323[a0_0x24d8('0x27')]===a0_0x24d8('0x28')||_0x19287f;if(this['runContext'][a0_0x24d8('0xe')][_0x2e1323[a0_0x24d8('0x2d')][a0_0x24d8('0x13')]]){_0x35ad9d=this['runContext'][a0_0x24d8('0xe')][_0x2e1323['task'][a0_0x24d8('0x13')]];}else if(_0x3138cd){_0x35ad9d=a0_0x24d8('0xc');}else if(_0x38e6df){_0x35ad9d=a0_0x24d8('0xf');}else{_0x35ad9d=a0_0x24d8('0x20');}this[a0_0x24d8('0x6')](_0x2e1323,_0x35ad9d);}}['endCommand'](){}[a0_0x24d8('0x6')](_0x4dc18d,_0x5cfc9f){const _0x1aeecf=this[a0_0x24d8('0x0')][a0_0x24d8('0x7')](_0x37c3f3=>_0x37c3f3[a0_0x24d8('0xd')]===_0x4dc18d[a0_0x24d8('0x2d')]['id']);if(!_0x1aeecf){throw new Error(a0_0x24d8('0x18')+_0x4dc18d[a0_0x24d8('0x2d')]['id']);}if((_0x4dc18d===null||_0x4dc18d===void 0x0?void 0x0:_0x4dc18d[a0_0x24d8('0x15')])&&(_0x4dc18d===null||_0x4dc18d===void 0x0?void 0x0:_0x4dc18d[a0_0x24d8('0x1')])){_0x1aeecf[a0_0x24d8('0x15')]=new Date(_0x4dc18d[a0_0x24d8('0x15')])[a0_0x24d8('0x29')]();_0x1aeecf[a0_0x24d8('0x1')]=new Date(_0x4dc18d[a0_0x24d8('0x1')])[a0_0x24d8('0x29')]();}else{_0x1aeecf['endTime']=new Date()[a0_0x24d8('0x29')]();}_0x1aeecf[a0_0x24d8('0x27')]=_0x4dc18d[a0_0x24d8('0x16')];_0x1aeecf[a0_0x24d8('0x2a')]=this[a0_0x24d8('0x24')][a0_0x24d8('0x5')](_0x1aeecf[a0_0x24d8('0x2a')]);_0x1aeecf['cacheStatus']=_0x5cfc9f;if(this[a0_0x24d8('0x22')]){_0x1aeecf['terminalOutput']=this[a0_0x24d8('0x26')](_0x4dc18d[a0_0x24d8('0x2d')][a0_0x24d8('0x13')],_0x1aeecf[a0_0x24d8('0x3')],_0x4dc18d['code']);}}[a0_0x24d8('0x26')](_0x555fda,_0x486e88,_0x3ff9af){return(0x0,read_task_terminal_output_1[a0_0x24d8('0x8')])(this[a0_0x24d8('0x1b')],this[a0_0x24d8('0x24')],_0x555fda,_0x486e88,_0x3ff9af);}['cleanUpHashDetails'](_0x21b474){const _0x3470d0={};Object[a0_0x24d8('0x21')](_0x21b474['nodes'])[a0_0x24d8('0x19')](_0x5b27b5=>!_0x5b27b5[a0_0x24d8('0x2b')]('npm:'))[a0_0x24d8('0x1e')](_0x5d4cde=>{_0x3470d0[_0x5d4cde]=_0x21b474[a0_0x24d8('0x4')][_0x5d4cde];});return{'nodes':_0x3470d0,'runtime':_0x21b474[a0_0x24d8('0x11')],'implicitDeps':_0x21b474[a0_0x24d8('0x9')]};}}exports['CloudEnabledLifeCycle']=CloudEnabledLifeCycle;
"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

@@ -1,1 +0,320 @@

const a1_0x5036=['../../../utilities/metric-logger','waitForStoreRequestsToComplete','getBranch','all','error','requests','../../terminal-output/output-obfuscator','env','forEach','done','encryptionKey','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','uploadedToStorage','/runs/','ACCESS_TOKEN','endRun','./cloud-remote-cache','CloudRunApi','assign','warn','resolve','then','E2EEncryption','MessageReporter','find','submitRunMetrics','.commit','obfuscate','CloudRemoteCache','local-cache-hit','printMessages','OutputObfuscator','cacheStatus','./id-generator','./cloud-run.api','note','agentRunningInDistributedExecution','../../terminal-output/message-reporter','toISOString','map','getRunGroup','daemon','cloudEnabledTasksRunner','catch','filter','exit','throw','path','join','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','nx-cloud/lib/daemon/process-run-end','EndOfRunMessage','store','subscribe','../../api/error-reporter.api','../../file-storage/e2e-encryption','cacheableOperations','hash','url','../../../utilities/remove-trailing-slash','printCacheHitsMessage','toString','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','getCIExecutionEnv','runUrl','next','delayedStoreRequests','\x20isn\x27t\x20recorded','../../../utilities/environment','accessToken','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','Executed\x20tasks\x20with\x20hashes:\x20','./cloud-enabled-life-cycle','length','writeFileSync','../../terminal-output/end-of-run-message','FileStorage','message','skipNxCache','complete','removeTrailingSlash','taskId','maskedProperties','anyErrors','stringify','startRun','ENCRYPTION_KEY','extractGitSha','tasks-hashes-','__awaiter','getCIExecutionId','VERBOSE_LOGGING','parseCommand','lifeCycle','cloud-enabled-runner'];(function(_0x33f636,_0x5036cf){const _0x13d479=function(_0x1fca3a){while(--_0x1fca3a){_0x33f636['push'](_0x33f636['shift']());}};_0x13d479(++_0x5036cf);}(a1_0x5036,0x13e));const a1_0x13d4=function(_0x33f636,_0x5036cf){_0x33f636=_0x33f636-0x0;let _0x13d479=a1_0x5036[_0x33f636];return _0x13d479;};'use strict';var __awaiter=this&&this[a1_0x13d4('0x38')]||function(_0x182213,_0x1accbb,_0x270ebd,_0x3cfe43){function _0x2b5d98(_0x2b77e1){return _0x2b77e1 instanceof _0x270ebd?_0x2b77e1:new _0x270ebd(function(_0x34ded9){_0x34ded9(_0x2b77e1);});}return new(_0x270ebd||(_0x270ebd=Promise))(function(_0xe89c54,_0x3b03bf){function _0x4b14f7(_0x2a0c0b){try{_0x5379bd(_0x3cfe43[a1_0x13d4('0x20')](_0x2a0c0b));}catch(_0xb5eaa4){_0x3b03bf(_0xb5eaa4);}}function _0x27accd(_0x2668be){try{_0x5379bd(_0x3cfe43[a1_0x13d4('0xd')](_0x2668be));}catch(_0x5ec4ad){_0x3b03bf(_0x5ec4ad);}}function _0x5379bd(_0x3c72ef){_0x3c72ef[a1_0x13d4('0x47')]?_0xe89c54(_0x3c72ef['value']):_0x2b5d98(_0x3c72ef['value'])['then'](_0x4b14f7,_0x27accd);}_0x5379bd((_0x3cfe43=_0x3cfe43['apply'](_0x182213,_0x1accbb||[]))[a1_0x13d4('0x20')]());});};Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a1_0x13d4('0x9')]=void 0x0;const message_reporter_1=require(a1_0x13d4('0x4'));const end_of_run_message_1=require(a1_0x13d4('0x2a'));const output_obfuscator_1=require(a1_0x13d4('0x44'));const cloud_enabled_life_cycle_1=require(a1_0x13d4('0x27'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a1_0x13d4('0x16'));const environment_1=require(a1_0x13d4('0x23'));const cloud_remote_cache_1=require(a1_0x13d4('0x4e'));const cloud_run_api_1=require(a1_0x13d4('0x1'));const fs_1=require('fs');const path=require(a1_0x13d4('0xe'));const path_1=require('path');const metric_logger_1=require(a1_0x13d4('0x3e'));const error_reporter_api_1=require(a1_0x13d4('0x15'));const fs_extra_1=require('fs-extra');const id_generator_1=require(a1_0x13d4('0x0'));const remove_trailing_slash_1=require(a1_0x13d4('0x1a'));const {tasksRunner,output,cacheDirectory}=require('../../../utilities/nx-imports');function createApi(_0x44ef00,_0x493f4e,_0x4ec0d3){const _0x4092e3=(0x0,environment_1['getMachineInfo'])(_0x493f4e);return new cloud_run_api_1[(a1_0x13d4('0x4f'))](_0x44ef00,_0x4ec0d3,_0x493f4e,_0x4092e3);}function storeTaskHashes(_0x37e534,_0x381ace,_0x4e7acd){const _0x42aedc=JSON[a1_0x13d4('0x33')](_0x37e534[a1_0x13d4('0x6')](_0x48224c=>({'taskId':_0x48224c[a1_0x13d4('0x30')],'hash':_0x48224c[a1_0x13d4('0x18')]})));if(environment_1[a1_0x13d4('0x3a')]){output[a1_0x13d4('0x2')]({'title':a1_0x13d4('0x26')+_0x42aedc});}(0x0,fs_1[a1_0x13d4('0x29')])(path[a1_0x13d4('0xf')](_0x381ace,a1_0x13d4('0x37')+_0x4e7acd),_0x42aedc);}function storeLocalCacheHits(_0x5e13b2,_0x86b5f1,_0x5969cd){const _0x188282=_0x5e13b2[a1_0x13d4('0xb')](_0x42e3f8=>_0x42e3f8[a1_0x13d4('0x5e')]===a1_0x13d4('0x5b'))[a1_0x13d4('0x6')](_0x3fbffc=>_0x3fbffc[a1_0x13d4('0x18')]);_0x188282[a1_0x13d4('0x46')](_0x2aaae9=>_0x86b5f1[a1_0x13d4('0x13')](_0x2aaae9,_0x5969cd));}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 _0x4f9fd8=new Date()['toISOString']();const _0x23619b=(0x0,environment_1[a1_0x13d4('0x40')])();const _0x4236fc={'command':outputObfuscator[a1_0x13d4('0x59')]((0x0,environment_1[a1_0x13d4('0x3b')])()),'startTime':runStartTime,'endTime':_0x4f9fd8,'distributedExecutionId':distributedExecutionId,'branch':_0x23619b,'runGroup':(0x0,environment_1['getRunGroup'])(),'sha':_0x23619b?(0x0,environment_1[a1_0x13d4('0x36')])():undefined,'inner':inner};const _0x4772ed={'branch':_0x23619b,'runGroup':(0x0,environment_1[a1_0x13d4('0x7')])(),'ciExecutionId':(0x0,environment_1[a1_0x13d4('0x39')])(),'ciExecutionEnv':(0x0,environment_1[a1_0x13d4('0x1e')])()};if(storeInCurrentProcess){if((0x0,environment_1[a1_0x13d4('0x3')])(distributedExecutionId)){storeTaskHashes(taskExecutions,cacheDirectory,distributedExecutionId);storeLocalCacheHits(taskExecutions,remoteCache,cacheDirectory);}try{yield remoteCache[a1_0x13d4('0x3f')]();}catch(_0x1c5612){output[a1_0x13d4('0x42')]({'title':a1_0x13d4('0x10')});messages[a1_0x13d4('0x5c')]();return![];}for(const _0x1e4af2 of fileStorage['storedHashes']){const _0x3006a9=taskExecutions[a1_0x13d4('0x56')](_0x1e3a41=>_0x1e3a41['hash']===_0x1e4af2);if(!_0x3006a9){throw new Error('Task\x20with\x20hash\x20'+_0x1e4af2+a1_0x13d4('0x22'));}_0x3006a9[a1_0x13d4('0x4a')]=!![];}try{yield api[a1_0x13d4('0x4d')](_0x4236fc,taskExecutions,_0x4772ed);}catch(_0x300c52){output[a1_0x13d4('0x42')]({'title':a1_0x13d4('0x25')});messages[a1_0x13d4('0x5c')]();return![];}yield(0x0,metric_logger_1[a1_0x13d4('0x57')])(options);}else{try{const _0x54059f=environment_1[a1_0x13d4('0x4c')]?environment_1[a1_0x13d4('0x4c')]:options[a1_0x13d4('0x24')];const _0x3b2069=(0x0,id_generator_1['generateUniqueLinkId'])();const _0xe0b938=require[a1_0x13d4('0x52')](a1_0x13d4('0x11'));yield daemon['processInBackground'](_0xe0b938,{'encryptionKey':encryptionKey,'runnerOptions':Object[a1_0x13d4('0x50')](Object[a1_0x13d4('0x50')]({},options),{'accessToken':_0x54059f}),'delayedStoreRequests':remoteCache[a1_0x13d4('0x21')],'ciExecutionContext':_0x4772ed,'runEnd':{'runData':_0x4236fc,'taskExecutions':taskExecutions,'linkId':_0x3b2069}});runContext[a1_0x13d4('0x1f')]=(0x0,remove_trailing_slash_1[a1_0x13d4('0x2f')])(options[a1_0x13d4('0x19')]||'https://nx.app')+a1_0x13d4('0x4b')+_0x3b2069;}catch(_0x35a2ba){output[a1_0x13d4('0x51')]({'title':'Nx\x20Cloud\x20Problems','bodyLines':[_0x35a2ba[a1_0x13d4('0x2c')]||_0x35a2ba[a1_0x13d4('0x1c')]()]});return![];}}if(versionOfNxBefore133){setTimeout(()=>{messages[a1_0x13d4('0x5c')]();if(!messages[a1_0x13d4('0x32')]&&!inner){endOfRunMessage[a1_0x13d4('0x1b')]();}},0x0);}else{messages[a1_0x13d4('0x5c')]();if(!messages[a1_0x13d4('0x32')]&&!inner){endOfRunMessage['printCacheHitsMessage']();}}return!![];});}function createLifeCycle(_0x484bc7,_0x1b81c4,_0x3e1f55,_0x1fa6ef){const _0x3244ed=new cloud_enabled_life_cycle_1['CloudEnabledLifeCycle'](_0x484bc7,cacheDirectory,!![],_0x1b81c4[a1_0x13d4('0x17')]||[],_0x3e1f55,_0x1fa6ef);try{const {CompositeLifeCycle}=require('../../../utilities/nx-imports');if(!CompositeLifeCycle)return _0x3244ed;return new CompositeLifeCycle([_0x1b81c4[a1_0x13d4('0x3c')],_0x3244ed]);}catch(_0x12be73){return _0x3244ed;}}function fetchUrlsForKnownHashesUpfront(_0x28e496,_0x3bb7e8,_0x418d2c,_0x3b9588,_0x4e54f6){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x3b9588[a1_0x13d4('0x2d')])return;let _0x516f3e=_0x418d2c[a1_0x13d4('0x6')](_0x8aba1a=>_0x8aba1a[a1_0x13d4('0x18')])[a1_0x13d4('0xb')](_0x2235ce=>!!_0x2235ce);const _0x55335a=yield Promise[a1_0x13d4('0x41')](_0x516f3e[a1_0x13d4('0x6')](_0x3eb89f=>{const _0x33bac2=(0x0,path_1['join'])(cacheDirectory,_0x3eb89f+a1_0x13d4('0x58'));return(0x0,fs_extra_1['pathExists'])(_0x33bac2);}));const _0x277181=[];for(let _0x49b368=0x0;_0x49b368<_0x55335a[a1_0x13d4('0x28')];++_0x49b368){if(!_0x55335a[_0x49b368]){_0x277181['push'](_0x516f3e[_0x49b368]);}}if(_0x277181['length']>0x0){const _0x348fc0=_0x28e496[a1_0x13d4('0x34')](_0x4e54f6,_0x277181);for(const _0x37d6ef of _0x277181){_0x3bb7e8[a1_0x13d4('0x43')][_0x37d6ef]=_0x348fc0;}}});}function cloudEnabledTasksRunner(_0x22deed,_0x110c28,_0x9d58d2,_0x13d494=![]){var _0x15cd2;const _0x1f55c4=process[a1_0x13d4('0x45')][a1_0x13d4('0x1d')];const _0xefbade={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x22deed};const _0x5a91e7=_0x110c28[a1_0x13d4('0x3c')]===undefined;const _0x1050ba=[];const _0xc1914c=new message_reporter_1[(a1_0x13d4('0x55'))](_0x110c28);const _0x1f60c3=createApi(_0xc1914c,_0x110c28,_0xefbade);const _0x3e31c7=new end_of_run_message_1[(a1_0x13d4('0x12'))](_0xefbade,_0x1050ba,_0x1f55c4);const _0x146693=new output_obfuscator_1[(a1_0x13d4('0x5d'))](_0x110c28[a1_0x13d4('0x31')]);const _0x6e4c77=new Date()[a1_0x13d4('0x5')]();const _0x4f0951=createLifeCycle(_0xefbade,_0x110c28,_0x146693,_0x1050ba);const _0x38c425=environment_1[a1_0x13d4('0x35')]||_0x110c28[a1_0x13d4('0x48')];const _0x40fc99=new e2e_encryption_1[(a1_0x13d4('0x54'))](_0x38c425);const _0x5cad19=new error_reporter_api_1['ErrorReporterApi'](_0x110c28);const _0x2a4a23=(0x0,environment_1[a1_0x13d4('0x3')])(_0x1f55c4)||!((_0x15cd2=_0x9d58d2['daemon'])===null||_0x15cd2===void 0x0?void 0x0:_0x15cd2['enabled']());const _0x1895eb=new file_storage_1[(a1_0x13d4('0x2b'))](_0x40fc99,_0x5cad19,_0x110c28,a1_0x13d4('0x3d'));const _0x129b5c=new cloud_remote_cache_1[(a1_0x13d4('0x5a'))](_0xc1914c,_0x1f60c3,_0xefbade,_0x1895eb,_0x1f55c4,_0x2a4a23);fetchUrlsForKnownHashesUpfront(_0x1f60c3,_0xefbade,_0x22deed,_0x110c28,_0x1f55c4);delete process[a1_0x13d4('0x45')][a1_0x13d4('0x1d')];const _0x4667fe=tasksRunner(_0x22deed,Object[a1_0x13d4('0x50')](Object['assign']({},_0x110c28),{'remoteCache':_0x129b5c,'lifeCycle':_0x4f0951}),_0x9d58d2);if(_0x4667fe[a1_0x13d4('0x14')]){const {Subject}=require('rxjs/internal/Subject');const _0x23ad56=new Subject();_0x4667fe['subscribe']({'next':_0x3de1e7=>_0x23ad56[a1_0x13d4('0x20')](_0x3de1e7),'error':_0x63382f=>_0x23ad56[a1_0x13d4('0x42')](_0x63382f),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x449474=yield onComplete({'daemon':_0x9d58d2[a1_0x13d4('0x8')],'options':_0x110c28,'fileStorage':_0x1895eb,'remoteCache':_0x129b5c,'api':_0x1f60c3,'outputObfuscator':_0x146693,'runStartTime':_0x6e4c77,'messages':_0xc1914c,'endOfRunMessage':_0x3e31c7,'taskExecutions':_0x1050ba,'versionOfNxBefore133':_0x5a91e7,'inner':_0x13d494,'encryptionKey':_0x38c425,'storeInCurrentProcess':_0x2a4a23,'runContext':_0xefbade,'distributedExecutionId':_0x1f55c4});if(!_0x449474&&(0x0,environment_1[a1_0x13d4('0x3')])(_0x1f55c4)){process[a1_0x13d4('0xc')](environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']);}_0x23ad56[a1_0x13d4('0x2e')]();})});return _0x23ad56;}else{return _0x4667fe[a1_0x13d4('0x53')](_0x4fb65f=>__awaiter(this,void 0x0,void 0x0,function*(){const _0xa9d3a6=yield onComplete({'daemon':_0x9d58d2[a1_0x13d4('0x8')],'options':_0x110c28,'fileStorage':_0x1895eb,'remoteCache':_0x129b5c,'api':_0x1f60c3,'outputObfuscator':_0x146693,'runStartTime':_0x6e4c77,'messages':_0xc1914c,'endOfRunMessage':_0x3e31c7,'taskExecutions':_0x1050ba,'versionOfNxBefore133':_0x5a91e7,'inner':_0x13d494,'encryptionKey':_0x38c425,'storeInCurrentProcess':_0x2a4a23,'runContext':_0xefbade,'distributedExecutionId':_0x1f55c4});if(!_0xa9d3a6&&(0x0,environment_1['agentRunningInDistributedExecution'])(_0x1f55c4)){process[a1_0x13d4('0xc')](environment_1[a1_0x13d4('0x49')]);}return _0x4fb65f;}))[a1_0x13d4('0xa')](_0x4699c3=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x59dd6d=yield onComplete({'daemon':_0x9d58d2['daemon'],'options':_0x110c28,'fileStorage':_0x1895eb,'remoteCache':_0x129b5c,'api':_0x1f60c3,'outputObfuscator':_0x146693,'runStartTime':_0x6e4c77,'messages':_0xc1914c,'endOfRunMessage':_0x3e31c7,'taskExecutions':_0x1050ba,'versionOfNxBefore133':_0x5a91e7,'inner':_0x13d494,'encryptionKey':_0x38c425,'storeInCurrentProcess':_0x2a4a23,'runContext':_0xefbade,'distributedExecutionId':_0x1f55c4});if(!_0x59dd6d&&(0x0,environment_1[a1_0x13d4('0x3')])(_0x1f55c4)){process[a1_0x13d4('0xc')](environment_1[a1_0x13d4('0x49')]);}throw _0x4699c3;}));}}exports[a1_0x13d4('0x9')]=cloudEnabledTasksRunner;
"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 { tasksRunner, output, cacheDirectory, } = require('../../../utilities/nx-imports');
function createApi(errors, options, runContext) {
const machineInfo = (0, environment_1.getMachineInfo)(options);
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

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

const a2_0x194b=['defineProperty','response','.\x20Status\x20404.','then','There\x20are\x20several\x20reasons\x20why\x20this\x20can\x20happen.','messages','CloudRemoteCache','waitForStoreRequestsToComplete','forEach','apply','extractErrorMessage','resolve','get','reduce','note','all','Error\x20when\x20storing\x20artifacts','statuses','runContext','store','fileStorage','requests','hashUrls','put','value','storeRequests','cacheError','Nx\x20Cloud:\x20Cache\x20miss\x20','api','remote-cache-hit','VERBOSE_LOGGING','scheduledTasks','indexOf','throw','storeInCurrentProcess','__awaiter','next','map','axiosException','hash','push','storage','filter','status','cache-miss','delayedStoreRequests','Nx\x20Cloud:\x20Skipping\x20storing\x20','done','retrieve','startRun','distributedExecutionId'];(function(_0x2c25a6,_0x194bfe){const _0x57ab48=function(_0x2d8ab1){while(--_0x2d8ab1){_0x2c25a6['push'](_0x2c25a6['shift']());}};_0x57ab48(++_0x194bfe);}(a2_0x194b,0x11d));const a2_0x57ab=function(_0x2c25a6,_0x194bfe){_0x2c25a6=_0x2c25a6-0x0;let _0x57ab48=a2_0x194b[_0x2c25a6];return _0x57ab48;};'use strict';var __awaiter=this&&this[a2_0x57ab('0x5')]||function(_0x427eed,_0x1b6ead,_0x8aa993,_0x214a2b){function _0x43e056(_0x33975d){return _0x33975d instanceof _0x8aa993?_0x33975d:new _0x8aa993(function(_0x268b3f){_0x268b3f(_0x33975d);});}return new(_0x8aa993||(_0x8aa993=Promise))(function(_0x3add58,_0xb38516){function _0x15c718(_0x20c602){try{_0x6687c2(_0x214a2b[a2_0x57ab('0x6')](_0x20c602));}catch(_0x50d5fe){_0xb38516(_0x50d5fe);}}function _0x5bf9a2(_0x2dfb1a){try{_0x6687c2(_0x214a2b[a2_0x57ab('0x3')](_0x2dfb1a));}catch(_0x33986c){_0xb38516(_0x33986c);}}function _0x6687c2(_0x5de673){_0x5de673[a2_0x57ab('0x11')]?_0x3add58(_0x5de673[a2_0x57ab('0x2d')]):_0x43e056(_0x5de673[a2_0x57ab('0x2d')])[a2_0x57ab('0x18')](_0x15c718,_0x5bf9a2);}_0x6687c2((_0x214a2b=_0x214a2b[a2_0x57ab('0x1e')](_0x427eed,_0x1b6ead||[]))[a2_0x57ab('0x6')]());});};Object[a2_0x57ab('0x15')](exports,'__esModule',{'value':!![]});exports[a2_0x57ab('0x1b')]=void 0x0;const environment_1=require('../../../utilities/environment');const {output}=require('../../../utilities/nx-imports');class CloudRemoteCache{constructor(_0x156627,_0x4fcc2b,_0x5ae464,_0xd7cd99,_0x266349,_0x17ee00){this[a2_0x57ab('0x1a')]=_0x156627;this[a2_0x57ab('0x31')]=_0x4fcc2b;this[a2_0x57ab('0x27')]=_0x5ae464;this[a2_0x57ab('0x29')]=_0xd7cd99;this[a2_0x57ab('0x14')]=_0x266349;this['storeInCurrentProcess']=_0x17ee00;this[a2_0x57ab('0x2e')]=[];this[a2_0x57ab('0xf')]=[];}['retrieve'](_0x1aef4a,_0x4591f1){var _0x58a8c8;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x57ab('0x1a')][a2_0x57ab('0x2f')])return![];const _0x52dcb1=yield this[a2_0x57ab('0x2b')](_0x1aef4a);if(!_0x52dcb1||!_0x52dcb1[a2_0x57ab('0x21')]){if(environment_1[a2_0x57ab('0x0')]){output[a2_0x57ab('0x23')]({'title':a2_0x57ab('0x30')+_0x1aef4a+'.'});}this[a2_0x57ab('0x27')][a2_0x57ab('0x26')][_0x1aef4a]=a2_0x57ab('0xe');return![];}try{yield this[a2_0x57ab('0x29')][a2_0x57ab('0x12')](_0x1aef4a,_0x52dcb1['get'],_0x4591f1);this['runContext'][a2_0x57ab('0x26')][_0x1aef4a]=a2_0x57ab('0x32');return!![];}catch(_0x281234){const _0x1cdd33=(_0x58a8c8=_0x281234[a2_0x57ab('0x8')])!==null&&_0x58a8c8!==void 0x0?_0x58a8c8:_0x281234;if(_0x1cdd33[a2_0x57ab('0x16')]&&_0x1cdd33[a2_0x57ab('0x16')][a2_0x57ab('0xd')]===0x194){if(environment_1[a2_0x57ab('0x0')]){output[a2_0x57ab('0x23')]({'title':'Nx\x20Cloud:\x20Cache\x20miss\x20'+_0x1aef4a+a2_0x57ab('0x17')});}}else{this['messages'][a2_0x57ab('0x2f')]=this[a2_0x57ab('0x1a')]['extractErrorMessage'](_0x1cdd33,a2_0x57ab('0xb'));}this[a2_0x57ab('0x27')][a2_0x57ab('0x26')][_0x1aef4a]=a2_0x57ab('0xe');return![];}});}['store'](_0x2def22,_0xe02f51){return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a2_0x57ab('0x2f')])return![];const _0x181b90=Promise[a2_0x57ab('0x20')]()[a2_0x57ab('0x18')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x5d0139;const _0x45d769=yield this[a2_0x57ab('0x2b')](_0x2def22);if(!_0x45d769)return![];if(!_0x45d769[a2_0x57ab('0x2c')]){if(environment_1[a2_0x57ab('0x0')]){output[a2_0x57ab('0x23')]({'title':a2_0x57ab('0x10')+_0x2def22+'.','bodyLines':[a2_0x57ab('0x19'),'Maybe\x20you\x20are\x20using\x20a\x20read-only\x20token\x20or\x20the\x20artifact\x20has\x20already\x20being\x20uploaded.']});}return!![];}if(!this[a2_0x57ab('0x4')]){this[a2_0x57ab('0xf')][a2_0x57ab('0xa')]({'hash':_0x2def22,'url':_0x45d769[a2_0x57ab('0x2c')]});return!![];}try{yield this[a2_0x57ab('0x29')][a2_0x57ab('0x28')](_0x2def22,_0x45d769['put'],_0xe02f51);return!![];}catch(_0x13ccb8){const _0x118044=(_0x5d0139=_0x13ccb8[a2_0x57ab('0x8')])!==null&&_0x5d0139!==void 0x0?_0x5d0139:_0x13ccb8;this['messages'][a2_0x57ab('0x2f')]=this['messages'][a2_0x57ab('0x1f')](_0x118044,'storage');return![];}}));this[a2_0x57ab('0x2e')][a2_0x57ab('0xa')](_0x181b90);return _0x181b90;});}[a2_0x57ab('0x2b')](_0x2c4b4f){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x2c4b4f in this['runContext'][a2_0x57ab('0x2a')]){return(yield this[a2_0x57ab('0x27')][a2_0x57ab('0x2a')][_0x2c4b4f])[_0x2c4b4f];}else{const _0x1baff4=this['runContext'][a2_0x57ab('0x1')][a2_0x57ab('0xc')](_0x39cb77=>!this[a2_0x57ab('0x27')][a2_0x57ab('0x2a')][_0x39cb77[a2_0x57ab('0x9')]])[a2_0x57ab('0x7')](_0x4a01af=>_0x4a01af[a2_0x57ab('0x9')]);if(_0x1baff4[a2_0x57ab('0x2')](_0x2c4b4f)===-0x1){_0x1baff4[a2_0x57ab('0xa')](_0x2c4b4f);}const _0xd3ba2c=this[a2_0x57ab('0x31')][a2_0x57ab('0x13')](this[a2_0x57ab('0x14')],_0x1baff4);_0x1baff4[a2_0x57ab('0x1d')](_0x5474bc=>{this[a2_0x57ab('0x27')][a2_0x57ab('0x2a')][_0x5474bc]=_0xd3ba2c;});return(yield _0xd3ba2c)[_0x2c4b4f];}});}[a2_0x57ab('0x1c')](){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x56d9a8=yield Promise[a2_0x57ab('0x24')](this[a2_0x57ab('0x2e')])['then'](_0xa8e93c=>_0xa8e93c[a2_0x57ab('0x22')]((_0x3b3db4,_0x48ed79)=>_0x3b3db4&&_0x48ed79,!![]));if(!_0x56d9a8){throw new Error(a2_0x57ab('0x25'));}});}}exports[a2_0x57ab('0x1b')]=CloudRemoteCache;
"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');
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

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

const a3_0x4266=['...','parse','/nx-cloud/runs/end','RunStart\x20duration','VERBOSE_LOGGING','Run\x20completion\x20responded\x20with\x20`undefined`.','nxCloudVersion','post','../../../utilities/axios','gzip','toString','promisify','status','defaults','RUNNER_FAILURE_PERF_ENTRY','value','done','Run\x20Details:','api','RunEnd.\x20Completed\x20tasks','urls','startRun','Invalid\x20end\x20run\x20response','messages','next','../../../utilities/metric-logger','string','getRunGroup','readFileSync','__esModule','createReqBody','error','defineProperty','printDuration','apiAxiosInstance','machineInfo','/nx-cloud/runs/start','note','@nrwl/nx-cloud','nx-cloud','headers','then','axiosException','createApiAxiosInstance','throw','Invalid\x20end\x20run\x20response:\x20','createMetricRecorder','isConnectedToPrivateCloud','zlib','apiError','response','uploadedToStorage','terminalOutput','getBranch','success','runUrl','recordMetric','axiosMultipleTries','runContext','../../../utilities/is-private-cloud','map','mapRespToPerfEntry','devDependencies','message','extractErrorMessage','assign','RunEnd\x20duration','slice','unknown','data','endRun','getCIExecutionId','getCIExecutionEnv','Invalid\x20Nx\x20Cloud\x20response:\x20','stringify','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','from'];(function(_0x5cfd21,_0x42665a){const _0x2b2436=function(_0x4bc1ab){while(--_0x4bc1ab){_0x5cfd21['push'](_0x5cfd21['shift']());}};_0x2b2436(++_0x42665a);}(a3_0x4266,0x1ea));const a3_0x2b24=function(_0x5cfd21,_0x42665a){_0x5cfd21=_0x5cfd21-0x0;let _0x2b2436=a3_0x4266[_0x5cfd21];return _0x2b2436;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x5570dc,_0x315676,_0x436fe7,_0x2594ba){function _0xfb591d(_0x586897){return _0x586897 instanceof _0x436fe7?_0x586897:new _0x436fe7(function(_0x10289a){_0x10289a(_0x586897);});}return new(_0x436fe7||(_0x436fe7=Promise))(function(_0x2fea87,_0x2759f1){function _0x69b4bf(_0x3f9f8d){try{_0x48f0b2(_0x2594ba[a3_0x2b24('0x49')](_0x3f9f8d));}catch(_0x54ef38){_0x2759f1(_0x54ef38);}}function _0x115805(_0x18c9c6){try{_0x48f0b2(_0x2594ba[a3_0x2b24('0x10')](_0x18c9c6));}catch(_0xe9b857){_0x2759f1(_0xe9b857);}}function _0x48f0b2(_0x365356){_0x365356[a3_0x2b24('0x41')]?_0x2fea87(_0x365356[a3_0x2b24('0x40')]):_0xfb591d(_0x365356[a3_0x2b24('0x40')])[a3_0x2b24('0xd')](_0x69b4bf,_0x115805);}_0x48f0b2((_0x2594ba=_0x2594ba['apply'](_0x5570dc,_0x315676||[]))['next']());});};Object[a3_0x2b24('0x4')](exports,a3_0x2b24('0x1'),{'value':!![]});exports['CloudRunApi']=void 0x0;const axios_1=require(a3_0x2b24('0x39'));const environment_1=require('../../../utilities/environment');const fs_1=require('fs');const zlib_1=require(a3_0x2b24('0x14'));const util_1=require('util');const metric_logger_1=require(a3_0x2b24('0x4a'));const is_private_cloud_1=require(a3_0x2b24('0x1f'));const {output}=require('../../../utilities/nx-imports');class CloudRunApi{constructor(_0x4ff02c,_0x510be9,_0x275bd4,_0x4ef45d){this[a3_0x2b24('0x48')]=_0x4ff02c;this[a3_0x2b24('0x1e')]=_0x510be9;this[a3_0x2b24('0x7')]=_0x4ef45d;this[a3_0x2b24('0x6')]=(0x0,axios_1[a3_0x2b24('0xf')])(_0x275bd4);}[a3_0x2b24('0x46')](_0x1c0a58,_0x420bb5){var _0x18a193;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages']['apiError'])return{};const _0x45a1e8=(0x0,metric_logger_1[a3_0x2b24('0x12')])(a3_0x2b24('0x46'));try{const _0x17c9ec={'meta':{'nxCloudVersion':this[a3_0x2b24('0x37')]()},'branch':(0x0,environment_1[a3_0x2b24('0x19')])(),'runGroup':(0x0,environment_1[a3_0x2b24('0x4c')])(),'ciExecutionId':(0x0,environment_1[a3_0x2b24('0x2b')])(),'ciExecutionEnv':(0x0,environment_1[a3_0x2b24('0x2c')])(),'distributedExecutionId':_0x1c0a58,'hashes':_0x420bb5};if(environment_1['VERBOSE_LOGGING']){output[a3_0x2b24('0x9')]({'title':'RunStart','bodyLines':['\x0a'+JSON[a3_0x2b24('0x2e')](_0x17c9ec,null,0x2)]});}const _0x3584d5=yield(0x0,axios_1[a3_0x2b24('0x5')])(a3_0x2b24('0x34'),()=>(0x0,axios_1[a3_0x2b24('0x1d')])(()=>this['apiAxiosInstance']['post'](a3_0x2b24('0x8'),_0x17c9ec)));_0x45a1e8[a3_0x2b24('0x1c')]((0x0,metric_logger_1[a3_0x2b24('0x21')])(_0x3584d5));if(_0x3584d5[a3_0x2b24('0x29')]&&_0x3584d5['data']['message']){this['messages'][a3_0x2b24('0x23')]=_0x3584d5[a3_0x2b24('0x29')][a3_0x2b24('0x23')];}if(!_0x3584d5['data']||!_0x3584d5[a3_0x2b24('0x29')][a3_0x2b24('0x45')]){this[a3_0x2b24('0x48')]['apiError']=a3_0x2b24('0x2d')+JSON[a3_0x2b24('0x2e')](_0x3584d5[a3_0x2b24('0x29')]);return{};}return _0x3584d5[a3_0x2b24('0x29')][a3_0x2b24('0x45')];}catch(_0x2751a8){_0x45a1e8[a3_0x2b24('0x1c')](((_0x18a193=_0x2751a8===null||_0x2751a8===void 0x0?void 0x0:_0x2751a8[a3_0x2b24('0xe')])===null||_0x18a193===void 0x0?void 0x0:_0x18a193[a3_0x2b24('0x16')])?(0x0,metric_logger_1[a3_0x2b24('0x21')])(_0x2751a8[a3_0x2b24('0xe')][a3_0x2b24('0x16')]):metric_logger_1[a3_0x2b24('0x3f')]);this[a3_0x2b24('0x48')][a3_0x2b24('0x15')]=this[a3_0x2b24('0x48')][a3_0x2b24('0x24')](_0x2751a8,a3_0x2b24('0x43'));return{};}});}[a3_0x2b24('0x2')](_0x22e9dc,_0x288a3a,_0x48094c,_0x200fca){if((0x0,is_private_cloud_1[a3_0x2b24('0x13')])()){for(let _0x5a24b2 of _0x288a3a){delete _0x5a24b2[a3_0x2b24('0x17')];}}const _0x4d09c0=Object[a3_0x2b24('0x25')](Object[a3_0x2b24('0x25')]({'meta':{'nxCloudVersion':this[a3_0x2b24('0x37')]()},'tasks':_0x288a3a,'run':_0x22e9dc,'linkId':_0x200fca},(0x0,is_private_cloud_1[a3_0x2b24('0x13')])()?{}:_0x48094c),{'machineInfo':this[a3_0x2b24('0x7')]});return JSON['stringify'](_0x4d09c0);}[a3_0x2b24('0x2a')](_0x14c957,_0x378893,_0xb73d83,_0x539a6d){var _0x16bcb6,_0x3bd18e;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x2b24('0x48')][a3_0x2b24('0x15')])return![];let _0x35f8fc=this['createReqBody'](_0x14c957,_0x378893,_0xb73d83,_0x539a6d);if(_0x35f8fc['length']>0x14*0x3e8*0x3e8){_0x35f8fc=this[a3_0x2b24('0x2')](_0x14c957,_0x378893[a3_0x2b24('0x20')](_0xf3d59a=>Object[a3_0x2b24('0x25')](Object['assign']({},_0xf3d59a),{'hashDetails':undefined})),_0xb73d83,_0x539a6d);}const _0x23559a=Buffer[a3_0x2b24('0x30')](_0x35f8fc);const _0x7d2707=yield(0x0,util_1[a3_0x2b24('0x3c')])(zlib_1['gzip'])(_0x23559a);const _0x28e138=(0x0,metric_logger_1['createMetricRecorder'])(a3_0x2b24('0x2a'));try{if(environment_1[a3_0x2b24('0x35')]){const _0x17a710=_0x378893[a3_0x2b24('0x20')](_0x4fbf16=>{return Object[a3_0x2b24('0x25')](Object[a3_0x2b24('0x25')]({},_0x4fbf16),{'terminalOutput':_0x4fbf16[a3_0x2b24('0x18')]?_0x4fbf16[a3_0x2b24('0x18')][a3_0x2b24('0x27')](0x0,0x14)+a3_0x2b24('0x31'):undefined});});output['note']({'title':a3_0x2b24('0x44'),'bodyLines':['\x0a'+JSON[a3_0x2b24('0x2e')](_0x17a710,null,0x2)]});}const _0x24faa4=yield(0x0,axios_1[a3_0x2b24('0x5')])(a3_0x2b24('0x26'),()=>(0x0,axios_1['axiosMultipleTries'])(()=>this[a3_0x2b24('0x6')][a3_0x2b24('0x38')](a3_0x2b24('0x33'),_0x7d2707,{'headers':Object[a3_0x2b24('0x25')](Object[a3_0x2b24('0x25')]({},this[a3_0x2b24('0x6')][a3_0x2b24('0x3e')][a3_0x2b24('0xc')]),{'Content-Encoding':a3_0x2b24('0x3a'),'Content-Type':'application/octet-stream'})})));if(_0x24faa4){_0x28e138[a3_0x2b24('0x1c')]((0x0,metric_logger_1[a3_0x2b24('0x21')])(_0x24faa4));if(_0x24faa4['data']&&_0x24faa4[a3_0x2b24('0x29')][a3_0x2b24('0x1b')]&&_0x24faa4[a3_0x2b24('0x29')][a3_0x2b24('0x3d')]===a3_0x2b24('0x1a')){this[a3_0x2b24('0x1e')]['runUrl']=_0x24faa4[a3_0x2b24('0x29')][a3_0x2b24('0x1b')];return!![];}if(_0x24faa4[a3_0x2b24('0x29')]&&_0x24faa4[a3_0x2b24('0x29')][a3_0x2b24('0x3d')]){this[a3_0x2b24('0x48')][a3_0x2b24('0x15')]=a3_0x2b24('0x11')+JSON[a3_0x2b24('0x2e')](_0x24faa4[a3_0x2b24('0x29')]['message']);}else if(_0x24faa4[a3_0x2b24('0x29')]&&typeof _0x24faa4[a3_0x2b24('0x29')]===a3_0x2b24('0x4b')){if(_0x24faa4['data']!==a3_0x2b24('0x1a')){this[a3_0x2b24('0x48')][a3_0x2b24('0x15')]=a3_0x2b24('0x11')+JSON[a3_0x2b24('0x2e')](_0x24faa4[a3_0x2b24('0x29')]);}}else{this[a3_0x2b24('0x48')][a3_0x2b24('0x15')]='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0x2b24('0x2e')](_0x24faa4[a3_0x2b24('0x29')]);}if(environment_1[a3_0x2b24('0x35')]){output[a3_0x2b24('0x9')]({'title':a3_0x2b24('0x47'),'bodyLines':[JSON[a3_0x2b24('0x2e')](_0x24faa4[a3_0x2b24('0x29')],null,0x2)]});}}else{output[a3_0x2b24('0x3')]({'title':a3_0x2b24('0x2f'),'bodyLines':[a3_0x2b24('0x36'),a3_0x2b24('0x42'),JSON[a3_0x2b24('0x2e')](_0x14c957,null,0x2),'Stack\x20Trace:',JSON[a3_0x2b24('0x2e')](new Error()['stack'],null,0x2)]});}return![];}catch(_0x4ef124){_0x28e138[a3_0x2b24('0x1c')](((_0x16bcb6=_0x4ef124===null||_0x4ef124===void 0x0?void 0x0:_0x4ef124[a3_0x2b24('0xe')])===null||_0x16bcb6===void 0x0?void 0x0:_0x16bcb6[a3_0x2b24('0x16')])?(0x0,metric_logger_1[a3_0x2b24('0x21')])(_0x4ef124[a3_0x2b24('0xe')][a3_0x2b24('0x16')]):metric_logger_1[a3_0x2b24('0x3f')]);const _0x12613c=(_0x3bd18e=_0x4ef124[a3_0x2b24('0xe')])!==null&&_0x3bd18e!==void 0x0?_0x3bd18e:_0x4ef124;this[a3_0x2b24('0x48')][a3_0x2b24('0x15')]=this[a3_0x2b24('0x48')]['extractErrorMessage'](_0x12613c,a3_0x2b24('0x43'));return![];}});}['nxCloudVersion'](){try{const _0x5d9331=JSON[a3_0x2b24('0x32')]((0x0,fs_1[a3_0x2b24('0x0')])('package.json')[a3_0x2b24('0x3b')]());return _0x5d9331[a3_0x2b24('0x22')][a3_0x2b24('0xb')]||_0x5d9331[a3_0x2b24('0x22')][a3_0x2b24('0xa')];}catch(_0x109b5b){return a3_0x2b24('0x28');}}}exports['CloudRunApi']=CloudRunApi;
"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');
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

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

const a4_0x11e4=['toLowerCase','__esModule','defineProperty','ABCDEFGHIJKLMNOPQRSTUVWXYZ','generateUniqueLinkId','length'];(function(_0x3c21c7,_0x11e409){const _0x4a7ced=function(_0x422275){while(--_0x422275){_0x3c21c7['push'](_0x3c21c7['shift']());}};_0x4a7ced(++_0x11e409);}(a4_0x11e4,0x160));const a4_0x4a7c=function(_0x3c21c7,_0x11e409){_0x3c21c7=_0x3c21c7-0x0;let _0x4a7ced=a4_0x11e4[_0x3c21c7];return _0x4a7ced;};'use strict';Object[a4_0x4a7c('0x4')](exports,a4_0x4a7c('0x3'),{'value':!![]});exports[a4_0x4a7c('0x0')]=void 0x0;const upper=a4_0x4a7c('0x5');const digits='0123456789';const lower=upper[a4_0x4a7c('0x2')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x505754='';for(let _0x37b959=0x0;_0x37b959<0xa;++_0x37b959){_0x505754+=alphanum[Math['floor'](Math['random']()*alphanum[a4_0x4a7c('0x1')])];}return _0x505754;}exports[a4_0x4a7c('0x0')]=generateUniqueLinkId;
"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

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

const a5_0x5372=['apply','response','VERBOSE_LOGGING','done','ciExecutionEnv:\x20','RUNNER_FAILURE_PERF_ENTRY','agentName','completeRunGroupWithError','next','runGroup:\x20','mapRespToPerfEntry','runGroup','__awaiter','value','apiAxiosInstance','tasks','post','recordMetric','DistributedAgentApi','Completed\x20run\x20group\x20with\x20an\x20error','axiosMultipleTries','branch','error','defineProperty','ciExecutionId','data','axiosException','ciExecutionId:\x20','note','../../../utilities/metric-logger','createMetricRecorder','/nx-cloud/executions/tasks','ciExecutionEnv','dtePollTasks','then','../../../utilities/axios','__esModule','/nx-cloud/executions/complete-run-group','throw'];(function(_0x12a74e,_0x53721b){const _0x2f0d82=function(_0x20ffc5){while(--_0x20ffc5){_0x12a74e['push'](_0x12a74e['shift']());}};_0x2f0d82(++_0x53721b);}(a5_0x5372,0xb2));const a5_0x2f0d=function(_0x12a74e,_0x53721b){_0x12a74e=_0x12a74e-0x0;let _0x2f0d82=a5_0x5372[_0x12a74e];return _0x2f0d82;};'use strict';var __awaiter=this&&this[a5_0x2f0d('0x1d')]||function(_0x3696d0,_0x450901,_0x4eea8a,_0xcdc006){function _0x517c6e(_0x3572ec){return _0x3572ec instanceof _0x4eea8a?_0x3572ec:new _0x4eea8a(function(_0x2e7eb8){_0x2e7eb8(_0x3572ec);});}return new(_0x4eea8a||(_0x4eea8a=Promise))(function(_0x4d2e7a,_0xa52c0d){function _0x466ee9(_0x398b48){try{_0x462d30(_0xcdc006[a5_0x2f0d('0x19')](_0x398b48));}catch(_0x16fdd2){_0xa52c0d(_0x16fdd2);}}function _0x5a5a25(_0x2d6888){try{_0x462d30(_0xcdc006[a5_0x2f0d('0x10')](_0x2d6888));}catch(_0x216414){_0xa52c0d(_0x216414);}}function _0x462d30(_0x3d2b03){_0x3d2b03[a5_0x2f0d('0x14')]?_0x4d2e7a(_0x3d2b03[a5_0x2f0d('0x1e')]):_0x517c6e(_0x3d2b03[a5_0x2f0d('0x1e')])[a5_0x2f0d('0xc')](_0x466ee9,_0x5a5a25);}_0x462d30((_0xcdc006=_0xcdc006[a5_0x2f0d('0x11')](_0x3696d0,_0x450901||[]))[a5_0x2f0d('0x19')]());});};Object[a5_0x2f0d('0x1')](exports,a5_0x2f0d('0xe'),{'value':!![]});exports[a5_0x2f0d('0x23')]=void 0x0;const axios_1=require(a5_0x2f0d('0xd'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a5_0x2f0d('0x7'));const {output}=require('../../../utilities/nx-imports');class DistributedAgentApi{constructor(_0x45b419,_0x24c46d,_0x236d79,_0x4c5c28,_0x39f2d8,_0x5b1552){this[a5_0x2f0d('0x26')]=_0x24c46d;this[a5_0x2f0d('0x1c')]=_0x236d79;this['ciExecutionId']=_0x4c5c28;this[a5_0x2f0d('0xa')]=_0x39f2d8;this[a5_0x2f0d('0x17')]=_0x5b1552;this[a5_0x2f0d('0x1f')]=(0x0,axios_1['createApiAxiosInstance'])(_0x45b419);}[a5_0x2f0d('0x20')](_0x3ba70d,_0x5696ac,_0x3eb7d1,_0x40d56b){var _0x29f1e3;return __awaiter(this,void 0x0,void 0x0,function*(){const _0xccc14=(0x0,metric_logger_1[a5_0x2f0d('0x8')])(a5_0x2f0d('0xb'));try{const _0x29ca23=yield(0x0,axios_1[a5_0x2f0d('0x25')])(()=>this[a5_0x2f0d('0x1f')][a5_0x2f0d('0x21')](a5_0x2f0d('0x9'),{'runGroup':this[a5_0x2f0d('0x1c')],'ciExecutionId':this[a5_0x2f0d('0x2')],'ciExecutionEnv':this['ciExecutionEnv'],'agentName':this[a5_0x2f0d('0x17')],'executionId':_0x3ba70d,'statusCode':_0x5696ac,'completedTasks':_0x3eb7d1,'targets':_0x40d56b}));_0xccc14[a5_0x2f0d('0x22')]((0x0,metric_logger_1[a5_0x2f0d('0x1b')])(_0x29ca23));return _0x29ca23[a5_0x2f0d('0x3')];}catch(_0x24592d){_0xccc14[a5_0x2f0d('0x22')](((_0x29f1e3=_0x24592d===null||_0x24592d===void 0x0?void 0x0:_0x24592d[a5_0x2f0d('0x4')])===null||_0x29f1e3===void 0x0?void 0x0:_0x29f1e3[a5_0x2f0d('0x12')])?(0x0,metric_logger_1[a5_0x2f0d('0x1b')])(_0x24592d[a5_0x2f0d('0x4')][a5_0x2f0d('0x12')]):metric_logger_1[a5_0x2f0d('0x16')]);throw _0x24592d;}});}[a5_0x2f0d('0x18')](_0x493c95){var _0x4ac06a;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a5_0x2f0d('0x13')]){output[a5_0x2f0d('0x6')]({'title':'Completing\x20with\x20an\x20error','bodyLines':[a5_0x2f0d('0x5')+this[a5_0x2f0d('0x2')],a5_0x2f0d('0x15')+this[a5_0x2f0d('0xa')],a5_0x2f0d('0x1a')+this[a5_0x2f0d('0x1c')],'error:\x20'+_0x493c95]});}const _0x34f6a3=(0x0,metric_logger_1[a5_0x2f0d('0x8')])('completeRunGroup');try{const _0x3c4d1b=yield(0x0,axios_1[a5_0x2f0d('0x25')])(()=>this[a5_0x2f0d('0x1f')][a5_0x2f0d('0x21')](a5_0x2f0d('0xf'),{'branch':this[a5_0x2f0d('0x26')],'runGroup':this['runGroup'],'ciExecutionId':this['ciExecutionId'],'ciExecutionEnv':this[a5_0x2f0d('0xa')],'agentName':this['agentName'],'criticalErrorMessage':_0x493c95}));if(environment_1['VERBOSE_LOGGING']){output[a5_0x2f0d('0x6')]({'title':a5_0x2f0d('0x24')});}_0x34f6a3['recordMetric']((0x0,metric_logger_1[a5_0x2f0d('0x1b')])(_0x3c4d1b));}catch(_0x357fb7){_0x34f6a3['recordMetric'](((_0x4ac06a=_0x357fb7===null||_0x357fb7===void 0x0?void 0x0:_0x357fb7[a5_0x2f0d('0x4')])===null||_0x4ac06a===void 0x0?void 0x0:_0x4ac06a['response'])?(0x0,metric_logger_1[a5_0x2f0d('0x1b')])(_0x357fb7[a5_0x2f0d('0x4')][a5_0x2f0d('0x12')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);console[a5_0x2f0d('0x0')](_0x357fb7);}});}}exports[a5_0x2f0d('0x23')]=DistributedAgentApi;
"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');
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

@@ -1,1 +0,170 @@

const a6_0x106a=['note','catch','submitRunMetrics','parse','map','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','cacheableOperations','readdirSync','../../file-storage/e2e-encryption','trim','invokeTasksUsingRunMany','Nx\x20Cloud:\x20Workspace\x20is\x20disabled','defineProperty','E2EEncryption','readFileSync','../../error/print-cacheable-targets-error','strip-json-comments','./invoke-tasks-using-run-many','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20[','completeRunGroupWithError','split','__awaiter','getCIExecutionId','../../../utilities/nx-imports','floor','FileStorage','runner','SIGTERM','toString','encryptionKey','apply','yargs-parser','some','executeTasks','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','next','isWorkspaceEnabled','startAgent','dte-agent','../../../utilities/metric-logger','default','filter','../../api/error-reporter.api','../../../utilities/dte-artifact-storage','join','Organization\x20administrators\x20can\x20find\x20more\x20information\x20on\x20the\x20\x27Billing\x20and\x20Plans\x27\x20page\x20in\x20the\x20Nx\x20Cloud\x20Webapp','mkdirSync','error','ENCRYPTION_KEY','DistributedAgentApi','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','length','includes','CIRCLE_JOB','Distributed\x20Task\x20Execution\x20is\x20disabled\x20when\x20your\x20workspace\x20is\x20disabled','./distributed-agent.api','done','./execute-tasks','/nx.json','/lockfiles','env','Critical\x20Error\x20in\x20Agent:\x20\x22','DteArtifactStorage','nx-cloud','@nrwl/nx-cloud','invokeTasksUsingNxImperativeApi','existsSync','Agent\x20','options','CIRCLECI','targets','warn','Agent\x20was\x20terminated\x20via\x20SIGTERM','Agent\x20was\x20terminated\x20via\x20SIGINT','.lock','getBranch','CIRCLE_STAGE','unlinkSync','printInvalidRunnerError','../../../utilities/environment','canDetectRunGroup','NX_AGENT_NAME','./invoke-tasks-using-nx-imperative-api','value','exit','getRunGroup'];(function(_0x4cf049,_0x106aa0){const _0x191b70=function(_0x1ef793){while(--_0x1ef793){_0x4cf049['push'](_0x4cf049['shift']());}};_0x191b70(++_0x106aa0);}(a6_0x106a,0x1a7));const a6_0x191b=function(_0x4cf049,_0x106aa0){_0x4cf049=_0x4cf049-0x0;let _0x191b70=a6_0x106a[_0x4cf049];return _0x191b70;};'use strict';var __awaiter=this&&this[a6_0x191b('0x1c')]||function(_0x1c29a0,_0x4d1aee,_0xf9304b,_0x286da1){function _0x3fea52(_0x2cdb1a){return _0x2cdb1a instanceof _0xf9304b?_0x2cdb1a:new _0xf9304b(function(_0x2933da){_0x2933da(_0x2cdb1a);});}return new(_0xf9304b||(_0xf9304b=Promise))(function(_0x109087,_0x260a5a){function _0x5de00f(_0x4e299a){try{_0x4f8fb6(_0x286da1[a6_0x191b('0x2a')](_0x4e299a));}catch(_0x48181b){_0x260a5a(_0x48181b);}}function _0x52c55c(_0x5248b4){try{_0x4f8fb6(_0x286da1['throw'](_0x5248b4));}catch(_0x29ff95){_0x260a5a(_0x29ff95);}}function _0x4f8fb6(_0x1cf465){_0x1cf465[a6_0x191b('0x3f')]?_0x109087(_0x1cf465[a6_0x191b('0x4')]):_0x3fea52(_0x1cf465[a6_0x191b('0x4')])['then'](_0x5de00f,_0x52c55c);}_0x4f8fb6((_0x286da1=_0x286da1[a6_0x191b('0x25')](_0x1c29a0,_0x4d1aee||[]))['next']());});};Object[a6_0x191b('0x13')](exports,'__esModule',{'value':!![]});exports['startAgent']=void 0x0;const fs_1=require('fs');const stripJsonComments=require(a6_0x191b('0x17'));const yargsParser=require(a6_0x191b('0x26'));const environment_1=require(a6_0x191b('0x0'));const metric_logger_1=require(a6_0x191b('0x2e'));const print_cacheable_targets_error_1=require(a6_0x191b('0x16'));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(a6_0x191b('0x3e'));const execute_tasks_1=require(a6_0x191b('0x40'));const dte_artifact_storage_1=require(a6_0x191b('0x32'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a6_0x191b('0xf'));const error_reporter_api_1=require(a6_0x191b('0x31'));const invoke_tasks_using_run_many_1=require(a6_0x191b('0x18'));const invoke_tasks_using_nx_imperative_api_1=require(a6_0x191b('0x3'));const is_workspace_enabled_1=require('../../../utilities/is-workspace-enabled');const {output,initTasksRunner,workspaceRoot,cacheDirectory}=require(a6_0x191b('0x1e'));const args=yargsParser(process['argv'],{'array':['targets'],'default':{}});if(args[a6_0x191b('0x4d')]&&args[a6_0x191b('0x4d')]['length']===0x1){args['targets']=args[a6_0x191b('0x4d')][0x0][a6_0x191b('0x1b')](',')[a6_0x191b('0xb')](_0x5aa352=>_0x5aa352[a6_0x191b('0x10')]());}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x11c4ec=(0x0,environment_1[a6_0x191b('0x52')])();const _0xf164a4=(0x0,environment_1[a6_0x191b('0x6')])();const _0x433fed=(0x0,environment_1[a6_0x191b('0x1d')])();const _0x557f85=(0x0,environment_1['getCIExecutionEnv'])();if(!(0x0,print_run_group_error_1[a6_0x191b('0x1')])(_0xf164a4,_0x433fed)){(0x0,print_run_group_error_1['printRunGroupError'])();process[a6_0x191b('0x5')](0x1);}if(args[a6_0x191b('0x4d')]&&args[a6_0x191b('0x4d')]['length']){output[a6_0x191b('0x7')]({'title':a6_0x191b('0x19')+args['targets'][a6_0x191b('0x33')](',\x20')+']'});}else{output['note']({'title':'Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks'});}const _0x431b93=JSON[a6_0x191b('0xa')](stripJsonComments((0x0,fs_1[a6_0x191b('0x15')])(workspaceRoot+a6_0x191b('0x41'))[a6_0x191b('0x23')]()))['tasksRunnerOptions'][a6_0x191b('0x2f')];if(_0x431b93[a6_0x191b('0x21')]!==a6_0x191b('0x46')&&_0x431b93[a6_0x191b('0x21')]!==a6_0x191b('0x47')){(0x0,print_invalid_runner_error_1[a6_0x191b('0x55')])();return process[a6_0x191b('0x5')](0x1);}const _0x5e69f3=_0x431b93[a6_0x191b('0x4b')];if(args['targets']&&args[a6_0x191b('0x4d')][a6_0x191b('0x27')](_0x482007=>{var _0x3ec261;return!((_0x3ec261=_0x5e69f3[a6_0x191b('0xd')])===null||_0x3ec261===void 0x0?void 0x0:_0x3ec261[a6_0x191b('0x3b')](_0x482007));})){const _0x442dc5=args[a6_0x191b('0x4d')][a6_0x191b('0x30')](_0x3d292b=>{var _0x257c81;return!((_0x257c81=_0x5e69f3[a6_0x191b('0xd')])===null||_0x257c81===void 0x0?void 0x0:_0x257c81['includes'](_0x3d292b));});(0x0,print_cacheable_targets_error_1['printCacheableTargetsError'])(_0x442dc5);return process[a6_0x191b('0x5')](0x1);}const _0x847a4=yield(0x0,is_workspace_enabled_1[a6_0x191b('0x2b')])(_0x5e69f3);if(!_0x847a4){output[a6_0x191b('0x36')]({'title':a6_0x191b('0x12'),'bodyLines':[a6_0x191b('0x3d'),'',a6_0x191b('0x34')]});process['exit'](0x1);}const _0x4dd191=getAgentName();const _0x1479db=new distributed_agent_api_1[(a6_0x191b('0x38'))](_0x5e69f3,_0x11c4ec,_0xf164a4,_0x433fed,_0x557f85,_0x4dd191);createAgentLockfileAndSetUpListeners(_0x1479db,_0x5e69f3,_0x4dd191);const _0x413e8f=new e2e_encryption_1[(a6_0x191b('0x14'))](environment_1[a6_0x191b('0x37')]||_0x5e69f3[a6_0x191b('0x24')]);const _0x39bf6b=new error_reporter_api_1['ErrorReporterApi'](_0x5e69f3);const _0x2f18e3=new dte_artifact_storage_1[(a6_0x191b('0x45'))](new file_storage_1[(a6_0x191b('0x20'))](_0x413e8f,_0x39bf6b,_0x5e69f3,a6_0x191b('0x2d')),cacheDirectory);const _0x545f14=initTasksRunner?yield(0x0,invoke_tasks_using_nx_imperative_api_1[a6_0x191b('0x48')])(_0x5e69f3):yield(0x0,invoke_tasks_using_run_many_1[a6_0x191b('0x11')])();return(0x0,execute_tasks_1[a6_0x191b('0x28')])(_0x4dd191,_0x1479db,_0x2f18e3,_0x545f14,args[a6_0x191b('0x4d')])['then'](_0x3f9154=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a6_0x191b('0x9')])(_0x5e69f3);return _0x3f9154;}))[a6_0x191b('0x8')](_0x2c886a=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x1479db[a6_0x191b('0x1a')](a6_0x191b('0x44')+_0x2c886a['message']+'\x22');throw _0x2c886a;}));});}exports[a6_0x191b('0x2c')]=startAgent;function getAgentName(){if(process[a6_0x191b('0x43')]['NX_AGENT_NAME']!==undefined){return process[a6_0x191b('0x43')][a6_0x191b('0x2')];}else if(process[a6_0x191b('0x43')][a6_0x191b('0x4c')]!==undefined&&process[a6_0x191b('0x43')]['CIRCLE_STAGE']){return process[a6_0x191b('0x43')][a6_0x191b('0x53')];}else if(process['env'][a6_0x191b('0x4c')]!==undefined&&process[a6_0x191b('0x43')][a6_0x191b('0x3c')]){return process[a6_0x191b('0x43')][a6_0x191b('0x3c')];}else{return a6_0x191b('0x4a')+Math[a6_0x191b('0x1f')](Math['random']()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x679c07,_0x567365,_0x3c4b92){const _0x48a77b=cacheDirectory+a6_0x191b('0x42');const _0xa6c68f=_0x48a77b+'/'+_0x3c4b92+a6_0x191b('0x51');if(!(0x0,fs_1[a6_0x191b('0x49')])(_0x48a77b)){(0x0,fs_1[a6_0x191b('0x35')])(_0x48a77b,{'recursive':!![]});}const _0x437cc6=(0x0,fs_1[a6_0x191b('0xe')])(_0x48a77b);if(_0x437cc6[a6_0x191b('0x3a')]){if(_0x437cc6[a6_0x191b('0x3b')](_0x3c4b92+a6_0x191b('0x51'))){output[a6_0x191b('0x36')]({'title':'Duplicate\x20Agent\x20ID\x20Detected','bodyLines':['We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','',a6_0x191b('0x39')]});process[a6_0x191b('0x5')](0x1);}output[a6_0x191b('0x4e')]({'title':'Other\x20Nx\x20Cloud\x20Agents\x20Detected','bodyLines':[a6_0x191b('0xc'),'',a6_0x191b('0x29'),'If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.']});}(0x0,fs_1['writeFileSync'])(_0xa6c68f,'');process['on'](a6_0x191b('0x5'),_0x19fd45=>{cleanupAgentLockfile(_0xa6c68f,_0x19fd45);});process['on'](a6_0x191b('0x22'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x679c07['completeRunGroupWithError'](a6_0x191b('0x4f'));cleanupAgentLockfile(_0xa6c68f,0x1);}));process['on']('SIGINT',()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x679c07['completeRunGroupWithError'](a6_0x191b('0x50'));cleanupAgentLockfile(_0xa6c68f,0x1);}));}function cleanupAgentLockfile(_0x30f616,_0x5d4925){if((0x0,fs_1[a6_0x191b('0x49')])(_0x30f616)){(0x0,fs_1[a6_0x191b('0x54')])(_0x30f616);process['exit'](_0x5d4925);}}
"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, initTasksRunner, workspaceRoot, 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

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

const a7_0x2f2b=['../../../utilities/nx-imports','number\x20of\x20tasks:\x20','url','executionId:\x20','\x20seconds','apply','../../../utilities/environment','RUN_GROUP_COMPLETED','\x20waiting...','\x20Hash:\x20','getTime','NO_FURTHER_TASKS_TO_RUN','taskId','VERBOSE_LOGGING','exit','status','\x20downloading\x20artifacts\x20for\x20','tasks','completed','NO_MESSAGES_TIMEOUT','reset','maxParallel','executionId','join','wait','completed:\x20','\x20received\x20an\x20API\x20Response','../../../utilities/create-unchanged-value-timeout','error','hash','__awaiter','retryDuring','Waiter','length','createUnchangedValueTimeout','maxParallel:\x20','completedTasks','\x20Url:\x20','completedStatusCode','note','No\x20new\x20messages\x20received\x20after\x20','error:\x20','executeTasks','throw','retryDuring:\x20','__esModule','criticalErrorMessage','../../../utilities/waiter','next','status:\x20','value'];(function(_0x4a93cc,_0x2f2bde){const _0x4e5222=function(_0x208775){while(--_0x208775){_0x4a93cc['push'](_0x4a93cc['shift']());}};_0x4e5222(++_0x2f2bde);}(a7_0x2f2b,0x19d));const a7_0x4e52=function(_0x4a93cc,_0x2f2bde){_0x4a93cc=_0x4a93cc-0x0;let _0x4e5222=a7_0x2f2b[_0x4a93cc];return _0x4e5222;};'use strict';var __awaiter=this&&this[a7_0x4e52('0x19')]||function(_0x2fc678,_0x258863,_0x322b95,_0x2c9c70){function _0x21452d(_0x38384f){return _0x38384f instanceof _0x322b95?_0x38384f:new _0x322b95(function(_0x55a54d){_0x55a54d(_0x38384f);});}return new(_0x322b95||(_0x322b95=Promise))(function(_0x12ed54,_0x32aac3){function _0x4db72d(_0x2ecc7f){try{_0x5e069c(_0x2c9c70['next'](_0x2ecc7f));}catch(_0x4b624f){_0x32aac3(_0x4b624f);}}function _0x271b70(_0x3f52df){try{_0x5e069c(_0x2c9c70[a7_0x4e52('0x26')](_0x3f52df));}catch(_0x53a73d){_0x32aac3(_0x53a73d);}}function _0x5e069c(_0x98b2c3){_0x98b2c3['done']?_0x12ed54(_0x98b2c3[a7_0x4e52('0x2d')]):_0x21452d(_0x98b2c3[a7_0x4e52('0x2d')])['then'](_0x4db72d,_0x271b70);}_0x5e069c((_0x2c9c70=_0x2c9c70[a7_0x4e52('0x0')](_0x2fc678,_0x258863||[]))[a7_0x4e52('0x2b')]());});};Object['defineProperty'](exports,a7_0x4e52('0x28'),{'value':!![]});exports[a7_0x4e52('0x25')]=void 0x0;const create_unchanged_value_timeout_1=require(a7_0x4e52('0x16'));const environment_1=require(a7_0x4e52('0x1'));const waiter_1=require(a7_0x4e52('0x2a'));const {output}=require(a7_0x4e52('0x2e'));function executeTasks(_0x336c95,_0x4c0723,_0x2f0735,_0x3ac29a,_0x4817c7){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x21b1da=0x0;let _0x3d3d9c=null;const _0xe92a44=(0x0,create_unchanged_value_timeout_1[a7_0x4e52('0x1d')])({'title':a7_0x4e52('0x23')+environment_1[a7_0x4e52('0xe')]/0x3e8+a7_0x4e52('0x32'),'timeout':environment_1['NO_MESSAGES_TIMEOUT']});const _0x4fba5c=new waiter_1[(a7_0x4e52('0x1b'))]();let _0x359251=[];const _0x34c352=new Date();let _0x53c0dd=![];const _0x42cf7f={};while(!![]){if(environment_1['VERBOSE_LOGGING']){output[a7_0x4e52('0x22')]({'title':_0x336c95+'\x20fetching\x20tasks...'});}_0x3d3d9c=yield _0x4c0723['tasks'](_0x3d3d9c?_0x3d3d9c[a7_0x4e52('0x11')]:null,_0x21b1da,_0x359251,_0x4817c7);if(environment_1[a7_0x4e52('0x8')]){output[a7_0x4e52('0x22')]({'title':_0x336c95+a7_0x4e52('0x15'),'bodyLines':[a7_0x4e52('0x14')+_0x3d3d9c[a7_0x4e52('0xd')],a7_0x4e52('0x2c')+_0x3d3d9c['status'],a7_0x4e52('0x27')+_0x3d3d9c['retryDuring'],a7_0x4e52('0x31')+_0x3d3d9c[a7_0x4e52('0x11')],a7_0x4e52('0x2f')+_0x3d3d9c[a7_0x4e52('0xc')][a7_0x4e52('0x1c')],a7_0x4e52('0x24')+_0x3d3d9c[a7_0x4e52('0x29')],a7_0x4e52('0x1e')+_0x3d3d9c[a7_0x4e52('0x10')]]});}if(_0x3d3d9c[a7_0x4e52('0x29')]){output[a7_0x4e52('0x17')]({'title':'Distributed\x20Execution\x20Terminated','bodyLines':['Error:',_0x3d3d9c['criticalErrorMessage']]});process[a7_0x4e52('0x9')](0x0);}if((_0x3d3d9c===null||_0x3d3d9c===void 0x0?void 0x0:_0x3d3d9c[a7_0x4e52('0x1a')])&&(_0x3d3d9c===null||_0x3d3d9c===void 0x0?void 0x0:_0x3d3d9c[a7_0x4e52('0x1a')])!==0x0&&!_0x53c0dd&&new Date()[a7_0x4e52('0x5')]()-_0x34c352[a7_0x4e52('0x5')]()>_0x3d3d9c[a7_0x4e52('0x1a')]){yield _0x4fba5c[a7_0x4e52('0x13')]();continue;}if((_0x3d3d9c===null||_0x3d3d9c===void 0x0?void 0x0:_0x3d3d9c[a7_0x4e52('0xa')])!==undefined){if(_0x3d3d9c[a7_0x4e52('0xa')]===a7_0x4e52('0x2')||_0x3d3d9c['status']===a7_0x4e52('0x6')){return;}}else if(_0x3d3d9c['completed']){return;}_0xe92a44(_0x3d3d9c['tasks']['map'](_0x26e7f5=>_0x26e7f5[a7_0x4e52('0x7')])[a7_0x4e52('0x12')](''));if(!_0x3d3d9c[a7_0x4e52('0x11')]){if(environment_1['VERBOSE_LOGGING']){output[a7_0x4e52('0x22')]({'title':_0x336c95+a7_0x4e52('0x3')});}yield _0x4fba5c[a7_0x4e52('0x13')]();_0x21b1da=0x0;_0x359251=[];continue;}_0x4fba5c[a7_0x4e52('0xf')]();_0x53c0dd=!![];if(_0x3d3d9c['completedTasks']){for(const _0x9f2d9a of _0x3d3d9c[a7_0x4e52('0x1f')]){if(_0x42cf7f[_0x9f2d9a[a7_0x4e52('0x7')]])continue;output[a7_0x4e52('0x22')]({'title':_0x336c95+a7_0x4e52('0xb')+_0x9f2d9a[a7_0x4e52('0x7')]+a7_0x4e52('0x4')+_0x9f2d9a[a7_0x4e52('0x18')]+a7_0x4e52('0x20')+_0x9f2d9a[a7_0x4e52('0x30')]});yield _0x2f0735['retrieveAndExtract'](_0x9f2d9a[a7_0x4e52('0x18')],_0x9f2d9a[a7_0x4e52('0x30')]);_0x42cf7f[_0x9f2d9a[a7_0x4e52('0x7')]]=!![];}}const _0x4fb1b2=yield _0x3ac29a(_0x3d3d9c[a7_0x4e52('0x11')],_0x3d3d9c[a7_0x4e52('0xc')],_0x3d3d9c[a7_0x4e52('0x10')]);for(const _0x1139fa of _0x4fb1b2['completedTasks']){_0x42cf7f[_0x1139fa[a7_0x4e52('0x7')]]=!![];}_0x21b1da=_0x4fb1b2[a7_0x4e52('0x21')];_0x359251=_0x4fb1b2[a7_0x4e52('0x1f')];}});}exports[a7_0x4e52('0x25')]=executeTasks;
"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');
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

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

const a8_0x1a24=['length','taskId','yargs-parser','env','throw','value','next','map','projectName','tasks','invokeTasksUsingNxImperativeApi','target','done','unparse','invoke','true','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','hash','params','values','taskGraph','configuration','assign','apply','__awaiter','NX_PREFIX_OUTPUT','defineProperty','../../../utilities/nx-imports'];(function(_0x513f0a,_0x1a2412){const _0xb1769f=function(_0x3bc0f8){while(--_0x3bc0f8){_0x513f0a['push'](_0x513f0a['shift']());}};_0xb1769f(++_0x1a2412);}(a8_0x1a24,0x1b9));const a8_0xb176=function(_0x513f0a,_0x1a2412){_0x513f0a=_0x513f0a-0x0;let _0xb1769f=a8_0x1a24[_0x513f0a];return _0xb1769f;};'use strict';var __awaiter=this&&this[a8_0xb176('0x3')]||function(_0x31909c,_0x31a001,_0x380491,_0x5dcbce){function _0x18fb15(_0x33a000){return _0x33a000 instanceof _0x380491?_0x33a000:new _0x380491(function(_0x5c7d6f){_0x5c7d6f(_0x33a000);});}return new(_0x380491||(_0x380491=Promise))(function(_0x46b5d3,_0x50d4f3){function _0xffa5f6(_0x5d10ec){try{_0x128129(_0x5dcbce[a8_0xb176('0xd')](_0x5d10ec));}catch(_0x36d40c){_0x50d4f3(_0x36d40c);}}function _0xe6fe4(_0x4bb7ff){try{_0x128129(_0x5dcbce[a8_0xb176('0xb')](_0x4bb7ff));}catch(_0x28966e){_0x50d4f3(_0x28966e);}}function _0x128129(_0x48e545){_0x48e545[a8_0xb176('0x13')]?_0x46b5d3(_0x48e545[a8_0xb176('0xc')]):_0x18fb15(_0x48e545[a8_0xb176('0xc')])['then'](_0xffa5f6,_0xe6fe4);}_0x128129((_0x5dcbce=_0x5dcbce[a8_0xb176('0x2')](_0x31909c,_0x31a001||[]))[a8_0xb176('0xd')]());});};Object[a8_0xb176('0x5')](exports,'__esModule',{'value':!![]});exports['invokeTasksUsingNxImperativeApi']=void 0x0;const {initTasksRunner}=require(a8_0xb176('0x6'));const parser=require(a8_0xb176('0x9'));const serializer_overrides_1=require('../../../utilities/serializer-overrides');function invokeTasksUsingNxImperativeApi(_0x4a75ea){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3cf81e=yield initTasksRunner(_0x4a75ea);return(_0xcce1d3,_0x2b64b5,_0x1d3c94)=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x1132ba=_0x2b64b5[a8_0xb176('0xe')](_0x51187f=>{const _0x182a9c=parser(_0x51187f[a8_0xb176('0x19')],{'configuration':{'camel-case-expansion':![],'dot-notation':!![]}});const _0x247628=(0x0,serializer_overrides_1[a8_0xb176('0x14')])(_0x182a9c);if(_0x182a9c['_'][a8_0xb176('0x7')]==0x0){delete _0x182a9c['_'];}return{'id':_0x51187f[a8_0xb176('0x8')],'target':{'project':_0x51187f[a8_0xb176('0xf')],'target':_0x51187f[a8_0xb176('0x12')],'configuration':_0x51187f[a8_0xb176('0x0')]},'overrides':Object[a8_0xb176('0x1')](Object[a8_0xb176('0x1')]({},_0x182a9c),{'__overrides_unparsed__':_0x247628})};});process[a8_0xb176('0xa')]['NX_CACHE_FAILURES']='true';process['env'][a8_0xb176('0x17')]=_0xcce1d3;process['env']['NX_STREAM_OUTPUT']=a8_0xb176('0x16');process['env'][a8_0xb176('0x4')]=a8_0xb176('0x16');const _0x141d49=yield _0x3cf81e[a8_0xb176('0x15')]({'tasks':_0x1132ba,'parallel':_0x1d3c94});const _0x27ed24=Object[a8_0xb176('0x1a')](_0x141d49[a8_0xb176('0x1b')][a8_0xb176('0x10')]);return{'completedTasks':_0x27ed24['map'](_0xd667d6=>({'taskId':_0xd667d6['id'],'hash':_0xd667d6[a8_0xb176('0x18')]})),'completedStatusCode':_0x141d49['status']};});});}exports[a8_0xb176('0x11')]=invokeTasksUsingNxImperativeApi;
"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

@@ -1,1 +0,96 @@

const a9_0x1b44=['--configuration=','readFileSync','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','params','value','status','true','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','VERBOSE_LOGGING','push','note','__awaiter','execSync','inherit','then','\x20--projects=','Executing:\x20\x27','projects','find','\x20--parallel\x20--max-parallel=',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','projectName','ignore','configuration','throw','toString','env','join','assign','next','child_process','defineProperty','length','target','unlinkSync','/tasks-hashes-','../../../utilities/nx-imports'];(function(_0x5addcc,_0x1b440c){const _0xaed78c=function(_0x19ad55){while(--_0x19ad55){_0x5addcc['push'](_0x5addcc['shift']());}};_0xaed78c(++_0x1b440c);}(a9_0x1b44,0x1e2));const a9_0xaed7=function(_0x5addcc,_0x1b440c){_0x5addcc=_0x5addcc-0x0;let _0xaed78c=a9_0x1b44[_0x5addcc];return _0xaed78c;};'use strict';var __awaiter=this&&this[a9_0xaed7('0xa')]||function(_0x5f0606,_0x10c902,_0x59014c,_0x1b76fd){function _0x2d3a12(_0x13384f){return _0x13384f instanceof _0x59014c?_0x13384f:new _0x59014c(function(_0x294236){_0x294236(_0x13384f);});}return new(_0x59014c||(_0x59014c=Promise))(function(_0x32770a,_0x3e51e9){function _0x348b91(_0x53ef56){try{_0x3c81dd(_0x1b76fd[a9_0xaed7('0x1c')](_0x53ef56));}catch(_0x3c7a8d){_0x3e51e9(_0x3c7a8d);}}function _0x474cea(_0x4c16d0){try{_0x3c81dd(_0x1b76fd[a9_0xaed7('0x17')](_0x4c16d0));}catch(_0x494fed){_0x3e51e9(_0x494fed);}}function _0x3c81dd(_0x3d2442){_0x3d2442['done']?_0x32770a(_0x3d2442[a9_0xaed7('0x3')]):_0x2d3a12(_0x3d2442['value'])[a9_0xaed7('0xd')](_0x348b91,_0x474cea);}_0x3c81dd((_0x1b76fd=_0x1b76fd['apply'](_0x5f0606,_0x10c902||[]))[a9_0xaed7('0x1c')]());});};Object[a9_0xaed7('0x1e')](exports,'__esModule',{'value':!![]});exports['invokeTasksUsingRunMany']=void 0x0;const environment_1=require('../../../utilities/environment');const child_process_1=require(a9_0xaed7('0x1d'));const fs_1=require('fs');const {output,cacheDirectory}=require(a9_0xaed7('0x23'));function invokeTasksUsingRunMany(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2eea35=completedTasksReader();return function _0x36ffcd(_0x26433b,_0x225938,_0x1d8027){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x411b67=0x0;const _0x2fdf7c=[];for(const _0x3f2a76 of groupByTarget(_0x225938)){const _0x2f9b28=_0x3f2a76[a9_0xaed7('0x16')]?a9_0xaed7('0x24')+_0x3f2a76['configuration']:'';const _0x352c4d=_0x1d8027>0x1?a9_0xaed7('0x12')+_0x1d8027:'';const _0x25075d='npx\x20nx\x20run-many\x20--target='+_0x3f2a76[a9_0xaed7('0x20')]+'\x20'+_0x2f9b28+a9_0xaed7('0xe')+_0x3f2a76[a9_0xaed7('0x10')][a9_0xaed7('0x1a')](',')+'\x20'+_0x3f2a76[a9_0xaed7('0x2')]+_0x352c4d;if(environment_1[a9_0xaed7('0x7')]){output[a9_0xaed7('0x9')]({'title':a9_0xaed7('0xf')+_0x25075d+'\x27'});}try{(0x0,child_process_1[a9_0xaed7('0xb')])(_0x25075d,{'stdio':[a9_0xaed7('0x15'),a9_0xaed7('0xc'),a9_0xaed7('0xc')],'env':Object[a9_0xaed7('0x1b')](Object['assign']({},process[a9_0xaed7('0x19')]),{'NX_CACHE_FAILURES':a9_0xaed7('0x5'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x26433b,'NX_STREAM_OUTPUT':a9_0xaed7('0x5'),'NX_PREFIX_OUTPUT':'true'})});_0x2fdf7c[a9_0xaed7('0x8')](..._0x2eea35(_0x26433b));}catch(_0x17aab9){if(_0x17aab9[a9_0xaed7('0x4')]===environment_1[a9_0xaed7('0x1')]){throw _0x17aab9;}else{_0x411b67=0x1;_0x2fdf7c[a9_0xaed7('0x8')](..._0x2eea35(_0x26433b));}}}return{'completedStatusCode':_0x411b67,'completedTasks':_0x2fdf7c};});};});}exports['invokeTasksUsingRunMany']=invokeTasksUsingRunMany;function groupByTarget(_0x545b93){const _0x1be3ed=[];_0x545b93['forEach'](_0x4ff27a=>{const _0x362732=_0x1be3ed[a9_0xaed7('0x11')](_0x5af6f1=>_0x5af6f1[a9_0xaed7('0x20')]===_0x4ff27a[a9_0xaed7('0x20')]&&_0x5af6f1[a9_0xaed7('0x16')]===_0x4ff27a[a9_0xaed7('0x16')]);if(_0x362732){_0x362732[a9_0xaed7('0x10')]['push'](_0x4ff27a[a9_0xaed7('0x14')]);}else{_0x1be3ed[a9_0xaed7('0x8')]({'target':_0x4ff27a[a9_0xaed7('0x20')],'projects':[_0x4ff27a[a9_0xaed7('0x14')]],'params':_0x4ff27a[a9_0xaed7('0x2')],'configuration':_0x4ff27a['configuration']});}});return _0x1be3ed;}function completedTasksReader(){return _0x28d720=>{const _0x2e2bb4=a9_0xaed7('0x6')+_0x28d720+a9_0xaed7('0x13');let _0x1d27db;try{const _0x1ade65=cacheDirectory+a9_0xaed7('0x22')+_0x28d720;_0x1d27db=JSON['parse']((0x0,fs_1[a9_0xaed7('0x0')])(_0x1ade65)[a9_0xaed7('0x18')]());(0x0,fs_1[a9_0xaed7('0x21')])(_0x1ade65);}catch(_0x623e7e){throw new Error(_0x2e2bb4);}if(_0x1d27db[a9_0xaed7('0x1f')]==0x0){throw new Error(_0x2e2bb4);}return _0x1d27db;};}
"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, 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

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

const a10_0x48c3=['runGroup:\x20','maxParallel','message','true','serializeOverrides','apiAxiosInstance','axiosException','start','note','throw','apply','map','createApiAxiosInstance','RUNNER_FAILURE_PERF_ENTRY','__awaiter','/nx-cloud/executions/status','parallel','agentCount','target','Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.','error:\x20','exit','mapRespToPerfEntry','defineProperty','../../../utilities/nx-imports','post','then','../../../utilities/axios','Starting\x20a\x20distributed\x20execution','recordMetric','ciExecutionEnv:\x20','createStartRequest','stringify','/nx-cloud/executions/complete-run-group','VERBOSE_LOGGING','parseCommand','next','axiosMultipleTries','project','enabled','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','DistributedExecutionApi','error','createMetricRecorder','stopAgentsOnFailure','data','response','ciExecutionId:\x20','../../../utilities/environment','hash','__esModule','completeRunGroupWithError'];(function(_0x5e08b8,_0x48c306){const _0x30dac5=function(_0x2ae0b6){while(--_0x2ae0b6){_0x5e08b8['push'](_0x5e08b8['shift']());}};_0x30dac5(++_0x48c306);}(a10_0x48c3,0x1ef));const a10_0x30da=function(_0x5e08b8,_0x48c306){_0x5e08b8=_0x5e08b8-0x0;let _0x30dac5=a10_0x48c3[_0x5e08b8];return _0x30dac5;};'use strict';var __awaiter=this&&this[a10_0x30da('0x27')]||function(_0x2a2c0c,_0x14a64d,_0x4d47f1,_0x331032){function _0x5c5067(_0x584877){return _0x584877 instanceof _0x4d47f1?_0x584877:new _0x4d47f1(function(_0x6c08e1){_0x6c08e1(_0x584877);});}return new(_0x4d47f1||(_0x4d47f1=Promise))(function(_0x17205a,_0xbbc72c){function _0x4af1d9(_0x1840a7){try{_0x16e640(_0x331032['next'](_0x1840a7));}catch(_0x40ad89){_0xbbc72c(_0x40ad89);}}function _0x388ad8(_0x3e8b60){try{_0x16e640(_0x331032[a10_0x30da('0x22')](_0x3e8b60));}catch(_0x53451d){_0xbbc72c(_0x53451d);}}function _0x16e640(_0x94bd96){_0x94bd96['done']?_0x17205a(_0x94bd96['value']):_0x5c5067(_0x94bd96['value'])[a10_0x30da('0x33')](_0x4af1d9,_0x388ad8);}_0x16e640((_0x331032=_0x331032[a10_0x30da('0x23')](_0x2a2c0c,_0x14a64d||[]))[a10_0x30da('0x9')]());});};Object[a10_0x30da('0x30')](exports,a10_0x30da('0x17'),{'value':!![]});exports[a10_0x30da('0x4')]=exports[a10_0x30da('0xe')]=void 0x0;const axios_1=require(a10_0x30da('0x0'));const environment_1=require(a10_0x30da('0x15'));const metric_logger_1=require('../../../utilities/metric-logger');const serializer_overrides_1=require('../../../utilities/serializer-overrides');const {output}=require(a10_0x30da('0x31'));class DistributedExecutionApi{constructor(_0x107eee){this[a10_0x30da('0x1e')]=(0x0,axios_1[a10_0x30da('0x25')])(_0x107eee);}[a10_0x30da('0x20')](_0x409e51){var _0x3f1c76;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x10e86d=(0x0,metric_logger_1[a10_0x30da('0x10')])('dteStart');let _0x301070;if(environment_1[a10_0x30da('0x7')]){output[a10_0x30da('0x21')]({'title':a10_0x30da('0x1'),'bodyLines':[JSON[a10_0x30da('0x5')](_0x409e51,null,0x2)]});}try{_0x301070=yield(0x0,axios_1[a10_0x30da('0xa')])(()=>this[a10_0x30da('0x1e')][a10_0x30da('0x32')]('/nx-cloud/executions/start',_0x409e51));_0x10e86d['recordMetric']((0x0,metric_logger_1[a10_0x30da('0x2f')])(_0x301070));}catch(_0x402b0f){_0x10e86d['recordMetric'](((_0x3f1c76=_0x402b0f===null||_0x402b0f===void 0x0?void 0x0:_0x402b0f['axiosException'])===null||_0x3f1c76===void 0x0?void 0x0:_0x3f1c76[a10_0x30da('0x13')])?(0x0,metric_logger_1[a10_0x30da('0x2f')])(_0x402b0f[a10_0x30da('0x1f')][a10_0x30da('0x13')]):metric_logger_1[a10_0x30da('0x26')]);throw _0x402b0f;}if(!_0x301070[a10_0x30da('0x12')][a10_0x30da('0xc')]){throw new Error(a10_0x30da('0x2c'));}if(_0x301070[a10_0x30da('0x12')][a10_0x30da('0xf')]){throw new Error(_0x301070[a10_0x30da('0x12')][a10_0x30da('0xf')]);}return _0x301070['data']['id'];});}['status'](_0x125ee7){var _0x1c94dc;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x11ceb6=(0x0,metric_logger_1[a10_0x30da('0x10')])('dteStatus');try{const _0x369cef=yield(0x0,axios_1[a10_0x30da('0xa')])(()=>this[a10_0x30da('0x1e')][a10_0x30da('0x32')](a10_0x30da('0x28'),{'id':_0x125ee7}));_0x11ceb6[a10_0x30da('0x2')]((0x0,metric_logger_1[a10_0x30da('0x2f')])(_0x369cef));return _0x369cef['data'];}catch(_0x22f8b6){_0x11ceb6[a10_0x30da('0x2')](((_0x1c94dc=_0x22f8b6===null||_0x22f8b6===void 0x0?void 0x0:_0x22f8b6['axiosException'])===null||_0x1c94dc===void 0x0?void 0x0:_0x1c94dc[a10_0x30da('0x13')])?(0x0,metric_logger_1[a10_0x30da('0x2f')])(_0x22f8b6[a10_0x30da('0x1f')]['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output['error']({'title':_0x22f8b6[a10_0x30da('0x1b')]});process[a10_0x30da('0x2e')](0x1);}});}[a10_0x30da('0x18')](_0x279a6d,_0x1fbfe3,_0x2db9e2,_0x2e2a70,_0x57fd22){var _0x520538;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x25c797=(0x0,metric_logger_1[a10_0x30da('0x10')])('completeRunGroup');if(environment_1['VERBOSE_LOGGING']){output[a10_0x30da('0x21')]({'title':'Completing\x20with\x20an\x20error','bodyLines':[a10_0x30da('0x14')+_0x2db9e2,a10_0x30da('0x3')+_0x2e2a70,a10_0x30da('0x19')+_0x1fbfe3,a10_0x30da('0x2d')+_0x57fd22]});}try{const _0x489656=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a10_0x30da('0x1e')][a10_0x30da('0x32')](a10_0x30da('0x6'),{'runGroup':_0x1fbfe3,'ciExecutionId':_0x2db9e2,'ciExecutionEnv':_0x2e2a70,'criticalErrorMessage':_0x57fd22}),0x3);_0x25c797[a10_0x30da('0x2')]((0x0,metric_logger_1[a10_0x30da('0x2f')])(_0x489656));}catch(_0x57694b){_0x25c797[a10_0x30da('0x2')](((_0x520538=_0x57694b===null||_0x57694b===void 0x0?void 0x0:_0x57694b[a10_0x30da('0x1f')])===null||_0x520538===void 0x0?void 0x0:_0x520538[a10_0x30da('0x13')])?(0x0,metric_logger_1[a10_0x30da('0x2f')])(_0x57694b[a10_0x30da('0x1f')][a10_0x30da('0x13')]):metric_logger_1[a10_0x30da('0x26')]);}});}}exports[a10_0x30da('0xe')]=DistributedExecutionApi;function createStartRequest(_0x2cc2f7,_0x4cfac4,_0x1760fe,_0x45e3b4,_0x46b938,_0x56a0b2,_0x2484b4){const _0x441e65=_0x46b938[a10_0x30da('0x24')](_0x84085=>{return _0x84085['map'](_0x197a6b=>{return{'taskId':_0x197a6b['id'],'hash':_0x197a6b[a10_0x30da('0x16')],'projectName':_0x197a6b[a10_0x30da('0x2b')][a10_0x30da('0xb')],'target':_0x197a6b[a10_0x30da('0x2b')]['target'],'configuration':_0x197a6b[a10_0x30da('0x2b')]['configuration']||null,'params':(0x0,serializer_overrides_1[a10_0x30da('0x1d')])(_0x197a6b)};});});const _0x1c3fd0={'command':(0x0,environment_1[a10_0x30da('0x8')])(),'branch':_0x2cc2f7,'runGroup':_0x4cfac4,'ciExecutionId':_0x1760fe,'ciExecutionEnv':_0x45e3b4,'tasks':_0x441e65,'maxParallel':calculateMaxParallel(_0x56a0b2),'commitSha':_0x2484b4};if(environment_1[a10_0x30da('0xd')]){_0x1c3fd0[a10_0x30da('0x2a')]=environment_1[a10_0x30da('0xd')];}if(!environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE']){_0x1c3fd0[a10_0x30da('0x11')]=![];}return _0x1c3fd0;}exports[a10_0x30da('0x4')]=createStartRequest;function calculateMaxParallel(_0xf36fb7){if(_0xf36fb7[a10_0x30da('0x29')]==='false'||_0xf36fb7['parallel']===![]){return 0x1;}else if(_0xf36fb7[a10_0x30da('0x29')]===a10_0x30da('0x1c')||_0xf36fb7['parallel']===!![]){return Number(_0xf36fb7[a10_0x30da('0x1a')]||0x3);}else if(_0xf36fb7['parallel']===undefined){return _0xf36fb7['maxParallel']?Number(_0xf36fb7['maxParallel']):0x3;}else{return Number(_0xf36fb7[a10_0x30da('0x29')])||0x3;}}
"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');
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

@@ -1,1 +0,120 @@

const a11_0x9ff6=['processTasks','__esModule','message','success','then','values','See\x20run\x20details\x20at\x20','../../file-storage/file-storage','getCIExecutionEnv','value','endTasks','SIGINT','ENCRYPTION_KEY','encryptionKey','./process-tasks','defineProperty','skipNxCache','Main\x20job\x20was\x20terminated\x20via\x20SIGTERM','lifeCycle','Command\x20execution\x20failed.','SIGTERM','next','extractGitRef','VERBOSE_LOGGING','Starting\x20distributed\x20command\x20execution','dte-main','DTE\x20needs\x20the\x20cache\x20to\x20share\x20files\x20between\x20agents.','../../../utilities/environment','extractGitSha','throw','__awaiter','startTask','runUrl','../../../utilities/dte-artifact-storage','Main\x20job\x20was\x20terminated\x20via\x20SIGINT','log','../../api/error-reporter.api','error','scheduleTask','DteArtifactStorage','Successfully\x20completed\x20running\x20the\x20command.','getCIExecutionId','printRunGroupError','completeRunGroupWithError','createTaskGraphCompat','getBranch','FileStorage','E2EEncryption','ErrorReporterApi','submitRunMetrics','commandStatus','exit','./distributed-execution.api','done','getRunGroup','note','warn','nxCloudDistributedTasksRunner','../../file-storage/e2e-encryption','../../error/print-run-group-error','--skip-nx-cache\x20is\x20ignored\x20when\x20using\x20distributed\x20tasks\x20execution\x20(DTE).','createStartRequest','tasks','Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','./task-graph-creator','Unable\x20to\x20complete\x20a\x20run.'];(function(_0x9cad56,_0x9ff61f){const _0x578773=function(_0x1bf351){while(--_0x1bf351){_0x9cad56['push'](_0x9cad56['shift']());}};_0x578773(++_0x9ff61f);}(a11_0x9ff6,0x8d));const a11_0x5787=function(_0x9cad56,_0x9ff61f){_0x9cad56=_0x9cad56-0x0;let _0x578773=a11_0x9ff6[_0x9cad56];return _0x578773;};'use strict';var __awaiter=this&&this[a11_0x5787('0x15')]||function(_0x5473bf,_0x1c022d,_0x19f8db,_0x4a2764){function _0x1df354(_0x2afee7){return _0x2afee7 instanceof _0x19f8db?_0x2afee7:new _0x19f8db(function(_0x1338da){_0x1338da(_0x2afee7);});}return new(_0x19f8db||(_0x19f8db=Promise))(function(_0x4e3ca9,_0x5b4907){function _0x57e414(_0x4e4171){try{_0x34cd24(_0x4a2764[a11_0x5787('0xc')](_0x4e4171));}catch(_0x3a4e89){_0x5b4907(_0x3a4e89);}}function _0x1729ac(_0xc254ec){try{_0x34cd24(_0x4a2764[a11_0x5787('0x14')](_0xc254ec));}catch(_0x22c330){_0x5b4907(_0x22c330);}}function _0x34cd24(_0x36dd4c){_0x36dd4c[a11_0x5787('0x2c')]?_0x4e3ca9(_0x36dd4c['value']):_0x1df354(_0x36dd4c[a11_0x5787('0x0')])[a11_0x5787('0x3d')](_0x57e414,_0x1729ac);}_0x34cd24((_0x4a2764=_0x4a2764['apply'](_0x5473bf,_0x1c022d||[]))[a11_0x5787('0xc')]());});};Object[a11_0x5787('0x6')](exports,a11_0x5787('0x3a'),{'value':!![]});exports['nxCloudDistributedTasksRunner']=void 0x0;const environment_1=require(a11_0x5787('0x12'));const metric_logger_1=require('../../../utilities/metric-logger');const error_reporter_api_1=require(a11_0x5787('0x1b'));const print_run_group_error_1=require(a11_0x5787('0x32'));const e2e_encryption_1=require(a11_0x5787('0x31'));const file_storage_1=require(a11_0x5787('0x40'));const distributed_execution_api_1=require(a11_0x5787('0x2b'));const split_task_graph_into_stages_1=require('./split-task-graph-into-stages');const task_graph_creator_1=require(a11_0x5787('0x37'));const process_tasks_1=require(a11_0x5787('0x5'));const dte_artifact_storage_1=require(a11_0x5787('0x18'));const {output,cacheDirectory}=require('../../../utilities/nx-imports');class NoopLifeCycle{[a11_0x5787('0x1d')](_0x3fa34a){}[a11_0x5787('0x16')](_0x8e9bb5){}[a11_0x5787('0x1')](_0x5da38e){}}const nxCloudDistributedTasksRunner=(_0x970fb9,_0x104c86,_0x528e0f)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(_0x104c86[a11_0x5787('0x7')]){output[a11_0x5787('0x2f')]({'title':a11_0x5787('0x33'),'bodyLine':[a11_0x5787('0x11')]});}if(environment_1[a11_0x5787('0xe')]){output[a11_0x5787('0x2e')]({'title':a11_0x5787('0xf')});}_0x104c86[a11_0x5787('0x9')]=new NoopLifeCycle();const _0x4b4326=(0x0,environment_1[a11_0x5787('0x24')])();const _0x2c4ab0=(0x0,environment_1[a11_0x5787('0x2d')])();const _0x139eec=(0x0,environment_1[a11_0x5787('0x20')])();const _0x3b972a=(0x0,environment_1[a11_0x5787('0x41')])();const _0x1d827b=(0x0,environment_1[a11_0x5787('0x13')])();const _0x2187b2=(0x0,environment_1[a11_0x5787('0xd')])();if(!(0x0,print_run_group_error_1['canDetectRunGroup'])(_0x2c4ab0,_0x139eec)){(0x0,print_run_group_error_1[a11_0x5787('0x21')])();process['exit'](0x1);}const _0x463546=new e2e_encryption_1[(a11_0x5787('0x26'))](environment_1[a11_0x5787('0x3')]||_0x104c86[a11_0x5787('0x4')]);const _0x201f87=new error_reporter_api_1[(a11_0x5787('0x27'))](_0x104c86);const _0x3b103e=new dte_artifact_storage_1[(a11_0x5787('0x1e'))](new file_storage_1[(a11_0x5787('0x25'))](_0x463546,_0x201f87,_0x104c86,a11_0x5787('0x10')),cacheDirectory);const _0x3ac8e4=new distributed_execution_api_1['DistributedExecutionApi'](_0x104c86);attachSignalListenersToCompleteRunGroupOnError(_0x3ac8e4,_0x4b4326,_0x2c4ab0,_0x139eec,_0x3b972a);try{const _0x4d4823=getTaskGraph(_0x528e0f,_0x970fb9,_0x104c86);const _0x4b013f=yield runDistributedExecution(_0x3ac8e4,_0x104c86,_0x3b103e,_0x4b4326,_0x2c4ab0,_0x139eec,_0x3b972a,_0x4d4823,_0x1d827b,_0x2187b2);if(_0x4b013f[a11_0x5787('0x29')]===0x0){output[a11_0x5787('0x3c')]({'title':a11_0x5787('0x1f'),'bodyLines':[a11_0x5787('0x3f')+_0x4b013f[a11_0x5787('0x17')]]});}else{output[a11_0x5787('0x1c')]({'title':a11_0x5787('0xa'),'bodyLines':[a11_0x5787('0x3f')+_0x4b013f[a11_0x5787('0x17')]]});}yield(0x0,metric_logger_1[a11_0x5787('0x28')])(_0x104c86);process[a11_0x5787('0x2a')](_0x4b013f['commandStatus']);}catch(_0x130a8f){output['error']({'title':a11_0x5787('0x38'),'bodyLines':[_0x130a8f[a11_0x5787('0x3b')]]});if(_0x130a8f['axiosException']){console['log'](_0x130a8f['axiosException']);}else{console[a11_0x5787('0x1a')](_0x130a8f);}try{yield _0x3ac8e4[a11_0x5787('0x22')](_0x4b4326,_0x2c4ab0,_0x139eec,_0x3b972a,a11_0x5787('0x36')+_0x130a8f[a11_0x5787('0x3b')]+'\x22');}finally{process['exit'](0x1);}}});exports[a11_0x5787('0x30')]=nxCloudDistributedTasksRunner;function getTaskGraph(_0x2eaefa,_0x3adbd0,_0x4ca4e6){if(_0x2eaefa['taskGraph']){return _0x2eaefa['taskGraph'];}else{return(0x0,task_graph_creator_1[a11_0x5787('0x23')])(_0x4ca4e6,_0x2eaefa['projectGraph'],_0x3adbd0);}}function attachSignalListenersToCompleteRunGroupOnError(_0x1e8b12,_0x555b9f,_0xcc3c08,_0x45c6e0,_0x391a13){process['on'](a11_0x5787('0x2'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x1e8b12['completeRunGroupWithError'](_0x555b9f,_0xcc3c08,_0x45c6e0,_0x391a13,a11_0x5787('0x19'));process[a11_0x5787('0x2a')](0x1);}));process['on'](a11_0x5787('0xb'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x1e8b12['completeRunGroupWithError'](_0x555b9f,_0xcc3c08,_0x45c6e0,_0x391a13,a11_0x5787('0x8'));process['exit'](0x1);}));}function runDistributedExecution(_0x148ff4,_0x4d3eb3,_0x424829,_0x12af81,_0x3aa7d0,_0x2dd1ef,_0x2b0d2f,_0x33a611,_0x339b67,_0x53b871){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x23c6c6=yield _0x148ff4['start']((0x0,distributed_execution_api_1[a11_0x5787('0x34')])(_0x12af81,_0x3aa7d0,_0x2dd1ef,_0x2b0d2f,(0x0,split_task_graph_into_stages_1['splitTasksIntoStages'])(_0x33a611),_0x4d3eb3,_0x339b67));return yield(0x0,process_tasks_1[a11_0x5787('0x39')])(_0x148ff4,_0x424829,_0x23c6c6,Object[a11_0x5787('0x3e')](_0x33a611[a11_0x5787('0x35')]));});}
"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, 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

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

const a12_0x182a=['processTask','value','taskId','../../../utilities/serializer-overrides','Processing\x20task\x20','throw','__esModule','../../../utilities/nx-imports','find','apply','VERBOSE_LOGGING','serializeOverrides','note','run','stdout','target','configuration','write','next','then','Found\x20unknown\x20task:\x20','done'];(function(_0x5c9192,_0x182ab4){const _0x51db7e=function(_0x5287ef){while(--_0x5287ef){_0x5c9192['push'](_0x5c9192['shift']());}};_0x51db7e(++_0x182ab4);}(a12_0x182a,0x1e9));const a12_0x51db=function(_0x5c9192,_0x182ab4){_0x5c9192=_0x5c9192-0x0;let _0x51db7e=a12_0x182a[_0x5c9192];return _0x51db7e;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x483a72,_0x25361b,_0x687ee6,_0x1d3312){function _0x2d81b1(_0x564397){return _0x564397 instanceof _0x687ee6?_0x564397:new _0x687ee6(function(_0x3180f0){_0x3180f0(_0x564397);});}return new(_0x687ee6||(_0x687ee6=Promise))(function(_0x3486f6,_0x2493ef){function _0x534099(_0x3c5987){try{_0xf78d5a(_0x1d3312[a12_0x51db('0xd')](_0x3c5987));}catch(_0x877c65){_0x2493ef(_0x877c65);}}function _0x57a715(_0x5e01a2){try{_0xf78d5a(_0x1d3312[a12_0x51db('0x0')](_0x5e01a2));}catch(_0x4081c2){_0x2493ef(_0x4081c2);}}function _0xf78d5a(_0x52eb36){_0x52eb36[a12_0x51db('0x10')]?_0x3486f6(_0x52eb36[a12_0x51db('0x12')]):_0x2d81b1(_0x52eb36[a12_0x51db('0x12')])[a12_0x51db('0xe')](_0x534099,_0x57a715);}_0xf78d5a((_0x1d3312=_0x1d3312[a12_0x51db('0x4')](_0x483a72,_0x25361b||[]))[a12_0x51db('0xd')]());});};Object['defineProperty'](exports,a12_0x51db('0x1'),{'value':!![]});exports[a12_0x51db('0x11')]=void 0x0;const environment_1=require('../../../utilities/environment');const serializer_overrides_1=require(a12_0x51db('0x14'));const {output}=require(a12_0x51db('0x2'));function processTask(_0x5310ce,_0x41a3f6,_0x54fe1a){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a12_0x51db('0x5')]){output[a12_0x51db('0x7')]({'title':a12_0x51db('0x15')+_0x54fe1a[a12_0x51db('0x13')]});}const _0x171cb7=_0x41a3f6[a12_0x51db('0x3')](_0x5b7197=>_0x54fe1a[a12_0x51db('0x13')]===_0x5b7197['id']);if(!_0x171cb7){throw new Error(a12_0x51db('0xf')+_0x54fe1a['taskId']);}const _0x11ecd7=yield _0x5310ce['retrieveAndExtract'](_0x54fe1a['hash'],_0x54fe1a['url']);output['logCommand'](getCommand(_0x171cb7));process[a12_0x51db('0x9')][a12_0x51db('0xc')](_0x11ecd7);output['addVerticalSeparator']();});}exports['processTask']=processTask;function getCommand(_0x5ff8a1){const _0x33aba6=_0x5ff8a1['target']['configuration']?':'+_0x5ff8a1[a12_0x51db('0xa')][a12_0x51db('0xb')]:'';return['nx',a12_0x51db('0x8'),_0x5ff8a1[a12_0x51db('0xa')]['project']+':'+_0x5ff8a1[a12_0x51db('0xa')]['target']+_0x33aba6,(0x0,serializer_overrides_1[a12_0x51db('0x6')])(_0x5ff8a1)]['join']('\x20');}
"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');
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

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

const a13_0x4436=['VERBOSE_LOGGING','apply','No\x20new\x20completed\x20tasks\x20after\x20','length','../../../utilities/create-unchanged-value-timeout','Waiting...','Distributed\x20Execution\x20Terminated','value','createUnchangedValueTimeout','error','reset','../../../utilities/environment','__esModule','executionId:\x20','wait','commandStatus','\x20seconds.','then','exit','Waiter','executionStatus','Status\x20update','../../../utilities/waiter','COMPLETED','taskId','processTasks','note','processTask','NO_COMPLETED_TASKS_TIMEOUT','error:\x20','../../../utilities/nx-imports','criticalErrorMessage','next','./process-task','executionStatus:\x20','completedTasks','number\x20of\x20completed\x20tasks:\x20'];(function(_0x48a9d1,_0x4436e8){const _0x370724=function(_0x51b4c4){while(--_0x51b4c4){_0x48a9d1['push'](_0x48a9d1['shift']());}};_0x370724(++_0x4436e8);}(a13_0x4436,0x195));const a13_0x3707=function(_0x48a9d1,_0x4436e8){_0x48a9d1=_0x48a9d1-0x0;let _0x370724=a13_0x4436[_0x48a9d1];return _0x370724;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x2c26be,_0x253745,_0x168e16,_0x57d1c3){function _0x2da8ed(_0x33842f){return _0x33842f instanceof _0x168e16?_0x33842f:new _0x168e16(function(_0x576d40){_0x576d40(_0x33842f);});}return new(_0x168e16||(_0x168e16=Promise))(function(_0x5a21fe,_0x36d71a){function _0x19b02c(_0x94e146){try{_0x46abe2(_0x57d1c3[a13_0x3707('0x22')](_0x94e146));}catch(_0x4539ef){_0x36d71a(_0x4539ef);}}function _0x223bcc(_0x3a677b){try{_0x46abe2(_0x57d1c3['throw'](_0x3a677b));}catch(_0x4b116e){_0x36d71a(_0x4b116e);}}function _0x46abe2(_0x55d7a7){_0x55d7a7['done']?_0x5a21fe(_0x55d7a7[a13_0x3707('0x9')]):_0x2da8ed(_0x55d7a7[a13_0x3707('0x9')])[a13_0x3707('0x13')](_0x19b02c,_0x223bcc);}_0x46abe2((_0x57d1c3=_0x57d1c3[a13_0x3707('0x3')](_0x2c26be,_0x253745||[]))[a13_0x3707('0x22')]());});};Object['defineProperty'](exports,a13_0x3707('0xe'),{'value':!![]});exports[a13_0x3707('0x1b')]=void 0x0;const create_unchanged_value_timeout_1=require(a13_0x3707('0x6'));const environment_1=require(a13_0x3707('0xd'));const waiter_1=require(a13_0x3707('0x18'));const process_task_1=require(a13_0x3707('0x23'));const {output}=require(a13_0x3707('0x20'));function processTasks(_0x520850,_0x4705de,_0x3c5702,_0x46bec1){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x348be3={};const _0x1a5ce2=(0x0,create_unchanged_value_timeout_1[a13_0x3707('0xa')])({'title':a13_0x3707('0x4')+environment_1[a13_0x3707('0x1e')]/0x3e8+a13_0x3707('0x12'),'timeout':environment_1[a13_0x3707('0x1e')]});const _0x1dd6eb=new waiter_1[(a13_0x3707('0x15'))]();while(!![]){if(environment_1[a13_0x3707('0x2')]){output['note']({'title':a13_0x3707('0x7')});}yield _0x1dd6eb[a13_0x3707('0x10')]();const _0x4478e4=yield _0x520850['status'](_0x3c5702);if(environment_1[a13_0x3707('0x2')]){output[a13_0x3707('0x1c')]({'title':a13_0x3707('0x17'),'bodyLines':[a13_0x3707('0xf')+_0x3c5702,a13_0x3707('0x24')+_0x4478e4[a13_0x3707('0x16')],a13_0x3707('0x1')+_0x4478e4[a13_0x3707('0x0')][a13_0x3707('0x5')],a13_0x3707('0x1f')+_0x4478e4[a13_0x3707('0x21')]]});}if(_0x4478e4['criticalErrorMessage']){output[a13_0x3707('0xb')]({'title':a13_0x3707('0x8'),'bodyLines':['Error:',_0x4478e4[a13_0x3707('0x21')]]});process[a13_0x3707('0x14')](0x1);}_0x1a5ce2(_0x4478e4[a13_0x3707('0x0')][a13_0x3707('0x5')]);for(const _0xdfe16b of _0x4478e4['completedTasks']){if(_0x348be3[_0xdfe16b[a13_0x3707('0x1a')]])continue;yield(0x0,process_task_1[a13_0x3707('0x1d')])(_0x4705de,_0x46bec1,_0xdfe16b);_0x1dd6eb[a13_0x3707('0xc')]();_0x348be3[_0xdfe16b[a13_0x3707('0x1a')]]=!![];}if(_0x4478e4['executionStatus']===a13_0x3707('0x19')){return{'commandStatus':_0x4478e4[a13_0x3707('0x11')],'runUrl':_0x4478e4['runUrl']};}}});}exports[a13_0x3707('0x1b')]=processTasks;
"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');
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

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

const a14_0x4c1b=['map','has','push','values','size','defineProperty','splitTasksIntoStages','dependencies','delete'];(function(_0x346da7,_0x4c1b65){const _0x1c5e5e=function(_0x903edd){while(--_0x903edd){_0x346da7['push'](_0x346da7['shift']());}};_0x1c5e5e(++_0x4c1b65);}(a14_0x4c1b,0x140));const a14_0x1c5e=function(_0x346da7,_0x4c1b65){_0x346da7=_0x346da7-0x0;let _0x1c5e5e=a14_0x4c1b[_0x346da7];return _0x1c5e5e;};'use strict';Object[a14_0x1c5e('0x0')](exports,'__esModule',{'value':!![]});exports[a14_0x1c5e('0x1')]=void 0x0;function splitTasksIntoStages(_0x1e3de4){const _0x5df268=[];const _0x50273e=new Set(Object[a14_0x1c5e('0x7')](_0x1e3de4['tasks'])[a14_0x1c5e('0x4')](_0x31afda=>_0x31afda['id']));let _0x5586a5=0x0;while(_0x50273e[a14_0x1c5e('0x8')]>0x0){const _0x191f5b=_0x5df268[_0x5586a5]=[];for(const _0x4d0052 of _0x50273e){let _0x26da7f=!![];for(const _0x340ee6 of _0x1e3de4[a14_0x1c5e('0x2')][_0x4d0052]){if(_0x50273e[a14_0x1c5e('0x5')](_0x340ee6)){_0x26da7f=![];break;}}if(!_0x26da7f){continue;}const _0x34f602=_0x1e3de4['tasks'][_0x4d0052];_0x191f5b[a14_0x1c5e('0x6')](_0x34f602);}for(const _0x4d4782 of _0x191f5b){_0x50273e[a14_0x1c5e('0x3')](_0x4d4782['id']);}_0x5586a5++;}return _0x5df268;}exports[a14_0x1c5e('0x1')]=splitTasksIntoStages;
"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

@@ -1,1 +0,100 @@

const a15_0x1b41=['keys','project','addTaskDependencies','defineProperty','strip-json-comments','createTaskGraphCompat','add','defaultTargetDependencies','parse','strictlyOrderedTargets','target','readFileSync','TaskGraphCreator','../../../utilities/nx-imports','/nx.json','tasks','addTaskToGraph','find','addDependencies','findTask','indexOf','projects','roots','dependencies','length','push','createTaskGraph','toString'];(function(_0x29a905,_0x1b414f){const _0x3defc9=function(_0x1de686){while(--_0x1de686){_0x29a905['push'](_0x29a905['shift']());}};_0x3defc9(++_0x1b414f);}(a15_0x1b41,0x113));const a15_0x3def=function(_0x29a905,_0x1b414f){_0x29a905=_0x29a905-0x0;let _0x3defc9=a15_0x1b41[_0x29a905];return _0x3defc9;};'use strict';Object[a15_0x3def('0x8')](exports,'__esModule',{'value':!![]});exports['TaskGraphCreator']=exports[a15_0x3def('0xa')]=void 0x0;const stripJsonComments=require(a15_0x3def('0x9'));const fs_1=require('fs');const {getDependencyConfigs,workspaceRoot}=require(a15_0x3def('0x12'));function createTaskGraphCompat(_0x4d0809,_0x5d96e1,_0x1979ca){const _0x27a3f3=JSON[a15_0x3def('0xd')](stripJsonComments((0x0,fs_1[a15_0x3def('0x10')])(workspaceRoot+a15_0x3def('0x13'))[a15_0x3def('0x4')]()));return new TaskGraphCreator(_0x5d96e1,getDefaultDependencyConfigs(_0x27a3f3,_0x4d0809))['createTaskGraph'](_0x1979ca);}exports[a15_0x3def('0xa')]=createTaskGraphCompat;function getDefaultDependencyConfigs(_0x1998c5,_0xab4a2a){var _0x2fc0ab,_0x4cc3db;const _0x3349d7=(_0x2fc0ab=_0x1998c5['targetDependencies'])!==null&&_0x2fc0ab!==void 0x0?_0x2fc0ab:{};const _0x18f184=_0xab4a2a?(_0x4cc3db=_0xab4a2a[a15_0x3def('0xe')])!==null&&_0x4cc3db!==void 0x0?_0x4cc3db:['build']:[];for(const _0x350c2e of _0x18f184){_0x3349d7[_0x350c2e]=_0x3349d7[_0x350c2e]||[];_0x3349d7[_0x350c2e][a15_0x3def('0x2')]({'target':_0x350c2e,'projects':a15_0x3def('0x0')});}return _0x3349d7;}class TaskGraphCreator{constructor(_0x4b8424,_0x10b47b){this['projectGraph']=_0x4b8424;this[a15_0x3def('0xc')]=_0x10b47b;}[a15_0x3def('0x3')](_0x18de58){const _0x545d57={'roots':[],'tasks':{},'dependencies':{}};for(const _0x4e8e0b of _0x18de58){this['addTaskToGraph'](_0x4e8e0b,_0x545d57);const _0x302e12=getDependencyConfigs(_0x4e8e0b[a15_0x3def('0xf')],this[a15_0x3def('0xc')],this['projectGraph']);if(!_0x302e12){continue;}this[a15_0x3def('0x7')](_0x4e8e0b,_0x302e12,_0x18de58,_0x545d57);}_0x545d57[a15_0x3def('0x1b')]=Object[a15_0x3def('0x5')](_0x545d57[a15_0x3def('0x0')])['filter'](_0x50970f=>_0x545d57['dependencies'][_0x50970f][a15_0x3def('0x1')]===0x0);return _0x545d57;}[a15_0x3def('0x7')](_0x54772f,_0x4b5ea1,_0x108276,_0x50e94e){for(const _0x577c07 of _0x4b5ea1){if(_0x577c07['projects']==='self'){for(const _0x551721 of _0x108276){if(_0x551721[a15_0x3def('0xf')][a15_0x3def('0x6')]===_0x54772f[a15_0x3def('0xf')]['project']&&_0x551721['target'][a15_0x3def('0xf')]===_0x577c07['target']){_0x50e94e['dependencies'][_0x54772f['id']]['push'](_0x551721['id']);}}}else if(_0x577c07[a15_0x3def('0x1a')]==='dependencies'){const _0x1039d8=new Set();this[a15_0x3def('0x17')](_0x54772f['target'][a15_0x3def('0x6')],_0x577c07['target'],_0x108276,_0x50e94e,_0x54772f['id'],_0x1039d8);}}}[a15_0x3def('0x17')](_0x4cf2ae,_0x1c8411,_0x140e8a,_0x1e4df7,_0x291f19,_0x87889c){_0x87889c[a15_0x3def('0xb')](_0x4cf2ae);const _0x55a0e0=this['projectGraph'][a15_0x3def('0x0')][_0x4cf2ae];if(_0x55a0e0){const _0x1e9689=_0x55a0e0['map'](_0x4d2c6e=>_0x4d2c6e[a15_0x3def('0xf')]);for(const _0x2de733 of _0x1e9689){if(_0x87889c['has'](_0x2de733)){continue;}const _0x598d47=this[a15_0x3def('0x18')]({'project':_0x2de733,'target':_0x1c8411},_0x140e8a);if(_0x598d47){if(_0x1e4df7[a15_0x3def('0x0')][_0x291f19][a15_0x3def('0x19')](_0x598d47['id'])===-0x1){_0x1e4df7['dependencies'][_0x291f19][a15_0x3def('0x2')](_0x598d47['id']);}}else{this[a15_0x3def('0x17')](_0x2de733,_0x1c8411,_0x140e8a,_0x1e4df7,_0x291f19,_0x87889c);}}}}[a15_0x3def('0x18')]({project,target},_0x16bcd8){return _0x16bcd8[a15_0x3def('0x16')](_0x4d29c7=>_0x4d29c7[a15_0x3def('0xf')][a15_0x3def('0x6')]===project&&_0x4d29c7['target'][a15_0x3def('0xf')]===target);}[a15_0x3def('0x15')](_0x4a0b06,_0x320a12){_0x320a12[a15_0x3def('0x14')][_0x4a0b06['id']]=_0x4a0b06;_0x320a12[a15_0x3def('0x0')][_0x4a0b06['id']]=[];}}exports[a15_0x3def('0x11')]=TaskGraphCreator;
"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 { getDependencyConfigs, workspaceRoot, } = 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
{
"name": "nx-cloud",
"version": "16.1.0",
"version": "16.1.1-beta.0",
"description": "Distributed caching and task execution for Lerna and Nx",

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

"open": "~8.4.0",
"@nrwl/nx-cloud": "16.1.0"
"@nrwl/nx-cloud": "16.1.1-beta.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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