Socket
Socket
Sign inDemoInstall

nx-cloud

Package Overview
Dependencies
Maintainers
2
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nx-cloud - npm Package Compare versions

Comparing version 16.0.5 to 16.1.0-beta.1

37

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

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

const a0_0x3476=['Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','value','/nx-cloud/report-client-error','throw','apiAxiosInstance','__esModule','ErrorReporterApi','next','../../utilities/axios','warn','../../utilities/nx-imports','reportError','message','defineProperty','axiosMultipleTries','then','__awaiter','createApiAxiosInstance'];(function(_0x4b3a55,_0x347617){const _0x130550=function(_0x37216b){while(--_0x37216b){_0x4b3a55['push'](_0x4b3a55['shift']());}};_0x130550(++_0x347617);}(a0_0x3476,0x1a0));const a0_0x1305=function(_0x4b3a55,_0x347617){_0x4b3a55=_0x4b3a55-0x0;let _0x130550=a0_0x3476[_0x4b3a55];return _0x130550;};'use strict';var __awaiter=this&&this[a0_0x1305('0xe')]||function(_0x89c7bd,_0x4d2bda,_0x39facc,_0x5d389b){function _0x516734(_0x52e499){return _0x52e499 instanceof _0x39facc?_0x52e499:new _0x39facc(function(_0x852dea){_0x852dea(_0x52e499);});}return new(_0x39facc||(_0x39facc=Promise))(function(_0x2524b9,_0x20a536){function _0x27b374(_0x33251f){try{_0x15de48(_0x5d389b[a0_0x1305('0x5')](_0x33251f));}catch(_0x14b6f7){_0x20a536(_0x14b6f7);}}function _0x4f75c0(_0x477191){try{_0x15de48(_0x5d389b[a0_0x1305('0x1')](_0x477191));}catch(_0x53fd94){_0x20a536(_0x53fd94);}}function _0x15de48(_0x333188){_0x333188['done']?_0x2524b9(_0x333188[a0_0x1305('0x11')]):_0x516734(_0x333188[a0_0x1305('0x11')])[a0_0x1305('0xd')](_0x27b374,_0x4f75c0);}_0x15de48((_0x5d389b=_0x5d389b['apply'](_0x89c7bd,_0x4d2bda||[]))['next']());});};Object[a0_0x1305('0xb')](exports,a0_0x1305('0x3'),{'value':!![]});exports[a0_0x1305('0x4')]=void 0x0;const axios_1=require(a0_0x1305('0x6'));const {output}=require(a0_0x1305('0x8'));class ErrorReporterApi{constructor(_0x5338b9){this[a0_0x1305('0x2')]=(0x0,axios_1[a0_0x1305('0xf')])(_0x5338b9);}[a0_0x1305('0x9')](_0x3db839){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x1305('0xc')])(()=>this[a0_0x1305('0x2')]['post'](a0_0x1305('0x0'),{'message':_0x3db839}));}catch(_0xdd5b6d){output[a0_0x1305('0x7')]({'title':a0_0x1305('0x10')+_0x3db839+'\x27','bodyLines':[_0xdd5b6d[a0_0x1305('0xa')]]});}});}}exports['ErrorReporterApi']=ErrorReporterApi;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorReporterApi = void 0;
const axios_1 = require("../../utilities/axios");
const { output } = require('../../utilities/nx-imports');
class ErrorReporterApi {
constructor(options) {
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
reportError(message) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', {
message,
}));
}
catch (e) {
output.warn({
title: `Unable to record the following error: '${message}'`,
bodyLines: [e.message],
});
}
});
}
}
exports.ErrorReporterApi = ErrorReporterApi;
//# sourceMappingURL=error-reporter.api.js.map

2

lib/core/api/run-group.api.d.ts

@@ -5,4 +5,4 @@ import { CloudTaskRunnerOptions } from '../models/cloud-task-runner-options';

constructor(options: CloudTaskRunnerOptions);
createRunGroup(branch: string | null, runGroup: string, ciExecutionId: string | null, ciExecutionEnv: string, stopAgentsOnFailure?: boolean, agentCount?: number, stopAgentsAfter?: string): Promise<void>;
createRunGroup(branch: string | null, runGroup: string, ciExecutionId: string | null, ciExecutionEnv: string, stopAgentsOnFailure?: boolean, agentCount?: number, stopAgentsAfter?: string, commitSha?: string): Promise<void>;
completeRunGroup(branch: string | null, runGroup: string, ciExecutionId: string | null, ciExecutionEnv: string): Promise<void>;
}

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

const a1_0x56f6=['createMetricRecorder','../../utilities/metric-logger','error','RUNNER_FAILURE_PERF_ENTRY','/nx-cloud/executions/create-run-group','createApiAxiosInstance','axiosMultipleTries','exit','throw','next','recordMetric','__awaiter','/nx-cloud/executions/complete-run-group','response','done','../../utilities/nx-imports','RunGroupApi','apiAxiosInstance','defineProperty','axiosException','completeRunGroup','createRunGroup','mapRespToPerfEntry','apply','message','value','../../utilities/axios'];(function(_0x19e833,_0x56f6f7){const _0x1d75f6=function(_0x2d1516){while(--_0x2d1516){_0x19e833['push'](_0x19e833['shift']());}};_0x1d75f6(++_0x56f6f7);}(a1_0x56f6,0xd0));const a1_0x1d75=function(_0x19e833,_0x56f6f7){_0x19e833=_0x19e833-0x0;let _0x1d75f6=a1_0x56f6[_0x19e833];return _0x1d75f6;};'use strict';var __awaiter=this&&this[a1_0x1d75('0x13')]||function(_0x3fb4c8,_0x22b5c9,_0x1344a3,_0x47d233){function _0x24e66d(_0x434352){return _0x434352 instanceof _0x1344a3?_0x434352:new _0x1344a3(function(_0x3c9dd9){_0x3c9dd9(_0x434352);});}return new(_0x1344a3||(_0x1344a3=Promise))(function(_0x185639,_0x4391a7){function _0x7ad20a(_0x256148){try{_0x158c1b(_0x47d233[a1_0x1d75('0x11')](_0x256148));}catch(_0x2616ae){_0x4391a7(_0x2616ae);}}function _0xae306c(_0x418e6e){try{_0x158c1b(_0x47d233[a1_0x1d75('0x10')](_0x418e6e));}catch(_0x2f2790){_0x4391a7(_0x2f2790);}}function _0x158c1b(_0x37984d){_0x37984d[a1_0x1d75('0x16')]?_0x185639(_0x37984d[a1_0x1d75('0x6')]):_0x24e66d(_0x37984d[a1_0x1d75('0x6')])['then'](_0x7ad20a,_0xae306c);}_0x158c1b((_0x47d233=_0x47d233[a1_0x1d75('0x4')](_0x3fb4c8,_0x22b5c9||[]))[a1_0x1d75('0x11')]());});};Object[a1_0x1d75('0x1a')](exports,'__esModule',{'value':!![]});exports[a1_0x1d75('0x18')]=void 0x0;const axios_1=require(a1_0x1d75('0x7'));const metric_logger_1=require(a1_0x1d75('0x9'));const {output}=require(a1_0x1d75('0x17'));class RunGroupApi{constructor(_0x309a4c){this['apiAxiosInstance']=(0x0,axios_1[a1_0x1d75('0xd')])(_0x309a4c);}[a1_0x1d75('0x2')](_0x3bf27d,_0xc5fcc4,_0x531f20,_0x354d38,_0x2f3850,_0x1b9f82,_0xa10e3a){var _0x145b7d;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5c823c=(0x0,metric_logger_1[a1_0x1d75('0x8')])('createRunGroup');try{const _0x1f3d33=yield(0x0,axios_1[a1_0x1d75('0xe')])(()=>this[a1_0x1d75('0x19')]['post'](a1_0x1d75('0xc'),{'branch':_0x3bf27d,'runGroup':_0xc5fcc4,'ciExecutionId':_0x531f20,'ciExecutionEnv':_0x354d38,'stopAgentsOnFailure':_0x2f3850,'agentCount':_0x1b9f82,'stopAgentsAfter':_0xa10e3a}));_0x5c823c['recordMetric']((0x0,metric_logger_1[a1_0x1d75('0x3')])(_0x1f3d33));}catch(_0x168c0c){_0x5c823c[a1_0x1d75('0x12')](((_0x145b7d=_0x168c0c===null||_0x168c0c===void 0x0?void 0x0:_0x168c0c[a1_0x1d75('0x0')])===null||_0x145b7d===void 0x0?void 0x0:_0x145b7d[a1_0x1d75('0x15')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x168c0c[a1_0x1d75('0x0')][a1_0x1d75('0x15')]):metric_logger_1[a1_0x1d75('0xb')]);output[a1_0x1d75('0xa')]({'title':_0x168c0c[a1_0x1d75('0x5')]});process[a1_0x1d75('0xf')](0x1);}});}['completeRunGroup'](_0x140572,_0x55d9e8,_0xa95691,_0x257c38){var _0x360b14;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5302f6=(0x0,metric_logger_1['createMetricRecorder'])(a1_0x1d75('0x1'));try{const _0x21d4d0=yield(0x0,axios_1[a1_0x1d75('0xe')])(()=>this['apiAxiosInstance']['post'](a1_0x1d75('0x14'),{'branch':_0x140572,'runGroup':_0x55d9e8,'ciExecutionId':_0xa95691,'ciExecutionEnv':_0x257c38}));_0x5302f6['recordMetric']((0x0,metric_logger_1[a1_0x1d75('0x3')])(_0x21d4d0));}catch(_0x5ef7ef){_0x5302f6['recordMetric'](((_0x360b14=_0x5ef7ef===null||_0x5ef7ef===void 0x0?void 0x0:_0x5ef7ef['axiosException'])===null||_0x360b14===void 0x0?void 0x0:_0x360b14['response'])?(0x0,metric_logger_1[a1_0x1d75('0x3')])(_0x5ef7ef[a1_0x1d75('0x0')]['response']):metric_logger_1[a1_0x1d75('0xb')]);output[a1_0x1d75('0xa')]({'title':_0x5ef7ef['message']});process[a1_0x1d75('0xf')](0x1);}});}}exports[a1_0x1d75('0x18')]=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) {
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

@@ -35,2 +35,3 @@ "use strict";

const ciExecutionEnv = (0, environment_1.getCIExecutionEnv)();
const commitSha = (0, environment_1.extractGitSha)();
if (!(0, print_run_group_error_1.canDetectRunGroup)(runGroup, ciExecutionId)) {

@@ -42,3 +43,3 @@ (0, print_run_group_error_1.printRunGroupError)();

output.note({
title: `Creating run group. branch: ${branch}, ciExecutionId: ${ciExecutionId}, ciExecutionEnv: ${ciExecutionEnv}, runGroup: ${runGroup}`,
title: `Creating run group. branch: ${branch}, ciExecutionId: ${ciExecutionId}, ciExecutionEnv: ${ciExecutionEnv}, runGroup: ${runGroup}, commitSha: ${commitSha}`,
});

@@ -55,3 +56,3 @@ }

const api = new run_group_api_1.RunGroupApi(options);
yield api.createRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv, args.stopAgentsOnFailure, args.agentCount, args.stopAgentsAfter);
yield api.createRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv, args.stopAgentsOnFailure, args.agentCount, args.stopAgentsAfter, commitSha);
if (args.useDteByDefault) {

@@ -58,0 +59,0 @@ (0, distributed_task_execution_detection_1.storeDteMarker)();

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

DependencyType["implicit"] = "implicit";
})(DependencyType = exports.DependencyType || (exports.DependencyType = {}));
})(DependencyType || (exports.DependencyType = DependencyType = {}));
//# sourceMappingURL=run-context.model.js.map

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

const a0_0x59e3=['runContext','status','remote-cache-hit','implicitDeps','cleanUpHashDetails','filter','obfuscate','statuses','cacheableOperations','code','find','outputObfuscator','tasks','hash','target','../../../utilities/serializer-overrides','defineProperty','Cannot\x20find\x20task\x20','serializeOverrides','terminalOutput','updateStartedTask','cache','remote-cache','startTask','runtime','getTerminalOutput','endTasks','startTime','scheduleTask','local-cache','readTaskTerminalOutput','nodes','keys','endCommand','npm:','scheduledTasks','toISOString','cacheDirectory','local-cache-kept-existing','collectTerminalOutput','endTime','forEach','task','startsWith','CloudEnabledLifeCycle','params','taskId'];(function(_0x2a4f18,_0x59e322){const _0x32069c=function(_0x26ae86){while(--_0x26ae86){_0x2a4f18['push'](_0x2a4f18['shift']());}};_0x32069c(++_0x59e322);}(a0_0x59e3,0x115));const a0_0x3206=function(_0x2a4f18,_0x59e322){_0x2a4f18=_0x2a4f18-0x0;let _0x32069c=a0_0x59e3[_0x2a4f18];return _0x32069c;};'use strict';Object[a0_0x3206('0x15')](exports,'__esModule',{'value':!![]});exports[a0_0x3206('0x2')]=void 0x0;const serializer_overrides_1=require(a0_0x3206('0x14'));const read_task_terminal_output_1=require('../../terminal-output/read-task-terminal-output');class CloudEnabledLifeCycle{constructor(_0x297719,_0x284d6b,_0x5a9efd,_0x4dc069,_0x58aaf2,_0x3c7d24){this[a0_0x3206('0x5')]=_0x297719;this[a0_0x3206('0x2a')]=_0x284d6b;this[a0_0x3206('0x2c')]=_0x5a9efd;this[a0_0x3206('0xd')]=_0x4dc069;this[a0_0x3206('0x10')]=_0x58aaf2;this[a0_0x3206('0x11')]=_0x3c7d24;}[a0_0x3206('0x21')](_0xdde103){this[a0_0x3206('0x5')][a0_0x3206('0x28')]['push'](_0xdde103);}[a0_0x3206('0x1c')](_0x448f80){this[a0_0x3206('0x11')]['push']({'taskId':_0x448f80['id'],'startTime':new Date()[a0_0x3206('0x29')](),'target':_0x448f80[a0_0x3206('0x13')]['target'],'projectName':_0x448f80[a0_0x3206('0x13')]['project'],'hash':_0x448f80['hash'],'hashDetails':this[a0_0x3206('0x9')](_0x448f80['hashDetails']),'params':(0x0,serializer_overrides_1[a0_0x3206('0x17')])(_0x448f80),'uploadedToStorage':![]});}[a0_0x3206('0x1f')](_0x29d340){for(let _0x193608 of _0x29d340){let _0x5b6489;const _0x5b48a3=_0x193608['status']===a0_0x3206('0x1b');const _0x353324=_0x193608['status']===a0_0x3206('0x1a');const _0x580746=_0x193608[a0_0x3206('0x6')]===a0_0x3206('0x22')||_0x193608[a0_0x3206('0x6')]===a0_0x3206('0x2b')||_0x353324;if(this['runContext']['statuses'][_0x193608[a0_0x3206('0x0')][a0_0x3206('0x12')]]){_0x5b6489=this[a0_0x3206('0x5')][a0_0x3206('0xc')][_0x193608[a0_0x3206('0x0')][a0_0x3206('0x12')]];}else if(_0x5b48a3){_0x5b6489=a0_0x3206('0x7');}else if(_0x580746){_0x5b6489='local-cache-hit';}else{_0x5b6489='cache-miss';}this[a0_0x3206('0x19')](_0x193608,_0x5b6489);}}[a0_0x3206('0x26')](){}[a0_0x3206('0x19')](_0x126fae,_0x1ea4ea){const _0x40732d=this['tasks'][a0_0x3206('0xf')](_0x4e7f5d=>_0x4e7f5d[a0_0x3206('0x4')]===_0x126fae[a0_0x3206('0x0')]['id']);if(!_0x40732d){throw new Error(a0_0x3206('0x16')+_0x126fae[a0_0x3206('0x0')]['id']);}if((_0x126fae===null||_0x126fae===void 0x0?void 0x0:_0x126fae[a0_0x3206('0x20')])&&(_0x126fae===null||_0x126fae===void 0x0?void 0x0:_0x126fae[a0_0x3206('0x2d')])){_0x40732d[a0_0x3206('0x20')]=new Date(_0x126fae['startTime'])[a0_0x3206('0x29')]();_0x40732d['endTime']=new Date(_0x126fae[a0_0x3206('0x2d')])[a0_0x3206('0x29')]();}else{_0x40732d[a0_0x3206('0x2d')]=new Date()[a0_0x3206('0x29')]();}_0x40732d['status']=_0x126fae[a0_0x3206('0xe')];_0x40732d[a0_0x3206('0x3')]=this[a0_0x3206('0x10')][a0_0x3206('0xb')](_0x40732d[a0_0x3206('0x3')]);_0x40732d['cacheStatus']=_0x1ea4ea;if(this[a0_0x3206('0x2c')]){_0x40732d[a0_0x3206('0x18')]=this[a0_0x3206('0x1e')](_0x126fae[a0_0x3206('0x0')][a0_0x3206('0x12')],_0x40732d['cacheStatus'],_0x126fae['code']);}}[a0_0x3206('0x1e')](_0x436e61,_0x15795d,_0xd40deb){return(0x0,read_task_terminal_output_1[a0_0x3206('0x23')])(this['cacheDirectory'],this[a0_0x3206('0x10')],_0x436e61,_0x15795d,_0xd40deb);}['cleanUpHashDetails'](_0x4501bd){const _0x119c24={};Object[a0_0x3206('0x25')](_0x4501bd[a0_0x3206('0x24')])[a0_0x3206('0xa')](_0x5279e5=>!_0x5279e5[a0_0x3206('0x1')](a0_0x3206('0x27')))[a0_0x3206('0x2e')](_0x14d8e4=>{_0x119c24[_0x14d8e4]=_0x4501bd[a0_0x3206('0x24')][_0x14d8e4];});return{'nodes':_0x119c24,'runtime':_0x4501bd[a0_0x3206('0x1d')],'implicitDeps':_0x4501bd[a0_0x3206('0x8')]};}}exports['CloudEnabledLifeCycle']=CloudEnabledLifeCycle;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudEnabledLifeCycle = void 0;
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
const read_task_terminal_output_1 = require("../../terminal-output/read-task-terminal-output");
class CloudEnabledLifeCycle {
constructor(runContext, cacheDirectory, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
this.runContext = runContext;
this.cacheDirectory = cacheDirectory;
this.collectTerminalOutput = collectTerminalOutput;
this.cacheableOperations = cacheableOperations;
this.outputObfuscator = outputObfuscator;
this.tasks = tasks;
}
scheduleTask(task) {
this.runContext.scheduledTasks.push(task);
}
// this gets called for every tasks that starts.
startTask(task) {
this.tasks.push({
taskId: task.id,
startTime: new Date().toISOString(),
target: task.target.target,
projectName: task.target.project,
hash: task.hash,
hashDetails: this.cleanUpHashDetails(task.hashDetails),
params: (0, serializer_overrides_1.serializeOverrides)(task),
uploadedToStorage: false,
});
}
endTasks(tasks) {
// this can be called multiple times changing this time.
for (let t of tasks) {
let cacheStatus;
const taskIsRemoteCacheHit = t.status === 'remote-cache';
const taskIsLocalCacheHitPreNx135 = t.status === 'cache';
const taskIsLocalCacheHit = t.status === 'local-cache' ||
t.status === 'local-cache-kept-existing' ||
taskIsLocalCacheHitPreNx135;
if (this.runContext.statuses[t.task.hash]) {
cacheStatus = this.runContext.statuses[t.task.hash];
}
else if (taskIsRemoteCacheHit) {
cacheStatus = 'remote-cache-hit';
}
else if (taskIsLocalCacheHit) {
cacheStatus = 'local-cache-hit';
}
else {
cacheStatus = 'cache-miss';
}
this.updateStartedTask(t, cacheStatus);
}
}
endCommand() { }
updateStartedTask(result, cacheStatus) {
const startedTask = this.tasks.find((t) => t.taskId === result.task.id);
if (!startedTask) {
throw new Error(`Cannot find task ${result.task.id}`);
}
if ((result === null || result === void 0 ? void 0 : result.startTime) && (result === null || result === void 0 ? void 0 : result.endTime)) {
startedTask.startTime = new Date(result.startTime).toISOString();
startedTask.endTime = new Date(result.endTime).toISOString();
}
else {
startedTask.endTime = new Date().toISOString();
}
startedTask.status = result.code;
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
startedTask.cacheStatus = cacheStatus;
if (this.collectTerminalOutput) {
startedTask.terminalOutput = this.getTerminalOutput(result.task.hash, startedTask.cacheStatus, result.code);
}
}
getTerminalOutput(hash, cacheStatus, code) {
return (0, read_task_terminal_output_1.readTaskTerminalOutput)(this.cacheDirectory, this.outputObfuscator, hash, cacheStatus, code);
}
cleanUpHashDetails(hashDetails) {
const nodes = {};
Object.keys(hashDetails.nodes)
.filter((k) => !k.startsWith('npm:'))
.forEach((k) => {
nodes[k] = hashDetails.nodes[k];
});
return {
nodes,
runtime: hashDetails.runtime,
implicitDeps: hashDetails.implicitDeps,
};
}
}
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
//# sourceMappingURL=cloud-enabled-life-cycle.js.map

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

const a1_0x2225=['maskedProperties','value','../../terminal-output/message-reporter','error','note','E2EEncryption','subscribe','../../terminal-output/end-of-run-message','removeTrailingSlash','getBranch','join','push','assign','../../file-storage/e2e-encryption','throw','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','endRun','getCIExecutionId','ACCESS_TOKEN','waitForStoreRequestsToComplete','writeFileSync','printMessages','printCacheHitsMessage','../../../utilities/remove-trailing-slash','ENCRYPTION_KEY','https://nx.app','toString','OutputObfuscator','hash','getCIExecutionEnv','parseCommand','next','skipNxCache','accessToken','.commit','../../../utilities/environment','./cloud-remote-cache','requests','./cloud-run.api','path','filter','getMachineInfo','fs-extra','catch','CloudRemoteCache','enabled','getRunGroup','defineProperty','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','Task\x20with\x20hash\x20','anyErrors','storedHashes','cloudEnabledTasksRunner','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','daemon','cacheableOperations','local-cache-hit','warn','forEach','../../../utilities/nx-imports','ErrorReporterApi','length','cloud-enabled-runner','processInBackground','map','extractGitSha','taskId','pathExists','message','EndOfRunMessage','./id-generator','url','Executed\x20tasks\x20with\x20hashes:\x20','toISOString','__esModule','startRun','exit','then','all','../../../utilities/metric-logger','lifeCycle','encryptionKey','tasks-hashes-','env','find','./cloud-enabled-life-cycle','agentRunningInDistributedExecution','store','MessageReporter','\x20isn\x27t\x20recorded','complete','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','../../terminal-output/output-obfuscator'];(function(_0x22d80a,_0x222528){const _0x3b84dc=function(_0x5eecf1){while(--_0x5eecf1){_0x22d80a['push'](_0x22d80a['shift']());}};_0x3b84dc(++_0x222528);}(a1_0x2225,0xf6));const a1_0x3b84=function(_0x22d80a,_0x222528){_0x22d80a=_0x22d80a-0x0;let _0x3b84dc=a1_0x2225[_0x22d80a];return _0x3b84dc;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x10dbdb,_0x229dda,_0x8ea7d5,_0x221352){function _0x4c58c2(_0x2bbd7e){return _0x2bbd7e instanceof _0x8ea7d5?_0x2bbd7e:new _0x8ea7d5(function(_0x4b8542){_0x4b8542(_0x2bbd7e);});}return new(_0x8ea7d5||(_0x8ea7d5=Promise))(function(_0x2ba64c,_0x355af1){function _0x4f88c8(_0x129752){try{_0x4726b6(_0x221352[a1_0x3b84('0x40')](_0x129752));}catch(_0x273c05){_0x355af1(_0x273c05);}}function _0x104507(_0x4fbace){try{_0x4726b6(_0x221352[a1_0x3b84('0x2f')](_0x4fbace));}catch(_0x39b330){_0x355af1(_0x39b330);}}function _0x4726b6(_0x15cbcc){_0x15cbcc['done']?_0x2ba64c(_0x15cbcc[a1_0x3b84('0x22')]):_0x4c58c2(_0x15cbcc[a1_0x3b84('0x22')])[a1_0x3b84('0x11')](_0x4f88c8,_0x104507);}_0x4726b6((_0x221352=_0x221352['apply'](_0x10dbdb,_0x229dda||[]))[a1_0x3b84('0x40')]());});};Object[a1_0x3b84('0x50')](exports,a1_0x3b84('0xe'),{'value':!![]});exports[a1_0x3b84('0x55')]=void 0x0;const message_reporter_1=require(a1_0x3b84('0x23'));const end_of_run_message_1=require(a1_0x3b84('0x28'));const output_obfuscator_1=require(a1_0x3b84('0x20'));const cloud_enabled_life_cycle_1=require(a1_0x3b84('0x19'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a1_0x3b84('0x2e'));const environment_1=require(a1_0x3b84('0x44'));const cloud_remote_cache_1=require(a1_0x3b84('0x45'));const cloud_run_api_1=require(a1_0x3b84('0x47'));const fs_1=require('fs');const path=require(a1_0x3b84('0x48'));const path_1=require('path');const metric_logger_1=require(a1_0x3b84('0x13'));const error_reporter_api_1=require('../../api/error-reporter.api');const fs_extra_1=require(a1_0x3b84('0x4b'));const id_generator_1=require(a1_0x3b84('0xa'));const remove_trailing_slash_1=require(a1_0x3b84('0x38'));const {tasksRunner,output,cacheDirectory}=require(a1_0x3b84('0x5c'));function createApi(_0x2cc7b9,_0x3a8bd3,_0x214eb5){const _0x3749d0=(0x0,environment_1[a1_0x3b84('0x4a')])(_0x3a8bd3);return new cloud_run_api_1['CloudRunApi'](_0x2cc7b9,_0x214eb5,_0x3a8bd3,_0x3749d0);}function storeTaskHashes(_0x2b189f,_0x40d740,_0x76813a){const _0xf1bd7b=JSON['stringify'](_0x2b189f[a1_0x3b84('0x4')](_0x28f399=>({'taskId':_0x28f399[a1_0x3b84('0x6')],'hash':_0x28f399[a1_0x3b84('0x3d')]})));if(environment_1['VERBOSE_LOGGING']){output[a1_0x3b84('0x25')]({'title':a1_0x3b84('0xc')+_0xf1bd7b});}(0x0,fs_1[a1_0x3b84('0x35')])(path[a1_0x3b84('0x2b')](_0x40d740,a1_0x3b84('0x16')+_0x76813a),_0xf1bd7b);}function storeLocalCacheHits(_0x33fdbd,_0x465f74,_0x4719a9){const _0x15c79f=_0x33fdbd[a1_0x3b84('0x49')](_0x230390=>_0x230390['cacheStatus']===a1_0x3b84('0x59'))['map'](_0x4452e1=>_0x4452e1['hash']);_0x15c79f[a1_0x3b84('0x5b')](_0x392d33=>_0x465f74[a1_0x3b84('0x1b')](_0x392d33,_0x4719a9));}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 _0x1a684d=new Date()['toISOString']();const _0x1c0d21=(0x0,environment_1[a1_0x3b84('0x2a')])();const _0x37cd9d={'command':outputObfuscator['obfuscate']((0x0,environment_1[a1_0x3b84('0x3f')])()),'startTime':runStartTime,'endTime':_0x1a684d,'distributedExecutionId':distributedExecutionId,'branch':_0x1c0d21,'runGroup':(0x0,environment_1[a1_0x3b84('0x4f')])(),'sha':_0x1c0d21?(0x0,environment_1[a1_0x3b84('0x5')])():undefined,'inner':inner};const _0x199c53={'branch':_0x1c0d21,'runGroup':(0x0,environment_1[a1_0x3b84('0x4f')])(),'ciExecutionId':(0x0,environment_1[a1_0x3b84('0x32')])(),'ciExecutionEnv':(0x0,environment_1[a1_0x3b84('0x3e')])()};if(storeInCurrentProcess){if((0x0,environment_1[a1_0x3b84('0x1a')])(distributedExecutionId)){storeTaskHashes(taskExecutions,cacheDirectory,distributedExecutionId);storeLocalCacheHits(taskExecutions,remoteCache,cacheDirectory);}try{yield remoteCache[a1_0x3b84('0x34')]();}catch(_0x4d42e0){output[a1_0x3b84('0x24')]({'title':a1_0x3b84('0x1f')});messages['printMessages']();return![];}for(const _0x3a25f1 of fileStorage[a1_0x3b84('0x54')]){const _0x29c33b=taskExecutions[a1_0x3b84('0x18')](_0x53b564=>_0x53b564['hash']===_0x3a25f1);if(!_0x29c33b){throw new Error(a1_0x3b84('0x52')+_0x3a25f1+a1_0x3b84('0x1d'));}_0x29c33b['uploadedToStorage']=!![];}try{yield api[a1_0x3b84('0x31')](_0x37cd9d,taskExecutions,_0x199c53);}catch(_0x17bc9b){output[a1_0x3b84('0x24')]({'title':a1_0x3b84('0x30')});messages[a1_0x3b84('0x36')]();return![];}yield(0x0,metric_logger_1['submitRunMetrics'])(options);}else{try{const _0x537cf8=environment_1[a1_0x3b84('0x33')]?environment_1['ACCESS_TOKEN']:options[a1_0x3b84('0x42')];const _0x3ce64c=(0x0,id_generator_1['generateUniqueLinkId'])();yield daemon[a1_0x3b84('0x3')]('nx-cloud/lib/daemon/process-run-end',{'encryptionKey':encryptionKey,'runnerOptions':Object[a1_0x3b84('0x2d')](Object[a1_0x3b84('0x2d')]({},options),{'accessToken':_0x537cf8}),'delayedStoreRequests':remoteCache['delayedStoreRequests'],'ciExecutionContext':_0x199c53,'runEnd':{'runData':_0x37cd9d,'taskExecutions':taskExecutions,'linkId':_0x3ce64c}});runContext['runUrl']=(0x0,remove_trailing_slash_1[a1_0x3b84('0x29')])(options[a1_0x3b84('0xb')]||a1_0x3b84('0x3a'))+'/runs/'+_0x3ce64c;}catch(_0x4cb788){output[a1_0x3b84('0x5a')]({'title':'Nx\x20Cloud\x20Problems','bodyLines':[_0x4cb788[a1_0x3b84('0x8')]||_0x4cb788[a1_0x3b84('0x3b')]()]});return![];}}if(versionOfNxBefore133){setTimeout(()=>{messages[a1_0x3b84('0x36')]();if(!messages[a1_0x3b84('0x53')]&&!inner){endOfRunMessage[a1_0x3b84('0x37')]();}},0x0);}else{messages[a1_0x3b84('0x36')]();if(!messages[a1_0x3b84('0x53')]&&!inner){endOfRunMessage[a1_0x3b84('0x37')]();}}return!![];});}function createLifeCycle(_0x429651,_0x19e121,_0x49a1b3,_0x404e88){const _0x5ed0e9=new cloud_enabled_life_cycle_1['CloudEnabledLifeCycle'](_0x429651,cacheDirectory,!![],_0x19e121[a1_0x3b84('0x58')]||[],_0x49a1b3,_0x404e88);try{const {CompositeLifeCycle}=require(a1_0x3b84('0x5c'));if(!CompositeLifeCycle)return _0x5ed0e9;return new CompositeLifeCycle([_0x19e121[a1_0x3b84('0x14')],_0x5ed0e9]);}catch(_0x37f75a){return _0x5ed0e9;}}function fetchUrlsForKnownHashesUpfront(_0x569e61,_0x971dcc,_0x508270,_0x47c68a,_0x386413){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x47c68a[a1_0x3b84('0x41')])return;let _0x33ca03=_0x508270[a1_0x3b84('0x4')](_0x11879d=>_0x11879d[a1_0x3b84('0x3d')])[a1_0x3b84('0x49')](_0x4592c7=>!!_0x4592c7);const _0x53edfb=yield Promise[a1_0x3b84('0x12')](_0x33ca03[a1_0x3b84('0x4')](_0xd2f170=>{const _0xad612a=(0x0,path_1[a1_0x3b84('0x2b')])(cacheDirectory,_0xd2f170+a1_0x3b84('0x43'));return(0x0,fs_extra_1[a1_0x3b84('0x7')])(_0xad612a);}));const _0x4772ca=[];for(let _0x4db882=0x0;_0x4db882<_0x53edfb['length'];++_0x4db882){if(!_0x53edfb[_0x4db882]){_0x4772ca[a1_0x3b84('0x2c')](_0x33ca03[_0x4db882]);}}if(_0x4772ca[a1_0x3b84('0x1')]>0x0){const _0x10d448=_0x569e61[a1_0x3b84('0xf')](_0x386413,_0x4772ca);for(const _0x804462 of _0x4772ca){_0x971dcc[a1_0x3b84('0x46')][_0x804462]=_0x10d448;}}});}function cloudEnabledTasksRunner(_0x25b4df,_0x3d4315,_0x3ecb83,_0x902903=![]){var _0x46b7b4;const _0x5c0e26=process['env']['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'];const _0x1c82ce={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x25b4df};const _0x32ad01=_0x3d4315['lifeCycle']===undefined;const _0x3b0a1b=[];const _0x55498a=new message_reporter_1[(a1_0x3b84('0x1c'))](_0x3d4315);const _0xbefe79=createApi(_0x55498a,_0x3d4315,_0x1c82ce);const _0x31e910=new end_of_run_message_1[(a1_0x3b84('0x9'))](_0x1c82ce,_0x3b0a1b,_0x5c0e26);const _0x530178=new output_obfuscator_1[(a1_0x3b84('0x3c'))](_0x3d4315[a1_0x3b84('0x21')]);const _0x3d5548=new Date()[a1_0x3b84('0xd')]();const _0x5c0cac=createLifeCycle(_0x1c82ce,_0x3d4315,_0x530178,_0x3b0a1b);const _0x57f285=environment_1[a1_0x3b84('0x39')]||_0x3d4315[a1_0x3b84('0x15')];const _0x1e27d4=new e2e_encryption_1[(a1_0x3b84('0x26'))](_0x57f285);const _0x490688=new error_reporter_api_1[(a1_0x3b84('0x0'))](_0x3d4315);const _0x49b4c2=(0x0,environment_1[a1_0x3b84('0x1a')])(_0x5c0e26)||!((_0x46b7b4=_0x3ecb83[a1_0x3b84('0x57')])===null||_0x46b7b4===void 0x0?void 0x0:_0x46b7b4[a1_0x3b84('0x4e')]());const _0x41f560=new file_storage_1['FileStorage'](_0x1e27d4,_0x490688,_0x3d4315,a1_0x3b84('0x2'));const _0x24022c=new cloud_remote_cache_1[(a1_0x3b84('0x4d'))](_0x55498a,_0xbefe79,_0x1c82ce,_0x41f560,_0x5c0e26,_0x49b4c2);fetchUrlsForKnownHashesUpfront(_0xbefe79,_0x1c82ce,_0x25b4df,_0x3d4315,_0x5c0e26);delete process[a1_0x3b84('0x17')][a1_0x3b84('0x56')];const _0x24e737=tasksRunner(_0x25b4df,Object[a1_0x3b84('0x2d')](Object[a1_0x3b84('0x2d')]({},_0x3d4315),{'remoteCache':_0x24022c,'lifeCycle':_0x5c0cac}),_0x3ecb83);if(_0x24e737['subscribe']){const {Subject}=require('rxjs/internal/Subject');const _0x1040f2=new Subject();_0x24e737[a1_0x3b84('0x27')]({'next':_0x3c5964=>_0x1040f2[a1_0x3b84('0x40')](_0x3c5964),'error':_0x582cd1=>_0x1040f2[a1_0x3b84('0x24')](_0x582cd1),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x392019=yield onComplete({'daemon':_0x3ecb83['daemon'],'options':_0x3d4315,'fileStorage':_0x41f560,'remoteCache':_0x24022c,'api':_0xbefe79,'outputObfuscator':_0x530178,'runStartTime':_0x3d5548,'messages':_0x55498a,'endOfRunMessage':_0x31e910,'taskExecutions':_0x3b0a1b,'versionOfNxBefore133':_0x32ad01,'inner':_0x902903,'encryptionKey':_0x57f285,'storeInCurrentProcess':_0x49b4c2,'runContext':_0x1c82ce,'distributedExecutionId':_0x5c0e26});if(!_0x392019&&(0x0,environment_1[a1_0x3b84('0x1a')])(_0x5c0e26)){process[a1_0x3b84('0x10')](environment_1[a1_0x3b84('0x51')]);}_0x1040f2[a1_0x3b84('0x1e')]();})});return _0x1040f2;}else{return _0x24e737[a1_0x3b84('0x11')](_0x205c38=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x42d3b1=yield onComplete({'daemon':_0x3ecb83[a1_0x3b84('0x57')],'options':_0x3d4315,'fileStorage':_0x41f560,'remoteCache':_0x24022c,'api':_0xbefe79,'outputObfuscator':_0x530178,'runStartTime':_0x3d5548,'messages':_0x55498a,'endOfRunMessage':_0x31e910,'taskExecutions':_0x3b0a1b,'versionOfNxBefore133':_0x32ad01,'inner':_0x902903,'encryptionKey':_0x57f285,'storeInCurrentProcess':_0x49b4c2,'runContext':_0x1c82ce,'distributedExecutionId':_0x5c0e26});if(!_0x42d3b1&&(0x0,environment_1['agentRunningInDistributedExecution'])(_0x5c0e26)){process[a1_0x3b84('0x10')](environment_1[a1_0x3b84('0x51')]);}return _0x205c38;}))[a1_0x3b84('0x4c')](_0x200a5a=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x200b1b=yield onComplete({'daemon':_0x3ecb83[a1_0x3b84('0x57')],'options':_0x3d4315,'fileStorage':_0x41f560,'remoteCache':_0x24022c,'api':_0xbefe79,'outputObfuscator':_0x530178,'runStartTime':_0x3d5548,'messages':_0x55498a,'endOfRunMessage':_0x31e910,'taskExecutions':_0x3b0a1b,'versionOfNxBefore133':_0x32ad01,'inner':_0x902903,'encryptionKey':_0x57f285,'storeInCurrentProcess':_0x49b4c2,'runContext':_0x1c82ce,'distributedExecutionId':_0x5c0e26});if(!_0x200b1b&&(0x0,environment_1[a1_0x3b84('0x1a')])(_0x5c0e26)){process[a1_0x3b84('0x10')](environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']);}throw _0x200a5a;}));}}exports[a1_0x3b84('0x55')]=cloudEnabledTasksRunner;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloudEnabledTasksRunner = void 0;
const message_reporter_1 = require("../../terminal-output/message-reporter");
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
const file_storage_1 = require("../../file-storage/file-storage");
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
const environment_1 = require("../../../utilities/environment");
const cloud_remote_cache_1 = require("./cloud-remote-cache");
const cloud_run_api_1 = require("./cloud-run.api");
const fs_1 = require("fs");
const path = require("path");
const path_1 = require("path");
const metric_logger_1 = require("../../../utilities/metric-logger");
const error_reporter_api_1 = require("../../api/error-reporter.api");
const fs_extra_1 = require("fs-extra");
const id_generator_1 = require("./id-generator");
const remove_trailing_slash_1 = require("../../../utilities/remove-trailing-slash");
const { tasksRunner, output, cacheDirectory, } = require('../../../utilities/nx-imports');
function createApi(errors, options, runContext) {
const machineInfo = (0, environment_1.getMachineInfo)(options);
return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
}
function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
const hashes = JSON.stringify(taskExecutions.map((t) => ({
taskId: t.taskId,
hash: t.hash,
})));
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Executed tasks with hashes: ${hashes}`,
});
}
(0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
}
/*
* It can happen that a task is executed multiple times on an agent, say for DTE1 and DTE2.
* When it runs for DTE2, it will be a local cache hit, so it will be marked as completed.
* However, Nx won't upload an artifact to S3 in this case. Usually this isn't a problem,
* cause the first DTE would have uploaded it. But if you are using a DTE, with a read-only token,
* the uploaded artifact will have a different scoped hash.
*
* To address this: we are finding all local cache hits, and upload everything that has a put url.
*/
function storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory) {
const hashes = taskExecutions
.filter((t) => t.cacheStatus === 'local-cache-hit')
.map((t) => t.hash);
hashes.forEach((hash) => remoteCache.store(hash, nxCacheDirectory));
}
function onComplete({ daemon, options, fileStorage, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner, encryptionKey, storeInCurrentProcess, distributedExecutionId, runContext, }) {
return __awaiter(this, void 0, void 0, function* () {
const runEndTime = new Date().toISOString();
const branch = (0, environment_1.getBranch)();
const runData = {
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
startTime: runStartTime,
endTime: runEndTime,
distributedExecutionId,
branch: branch,
runGroup: (0, environment_1.getRunGroup)(),
// only set sha if branch is set because we invoke a separate process,
// which adds a few millis
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
inner: inner,
};
const ciExecutionContext = {
branch: branch,
runGroup: (0, environment_1.getRunGroup)(),
ciExecutionId: (0, environment_1.getCIExecutionId)(),
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
};
if (storeInCurrentProcess) {
if ((0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
storeTaskHashes(taskExecutions, cacheDirectory, distributedExecutionId);
storeLocalCacheHits(taskExecutions, remoteCache, cacheDirectory);
}
try {
yield remoteCache.waitForStoreRequestsToComplete();
}
catch (e) {
output.error({
title: `Nx Cloud wasn't able to store artifacts.`,
});
messages.printMessages();
return false;
}
for (const hash of fileStorage.storedHashes) {
const matchingTask = taskExecutions.find((t) => t.hash === hash);
if (!matchingTask) {
throw new Error(`Task with hash ${hash} isn't recorded`);
}
matchingTask.uploadedToStorage = true;
}
try {
yield api.endRun(runData, taskExecutions, ciExecutionContext);
}
catch (e) {
output.error({
title: `Nx Cloud wasn't able to record its run.`,
});
messages.printMessages();
return false;
}
yield (0, metric_logger_1.submitRunMetrics)(options);
}
else {
try {
const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken;
const linkId = (0, id_generator_1.generateUniqueLinkId)();
const processRunEndFullPath = require.resolve('nx-cloud/lib/daemon/process-run-end');
yield daemon.processInBackground(processRunEndFullPath, {
encryptionKey,
runnerOptions: Object.assign(Object.assign({}, options), { accessToken }),
delayedStoreRequests: remoteCache.delayedStoreRequests,
ciExecutionContext,
runEnd: {
runData,
taskExecutions,
linkId,
},
});
runContext.runUrl = `${(0, remove_trailing_slash_1.removeTrailingSlash)(options.url || 'https://nx.app')}/runs/${linkId}`;
}
catch (e) {
output.warn({
title: `Nx Cloud Problems`,
bodyLines: [e.message || e.toString()],
});
return false;
}
}
// this workaround is required because prior to Nx 13.3 we printed
// the end message after the runner completes, so we need to wait for the
// message to appear in the right place
if (versionOfNxBefore133) {
setTimeout(() => {
messages.printMessages();
if (!messages.anyErrors && !inner) {
endOfRunMessage.printCacheHitsMessage();
}
}, 0);
}
else {
messages.printMessages();
if (!messages.anyErrors && !inner) {
endOfRunMessage.printCacheHitsMessage();
}
}
return true;
});
}
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, cacheDirectory, true, options.cacheableOperations || [], outputObfuscator, tasks);
try {
const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
if (!CompositeLifeCycle)
return cloudEnabledLifeCycle;
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
}
catch (e) {
return cloudEnabledLifeCycle;
}
}
function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId) {
return __awaiter(this, void 0, void 0, function* () {
if (options.skipNxCache)
return;
let hashes = tasks.map((t) => t.hash).filter((h) => !!h);
// filter out the urls that don't have artifact stored locally
const exists = yield Promise.all(hashes.map((hash) => {
const tdCommit = (0, path_1.join)(cacheDirectory, `${hash}.commit`);
return (0, fs_extra_1.pathExists)(tdCommit);
}));
const missingHashes = [];
for (let i = 0; i < exists.length; ++i) {
if (!exists[i]) {
missingHashes.push(hashes[i]);
}
}
if (missingHashes.length > 0) {
const startRunRequest = api.startRun(distributedExecutionId, missingHashes);
for (const hash of missingHashes) {
runContext.requests[hash] = startRunRequest;
}
}
});
}
function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
var _a;
const distributedExecutionId = process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
const runContext = {
statuses: {},
scheduledTasks: [],
requests: {},
allTasks: tasks,
};
const versionOfNxBefore133 = options.lifeCycle === undefined;
const taskExecutions = [];
const messages = new message_reporter_1.MessageReporter(options);
const api = createApi(messages, options, runContext);
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions, distributedExecutionId);
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
const runStartTime = new Date().toISOString();
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
const encryptionKey = environment_1.ENCRYPTION_KEY || options.encryptionKey;
const encryption = new e2e_encryption_1.E2EEncryption(encryptionKey);
const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
const storeInCurrentProcess = (0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId) ||
!((_a = context.daemon) === null || _a === void 0 ? void 0 : _a.enabled());
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, options, 'cloud-enabled-runner');
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess);
// we don't await for it cause this step is optional
fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId);
// have to reset it so we don't capture inner tasks
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
// observable -> legacy
if (res.subscribe) {
const { Subject } = require('rxjs/internal/Subject');
const wrappedRes = new Subject();
res.subscribe({
next: (value) => wrappedRes.next(value),
error: (err) => wrappedRes.error(err),
complete: () => __awaiter(this, void 0, void 0, function* () {
const success = yield onComplete({
daemon: context.daemon,
options,
fileStorage,
remoteCache,
api,
outputObfuscator,
runStartTime,
messages,
endOfRunMessage,
taskExecutions,
versionOfNxBefore133,
inner,
encryptionKey,
storeInCurrentProcess,
runContext,
distributedExecutionId,
});
if (!success &&
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
wrappedRes.complete();
}),
});
return wrappedRes;
// promise
}
else {
return res
.then((r) => __awaiter(this, void 0, void 0, function* () {
const success = yield onComplete({
daemon: context.daemon,
options,
fileStorage,
remoteCache,
api,
outputObfuscator,
runStartTime,
messages,
endOfRunMessage,
taskExecutions,
versionOfNxBefore133,
inner,
encryptionKey,
storeInCurrentProcess,
runContext,
distributedExecutionId,
});
if (!success &&
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
return r;
}))
.catch((e) => __awaiter(this, void 0, void 0, function* () {
const success = yield onComplete({
daemon: context.daemon,
options,
fileStorage,
remoteCache,
api,
outputObfuscator,
runStartTime,
messages,
endOfRunMessage,
taskExecutions,
versionOfNxBefore133,
inner,
encryptionKey,
storeInCurrentProcess,
runContext,
distributedExecutionId,
});
if (!success &&
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
throw e;
}));
}
}
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
//# sourceMappingURL=cloud-enabled.runner.js.map

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

const a2_0x6c95=['Error\x20when\x20storing\x20artifacts','note','then','Nx\x20Cloud:\x20Skipping\x20storing\x20','status','response','../../../utilities/nx-imports','fileStorage','retrieve','value','get','distributedExecutionId','startRun','scheduledTasks','next','waitForStoreRequestsToComplete','remote-cache-hit','push','messages','statuses','hash','Maybe\x20you\x20are\x20using\x20a\x20read-only\x20token\x20or\x20the\x20artifact\x20has\x20already\x20being\x20uploaded.','filter','forEach','storeInCurrentProcess','put','storage','delayedStoreRequests','api','all','../../../utilities/environment','resolve','storeRequests','defineProperty','extractErrorMessage','runContext','VERBOSE_LOGGING','throw','requests','hashUrls','axiosException','map','reduce','done','CloudRemoteCache','cacheError','.\x20Status\x20404.','Nx\x20Cloud:\x20Cache\x20miss\x20','store'];(function(_0x7e0adb,_0x6c95e){const _0x32b564=function(_0x4d49d7){while(--_0x4d49d7){_0x7e0adb['push'](_0x7e0adb['shift']());}};_0x32b564(++_0x6c95e);}(a2_0x6c95,0x85));const a2_0x32b5=function(_0x7e0adb,_0x6c95e){_0x7e0adb=_0x7e0adb-0x0;let _0x32b564=a2_0x6c95[_0x7e0adb];return _0x32b564;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x42acc7,_0x30f9bd,_0x555572,_0x881178){function _0x508eca(_0x34d826){return _0x34d826 instanceof _0x555572?_0x34d826:new _0x555572(function(_0x5e0cee){_0x5e0cee(_0x34d826);});}return new(_0x555572||(_0x555572=Promise))(function(_0x26d125,_0x171a6e){function _0x64a397(_0x30df01){try{_0x18a153(_0x881178[a2_0x32b5('0x1c')](_0x30df01));}catch(_0x45cf07){_0x171a6e(_0x45cf07);}}function _0x39d9fb(_0x5214db){try{_0x18a153(_0x881178[a2_0x32b5('0x2')](_0x5214db));}catch(_0x489286){_0x171a6e(_0x489286);}}function _0x18a153(_0x2df352){_0x2df352[a2_0x32b5('0x8')]?_0x26d125(_0x2df352[a2_0x32b5('0x17')]):_0x508eca(_0x2df352[a2_0x32b5('0x17')])[a2_0x32b5('0x10')](_0x64a397,_0x39d9fb);}_0x18a153((_0x881178=_0x881178['apply'](_0x42acc7,_0x30f9bd||[]))[a2_0x32b5('0x1c')]());});};Object[a2_0x32b5('0x2f')](exports,'__esModule',{'value':!![]});exports[a2_0x32b5('0x9')]=void 0x0;const environment_1=require(a2_0x32b5('0x2c'));const {output}=require(a2_0x32b5('0x14'));class CloudRemoteCache{constructor(_0x4ce53f,_0xe47537,_0x3ebaba,_0x1cfe89,_0xb71c83,_0x557203){this[a2_0x32b5('0x20')]=_0x4ce53f;this[a2_0x32b5('0x2a')]=_0xe47537;this[a2_0x32b5('0x0')]=_0x3ebaba;this[a2_0x32b5('0x15')]=_0x1cfe89;this['distributedExecutionId']=_0xb71c83;this[a2_0x32b5('0x26')]=_0x557203;this[a2_0x32b5('0x2e')]=[];this[a2_0x32b5('0x29')]=[];}[a2_0x32b5('0x16')](_0x46d644,_0x36a3a7){var _0x341de5;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a2_0x32b5('0xa')])return![];const _0x3f378e=yield this['hashUrls'](_0x46d644);if(!_0x3f378e||!_0x3f378e[a2_0x32b5('0x18')]){if(environment_1[a2_0x32b5('0x1')]){output[a2_0x32b5('0xf')]({'title':a2_0x32b5('0xc')+_0x46d644+'.'});}this[a2_0x32b5('0x0')][a2_0x32b5('0x21')][_0x46d644]='cache-miss';return![];}try{yield this['fileStorage'][a2_0x32b5('0x16')](_0x46d644,_0x3f378e[a2_0x32b5('0x18')],_0x36a3a7);this[a2_0x32b5('0x0')][a2_0x32b5('0x21')][_0x46d644]=a2_0x32b5('0x1e');return!![];}catch(_0x9f263c){const _0x1eb6c9=(_0x341de5=_0x9f263c[a2_0x32b5('0x5')])!==null&&_0x341de5!==void 0x0?_0x341de5:_0x9f263c;if(_0x1eb6c9['response']&&_0x1eb6c9[a2_0x32b5('0x13')][a2_0x32b5('0x12')]===0x194){if(environment_1[a2_0x32b5('0x1')]){output[a2_0x32b5('0xf')]({'title':a2_0x32b5('0xc')+_0x46d644+a2_0x32b5('0xb')});}}else{this[a2_0x32b5('0x20')]['cacheError']=this['messages'][a2_0x32b5('0x30')](_0x1eb6c9,a2_0x32b5('0x28'));}this[a2_0x32b5('0x0')]['statuses'][_0x46d644]='cache-miss';return![];}});}[a2_0x32b5('0xd')](_0x2be732,_0x1e6f32){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x32b5('0x20')][a2_0x32b5('0xa')])return![];const _0x5bfdad=Promise[a2_0x32b5('0x2d')]()[a2_0x32b5('0x10')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x5583e3;const _0x1a8cde=yield this[a2_0x32b5('0x4')](_0x2be732);if(!_0x1a8cde)return![];if(!_0x1a8cde[a2_0x32b5('0x27')]){if(environment_1[a2_0x32b5('0x1')]){output['note']({'title':a2_0x32b5('0x11')+_0x2be732+'.','bodyLines':['There\x20are\x20several\x20reasons\x20why\x20this\x20can\x20happen.',a2_0x32b5('0x23')]});}return!![];}if(!this['storeInCurrentProcess']){this[a2_0x32b5('0x29')][a2_0x32b5('0x1f')]({'hash':_0x2be732,'url':_0x1a8cde[a2_0x32b5('0x27')]});return!![];}try{yield this[a2_0x32b5('0x15')][a2_0x32b5('0xd')](_0x2be732,_0x1a8cde[a2_0x32b5('0x27')],_0x1e6f32);return!![];}catch(_0x418811){const _0xb4a98=(_0x5583e3=_0x418811[a2_0x32b5('0x5')])!==null&&_0x5583e3!==void 0x0?_0x5583e3:_0x418811;this[a2_0x32b5('0x20')][a2_0x32b5('0xa')]=this[a2_0x32b5('0x20')][a2_0x32b5('0x30')](_0xb4a98,'storage');return![];}}));this[a2_0x32b5('0x2e')]['push'](_0x5bfdad);return _0x5bfdad;});}[a2_0x32b5('0x4')](_0x433486){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x433486 in this[a2_0x32b5('0x0')][a2_0x32b5('0x3')]){return(yield this[a2_0x32b5('0x0')][a2_0x32b5('0x3')][_0x433486])[_0x433486];}else{const _0x4de827=this['runContext'][a2_0x32b5('0x1b')][a2_0x32b5('0x24')](_0x5dd03d=>!this[a2_0x32b5('0x0')][a2_0x32b5('0x3')][_0x5dd03d[a2_0x32b5('0x22')]])[a2_0x32b5('0x6')](_0x145906=>_0x145906[a2_0x32b5('0x22')]);if(_0x4de827['indexOf'](_0x433486)===-0x1){_0x4de827['push'](_0x433486);}const _0x20247f=this[a2_0x32b5('0x2a')][a2_0x32b5('0x1a')](this[a2_0x32b5('0x19')],_0x4de827);_0x4de827[a2_0x32b5('0x25')](_0x256ed6=>{this[a2_0x32b5('0x0')][a2_0x32b5('0x3')][_0x256ed6]=_0x20247f;});return(yield _0x20247f)[_0x433486];}});}[a2_0x32b5('0x1d')](){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x230a10=yield Promise[a2_0x32b5('0x2b')](this[a2_0x32b5('0x2e')])[a2_0x32b5('0x10')](_0xfcaab=>_0xfcaab[a2_0x32b5('0x7')]((_0x3d8c3b,_0x37c689)=>_0x3d8c3b&&_0x37c689,!![]));if(!_0x230a10){throw new Error(a2_0x32b5('0xe'));}});}}exports['CloudRemoteCache']=CloudRemoteCache;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudRemoteCache = void 0;
const environment_1 = require("../../../utilities/environment");
const { output } = require('../../../utilities/nx-imports');
class CloudRemoteCache {
constructor(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess) {
this.messages = messages;
this.api = api;
this.runContext = runContext;
this.fileStorage = fileStorage;
this.distributedExecutionId = distributedExecutionId;
this.storeInCurrentProcess = storeInCurrentProcess;
this.storeRequests = [];
this.delayedStoreRequests = [];
}
retrieve(hash, cacheDirectory) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
if (this.messages.cacheError)
return false;
const hashUrls = yield this.hashUrls(hash);
if (!hashUrls || !hashUrls.get) {
if (environment_1.VERBOSE_LOGGING) {
output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
}
this.runContext.statuses[hash] = 'cache-miss';
return false;
}
try {
yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
this.runContext.statuses[hash] = 'remote-cache-hit';
return true;
}
catch (ee) {
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
// TODO: vsavkin remove this handling Oct 2023
// 404 indicates that something is broken, but older versions
// of the api can result in such errors
// we ignore them for now
if (e.response && e.response.status === 404) {
if (environment_1.VERBOSE_LOGGING) {
output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
}
// cache miss. print nothing
}
else {
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
}
this.runContext.statuses[hash] = 'cache-miss';
return false;
}
});
}
store(hash, cacheDirectory) {
return __awaiter(this, void 0, void 0, function* () {
if (this.messages.cacheError)
return false;
const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
var _a;
const hashUrls = yield this.hashUrls(hash);
if (!hashUrls)
return false;
if (!hashUrls.put) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Nx Cloud: Skipping storing ${hash}.`,
bodyLines: [
`There are several reasons why this can happen.`,
`Maybe you are using a read-only token or the artifact has already being uploaded.`,
],
});
}
return true;
}
if (!this.storeInCurrentProcess) {
this.delayedStoreRequests.push({ hash: hash, url: hashUrls.put });
return true;
}
try {
yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
return true;
}
catch (ee) {
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
return false;
}
}));
this.storeRequests.push(res);
return res;
});
}
hashUrls(hash) {
return __awaiter(this, void 0, void 0, function* () {
if (hash in this.runContext.requests) {
return (yield this.runContext.requests[hash])[hash];
}
else {
const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
.filter((t) => !this.runContext.requests[t.hash])
.map((t) => t.hash);
if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
scheduledTaskHashesWithoutRequests.push(hash);
}
const request = this.api.startRun(this.distributedExecutionId, scheduledTaskHashesWithoutRequests);
scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
this.runContext.requests[taskHash] = request;
});
return (yield request)[hash];
}
});
}
waitForStoreRequestsToComplete() {
return __awaiter(this, void 0, void 0, function* () {
const res = yield Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
if (!res) {
throw new Error(`Error when storing artifacts`);
}
});
}
}
exports.CloudRemoteCache = CloudRemoteCache;
//# sourceMappingURL=cloud-remote-cache.js.map

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

const a3_0x135d=['post','extractErrorMessage','printDuration','RUNNER_FAILURE_PERF_ENTRY','message','done','gzip','zlib','__esModule','apiError','data','getRunGroup','toString','axiosException','apply','../../../utilities/is-private-cloud','axiosMultipleTries','nxCloudVersion','stringify','unknown','success','promisify','messages','assign','error','@nrwl/nx-cloud','runContext','nx-cloud','__awaiter','../../../utilities/nx-imports','note','map','recordMetric','createMetricRecorder','package.json','status','apiAxiosInstance','slice','getCIExecutionId','RunStart\x20duration','../../../utilities/metric-logger','then','terminalOutput','uploadedToStorage','RunEnd.\x20Completed\x20tasks','value','headers','util','/nx-cloud/runs/start','../../../utilities/axios','Stack\x20Trace:','createApiAxiosInstance','runUrl','RunStart','createReqBody','mapRespToPerfEntry','defineProperty','response','api','startRun','parse','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','devDependencies','Invalid\x20end\x20run\x20response:\x20','application/octet-stream','VERBOSE_LOGGING','endRun','machineInfo','urls','../../../utilities/environment','next','readFileSync','...','string','defaults','throw','length','/nx-cloud/runs/end'];(function(_0x1503ba,_0x135d70){const _0xaf14e2=function(_0x1e840e){while(--_0x1e840e){_0x1503ba['push'](_0x1503ba['shift']());}};_0xaf14e2(++_0x135d70);}(a3_0x135d,0xbc));const a3_0xaf14=function(_0x1503ba,_0x135d70){_0x1503ba=_0x1503ba-0x0;let _0xaf14e2=a3_0x135d[_0x1503ba];return _0xaf14e2;};'use strict';var __awaiter=this&&this[a3_0xaf14('0x4a')]||function(_0x3b844a,_0x2291ba,_0x544de1,_0x4c2019){function _0xfcb795(_0x57389f){return _0x57389f instanceof _0x544de1?_0x57389f:new _0x544de1(function(_0x2ae94c){_0x2ae94c(_0x57389f);});}return new(_0x544de1||(_0x544de1=Promise))(function(_0x2e9ec2,_0x3af6ec){function _0x228777(_0x1e0bac){try{_0x1a615b(_0x4c2019[a3_0xaf14('0x26')](_0x1e0bac));}catch(_0x55e06a){_0x3af6ec(_0x55e06a);}}function _0x161900(_0x319037){try{_0x1a615b(_0x4c2019[a3_0xaf14('0x2b')](_0x319037));}catch(_0x5b1835){_0x3af6ec(_0x5b1835);}}function _0x1a615b(_0x5a1a5c){_0x5a1a5c[a3_0xaf14('0x33')]?_0x2e9ec2(_0x5a1a5c['value']):_0xfcb795(_0x5a1a5c[a3_0xaf14('0xd')])[a3_0xaf14('0x9')](_0x228777,_0x161900);}_0x1a615b((_0x4c2019=_0x4c2019[a3_0xaf14('0x3c')](_0x3b844a,_0x2291ba||[]))[a3_0xaf14('0x26')]());});};Object[a3_0xaf14('0x18')](exports,a3_0xaf14('0x36'),{'value':!![]});exports['CloudRunApi']=void 0x0;const axios_1=require(a3_0xaf14('0x11'));const environment_1=require(a3_0xaf14('0x25'));const fs_1=require('fs');const zlib_1=require(a3_0xaf14('0x35'));const util_1=require(a3_0xaf14('0xf'));const metric_logger_1=require(a3_0xaf14('0x8'));const is_private_cloud_1=require(a3_0xaf14('0x3d'));const {output}=require(a3_0xaf14('0x4b'));class CloudRunApi{constructor(_0x25a61b,_0x1dcf1a,_0x460f06,_0x177ead){this[a3_0xaf14('0x44')]=_0x25a61b;this[a3_0xaf14('0x48')]=_0x1dcf1a;this[a3_0xaf14('0x23')]=_0x177ead;this[a3_0xaf14('0x4')]=(0x0,axios_1[a3_0xaf14('0x13')])(_0x460f06);}[a3_0xaf14('0x1b')](_0x98a27a,_0x43f15f){var _0x5463e2;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0xaf14('0x44')][a3_0xaf14('0x37')])return{};const _0x2f3371=(0x0,metric_logger_1[a3_0xaf14('0x1')])(a3_0xaf14('0x1b'));try{const _0x263df4={'meta':{'nxCloudVersion':this[a3_0xaf14('0x3f')]()},'branch':(0x0,environment_1['getBranch'])(),'runGroup':(0x0,environment_1[a3_0xaf14('0x39')])(),'ciExecutionId':(0x0,environment_1[a3_0xaf14('0x6')])(),'ciExecutionEnv':(0x0,environment_1['getCIExecutionEnv'])(),'distributedExecutionId':_0x98a27a,'hashes':_0x43f15f};if(environment_1['VERBOSE_LOGGING']){output[a3_0xaf14('0x4c')]({'title':a3_0xaf14('0x15'),'bodyLines':['\x0a'+JSON['stringify'](_0x263df4,null,0x2)]});}const _0x328366=yield(0x0,axios_1[a3_0xaf14('0x30')])(a3_0xaf14('0x7'),()=>(0x0,axios_1[a3_0xaf14('0x3e')])(()=>this[a3_0xaf14('0x4')]['post'](a3_0xaf14('0x10'),_0x263df4)));_0x2f3371[a3_0xaf14('0x0')]((0x0,metric_logger_1[a3_0xaf14('0x17')])(_0x328366));if(_0x328366[a3_0xaf14('0x38')]&&_0x328366[a3_0xaf14('0x38')]['message']){this[a3_0xaf14('0x44')][a3_0xaf14('0x32')]=_0x328366[a3_0xaf14('0x38')][a3_0xaf14('0x32')];}if(!_0x328366[a3_0xaf14('0x38')]||!_0x328366[a3_0xaf14('0x38')][a3_0xaf14('0x24')]){this[a3_0xaf14('0x44')][a3_0xaf14('0x37')]='Invalid\x20Nx\x20Cloud\x20response:\x20'+JSON[a3_0xaf14('0x40')](_0x328366[a3_0xaf14('0x38')]);return{};}return _0x328366[a3_0xaf14('0x38')][a3_0xaf14('0x24')];}catch(_0xe3691a){_0x2f3371['recordMetric'](((_0x5463e2=_0xe3691a===null||_0xe3691a===void 0x0?void 0x0:_0xe3691a[a3_0xaf14('0x3b')])===null||_0x5463e2===void 0x0?void 0x0:_0x5463e2[a3_0xaf14('0x19')])?(0x0,metric_logger_1[a3_0xaf14('0x17')])(_0xe3691a['axiosException'][a3_0xaf14('0x19')]):metric_logger_1[a3_0xaf14('0x31')]);this[a3_0xaf14('0x44')][a3_0xaf14('0x37')]=this['messages']['extractErrorMessage'](_0xe3691a,a3_0xaf14('0x1a'));return{};}});}[a3_0xaf14('0x16')](_0x28c523,_0x5dea67,_0x32f230,_0x1943cc){if((0x0,is_private_cloud_1['isConnectedToPrivateCloud'])()){for(let _0x4849d2 of _0x5dea67){delete _0x4849d2[a3_0xaf14('0xb')];}}const _0x180b1c=Object['assign'](Object[a3_0xaf14('0x45')]({'meta':{'nxCloudVersion':this['nxCloudVersion']()},'tasks':_0x5dea67,'run':_0x28c523,'linkId':_0x1943cc},(0x0,is_private_cloud_1['isConnectedToPrivateCloud'])()?{}:_0x32f230),{'machineInfo':this[a3_0xaf14('0x23')]});return JSON['stringify'](_0x180b1c);}[a3_0xaf14('0x22')](_0x2a8160,_0x5e1856,_0x31c32b,_0x40122e){var _0x506fb8,_0x4444dd;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0xaf14('0x44')][a3_0xaf14('0x37')])return![];let _0x4c165d=this[a3_0xaf14('0x16')](_0x2a8160,_0x5e1856,_0x31c32b,_0x40122e);if(_0x4c165d[a3_0xaf14('0x2c')]>0x14*0x3e8*0x3e8){_0x4c165d=this[a3_0xaf14('0x16')](_0x2a8160,_0x5e1856[a3_0xaf14('0x4d')](_0x241ccf=>Object[a3_0xaf14('0x45')](Object['assign']({},_0x241ccf),{'hashDetails':undefined})),_0x31c32b,_0x40122e);}const _0x17f696=Buffer['from'](_0x4c165d);const _0x5bb6d9=yield(0x0,util_1[a3_0xaf14('0x43')])(zlib_1[a3_0xaf14('0x34')])(_0x17f696);const _0x360122=(0x0,metric_logger_1[a3_0xaf14('0x1')])(a3_0xaf14('0x22'));try{if(environment_1[a3_0xaf14('0x21')]){const _0x293057=_0x5e1856[a3_0xaf14('0x4d')](_0x3a67c1=>{return Object[a3_0xaf14('0x45')](Object[a3_0xaf14('0x45')]({},_0x3a67c1),{'terminalOutput':_0x3a67c1[a3_0xaf14('0xa')]?_0x3a67c1[a3_0xaf14('0xa')][a3_0xaf14('0x5')](0x0,0x14)+a3_0xaf14('0x28'):undefined});});output[a3_0xaf14('0x4c')]({'title':a3_0xaf14('0xc'),'bodyLines':['\x0a'+JSON[a3_0xaf14('0x40')](_0x293057,null,0x2)]});}const _0x4b1a50=yield(0x0,axios_1[a3_0xaf14('0x30')])('RunEnd\x20duration',()=>(0x0,axios_1[a3_0xaf14('0x3e')])(()=>this['apiAxiosInstance'][a3_0xaf14('0x2e')](a3_0xaf14('0x2d'),_0x5bb6d9,{'headers':Object[a3_0xaf14('0x45')](Object[a3_0xaf14('0x45')]({},this[a3_0xaf14('0x4')][a3_0xaf14('0x2a')][a3_0xaf14('0xe')]),{'Content-Encoding':a3_0xaf14('0x34'),'Content-Type':a3_0xaf14('0x20')})})));if(_0x4b1a50){_0x360122['recordMetric']((0x0,metric_logger_1[a3_0xaf14('0x17')])(_0x4b1a50));if(_0x4b1a50[a3_0xaf14('0x38')]&&_0x4b1a50[a3_0xaf14('0x38')][a3_0xaf14('0x14')]&&_0x4b1a50['data'][a3_0xaf14('0x3')]===a3_0xaf14('0x42')){this[a3_0xaf14('0x48')][a3_0xaf14('0x14')]=_0x4b1a50[a3_0xaf14('0x38')][a3_0xaf14('0x14')];return!![];}if(_0x4b1a50['data']&&_0x4b1a50[a3_0xaf14('0x38')][a3_0xaf14('0x3')]){this['messages'][a3_0xaf14('0x37')]=a3_0xaf14('0x1f')+JSON[a3_0xaf14('0x40')](_0x4b1a50[a3_0xaf14('0x38')][a3_0xaf14('0x32')]);}else if(_0x4b1a50[a3_0xaf14('0x38')]&&typeof _0x4b1a50[a3_0xaf14('0x38')]===a3_0xaf14('0x29')){if(_0x4b1a50[a3_0xaf14('0x38')]!=='success'){this[a3_0xaf14('0x44')][a3_0xaf14('0x37')]=a3_0xaf14('0x1f')+JSON[a3_0xaf14('0x40')](_0x4b1a50[a3_0xaf14('0x38')]);}}else{this['messages'][a3_0xaf14('0x37')]='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0xaf14('0x40')](_0x4b1a50['data']);}if(environment_1[a3_0xaf14('0x21')]){output[a3_0xaf14('0x4c')]({'title':'Invalid\x20end\x20run\x20response','bodyLines':[JSON[a3_0xaf14('0x40')](_0x4b1a50[a3_0xaf14('0x38')],null,0x2)]});}}else{output[a3_0xaf14('0x46')]({'title':a3_0xaf14('0x1d'),'bodyLines':['Run\x20completion\x20responded\x20with\x20`undefined`.','Run\x20Details:',JSON[a3_0xaf14('0x40')](_0x2a8160,null,0x2),a3_0xaf14('0x12'),JSON['stringify'](new Error()['stack'],null,0x2)]});}return![];}catch(_0x5e7619){_0x360122[a3_0xaf14('0x0')](((_0x506fb8=_0x5e7619===null||_0x5e7619===void 0x0?void 0x0:_0x5e7619[a3_0xaf14('0x3b')])===null||_0x506fb8===void 0x0?void 0x0:_0x506fb8[a3_0xaf14('0x19')])?(0x0,metric_logger_1[a3_0xaf14('0x17')])(_0x5e7619[a3_0xaf14('0x3b')][a3_0xaf14('0x19')]):metric_logger_1[a3_0xaf14('0x31')]);const _0x3d5bbb=(_0x4444dd=_0x5e7619['axiosException'])!==null&&_0x4444dd!==void 0x0?_0x4444dd:_0x5e7619;this[a3_0xaf14('0x44')]['apiError']=this['messages'][a3_0xaf14('0x2f')](_0x3d5bbb,'api');return![];}});}[a3_0xaf14('0x3f')](){try{const _0x356842=JSON[a3_0xaf14('0x1c')]((0x0,fs_1[a3_0xaf14('0x27')])(a3_0xaf14('0x2'))[a3_0xaf14('0x3a')]());return _0x356842[a3_0xaf14('0x1e')][a3_0xaf14('0x49')]||_0x356842['devDependencies'][a3_0xaf14('0x47')];}catch(_0x58fba4){return a3_0xaf14('0x41');}}}exports['CloudRunApi']=CloudRunApi;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudRunApi = void 0;
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const fs_1 = require("fs");
const zlib_1 = require("zlib");
const util_1 = require("util");
const metric_logger_1 = require("../../../utilities/metric-logger");
const is_private_cloud_1 = require("../../../utilities/is-private-cloud");
const { output } = require('../../../utilities/nx-imports');
class CloudRunApi {
constructor(messages, runContext, options, machineInfo) {
this.messages = messages;
this.runContext = runContext;
this.machineInfo = machineInfo;
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
startRun(distributedExecutionId, hashes) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
// API is not working, don't make the end request
if (this.messages.apiError)
return {};
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
try {
const request = {
meta: {
nxCloudVersion: this.nxCloudVersion(),
},
branch: (0, environment_1.getBranch)(),
runGroup: (0, environment_1.getRunGroup)(),
ciExecutionId: (0, environment_1.getCIExecutionId)(),
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
distributedExecutionId,
hashes,
};
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'RunStart',
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
});
}
const resp = yield (0, axios_1.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request)));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
if (resp.data && resp.data.message) {
this.messages.message = resp.data.message;
}
if (!resp.data || !resp.data.urls) {
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
return {};
}
return resp.data.urls;
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
return {};
}
});
}
createReqBody(run, tasks, ciExecutionContext, linkId) {
if ((0, is_private_cloud_1.isConnectedToPrivateCloud)()) {
for (let t of tasks) {
delete t.uploadedToStorage;
}
}
const uncompressedReqBody = Object.assign(Object.assign({ meta: {
nxCloudVersion: this.nxCloudVersion(),
}, tasks,
run,
linkId }, ((0, is_private_cloud_1.isConnectedToPrivateCloud)() ? {} : ciExecutionContext)), { machineInfo: this.machineInfo });
return JSON.stringify(uncompressedReqBody);
}
endRun(run, tasks, ciExecutionContext, linkId) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
// API is not working, don't make the end request
if (this.messages.apiError)
return false;
let uncompressedBodyString = this.createReqBody(run, tasks, ciExecutionContext, linkId);
// if the req body is > 20mb, remove hashDetails
if (uncompressedBodyString.length > 20 * 1000 * 1000) {
uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))), ciExecutionContext, linkId);
}
const uncompressedBuffer = Buffer.from(uncompressedBodyString);
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
try {
if (environment_1.VERBOSE_LOGGING) {
const t = tasks.map((tt) => {
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
? `${tt.terminalOutput.slice(0, 20)}...`
: undefined });
});
output.note({
title: 'RunEnd. Completed tasks',
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
});
}
const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
})));
if (resp) {
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
this.runContext.runUrl = resp.data.runUrl;
return true;
}
if (resp.data && resp.data.status) {
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
}
else if (resp.data && typeof resp.data === 'string') {
if (resp.data !== 'success') {
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
}
}
else {
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
}
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Invalid end run response',
bodyLines: [JSON.stringify(resp.data, null, 2)],
});
}
}
else {
output.error({
title: 'Nx Cloud: Unknown Error Occurred',
bodyLines: [
'Run completion responded with `undefined`.',
'Run Details:',
JSON.stringify(run, null, 2),
'Stack Trace:',
JSON.stringify(new Error().stack, null, 2),
],
});
}
return false;
}
catch (ee) {
recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
return false;
}
});
}
nxCloudVersion() {
try {
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
return (v.devDependencies['nx-cloud'] || v.devDependencies['@nrwl/nx-cloud']);
}
catch (e) {
return 'unknown';
}
}
}
exports.CloudRunApi = CloudRunApi;
//# sourceMappingURL=cloud-run.api.js.map

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

const a4_0x1da6=['floor','length','0123456789','ABCDEFGHIJKLMNOPQRSTUVWXYZ','random','defineProperty','__esModule'];(function(_0x4da066,_0x1da6c3){const _0x5253a9=function(_0x40a3ae){while(--_0x40a3ae){_0x4da066['push'](_0x4da066['shift']());}};_0x5253a9(++_0x1da6c3);}(a4_0x1da6,0x1aa));const a4_0x5253=function(_0x4da066,_0x1da6c3){_0x4da066=_0x4da066-0x0;let _0x5253a9=a4_0x1da6[_0x4da066];return _0x5253a9;};'use strict';Object[a4_0x5253('0x6')](exports,a4_0x5253('0x0'),{'value':!![]});exports['generateUniqueLinkId']=void 0x0;const upper=a4_0x5253('0x4');const digits=a4_0x5253('0x3');const lower=upper['toLowerCase']();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x2fd6d1='';for(let _0xb930e0=0x0;_0xb930e0<0xa;++_0xb930e0){_0x2fd6d1+=alphanum[Math[a4_0x5253('0x1')](Math[a4_0x5253('0x5')]()*alphanum[a4_0x5253('0x2')])];}return _0x2fd6d1;}exports['generateUniqueLinkId']=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_0x473d=['__esModule','Completed\x20run\x20group\x20with\x20an\x20error','../../../utilities/axios','post','DistributedAgentApi','recordMetric','apiAxiosInstance','value','axiosMultipleTries','mapRespToPerfEntry','ciExecutionEnv:\x20','throw','ciExecutionId','ciExecutionId:\x20','error:\x20','ciExecutionEnv','data','response','defineProperty','completeRunGroup','note','createMetricRecorder','RUNNER_FAILURE_PERF_ENTRY','axiosException','then','branch','/nx-cloud/executions/tasks','error','createApiAxiosInstance','agentName','runGroup','next','Completing\x20with\x20an\x20error'];(function(_0x5c0c37,_0x473dee){const _0x66c76d=function(_0x534c03){while(--_0x534c03){_0x5c0c37['push'](_0x5c0c37['shift']());}};_0x66c76d(++_0x473dee);}(a5_0x473d,0x1e7));const a5_0x66c7=function(_0x5c0c37,_0x473dee){_0x5c0c37=_0x5c0c37-0x0;let _0x66c76d=a5_0x473d[_0x5c0c37];return _0x66c76d;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x4b3748,_0x3f1047,_0x12cb1a,_0x4a37d0){function _0x5e06db(_0x24d558){return _0x24d558 instanceof _0x12cb1a?_0x24d558:new _0x12cb1a(function(_0x5f4008){_0x5f4008(_0x24d558);});}return new(_0x12cb1a||(_0x12cb1a=Promise))(function(_0x3c52b3,_0x1db2e1){function _0x433aee(_0x112d41){try{_0x4fc880(_0x4a37d0[a5_0x66c7('0x6')](_0x112d41));}catch(_0x1dae8c){_0x1db2e1(_0x1dae8c);}}function _0x47b938(_0x6df6cd){try{_0x4fc880(_0x4a37d0[a5_0x66c7('0x13')](_0x6df6cd));}catch(_0x2d9065){_0x1db2e1(_0x2d9065);}}function _0x4fc880(_0x4ae125){_0x4ae125['done']?_0x3c52b3(_0x4ae125[a5_0x66c7('0xf')]):_0x5e06db(_0x4ae125['value'])[a5_0x66c7('0x20')](_0x433aee,_0x47b938);}_0x4fc880((_0x4a37d0=_0x4a37d0['apply'](_0x4b3748,_0x3f1047||[]))[a5_0x66c7('0x6')]());});};Object[a5_0x66c7('0x1a')](exports,a5_0x66c7('0x8'),{'value':!![]});exports['DistributedAgentApi']=void 0x0;const axios_1=require(a5_0x66c7('0xa'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require('../../../utilities/metric-logger');const {output}=require('../../../utilities/nx-imports');class DistributedAgentApi{constructor(_0x16b1ef,_0x1fed7a,_0x1236ea,_0x557d51,_0x4da1c6,_0x3703c1){this['branch']=_0x1fed7a;this[a5_0x66c7('0x5')]=_0x1236ea;this[a5_0x66c7('0x14')]=_0x557d51;this[a5_0x66c7('0x17')]=_0x4da1c6;this[a5_0x66c7('0x4')]=_0x3703c1;this[a5_0x66c7('0xe')]=(0x0,axios_1[a5_0x66c7('0x3')])(_0x16b1ef);}['tasks'](_0x13733c,_0x560cab,_0x118ef3,_0x3f3148){var _0x55c9e5;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3b514d=(0x0,metric_logger_1[a5_0x66c7('0x1d')])('dtePollTasks');try{const _0x50a03d=yield(0x0,axios_1[a5_0x66c7('0x10')])(()=>this[a5_0x66c7('0xe')][a5_0x66c7('0xb')](a5_0x66c7('0x1'),{'runGroup':this[a5_0x66c7('0x5')],'ciExecutionId':this[a5_0x66c7('0x14')],'ciExecutionEnv':this['ciExecutionEnv'],'agentName':this[a5_0x66c7('0x4')],'executionId':_0x13733c,'statusCode':_0x560cab,'completedTasks':_0x118ef3,'targets':_0x3f3148}));_0x3b514d['recordMetric']((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x50a03d));return _0x50a03d[a5_0x66c7('0x18')];}catch(_0x2fe5b1){_0x3b514d[a5_0x66c7('0xd')](((_0x55c9e5=_0x2fe5b1===null||_0x2fe5b1===void 0x0?void 0x0:_0x2fe5b1['axiosException'])===null||_0x55c9e5===void 0x0?void 0x0:_0x55c9e5[a5_0x66c7('0x19')])?(0x0,metric_logger_1[a5_0x66c7('0x11')])(_0x2fe5b1[a5_0x66c7('0x1f')][a5_0x66c7('0x19')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);throw _0x2fe5b1;}});}['completeRunGroupWithError'](_0x2fbea5){var _0x4df67a;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1['VERBOSE_LOGGING']){output[a5_0x66c7('0x1c')]({'title':a5_0x66c7('0x7'),'bodyLines':[a5_0x66c7('0x15')+this[a5_0x66c7('0x14')],a5_0x66c7('0x12')+this['ciExecutionEnv'],'runGroup:\x20'+this[a5_0x66c7('0x5')],a5_0x66c7('0x16')+_0x2fbea5]});}const _0x20528a=(0x0,metric_logger_1[a5_0x66c7('0x1d')])(a5_0x66c7('0x1b'));try{const _0x199183=yield(0x0,axios_1[a5_0x66c7('0x10')])(()=>this[a5_0x66c7('0xe')][a5_0x66c7('0xb')]('/nx-cloud/executions/complete-run-group',{'branch':this[a5_0x66c7('0x0')],'runGroup':this['runGroup'],'ciExecutionId':this['ciExecutionId'],'ciExecutionEnv':this[a5_0x66c7('0x17')],'agentName':this[a5_0x66c7('0x4')],'criticalErrorMessage':_0x2fbea5}));if(environment_1['VERBOSE_LOGGING']){output[a5_0x66c7('0x1c')]({'title':a5_0x66c7('0x9')});}_0x20528a['recordMetric']((0x0,metric_logger_1[a5_0x66c7('0x11')])(_0x199183));}catch(_0x12431a){_0x20528a[a5_0x66c7('0xd')](((_0x4df67a=_0x12431a===null||_0x12431a===void 0x0?void 0x0:_0x12431a[a5_0x66c7('0x1f')])===null||_0x4df67a===void 0x0?void 0x0:_0x4df67a[a5_0x66c7('0x19')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x12431a[a5_0x66c7('0x1f')][a5_0x66c7('0x19')]):metric_logger_1[a5_0x66c7('0x1e')]);console[a5_0x66c7('0x2')](_0x12431a);}});}}exports[a5_0x66c7('0xc')]=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_0x5519=['env','readdirSync','DistributedAgentApi','targets','CIRCLE_STAGE','throw','ENCRYPTION_KEY','encryptionKey','some','Critical\x20Error\x20in\x20Agent:\x20\x22','../../file-storage/e2e-encryption','../../error/print-run-group-error','floor','includes','tasksRunnerOptions','join','../../error/print-invalid-runner-error','note','exit','Distributed\x20Task\x20Execution\x20is\x20disabled\x20when\x20your\x20workspace\x20is\x20disabled','./invoke-tasks-using-nx-imperative-api','map','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','ErrorReporterApi','../../file-storage/file-storage','readFileSync','__awaiter','split','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','Other\x20Nx\x20Cloud\x20Agents\x20Detected','strip-json-comments','message','NX_AGENT_NAME','./invoke-tasks-using-run-many','Nx\x20Cloud:\x20Workspace\x20is\x20disabled','../../../utilities/is-workspace-enabled','argv','Agent\x20was\x20terminated\x20via\x20SIGINT','existsSync','Organization\x20administrators\x20can\x20find\x20more\x20information\x20on\x20the\x20\x27Billing\x20and\x20Plans\x27\x20page\x20in\x20the\x20Nx\x20Cloud\x20Webapp','trim','printInvalidRunnerError','value','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','SIGINT','submitRunMetrics','../../../utilities/nx-imports','executeTasks','next','yargs-parser','done','length','CIRCLE_JOB','./distributed-agent.api','isWorkspaceEnabled','nx-cloud','error','filter','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','canDetectRunGroup','__esModule','parse','getRunGroup','getCIExecutionId','writeFileSync','DteArtifactStorage','../../../utilities/metric-logger','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','Agent\x20was\x20terminated\x20via\x20SIGTERM','runner','Duplicate\x20Agent\x20ID\x20Detected','random','E2EEncryption','getBranch','warn','toString','printRunGroupError','then','startAgent','Agent\x20','/lockfiles','FileStorage','@nrwl/nx-cloud','CIRCLECI','cacheableOperations','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20[','getCIExecutionEnv','.lock','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','unlinkSync','completeRunGroupWithError'];(function(_0xef0481,_0x55195e){const _0x6929e=function(_0x4492f){while(--_0x4492f){_0xef0481['push'](_0xef0481['shift']());}};_0x6929e(++_0x55195e);}(a6_0x5519,0xa2));const a6_0x6929=function(_0xef0481,_0x55195e){_0xef0481=_0xef0481-0x0;let _0x6929e=a6_0x5519[_0xef0481];return _0x6929e;};'use strict';var __awaiter=this&&this[a6_0x6929('0x2e')]||function(_0x3874a0,_0x170d08,_0x368b51,_0x747716){function _0x635229(_0x3a479f){return _0x3a479f instanceof _0x368b51?_0x3a479f:new _0x368b51(function(_0x4b3288){_0x4b3288(_0x3a479f);});}return new(_0x368b51||(_0x368b51=Promise))(function(_0x137945,_0x4baaa1){function _0x2be676(_0x8a38e1){try{_0x3f620c(_0x747716['next'](_0x8a38e1));}catch(_0x523ed0){_0x4baaa1(_0x523ed0);}}function _0x593d72(_0x2347de){try{_0x3f620c(_0x747716[a6_0x6929('0x19')](_0x2347de));}catch(_0x569151){_0x4baaa1(_0x569151);}}function _0x3f620c(_0xa7950e){_0xa7950e[a6_0x6929('0x46')]?_0x137945(_0xa7950e[a6_0x6929('0x3e')]):_0x635229(_0xa7950e['value'])[a6_0x6929('0x6')](_0x2be676,_0x593d72);}_0x3f620c((_0x747716=_0x747716['apply'](_0x3874a0,_0x170d08||[]))[a6_0x6929('0x44')]());});};Object['defineProperty'](exports,a6_0x6929('0x50'),{'value':!![]});exports[a6_0x6929('0x7')]=void 0x0;const fs_1=require('fs');const stripJsonComments=require(a6_0x6929('0x32'));const yargsParser=require(a6_0x6929('0x45'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a6_0x6929('0x56'));const print_cacheable_targets_error_1=require('../../error/print-cacheable-targets-error');const print_invalid_runner_error_1=require(a6_0x6929('0x24'));const print_run_group_error_1=require(a6_0x6929('0x1f'));const distributed_agent_api_1=require(a6_0x6929('0x49'));const execute_tasks_1=require('./execute-tasks');const dte_artifact_storage_1=require('../../../utilities/dte-artifact-storage');const file_storage_1=require(a6_0x6929('0x2c'));const e2e_encryption_1=require(a6_0x6929('0x1e'));const error_reporter_api_1=require('../../api/error-reporter.api');const invoke_tasks_using_run_many_1=require(a6_0x6929('0x35'));const invoke_tasks_using_nx_imperative_api_1=require(a6_0x6929('0x28'));const is_workspace_enabled_1=require(a6_0x6929('0x37'));const {output,initTasksRunner,workspaceRoot,cacheDirectory}=require(a6_0x6929('0x42'));const args=yargsParser(process[a6_0x6929('0x38')],{'array':['targets'],'default':{}});if(args[a6_0x6929('0x17')]&&args[a6_0x6929('0x17')][a6_0x6929('0x47')]===0x1){args[a6_0x6929('0x17')]=args[a6_0x6929('0x17')][0x0][a6_0x6929('0x2f')](',')[a6_0x6929('0x29')](_0x37d48f=>_0x37d48f[a6_0x6929('0x3c')]());}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x8dbc8e=(0x0,environment_1[a6_0x6929('0x2')])();const _0x5735aa=(0x0,environment_1[a6_0x6929('0x52')])();const _0x7befde=(0x0,environment_1[a6_0x6929('0x53')])();const _0x24cd4c=(0x0,environment_1[a6_0x6929('0xf')])();if(!(0x0,print_run_group_error_1[a6_0x6929('0x4f')])(_0x5735aa,_0x7befde)){(0x0,print_run_group_error_1[a6_0x6929('0x5')])();process['exit'](0x1);}if(args[a6_0x6929('0x17')]&&args['targets']['length']){output[a6_0x6929('0x25')]({'title':a6_0x6929('0xe')+args[a6_0x6929('0x17')][a6_0x6929('0x23')](',\x20')+']'});}else{output['note']({'title':a6_0x6929('0x57')});}const _0x2fda43=JSON[a6_0x6929('0x51')](stripJsonComments((0x0,fs_1[a6_0x6929('0x2d')])(workspaceRoot+'/nx.json')[a6_0x6929('0x4')]()))[a6_0x6929('0x22')]['default'];if(_0x2fda43[a6_0x6929('0x59')]!==a6_0x6929('0x4b')&&_0x2fda43['runner']!==a6_0x6929('0xb')){(0x0,print_invalid_runner_error_1[a6_0x6929('0x3d')])();return process[a6_0x6929('0x26')](0x1);}const _0x32f1a6=_0x2fda43['options'];if(args[a6_0x6929('0x17')]&&args[a6_0x6929('0x17')][a6_0x6929('0x1c')](_0x3e8f81=>{var _0x501634;return!((_0x501634=_0x32f1a6['cacheableOperations'])===null||_0x501634===void 0x0?void 0x0:_0x501634['includes'](_0x3e8f81));})){const _0x2a67a1=args[a6_0x6929('0x17')][a6_0x6929('0x4d')](_0x1f9c64=>{var _0x25d91a;return!((_0x25d91a=_0x32f1a6[a6_0x6929('0xd')])===null||_0x25d91a===void 0x0?void 0x0:_0x25d91a[a6_0x6929('0x21')](_0x1f9c64));});(0x0,print_cacheable_targets_error_1['printCacheableTargetsError'])(_0x2a67a1);return process[a6_0x6929('0x26')](0x1);}const _0x1e065c=yield(0x0,is_workspace_enabled_1[a6_0x6929('0x4a')])(_0x32f1a6);if(!_0x1e065c){output['error']({'title':a6_0x6929('0x36'),'bodyLines':[a6_0x6929('0x27'),'',a6_0x6929('0x3b')]});process[a6_0x6929('0x26')](0x1);}const _0xedd047=getAgentName();const _0x237562=new distributed_agent_api_1[(a6_0x6929('0x16'))](_0x32f1a6,_0x8dbc8e,_0x5735aa,_0x7befde,_0x24cd4c,_0xedd047);createAgentLockfileAndSetUpListeners(_0x237562,_0x32f1a6,_0xedd047);const _0x3f9023=new e2e_encryption_1[(a6_0x6929('0x1'))](environment_1[a6_0x6929('0x1a')]||_0x32f1a6[a6_0x6929('0x1b')]);const _0x4e12e3=new error_reporter_api_1[(a6_0x6929('0x2b'))](_0x32f1a6);const _0x1aa783=new dte_artifact_storage_1[(a6_0x6929('0x55'))](new file_storage_1[(a6_0x6929('0xa'))](_0x3f9023,_0x4e12e3,_0x32f1a6,'dte-agent'),cacheDirectory);const _0xa3da46=initTasksRunner?yield(0x0,invoke_tasks_using_nx_imperative_api_1['invokeTasksUsingNxImperativeApi'])(_0x32f1a6):yield(0x0,invoke_tasks_using_run_many_1['invokeTasksUsingRunMany'])();return(0x0,execute_tasks_1[a6_0x6929('0x43')])(_0xedd047,_0x237562,_0x1aa783,_0xa3da46,args['targets'])[a6_0x6929('0x6')](_0x104ae8=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a6_0x6929('0x41')])(_0x32f1a6);return _0x104ae8;}))['catch'](_0x478d36=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x237562[a6_0x6929('0x13')](a6_0x6929('0x1d')+_0x478d36[a6_0x6929('0x33')]+'\x22');throw _0x478d36;}));});}exports[a6_0x6929('0x7')]=startAgent;function getAgentName(){if(process[a6_0x6929('0x14')][a6_0x6929('0x34')]!==undefined){return process['env'][a6_0x6929('0x34')];}else if(process[a6_0x6929('0x14')][a6_0x6929('0xc')]!==undefined&&process[a6_0x6929('0x14')][a6_0x6929('0x18')]){return process['env']['CIRCLE_STAGE'];}else if(process[a6_0x6929('0x14')][a6_0x6929('0xc')]!==undefined&&process[a6_0x6929('0x14')][a6_0x6929('0x48')]){return process[a6_0x6929('0x14')][a6_0x6929('0x48')];}else{return a6_0x6929('0x8')+Math[a6_0x6929('0x20')](Math[a6_0x6929('0x0')]()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x29eefb,_0x2cf3ab,_0xa8f37){const _0xd70e07=cacheDirectory+a6_0x6929('0x9');const _0x10f79e=_0xd70e07+'/'+_0xa8f37+a6_0x6929('0x10');if(!(0x0,fs_1[a6_0x6929('0x3a')])(_0xd70e07)){(0x0,fs_1['mkdirSync'])(_0xd70e07,{'recursive':!![]});}const _0x4e9388=(0x0,fs_1[a6_0x6929('0x15')])(_0xd70e07);if(_0x4e9388[a6_0x6929('0x47')]){if(_0x4e9388[a6_0x6929('0x21')](_0xa8f37+'.lock')){output[a6_0x6929('0x4c')]({'title':a6_0x6929('0x5a'),'bodyLines':[a6_0x6929('0x3f'),'',a6_0x6929('0x2a')]});process[a6_0x6929('0x26')](0x1);}output[a6_0x6929('0x3')]({'title':a6_0x6929('0x31'),'bodyLines':[a6_0x6929('0x30'),'',a6_0x6929('0x4e'),a6_0x6929('0x11')]});}(0x0,fs_1[a6_0x6929('0x54')])(_0x10f79e,'');process['on']('exit',_0x488c3e=>{cleanupAgentLockfile(_0x10f79e,_0x488c3e);});process['on']('SIGTERM',()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x29eefb[a6_0x6929('0x13')](a6_0x6929('0x58'));cleanupAgentLockfile(_0x10f79e,0x1);}));process['on'](a6_0x6929('0x40'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x29eefb['completeRunGroupWithError'](a6_0x6929('0x39'));cleanupAgentLockfile(_0x10f79e,0x1);}));}function cleanupAgentLockfile(_0x747b54,_0x49b4ee){if((0x0,fs_1[a6_0x6929('0x3a')])(_0x747b54)){(0x0,fs_1[a6_0x6929('0x12')])(_0x747b54);process[a6_0x6929('0x26')](_0x49b4ee);}}
"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_0x4993=['wait','reset','../../../utilities/create-unchanged-value-timeout','executeTasks','\x20downloading\x20artifacts\x20for\x20','\x20Url:\x20','throw','\x20seconds','value','No\x20new\x20messages\x20received\x20after\x20','createUnchangedValueTimeout','executionId','exit','url','note','\x20waiting...','status','apply','completed','retrieveAndExtract','tasks','executionId:\x20','hash','__esModule','__awaiter','number\x20of\x20tasks:\x20','getTime','retryDuring:\x20','join','done','../../../utilities/nx-imports','Distributed\x20Execution\x20Terminated','\x20Hash:\x20','taskId','\x20fetching\x20tasks...','map','completedTasks','../../../utilities/waiter','completed:\x20','status:\x20','error:\x20','criticalErrorMessage','VERBOSE_LOGGING','Waiter','error','retryDuring'];(function(_0xd1e0dc,_0x4993f4){const _0x56301c=function(_0x2f12f6){while(--_0x2f12f6){_0xd1e0dc['push'](_0xd1e0dc['shift']());}};_0x56301c(++_0x4993f4);}(a7_0x4993,0x9b));const a7_0x5630=function(_0xd1e0dc,_0x4993f4){_0xd1e0dc=_0xd1e0dc-0x0;let _0x56301c=a7_0x4993[_0xd1e0dc];return _0x56301c;};'use strict';var __awaiter=this&&this[a7_0x5630('0x7')]||function(_0x238705,_0x163040,_0x3603ad,_0x3e464a){function _0x39ca7e(_0x417598){return _0x417598 instanceof _0x3603ad?_0x417598:new _0x3603ad(function(_0x32b784){_0x32b784(_0x417598);});}return new(_0x3603ad||(_0x3603ad=Promise))(function(_0x380089,_0x70efc4){function _0x4a7cb5(_0x47f82f){try{_0x5a177c(_0x3e464a['next'](_0x47f82f));}catch(_0x3aa9fd){_0x70efc4(_0x3aa9fd);}}function _0x3d7001(_0x597f7e){try{_0x5a177c(_0x3e464a[a7_0x5630('0x23')](_0x597f7e));}catch(_0x4b665b){_0x70efc4(_0x4b665b);}}function _0x5a177c(_0x2fbd3d){_0x2fbd3d[a7_0x5630('0xc')]?_0x380089(_0x2fbd3d['value']):_0x39ca7e(_0x2fbd3d[a7_0x5630('0x25')])['then'](_0x4a7cb5,_0x3d7001);}_0x5a177c((_0x3e464a=_0x3e464a[a7_0x5630('0x0')](_0x238705,_0x163040||[]))['next']());});};Object['defineProperty'](exports,a7_0x5630('0x6'),{'value':!![]});exports[a7_0x5630('0x20')]=void 0x0;const create_unchanged_value_timeout_1=require(a7_0x5630('0x1f'));const environment_1=require('../../../utilities/environment');const waiter_1=require(a7_0x5630('0x14'));const {output}=require(a7_0x5630('0xd'));function executeTasks(_0x3fdfc9,_0x380015,_0x38a58d,_0x22b9f6,_0x23cb25){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x3efe8e=0x0;let _0x29d34d=null;const _0x5cf4b9=(0x0,create_unchanged_value_timeout_1[a7_0x5630('0x27')])({'title':a7_0x5630('0x26')+environment_1['NO_MESSAGES_TIMEOUT']/0x3e8+a7_0x5630('0x24'),'timeout':environment_1['NO_MESSAGES_TIMEOUT']});const _0xc4a6b8=new waiter_1[(a7_0x5630('0x1a'))]();let _0x2235e5=[];const _0x4b23bc=new Date();let _0x597f66=![];const _0x1dfa5a={};while(!![]){if(environment_1[a7_0x5630('0x19')]){output[a7_0x5630('0x2b')]({'title':_0x3fdfc9+a7_0x5630('0x11')});}_0x29d34d=yield _0x380015[a7_0x5630('0x3')](_0x29d34d?_0x29d34d[a7_0x5630('0x28')]:null,_0x3efe8e,_0x2235e5,_0x23cb25);if(environment_1[a7_0x5630('0x19')]){output[a7_0x5630('0x2b')]({'title':_0x3fdfc9+'\x20received\x20an\x20API\x20Response','bodyLines':[a7_0x5630('0x15')+_0x29d34d[a7_0x5630('0x1')],a7_0x5630('0x16')+_0x29d34d[a7_0x5630('0x2d')],a7_0x5630('0xa')+_0x29d34d[a7_0x5630('0x1c')],a7_0x5630('0x4')+_0x29d34d[a7_0x5630('0x28')],a7_0x5630('0x8')+_0x29d34d[a7_0x5630('0x3')]['length'],a7_0x5630('0x17')+_0x29d34d[a7_0x5630('0x18')],'maxParallel:\x20'+_0x29d34d['maxParallel']]});}if(_0x29d34d[a7_0x5630('0x18')]){output[a7_0x5630('0x1b')]({'title':a7_0x5630('0xe'),'bodyLines':['Error:',_0x29d34d[a7_0x5630('0x18')]]});process[a7_0x5630('0x29')](0x0);}if((_0x29d34d===null||_0x29d34d===void 0x0?void 0x0:_0x29d34d['retryDuring'])&&(_0x29d34d===null||_0x29d34d===void 0x0?void 0x0:_0x29d34d['retryDuring'])!==0x0&&!_0x597f66&&new Date()[a7_0x5630('0x9')]()-_0x4b23bc['getTime']()>_0x29d34d[a7_0x5630('0x1c')]){yield _0xc4a6b8[a7_0x5630('0x1d')]();continue;}if((_0x29d34d===null||_0x29d34d===void 0x0?void 0x0:_0x29d34d[a7_0x5630('0x2d')])!==undefined){if(_0x29d34d['status']==='RUN_GROUP_COMPLETED'||_0x29d34d[a7_0x5630('0x2d')]==='NO_FURTHER_TASKS_TO_RUN'){return;}}else if(_0x29d34d[a7_0x5630('0x1')]){return;}_0x5cf4b9(_0x29d34d[a7_0x5630('0x3')][a7_0x5630('0x12')](_0x4b5153=>_0x4b5153[a7_0x5630('0x10')])[a7_0x5630('0xb')](''));if(!_0x29d34d['executionId']){if(environment_1['VERBOSE_LOGGING']){output[a7_0x5630('0x2b')]({'title':_0x3fdfc9+a7_0x5630('0x2c')});}yield _0xc4a6b8[a7_0x5630('0x1d')]();_0x3efe8e=0x0;_0x2235e5=[];continue;}_0xc4a6b8[a7_0x5630('0x1e')]();_0x597f66=!![];if(_0x29d34d[a7_0x5630('0x13')]){for(const _0x1452e9 of _0x29d34d[a7_0x5630('0x13')]){if(_0x1dfa5a[_0x1452e9[a7_0x5630('0x10')]])continue;output[a7_0x5630('0x2b')]({'title':_0x3fdfc9+a7_0x5630('0x21')+_0x1452e9['taskId']+a7_0x5630('0xf')+_0x1452e9[a7_0x5630('0x5')]+a7_0x5630('0x22')+_0x1452e9[a7_0x5630('0x2a')]});yield _0x38a58d[a7_0x5630('0x2')](_0x1452e9[a7_0x5630('0x5')],_0x1452e9[a7_0x5630('0x2a')]);_0x1dfa5a[_0x1452e9['taskId']]=!![];}}const _0xb18410=yield _0x22b9f6(_0x29d34d[a7_0x5630('0x28')],_0x29d34d[a7_0x5630('0x3')],_0x29d34d['maxParallel']);for(const _0x2b984f of _0xb18410[a7_0x5630('0x13')]){_0x1dfa5a[_0x2b984f[a7_0x5630('0x10')]]=!![];}_0x3efe8e=_0xb18410['completedStatusCode'];_0x2235e5=_0xb18410[a7_0x5630('0x13')];}});}exports[a7_0x5630('0x20')]=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_0x59b1=['__esModule','tasks','env','done','yargs-parser','true','apply','throw','length','__awaiter','next','invokeTasksUsingNxImperativeApi','value','taskGraph','projectName','params','../../../utilities/serializer-overrides','invoke','NX_PREFIX_OUTPUT','unparse','hash','taskId','assign','NX_STREAM_OUTPUT','target','map','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','../../../utilities/nx-imports'];(function(_0x236642,_0x59b1bb){const _0x3e773d=function(_0x47cb83){while(--_0x47cb83){_0x236642['push'](_0x236642['shift']());}};_0x3e773d(++_0x59b1bb);}(a8_0x59b1,0xf8));const a8_0x3e77=function(_0x236642,_0x59b1bb){_0x236642=_0x236642-0x0;let _0x3e773d=a8_0x59b1[_0x236642];return _0x3e773d;};'use strict';var __awaiter=this&&this[a8_0x3e77('0xd')]||function(_0x132f69,_0x1eafcc,_0x17c77c,_0xf6b0b6){function _0x442862(_0x1c4d39){return _0x1c4d39 instanceof _0x17c77c?_0x1c4d39:new _0x17c77c(function(_0x186751){_0x186751(_0x1c4d39);});}return new(_0x17c77c||(_0x17c77c=Promise))(function(_0xe53de4,_0x161aab){function _0x4173c8(_0x34fbd1){try{_0x25f569(_0xf6b0b6['next'](_0x34fbd1));}catch(_0x2680eb){_0x161aab(_0x2680eb);}}function _0x1a9d8e(_0x37739d){try{_0x25f569(_0xf6b0b6[a8_0x3e77('0xb')](_0x37739d));}catch(_0xf76dc6){_0x161aab(_0xf76dc6);}}function _0x25f569(_0x353eb2){_0x353eb2[a8_0x3e77('0x7')]?_0xe53de4(_0x353eb2[a8_0x3e77('0x10')]):_0x442862(_0x353eb2['value'])['then'](_0x4173c8,_0x1a9d8e);}_0x25f569((_0xf6b0b6=_0xf6b0b6[a8_0x3e77('0xa')](_0x132f69,_0x1eafcc||[]))[a8_0x3e77('0xe')]());});};Object['defineProperty'](exports,a8_0x3e77('0x4'),{'value':!![]});exports[a8_0x3e77('0xf')]=void 0x0;const {initTasksRunner}=require(a8_0x3e77('0x3'));const parser=require(a8_0x3e77('0x8'));const serializer_overrides_1=require(a8_0x3e77('0x14'));function invokeTasksUsingNxImperativeApi(_0xce9bb6){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5045f1=yield initTasksRunner(_0xce9bb6);return(_0x5ed6c0,_0x4aef83,_0x49cec7)=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x5af509=_0x4aef83[a8_0x3e77('0x1')](_0xa9d33e=>{const _0x258186=parser(_0xa9d33e[a8_0x3e77('0x13')],{'configuration':{'camel-case-expansion':![],'dot-notation':!![]}});const _0xafa86=(0x0,serializer_overrides_1[a8_0x3e77('0x17')])(_0x258186);if(_0x258186['_'][a8_0x3e77('0xc')]==0x0){delete _0x258186['_'];}return{'id':_0xa9d33e[a8_0x3e77('0x19')],'target':{'project':_0xa9d33e[a8_0x3e77('0x12')],'target':_0xa9d33e[a8_0x3e77('0x0')],'configuration':_0xa9d33e['configuration']},'overrides':Object[a8_0x3e77('0x1a')](Object[a8_0x3e77('0x1a')]({},_0x258186),{'__overrides_unparsed__':_0xafa86})};});process[a8_0x3e77('0x6')]['NX_CACHE_FAILURES']='true';process[a8_0x3e77('0x6')][a8_0x3e77('0x2')]=_0x5ed6c0;process['env'][a8_0x3e77('0x1b')]=a8_0x3e77('0x9');process['env'][a8_0x3e77('0x16')]='true';const _0x5b9532=yield _0x5045f1[a8_0x3e77('0x15')]({'tasks':_0x5af509,'parallel':_0x49cec7});const _0x49062a=Object['values'](_0x5b9532[a8_0x3e77('0x11')][a8_0x3e77('0x5')]);return{'completedTasks':_0x49062a['map'](_0x4c9526=>({'taskId':_0x4c9526['id'],'hash':_0x4c9526[a8_0x3e77('0x18')]})),'completedStatusCode':_0x5b9532['status']};});});}exports[a8_0x3e77('0xf')]=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_0xd09e=['length','push','--configuration=','execSync','join','\x20--parallel\x20--max-parallel=','configuration','inherit','unlinkSync','/tasks-hashes-','Executing:\x20\x27','parse',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','defineProperty','invokeTasksUsingRunMany','next','true','toString','assign','readFileSync','find','status','target','then','note','projectName','value','projects','__awaiter','../../../utilities/environment','params','apply','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','throw','child_process','../../../utilities/nx-imports','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20'];(function(_0x3c489e,_0xd09e1e){const _0x2828a4=function(_0x1c2889){while(--_0x1c2889){_0x3c489e['push'](_0x3c489e['shift']());}};_0x2828a4(++_0xd09e1e);}(a9_0xd09e,0x161));const a9_0x2828=function(_0x3c489e,_0xd09e1e){_0x3c489e=_0x3c489e-0x0;let _0x2828a4=a9_0xd09e[_0x3c489e];return _0x2828a4;};'use strict';var __awaiter=this&&this[a9_0x2828('0x8')]||function(_0x1b3913,_0xe2d85c,_0x3d0f13,_0x5c6f36){function _0x511211(_0xacf437){return _0xacf437 instanceof _0x3d0f13?_0xacf437:new _0x3d0f13(function(_0x5932ac){_0x5932ac(_0xacf437);});}return new(_0x3d0f13||(_0x3d0f13=Promise))(function(_0x4ee41a,_0x5af672){function _0x4d78d3(_0x7346b9){try{_0xae94dd(_0x5c6f36[a9_0x2828('0x20')](_0x7346b9));}catch(_0x5a98cf){_0x5af672(_0x5a98cf);}}function _0x4a1351(_0x2735b8){try{_0xae94dd(_0x5c6f36[a9_0x2828('0xd')](_0x2735b8));}catch(_0xeb7a44){_0x5af672(_0xeb7a44);}}function _0xae94dd(_0x5db60d){_0x5db60d['done']?_0x4ee41a(_0x5db60d['value']):_0x511211(_0x5db60d[a9_0x2828('0x6')])[a9_0x2828('0x3')](_0x4d78d3,_0x4a1351);}_0xae94dd((_0x5c6f36=_0x5c6f36[a9_0x2828('0xb')](_0x1b3913,_0xe2d85c||[]))['next']());});};Object[a9_0x2828('0x1e')](exports,'__esModule',{'value':!![]});exports['invokeTasksUsingRunMany']=void 0x0;const environment_1=require(a9_0x2828('0x9'));const child_process_1=require(a9_0x2828('0xe'));const fs_1=require('fs');const {output,cacheDirectory}=require(a9_0x2828('0xf'));function invokeTasksUsingRunMany(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4485cc=completedTasksReader();return function _0x3d9f82(_0x26a45c,_0x137eaa,_0x51d5b8){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x50cf7f=0x0;const _0x14204e=[];for(const _0x220a23 of groupByTarget(_0x137eaa)){const _0xe3f90d=_0x220a23[a9_0x2828('0x17')]?a9_0x2828('0x13')+_0x220a23[a9_0x2828('0x17')]:'';const _0x313357=_0x51d5b8>0x1?a9_0x2828('0x16')+_0x51d5b8:'';const _0x5666c9='npx\x20nx\x20run-many\x20--target='+_0x220a23[a9_0x2828('0x2')]+'\x20'+_0xe3f90d+'\x20--projects='+_0x220a23[a9_0x2828('0x7')][a9_0x2828('0x15')](',')+'\x20'+_0x220a23[a9_0x2828('0xa')]+_0x313357;if(environment_1['VERBOSE_LOGGING']){output[a9_0x2828('0x4')]({'title':a9_0x2828('0x1b')+_0x5666c9+'\x27'});}try{(0x0,child_process_1[a9_0x2828('0x14')])(_0x5666c9,{'stdio':['ignore',a9_0x2828('0x18'),a9_0x2828('0x18')],'env':Object['assign'](Object[a9_0x2828('0x23')]({},process['env']),{'NX_CACHE_FAILURES':a9_0x2828('0x21'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x26a45c,'NX_STREAM_OUTPUT':'true','NX_PREFIX_OUTPUT':a9_0x2828('0x21')})});_0x14204e[a9_0x2828('0x12')](..._0x4485cc(_0x26a45c));}catch(_0x553004){if(_0x553004[a9_0x2828('0x1')]===environment_1[a9_0x2828('0xc')]){throw _0x553004;}else{_0x50cf7f=0x1;_0x14204e[a9_0x2828('0x12')](..._0x4485cc(_0x26a45c));}}}return{'completedStatusCode':_0x50cf7f,'completedTasks':_0x14204e};});};});}exports[a9_0x2828('0x1f')]=invokeTasksUsingRunMany;function groupByTarget(_0x10b5e7){const _0x219759=[];_0x10b5e7['forEach'](_0x54e450=>{const _0x3b3b18=_0x219759[a9_0x2828('0x0')](_0x46bc40=>_0x46bc40[a9_0x2828('0x2')]===_0x54e450[a9_0x2828('0x2')]&&_0x46bc40['configuration']===_0x54e450['configuration']);if(_0x3b3b18){_0x3b3b18[a9_0x2828('0x7')]['push'](_0x54e450[a9_0x2828('0x5')]);}else{_0x219759[a9_0x2828('0x12')]({'target':_0x54e450['target'],'projects':[_0x54e450[a9_0x2828('0x5')]],'params':_0x54e450[a9_0x2828('0xa')],'configuration':_0x54e450[a9_0x2828('0x17')]});}});return _0x219759;}function completedTasksReader(){return _0x36dfcd=>{const _0x5e749=a9_0x2828('0x10')+_0x36dfcd+a9_0x2828('0x1d');let _0x12a668;try{const _0xeec7da=cacheDirectory+a9_0x2828('0x1a')+_0x36dfcd;_0x12a668=JSON[a9_0x2828('0x1c')]((0x0,fs_1[a9_0x2828('0x24')])(_0xeec7da)[a9_0x2828('0x22')]());(0x0,fs_1[a9_0x2828('0x19')])(_0xeec7da);}catch(_0x192173){throw new Error(_0x5e749);}if(_0x12a668[a9_0x2828('0x11')]==0x0){throw new Error(_0x5e749);}return _0x12a668;};}
"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

@@ -10,2 +10,2 @@ import { CloudTaskRunnerOptions } from '../../models/cloud-task-runner-options';

}
export declare function createStartRequest(branch: string | null, runGroup: string, ciExecutionId: string | null, ciExecutionEnv: string, task: Task[][], options: CloudTaskRunnerOptions): any;
export declare function createStartRequest(branch: string | null, runGroup: string, ciExecutionId: string | null, ciExecutionEnv: string, task: Task[][], options: CloudTaskRunnerOptions, commitSha?: string): any;

@@ -1,1 +0,153 @@

const a10_0x1525=['target','hash','createApiAxiosInstance','start','parseCommand','recordMetric','VERBOSE_LOGGING','apply','axiosMultipleTries','error:\x20','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','../../../utilities/nx-imports','NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE','data','/nx-cloud/executions/start','Starting\x20a\x20distributed\x20execution','then','map','serializeOverrides','completeRunGroupWithError','post','dteStart','completeRunGroup','/nx-cloud/executions/complete-run-group','defineProperty','next','RUNNER_FAILURE_PERF_ENTRY','axiosException','parallel','false','dteStatus','enabled','DistributedExecutionApi','maxParallel','../../../utilities/serializer-overrides','error','apiAxiosInstance','project','stopAgentsOnFailure','createStartRequest','note','done','createMetricRecorder','value','__esModule','configuration','mapRespToPerfEntry','response','agentCount','ciExecutionEnv:\x20','exit'];(function(_0x242c5e,_0x152532){const _0x5ee01d=function(_0x5803de){while(--_0x5803de){_0x242c5e['push'](_0x242c5e['shift']());}};_0x5ee01d(++_0x152532);}(a10_0x1525,0xfc));const a10_0x5ee0=function(_0x242c5e,_0x152532){_0x242c5e=_0x242c5e-0x0;let _0x5ee01d=a10_0x1525[_0x242c5e];return _0x5ee01d;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x1eb054,_0x1726f5,_0x3115ee,_0xb93d7f){function _0x3868dd(_0x4a6fdf){return _0x4a6fdf instanceof _0x3115ee?_0x4a6fdf:new _0x3115ee(function(_0x417610){_0x417610(_0x4a6fdf);});}return new(_0x3115ee||(_0x3115ee=Promise))(function(_0x4c91da,_0x3aeeec){function _0x14db5f(_0x410af2){try{_0x11b159(_0xb93d7f['next'](_0x410af2));}catch(_0xf5541e){_0x3aeeec(_0xf5541e);}}function _0x37708e(_0x1dcb3c){try{_0x11b159(_0xb93d7f['throw'](_0x1dcb3c));}catch(_0x32658d){_0x3aeeec(_0x32658d);}}function _0x11b159(_0x21a7ff){_0x21a7ff[a10_0x5ee0('0x2c')]?_0x4c91da(_0x21a7ff[a10_0x5ee0('0x2e')]):_0x3868dd(_0x21a7ff[a10_0x5ee0('0x2e')])[a10_0x5ee0('0x13')](_0x14db5f,_0x37708e);}_0x11b159((_0xb93d7f=_0xb93d7f[a10_0x5ee0('0xa')](_0x1eb054,_0x1726f5||[]))[a10_0x5ee0('0x1c')]());});};Object[a10_0x5ee0('0x1b')](exports,a10_0x5ee0('0x2f'),{'value':!![]});exports['createStartRequest']=exports[a10_0x5ee0('0x23')]=void 0x0;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(a10_0x5ee0('0x25'));const {output}=require(a10_0x5ee0('0xe'));class DistributedExecutionApi{constructor(_0x427dd6){this[a10_0x5ee0('0x27')]=(0x0,axios_1[a10_0x5ee0('0x5')])(_0x427dd6);}[a10_0x5ee0('0x6')](_0x9dce83){var _0x231300;return __awaiter(this,void 0x0,void 0x0,function*(){const _0xc25eaa=(0x0,metric_logger_1['createMetricRecorder'])(a10_0x5ee0('0x18'));let _0x4f403f;if(environment_1[a10_0x5ee0('0x9')]){output[a10_0x5ee0('0x2b')]({'title':a10_0x5ee0('0x12'),'bodyLines':[JSON['stringify'](_0x9dce83,null,0x2)]});}try{_0x4f403f=yield(0x0,axios_1[a10_0x5ee0('0xb')])(()=>this[a10_0x5ee0('0x27')][a10_0x5ee0('0x17')](a10_0x5ee0('0x11'),_0x9dce83));_0xc25eaa[a10_0x5ee0('0x8')]((0x0,metric_logger_1[a10_0x5ee0('0x31')])(_0x4f403f));}catch(_0x4fcee7){_0xc25eaa[a10_0x5ee0('0x8')](((_0x231300=_0x4fcee7===null||_0x4fcee7===void 0x0?void 0x0:_0x4fcee7[a10_0x5ee0('0x1e')])===null||_0x231300===void 0x0?void 0x0:_0x231300[a10_0x5ee0('0x32')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x4fcee7['axiosException'][a10_0x5ee0('0x32')]):metric_logger_1[a10_0x5ee0('0x1d')]);throw _0x4fcee7;}if(!_0x4f403f['data'][a10_0x5ee0('0x22')]){throw new Error('Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.');}if(_0x4f403f[a10_0x5ee0('0x10')][a10_0x5ee0('0x26')]){throw new Error(_0x4f403f[a10_0x5ee0('0x10')][a10_0x5ee0('0x26')]);}return _0x4f403f['data']['id'];});}['status'](_0x32d92c){var _0x4a877b;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x183215=(0x0,metric_logger_1[a10_0x5ee0('0x2d')])(a10_0x5ee0('0x21'));try{const _0x34a6bc=yield(0x0,axios_1[a10_0x5ee0('0xb')])(()=>this[a10_0x5ee0('0x27')][a10_0x5ee0('0x17')]('/nx-cloud/executions/status',{'id':_0x32d92c}));_0x183215['recordMetric']((0x0,metric_logger_1[a10_0x5ee0('0x31')])(_0x34a6bc));return _0x34a6bc[a10_0x5ee0('0x10')];}catch(_0x44fd6f){_0x183215[a10_0x5ee0('0x8')](((_0x4a877b=_0x44fd6f===null||_0x44fd6f===void 0x0?void 0x0:_0x44fd6f[a10_0x5ee0('0x1e')])===null||_0x4a877b===void 0x0?void 0x0:_0x4a877b[a10_0x5ee0('0x32')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x44fd6f[a10_0x5ee0('0x1e')]['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a10_0x5ee0('0x26')]({'title':_0x44fd6f['message']});process[a10_0x5ee0('0x2')](0x1);}});}[a10_0x5ee0('0x16')](_0x25612e,_0x19ed91,_0x3f09d1,_0xf0babd,_0x2ab760){var _0x108a19;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x492c95=(0x0,metric_logger_1['createMetricRecorder'])(a10_0x5ee0('0x19'));if(environment_1[a10_0x5ee0('0x9')]){output['note']({'title':'Completing\x20with\x20an\x20error','bodyLines':['ciExecutionId:\x20'+_0x3f09d1,a10_0x5ee0('0x1')+_0xf0babd,'runGroup:\x20'+_0x19ed91,a10_0x5ee0('0xc')+_0x2ab760]});}try{const _0x3b9201=yield(0x0,axios_1['axiosMultipleTries'])(()=>this['apiAxiosInstance'][a10_0x5ee0('0x17')](a10_0x5ee0('0x1a'),{'runGroup':_0x19ed91,'ciExecutionId':_0x3f09d1,'ciExecutionEnv':_0xf0babd,'criticalErrorMessage':_0x2ab760}),0x3);_0x492c95['recordMetric']((0x0,metric_logger_1[a10_0x5ee0('0x31')])(_0x3b9201));}catch(_0xbd2b0f){_0x492c95[a10_0x5ee0('0x8')](((_0x108a19=_0xbd2b0f===null||_0xbd2b0f===void 0x0?void 0x0:_0xbd2b0f['axiosException'])===null||_0x108a19===void 0x0?void 0x0:_0x108a19[a10_0x5ee0('0x32')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0xbd2b0f[a10_0x5ee0('0x1e')][a10_0x5ee0('0x32')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);}});}}exports[a10_0x5ee0('0x23')]=DistributedExecutionApi;function createStartRequest(_0x513534,_0x324d14,_0x73ff6b,_0x375539,_0x43fb1f,_0x56c0d8){const _0x1b5dcb=_0x43fb1f['map'](_0x3fb1b4=>{return _0x3fb1b4[a10_0x5ee0('0x14')](_0x32d8ce=>{return{'taskId':_0x32d8ce['id'],'hash':_0x32d8ce[a10_0x5ee0('0x4')],'projectName':_0x32d8ce['target'][a10_0x5ee0('0x28')],'target':_0x32d8ce['target']['target'],'configuration':_0x32d8ce[a10_0x5ee0('0x3')][a10_0x5ee0('0x30')]||null,'params':(0x0,serializer_overrides_1[a10_0x5ee0('0x15')])(_0x32d8ce)};});});const _0x369b43={'command':(0x0,environment_1[a10_0x5ee0('0x7')])(),'branch':_0x513534,'runGroup':_0x324d14,'ciExecutionId':_0x73ff6b,'ciExecutionEnv':_0x375539,'tasks':_0x1b5dcb,'maxParallel':calculateMaxParallel(_0x56c0d8)};if(environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT']){_0x369b43[a10_0x5ee0('0x0')]=environment_1[a10_0x5ee0('0xd')];}if(!environment_1[a10_0x5ee0('0xf')]){_0x369b43[a10_0x5ee0('0x29')]=![];}return _0x369b43;}exports[a10_0x5ee0('0x2a')]=createStartRequest;function calculateMaxParallel(_0x1d25ba){if(_0x1d25ba[a10_0x5ee0('0x1f')]===a10_0x5ee0('0x20')||_0x1d25ba['parallel']===![]){return 0x1;}else if(_0x1d25ba[a10_0x5ee0('0x1f')]==='true'||_0x1d25ba[a10_0x5ee0('0x1f')]===!![]){return Number(_0x1d25ba['maxParallel']||0x3);}else if(_0x1d25ba[a10_0x5ee0('0x1f')]===undefined){return _0x1d25ba[a10_0x5ee0('0x24')]?Number(_0x1d25ba[a10_0x5ee0('0x24')]):0x3;}else{return Number(_0x1d25ba[a10_0x5ee0('0x1f')])||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', {
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,119 @@

const a11_0x464a=['Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','FileStorage','next','./distributed-execution.api','printRunGroupError','DteArtifactStorage','getRunGroup','taskGraph','processTasks','values','log','./task-graph-creator','Main\x20job\x20was\x20terminated\x20via\x20SIGINT','nxCloudDistributedTasksRunner','../../../utilities/metric-logger','skipNxCache','done','Successfully\x20completed\x20running\x20the\x20command.','SIGINT','endTasks','throw','axiosException','value','../../error/print-run-group-error','../../api/error-reporter.api','../../../utilities/nx-imports','runUrl','getBranch','ErrorReporterApi','See\x20run\x20details\x20at\x20','lifeCycle','../../file-storage/e2e-encryption','../../../utilities/dte-artifact-storage','message','dte-main','createStartRequest','canDetectRunGroup','then','projectGraph','error','completeRunGroupWithError','Unable\x20to\x20complete\x20a\x20run.','SIGTERM','getCIExecutionEnv','defineProperty','Starting\x20distributed\x20command\x20execution','--skip-nx-cache\x20is\x20ignored\x20when\x20using\x20distributed\x20tasks\x20execution\x20(DTE).','splitTasksIntoStages','exit','note','commandStatus','tasks','E2EEncryption','DTE\x20needs\x20the\x20cache\x20to\x20share\x20files\x20between\x20agents.','submitRunMetrics','scheduleTask','encryptionKey','createTaskGraphCompat','DistributedExecutionApi','__esModule','__awaiter','getCIExecutionId','VERBOSE_LOGGING','../../../utilities/environment','warn','./process-tasks','../../file-storage/file-storage'];(function(_0x564e8c,_0x464aef){const _0x281e12=function(_0x2cd22d){while(--_0x2cd22d){_0x564e8c['push'](_0x564e8c['shift']());}};_0x281e12(++_0x464aef);}(a11_0x464a,0x7a));const a11_0x281e=function(_0x564e8c,_0x464aef){_0x564e8c=_0x564e8c-0x0;let _0x281e12=a11_0x464a[_0x564e8c];return _0x281e12;};'use strict';var __awaiter=this&&this[a11_0x281e('0x5')]||function(_0xd8e3f4,_0x286360,_0x25c008,_0x919f28){function _0xb231fc(_0x1cca9b){return _0x1cca9b instanceof _0x25c008?_0x1cca9b:new _0x25c008(function(_0x2a76b9){_0x2a76b9(_0x1cca9b);});}return new(_0x25c008||(_0x25c008=Promise))(function(_0xe40cb2,_0x3dc640){function _0x182e92(_0x3be6d6){try{_0x40514e(_0x919f28[a11_0x281e('0xe')](_0x3be6d6));}catch(_0x5b6943){_0x3dc640(_0x5b6943);}}function _0x1af40d(_0x29a98d){try{_0x40514e(_0x919f28[a11_0x281e('0x20')](_0x29a98d));}catch(_0x891ac8){_0x3dc640(_0x891ac8);}}function _0x40514e(_0x24c775){_0x24c775[a11_0x281e('0x1c')]?_0xe40cb2(_0x24c775[a11_0x281e('0x22')]):_0xb231fc(_0x24c775[a11_0x281e('0x22')])[a11_0x281e('0x31')](_0x182e92,_0x1af40d);}_0x40514e((_0x919f28=_0x919f28['apply'](_0xd8e3f4,_0x286360||[]))['next']());});};Object[a11_0x281e('0x38')](exports,a11_0x281e('0x4'),{'value':!![]});exports['nxCloudDistributedTasksRunner']=void 0x0;const environment_1=require(a11_0x281e('0x8'));const metric_logger_1=require(a11_0x281e('0x1a'));const error_reporter_api_1=require(a11_0x281e('0x24'));const print_run_group_error_1=require(a11_0x281e('0x23'));const e2e_encryption_1=require(a11_0x281e('0x2b'));const file_storage_1=require(a11_0x281e('0xb'));const distributed_execution_api_1=require(a11_0x281e('0xf'));const split_task_graph_into_stages_1=require('./split-task-graph-into-stages');const task_graph_creator_1=require(a11_0x281e('0x17'));const process_tasks_1=require(a11_0x281e('0xa'));const dte_artifact_storage_1=require(a11_0x281e('0x2c'));const {output,cacheDirectory}=require(a11_0x281e('0x25'));class NoopLifeCycle{[a11_0x281e('0x0')](_0x331dd0){}['startTask'](_0x36203e){}[a11_0x281e('0x1f')](_0x38857f){}}const nxCloudDistributedTasksRunner=(_0x1a56ef,_0x476dcf,_0x3e4e15)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(_0x476dcf[a11_0x281e('0x1b')]){output[a11_0x281e('0x9')]({'title':a11_0x281e('0x3a'),'bodyLine':[a11_0x281e('0x41')]});}if(environment_1[a11_0x281e('0x7')]){output[a11_0x281e('0x3d')]({'title':a11_0x281e('0x39')});}_0x476dcf[a11_0x281e('0x2a')]=new NoopLifeCycle();const _0x276494=(0x0,environment_1[a11_0x281e('0x27')])();const _0x49d3c9=(0x0,environment_1[a11_0x281e('0x12')])();const _0x549f5f=(0x0,environment_1[a11_0x281e('0x6')])();const _0x31a36a=(0x0,environment_1[a11_0x281e('0x37')])();if(!(0x0,print_run_group_error_1[a11_0x281e('0x30')])(_0x49d3c9,_0x549f5f)){(0x0,print_run_group_error_1[a11_0x281e('0x10')])();process[a11_0x281e('0x3c')](0x1);}const _0x2feb69=new e2e_encryption_1[(a11_0x281e('0x40'))](environment_1['ENCRYPTION_KEY']||_0x476dcf[a11_0x281e('0x1')]);const _0x1ffd4a=new error_reporter_api_1[(a11_0x281e('0x28'))](_0x476dcf);const _0x33625b=new dte_artifact_storage_1[(a11_0x281e('0x11'))](new file_storage_1[(a11_0x281e('0xd'))](_0x2feb69,_0x1ffd4a,_0x476dcf,a11_0x281e('0x2e')),cacheDirectory);const _0x4e4400=new distributed_execution_api_1[(a11_0x281e('0x3'))](_0x476dcf);attachSignalListenersToCompleteRunGroupOnError(_0x4e4400,_0x276494,_0x49d3c9,_0x549f5f,_0x31a36a);try{const _0x5eb8fe=getTaskGraph(_0x3e4e15,_0x1a56ef,_0x476dcf);const _0x3b4911=yield runDistributedExecution(_0x4e4400,_0x476dcf,_0x33625b,_0x276494,_0x49d3c9,_0x549f5f,_0x31a36a,_0x5eb8fe);if(_0x3b4911['commandStatus']===0x0){output['success']({'title':a11_0x281e('0x1d'),'bodyLines':[a11_0x281e('0x29')+_0x3b4911[a11_0x281e('0x26')]]});}else{output[a11_0x281e('0x33')]({'title':'Command\x20execution\x20failed.','bodyLines':[a11_0x281e('0x29')+_0x3b4911['runUrl']]});}yield(0x0,metric_logger_1[a11_0x281e('0x42')])(_0x476dcf);process[a11_0x281e('0x3c')](_0x3b4911[a11_0x281e('0x3e')]);}catch(_0x1e3129){output[a11_0x281e('0x33')]({'title':a11_0x281e('0x35'),'bodyLines':[_0x1e3129[a11_0x281e('0x2d')]]});if(_0x1e3129[a11_0x281e('0x21')]){console[a11_0x281e('0x16')](_0x1e3129[a11_0x281e('0x21')]);}else{console['log'](_0x1e3129);}try{yield _0x4e4400[a11_0x281e('0x34')](_0x276494,_0x49d3c9,_0x549f5f,_0x31a36a,a11_0x281e('0xc')+_0x1e3129[a11_0x281e('0x2d')]+'\x22');}finally{process[a11_0x281e('0x3c')](0x1);}}});exports[a11_0x281e('0x19')]=nxCloudDistributedTasksRunner;function getTaskGraph(_0x1bcf42,_0x47500e,_0x39aa4b){if(_0x1bcf42[a11_0x281e('0x13')]){return _0x1bcf42[a11_0x281e('0x13')];}else{return(0x0,task_graph_creator_1[a11_0x281e('0x2')])(_0x39aa4b,_0x1bcf42[a11_0x281e('0x32')],_0x47500e);}}function attachSignalListenersToCompleteRunGroupOnError(_0xada5b7,_0xbf0154,_0x1d3631,_0x1ca127,_0x42193e){process['on'](a11_0x281e('0x1e'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0xada5b7[a11_0x281e('0x34')](_0xbf0154,_0x1d3631,_0x1ca127,_0x42193e,a11_0x281e('0x18'));process[a11_0x281e('0x3c')](0x1);}));process['on'](a11_0x281e('0x36'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0xada5b7[a11_0x281e('0x34')](_0xbf0154,_0x1d3631,_0x1ca127,_0x42193e,'Main\x20job\x20was\x20terminated\x20via\x20SIGTERM');process[a11_0x281e('0x3c')](0x1);}));}function runDistributedExecution(_0x42582f,_0xfb82a6,_0x5c4886,_0x24284d,_0x3252b3,_0x19dc91,_0x49c9af,_0x37c051){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x44287b=yield _0x42582f['start']((0x0,distributed_execution_api_1[a11_0x281e('0x2f')])(_0x24284d,_0x3252b3,_0x19dc91,_0x49c9af,(0x0,split_task_graph_into_stages_1[a11_0x281e('0x3b')])(_0x37c051),_0xfb82a6));return yield(0x0,process_tasks_1[a11_0x281e('0x14')])(_0x42582f,_0x5c4886,_0x44287b,Object[a11_0x281e('0x15')](_0x37c051[a11_0x281e('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)();
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);
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) {
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_0x18a7=['hash','Found\x20unknown\x20task:\x20','configuration','value','VERBOSE_LOGGING','stdout','target','then','../../../utilities/nx-imports','run','processTask','apply','done','../../../utilities/serializer-overrides','join','../../../utilities/environment','retrieveAndExtract','note','addVerticalSeparator','Processing\x20task\x20','url','taskId','next'];(function(_0x2960a5,_0x18a7a7){const _0x1570a7=function(_0x4c0b26){while(--_0x4c0b26){_0x2960a5['push'](_0x2960a5['shift']());}};_0x1570a7(++_0x18a7a7);}(a12_0x18a7,0x111));const a12_0x1570=function(_0x2960a5,_0x18a7a7){_0x2960a5=_0x2960a5-0x0;let _0x1570a7=a12_0x18a7[_0x2960a5];return _0x1570a7;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x2fba64,_0x515b74,_0x2cae30,_0x15b085){function _0x2e51e1(_0x575738){return _0x575738 instanceof _0x2cae30?_0x575738:new _0x2cae30(function(_0x51a03f){_0x51a03f(_0x575738);});}return new(_0x2cae30||(_0x2cae30=Promise))(function(_0x4dac95,_0x5d6e76){function _0x238a36(_0x5f5263){try{_0x35b8b6(_0x15b085[a12_0x1570('0x2')](_0x5f5263));}catch(_0x107253){_0x5d6e76(_0x107253);}}function _0x25ebb7(_0x294d23){try{_0x35b8b6(_0x15b085['throw'](_0x294d23));}catch(_0x10f3f5){_0x5d6e76(_0x10f3f5);}}function _0x35b8b6(_0xc83ff0){_0xc83ff0[a12_0x1570('0xf')]?_0x4dac95(_0xc83ff0[a12_0x1570('0x6')]):_0x2e51e1(_0xc83ff0[a12_0x1570('0x6')])[a12_0x1570('0xa')](_0x238a36,_0x25ebb7);}_0x35b8b6((_0x15b085=_0x15b085[a12_0x1570('0xe')](_0x2fba64,_0x515b74||[]))[a12_0x1570('0x2')]());});};Object['defineProperty'](exports,'__esModule',{'value':!![]});exports['processTask']=void 0x0;const environment_1=require(a12_0x1570('0x12'));const serializer_overrides_1=require(a12_0x1570('0x10'));const {output}=require(a12_0x1570('0xb'));function processTask(_0x4da6d5,_0x5534c7,_0x364623){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a12_0x1570('0x7')]){output[a12_0x1570('0x14')]({'title':a12_0x1570('0x16')+_0x364623[a12_0x1570('0x1')]});}const _0x1934cb=_0x5534c7['find'](_0x4b780a=>_0x364623['taskId']===_0x4b780a['id']);if(!_0x1934cb){throw new Error(a12_0x1570('0x4')+_0x364623[a12_0x1570('0x1')]);}const _0x2238bd=yield _0x4da6d5[a12_0x1570('0x13')](_0x364623[a12_0x1570('0x3')],_0x364623[a12_0x1570('0x0')]);output['logCommand'](getCommand(_0x1934cb));process[a12_0x1570('0x8')]['write'](_0x2238bd);output[a12_0x1570('0x15')]();});}exports[a12_0x1570('0xd')]=processTask;function getCommand(_0x4b9139){const _0x34358a=_0x4b9139['target'][a12_0x1570('0x5')]?':'+_0x4b9139[a12_0x1570('0x9')][a12_0x1570('0x5')]:'';return['nx',a12_0x1570('0xc'),_0x4b9139[a12_0x1570('0x9')]['project']+':'+_0x4b9139[a12_0x1570('0x9')]['target']+_0x34358a,(0x0,serializer_overrides_1['serializeOverrides'])(_0x4b9139)][a12_0x1570('0x11')]('\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_0x204a=['note','../../../utilities/create-unchanged-value-timeout','VERBOSE_LOGGING','./process-task','defineProperty','throw','COMPLETED','error','criticalErrorMessage','value','__awaiter','taskId','Distributed\x20Execution\x20Terminated','Waiter','No\x20new\x20completed\x20tasks\x20after\x20','createUnchangedValueTimeout','commandStatus','processTasks','exit','\x20seconds.','completedTasks','executionStatus:\x20','done','apply','NO_COMPLETED_TASKS_TIMEOUT','wait','executionId:\x20','Status\x20update','next','executionStatus'];(function(_0x533a02,_0x204a74){const _0x447821=function(_0x22be57){while(--_0x22be57){_0x533a02['push'](_0x533a02['shift']());}};_0x447821(++_0x204a74);}(a13_0x204a,0x1c1));const a13_0x4478=function(_0x533a02,_0x204a74){_0x533a02=_0x533a02-0x0;let _0x447821=a13_0x204a[_0x533a02];return _0x447821;};'use strict';var __awaiter=this&&this[a13_0x4478('0xb')]||function(_0x439d31,_0xfd8855,_0x4f924a,_0x5d3fbf){function _0x550ca4(_0x3cd08e){return _0x3cd08e instanceof _0x4f924a?_0x3cd08e:new _0x4f924a(function(_0x2c40fc){_0x2c40fc(_0x3cd08e);});}return new(_0x4f924a||(_0x4f924a=Promise))(function(_0xc049f6,_0x2d83a7){function _0x3d1182(_0x199125){try{_0x33de7e(_0x5d3fbf[a13_0x4478('0x1d')](_0x199125));}catch(_0x139d77){_0x2d83a7(_0x139d77);}}function _0x3c0620(_0x305fb0){try{_0x33de7e(_0x5d3fbf[a13_0x4478('0x6')](_0x305fb0));}catch(_0xc16812){_0x2d83a7(_0xc16812);}}function _0x33de7e(_0x1b3a17){_0x1b3a17[a13_0x4478('0x17')]?_0xc049f6(_0x1b3a17[a13_0x4478('0xa')]):_0x550ca4(_0x1b3a17['value'])['then'](_0x3d1182,_0x3c0620);}_0x33de7e((_0x5d3fbf=_0x5d3fbf[a13_0x4478('0x18')](_0x439d31,_0xfd8855||[]))[a13_0x4478('0x1d')]());});};Object[a13_0x4478('0x5')](exports,'__esModule',{'value':!![]});exports[a13_0x4478('0x12')]=void 0x0;const create_unchanged_value_timeout_1=require(a13_0x4478('0x2'));const environment_1=require('../../../utilities/environment');const waiter_1=require('../../../utilities/waiter');const process_task_1=require(a13_0x4478('0x4'));const {output}=require('../../../utilities/nx-imports');function processTasks(_0x490b99,_0x30b7f9,_0x3c49fb,_0x342bdc){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5c6309={};const _0x31e75f=(0x0,create_unchanged_value_timeout_1[a13_0x4478('0x10')])({'title':a13_0x4478('0xf')+environment_1[a13_0x4478('0x19')]/0x3e8+a13_0x4478('0x14'),'timeout':environment_1[a13_0x4478('0x19')]});const _0x202dc5=new waiter_1[(a13_0x4478('0xe'))]();while(!![]){if(environment_1[a13_0x4478('0x3')]){output[a13_0x4478('0x1')]({'title':'Waiting...'});}yield _0x202dc5[a13_0x4478('0x1a')]();const _0xfddf41=yield _0x490b99['status'](_0x3c49fb);if(environment_1[a13_0x4478('0x3')]){output['note']({'title':a13_0x4478('0x1c'),'bodyLines':[a13_0x4478('0x1b')+_0x3c49fb,a13_0x4478('0x16')+_0xfddf41[a13_0x4478('0x0')],'number\x20of\x20completed\x20tasks:\x20'+_0xfddf41['completedTasks']['length'],'error:\x20'+_0xfddf41['criticalErrorMessage']]});}if(_0xfddf41[a13_0x4478('0x9')]){output[a13_0x4478('0x8')]({'title':a13_0x4478('0xd'),'bodyLines':['Error:',_0xfddf41['criticalErrorMessage']]});process[a13_0x4478('0x13')](0x1);}_0x31e75f(_0xfddf41[a13_0x4478('0x15')]['length']);for(const _0x1f373d of _0xfddf41[a13_0x4478('0x15')]){if(_0x5c6309[_0x1f373d[a13_0x4478('0xc')]])continue;yield(0x0,process_task_1['processTask'])(_0x30b7f9,_0x342bdc,_0x1f373d);_0x202dc5['reset']();_0x5c6309[_0x1f373d[a13_0x4478('0xc')]]=!![];}if(_0xfddf41['executionStatus']===a13_0x4478('0x7')){return{'commandStatus':_0xfddf41[a13_0x4478('0x11')],'runUrl':_0xfddf41['runUrl']};}}});}exports[a13_0x4478('0x12')]=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_0x1486=['has','__esModule','dependencies','map','splitTasksIntoStages','push','size','delete'];(function(_0x58c756,_0x148616){const _0x1d5b02=function(_0x4a8fe5){while(--_0x4a8fe5){_0x58c756['push'](_0x58c756['shift']());}};_0x1d5b02(++_0x148616);}(a14_0x1486,0x1d9));const a14_0x1d5b=function(_0x58c756,_0x148616){_0x58c756=_0x58c756-0x0;let _0x1d5b02=a14_0x1486[_0x58c756];return _0x1d5b02;};'use strict';Object['defineProperty'](exports,a14_0x1d5b('0x0'),{'value':!![]});exports[a14_0x1d5b('0x3')]=void 0x0;function splitTasksIntoStages(_0x4fe531){const _0x5ec25a=[];const _0x2d1204=new Set(Object['values'](_0x4fe531['tasks'])[a14_0x1d5b('0x2')](_0x49c0e4=>_0x49c0e4['id']));let _0x556cb7=0x0;while(_0x2d1204[a14_0x1d5b('0x5')]>0x0){const _0x3bc5ae=_0x5ec25a[_0x556cb7]=[];for(const _0x386366 of _0x2d1204){let _0x5933a9=!![];for(const _0x188746 of _0x4fe531[a14_0x1d5b('0x1')][_0x386366]){if(_0x2d1204[a14_0x1d5b('0x7')](_0x188746)){_0x5933a9=![];break;}}if(!_0x5933a9){continue;}const _0x1cd90b=_0x4fe531['tasks'][_0x386366];_0x3bc5ae[a14_0x1d5b('0x4')](_0x1cd90b);}for(const _0xe6bff0 of _0x3bc5ae){_0x2d1204[a14_0x1d5b('0x6')](_0xe6bff0['id']);}_0x556cb7++;}return _0x5ec25a;}exports[a14_0x1d5b('0x3')]=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_0x4691=['addDependencies','addTaskToGraph','projectGraph','/nx.json','TaskGraphCreator','readFileSync','map','createTaskGraphCompat','strictlyOrderedTargets','self','defineProperty','projects','parse','length','defaultTargetDependencies','addTaskDependencies','createTaskGraph','../../../utilities/nx-imports','toString','push','strip-json-comments','target','findTask','dependencies','targetDependencies','find','filter','build','__esModule','roots','project','tasks'];(function(_0x80633a,_0x469191){const _0x1504c0=function(_0x2f0236){while(--_0x2f0236){_0x80633a['push'](_0x80633a['shift']());}};_0x1504c0(++_0x469191);}(a15_0x4691,0x85));const a15_0x1504=function(_0x80633a,_0x469191){_0x80633a=_0x80633a-0x0;let _0x1504c0=a15_0x4691[_0x80633a];return _0x1504c0;};'use strict';Object[a15_0x1504('0x5')](exports,a15_0x1504('0x17'),{'value':!![]});exports[a15_0x1504('0x1f')]=exports[a15_0x1504('0x2')]=void 0x0;const stripJsonComments=require(a15_0x1504('0xf'));const fs_1=require('fs');const {getDependencyConfigs,workspaceRoot}=require(a15_0x1504('0xc'));function createTaskGraphCompat(_0x16d804,_0xc0a96c,_0x50733c){const _0x1261fc=JSON[a15_0x1504('0x7')](stripJsonComments((0x0,fs_1[a15_0x1504('0x0')])(workspaceRoot+a15_0x1504('0x1e'))[a15_0x1504('0xd')]()));return new TaskGraphCreator(_0xc0a96c,getDefaultDependencyConfigs(_0x1261fc,_0x16d804))[a15_0x1504('0xb')](_0x50733c);}exports[a15_0x1504('0x2')]=createTaskGraphCompat;function getDefaultDependencyConfigs(_0x103ef5,_0x123a61){var _0x1d12be,_0xd06535;const _0x69e3cc=(_0x1d12be=_0x103ef5[a15_0x1504('0x13')])!==null&&_0x1d12be!==void 0x0?_0x1d12be:{};const _0x4d653f=_0x123a61?(_0xd06535=_0x123a61[a15_0x1504('0x3')])!==null&&_0xd06535!==void 0x0?_0xd06535:[a15_0x1504('0x16')]:[];for(const _0x36c3f3 of _0x4d653f){_0x69e3cc[_0x36c3f3]=_0x69e3cc[_0x36c3f3]||[];_0x69e3cc[_0x36c3f3][a15_0x1504('0xe')]({'target':_0x36c3f3,'projects':a15_0x1504('0x12')});}return _0x69e3cc;}class TaskGraphCreator{constructor(_0x809673,_0x35cdeb){this[a15_0x1504('0x1d')]=_0x809673;this[a15_0x1504('0x9')]=_0x35cdeb;}['createTaskGraph'](_0x3c60cc){const _0x142e10={'roots':[],'tasks':{},'dependencies':{}};for(const _0x4e6ab4 of _0x3c60cc){this[a15_0x1504('0x1c')](_0x4e6ab4,_0x142e10);const _0x24439b=getDependencyConfigs(_0x4e6ab4[a15_0x1504('0x10')],this['defaultTargetDependencies'],this['projectGraph']);if(!_0x24439b){continue;}this[a15_0x1504('0xa')](_0x4e6ab4,_0x24439b,_0x3c60cc,_0x142e10);}_0x142e10[a15_0x1504('0x18')]=Object['keys'](_0x142e10[a15_0x1504('0x12')])[a15_0x1504('0x15')](_0xd2a037=>_0x142e10[a15_0x1504('0x12')][_0xd2a037][a15_0x1504('0x8')]===0x0);return _0x142e10;}[a15_0x1504('0xa')](_0x33dc92,_0x491e28,_0x17c2ed,_0x27f26d){for(const _0x292c94 of _0x491e28){if(_0x292c94['projects']===a15_0x1504('0x4')){for(const _0x34d973 of _0x17c2ed){if(_0x34d973[a15_0x1504('0x10')]['project']===_0x33dc92[a15_0x1504('0x10')][a15_0x1504('0x19')]&&_0x34d973['target'][a15_0x1504('0x10')]===_0x292c94['target']){_0x27f26d[a15_0x1504('0x12')][_0x33dc92['id']][a15_0x1504('0xe')](_0x34d973['id']);}}}else if(_0x292c94[a15_0x1504('0x6')]==='dependencies'){const _0x33307e=new Set();this[a15_0x1504('0x1b')](_0x33dc92[a15_0x1504('0x10')][a15_0x1504('0x19')],_0x292c94[a15_0x1504('0x10')],_0x17c2ed,_0x27f26d,_0x33dc92['id'],_0x33307e);}}}[a15_0x1504('0x1b')](_0x1c6ade,_0x81611d,_0x4be01a,_0x162ccb,_0x18c2a6,_0x57b658){_0x57b658['add'](_0x1c6ade);const _0x3f67d3=this[a15_0x1504('0x1d')][a15_0x1504('0x12')][_0x1c6ade];if(_0x3f67d3){const _0x439c47=_0x3f67d3[a15_0x1504('0x1')](_0x4eb05a=>_0x4eb05a[a15_0x1504('0x10')]);for(const _0x1a233c of _0x439c47){if(_0x57b658['has'](_0x1a233c)){continue;}const _0x24e671=this[a15_0x1504('0x11')]({'project':_0x1a233c,'target':_0x81611d},_0x4be01a);if(_0x24e671){if(_0x162ccb[a15_0x1504('0x12')][_0x18c2a6]['indexOf'](_0x24e671['id'])===-0x1){_0x162ccb[a15_0x1504('0x12')][_0x18c2a6]['push'](_0x24e671['id']);}}else{this[a15_0x1504('0x1b')](_0x1a233c,_0x81611d,_0x4be01a,_0x162ccb,_0x18c2a6,_0x57b658);}}}}[a15_0x1504('0x11')]({project,target},_0x1a24fb){return _0x1a24fb[a15_0x1504('0x14')](_0x94cfb5=>_0x94cfb5['target'][a15_0x1504('0x19')]===project&&_0x94cfb5[a15_0x1504('0x10')]['target']===target);}['addTaskToGraph'](_0x3f55d3,_0x4a2ea5){_0x4a2ea5[a15_0x1504('0x1a')][_0x3f55d3['id']]=_0x3f55d3;_0x4a2ea5[a15_0x1504('0x12')][_0x3f55d3['id']]=[];}}exports[a15_0x1504('0x1f')]=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

@@ -10,2 +10,2 @@ import { CloudTaskRunnerOptions } from '../core/models/cloud-task-runner-options';

export declare function printDuration(description: string, callback: Function): Promise<any>;
export declare function axiosMultipleTries(axiosCallCreator: () => Promise<any>, retriesLeft?: number): any;
export declare function axiosMultipleTries(axiosCallCreator: () => Promise<any>, retriesLeft?: number): Promise<any>;

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

let axiosConfigBuilder = (axiosConfig) => axiosConfig;
const baseUrl = options.url || 'https://cloud.nx.app';
const baseUrl = process.env.NX_CLOUD_API || options.url || 'https://cloud.nx.app';
const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken;

@@ -31,0 +31,0 @@ if (!accessToken) {

{
"name": "nx-cloud",
"version": "16.0.5",
"version": "16.1.0-beta.1",
"description": "Distributed caching and task execution for Lerna and Nx",

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc