Socket
Socket
Sign inDemoInstall

nx-cloud

Package Overview
Dependencies
35
Maintainers
2
Versions
149
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 16.1.1 to 16.2.0-beta.0

37

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

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

const a0_0x5132=['apply','__awaiter','next','apiAxiosInstance','__esModule','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','throw','value','reportError','ErrorReporterApi','axiosMultipleTries','done','then','createApiAxiosInstance','/nx-cloud/report-client-error','post','defineProperty'];(function(_0x223573,_0x513260){const _0x18ce0e=function(_0x68cf24){while(--_0x68cf24){_0x223573['push'](_0x223573['shift']());}};_0x18ce0e(++_0x513260);}(a0_0x5132,0xf3));const a0_0x18ce=function(_0x223573,_0x513260){_0x223573=_0x223573-0x0;let _0x18ce0e=a0_0x5132[_0x223573];return _0x18ce0e;};'use strict';var __awaiter=this&&this[a0_0x18ce('0xd')]||function(_0x202b14,_0x315183,_0x27ca6c,_0x564e73){function _0x4a35c5(_0x17538f){return _0x17538f instanceof _0x27ca6c?_0x17538f:new _0x27ca6c(function(_0x3aaf3b){_0x3aaf3b(_0x17538f);});}return new(_0x27ca6c||(_0x27ca6c=Promise))(function(_0x1f4dc4,_0x3dfdae){function _0x102792(_0x25bf12){try{_0x4e8787(_0x564e73[a0_0x18ce('0xe')](_0x25bf12));}catch(_0x1ea42a){_0x3dfdae(_0x1ea42a);}}function _0x22a069(_0x28d746){try{_0x4e8787(_0x564e73[a0_0x18ce('0x1')](_0x28d746));}catch(_0x4954bd){_0x3dfdae(_0x4954bd);}}function _0x4e8787(_0x3ac2b9){_0x3ac2b9[a0_0x18ce('0x6')]?_0x1f4dc4(_0x3ac2b9[a0_0x18ce('0x2')]):_0x4a35c5(_0x3ac2b9[a0_0x18ce('0x2')])[a0_0x18ce('0x7')](_0x102792,_0x22a069);}_0x4e8787((_0x564e73=_0x564e73[a0_0x18ce('0xc')](_0x202b14,_0x315183||[]))[a0_0x18ce('0xe')]());});};Object[a0_0x18ce('0xb')](exports,a0_0x18ce('0x10'),{'value':!![]});exports[a0_0x18ce('0x4')]=void 0x0;const axios_1=require('../../utilities/axios');const {output}=require('../../utilities/nx-imports');class ErrorReporterApi{constructor(_0x5ad961){this[a0_0x18ce('0xf')]=(0x0,axios_1[a0_0x18ce('0x8')])(_0x5ad961);}[a0_0x18ce('0x3')](_0x39a872){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x18ce('0x5')])(()=>this[a0_0x18ce('0xf')][a0_0x18ce('0xa')](a0_0x18ce('0x9'),{'message':_0x39a872}));}catch(_0x172155){output['warn']({'title':a0_0x18ce('0x0')+_0x39a872+'\x27','bodyLines':[_0x172155['message']]});}});}}exports[a0_0x18ce('0x4')]=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_0x30b7=['next','RunGroupApi','apply','post','/nx-cloud/executions/complete-run-group','then','recordMetric','defineProperty','__esModule','apiAxiosInstance','message','error','../../utilities/metric-logger','exit','throw','completeRunGroup','done','__awaiter','axiosMultipleTries','axiosException','createMetricRecorder','response','createApiAxiosInstance','value','../../utilities/nx-imports','mapRespToPerfEntry'];(function(_0x4adb66,_0x30b718){const _0x3cd006=function(_0xb90d76){while(--_0xb90d76){_0x4adb66['push'](_0x4adb66['shift']());}};_0x3cd006(++_0x30b718);}(a1_0x30b7,0x19e));const a1_0x3cd0=function(_0x4adb66,_0x30b718){_0x4adb66=_0x4adb66-0x0;let _0x3cd006=a1_0x30b7[_0x4adb66];return _0x3cd006;};'use strict';var __awaiter=this&&this[a1_0x3cd0('0x13')]||function(_0xd909a8,_0x17fa71,_0x14a206,_0x53dd9e){function _0x174b15(_0x262a64){return _0x262a64 instanceof _0x14a206?_0x262a64:new _0x14a206(function(_0x1003ab){_0x1003ab(_0x262a64);});}return new(_0x14a206||(_0x14a206=Promise))(function(_0xba3e2d,_0x4f9fef){function _0x165f9c(_0x209ee9){try{_0x2957ab(_0x53dd9e[a1_0x3cd0('0x2')](_0x209ee9));}catch(_0x7e7694){_0x4f9fef(_0x7e7694);}}function _0x3759c5(_0x2829dc){try{_0x2957ab(_0x53dd9e[a1_0x3cd0('0x10')](_0x2829dc));}catch(_0x152a2b){_0x4f9fef(_0x152a2b);}}function _0x2957ab(_0xd5528f){_0xd5528f[a1_0x3cd0('0x12')]?_0xba3e2d(_0xd5528f[a1_0x3cd0('0x19')]):_0x174b15(_0xd5528f['value'])[a1_0x3cd0('0x7')](_0x165f9c,_0x3759c5);}_0x2957ab((_0x53dd9e=_0x53dd9e[a1_0x3cd0('0x4')](_0xd909a8,_0x17fa71||[]))[a1_0x3cd0('0x2')]());});};Object[a1_0x3cd0('0x9')](exports,a1_0x3cd0('0xa'),{'value':!![]});exports[a1_0x3cd0('0x3')]=void 0x0;const axios_1=require('../../utilities/axios');const metric_logger_1=require(a1_0x3cd0('0xe'));const {output}=require(a1_0x3cd0('0x0'));class RunGroupApi{constructor(_0x5ad02a){this[a1_0x3cd0('0xb')]=(0x0,axios_1[a1_0x3cd0('0x18')])(_0x5ad02a);}['createRunGroup'](_0x335334,_0x57edb0,_0xb388cd,_0x29cd05,_0x318dbe,_0x1e51b3,_0x537732,_0x486827,_0x3c98f0){var _0x2896f2;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x26114e=(0x0,metric_logger_1[a1_0x3cd0('0x16')])('createRunGroup');try{const _0x575506=yield(0x0,axios_1[a1_0x3cd0('0x14')])(()=>this[a1_0x3cd0('0xb')]['post']('/nx-cloud/executions/create-run-group',{'branch':_0x335334,'runGroup':_0x57edb0,'ciExecutionId':_0xb388cd,'ciExecutionEnv':_0x29cd05,'stopAgentsOnFailure':_0x318dbe,'agentCount':_0x1e51b3,'stopAgentsAfter':_0x537732,'commitSha':_0x486827}));_0x26114e[a1_0x3cd0('0x8')]((0x0,metric_logger_1[a1_0x3cd0('0x1')])(_0x575506));}catch(_0xfce233){_0x26114e[a1_0x3cd0('0x8')](((_0x2896f2=_0xfce233===null||_0xfce233===void 0x0?void 0x0:_0xfce233['axiosException'])===null||_0x2896f2===void 0x0?void 0x0:_0x2896f2['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0xfce233[a1_0x3cd0('0x15')][a1_0x3cd0('0x17')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x3cd0('0xd')]({'title':_0xfce233[a1_0x3cd0('0xc')]});process[a1_0x3cd0('0xf')](0x1);}});}[a1_0x3cd0('0x11')](_0x400624,_0x2fc06b,_0x2c1439,_0x205930){var _0x3a4ab9;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x7cd90e=(0x0,metric_logger_1[a1_0x3cd0('0x16')])(a1_0x3cd0('0x11'));try{const _0x35c1f6=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a1_0x3cd0('0xb')][a1_0x3cd0('0x5')](a1_0x3cd0('0x6'),{'branch':_0x400624,'runGroup':_0x2fc06b,'ciExecutionId':_0x2c1439,'ciExecutionEnv':_0x205930}));_0x7cd90e['recordMetric']((0x0,metric_logger_1[a1_0x3cd0('0x1')])(_0x35c1f6));}catch(_0x28699d){_0x7cd90e[a1_0x3cd0('0x8')](((_0x3a4ab9=_0x28699d===null||_0x28699d===void 0x0?void 0x0:_0x28699d[a1_0x3cd0('0x15')])===null||_0x3a4ab9===void 0x0?void 0x0:_0x3a4ab9['response'])?(0x0,metric_logger_1[a1_0x3cd0('0x1')])(_0x28699d['axiosException'][a1_0x3cd0('0x17')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x3cd0('0xd')]({'title':_0x28699d[a1_0x3cd0('0xc')]});process['exit'](0x1);}});}}exports[a1_0x3cd0('0x3')]=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

2

lib/core/commands/record-output.js

@@ -148,3 +148,3 @@ "use strict";

ciExecutionEnv: params.ciExecutionEnv,
machineInfo: (0, environment_1.getMachineInfo)(taskRunnerOptions),
machineInfo: (0, environment_1.getMachineInfo)(),
};

@@ -151,0 +151,0 @@ const uncompressedBuffer = Buffer.from(JSON.stringify(endRunReq));

@@ -30,3 +30,3 @@ "use strict";

const runContext = {};
const machineInfo = (0, environment_1.getMachineInfo)(options);
const machineInfo = (0, environment_1.getMachineInfo)();
const api = new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);

@@ -33,0 +33,0 @@ const outputObfusactor = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);

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

const a0_0x1ee9=['collectTerminalOutput','implicitDeps','readTaskTerminalOutput','task','CloudEnabledLifeCycle','hash','cacheableOperations','outputObfuscator','toISOString','runtime','cacheStatus','defineProperty','scheduleTask','params','endCommand','__esModule','tasks','cacheDirectory','local-cache-kept-existing','runContext','scheduledTasks','obfuscate','local-cache','startsWith','endTime','remote-cache','target','project','keys','npm:','code','startTime','cache','endTasks','serializeOverrides','Cannot\x20find\x20task\x20','../../terminal-output/read-task-terminal-output','startTask','terminalOutput','hashDetails','taskId','push','updateStartedTask','statuses','forEach','../../../utilities/serializer-overrides','status'];(function(_0x6fda74,_0x1ee97d){const _0xefb956=function(_0x246e42){while(--_0x246e42){_0x6fda74['push'](_0x6fda74['shift']());}};_0xefb956(++_0x1ee97d);}(a0_0x1ee9,0x81));const a0_0xefb9=function(_0x6fda74,_0x1ee97d){_0x6fda74=_0x6fda74-0x0;let _0xefb956=a0_0x1ee9[_0x6fda74];return _0xefb956;};'use strict';Object[a0_0xefb9('0x17')](exports,a0_0xefb9('0x1b'),{'value':!![]});exports[a0_0xefb9('0x10')]=void 0x0;const serializer_overrides_1=require(a0_0xefb9('0xa'));const read_task_terminal_output_1=require(a0_0xefb9('0x1'));class CloudEnabledLifeCycle{constructor(_0x110dff,_0x5bf8b2,_0x484209,_0x401179,_0x712498,_0x2e9b25){this[a0_0xefb9('0x1f')]=_0x110dff;this['cacheDirectory']=_0x5bf8b2;this[a0_0xefb9('0xc')]=_0x484209;this[a0_0xefb9('0x12')]=_0x401179;this[a0_0xefb9('0x13')]=_0x712498;this[a0_0xefb9('0x1c')]=_0x2e9b25;}[a0_0xefb9('0x18')](_0x1474ee){this[a0_0xefb9('0x1f')][a0_0xefb9('0x20')][a0_0xefb9('0x6')](_0x1474ee);}[a0_0xefb9('0x2')](_0x401ca0){this[a0_0xefb9('0x1c')][a0_0xefb9('0x6')]({'taskId':_0x401ca0['id'],'startTime':new Date()[a0_0xefb9('0x14')](),'target':_0x401ca0[a0_0xefb9('0x26')][a0_0xefb9('0x26')],'projectName':_0x401ca0[a0_0xefb9('0x26')][a0_0xefb9('0x27')],'hash':_0x401ca0[a0_0xefb9('0x11')],'hashDetails':this['cleanUpHashDetails'](_0x401ca0[a0_0xefb9('0x4')]),'params':(0x0,serializer_overrides_1[a0_0xefb9('0x2e')])(_0x401ca0),'uploadedToStorage':![]});}[a0_0xefb9('0x2d')](_0x4c477e){for(let _0x2bbb7a of _0x4c477e){let _0x25bf96;const _0x1df5f8=_0x2bbb7a[a0_0xefb9('0xb')]===a0_0xefb9('0x25');const _0x59cd3f=_0x2bbb7a[a0_0xefb9('0xb')]===a0_0xefb9('0x2c');const _0x39cec6=_0x2bbb7a[a0_0xefb9('0xb')]===a0_0xefb9('0x22')||_0x2bbb7a[a0_0xefb9('0xb')]===a0_0xefb9('0x1e')||_0x59cd3f;if(this[a0_0xefb9('0x1f')][a0_0xefb9('0x8')][_0x2bbb7a[a0_0xefb9('0xf')][a0_0xefb9('0x11')]]){_0x25bf96=this[a0_0xefb9('0x1f')][a0_0xefb9('0x8')][_0x2bbb7a['task'][a0_0xefb9('0x11')]];}else if(_0x1df5f8){_0x25bf96='remote-cache-hit';}else if(_0x39cec6){_0x25bf96='local-cache-hit';}else{_0x25bf96='cache-miss';}this[a0_0xefb9('0x7')](_0x2bbb7a,_0x25bf96);}}[a0_0xefb9('0x1a')](){}['updateStartedTask'](_0x1c248c,_0x174d0e){const _0x477aa6=this[a0_0xefb9('0x1c')]['find'](_0x4c22a0=>_0x4c22a0[a0_0xefb9('0x5')]===_0x1c248c[a0_0xefb9('0xf')]['id']);if(!_0x477aa6){throw new Error(a0_0xefb9('0x0')+_0x1c248c[a0_0xefb9('0xf')]['id']);}if((_0x1c248c===null||_0x1c248c===void 0x0?void 0x0:_0x1c248c[a0_0xefb9('0x2b')])&&(_0x1c248c===null||_0x1c248c===void 0x0?void 0x0:_0x1c248c['endTime'])){_0x477aa6['startTime']=new Date(_0x1c248c[a0_0xefb9('0x2b')])[a0_0xefb9('0x14')]();_0x477aa6[a0_0xefb9('0x24')]=new Date(_0x1c248c[a0_0xefb9('0x24')])[a0_0xefb9('0x14')]();}else{_0x477aa6[a0_0xefb9('0x24')]=new Date()[a0_0xefb9('0x14')]();}_0x477aa6[a0_0xefb9('0xb')]=_0x1c248c['code'];_0x477aa6[a0_0xefb9('0x19')]=this[a0_0xefb9('0x13')][a0_0xefb9('0x21')](_0x477aa6[a0_0xefb9('0x19')]);_0x477aa6['cacheStatus']=_0x174d0e;if(this[a0_0xefb9('0xc')]){_0x477aa6[a0_0xefb9('0x3')]=this['getTerminalOutput'](_0x1c248c['task'][a0_0xefb9('0x11')],_0x477aa6[a0_0xefb9('0x16')],_0x1c248c[a0_0xefb9('0x2a')]);}}['getTerminalOutput'](_0x5b1681,_0x5b4db9,_0x177255){return(0x0,read_task_terminal_output_1[a0_0xefb9('0xe')])(this[a0_0xefb9('0x1d')],this[a0_0xefb9('0x13')],_0x5b1681,_0x5b4db9,_0x177255);}['cleanUpHashDetails'](_0x4aae26){const _0x27f186={};Object[a0_0xefb9('0x28')](_0x4aae26['nodes'])['filter'](_0x50b5bf=>!_0x50b5bf[a0_0xefb9('0x23')](a0_0xefb9('0x29')))[a0_0xefb9('0x9')](_0x3d7a8f=>{_0x27f186[_0x3d7a8f]=_0x4aae26['nodes'][_0x3d7a8f];});return{'nodes':_0x27f186,'runtime':_0x4aae26[a0_0xefb9('0x15')],'implicitDeps':_0x4aae26[a0_0xefb9('0xd')]};}}exports[a0_0xefb9('0x10')]=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_0x3ef0=['writeFileSync','toISOString','complete','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','maskedProperties','obfuscate','ENCRYPTION_KEY','E2EEncryption','catch','resolve','value','parseCommand','note','submitRunMetrics','storedHashes','map','./cloud-run.api','Executed\x20tasks\x20with\x20hashes:\x20','../../../utilities/environment','CloudEnabledLifeCycle','lifeCycle','assign','fs-extra','cacheableOperations','VERBOSE_LOGGING','skipNxCache','done','requests','\x20isn\x27t\x20recorded','length','env','../../../utilities/metric-logger','filter','anyErrors','taskId','../../terminal-output/output-obfuscator','cloud-enabled-runner','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','CloudRemoteCache','url','./id-generator','../../file-storage/e2e-encryption','/runs/','pathExists','join','enabled','runUrl','uploadedToStorage','processInBackground','then','Nx\x20Cloud\x20Problems','cacheStatus','EndOfRunMessage','push','removeTrailingSlash','defineProperty','getCIExecutionId','../../terminal-output/end-of-run-message','getBranch','ACCESS_TOKEN','path','https://nx.app','hash','./cloud-enabled-life-cycle','endRun','subscribe','exit','store','ErrorReporterApi','next','apply','CloudRunApi','printMessages','../../../utilities/remove-trailing-slash','all','getRunGroup','FileStorage','printCacheHitsMessage','cloudEnabledTasksRunner','Task\x20with\x20hash\x20','error','agentRunningInDistributedExecution','encryptionKey','local-cache-hit','__awaiter','warn','tasks-hashes-','../../api/error-reporter.api','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','daemon','stringify'];(function(_0x5852c8,_0x3ef063){const _0x2aa33c=function(_0x450f76){while(--_0x450f76){_0x5852c8['push'](_0x5852c8['shift']());}};_0x2aa33c(++_0x3ef063);}(a1_0x3ef0,0x1d7));const a1_0x2aa3=function(_0x5852c8,_0x3ef063){_0x5852c8=_0x5852c8-0x0;let _0x2aa33c=a1_0x3ef0[_0x5852c8];return _0x2aa33c;};'use strict';var __awaiter=this&&this[a1_0x2aa3('0x44')]||function(_0x310049,_0x1d2228,_0x4f3c19,_0x193ec5){function _0x267999(_0x1b7dd1){return _0x1b7dd1 instanceof _0x4f3c19?_0x1b7dd1:new _0x4f3c19(function(_0x4d9992){_0x4d9992(_0x1b7dd1);});}return new(_0x4f3c19||(_0x4f3c19=Promise))(function(_0xa83d3f,_0x3cf874){function _0x3fcfb7(_0x1ce221){try{_0xc7357(_0x193ec5['next'](_0x1ce221));}catch(_0x1e2d0d){_0x3cf874(_0x1e2d0d);}}function _0x56913d(_0x5baf6d){try{_0xc7357(_0x193ec5['throw'](_0x5baf6d));}catch(_0x514f82){_0x3cf874(_0x514f82);}}function _0xc7357(_0x20ac6d){_0x20ac6d[a1_0x2aa3('0xa')]?_0xa83d3f(_0x20ac6d[a1_0x2aa3('0x55')]):_0x267999(_0x20ac6d[a1_0x2aa3('0x55')])[a1_0x2aa3('0x21')](_0x3fcfb7,_0x56913d);}_0xc7357((_0x193ec5=_0x193ec5[a1_0x2aa3('0x36')](_0x310049,_0x1d2228||[]))[a1_0x2aa3('0x35')]());});};Object[a1_0x2aa3('0x27')](exports,'__esModule',{'value':!![]});exports[a1_0x2aa3('0x3e')]=void 0x0;const message_reporter_1=require('../../terminal-output/message-reporter');const end_of_run_message_1=require(a1_0x2aa3('0x29'));const output_obfuscator_1=require(a1_0x2aa3('0x13'));const cloud_enabled_life_cycle_1=require(a1_0x2aa3('0x2f'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a1_0x2aa3('0x19'));const environment_1=require(a1_0x2aa3('0x2'));const cloud_remote_cache_1=require('./cloud-remote-cache');const cloud_run_api_1=require(a1_0x2aa3('0x0'));const fs_1=require('fs');const path=require(a1_0x2aa3('0x2c'));const path_1=require('path');const metric_logger_1=require(a1_0x2aa3('0xf'));const error_reporter_api_1=require(a1_0x2aa3('0x47'));const fs_extra_1=require(a1_0x2aa3('0x6'));const id_generator_1=require(a1_0x2aa3('0x18'));const remove_trailing_slash_1=require(a1_0x2aa3('0x39'));const {tasksRunner,output,cacheDirectory}=require('../../../utilities/nx-imports');function createApi(_0x5eda0b,_0x2deb2f,_0x287a89){const _0x2b3655=(0x0,environment_1['getMachineInfo'])(_0x2deb2f);return new cloud_run_api_1[(a1_0x2aa3('0x37'))](_0x5eda0b,_0x287a89,_0x2deb2f,_0x2b3655);}function storeTaskHashes(_0x5f0f2d,_0x3623c1,_0x4cad69){const _0x35f5c0=JSON[a1_0x2aa3('0x4a')](_0x5f0f2d[a1_0x2aa3('0x5a')](_0x4ccc7b=>({'taskId':_0x4ccc7b[a1_0x2aa3('0x12')],'hash':_0x4ccc7b[a1_0x2aa3('0x2e')]})));if(environment_1[a1_0x2aa3('0x8')]){output[a1_0x2aa3('0x57')]({'title':a1_0x2aa3('0x1')+_0x35f5c0});}(0x0,fs_1[a1_0x2aa3('0x4b')])(path[a1_0x2aa3('0x1c')](_0x3623c1,a1_0x2aa3('0x46')+_0x4cad69),_0x35f5c0);}function storeLocalCacheHits(_0x413230,_0x502781,_0x42380b){const _0xcd1730=_0x413230[a1_0x2aa3('0x10')](_0x21fa49=>_0x21fa49[a1_0x2aa3('0x23')]===a1_0x2aa3('0x43'))[a1_0x2aa3('0x5a')](_0x26a00b=>_0x26a00b[a1_0x2aa3('0x2e')]);_0xcd1730['forEach'](_0x36a4f0=>_0x502781[a1_0x2aa3('0x33')](_0x36a4f0,_0x42380b));}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 _0x5a8948=new Date()[a1_0x2aa3('0x4c')]();const _0x519afa=(0x0,environment_1[a1_0x2aa3('0x2a')])();const _0x8c0cfe={'command':outputObfuscator[a1_0x2aa3('0x50')]((0x0,environment_1[a1_0x2aa3('0x56')])()),'startTime':runStartTime,'endTime':_0x5a8948,'distributedExecutionId':distributedExecutionId,'branch':_0x519afa,'runGroup':(0x0,environment_1[a1_0x2aa3('0x3b')])(),'sha':_0x519afa?(0x0,environment_1['extractGitSha'])():undefined,'inner':inner};const _0x5e85d6={'branch':_0x519afa,'runGroup':(0x0,environment_1[a1_0x2aa3('0x3b')])(),'ciExecutionId':(0x0,environment_1[a1_0x2aa3('0x28')])(),'ciExecutionEnv':(0x0,environment_1['getCIExecutionEnv'])()};if(storeInCurrentProcess){if((0x0,environment_1[a1_0x2aa3('0x41')])(distributedExecutionId)){storeTaskHashes(taskExecutions,cacheDirectory,distributedExecutionId);storeLocalCacheHits(taskExecutions,remoteCache,cacheDirectory);}try{yield remoteCache['waitForStoreRequestsToComplete']();}catch(_0x4ffc78){output[a1_0x2aa3('0x40')]({'title':'Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.'});messages['printMessages']();return![];}for(const _0xfc5714 of fileStorage[a1_0x2aa3('0x59')]){const _0x466884=taskExecutions['find'](_0x3af236=>_0x3af236[a1_0x2aa3('0x2e')]===_0xfc5714);if(!_0x466884){throw new Error(a1_0x2aa3('0x3f')+_0xfc5714+a1_0x2aa3('0xc'));}_0x466884[a1_0x2aa3('0x1f')]=!![];}try{yield api[a1_0x2aa3('0x30')](_0x8c0cfe,taskExecutions,_0x5e85d6);}catch(_0x4e742e){output[a1_0x2aa3('0x40')]({'title':a1_0x2aa3('0x4e')});messages[a1_0x2aa3('0x38')]();return![];}yield(0x0,metric_logger_1[a1_0x2aa3('0x58')])(options);}else{try{const _0x5646c0=environment_1['ACCESS_TOKEN']?environment_1[a1_0x2aa3('0x2b')]:options['accessToken'];const _0x450009=(0x0,id_generator_1['generateUniqueLinkId'])();const _0xd8eda9=require[a1_0x2aa3('0x54')]('nx-cloud/lib/daemon/process-run-end');yield daemon[a1_0x2aa3('0x20')](_0xd8eda9,{'encryptionKey':encryptionKey,'runnerOptions':Object['assign'](Object['assign']({},options),{'accessToken':_0x5646c0}),'delayedStoreRequests':remoteCache['delayedStoreRequests'],'ciExecutionContext':_0x5e85d6,'runEnd':{'runData':_0x8c0cfe,'taskExecutions':taskExecutions,'linkId':_0x450009}});runContext[a1_0x2aa3('0x1e')]=(0x0,remove_trailing_slash_1[a1_0x2aa3('0x26')])(options[a1_0x2aa3('0x17')]||a1_0x2aa3('0x2d'))+a1_0x2aa3('0x1a')+_0x450009;}catch(_0x45c0c8){output[a1_0x2aa3('0x45')]({'title':a1_0x2aa3('0x22'),'bodyLines':[_0x45c0c8['message']||_0x45c0c8['toString']()]});return![];}}if(versionOfNxBefore133){setTimeout(()=>{messages[a1_0x2aa3('0x38')]();if(!messages[a1_0x2aa3('0x11')]&&!inner){endOfRunMessage['printCacheHitsMessage']();}},0x0);}else{messages[a1_0x2aa3('0x38')]();if(!messages[a1_0x2aa3('0x11')]&&!inner){endOfRunMessage[a1_0x2aa3('0x3d')]();}}return!![];});}function createLifeCycle(_0x502647,_0x1c9997,_0x4e101f,_0x29c5c4){const _0x4ede55=new cloud_enabled_life_cycle_1[(a1_0x2aa3('0x3'))](_0x502647,cacheDirectory,!![],_0x1c9997[a1_0x2aa3('0x7')]||[],_0x4e101f,_0x29c5c4);try{const {CompositeLifeCycle}=require('../../../utilities/nx-imports');if(!CompositeLifeCycle)return _0x4ede55;return new CompositeLifeCycle([_0x1c9997[a1_0x2aa3('0x4')],_0x4ede55]);}catch(_0x297fbc){return _0x4ede55;}}function fetchUrlsForKnownHashesUpfront(_0x2ce1de,_0x4a0e48,_0x16bacc,_0xe80182,_0x20ac3e){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0xe80182[a1_0x2aa3('0x9')])return;let _0x4a5609=_0x16bacc[a1_0x2aa3('0x5a')](_0x2cde36=>_0x2cde36[a1_0x2aa3('0x2e')])[a1_0x2aa3('0x10')](_0x2d0506=>!!_0x2d0506);const _0x1a92c6=yield Promise[a1_0x2aa3('0x3a')](_0x4a5609[a1_0x2aa3('0x5a')](_0x5e098a=>{const _0x5cd19b=(0x0,path_1[a1_0x2aa3('0x1c')])(cacheDirectory,_0x5e098a+'.commit');return(0x0,fs_extra_1[a1_0x2aa3('0x1b')])(_0x5cd19b);}));const _0x13ec19=[];for(let _0x37c704=0x0;_0x37c704<_0x1a92c6[a1_0x2aa3('0xd')];++_0x37c704){if(!_0x1a92c6[_0x37c704]){_0x13ec19[a1_0x2aa3('0x25')](_0x4a5609[_0x37c704]);}}if(_0x13ec19[a1_0x2aa3('0xd')]>0x0){const _0x5a9555=_0x2ce1de['startRun'](_0x20ac3e,_0x13ec19);for(const _0x1eb3c4 of _0x13ec19){_0x4a0e48[a1_0x2aa3('0xb')][_0x1eb3c4]=_0x5a9555;}}});}function cloudEnabledTasksRunner(_0x1430ad,_0x42c51c,_0x6e141,_0x1d6194=![]){var _0x43fb12;const _0x38bb1f=process['env'][a1_0x2aa3('0x15')];const _0x4fc62d={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x1430ad};const _0x565829=_0x42c51c[a1_0x2aa3('0x4')]===undefined;const _0x552860=[];const _0x22890c=new message_reporter_1['MessageReporter'](_0x42c51c);const _0x2a88b4=createApi(_0x22890c,_0x42c51c,_0x4fc62d);const _0x130bbb=new end_of_run_message_1[(a1_0x2aa3('0x24'))](_0x4fc62d,_0x552860,_0x38bb1f);const _0x559e82=new output_obfuscator_1['OutputObfuscator'](_0x42c51c[a1_0x2aa3('0x4f')]);const _0xc555f1=new Date()[a1_0x2aa3('0x4c')]();const _0x175b45=createLifeCycle(_0x4fc62d,_0x42c51c,_0x559e82,_0x552860);const _0x1613ea=environment_1[a1_0x2aa3('0x51')]||_0x42c51c[a1_0x2aa3('0x42')];const _0x429c1b=new e2e_encryption_1[(a1_0x2aa3('0x52'))](_0x1613ea);const _0x1745d1=new error_reporter_api_1[(a1_0x2aa3('0x34'))](_0x42c51c);const _0x3a5b7f=(0x0,environment_1['agentRunningInDistributedExecution'])(_0x38bb1f)||!((_0x43fb12=_0x6e141[a1_0x2aa3('0x49')])===null||_0x43fb12===void 0x0?void 0x0:_0x43fb12[a1_0x2aa3('0x1d')]());const _0x1ab1ef=new file_storage_1[(a1_0x2aa3('0x3c'))](_0x429c1b,_0x1745d1,_0x42c51c,a1_0x2aa3('0x14'));const _0x1dfb5f=new cloud_remote_cache_1[(a1_0x2aa3('0x16'))](_0x22890c,_0x2a88b4,_0x4fc62d,_0x1ab1ef,_0x38bb1f,_0x3a5b7f);fetchUrlsForKnownHashesUpfront(_0x2a88b4,_0x4fc62d,_0x1430ad,_0x42c51c,_0x38bb1f);delete process[a1_0x2aa3('0xe')][a1_0x2aa3('0x15')];const _0x3ad5b6=tasksRunner(_0x1430ad,Object['assign'](Object[a1_0x2aa3('0x5')]({},_0x42c51c),{'remoteCache':_0x1dfb5f,'lifeCycle':_0x175b45}),_0x6e141);if(_0x3ad5b6['subscribe']){const {Subject}=require('rxjs/internal/Subject');const _0x388061=new Subject();_0x3ad5b6[a1_0x2aa3('0x31')]({'next':_0x28d336=>_0x388061[a1_0x2aa3('0x35')](_0x28d336),'error':_0x146a16=>_0x388061[a1_0x2aa3('0x40')](_0x146a16),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x3b7315=yield onComplete({'daemon':_0x6e141[a1_0x2aa3('0x49')],'options':_0x42c51c,'fileStorage':_0x1ab1ef,'remoteCache':_0x1dfb5f,'api':_0x2a88b4,'outputObfuscator':_0x559e82,'runStartTime':_0xc555f1,'messages':_0x22890c,'endOfRunMessage':_0x130bbb,'taskExecutions':_0x552860,'versionOfNxBefore133':_0x565829,'inner':_0x1d6194,'encryptionKey':_0x1613ea,'storeInCurrentProcess':_0x3a5b7f,'runContext':_0x4fc62d,'distributedExecutionId':_0x38bb1f});if(!_0x3b7315&&(0x0,environment_1[a1_0x2aa3('0x41')])(_0x38bb1f)){process['exit'](environment_1[a1_0x2aa3('0x48')]);}_0x388061[a1_0x2aa3('0x4d')]();})});return _0x388061;}else{return _0x3ad5b6[a1_0x2aa3('0x21')](_0x305bf6=>__awaiter(this,void 0x0,void 0x0,function*(){const _0xd66f6=yield onComplete({'daemon':_0x6e141[a1_0x2aa3('0x49')],'options':_0x42c51c,'fileStorage':_0x1ab1ef,'remoteCache':_0x1dfb5f,'api':_0x2a88b4,'outputObfuscator':_0x559e82,'runStartTime':_0xc555f1,'messages':_0x22890c,'endOfRunMessage':_0x130bbb,'taskExecutions':_0x552860,'versionOfNxBefore133':_0x565829,'inner':_0x1d6194,'encryptionKey':_0x1613ea,'storeInCurrentProcess':_0x3a5b7f,'runContext':_0x4fc62d,'distributedExecutionId':_0x38bb1f});if(!_0xd66f6&&(0x0,environment_1[a1_0x2aa3('0x41')])(_0x38bb1f)){process[a1_0x2aa3('0x32')](environment_1[a1_0x2aa3('0x48')]);}return _0x305bf6;}))[a1_0x2aa3('0x53')](_0x2ef44a=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x1c04c2=yield onComplete({'daemon':_0x6e141[a1_0x2aa3('0x49')],'options':_0x42c51c,'fileStorage':_0x1ab1ef,'remoteCache':_0x1dfb5f,'api':_0x2a88b4,'outputObfuscator':_0x559e82,'runStartTime':_0xc555f1,'messages':_0x22890c,'endOfRunMessage':_0x130bbb,'taskExecutions':_0x552860,'versionOfNxBefore133':_0x565829,'inner':_0x1d6194,'encryptionKey':_0x1613ea,'storeInCurrentProcess':_0x3a5b7f,'runContext':_0x4fc62d,'distributedExecutionId':_0x38bb1f});if(!_0x1c04c2&&(0x0,environment_1[a1_0x2aa3('0x41')])(_0x38bb1f)){process[a1_0x2aa3('0x32')](environment_1[a1_0x2aa3('0x48')]);}throw _0x2ef44a;}));}}exports['cloudEnabledTasksRunner']=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)();
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_0x16cf=['push','storage','put','Error\x20when\x20storing\x20artifacts','retrieve','indexOf','store','runContext','then','done','VERBOSE_LOGGING','get','axiosException','response','resolve','storeRequests','statuses','requests','delayedStoreRequests','waitForStoreRequestsToComplete','distributedExecutionId','fileStorage','scheduledTasks','Nx\x20Cloud:\x20Skipping\x20storing\x20','hash','next','extractErrorMessage','forEach','value','hashUrls','__esModule','throw','startRun','cacheError','messages','Maybe\x20you\x20are\x20using\x20a\x20read-only\x20token\x20or\x20the\x20artifact\x20has\x20already\x20being\x20uploaded.','.\x20Status\x20404.','cache-miss','Nx\x20Cloud:\x20Cache\x20miss\x20','api','remote-cache-hit','CloudRemoteCache','There\x20are\x20several\x20reasons\x20why\x20this\x20can\x20happen.'];(function(_0x48630a,_0x16cf39){const _0x5011f1=function(_0x510e86){while(--_0x510e86){_0x48630a['push'](_0x48630a['shift']());}};_0x5011f1(++_0x16cf39);}(a2_0x16cf,0x194));const a2_0x5011=function(_0x48630a,_0x16cf39){_0x48630a=_0x48630a-0x0;let _0x5011f1=a2_0x16cf[_0x48630a];return _0x5011f1;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x3b69e5,_0x10a4bf,_0x672950,_0x4d25f2){function _0x44fb2c(_0x4a1313){return _0x4a1313 instanceof _0x672950?_0x4a1313:new _0x672950(function(_0x5bc94d){_0x5bc94d(_0x4a1313);});}return new(_0x672950||(_0x672950=Promise))(function(_0x2806db,_0x4c8f2c){function _0x5c4845(_0x50af2d){try{_0x1134c5(_0x4d25f2[a2_0x5011('0x8')](_0x50af2d));}catch(_0x254b77){_0x4c8f2c(_0x254b77);}}function _0x2b704b(_0x176b1d){try{_0x1134c5(_0x4d25f2[a2_0x5011('0xe')](_0x176b1d));}catch(_0x2d79ea){_0x4c8f2c(_0x2d79ea);}}function _0x1134c5(_0x28bec5){_0x28bec5[a2_0x5011('0x23')]?_0x2806db(_0x28bec5[a2_0x5011('0xb')]):_0x44fb2c(_0x28bec5[a2_0x5011('0xb')])[a2_0x5011('0x22')](_0x5c4845,_0x2b704b);}_0x1134c5((_0x4d25f2=_0x4d25f2['apply'](_0x3b69e5,_0x10a4bf||[]))[a2_0x5011('0x8')]());});};Object['defineProperty'](exports,a2_0x5011('0xd'),{'value':!![]});exports['CloudRemoteCache']=void 0x0;const environment_1=require('../../../utilities/environment');const {output}=require('../../../utilities/nx-imports');class CloudRemoteCache{constructor(_0x1926b7,_0x26c37a,_0x27c2df,_0x4f1a06,_0x217f90,_0x5a6fad){this[a2_0x5011('0x11')]=_0x1926b7;this[a2_0x5011('0x16')]=_0x26c37a;this[a2_0x5011('0x21')]=_0x27c2df;this[a2_0x5011('0x4')]=_0x4f1a06;this[a2_0x5011('0x3')]=_0x217f90;this['storeInCurrentProcess']=_0x5a6fad;this[a2_0x5011('0x29')]=[];this['delayedStoreRequests']=[];}[a2_0x5011('0x1e')](_0x4def98,_0xf2517a){var _0x55b6e3;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x5011('0x11')]['cacheError'])return![];const _0x5772b9=yield this[a2_0x5011('0xc')](_0x4def98);if(!_0x5772b9||!_0x5772b9[a2_0x5011('0x25')]){if(environment_1['VERBOSE_LOGGING']){output['note']({'title':a2_0x5011('0x15')+_0x4def98+'.'});}this[a2_0x5011('0x21')][a2_0x5011('0x2a')][_0x4def98]=a2_0x5011('0x14');return![];}try{yield this[a2_0x5011('0x4')]['retrieve'](_0x4def98,_0x5772b9[a2_0x5011('0x25')],_0xf2517a);this['runContext'][a2_0x5011('0x2a')][_0x4def98]=a2_0x5011('0x17');return!![];}catch(_0x490045){const _0x260c6a=(_0x55b6e3=_0x490045[a2_0x5011('0x26')])!==null&&_0x55b6e3!==void 0x0?_0x55b6e3:_0x490045;if(_0x260c6a[a2_0x5011('0x27')]&&_0x260c6a[a2_0x5011('0x27')]['status']===0x194){if(environment_1[a2_0x5011('0x24')]){output['note']({'title':a2_0x5011('0x15')+_0x4def98+a2_0x5011('0x13')});}}else{this[a2_0x5011('0x11')][a2_0x5011('0x10')]=this['messages'][a2_0x5011('0x9')](_0x260c6a,a2_0x5011('0x1b'));}this[a2_0x5011('0x21')][a2_0x5011('0x2a')][_0x4def98]='cache-miss';return![];}});}[a2_0x5011('0x20')](_0x445748,_0x48bb60){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x5011('0x11')][a2_0x5011('0x10')])return![];const _0x28f5b4=Promise[a2_0x5011('0x28')]()[a2_0x5011('0x22')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x4fcc6c;const _0x172c54=yield this[a2_0x5011('0xc')](_0x445748);if(!_0x172c54)return![];if(!_0x172c54[a2_0x5011('0x1c')]){if(environment_1['VERBOSE_LOGGING']){output['note']({'title':a2_0x5011('0x6')+_0x445748+'.','bodyLines':[a2_0x5011('0x19'),a2_0x5011('0x12')]});}return!![];}if(!this['storeInCurrentProcess']){this[a2_0x5011('0x1')][a2_0x5011('0x1a')]({'hash':_0x445748,'url':_0x172c54[a2_0x5011('0x1c')]});return!![];}try{yield this[a2_0x5011('0x4')][a2_0x5011('0x20')](_0x445748,_0x172c54[a2_0x5011('0x1c')],_0x48bb60);return!![];}catch(_0x44fbc6){const _0x5ae49b=(_0x4fcc6c=_0x44fbc6[a2_0x5011('0x26')])!==null&&_0x4fcc6c!==void 0x0?_0x4fcc6c:_0x44fbc6;this[a2_0x5011('0x11')]['cacheError']=this[a2_0x5011('0x11')][a2_0x5011('0x9')](_0x5ae49b,a2_0x5011('0x1b'));return![];}}));this['storeRequests'][a2_0x5011('0x1a')](_0x28f5b4);return _0x28f5b4;});}['hashUrls'](_0x22fe7a){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x22fe7a in this[a2_0x5011('0x21')][a2_0x5011('0x0')]){return(yield this['runContext']['requests'][_0x22fe7a])[_0x22fe7a];}else{const _0x342163=this[a2_0x5011('0x21')][a2_0x5011('0x5')]['filter'](_0x1a5fe9=>!this['runContext'][a2_0x5011('0x0')][_0x1a5fe9[a2_0x5011('0x7')]])['map'](_0x18f3bc=>_0x18f3bc[a2_0x5011('0x7')]);if(_0x342163[a2_0x5011('0x1f')](_0x22fe7a)===-0x1){_0x342163[a2_0x5011('0x1a')](_0x22fe7a);}const _0x2a7e9b=this[a2_0x5011('0x16')][a2_0x5011('0xf')](this[a2_0x5011('0x3')],_0x342163);_0x342163[a2_0x5011('0xa')](_0x331de=>{this['runContext']['requests'][_0x331de]=_0x2a7e9b;});return(yield _0x2a7e9b)[_0x22fe7a];}});}[a2_0x5011('0x2')](){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1deedf=yield Promise['all'](this[a2_0x5011('0x29')])[a2_0x5011('0x22')](_0x5b36a2=>_0x5b36a2['reduce']((_0x2cebf0,_0x57f09f)=>_0x2cebf0&&_0x57f09f,!![]));if(!_0x1deedf){throw new Error(a2_0x5011('0x1d'));}});}}exports[a2_0x5011('0x18')]=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,175 @@

const a3_0x1533=['string','axiosException','toString','nxCloudVersion','RunEnd\x20duration','__awaiter','status','assign','next','Run\x20completion\x20responded\x20with\x20`undefined`.','throw','getRunGroup','startRun','/nx-cloud/runs/start','RunEnd.\x20Completed\x20tasks','machineInfo','../../../utilities/is-private-cloud','Invalid\x20Nx\x20Cloud\x20response:\x20','recordMetric','RunStart','runContext','axiosMultipleTries','RunStart\x20duration','VERBOSE_LOGGING','promisify','mapRespToPerfEntry','extractErrorMessage','application/octet-stream','response','/nx-cloud/runs/end','runUrl','parse','headers','createReqBody','api','printDuration','CloudRunApi','Invalid\x20end\x20run\x20response:\x20','stack','note','Stack\x20Trace:','../../../utilities/environment','slice','error','Run\x20Details:','messages','urls','post','message','endRun','Invalid\x20end\x20run\x20response','getCIExecutionEnv','nx-cloud','map','uploadedToStorage','__esModule','getCIExecutionId','apiAxiosInstance','RUNNER_FAILURE_PERF_ENTRY','unknown','zlib','devDependencies','length','apiError','util','stringify','data','terminalOutput','getBranch','...','value','createApiAxiosInstance','@nrwl/nx-cloud','gzip'];(function(_0x4150f0,_0x1533a3){const _0x3757fb=function(_0x167f94){while(--_0x167f94){_0x4150f0['push'](_0x4150f0['shift']());}};_0x3757fb(++_0x1533a3);}(a3_0x1533,0x75));const a3_0x3757=function(_0x4150f0,_0x1533a3){_0x4150f0=_0x4150f0-0x0;let _0x3757fb=a3_0x1533[_0x4150f0];return _0x3757fb;};'use strict';var __awaiter=this&&this[a3_0x3757('0x24')]||function(_0x7c8a52,_0x393f1b,_0x5a1fd2,_0x249da9){function _0x282f4d(_0x3a7953){return _0x3a7953 instanceof _0x5a1fd2?_0x3a7953:new _0x5a1fd2(function(_0x589381){_0x589381(_0x3a7953);});}return new(_0x5a1fd2||(_0x5a1fd2=Promise))(function(_0x44487e,_0x28d4e2){function _0x36f055(_0x476207){try{_0x55f52e(_0x249da9[a3_0x3757('0x27')](_0x476207));}catch(_0x8bb708){_0x28d4e2(_0x8bb708);}}function _0x4b9048(_0x31e270){try{_0x55f52e(_0x249da9[a3_0x3757('0x29')](_0x31e270));}catch(_0x1e82b2){_0x28d4e2(_0x1e82b2);}}function _0x55f52e(_0x5cd12e){_0x5cd12e['done']?_0x44487e(_0x5cd12e[a3_0x3757('0x1b')]):_0x282f4d(_0x5cd12e[a3_0x3757('0x1b')])['then'](_0x36f055,_0x4b9048);}_0x55f52e((_0x249da9=_0x249da9['apply'](_0x7c8a52,_0x393f1b||[]))[a3_0x3757('0x27')]());});};Object['defineProperty'](exports,a3_0x3757('0xc'),{'value':!![]});exports[a3_0x3757('0x43')]=void 0x0;const axios_1=require('../../../utilities/axios');const environment_1=require(a3_0x3757('0x48'));const fs_1=require('fs');const zlib_1=require(a3_0x3757('0x11'));const util_1=require(a3_0x3757('0x15'));const metric_logger_1=require('../../../utilities/metric-logger');const is_private_cloud_1=require(a3_0x3757('0x2f'));const {output}=require('../../../utilities/nx-imports');class CloudRunApi{constructor(_0x318863,_0x2483fc,_0x50c210,_0x56fa53){this[a3_0x3757('0x2')]=_0x318863;this['runContext']=_0x2483fc;this[a3_0x3757('0x2e')]=_0x56fa53;this[a3_0x3757('0xe')]=(0x0,axios_1[a3_0x3757('0x1c')])(_0x50c210);}['startRun'](_0xf9a0e3,_0x2539a6){var _0x11ecdd;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x3757('0x2')][a3_0x3757('0x14')])return{};const _0x25151f=(0x0,metric_logger_1['createMetricRecorder'])(a3_0x3757('0x2b'));try{const _0x484e63={'meta':{'nxCloudVersion':this[a3_0x3757('0x22')]()},'branch':(0x0,environment_1[a3_0x3757('0x19')])(),'runGroup':(0x0,environment_1[a3_0x3757('0x2a')])(),'ciExecutionId':(0x0,environment_1[a3_0x3757('0xd')])(),'ciExecutionEnv':(0x0,environment_1[a3_0x3757('0x8')])(),'distributedExecutionId':_0xf9a0e3,'hashes':_0x2539a6};if(environment_1['VERBOSE_LOGGING']){output['note']({'title':a3_0x3757('0x32'),'bodyLines':['\x0a'+JSON[a3_0x3757('0x16')](_0x484e63,null,0x2)]});}const _0x32444f=yield(0x0,axios_1['printDuration'])(a3_0x3757('0x35'),()=>(0x0,axios_1[a3_0x3757('0x34')])(()=>this[a3_0x3757('0xe')][a3_0x3757('0x4')](a3_0x3757('0x2c'),_0x484e63)));_0x25151f['recordMetric']((0x0,metric_logger_1[a3_0x3757('0x38')])(_0x32444f));if(_0x32444f[a3_0x3757('0x17')]&&_0x32444f['data']['message']){this['messages'][a3_0x3757('0x5')]=_0x32444f[a3_0x3757('0x17')][a3_0x3757('0x5')];}if(!_0x32444f[a3_0x3757('0x17')]||!_0x32444f['data']['urls']){this[a3_0x3757('0x2')][a3_0x3757('0x14')]=a3_0x3757('0x30')+JSON[a3_0x3757('0x16')](_0x32444f[a3_0x3757('0x17')]);return{};}return _0x32444f[a3_0x3757('0x17')][a3_0x3757('0x3')];}catch(_0x5c53bc){_0x25151f[a3_0x3757('0x31')](((_0x11ecdd=_0x5c53bc===null||_0x5c53bc===void 0x0?void 0x0:_0x5c53bc['axiosException'])===null||_0x11ecdd===void 0x0?void 0x0:_0x11ecdd['response'])?(0x0,metric_logger_1[a3_0x3757('0x38')])(_0x5c53bc['axiosException']['response']):metric_logger_1[a3_0x3757('0xf')]);this['messages'][a3_0x3757('0x14')]=this['messages'][a3_0x3757('0x39')](_0x5c53bc,a3_0x3757('0x41'));return{};}});}[a3_0x3757('0x40')](_0x65f761,_0x573e21,_0xa5ef6c,_0x1519ef){if((0x0,is_private_cloud_1['isConnectedToPrivateCloud'])()){for(let _0x10df1a of _0x573e21){delete _0x10df1a[a3_0x3757('0xb')];}}const _0x57e0cf=Object[a3_0x3757('0x26')](Object[a3_0x3757('0x26')]({'meta':{'nxCloudVersion':this['nxCloudVersion']()},'tasks':_0x573e21,'run':_0x65f761,'linkId':_0x1519ef},(0x0,is_private_cloud_1['isConnectedToPrivateCloud'])()?{}:_0xa5ef6c),{'machineInfo':this[a3_0x3757('0x2e')]});return JSON[a3_0x3757('0x16')](_0x57e0cf);}[a3_0x3757('0x6')](_0x1e6c06,_0x1acee4,_0x6332aa,_0x16f67){var _0x1b378f,_0x275cd2;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x3757('0x2')][a3_0x3757('0x14')])return![];let _0x169867=this[a3_0x3757('0x40')](_0x1e6c06,_0x1acee4,_0x6332aa,_0x16f67);if(_0x169867[a3_0x3757('0x13')]>0x14*0x3e8*0x3e8){_0x169867=this[a3_0x3757('0x40')](_0x1e6c06,_0x1acee4[a3_0x3757('0xa')](_0x1b33ef=>Object[a3_0x3757('0x26')](Object['assign']({},_0x1b33ef),{'hashDetails':undefined})),_0x6332aa,_0x16f67);}const _0xbef20e=Buffer['from'](_0x169867);const _0xbe0b3f=yield(0x0,util_1[a3_0x3757('0x37')])(zlib_1[a3_0x3757('0x1e')])(_0xbef20e);const _0xac7b31=(0x0,metric_logger_1['createMetricRecorder'])(a3_0x3757('0x6'));try{if(environment_1[a3_0x3757('0x36')]){const _0x8a1681=_0x1acee4[a3_0x3757('0xa')](_0x17d535=>{return Object[a3_0x3757('0x26')](Object[a3_0x3757('0x26')]({},_0x17d535),{'terminalOutput':_0x17d535[a3_0x3757('0x18')]?_0x17d535[a3_0x3757('0x18')][a3_0x3757('0x49')](0x0,0x14)+a3_0x3757('0x1a'):undefined});});output[a3_0x3757('0x46')]({'title':a3_0x3757('0x2d'),'bodyLines':['\x0a'+JSON[a3_0x3757('0x16')](_0x8a1681,null,0x2)]});}const _0x499009=yield(0x0,axios_1[a3_0x3757('0x42')])(a3_0x3757('0x23'),()=>(0x0,axios_1[a3_0x3757('0x34')])(()=>this[a3_0x3757('0xe')][a3_0x3757('0x4')](a3_0x3757('0x3c'),_0xbe0b3f,{'headers':Object[a3_0x3757('0x26')](Object[a3_0x3757('0x26')]({},this[a3_0x3757('0xe')]['defaults'][a3_0x3757('0x3f')]),{'Content-Encoding':a3_0x3757('0x1e'),'Content-Type':a3_0x3757('0x3a')})})));if(_0x499009){_0xac7b31[a3_0x3757('0x31')]((0x0,metric_logger_1[a3_0x3757('0x38')])(_0x499009));if(_0x499009['data']&&_0x499009[a3_0x3757('0x17')]['runUrl']&&_0x499009[a3_0x3757('0x17')][a3_0x3757('0x25')]==='success'){this[a3_0x3757('0x33')]['runUrl']=_0x499009['data'][a3_0x3757('0x3d')];return!![];}if(_0x499009[a3_0x3757('0x17')]&&_0x499009[a3_0x3757('0x17')][a3_0x3757('0x25')]){this[a3_0x3757('0x2')][a3_0x3757('0x14')]=a3_0x3757('0x44')+JSON['stringify'](_0x499009[a3_0x3757('0x17')][a3_0x3757('0x5')]);}else if(_0x499009[a3_0x3757('0x17')]&&typeof _0x499009['data']===a3_0x3757('0x1f')){if(_0x499009[a3_0x3757('0x17')]!=='success'){this['messages'][a3_0x3757('0x14')]=a3_0x3757('0x44')+JSON[a3_0x3757('0x16')](_0x499009[a3_0x3757('0x17')]);}}else{this['messages']['apiError']=a3_0x3757('0x44')+JSON[a3_0x3757('0x16')](_0x499009[a3_0x3757('0x17')]);}if(environment_1[a3_0x3757('0x36')]){output[a3_0x3757('0x46')]({'title':a3_0x3757('0x7'),'bodyLines':[JSON[a3_0x3757('0x16')](_0x499009[a3_0x3757('0x17')],null,0x2)]});}}else{output[a3_0x3757('0x0')]({'title':'Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','bodyLines':[a3_0x3757('0x28'),a3_0x3757('0x1'),JSON[a3_0x3757('0x16')](_0x1e6c06,null,0x2),a3_0x3757('0x47'),JSON['stringify'](new Error()[a3_0x3757('0x45')],null,0x2)]});}return![];}catch(_0x170a98){_0xac7b31['recordMetric'](((_0x1b378f=_0x170a98===null||_0x170a98===void 0x0?void 0x0:_0x170a98['axiosException'])===null||_0x1b378f===void 0x0?void 0x0:_0x1b378f[a3_0x3757('0x3b')])?(0x0,metric_logger_1[a3_0x3757('0x38')])(_0x170a98[a3_0x3757('0x20')][a3_0x3757('0x3b')]):metric_logger_1[a3_0x3757('0xf')]);const _0x4ada7b=(_0x275cd2=_0x170a98[a3_0x3757('0x20')])!==null&&_0x275cd2!==void 0x0?_0x275cd2:_0x170a98;this[a3_0x3757('0x2')][a3_0x3757('0x14')]=this[a3_0x3757('0x2')][a3_0x3757('0x39')](_0x4ada7b,'api');return![];}});}['nxCloudVersion'](){try{const _0x26651f=JSON[a3_0x3757('0x3e')]((0x0,fs_1['readFileSync'])('package.json')[a3_0x3757('0x21')]());return _0x26651f[a3_0x3757('0x12')][a3_0x3757('0x9')]||_0x26651f[a3_0x3757('0x12')][a3_0x3757('0x1d')];}catch(_0x50fa5d){return a3_0x3757('0x10');}}}exports[a3_0x3757('0x43')]=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,
machineInfo: this.machineInfo,
};
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_0x5868=['ABCDEFGHIJKLMNOPQRSTUVWXYZ','0123456789','floor','generateUniqueLinkId','__esModule','random','length','defineProperty','toLowerCase'];(function(_0x280f52,_0x5868f6){const _0x1ab766=function(_0x35a341){while(--_0x35a341){_0x280f52['push'](_0x280f52['shift']());}};_0x1ab766(++_0x5868f6);}(a4_0x5868,0x10c));const a4_0x1ab7=function(_0x280f52,_0x5868f6){_0x280f52=_0x280f52-0x0;let _0x1ab766=a4_0x5868[_0x280f52];return _0x1ab766;};'use strict';Object[a4_0x1ab7('0x0')](exports,a4_0x1ab7('0x6'),{'value':!![]});exports[a4_0x1ab7('0x5')]=void 0x0;const upper=a4_0x1ab7('0x2');const digits=a4_0x1ab7('0x3');const lower=upper[a4_0x1ab7('0x1')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x4cd706='';for(let _0x1a4ae5=0x0;_0x1a4ae5<0xa;++_0x1a4ae5){_0x4cd706+=alphanum[Math[a4_0x1ab7('0x4')](Math[a4_0x1ab7('0x7')]()*alphanum[a4_0x1ab7('0x8')])];}return _0x4cd706;}exports[a4_0x1ab7('0x5')]=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_0x290a=['runGroup','createApiAxiosInstance','mapRespToPerfEntry','post','data','axiosMultipleTries','agentName','branch','../../../utilities/axios','done','throw','apiAxiosInstance','axiosException','RUNNER_FAILURE_PERF_ENTRY','error','apply','ciExecutionEnv','ciExecutionId','note','ciExecutionId:\x20','Completing\x20with\x20an\x20error','tasks','VERBOSE_LOGGING','Completed\x20run\x20group\x20with\x20an\x20error','../../../utilities/nx-imports','/nx-cloud/executions/tasks','dtePollTasks','__awaiter','runGroup:\x20','DistributedAgentApi','response','defineProperty','value','recordMetric','then'];(function(_0x2bbc42,_0x290a61){const _0x240bcb=function(_0x28529e){while(--_0x28529e){_0x2bbc42['push'](_0x2bbc42['shift']());}};_0x240bcb(++_0x290a61);}(a5_0x290a,0x11b));const a5_0x240b=function(_0x2bbc42,_0x290a61){_0x2bbc42=_0x2bbc42-0x0;let _0x240bcb=a5_0x290a[_0x2bbc42];return _0x240bcb;};'use strict';var __awaiter=this&&this[a5_0x240b('0x18')]||function(_0x266487,_0x49459c,_0xfbdb4f,_0x3e3e04){function _0x17a8f9(_0x371af0){return _0x371af0 instanceof _0xfbdb4f?_0x371af0:new _0xfbdb4f(function(_0x4e3197){_0x4e3197(_0x371af0);});}return new(_0xfbdb4f||(_0xfbdb4f=Promise))(function(_0x8470a,_0xe9e71b){function _0x2ac819(_0x544417){try{_0x1ee13b(_0x3e3e04['next'](_0x544417));}catch(_0x245197){_0xe9e71b(_0x245197);}}function _0x34e97d(_0x25cc77){try{_0x1ee13b(_0x3e3e04[a5_0x240b('0x7')](_0x25cc77));}catch(_0x50933b){_0xe9e71b(_0x50933b);}}function _0x1ee13b(_0x27f3fc){_0x27f3fc[a5_0x240b('0x6')]?_0x8470a(_0x27f3fc['value']):_0x17a8f9(_0x27f3fc[a5_0x240b('0x1d')])[a5_0x240b('0x1f')](_0x2ac819,_0x34e97d);}_0x1ee13b((_0x3e3e04=_0x3e3e04[a5_0x240b('0xc')](_0x266487,_0x49459c||[]))['next']());});};Object[a5_0x240b('0x1c')](exports,'__esModule',{'value':!![]});exports['DistributedAgentApi']=void 0x0;const axios_1=require(a5_0x240b('0x5'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require('../../../utilities/metric-logger');const {output}=require(a5_0x240b('0x15'));class DistributedAgentApi{constructor(_0x18a5ef,_0x2dede5,_0x26ebe1,_0x5b7fbc,_0x321f4a,_0x2fb435){this[a5_0x240b('0x4')]=_0x2dede5;this[a5_0x240b('0x20')]=_0x26ebe1;this['ciExecutionId']=_0x5b7fbc;this[a5_0x240b('0xd')]=_0x321f4a;this[a5_0x240b('0x3')]=_0x2fb435;this[a5_0x240b('0x8')]=(0x0,axios_1[a5_0x240b('0x21')])(_0x18a5ef);}[a5_0x240b('0x12')](_0x209c4e,_0x5ed976,_0x1014b7,_0x311ab3){var _0x57a284;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2efd8d=(0x0,metric_logger_1['createMetricRecorder'])(a5_0x240b('0x17'));try{const _0xbe28f9=yield(0x0,axios_1[a5_0x240b('0x2')])(()=>this['apiAxiosInstance'][a5_0x240b('0x0')](a5_0x240b('0x16'),{'runGroup':this[a5_0x240b('0x20')],'ciExecutionId':this[a5_0x240b('0xe')],'ciExecutionEnv':this[a5_0x240b('0xd')],'agentName':this[a5_0x240b('0x3')],'executionId':_0x209c4e,'statusCode':_0x5ed976,'completedTasks':_0x1014b7,'targets':_0x311ab3}));_0x2efd8d['recordMetric']((0x0,metric_logger_1[a5_0x240b('0x22')])(_0xbe28f9));return _0xbe28f9[a5_0x240b('0x1')];}catch(_0x1b859c){_0x2efd8d[a5_0x240b('0x1e')](((_0x57a284=_0x1b859c===null||_0x1b859c===void 0x0?void 0x0:_0x1b859c[a5_0x240b('0x9')])===null||_0x57a284===void 0x0?void 0x0:_0x57a284['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x1b859c['axiosException']['response']):metric_logger_1[a5_0x240b('0xa')]);throw _0x1b859c;}});}['completeRunGroupWithError'](_0x3a3363){var _0x5b5c46;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a5_0x240b('0x13')]){output[a5_0x240b('0xf')]({'title':a5_0x240b('0x11'),'bodyLines':[a5_0x240b('0x10')+this[a5_0x240b('0xe')],'ciExecutionEnv:\x20'+this[a5_0x240b('0xd')],a5_0x240b('0x19')+this[a5_0x240b('0x20')],'error:\x20'+_0x3a3363]});}const _0x542cdc=(0x0,metric_logger_1['createMetricRecorder'])('completeRunGroup');try{const _0x4dbcef=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a5_0x240b('0x8')][a5_0x240b('0x0')]('/nx-cloud/executions/complete-run-group',{'branch':this[a5_0x240b('0x4')],'runGroup':this['runGroup'],'ciExecutionId':this['ciExecutionId'],'ciExecutionEnv':this[a5_0x240b('0xd')],'agentName':this[a5_0x240b('0x3')],'criticalErrorMessage':_0x3a3363}));if(environment_1[a5_0x240b('0x13')]){output[a5_0x240b('0xf')]({'title':a5_0x240b('0x14')});}_0x542cdc[a5_0x240b('0x1e')]((0x0,metric_logger_1[a5_0x240b('0x22')])(_0x4dbcef));}catch(_0x512796){_0x542cdc[a5_0x240b('0x1e')](((_0x5b5c46=_0x512796===null||_0x512796===void 0x0?void 0x0:_0x512796[a5_0x240b('0x9')])===null||_0x5b5c46===void 0x0?void 0x0:_0x5b5c46[a5_0x240b('0x1b')])?(0x0,metric_logger_1[a5_0x240b('0x22')])(_0x512796[a5_0x240b('0x9')][a5_0x240b('0x1b')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);console[a5_0x240b('0xb')](_0x512796);}});}}exports[a5_0x240b('0x1a')]=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_0x3b6c=['then','CIRCLE_STAGE','tasksRunnerOptions','printRunGroupError','E2EEncryption','../../error/print-cacheable-targets-error','Agent\x20was\x20terminated\x20via\x20SIGTERM','printCacheableTargetsError','SIGTERM','Nx\x20Cloud:\x20Workspace\x20is\x20disabled','./execute-tasks','unlinkSync','includes','mkdirSync','Distributed\x20Task\x20Execution\x20is\x20disabled\x20when\x20your\x20workspace\x20is\x20disabled','completeRunGroupWithError','Duplicate\x20Agent\x20ID\x20Detected','filter','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','join','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','defineProperty','submitRunMetrics','ENCRYPTION_KEY','readdirSync','warn','yargs-parser','cacheableOperations','strip-json-comments','existsSync','value','nx-cloud','writeFileSync','Agent\x20was\x20terminated\x20via\x20SIGINT','../../../utilities/nx-imports','canDetectRunGroup','next','../../error/print-invalid-runner-error','startAgent','printInvalidRunnerError','invokeTasksUsingNxImperativeApi','toString','../../../utilities/is-workspace-enabled','default','CIRCLE_JOB','./invoke-tasks-using-nx-imperative-api','../../../utilities/metric-logger','invokeTasksUsingRunMany','getCIExecutionEnv','__esModule','../../../utilities/environment','catch','error','../../../utilities/dte-artifact-storage','done','Agent\x20','parse','random','.lock','split','targets','SIGINT','/nx.json','../../file-storage/e2e-encryption','@nrwl/nx-cloud','throw','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20[','length','Organization\x20administrators\x20can\x20find\x20more\x20information\x20on\x20the\x20\x27Billing\x20and\x20Plans\x27\x20page\x20in\x20the\x20Nx\x20Cloud\x20Webapp','env','../../error/print-run-group-error','map','executeTasks','floor','exit','NX_AGENT_NAME','Critical\x20Error\x20in\x20Agent:\x20\x22','ErrorReporterApi','./invoke-tasks-using-run-many','FileStorage','./distributed-agent.api','trim','runner','message','argv','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','CIRCLECI','dte-agent','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.'];(function(_0x47e414,_0x3b6c19){const _0x32fc67=function(_0x54a38f){while(--_0x54a38f){_0x47e414['push'](_0x47e414['shift']());}};_0x32fc67(++_0x3b6c19);}(a6_0x3b6c,0x192));const a6_0x32fc=function(_0x47e414,_0x3b6c19){_0x47e414=_0x47e414-0x0;let _0x32fc67=a6_0x3b6c[_0x47e414];return _0x32fc67;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x23c079,_0x3b7478,_0x2d9ef5,_0x9da9a6){function _0x4352ab(_0x362b67){return _0x362b67 instanceof _0x2d9ef5?_0x362b67:new _0x2d9ef5(function(_0xe0f2a1){_0xe0f2a1(_0x362b67);});}return new(_0x2d9ef5||(_0x2d9ef5=Promise))(function(_0x548239,_0x28bb13){function _0x25c05e(_0x1429ee){try{_0x468bcd(_0x9da9a6[a6_0x32fc('0x4f')](_0x1429ee));}catch(_0x38ba9b){_0x28bb13(_0x38ba9b);}}function _0x49f5e0(_0x80810c){try{_0x468bcd(_0x9da9a6[a6_0x32fc('0x13')](_0x80810c));}catch(_0xbd57ec){_0x28bb13(_0xbd57ec);}}function _0x468bcd(_0x47871f){_0x47871f[a6_0x32fc('0x8')]?_0x548239(_0x47871f[a6_0x32fc('0x49')]):_0x4352ab(_0x47871f['value'])[a6_0x32fc('0x2b')](_0x25c05e,_0x49f5e0);}_0x468bcd((_0x9da9a6=_0x9da9a6['apply'](_0x23c079,_0x3b7478||[]))[a6_0x32fc('0x4f')]());});};Object[a6_0x32fc('0x40')](exports,a6_0x32fc('0x3'),{'value':!![]});exports['startAgent']=void 0x0;const fs_1=require('fs');const stripJsonComments=require(a6_0x32fc('0x47'));const yargsParser=require(a6_0x32fc('0x45'));const environment_1=require(a6_0x32fc('0x4'));const metric_logger_1=require(a6_0x32fc('0x0'));const print_cacheable_targets_error_1=require(a6_0x32fc('0x30'));const print_invalid_runner_error_1=require(a6_0x32fc('0x50'));const print_run_group_error_1=require(a6_0x32fc('0x18'));const distributed_agent_api_1=require(a6_0x32fc('0x22'));const execute_tasks_1=require(a6_0x32fc('0x35'));const dte_artifact_storage_1=require(a6_0x32fc('0x7'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a6_0x32fc('0x11'));const error_reporter_api_1=require('../../api/error-reporter.api');const invoke_tasks_using_run_many_1=require(a6_0x32fc('0x20'));const invoke_tasks_using_nx_imperative_api_1=require(a6_0x32fc('0x58'));const is_workspace_enabled_1=require(a6_0x32fc('0x55'));const {output,initTasksRunner,workspaceRoot,cacheDirectory}=require(a6_0x32fc('0x4d'));const args=yargsParser(process[a6_0x32fc('0x26')],{'array':[a6_0x32fc('0xe')],'default':{}});if(args['targets']&&args[a6_0x32fc('0xe')][a6_0x32fc('0x15')]===0x1){args[a6_0x32fc('0xe')]=args[a6_0x32fc('0xe')][0x0][a6_0x32fc('0xd')](',')[a6_0x32fc('0x19')](_0x3fce66=>_0x3fce66[a6_0x32fc('0x23')]());}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x13246a=(0x0,environment_1['getBranch'])();const _0x238e96=(0x0,environment_1['getRunGroup'])();const _0x25bdaf=(0x0,environment_1['getCIExecutionId'])();const _0x2e5cd1=(0x0,environment_1[a6_0x32fc('0x2')])();if(!(0x0,print_run_group_error_1[a6_0x32fc('0x4e')])(_0x238e96,_0x25bdaf)){(0x0,print_run_group_error_1[a6_0x32fc('0x2e')])();process['exit'](0x1);}if(args[a6_0x32fc('0xe')]&&args[a6_0x32fc('0xe')][a6_0x32fc('0x15')]){output['note']({'title':a6_0x32fc('0x14')+args['targets'][a6_0x32fc('0x3e')](',\x20')+']'});}else{output['note']({'title':a6_0x32fc('0x27')});}const _0x298353=JSON[a6_0x32fc('0xa')](stripJsonComments((0x0,fs_1['readFileSync'])(workspaceRoot+a6_0x32fc('0x10'))[a6_0x32fc('0x54')]()))[a6_0x32fc('0x2d')][a6_0x32fc('0x56')];if(_0x298353['runner']!==a6_0x32fc('0x4a')&&_0x298353[a6_0x32fc('0x24')]!==a6_0x32fc('0x12')){(0x0,print_invalid_runner_error_1[a6_0x32fc('0x52')])();return process[a6_0x32fc('0x1c')](0x1);}const _0x1354de=_0x298353['options'];if(args['targets']&&args['targets']['some'](_0x4c4f53=>{var _0x12ee93;return!((_0x12ee93=_0x1354de[a6_0x32fc('0x46')])===null||_0x12ee93===void 0x0?void 0x0:_0x12ee93['includes'](_0x4c4f53));})){const _0x31fcf6=args[a6_0x32fc('0xe')][a6_0x32fc('0x3c')](_0x235943=>{var _0x3eac16;return!((_0x3eac16=_0x1354de[a6_0x32fc('0x46')])===null||_0x3eac16===void 0x0?void 0x0:_0x3eac16[a6_0x32fc('0x37')](_0x235943));});(0x0,print_cacheable_targets_error_1[a6_0x32fc('0x32')])(_0x31fcf6);return process[a6_0x32fc('0x1c')](0x1);}const _0x428fe9=yield(0x0,is_workspace_enabled_1['isWorkspaceEnabled'])(_0x1354de);if(!_0x428fe9){output[a6_0x32fc('0x6')]({'title':a6_0x32fc('0x34'),'bodyLines':[a6_0x32fc('0x39'),'',a6_0x32fc('0x16')]});process[a6_0x32fc('0x1c')](0x1);}const _0x386318=getAgentName();const _0x4cbe34=new distributed_agent_api_1['DistributedAgentApi'](_0x1354de,_0x13246a,_0x238e96,_0x25bdaf,_0x2e5cd1,_0x386318);createAgentLockfileAndSetUpListeners(_0x4cbe34,_0x1354de,_0x386318);const _0x1ffdc7=new e2e_encryption_1[(a6_0x32fc('0x2f'))](environment_1[a6_0x32fc('0x42')]||_0x1354de['encryptionKey']);const _0x4d7082=new error_reporter_api_1[(a6_0x32fc('0x1f'))](_0x1354de);const _0x447af7=new dte_artifact_storage_1['DteArtifactStorage'](new file_storage_1[(a6_0x32fc('0x21'))](_0x1ffdc7,_0x4d7082,_0x1354de,a6_0x32fc('0x29')),cacheDirectory);const _0x51c118=initTasksRunner?yield(0x0,invoke_tasks_using_nx_imperative_api_1[a6_0x32fc('0x53')])(_0x1354de):yield(0x0,invoke_tasks_using_run_many_1[a6_0x32fc('0x1')])();return(0x0,execute_tasks_1[a6_0x32fc('0x1a')])(_0x386318,_0x4cbe34,_0x447af7,_0x51c118,args[a6_0x32fc('0xe')])['then'](_0x4a37f1=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a6_0x32fc('0x41')])(_0x1354de);return _0x4a37f1;}))[a6_0x32fc('0x5')](_0x1c9621=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x4cbe34[a6_0x32fc('0x3a')](a6_0x32fc('0x1e')+_0x1c9621[a6_0x32fc('0x25')]+'\x22');throw _0x1c9621;}));});}exports[a6_0x32fc('0x51')]=startAgent;function getAgentName(){if(process[a6_0x32fc('0x17')][a6_0x32fc('0x1d')]!==undefined){return process[a6_0x32fc('0x17')][a6_0x32fc('0x1d')];}else if(process['env'][a6_0x32fc('0x28')]!==undefined&&process[a6_0x32fc('0x17')][a6_0x32fc('0x2c')]){return process[a6_0x32fc('0x17')][a6_0x32fc('0x2c')];}else if(process[a6_0x32fc('0x17')]['CIRCLECI']!==undefined&&process[a6_0x32fc('0x17')][a6_0x32fc('0x57')]){return process[a6_0x32fc('0x17')][a6_0x32fc('0x57')];}else{return a6_0x32fc('0x9')+Math[a6_0x32fc('0x1b')](Math[a6_0x32fc('0xb')]()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x1b1fee,_0x3279bd,_0x2649a3){const _0x37a7a6=cacheDirectory+'/lockfiles';const _0x220026=_0x37a7a6+'/'+_0x2649a3+a6_0x32fc('0xc');if(!(0x0,fs_1[a6_0x32fc('0x48')])(_0x37a7a6)){(0x0,fs_1[a6_0x32fc('0x38')])(_0x37a7a6,{'recursive':!![]});}const _0x4ee80b=(0x0,fs_1[a6_0x32fc('0x43')])(_0x37a7a6);if(_0x4ee80b[a6_0x32fc('0x15')]){if(_0x4ee80b[a6_0x32fc('0x37')](_0x2649a3+a6_0x32fc('0xc'))){output[a6_0x32fc('0x6')]({'title':a6_0x32fc('0x3b'),'bodyLines':['We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.']});process[a6_0x32fc('0x1c')](0x1);}output[a6_0x32fc('0x44')]({'title':'Other\x20Nx\x20Cloud\x20Agents\x20Detected','bodyLines':[a6_0x32fc('0x2a'),'',a6_0x32fc('0x3d'),a6_0x32fc('0x3f')]});}(0x0,fs_1[a6_0x32fc('0x4b')])(_0x220026,'');process['on'](a6_0x32fc('0x1c'),_0x3683f1=>{cleanupAgentLockfile(_0x220026,_0x3683f1);});process['on'](a6_0x32fc('0x33'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x1b1fee['completeRunGroupWithError'](a6_0x32fc('0x31'));cleanupAgentLockfile(_0x220026,0x1);}));process['on'](a6_0x32fc('0xf'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x1b1fee['completeRunGroupWithError'](a6_0x32fc('0x4c'));cleanupAgentLockfile(_0x220026,0x1);}));}function cleanupAgentLockfile(_0x4ec02f,_0x400a11){if((0x0,fs_1[a6_0x32fc('0x48')])(_0x4ec02f)){(0x0,fs_1[a6_0x32fc('0x36')])(_0x4ec02f);process[a6_0x32fc('0x1c')](_0x400a11);}}
"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_0x21c8=['retryDuring:\x20','map','url','\x20fetching\x20tasks...','__awaiter','getTime','next','Error:','../../../utilities/nx-imports','NO_FURTHER_TASKS_TO_RUN','error:\x20','executionId','\x20waiting...','../../../utilities/create-unchanged-value-timeout','No\x20new\x20messages\x20received\x20after\x20','value','\x20downloading\x20artifacts\x20for\x20','\x20Url:\x20','hash','note','NO_MESSAGES_TIMEOUT','tasks','reset','../../../utilities/environment','retryDuring','retrieveAndExtract','exit','createUnchangedValueTimeout','Waiter','maxParallel:\x20','Distributed\x20Execution\x20Terminated','criticalErrorMessage','status:\x20','taskId','\x20seconds','../../../utilities/waiter','RUN_GROUP_COMPLETED','completedTasks','maxParallel','status','join','wait','error','VERBOSE_LOGGING','apply','__esModule','done','completed:\x20'];(function(_0x5e7d7e,_0x21c842){const _0x4b9039=function(_0x21f929){while(--_0x21f929){_0x5e7d7e['push'](_0x5e7d7e['shift']());}};_0x4b9039(++_0x21c842);}(a7_0x21c8,0x1f1));const a7_0x4b90=function(_0x5e7d7e,_0x21c842){_0x5e7d7e=_0x5e7d7e-0x0;let _0x4b9039=a7_0x21c8[_0x5e7d7e];return _0x4b9039;};'use strict';var __awaiter=this&&this[a7_0x4b90('0x23')]||function(_0x1c1cd3,_0x40408a,_0x31d8cc,_0x39d164){function _0x197760(_0x4e4053){return _0x4e4053 instanceof _0x31d8cc?_0x4e4053:new _0x31d8cc(function(_0x1d76dd){_0x1d76dd(_0x4e4053);});}return new(_0x31d8cc||(_0x31d8cc=Promise))(function(_0x5e6abe,_0x107cc6){function _0x36e2a5(_0x3f555d){try{_0x19688a(_0x39d164[a7_0x4b90('0x25')](_0x3f555d));}catch(_0x412320){_0x107cc6(_0x412320);}}function _0x5ee546(_0x463ca1){try{_0x19688a(_0x39d164['throw'](_0x463ca1));}catch(_0x572828){_0x107cc6(_0x572828);}}function _0x19688a(_0x4026b3){_0x4026b3[a7_0x4b90('0x1d')]?_0x5e6abe(_0x4026b3[a7_0x4b90('0x2e')]):_0x197760(_0x4026b3[a7_0x4b90('0x2e')])['then'](_0x36e2a5,_0x5ee546);}_0x19688a((_0x39d164=_0x39d164[a7_0x4b90('0x1b')](_0x1c1cd3,_0x40408a||[]))[a7_0x4b90('0x25')]());});};Object['defineProperty'](exports,a7_0x4b90('0x1c'),{'value':!![]});exports['executeTasks']=void 0x0;const create_unchanged_value_timeout_1=require(a7_0x4b90('0x2c'));const environment_1=require(a7_0x4b90('0x6'));const waiter_1=require(a7_0x4b90('0x12'));const {output}=require(a7_0x4b90('0x27'));function executeTasks(_0x1294ad,_0x54436d,_0x334fc9,_0x2f6c6b,_0x47abd5){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x26fbb8=0x0;let _0x107901=null;const _0x227b9a=(0x0,create_unchanged_value_timeout_1[a7_0x4b90('0xa')])({'title':a7_0x4b90('0x2d')+environment_1[a7_0x4b90('0x3')]/0x3e8+a7_0x4b90('0x11'),'timeout':environment_1[a7_0x4b90('0x3')]});const _0x6d1976=new waiter_1[(a7_0x4b90('0xb'))]();let _0x310918=[];const _0x4568bb=new Date();let _0x30832b=![];const _0x1b153c={};while(!![]){if(environment_1['VERBOSE_LOGGING']){output['note']({'title':_0x1294ad+a7_0x4b90('0x22')});}_0x107901=yield _0x54436d[a7_0x4b90('0x4')](_0x107901?_0x107901[a7_0x4b90('0x2a')]:null,_0x26fbb8,_0x310918,_0x47abd5);if(environment_1[a7_0x4b90('0x1a')]){output[a7_0x4b90('0x2')]({'title':_0x1294ad+'\x20received\x20an\x20API\x20Response','bodyLines':[a7_0x4b90('0x1e')+_0x107901['completed'],a7_0x4b90('0xf')+_0x107901[a7_0x4b90('0x16')],a7_0x4b90('0x1f')+_0x107901[a7_0x4b90('0x7')],'executionId:\x20'+_0x107901[a7_0x4b90('0x2a')],'number\x20of\x20tasks:\x20'+_0x107901[a7_0x4b90('0x4')]['length'],a7_0x4b90('0x29')+_0x107901[a7_0x4b90('0xe')],a7_0x4b90('0xc')+_0x107901[a7_0x4b90('0x15')]]});}if(_0x107901[a7_0x4b90('0xe')]){output[a7_0x4b90('0x19')]({'title':a7_0x4b90('0xd'),'bodyLines':[a7_0x4b90('0x26'),_0x107901[a7_0x4b90('0xe')]]});process[a7_0x4b90('0x9')](0x0);}if((_0x107901===null||_0x107901===void 0x0?void 0x0:_0x107901[a7_0x4b90('0x7')])&&(_0x107901===null||_0x107901===void 0x0?void 0x0:_0x107901[a7_0x4b90('0x7')])!==0x0&&!_0x30832b&&new Date()[a7_0x4b90('0x24')]()-_0x4568bb[a7_0x4b90('0x24')]()>_0x107901[a7_0x4b90('0x7')]){yield _0x6d1976[a7_0x4b90('0x18')]();continue;}if((_0x107901===null||_0x107901===void 0x0?void 0x0:_0x107901[a7_0x4b90('0x16')])!==undefined){if(_0x107901[a7_0x4b90('0x16')]===a7_0x4b90('0x13')||_0x107901[a7_0x4b90('0x16')]===a7_0x4b90('0x28')){return;}}else if(_0x107901['completed']){return;}_0x227b9a(_0x107901[a7_0x4b90('0x4')][a7_0x4b90('0x20')](_0x25e740=>_0x25e740['taskId'])[a7_0x4b90('0x17')](''));if(!_0x107901['executionId']){if(environment_1[a7_0x4b90('0x1a')]){output['note']({'title':_0x1294ad+a7_0x4b90('0x2b')});}yield _0x6d1976[a7_0x4b90('0x18')]();_0x26fbb8=0x0;_0x310918=[];continue;}_0x6d1976[a7_0x4b90('0x5')]();_0x30832b=!![];if(_0x107901['completedTasks']){for(const _0x3a4e31 of _0x107901[a7_0x4b90('0x14')]){if(_0x1b153c[_0x3a4e31[a7_0x4b90('0x10')]])continue;output[a7_0x4b90('0x2')]({'title':_0x1294ad+a7_0x4b90('0x2f')+_0x3a4e31[a7_0x4b90('0x10')]+'\x20Hash:\x20'+_0x3a4e31[a7_0x4b90('0x1')]+a7_0x4b90('0x0')+_0x3a4e31[a7_0x4b90('0x21')]});yield _0x334fc9[a7_0x4b90('0x8')](_0x3a4e31[a7_0x4b90('0x1')],_0x3a4e31[a7_0x4b90('0x21')]);_0x1b153c[_0x3a4e31[a7_0x4b90('0x10')]]=!![];}}const _0x69f4e7=yield _0x2f6c6b(_0x107901[a7_0x4b90('0x2a')],_0x107901[a7_0x4b90('0x4')],_0x107901[a7_0x4b90('0x15')]);for(const _0x3c4e5c of _0x69f4e7[a7_0x4b90('0x14')]){_0x1b153c[_0x3c4e5c[a7_0x4b90('0x10')]]=!![];}_0x26fbb8=_0x69f4e7['completedStatusCode'];_0x310918=_0x69f4e7[a7_0x4b90('0x14')];}});}exports['executeTasks']=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_0x49e0=['configuration','env','assign','__esModule','value','hash','__awaiter','params','invokeTasksUsingNxImperativeApi','true','defineProperty','projectName','map','yargs-parser','NX_STREAM_OUTPUT','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','values','next','taskId','invoke','length','throw','done','../../../utilities/serializer-overrides','NX_CACHE_FAILURES','../../../utilities/nx-imports','NX_PREFIX_OUTPUT','taskGraph','target','then','tasks','apply','status'];(function(_0x5704a9,_0x49e013){const _0x365b21=function(_0x234a3b){while(--_0x234a3b){_0x5704a9['push'](_0x5704a9['shift']());}};_0x365b21(++_0x49e013);}(a8_0x49e0,0x1d1));const a8_0x365b=function(_0x5704a9,_0x49e013){_0x5704a9=_0x5704a9-0x0;let _0x365b21=a8_0x49e0[_0x5704a9];return _0x365b21;};'use strict';var __awaiter=this&&this[a8_0x365b('0x3')]||function(_0x46ef87,_0x56ba52,_0x25512a,_0x1513a9){function _0x554414(_0x33163e){return _0x33163e instanceof _0x25512a?_0x33163e:new _0x25512a(function(_0x302fbf){_0x302fbf(_0x33163e);});}return new(_0x25512a||(_0x25512a=Promise))(function(_0x1d28ec,_0x5c5d19){function _0x1d9ae7(_0x5d1510){try{_0x153d70(_0x1513a9[a8_0x365b('0xe')](_0x5d1510));}catch(_0x2c665c){_0x5c5d19(_0x2c665c);}}function _0xd68c19(_0x414020){try{_0x153d70(_0x1513a9[a8_0x365b('0x12')](_0x414020));}catch(_0x4a4e89){_0x5c5d19(_0x4a4e89);}}function _0x153d70(_0x2eb1cb){_0x2eb1cb[a8_0x365b('0x13')]?_0x1d28ec(_0x2eb1cb[a8_0x365b('0x1')]):_0x554414(_0x2eb1cb[a8_0x365b('0x1')])[a8_0x365b('0x1a')](_0x1d9ae7,_0xd68c19);}_0x153d70((_0x1513a9=_0x1513a9[a8_0x365b('0x1c')](_0x46ef87,_0x56ba52||[]))[a8_0x365b('0xe')]());});};Object[a8_0x365b('0x7')](exports,a8_0x365b('0x0'),{'value':!![]});exports[a8_0x365b('0x5')]=void 0x0;const {initTasksRunner}=require(a8_0x365b('0x16'));const parser=require(a8_0x365b('0xa'));const serializer_overrides_1=require(a8_0x365b('0x14'));function invokeTasksUsingNxImperativeApi(_0x232fa0){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x16d224=yield initTasksRunner(_0x232fa0);return(_0x213704,_0x11a211,_0x5c7506)=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x3fd29a=_0x11a211['map'](_0x3ad380=>{const _0x12872f=parser(_0x3ad380[a8_0x365b('0x4')],{'configuration':{'camel-case-expansion':![],'dot-notation':!![]}});const _0x314b44=(0x0,serializer_overrides_1['unparse'])(_0x12872f);if(_0x12872f['_'][a8_0x365b('0x11')]==0x0){delete _0x12872f['_'];}return{'id':_0x3ad380[a8_0x365b('0xf')],'target':{'project':_0x3ad380[a8_0x365b('0x8')],'target':_0x3ad380[a8_0x365b('0x19')],'configuration':_0x3ad380[a8_0x365b('0x1e')]},'overrides':Object[a8_0x365b('0x20')](Object[a8_0x365b('0x20')]({},_0x12872f),{'__overrides_unparsed__':_0x314b44})};});process[a8_0x365b('0x1f')][a8_0x365b('0x15')]=a8_0x365b('0x6');process[a8_0x365b('0x1f')][a8_0x365b('0xc')]=_0x213704;process[a8_0x365b('0x1f')][a8_0x365b('0xb')]=a8_0x365b('0x6');process[a8_0x365b('0x1f')][a8_0x365b('0x17')]=a8_0x365b('0x6');const _0x1ab854=yield _0x16d224[a8_0x365b('0x10')]({'tasks':_0x3fd29a,'parallel':_0x5c7506});const _0x35e503=Object[a8_0x365b('0xd')](_0x1ab854[a8_0x365b('0x18')][a8_0x365b('0x1b')]);return{'completedTasks':_0x35e503[a8_0x365b('0x9')](_0x2f702=>({'taskId':_0x2f702['id'],'hash':_0x2f702[a8_0x365b('0x2')]})),'completedStatusCode':_0x1ab854[a8_0x365b('0x1d')]};});});}exports[a8_0x365b('0x5')]=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_0x27ff=['execSync','params','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','invokeTasksUsingRunMany','readFileSync','true','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','value','unlinkSync','ignore','assign','forEach','join','defineProperty','../../../utilities/nx-imports','\x20--parallel\x20--max-parallel=','__esModule','projectName','parse','throw','Executing:\x20\x27','child_process','note','target','configuration','--configuration=','next','length','\x20--projects=','apply','inherit','push'];(function(_0x312b69,_0x27ff16){const _0xe8e1be=function(_0x5121bf){while(--_0x5121bf){_0x312b69['push'](_0x312b69['shift']());}};_0xe8e1be(++_0x27ff16);}(a9_0x27ff,0x132));const a9_0xe8e1=function(_0x312b69,_0x27ff16){_0x312b69=_0x312b69-0x0;let _0xe8e1be=a9_0x27ff[_0x312b69];return _0xe8e1be;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x20ed86,_0x529145,_0x3f3754,_0xfc0775){function _0x5ad582(_0x33a5b1){return _0x33a5b1 instanceof _0x3f3754?_0x33a5b1:new _0x3f3754(function(_0xe48561){_0xe48561(_0x33a5b1);});}return new(_0x3f3754||(_0x3f3754=Promise))(function(_0x578660,_0x43c737){function _0x411965(_0x62c75e){try{_0x417890(_0xfc0775[a9_0xe8e1('0x8')](_0x62c75e));}catch(_0x4221ef){_0x43c737(_0x4221ef);}}function _0x11546c(_0x2e9997){try{_0x417890(_0xfc0775[a9_0xe8e1('0x1')](_0x2e9997));}catch(_0x649cc0){_0x43c737(_0x649cc0);}}function _0x417890(_0x10e18f){_0x10e18f['done']?_0x578660(_0x10e18f[a9_0xe8e1('0x15')]):_0x5ad582(_0x10e18f['value'])['then'](_0x411965,_0x11546c);}_0x417890((_0xfc0775=_0xfc0775[a9_0xe8e1('0xb')](_0x20ed86,_0x529145||[]))[a9_0xe8e1('0x8')]());});};Object[a9_0xe8e1('0x1b')](exports,a9_0xe8e1('0x1e'),{'value':!![]});exports[a9_0xe8e1('0x11')]=void 0x0;const environment_1=require('../../../utilities/environment');const child_process_1=require(a9_0xe8e1('0x3'));const fs_1=require('fs');const {output,cacheDirectory}=require(a9_0xe8e1('0x1c'));function invokeTasksUsingRunMany(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5a4ad2=completedTasksReader();return function _0x469da4(_0x2af3d0,_0x1e1016,_0x2d2c66){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x43f748=0x0;const _0x146d3b=[];for(const _0x5724ad of groupByTarget(_0x1e1016)){const _0x4d8b29=_0x5724ad[a9_0xe8e1('0x6')]?a9_0xe8e1('0x7')+_0x5724ad[a9_0xe8e1('0x6')]:'';const _0xa01928=_0x2d2c66>0x1?a9_0xe8e1('0x1d')+_0x2d2c66:'';const _0x47d2ec='npx\x20nx\x20run-many\x20--target='+_0x5724ad[a9_0xe8e1('0x5')]+'\x20'+_0x4d8b29+a9_0xe8e1('0xa')+_0x5724ad['projects'][a9_0xe8e1('0x1a')](',')+'\x20'+_0x5724ad[a9_0xe8e1('0xf')]+_0xa01928;if(environment_1['VERBOSE_LOGGING']){output[a9_0xe8e1('0x4')]({'title':a9_0xe8e1('0x2')+_0x47d2ec+'\x27'});}try{(0x0,child_process_1[a9_0xe8e1('0xe')])(_0x47d2ec,{'stdio':[a9_0xe8e1('0x17'),'inherit',a9_0xe8e1('0xc')],'env':Object[a9_0xe8e1('0x18')](Object[a9_0xe8e1('0x18')]({},process['env']),{'NX_CACHE_FAILURES':'true','NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x2af3d0,'NX_STREAM_OUTPUT':a9_0xe8e1('0x13'),'NX_PREFIX_OUTPUT':a9_0xe8e1('0x13')})});_0x146d3b['push'](..._0x5a4ad2(_0x2af3d0));}catch(_0x1998f6){if(_0x1998f6['status']===environment_1[a9_0xe8e1('0x10')]){throw _0x1998f6;}else{_0x43f748=0x1;_0x146d3b['push'](..._0x5a4ad2(_0x2af3d0));}}}return{'completedStatusCode':_0x43f748,'completedTasks':_0x146d3b};});};});}exports['invokeTasksUsingRunMany']=invokeTasksUsingRunMany;function groupByTarget(_0x3a4a3c){const _0x16a3bd=[];_0x3a4a3c[a9_0xe8e1('0x19')](_0x4a4811=>{const _0x1349b9=_0x16a3bd['find'](_0x108235=>_0x108235[a9_0xe8e1('0x5')]===_0x4a4811[a9_0xe8e1('0x5')]&&_0x108235[a9_0xe8e1('0x6')]===_0x4a4811['configuration']);if(_0x1349b9){_0x1349b9['projects'][a9_0xe8e1('0xd')](_0x4a4811[a9_0xe8e1('0x1f')]);}else{_0x16a3bd[a9_0xe8e1('0xd')]({'target':_0x4a4811[a9_0xe8e1('0x5')],'projects':[_0x4a4811[a9_0xe8e1('0x1f')]],'params':_0x4a4811[a9_0xe8e1('0xf')],'configuration':_0x4a4811[a9_0xe8e1('0x6')]});}});return _0x16a3bd;}function completedTasksReader(){return _0x31f55e=>{const _0x468d8d=a9_0xe8e1('0x14')+_0x31f55e+').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.';let _0x46279e;try{const _0x5eac7e=cacheDirectory+'/tasks-hashes-'+_0x31f55e;_0x46279e=JSON[a9_0xe8e1('0x0')]((0x0,fs_1[a9_0xe8e1('0x12')])(_0x5eac7e)['toString']());(0x0,fs_1[a9_0xe8e1('0x16')])(_0x5eac7e);}catch(_0x305b4f){throw new Error(_0x468d8d);}if(_0x46279e[a9_0xe8e1('0x9')]==0x0){throw new Error(_0x468d8d);}return _0x46279e;};}
"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_0x2566=['createApiAxiosInstance','project','response','../../../utilities/metric-logger','parseCommand','Completing\x20with\x20an\x20error','../../../utilities/axios','apply','serializeOverrides','Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.','__esModule','map','DistributedExecutionApi','../../../utilities/serializer-overrides','start','mapRespToPerfEntry','/nx-cloud/executions/complete-run-group','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','error:\x20','defineProperty','createStartRequest','done','ciExecutionId:\x20','false','createMetricRecorder','enabled','throw','note','apiAxiosInstance','../../../utilities/nx-imports','runGroup:\x20','parallel','VERBOSE_LOGGING','agentCount','stopAgentsOnFailure','dteStatus','maxParallel','ciExecutionEnv:\x20','error','message','data','then','status','value','post','recordMetric','axiosException','true','completeRunGroupWithError','__awaiter','RUNNER_FAILURE_PERF_ENTRY','NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE','../../../utilities/environment','completeRunGroup','axiosMultipleTries','exit','stringify','target'];(function(_0x33c801,_0x2566de){const _0xea0bd2=function(_0x261120){while(--_0x261120){_0x33c801['push'](_0x33c801['shift']());}};_0xea0bd2(++_0x2566de);}(a10_0x2566,0x13d));const a10_0xea0b=function(_0x33c801,_0x2566de){_0x33c801=_0x33c801-0x0;let _0xea0bd2=a10_0x2566[_0x33c801];return _0xea0bd2;};'use strict';var __awaiter=this&&this[a10_0xea0b('0x16')]||function(_0x2e0fb0,_0x5056ef,_0x128142,_0x411a1a){function _0x2827f0(_0x109753){return _0x109753 instanceof _0x128142?_0x109753:new _0x128142(function(_0x590468){_0x590468(_0x109753);});}return new(_0x128142||(_0x128142=Promise))(function(_0x4d7202,_0xc028f0){function _0x4b2908(_0x248b12){try{_0x31b8e4(_0x411a1a['next'](_0x248b12));}catch(_0x59f324){_0xc028f0(_0x59f324);}}function _0x8dc97e(_0xd19c89){try{_0x31b8e4(_0x411a1a[a10_0xea0b('0x39')](_0xd19c89));}catch(_0x1df652){_0xc028f0(_0x1df652);}}function _0x31b8e4(_0x486556){_0x486556[a10_0xea0b('0x34')]?_0x4d7202(_0x486556[a10_0xea0b('0x10')]):_0x2827f0(_0x486556[a10_0xea0b('0x10')])[a10_0xea0b('0xe')](_0x4b2908,_0x8dc97e);}_0x31b8e4((_0x411a1a=_0x411a1a[a10_0xea0b('0x26')](_0x2e0fb0,_0x5056ef||[]))['next']());});};Object[a10_0xea0b('0x32')](exports,a10_0xea0b('0x29'),{'value':!![]});exports[a10_0xea0b('0x33')]=exports[a10_0xea0b('0x2b')]=void 0x0;const axios_1=require(a10_0xea0b('0x25'));const environment_1=require(a10_0xea0b('0x19'));const metric_logger_1=require(a10_0xea0b('0x22'));const serializer_overrides_1=require(a10_0xea0b('0x2c'));const {output}=require(a10_0xea0b('0x2'));class DistributedExecutionApi{constructor(_0x14735c){this[a10_0xea0b('0x1')]=(0x0,axios_1[a10_0xea0b('0x1f')])(_0x14735c);}[a10_0xea0b('0x2d')](_0x5f3a6f){var _0x4f1dad;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x56b6c7=(0x0,metric_logger_1[a10_0xea0b('0x37')])('dteStart');let _0x128f49;if(environment_1[a10_0xea0b('0x5')]){output['note']({'title':'Starting\x20a\x20distributed\x20execution','bodyLines':[JSON[a10_0xea0b('0x1d')](_0x5f3a6f,null,0x2)]});}try{_0x128f49=yield(0x0,axios_1[a10_0xea0b('0x1b')])(()=>this[a10_0xea0b('0x1')][a10_0xea0b('0x11')]('/nx-cloud/executions/start',_0x5f3a6f));_0x56b6c7[a10_0xea0b('0x12')]((0x0,metric_logger_1[a10_0xea0b('0x2e')])(_0x128f49));}catch(_0x2b7f3b){_0x56b6c7[a10_0xea0b('0x12')](((_0x4f1dad=_0x2b7f3b===null||_0x2b7f3b===void 0x0?void 0x0:_0x2b7f3b[a10_0xea0b('0x13')])===null||_0x4f1dad===void 0x0?void 0x0:_0x4f1dad[a10_0xea0b('0x21')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x2b7f3b[a10_0xea0b('0x13')][a10_0xea0b('0x21')]):metric_logger_1[a10_0xea0b('0x17')]);throw _0x2b7f3b;}if(!_0x128f49['data'][a10_0xea0b('0x38')]){throw new Error(a10_0xea0b('0x28'));}if(_0x128f49[a10_0xea0b('0xd')]['error']){throw new Error(_0x128f49[a10_0xea0b('0xd')][a10_0xea0b('0xb')]);}return _0x128f49[a10_0xea0b('0xd')]['id'];});}[a10_0xea0b('0xf')](_0x3b89b6){var _0x32077a;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1490cf=(0x0,metric_logger_1[a10_0xea0b('0x37')])(a10_0xea0b('0x8'));try{const _0x39141f=yield(0x0,axios_1[a10_0xea0b('0x1b')])(()=>this['apiAxiosInstance']['post']('/nx-cloud/executions/status',{'id':_0x3b89b6}));_0x1490cf['recordMetric']((0x0,metric_logger_1[a10_0xea0b('0x2e')])(_0x39141f));return _0x39141f[a10_0xea0b('0xd')];}catch(_0x439c51){_0x1490cf[a10_0xea0b('0x12')](((_0x32077a=_0x439c51===null||_0x439c51===void 0x0?void 0x0:_0x439c51[a10_0xea0b('0x13')])===null||_0x32077a===void 0x0?void 0x0:_0x32077a['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x439c51[a10_0xea0b('0x13')][a10_0xea0b('0x21')]):metric_logger_1[a10_0xea0b('0x17')]);output['error']({'title':_0x439c51[a10_0xea0b('0xc')]});process[a10_0xea0b('0x1c')](0x1);}});}[a10_0xea0b('0x15')](_0x4f45ed,_0x2d7b7e,_0x46267c,_0x59fadf,_0x460e01){var _0x502069;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x195586=(0x0,metric_logger_1['createMetricRecorder'])(a10_0xea0b('0x1a'));if(environment_1['VERBOSE_LOGGING']){output[a10_0xea0b('0x0')]({'title':a10_0xea0b('0x24'),'bodyLines':[a10_0xea0b('0x35')+_0x46267c,a10_0xea0b('0xa')+_0x59fadf,a10_0xea0b('0x3')+_0x2d7b7e,a10_0xea0b('0x31')+_0x460e01]});}try{const _0x15e892=yield(0x0,axios_1[a10_0xea0b('0x1b')])(()=>this[a10_0xea0b('0x1')][a10_0xea0b('0x11')](a10_0xea0b('0x2f'),{'branch':_0x4f45ed,'runGroup':_0x2d7b7e,'ciExecutionId':_0x46267c,'ciExecutionEnv':_0x59fadf,'criticalErrorMessage':_0x460e01}),0x3);_0x195586[a10_0xea0b('0x12')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x15e892));}catch(_0x489efc){_0x195586['recordMetric'](((_0x502069=_0x489efc===null||_0x489efc===void 0x0?void 0x0:_0x489efc[a10_0xea0b('0x13')])===null||_0x502069===void 0x0?void 0x0:_0x502069[a10_0xea0b('0x21')])?(0x0,metric_logger_1[a10_0xea0b('0x2e')])(_0x489efc[a10_0xea0b('0x13')][a10_0xea0b('0x21')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);}});}}exports[a10_0xea0b('0x2b')]=DistributedExecutionApi;function createStartRequest(_0xb69a17,_0x481f1f,_0xc495fd,_0x5bd453,_0x5ab9d9,_0x5456c9,_0x3e4d85){const _0x3a5b70=_0x5ab9d9[a10_0xea0b('0x2a')](_0x3a9c4a=>{return _0x3a9c4a['map'](_0x62d6ce=>{return{'taskId':_0x62d6ce['id'],'hash':_0x62d6ce['hash'],'projectName':_0x62d6ce[a10_0xea0b('0x1e')][a10_0xea0b('0x20')],'target':_0x62d6ce[a10_0xea0b('0x1e')]['target'],'configuration':_0x62d6ce[a10_0xea0b('0x1e')]['configuration']||null,'params':(0x0,serializer_overrides_1[a10_0xea0b('0x27')])(_0x62d6ce)};});});const _0x2f1407={'command':(0x0,environment_1[a10_0xea0b('0x23')])(),'branch':_0xb69a17,'runGroup':_0x481f1f,'ciExecutionId':_0xc495fd,'ciExecutionEnv':_0x5bd453,'tasks':_0x3a5b70,'maxParallel':calculateMaxParallel(_0x5456c9),'commitSha':_0x3e4d85};if(environment_1[a10_0xea0b('0x30')]){_0x2f1407[a10_0xea0b('0x6')]=environment_1[a10_0xea0b('0x30')];}if(!environment_1[a10_0xea0b('0x18')]){_0x2f1407[a10_0xea0b('0x7')]=![];}return _0x2f1407;}exports[a10_0xea0b('0x33')]=createStartRequest;function calculateMaxParallel(_0x1893f7){if(_0x1893f7[a10_0xea0b('0x4')]===a10_0xea0b('0x36')||_0x1893f7[a10_0xea0b('0x4')]===![]){return 0x1;}else if(_0x1893f7[a10_0xea0b('0x4')]===a10_0xea0b('0x14')||_0x1893f7[a10_0xea0b('0x4')]===!![]){return Number(_0x1893f7['maxParallel']||0x3);}else if(_0x1893f7[a10_0xea0b('0x4')]===undefined){return _0x1893f7[a10_0xea0b('0x9')]?Number(_0x1893f7['maxParallel']):0x3;}else{return Number(_0x1893f7[a10_0xea0b('0x4')])||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_0x5bdc=['Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','endTasks','then','tasks','SIGINT','completeRunGroupWithError','next','See\x20run\x20details\x20at\x20','success','Main\x20job\x20was\x20terminated\x20via\x20SIGTERM','start','DTE\x20needs\x20the\x20cache\x20to\x20share\x20files\x20between\x20agents.','error','Unable\x20to\x20complete\x20a\x20run.','ErrorReporterApi','value','encryptionKey','apply','__esModule','Successfully\x20completed\x20running\x20the\x20command.','scheduleTask','__awaiter','commandStatus','nxCloudDistributedTasksRunner','skipNxCache','./distributed-execution.api','warn','message','log','--skip-nx-cache\x20is\x20ignored\x20when\x20using\x20distributed\x20tasks\x20execution\x20(DTE).','getCIExecutionId','createTaskGraphCompat','lifeCycle','taskGraph','axiosException','values','../../../utilities/metric-logger','ENCRYPTION_KEY','startTask','./split-task-graph-into-stages','note','./task-graph-creator','E2EEncryption','../../file-storage/e2e-encryption','./process-tasks','Command\x20execution\x20failed.','../../api/error-reporter.api','defineProperty','getRunGroup','../../error/print-run-group-error','DteArtifactStorage','../../../utilities/environment','done','exit','throw','../../../utilities/nx-imports','projectGraph','VERBOSE_LOGGING','splitTasksIntoStages','processTasks','getBranch','printRunGroupError','runUrl','extractGitRef','extractGitSha','SIGTERM'];(function(_0x578b42,_0x5bdce8){const _0x2dc90c=function(_0xc8d9ff){while(--_0xc8d9ff){_0x578b42['push'](_0x578b42['shift']());}};_0x2dc90c(++_0x5bdce8);}(a11_0x5bdc,0x1d4));const a11_0x2dc9=function(_0x578b42,_0x5bdce8){_0x578b42=_0x578b42-0x0;let _0x2dc90c=a11_0x5bdc[_0x578b42];return _0x2dc90c;};'use strict';var __awaiter=this&&this[a11_0x2dc9('0xf')]||function(_0x527abd,_0x534794,_0x4dcb1e,_0x1fcbbd){function _0x11330b(_0x2f02cf){return _0x2f02cf instanceof _0x4dcb1e?_0x2f02cf:new _0x4dcb1e(function(_0x1f99c6){_0x1f99c6(_0x2f02cf);});}return new(_0x4dcb1e||(_0x4dcb1e=Promise))(function(_0x3e7046,_0xce139a){function _0xa250dc(_0x32d926){try{_0x81a85(_0x1fcbbd[a11_0x2dc9('0x0')](_0x32d926));}catch(_0x1c53bd){_0xce139a(_0x1c53bd);}}function _0xa4c67d(_0x16eac1){try{_0x81a85(_0x1fcbbd[a11_0x2dc9('0x30')](_0x16eac1));}catch(_0x114777){_0xce139a(_0x114777);}}function _0x81a85(_0x29b42f){_0x29b42f[a11_0x2dc9('0x2e')]?_0x3e7046(_0x29b42f[a11_0x2dc9('0x9')]):_0x11330b(_0x29b42f[a11_0x2dc9('0x9')])[a11_0x2dc9('0x3e')](_0xa250dc,_0xa4c67d);}_0x81a85((_0x1fcbbd=_0x1fcbbd[a11_0x2dc9('0xb')](_0x527abd,_0x534794||[]))['next']());});};Object[a11_0x2dc9('0x29')](exports,a11_0x2dc9('0xc'),{'value':!![]});exports[a11_0x2dc9('0x11')]=void 0x0;const environment_1=require(a11_0x2dc9('0x2d'));const metric_logger_1=require(a11_0x2dc9('0x1e'));const error_reporter_api_1=require(a11_0x2dc9('0x28'));const print_run_group_error_1=require(a11_0x2dc9('0x2b'));const e2e_encryption_1=require(a11_0x2dc9('0x25'));const file_storage_1=require('../../file-storage/file-storage');const distributed_execution_api_1=require(a11_0x2dc9('0x13'));const split_task_graph_into_stages_1=require(a11_0x2dc9('0x21'));const task_graph_creator_1=require(a11_0x2dc9('0x23'));const process_tasks_1=require(a11_0x2dc9('0x26'));const dte_artifact_storage_1=require('../../../utilities/dte-artifact-storage');const {output,cacheDirectory}=require(a11_0x2dc9('0x31'));class NoopLifeCycle{[a11_0x2dc9('0xe')](_0x241e8c){}[a11_0x2dc9('0x20')](_0x2c6f80){}[a11_0x2dc9('0x3d')](_0x5d9adb){}}const nxCloudDistributedTasksRunner=(_0x49c766,_0x301dd1,_0x180bdf)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(_0x301dd1[a11_0x2dc9('0x12')]){output[a11_0x2dc9('0x14')]({'title':a11_0x2dc9('0x17'),'bodyLine':[a11_0x2dc9('0x5')]});}if(environment_1[a11_0x2dc9('0x33')]){output[a11_0x2dc9('0x22')]({'title':'Starting\x20distributed\x20command\x20execution'});}_0x301dd1[a11_0x2dc9('0x1a')]=new NoopLifeCycle();const _0x49a7cd=(0x0,environment_1[a11_0x2dc9('0x36')])();const _0x17330f=(0x0,environment_1[a11_0x2dc9('0x2a')])();const _0xc22899=(0x0,environment_1[a11_0x2dc9('0x18')])();const _0x2b0a2f=(0x0,environment_1['getCIExecutionEnv'])();const _0x4eb2f8=(0x0,environment_1[a11_0x2dc9('0x3a')])();const _0x20783e=(0x0,environment_1[a11_0x2dc9('0x39')])();if(!(0x0,print_run_group_error_1['canDetectRunGroup'])(_0x17330f,_0xc22899)){(0x0,print_run_group_error_1[a11_0x2dc9('0x37')])();process['exit'](0x1);}const _0x525d62=new e2e_encryption_1[(a11_0x2dc9('0x24'))](environment_1[a11_0x2dc9('0x1f')]||_0x301dd1[a11_0x2dc9('0xa')]);const _0x31aaaa=new error_reporter_api_1[(a11_0x2dc9('0x8'))](_0x301dd1);const _0x47aa19=new dte_artifact_storage_1[(a11_0x2dc9('0x2c'))](new file_storage_1['FileStorage'](_0x525d62,_0x31aaaa,_0x301dd1,'dte-main'),cacheDirectory);const _0x4e2661=new distributed_execution_api_1['DistributedExecutionApi'](_0x301dd1);attachSignalListenersToCompleteRunGroupOnError(_0x4e2661,_0x49a7cd,_0x17330f,_0xc22899,_0x2b0a2f);try{const _0x3ad13d=getTaskGraph(_0x180bdf,_0x49c766,_0x301dd1);const _0x5cf75f=yield runDistributedExecution(_0x4e2661,_0x301dd1,_0x47aa19,_0x49a7cd,_0x17330f,_0xc22899,_0x2b0a2f,_0x3ad13d,_0x4eb2f8,_0x20783e);if(_0x5cf75f[a11_0x2dc9('0x10')]===0x0){output[a11_0x2dc9('0x2')]({'title':a11_0x2dc9('0xd'),'bodyLines':[a11_0x2dc9('0x1')+_0x5cf75f[a11_0x2dc9('0x38')]]});}else{output[a11_0x2dc9('0x6')]({'title':a11_0x2dc9('0x27'),'bodyLines':['See\x20run\x20details\x20at\x20'+_0x5cf75f[a11_0x2dc9('0x38')]]});}yield(0x0,metric_logger_1['submitRunMetrics'])(_0x301dd1);process[a11_0x2dc9('0x2f')](_0x5cf75f[a11_0x2dc9('0x10')]);}catch(_0x3430e8){output[a11_0x2dc9('0x6')]({'title':a11_0x2dc9('0x7'),'bodyLines':[_0x3430e8[a11_0x2dc9('0x15')]]});if(_0x3430e8[a11_0x2dc9('0x1c')]){console['log'](_0x3430e8[a11_0x2dc9('0x1c')]);}else{console[a11_0x2dc9('0x16')](_0x3430e8);}try{yield _0x4e2661[a11_0x2dc9('0x41')](_0x49a7cd,_0x17330f,_0xc22899,_0x2b0a2f,a11_0x2dc9('0x3c')+_0x3430e8[a11_0x2dc9('0x15')]+'\x22');}finally{process['exit'](0x1);}}});exports[a11_0x2dc9('0x11')]=nxCloudDistributedTasksRunner;function getTaskGraph(_0x2104bb,_0x45566a,_0x43dce4){if(_0x2104bb[a11_0x2dc9('0x1b')]){return _0x2104bb['taskGraph'];}else{return(0x0,task_graph_creator_1[a11_0x2dc9('0x19')])(_0x43dce4,_0x2104bb[a11_0x2dc9('0x32')],_0x45566a);}}function attachSignalListenersToCompleteRunGroupOnError(_0x5534ed,_0x981231,_0x1385b1,_0x246456,_0xcb9cd2){process['on'](a11_0x2dc9('0x40'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x5534ed['completeRunGroupWithError'](_0x981231,_0x1385b1,_0x246456,_0xcb9cd2,'Main\x20job\x20was\x20terminated\x20via\x20SIGINT');process[a11_0x2dc9('0x2f')](0x1);}));process['on'](a11_0x2dc9('0x3b'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x5534ed[a11_0x2dc9('0x41')](_0x981231,_0x1385b1,_0x246456,_0xcb9cd2,a11_0x2dc9('0x3'));process['exit'](0x1);}));}function runDistributedExecution(_0x1516b2,_0x509a87,_0x1b7630,_0x372186,_0x23df7b,_0x34ecda,_0x32fd45,_0x29c305,_0x362cea,_0xd76541){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5d31a6=yield _0x1516b2[a11_0x2dc9('0x4')]((0x0,distributed_execution_api_1['createStartRequest'])(_0x372186,_0x23df7b,_0x34ecda,_0x32fd45,(0x0,split_task_graph_into_stages_1[a11_0x2dc9('0x34')])(_0x29c305),_0x509a87,_0x362cea));return yield(0x0,process_tasks_1[a11_0x2dc9('0x35')])(_0x1516b2,_0x1b7630,_0x5d31a6,Object[a11_0x2dc9('0x1d')](_0x29c305[a11_0x2dc9('0x3f')]));});}
"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_0x5892=['value','find','then','VERBOSE_LOGGING','note','defineProperty','configuration','hash','write','../../../utilities/serializer-overrides','serializeOverrides','url','target','Processing\x20task\x20','apply','processTask','../../../utilities/nx-imports','__awaiter','logCommand','../../../utilities/environment','taskId','next','addVerticalSeparator','run','Found\x20unknown\x20task:\x20','done','__esModule'];(function(_0x567878,_0x58927b){const _0x1fd419=function(_0x2654f2){while(--_0x2654f2){_0x567878['push'](_0x567878['shift']());}};_0x1fd419(++_0x58927b);}(a12_0x5892,0x1cf));const a12_0x1fd4=function(_0x567878,_0x58927b){_0x567878=_0x567878-0x0;let _0x1fd419=a12_0x5892[_0x567878];return _0x1fd419;};'use strict';var __awaiter=this&&this[a12_0x1fd4('0xd')]||function(_0x4543ca,_0xee94de,_0x8ee8c9,_0x421271){function _0x523efe(_0x43867d){return _0x43867d instanceof _0x8ee8c9?_0x43867d:new _0x8ee8c9(function(_0x3767c0){_0x3767c0(_0x43867d);});}return new(_0x8ee8c9||(_0x8ee8c9=Promise))(function(_0x1225df,_0x881d3b){function _0x5a5dbe(_0x2d5cb3){try{_0x2c9f91(_0x421271[a12_0x1fd4('0x11')](_0x2d5cb3));}catch(_0x89521a){_0x881d3b(_0x89521a);}}function _0x27ab8b(_0x47db10){try{_0x2c9f91(_0x421271['throw'](_0x47db10));}catch(_0x32c142){_0x881d3b(_0x32c142);}}function _0x2c9f91(_0x1762e5){_0x1762e5[a12_0x1fd4('0x15')]?_0x1225df(_0x1762e5[a12_0x1fd4('0x17')]):_0x523efe(_0x1762e5[a12_0x1fd4('0x17')])[a12_0x1fd4('0x19')](_0x5a5dbe,_0x27ab8b);}_0x2c9f91((_0x421271=_0x421271[a12_0x1fd4('0xa')](_0x4543ca,_0xee94de||[]))[a12_0x1fd4('0x11')]());});};Object[a12_0x1fd4('0x1')](exports,a12_0x1fd4('0x16'),{'value':!![]});exports['processTask']=void 0x0;const environment_1=require(a12_0x1fd4('0xf'));const serializer_overrides_1=require(a12_0x1fd4('0x5'));const {output}=require(a12_0x1fd4('0xc'));function processTask(_0x16d4ba,_0x353f10,_0x234c9){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a12_0x1fd4('0x1a')]){output[a12_0x1fd4('0x0')]({'title':a12_0x1fd4('0x9')+_0x234c9['taskId']});}const _0x5cb885=_0x353f10[a12_0x1fd4('0x18')](_0x5322ff=>_0x234c9[a12_0x1fd4('0x10')]===_0x5322ff['id']);if(!_0x5cb885){throw new Error(a12_0x1fd4('0x14')+_0x234c9[a12_0x1fd4('0x10')]);}const _0x16409a=yield _0x16d4ba['retrieveAndExtract'](_0x234c9[a12_0x1fd4('0x3')],_0x234c9[a12_0x1fd4('0x7')]);output[a12_0x1fd4('0xe')](getCommand(_0x5cb885));process['stdout'][a12_0x1fd4('0x4')](_0x16409a);output[a12_0x1fd4('0x12')]();});}exports[a12_0x1fd4('0xb')]=processTask;function getCommand(_0x2f97e5){const _0xb94694=_0x2f97e5['target'][a12_0x1fd4('0x2')]?':'+_0x2f97e5['target'][a12_0x1fd4('0x2')]:'';return['nx',a12_0x1fd4('0x13'),_0x2f97e5['target']['project']+':'+_0x2f97e5['target'][a12_0x1fd4('0x8')]+_0xb94694,(0x0,serializer_overrides_1[a12_0x1fd4('0x6')])(_0x2f97e5)]['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_0x2ddd=['value','../../../utilities/environment','../../../utilities/create-unchanged-value-timeout','done','__esModule','then','executionId:\x20','note','executionStatus','processTask','./process-task','length','NO_COMPLETED_TASKS_TIMEOUT','error','VERBOSE_LOGGING','throw','criticalErrorMessage','Distributed\x20Execution\x20Terminated','completedTasks','error:\x20','apply','Waiter','defineProperty','../../../utilities/nx-imports','Waiting...','status','runUrl','wait','No\x20new\x20completed\x20tasks\x20after\x20','processTasks','taskId','next','../../../utilities/waiter','createUnchangedValueTimeout','reset','Status\x20update','COMPLETED','executionStatus:\x20'];(function(_0x34eb68,_0x2ddd94){const _0x4b45dd=function(_0x4a6b7b){while(--_0x4a6b7b){_0x34eb68['push'](_0x34eb68['shift']());}};_0x4b45dd(++_0x2ddd94);}(a13_0x2ddd,0x142));const a13_0x4b45=function(_0x34eb68,_0x2ddd94){_0x34eb68=_0x34eb68-0x0;let _0x4b45dd=a13_0x2ddd[_0x34eb68];return _0x4b45dd;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x576e0a,_0x576000,_0x93b81,_0xc68ff){function _0x2c06fc(_0x31530d){return _0x31530d instanceof _0x93b81?_0x31530d:new _0x93b81(function(_0x1e1dad){_0x1e1dad(_0x31530d);});}return new(_0x93b81||(_0x93b81=Promise))(function(_0x5d0b28,_0x1867f6){function _0x516597(_0x47adbd){try{_0x6098b8(_0xc68ff['next'](_0x47adbd));}catch(_0x582744){_0x1867f6(_0x582744);}}function _0x27a1bd(_0x4d30cd){try{_0x6098b8(_0xc68ff[a13_0x4b45('0x23')](_0x4d30cd));}catch(_0x1c8584){_0x1867f6(_0x1c8584);}}function _0x6098b8(_0x38fb6e){_0x38fb6e[a13_0x4b45('0x17')]?_0x5d0b28(_0x38fb6e[a13_0x4b45('0x14')]):_0x2c06fc(_0x38fb6e['value'])[a13_0x4b45('0x19')](_0x516597,_0x27a1bd);}_0x6098b8((_0xc68ff=_0xc68ff[a13_0x4b45('0x2')](_0x576e0a,_0x576000||[]))[a13_0x4b45('0xd')]());});};Object[a13_0x4b45('0x4')](exports,a13_0x4b45('0x18'),{'value':!![]});exports[a13_0x4b45('0xb')]=void 0x0;const create_unchanged_value_timeout_1=require(a13_0x4b45('0x16'));const environment_1=require(a13_0x4b45('0x15'));const waiter_1=require(a13_0x4b45('0xe'));const process_task_1=require(a13_0x4b45('0x1e'));const {output}=require(a13_0x4b45('0x5'));function processTasks(_0x21a299,_0xf4c8e5,_0x51a2cf,_0x501678){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4af1d0={};const _0x262cc6=(0x0,create_unchanged_value_timeout_1[a13_0x4b45('0xf')])({'title':a13_0x4b45('0xa')+environment_1[a13_0x4b45('0x20')]/0x3e8+'\x20seconds.','timeout':environment_1[a13_0x4b45('0x20')]});const _0x176997=new waiter_1[(a13_0x4b45('0x3'))]();while(!![]){if(environment_1[a13_0x4b45('0x22')]){output[a13_0x4b45('0x1b')]({'title':a13_0x4b45('0x6')});}yield _0x176997[a13_0x4b45('0x9')]();const _0x469889=yield _0x21a299[a13_0x4b45('0x7')](_0x51a2cf);if(environment_1[a13_0x4b45('0x22')]){output[a13_0x4b45('0x1b')]({'title':a13_0x4b45('0x11'),'bodyLines':[a13_0x4b45('0x1a')+_0x51a2cf,a13_0x4b45('0x13')+_0x469889['executionStatus'],'number\x20of\x20completed\x20tasks:\x20'+_0x469889[a13_0x4b45('0x0')][a13_0x4b45('0x1f')],a13_0x4b45('0x1')+_0x469889[a13_0x4b45('0x24')]]});}if(_0x469889[a13_0x4b45('0x24')]){output[a13_0x4b45('0x21')]({'title':a13_0x4b45('0x25'),'bodyLines':['Error:',_0x469889[a13_0x4b45('0x24')]]});process['exit'](0x1);}_0x262cc6(_0x469889[a13_0x4b45('0x0')]['length']);for(const _0x33b8ab of _0x469889[a13_0x4b45('0x0')]){if(_0x4af1d0[_0x33b8ab['taskId']])continue;yield(0x0,process_task_1[a13_0x4b45('0x1d')])(_0xf4c8e5,_0x501678,_0x33b8ab);_0x176997[a13_0x4b45('0x10')]();_0x4af1d0[_0x33b8ab[a13_0x4b45('0xc')]]=!![];}if(_0x469889[a13_0x4b45('0x1c')]===a13_0x4b45('0x12')){return{'commandStatus':_0x469889['commandStatus'],'runUrl':_0x469889[a13_0x4b45('0x8')]};}}});}exports['processTasks']=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_0x162c=['values','delete','tasks','splitTasksIntoStages','size','push','defineProperty'];(function(_0x130838,_0x162ca1){const _0x39ca39=function(_0x324f4c){while(--_0x324f4c){_0x130838['push'](_0x130838['shift']());}};_0x39ca39(++_0x162ca1);}(a14_0x162c,0xb3));const a14_0x39ca=function(_0x130838,_0x162ca1){_0x130838=_0x130838-0x0;let _0x39ca39=a14_0x162c[_0x130838];return _0x39ca39;};'use strict';Object[a14_0x39ca('0x2')](exports,'__esModule',{'value':!![]});exports[a14_0x39ca('0x6')]=void 0x0;function splitTasksIntoStages(_0x16f2ca){const _0x1f252a=[];const _0x455b65=new Set(Object[a14_0x39ca('0x3')](_0x16f2ca[a14_0x39ca('0x5')])['map'](_0x4dd1ac=>_0x4dd1ac['id']));let _0x40d98d=0x0;while(_0x455b65[a14_0x39ca('0x0')]>0x0){const _0x4e163c=_0x1f252a[_0x40d98d]=[];for(const _0x27cf83 of _0x455b65){let _0x5a60b1=!![];for(const _0x44b159 of _0x16f2ca['dependencies'][_0x27cf83]){if(_0x455b65['has'](_0x44b159)){_0x5a60b1=![];break;}}if(!_0x5a60b1){continue;}const _0x1219dc=_0x16f2ca[a14_0x39ca('0x5')][_0x27cf83];_0x4e163c[a14_0x39ca('0x1')](_0x1219dc);}for(const _0x2e9d7b of _0x4e163c){_0x455b65[a14_0x39ca('0x4')](_0x2e9d7b['id']);}_0x40d98d++;}return _0x1f252a;}exports['splitTasksIntoStages']=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_0x39f8=['strictlyOrderedTargets','parse','readFileSync','projectGraph','toString','addDependencies','projects','__esModule','target','../../../utilities/nx-imports','keys','defaultTargetDependencies','createTaskGraphCompat','dependencies','/nx.json','find','targetDependencies','self','push','roots','has','addTaskDependencies','addTaskToGraph','project','TaskGraphCreator','createTaskGraph','length','build','tasks'];(function(_0x35a1d5,_0x39f8b4){const _0x3bd608=function(_0x57111f){while(--_0x57111f){_0x35a1d5['push'](_0x35a1d5['shift']());}};_0x3bd608(++_0x39f8b4);}(a15_0x39f8,0x145));const a15_0x3bd6=function(_0x35a1d5,_0x39f8b4){_0x35a1d5=_0x35a1d5-0x0;let _0x3bd608=a15_0x39f8[_0x35a1d5];return _0x3bd608;};'use strict';Object['defineProperty'](exports,a15_0x3bd6('0x1'),{'value':!![]});exports[a15_0x3bd6('0x12')]=exports[a15_0x3bd6('0x6')]=void 0x0;const stripJsonComments=require('strip-json-comments');const fs_1=require('fs');const {getDependencyConfigs,workspaceRoot}=require(a15_0x3bd6('0x3'));function createTaskGraphCompat(_0x25be70,_0x39cd8f,_0x522c81){const _0xeddcb0=JSON[a15_0x3bd6('0x18')](stripJsonComments((0x0,fs_1[a15_0x3bd6('0x19')])(workspaceRoot+a15_0x3bd6('0x8'))[a15_0x3bd6('0x1b')]()));return new TaskGraphCreator(_0x39cd8f,getDefaultDependencyConfigs(_0xeddcb0,_0x25be70))[a15_0x3bd6('0x13')](_0x522c81);}exports[a15_0x3bd6('0x6')]=createTaskGraphCompat;function getDefaultDependencyConfigs(_0xef3781,_0x4695d9){var _0xbdd965,_0x13e4a6;const _0x24f77d=(_0xbdd965=_0xef3781[a15_0x3bd6('0xa')])!==null&&_0xbdd965!==void 0x0?_0xbdd965:{};const _0x4f7cfb=_0x4695d9?(_0x13e4a6=_0x4695d9[a15_0x3bd6('0x17')])!==null&&_0x13e4a6!==void 0x0?_0x13e4a6:[a15_0x3bd6('0x15')]:[];for(const _0x8ee0d of _0x4f7cfb){_0x24f77d[_0x8ee0d]=_0x24f77d[_0x8ee0d]||[];_0x24f77d[_0x8ee0d][a15_0x3bd6('0xc')]({'target':_0x8ee0d,'projects':a15_0x3bd6('0x7')});}return _0x24f77d;}class TaskGraphCreator{constructor(_0x136d0c,_0x3caedb){this[a15_0x3bd6('0x1a')]=_0x136d0c;this[a15_0x3bd6('0x5')]=_0x3caedb;}['createTaskGraph'](_0x575702){const _0x26efa3={'roots':[],'tasks':{},'dependencies':{}};for(const _0x1c6f68 of _0x575702){this[a15_0x3bd6('0x10')](_0x1c6f68,_0x26efa3);const _0x306510=getDependencyConfigs(_0x1c6f68[a15_0x3bd6('0x2')],this['defaultTargetDependencies'],this[a15_0x3bd6('0x1a')]);if(!_0x306510){continue;}this[a15_0x3bd6('0xf')](_0x1c6f68,_0x306510,_0x575702,_0x26efa3);}_0x26efa3[a15_0x3bd6('0xd')]=Object[a15_0x3bd6('0x4')](_0x26efa3['dependencies'])['filter'](_0x196b32=>_0x26efa3[a15_0x3bd6('0x7')][_0x196b32][a15_0x3bd6('0x14')]===0x0);return _0x26efa3;}[a15_0x3bd6('0xf')](_0x76088b,_0x16c2cd,_0x4b9536,_0xc982e){for(const _0x11a542 of _0x16c2cd){if(_0x11a542[a15_0x3bd6('0x0')]===a15_0x3bd6('0xb')){for(const _0x4c824b of _0x4b9536){if(_0x4c824b[a15_0x3bd6('0x2')][a15_0x3bd6('0x11')]===_0x76088b['target'][a15_0x3bd6('0x11')]&&_0x4c824b[a15_0x3bd6('0x2')]['target']===_0x11a542['target']){_0xc982e[a15_0x3bd6('0x7')][_0x76088b['id']][a15_0x3bd6('0xc')](_0x4c824b['id']);}}}else if(_0x11a542[a15_0x3bd6('0x0')]===a15_0x3bd6('0x7')){const _0xa05e68=new Set();this[a15_0x3bd6('0x1c')](_0x76088b[a15_0x3bd6('0x2')][a15_0x3bd6('0x11')],_0x11a542[a15_0x3bd6('0x2')],_0x4b9536,_0xc982e,_0x76088b['id'],_0xa05e68);}}}[a15_0x3bd6('0x1c')](_0x2eed42,_0x2a15a5,_0x338453,_0x1c325f,_0x32ee1c,_0x198f0c){_0x198f0c['add'](_0x2eed42);const _0x23f48c=this[a15_0x3bd6('0x1a')][a15_0x3bd6('0x7')][_0x2eed42];if(_0x23f48c){const _0x4c5689=_0x23f48c['map'](_0x55017f=>_0x55017f[a15_0x3bd6('0x2')]);for(const _0x1f5a93 of _0x4c5689){if(_0x198f0c[a15_0x3bd6('0xe')](_0x1f5a93)){continue;}const _0xd484e0=this['findTask']({'project':_0x1f5a93,'target':_0x2a15a5},_0x338453);if(_0xd484e0){if(_0x1c325f[a15_0x3bd6('0x7')][_0x32ee1c]['indexOf'](_0xd484e0['id'])===-0x1){_0x1c325f['dependencies'][_0x32ee1c]['push'](_0xd484e0['id']);}}else{this[a15_0x3bd6('0x1c')](_0x1f5a93,_0x2a15a5,_0x338453,_0x1c325f,_0x32ee1c,_0x198f0c);}}}}['findTask']({project,target},_0x4f06fb){return _0x4f06fb[a15_0x3bd6('0x9')](_0x4e173b=>_0x4e173b['target'][a15_0x3bd6('0x11')]===project&&_0x4e173b[a15_0x3bd6('0x2')][a15_0x3bd6('0x2')]===target);}['addTaskToGraph'](_0x4165a5,_0xe5fb5f){_0xe5fb5f[a15_0x3bd6('0x16')][_0x4165a5['id']]=_0x4165a5;_0xe5fb5f[a15_0x3bd6('0x7')][_0x4165a5['id']]=[];}}exports['TaskGraphCreator']=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

@@ -27,3 +27,3 @@ "use strict";

const runContext = {};
const machineInfo = (0, environment_1.getMachineInfo)(data.runnerOptions);
const machineInfo = (0, environment_1.getMachineInfo)();
const api = new cloud_run_api_1.CloudRunApi(reporter, runContext, data.runnerOptions, machineInfo);

@@ -30,0 +30,0 @@ setTimeout(() => __awaiter(this, void 0, void 0, function* () {

@@ -1,2 +0,1 @@

import { CloudTaskRunnerOptions } from '../core/models/cloud-task-runner-options';
import { MachineInfo } from '../core/models/machine-info.model';

@@ -27,3 +26,3 @@ export declare const UNLIMITED_TIMEOUT = 9999999;

export declare function getBranch(): string | null;
export declare function getMachineInfo(options: CloudTaskRunnerOptions): MachineInfo;
export declare function getMachineInfo(): MachineInfo;
export declare function parseCommand(): string;

@@ -7,5 +7,7 @@ "use strict";

const fs_1 = require("fs");
const node_machine_id_1 = require("node-machine-id");
const path_1 = require("path");
const is_ci_1 = require("./is-ci");
const is_private_cloud_1 = require("./is-private-cloud");
const crypto_1 = require("crypto");
const { workspaceRoot } = require('./nx-imports');

@@ -214,6 +216,9 @@ // Set once

exports.getBranch = getBranch;
function getMachineInfo(options) {
function getMachineInfo() {
const os = require('os');
const hasher = (0, crypto_1.createHash)('md5');
hasher.update((0, node_machine_id_1.machineIdSync)());
const machineId = hasher.digest('base64');
return {
machineId: '',
machineId,
platform: os.platform(),

@@ -220,0 +225,0 @@ version: os.version ? os.version() : '',

{
"name": "nx-cloud",
"version": "16.1.1",
"version": "16.2.0-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.1"
"@nrwl/nx-cloud": "16.2.0-beta.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc