Socket
Socket
Sign inDemoInstall

nx-cloud

Package Overview
Dependencies
Maintainers
1
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 14.0.6-beta.1 to 14.0.6

37

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

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

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorReporterApi = void 0;
const axios_1 = require("../../utilities/axios");
const { output } = require('../../utilities/nx-imports');
class ErrorReporterApi {
constructor(options) {
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
reportError(message) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', {
message,
}));
}
catch (e) {
output.warn({
title: `Unable to record the following error: '${message}'`,
bodyLines: [e.message],
});
}
});
}
}
exports.ErrorReporterApi = ErrorReporterApi;
//# sourceMappingURL=error-reporter.api.js.map
const a0_0x4a6b=['../../utilities/nx-imports','message','reportError','__esModule','createApiAxiosInstance','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','apply','__awaiter','warn','post','ErrorReporterApi','/nx-cloud/report-client-error','next','axiosMultipleTries','done','../../utilities/axios','defineProperty','apiAxiosInstance'];(function(_0x34b1ac,_0x4a6bd6){const _0x1d0e86=function(_0x1fdff6){while(--_0x1fdff6){_0x34b1ac['push'](_0x34b1ac['shift']());}};_0x1d0e86(++_0x4a6bd6);}(a0_0x4a6b,0x141));const a0_0x1d0e=function(_0x34b1ac,_0x4a6bd6){_0x34b1ac=_0x34b1ac-0x0;let _0x1d0e86=a0_0x4a6b[_0x34b1ac];return _0x1d0e86;};'use strict';var __awaiter=this&&this[a0_0x1d0e('0xa')]||function(_0x4083db,_0x268419,_0x5a595,_0x4087b6){function _0x7c84a5(_0x5a46ea){return _0x5a46ea instanceof _0x5a595?_0x5a46ea:new _0x5a595(function(_0x5171e9){_0x5171e9(_0x5a46ea);});}return new(_0x5a595||(_0x5a595=Promise))(function(_0x2f3089,_0x34b7b6){function _0x3cbdf8(_0x19c755){try{_0x2b0a82(_0x4087b6[a0_0x1d0e('0xf')](_0x19c755));}catch(_0x146622){_0x34b7b6(_0x146622);}}function _0x6633cd(_0x471c17){try{_0x2b0a82(_0x4087b6['throw'](_0x471c17));}catch(_0x1e953c){_0x34b7b6(_0x1e953c);}}function _0x2b0a82(_0x323a20){_0x323a20[a0_0x1d0e('0x11')]?_0x2f3089(_0x323a20['value']):_0x7c84a5(_0x323a20['value'])['then'](_0x3cbdf8,_0x6633cd);}_0x2b0a82((_0x4087b6=_0x4087b6[a0_0x1d0e('0x9')](_0x4083db,_0x268419||[]))[a0_0x1d0e('0xf')]());});};Object[a0_0x1d0e('0x1')](exports,a0_0x1d0e('0x6'),{'value':!![]});exports[a0_0x1d0e('0xd')]=void 0x0;const axios_1=require(a0_0x1d0e('0x0'));const {output}=require(a0_0x1d0e('0x3'));class ErrorReporterApi{constructor(_0xf0e689){this['apiAxiosInstance']=(0x0,axios_1[a0_0x1d0e('0x7')])(_0xf0e689);}[a0_0x1d0e('0x5')](_0x304609){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x1d0e('0x10')])(()=>this[a0_0x1d0e('0x2')][a0_0x1d0e('0xc')](a0_0x1d0e('0xe'),{'message':_0x304609}));}catch(_0x105ffe){output[a0_0x1d0e('0xb')]({'title':a0_0x1d0e('0x8')+_0x304609+'\x27','bodyLines':[_0x105ffe[a0_0x1d0e('0x4')]]});}});}}exports[a0_0x1d0e('0xd')]=ErrorReporterApi;

@@ -1,65 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunGroupApi = void 0;
const axios_1 = require("../../utilities/axios");
const metric_logger_1 = require("../../utilities/metric-logger");
const { output } = require('../../utilities/nx-imports');
class RunGroupApi {
constructor(options) {
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
createRunGroup(branch, runGroup) {
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: branch,
runGroup: runGroup,
}));
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(runGroup) {
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/complete-run-group', {
runGroup: runGroup,
}));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
output.error({
title: e.message,
});
process.exit(1);
}
});
}
}
exports.RunGroupApi = RunGroupApi;
//# sourceMappingURL=run-group.api.js.map
const a1_0xc099=['axiosMultipleTries','exit','message','completeRunGroup','done','../../utilities/axios','/nx-cloud/executions/create-run-group','createRunGroup','next','/nx-cloud/executions/complete-run-group','__esModule','createApiAxiosInstance','../../utilities/metric-logger','response','RUNNER_FAILURE_PERF_ENTRY','apply','then','apiAxiosInstance','RunGroupApi','recordMetric','value','createMetricRecorder','error','axiosException'];(function(_0x8ae972,_0xc099c7){const _0x213d4b=function(_0x5d8dc2){while(--_0x5d8dc2){_0x8ae972['push'](_0x8ae972['shift']());}};_0x213d4b(++_0xc099c7);}(a1_0xc099,0x88));const a1_0x213d=function(_0x8ae972,_0xc099c7){_0x8ae972=_0x8ae972-0x0;let _0x213d4b=a1_0xc099[_0x8ae972];return _0x213d4b;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x5c61c3,_0x5d0894,_0x303275,_0x2b030d){function _0x36310e(_0x315b03){return _0x315b03 instanceof _0x303275?_0x315b03:new _0x303275(function(_0x75e815){_0x75e815(_0x315b03);});}return new(_0x303275||(_0x303275=Promise))(function(_0x52224a,_0x51ae8a){function _0x198c0a(_0x595a36){try{_0x4486f8(_0x2b030d[a1_0x213d('0x10')](_0x595a36));}catch(_0x3039aa){_0x51ae8a(_0x3039aa);}}function _0x403c67(_0x2ad000){try{_0x4486f8(_0x2b030d['throw'](_0x2ad000));}catch(_0x491a75){_0x51ae8a(_0x491a75);}}function _0x4486f8(_0xd0eb9d){_0xd0eb9d[a1_0x213d('0xc')]?_0x52224a(_0xd0eb9d[a1_0x213d('0x4')]):_0x36310e(_0xd0eb9d['value'])[a1_0x213d('0x0')](_0x198c0a,_0x403c67);}_0x4486f8((_0x2b030d=_0x2b030d[a1_0x213d('0x17')](_0x5c61c3,_0x5d0894||[]))['next']());});};Object['defineProperty'](exports,a1_0x213d('0x12'),{'value':!![]});exports['RunGroupApi']=void 0x0;const axios_1=require(a1_0x213d('0xd'));const metric_logger_1=require(a1_0x213d('0x14'));const {output}=require('../../utilities/nx-imports');class RunGroupApi{constructor(_0x15e4bc){this[a1_0x213d('0x1')]=(0x0,axios_1[a1_0x213d('0x13')])(_0x15e4bc);}[a1_0x213d('0xf')](_0x14c1dc,_0x43205a){var _0x46f952;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1ad305=(0x0,metric_logger_1[a1_0x213d('0x5')])('createRunGroup');try{const _0x4e202a=yield(0x0,axios_1[a1_0x213d('0x8')])(()=>this[a1_0x213d('0x1')]['post'](a1_0x213d('0xe'),{'branch':_0x14c1dc,'runGroup':_0x43205a}));_0x1ad305['recordMetric']((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x4e202a));}catch(_0x3d05db){_0x1ad305[a1_0x213d('0x3')](((_0x46f952=_0x3d05db===null||_0x3d05db===void 0x0?void 0x0:_0x3d05db[a1_0x213d('0x7')])===null||_0x46f952===void 0x0?void 0x0:_0x46f952[a1_0x213d('0x15')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x3d05db[a1_0x213d('0x7')][a1_0x213d('0x15')]):metric_logger_1[a1_0x213d('0x16')]);output[a1_0x213d('0x6')]({'title':_0x3d05db[a1_0x213d('0xa')]});process[a1_0x213d('0x9')](0x1);}});}[a1_0x213d('0xb')](_0x3bdcd8){var _0x2e61aa;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x451d20=(0x0,metric_logger_1[a1_0x213d('0x5')])(a1_0x213d('0xf'));try{const _0x8a9ea7=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a1_0x213d('0x1')]['post'](a1_0x213d('0x11'),{'runGroup':_0x3bdcd8}));_0x451d20[a1_0x213d('0x3')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x8a9ea7));}catch(_0x41adf9){_0x451d20[a1_0x213d('0x3')](((_0x2e61aa=_0x41adf9===null||_0x41adf9===void 0x0?void 0x0:_0x41adf9[a1_0x213d('0x7')])===null||_0x2e61aa===void 0x0?void 0x0:_0x2e61aa[a1_0x213d('0x15')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x41adf9[a1_0x213d('0x7')][a1_0x213d('0x15')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a1_0x213d('0x6')]({'title':_0x41adf9[a1_0x213d('0xa')]});process[a1_0x213d('0x9')](0x1);}});}}exports[a1_0x213d('0x2')]=RunGroupApi;

@@ -1,141 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudEnabledLifeCycle = void 0;
const path = require("path");
const path_1 = require("path");
const fs_1 = require("fs");
const environment_1 = require("../../../utilities/environment");
const { workspaceRoot, unparse } = require('../../../utilities/nx-imports');
class CloudEnabledLifeCycle {
constructor(runContext, cacheDirectory, skipNxCache, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
this.runContext = runContext;
this.cacheDirectory = cacheDirectory;
this.skipNxCache = skipNxCache;
this.collectTerminalOutput = collectTerminalOutput;
this.cacheableOperations = cacheableOperations;
this.outputObfuscator = outputObfuscator;
this.tasks = tasks;
}
scheduleTask(task) {
this.runContext.scheduledTasks.push(task);
}
startTask(task) {
const overrides = Object.assign({}, (task.overrides || {}));
if (task.target.configuration) {
overrides['configuration'] = task.target.configuration;
}
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: unparse(overrides).join(' '),
});
}
// Used for older version for Nx. Remove in Dec 2022
endTask(task, code) {
let cacheStatus;
if (this.runContext.statuses[task.hash]) {
cacheStatus = this.runContext.statuses[task.hash];
}
else {
if (this.cacheableOperations.indexOf(task.target.target) > -1 &&
!this.skipNxCache) {
cacheStatus = 'local-cache-hit';
}
else {
cacheStatus = 'cache-miss';
}
}
this.updateStartedTask(task, code, cacheStatus);
}
endTasks(tasks) {
for (let t of tasks) {
const status = t.status === 'remote-cache'
? 'remote-cache-hit'
: t.status === 'local-cache' ||
t.status === 'local-cache-kept-existing'
? 'local-cache-hit'
: 'cache-miss';
this.updateStartedTask(t.task, t.code, status);
}
}
endCommand() { }
updateStartedTask(task, code, cacheStatus) {
const startedTask = this.tasks.find((t) => t.taskId === task.id);
if (!startedTask) {
throw new Error(`Cannot find task ${task.id}`);
}
startedTask.endTime = new Date().toISOString();
startedTask.status = code;
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
startedTask.cacheStatus = cacheStatus;
if (this.collectTerminalOutput) {
startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
}
}
getTerminalOutput(hash, cacheStatus, code) {
let dir;
if (this.cacheDirectory) {
if (this.cacheDirectory.startsWith('./')) {
dir = (0, path_1.join)(workspaceRoot, this.cacheDirectory);
}
else {
dir = this.cacheDirectory;
}
}
else {
dir = (0, path_1.join)(workspaceRoot, 'node_modules', '.cache', 'nx');
}
try {
const taskOutput = this.readTerminalOutputFile(dir, hash);
const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
if (environment_1.NX_CLOUD_UNLIMITED_OUTPUT)
return taskOutputSanitized;
const maxCharacters = cacheStatus === 'cache-miss'
? code === 0
? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
: CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
: CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
return taskOutputSanitized.length > maxCharacters
? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
: taskOutputSanitized;
}
catch (e) {
return '';
}
}
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,
};
}
readTerminalOutputFile(dir, hash) {
try {
return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
}
catch (_a) {
try {
return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
}
catch (_b) {
return '';
}
}
}
}
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 20000;
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
const a0_0x3a17=['push','code','runtime','defineProperty','startsWith','NX_CLOUD_UNLIMITED_OUTPUT','cacheableOperations','MAX_CHARACTERS_SUCCESSFUL_TASK','readTerminalOutputFile','implicitDeps','endTime','npm:','scheduledTasks','__esModule','MAX_CHARACTERS_CACHED_TASK','remote-cache-hit','filter','overrides','Cannot\x20find\x20task\x20','skipNxCache','cleanUpHashDetails','CloudEnabledLifeCycle','nodes','remote-cache','../../../utilities/nx-imports','terminalOutputs','status','join','local-cache-hit','terminalOutput','target','updateStartedTask','find','tasks','runContext','MAX_CHARACTERS_FAILED_TASK','indexOf','endCommand','assign','TRUNCATED\x0a\x0a','cache-miss','length','outputObfuscator','project','taskId','toString','statuses','slice','readFileSync','forEach','task','toISOString','path','configuration','params','obfuscate','endTasks','cacheStatus','cacheDirectory','local-cache-kept-existing','getTerminalOutput','collectTerminalOutput','hash'];(function(_0x5cea3a,_0x3a171c){const _0xc3145d=function(_0x27350b){while(--_0x27350b){_0x5cea3a['push'](_0x5cea3a['shift']());}};_0xc3145d(++_0x3a171c);}(a0_0x3a17,0x1ea));const a0_0xc314=function(_0x5cea3a,_0x3a171c){_0x5cea3a=_0x5cea3a-0x0;let _0xc3145d=a0_0x3a17[_0x5cea3a];return _0xc3145d;};'use strict';Object[a0_0xc314('0x11')](exports,a0_0xc314('0x1b'),{'value':!![]});exports['CloudEnabledLifeCycle']=void 0x0;const path=require(a0_0xc314('0x3'));const path_1=require(a0_0xc314('0x3'));const fs_1=require('fs');const environment_1=require('../../../utilities/environment');const {workspaceRoot,unparse}=require(a0_0xc314('0x26'));class CloudEnabledLifeCycle{constructor(_0x4a123a,_0x128b53,_0x38eeeb,_0x33ef30,_0x4b9f13,_0x447bb9,_0x5719c1){this[a0_0xc314('0x30')]=_0x4a123a;this['cacheDirectory']=_0x128b53;this[a0_0xc314('0x21')]=_0x38eeeb;this[a0_0xc314('0xc')]=_0x33ef30;this[a0_0xc314('0x14')]=_0x4b9f13;this[a0_0xc314('0x38')]=_0x447bb9;this[a0_0xc314('0x2f')]=_0x5719c1;}['scheduleTask'](_0x32760f){this[a0_0xc314('0x30')][a0_0xc314('0x1a')][a0_0xc314('0xe')](_0x32760f);}['startTask'](_0x3ac6e1){const _0x21b434=Object[a0_0xc314('0x34')]({},_0x3ac6e1[a0_0xc314('0x1f')]||{});if(_0x3ac6e1[a0_0xc314('0x2c')][a0_0xc314('0x4')]){_0x21b434['configuration']=_0x3ac6e1['target'][a0_0xc314('0x4')];}this[a0_0xc314('0x2f')]['push']({'taskId':_0x3ac6e1['id'],'startTime':new Date()['toISOString'](),'target':_0x3ac6e1[a0_0xc314('0x2c')][a0_0xc314('0x2c')],'projectName':_0x3ac6e1[a0_0xc314('0x2c')][a0_0xc314('0x39')],'hash':_0x3ac6e1[a0_0xc314('0xd')],'hashDetails':this['cleanUpHashDetails'](_0x3ac6e1['hashDetails']),'params':unparse(_0x21b434)[a0_0xc314('0x29')]('\x20')});}['endTask'](_0x567b16,_0x2499a6){let _0x3e4be3;if(this['runContext'][a0_0xc314('0x3c')][_0x567b16[a0_0xc314('0xd')]]){_0x3e4be3=this[a0_0xc314('0x30')][a0_0xc314('0x3c')][_0x567b16[a0_0xc314('0xd')]];}else{if(this[a0_0xc314('0x14')][a0_0xc314('0x32')](_0x567b16[a0_0xc314('0x2c')][a0_0xc314('0x2c')])>-0x1&&!this[a0_0xc314('0x21')]){_0x3e4be3=a0_0xc314('0x2a');}else{_0x3e4be3=a0_0xc314('0x36');}}this[a0_0xc314('0x2d')](_0x567b16,_0x2499a6,_0x3e4be3);}[a0_0xc314('0x7')](_0x35ef9b){for(let _0x2bb86b of _0x35ef9b){const _0xc0dac4=_0x2bb86b[a0_0xc314('0x28')]===a0_0xc314('0x25')?a0_0xc314('0x1d'):_0x2bb86b['status']==='local-cache'||_0x2bb86b[a0_0xc314('0x28')]===a0_0xc314('0xa')?a0_0xc314('0x2a'):a0_0xc314('0x36');this[a0_0xc314('0x2d')](_0x2bb86b[a0_0xc314('0x1')],_0x2bb86b[a0_0xc314('0xf')],_0xc0dac4);}}[a0_0xc314('0x33')](){}[a0_0xc314('0x2d')](_0x169ff6,_0x18bbb6,_0x322325){const _0x463534=this[a0_0xc314('0x2f')][a0_0xc314('0x2e')](_0x2c4300=>_0x2c4300[a0_0xc314('0x3a')]===_0x169ff6['id']);if(!_0x463534){throw new Error(a0_0xc314('0x20')+_0x169ff6['id']);}_0x463534[a0_0xc314('0x18')]=new Date()[a0_0xc314('0x2')]();_0x463534[a0_0xc314('0x28')]=_0x18bbb6;_0x463534[a0_0xc314('0x5')]=this[a0_0xc314('0x38')][a0_0xc314('0x6')](_0x463534[a0_0xc314('0x5')]);_0x463534[a0_0xc314('0x8')]=_0x322325;if(this[a0_0xc314('0xc')]){_0x463534[a0_0xc314('0x2b')]=this[a0_0xc314('0xb')](_0x169ff6[a0_0xc314('0xd')],_0x463534[a0_0xc314('0x8')],_0x18bbb6);}}[a0_0xc314('0xb')](_0x50bed2,_0x5ecaf0,_0x44f856){let _0x1d6c58;if(this[a0_0xc314('0x9')]){if(this['cacheDirectory'][a0_0xc314('0x12')]('./')){_0x1d6c58=(0x0,path_1[a0_0xc314('0x29')])(workspaceRoot,this['cacheDirectory']);}else{_0x1d6c58=this['cacheDirectory'];}}else{_0x1d6c58=(0x0,path_1[a0_0xc314('0x29')])(workspaceRoot,'node_modules','.cache','nx');}try{const _0x4a327d=this[a0_0xc314('0x16')](_0x1d6c58,_0x50bed2);const _0xb7f607=this[a0_0xc314('0x38')][a0_0xc314('0x6')](_0x4a327d);if(environment_1[a0_0xc314('0x13')])return _0xb7f607;const _0x525a4c=_0x5ecaf0===a0_0xc314('0x36')?_0x44f856===0x0?CloudEnabledLifeCycle[a0_0xc314('0x15')]:CloudEnabledLifeCycle[a0_0xc314('0x31')]:CloudEnabledLifeCycle['MAX_CHARACTERS_CACHED_TASK'];return _0xb7f607['length']>_0x525a4c?a0_0xc314('0x35')+_0xb7f607[a0_0xc314('0x3d')](_0xb7f607[a0_0xc314('0x37')]-_0x525a4c):_0xb7f607;}catch(_0x41d68f){return'';}}[a0_0xc314('0x22')](_0x24e111){const _0x54f8a5={};Object['keys'](_0x24e111[a0_0xc314('0x24')])[a0_0xc314('0x1e')](_0x4f1637=>!_0x4f1637[a0_0xc314('0x12')](a0_0xc314('0x19')))[a0_0xc314('0x0')](_0x1b8c7b=>{_0x54f8a5[_0x1b8c7b]=_0x24e111[a0_0xc314('0x24')][_0x1b8c7b];});return{'nodes':_0x54f8a5,'runtime':_0x24e111[a0_0xc314('0x10')],'implicitDeps':_0x24e111[a0_0xc314('0x17')]};}[a0_0xc314('0x16')](_0x49c698,_0xffed54){try{return(0x0,fs_1[a0_0xc314('0x3e')])(path[a0_0xc314('0x29')](_0x49c698,a0_0xc314('0x27'),_0xffed54))[a0_0xc314('0x3b')]();}catch(_0x549dfc){try{return(0x0,fs_1['readFileSync'])(path[a0_0xc314('0x29')](_0x49c698,_0xffed54,a0_0xc314('0x2b')))[a0_0xc314('0x3b')]();}catch(_0x4fc4ec){return'';}}}}exports[a0_0xc314('0x23')]=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0xc314('0x31')]=0x30d40;CloudEnabledLifeCycle[a0_0xc314('0x15')]=0x4e20;CloudEnabledLifeCycle[a0_0xc314('0x1c')]=0x4e20;

@@ -1,169 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloudEnabledTasksRunner = void 0;
const message_reporter_1 = require("../../terminal-output/message-reporter");
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
const file_storage_1 = require("../../file-storage/file-storage");
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
const environment_1 = require("../../../utilities/environment");
const cloud_remote_cache_1 = require("./cloud-remote-cache");
const cloud_run_api_1 = require("./cloud-run.api");
const fs_1 = require("fs");
const path = require("path");
const metric_logger_1 = require("../../../utilities/metric-logger");
const error_reporter_api_1 = require("../../api/error-reporter.api");
const { tasksRunner, output } = 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);
}
function onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner) {
return __awaiter(this, void 0, void 0, function* () {
const runEndTime = new Date().toISOString();
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
storeTaskHashes(taskExecutions, options.cacheDirectory || './node_modules/.cache/nx', environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
}
const branch = (0, environment_1.getBranch)();
const endRequest = yield Promise.all([
remoteCache.waitForStoreRequestsToComplete(),
api.endRun({
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
startTime: runStartTime,
endTime: runEndTime,
distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
branch: branch,
scan: true,
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,
}, taskExecutions),
]);
// 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();
}
}
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
if (!endRequest[0]) {
output.error({
title: `Agent wasn't able to store artifacts`,
});
messages.printMessages();
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
if (!endRequest[1]) {
output.error({
title: `Agent wasn't able to record its run`,
});
messages.printMessages();
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
}
yield (0, metric_logger_1.submitRunMetrics)(options);
});
}
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, options.cacheDirectory, !!options.skipNxCache, options.scan === undefined ? true : options.scan, 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 cloudEnabledTasksRunner(tasks, options, context, inner = false) {
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);
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
const hashes = tasks.map((t) => t.hash).filter((h) => !!h);
const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
hashes.forEach((hash) => {
runContext.requests[hash] = startRunRequest;
});
const runStartTime = new Date().toISOString();
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, false);
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
// 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* () {
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
wrappedRes.complete();
}),
});
return wrappedRes;
// promise
}
else {
return res
.then((r) => __awaiter(this, void 0, void 0, function* () {
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
return r;
}))
.catch((e) => __awaiter(this, void 0, void 0, function* () {
yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
throw e;
}));
}
}
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
//# sourceMappingURL=cloud-enabled.runner.js.map
const a1_0x1717=['getRunGroup','then','cacheableOperations','assign','printMessages','MessageReporter','cloudEnabledTasksRunner','../../terminal-output/output-obfuscator','lifeCycle','Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts','../../../utilities/nx-imports','waitForStoreRequestsToComplete','E2EEncryption','scan','hash','__esModule','cacheDirectory','catch','./cloud-run.api','writeFileSync','value','OutputObfuscator','../../file-storage/e2e-encryption','exit','forEach','VERBOSE_LOGGING','../../terminal-output/message-reporter','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','FileStorage','error','CloudRunApi','taskId','../../../utilities/environment','printCacheHitsMessage','EndOfRunMessage','skipNxCache','stringify','Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run','subscribe','startRun','../../api/error-reporter.api','../../../utilities/metric-logger','env','../../terminal-output/end-of-run-message','getBranch','join','toISOString','anyErrors','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','filter','all','getMachineInfo','CloudEnabledLifeCycle','__awaiter','next','complete','requests','./node_modules/.cache/nx','map','endRun','done','maskedProperties','rxjs/internal/Subject','parseCommand'];(function(_0x26f30c,_0x171775){const _0x3272d0=function(_0x17a674){while(--_0x17a674){_0x26f30c['push'](_0x26f30c['shift']());}};_0x3272d0(++_0x171775);}(a1_0x1717,0x6e));const a1_0x3272=function(_0x26f30c,_0x171775){_0x26f30c=_0x26f30c-0x0;let _0x3272d0=a1_0x1717[_0x26f30c];return _0x3272d0;};'use strict';var __awaiter=this&&this[a1_0x3272('0x7')]||function(_0x43978e,_0x5c1f8e,_0x9888be,_0x516c04){function _0x129171(_0x13d5a6){return _0x13d5a6 instanceof _0x9888be?_0x13d5a6:new _0x9888be(function(_0x282c2f){_0x282c2f(_0x13d5a6);});}return new(_0x9888be||(_0x9888be=Promise))(function(_0x17a487,_0xc34a2c){function _0x2f171b(_0x5c900e){try{_0x41ab0d(_0x516c04[a1_0x3272('0x8')](_0x5c900e));}catch(_0x5709ef){_0xc34a2c(_0x5709ef);}}function _0xac9a47(_0x75f910){try{_0x41ab0d(_0x516c04['throw'](_0x75f910));}catch(_0x2916f0){_0xc34a2c(_0x2916f0);}}function _0x41ab0d(_0x1acdef){_0x1acdef[a1_0x3272('0xe')]?_0x17a487(_0x1acdef['value']):_0x129171(_0x1acdef[a1_0x3272('0x26')])[a1_0x3272('0x13')](_0x2f171b,_0xac9a47);}_0x41ab0d((_0x516c04=_0x516c04['apply'](_0x43978e,_0x5c1f8e||[]))[a1_0x3272('0x8')]());});};Object['defineProperty'](exports,a1_0x3272('0x21'),{'value':!![]});exports[a1_0x3272('0x18')]=void 0x0;const message_reporter_1=require(a1_0x3272('0x2c'));const end_of_run_message_1=require(a1_0x3272('0x3d'));const output_obfuscator_1=require(a1_0x3272('0x19'));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(a1_0x3272('0x28'));const environment_1=require(a1_0x3272('0x32'));const cloud_remote_cache_1=require('./cloud-remote-cache');const cloud_run_api_1=require(a1_0x3272('0x24'));const fs_1=require('fs');const path=require('path');const metric_logger_1=require(a1_0x3272('0x3b'));const error_reporter_api_1=require(a1_0x3272('0x3a'));const {tasksRunner,output}=require(a1_0x3272('0x1c'));function createApi(_0x2bf162,_0x3cb7e6,_0x17f7bb){const _0x51fa89=(0x0,environment_1[a1_0x3272('0x5')])(_0x3cb7e6);return new cloud_run_api_1[(a1_0x3272('0x30'))](_0x2bf162,_0x17f7bb,_0x3cb7e6,_0x51fa89);}function storeTaskHashes(_0x1a8e1f,_0xfd2e1e,_0x4ef4a1){const _0x3c4da6=JSON[a1_0x3272('0x36')](_0x1a8e1f[a1_0x3272('0xc')](_0x55b245=>({'taskId':_0x55b245[a1_0x3272('0x31')],'hash':_0x55b245[a1_0x3272('0x20')]})));if(environment_1[a1_0x3272('0x2b')]){output['note']({'title':'Executed\x20tasks\x20with\x20hashes:\x20'+_0x3c4da6});}(0x0,fs_1[a1_0x3272('0x25')])(path[a1_0x3272('0x3f')](_0xfd2e1e,'tasks-hashes-'+_0x4ef4a1),_0x3c4da6);}function onComplete(_0x2728ce,_0x4029de,_0x25a82a,_0x521186,_0x3bc598,_0x3c1025,_0x530b07,_0x2cdc0f,_0x25028a,_0x1d8c56,_0x46aedb){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3064dc=new Date()[a1_0x3272('0x0')]();if(environment_1['AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION']){storeTaskHashes(_0x25028a,_0x4029de[a1_0x3272('0x22')]||a1_0x3272('0xb'),environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID']);}const _0x3e3c58=(0x0,environment_1[a1_0x3272('0x3e')])();const _0x1d9578=yield Promise[a1_0x3272('0x4')]([_0x25a82a[a1_0x3272('0x1d')](),_0x521186[a1_0x3272('0xd')]({'command':_0x3bc598['obfuscate']((0x0,environment_1[a1_0x3272('0x11')])()),'startTime':_0x3c1025,'endTime':_0x3064dc,'distributedExecutionId':environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],'branch':_0x3e3c58,'scan':!![],'runGroup':(0x0,environment_1[a1_0x3272('0x12')])(),'sha':_0x3e3c58?(0x0,environment_1['extractGitSha'])():undefined,'inner':_0x46aedb},_0x25028a)]);if(_0x1d8c56){setTimeout(()=>{_0x530b07['printMessages']();if(!_0x530b07[a1_0x3272('0x1')]&&!_0x46aedb){_0x2cdc0f[a1_0x3272('0x33')]();}},0x0);}else{_0x530b07[a1_0x3272('0x16')]();if(!_0x530b07[a1_0x3272('0x1')]&&!_0x46aedb){_0x2cdc0f['printCacheHitsMessage']();}}if(environment_1['AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION']){if(!_0x1d9578[0x0]){output['error']({'title':a1_0x3272('0x1b')});_0x530b07[a1_0x3272('0x16')]();process[a1_0x3272('0x29')](environment_1[a1_0x3272('0x2')]);}if(!_0x1d9578[0x1]){output['error']({'title':a1_0x3272('0x37')});_0x530b07[a1_0x3272('0x16')]();process['exit'](environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']);}}yield(0x0,metric_logger_1['submitRunMetrics'])(_0x4029de);});}function createLifeCycle(_0x39e29f,_0x39d912,_0x2a6cfd,_0x3345ef){const _0x1656d3=new cloud_enabled_life_cycle_1[(a1_0x3272('0x6'))](_0x39e29f,_0x39d912[a1_0x3272('0x22')],!!_0x39d912[a1_0x3272('0x35')],_0x39d912[a1_0x3272('0x1f')]===undefined?!![]:_0x39d912[a1_0x3272('0x1f')],_0x39d912[a1_0x3272('0x14')]||[],_0x2a6cfd,_0x3345ef);try{const {CompositeLifeCycle}=require(a1_0x3272('0x1c'));if(!CompositeLifeCycle)return _0x1656d3;return new CompositeLifeCycle([_0x39d912['lifeCycle'],_0x1656d3]);}catch(_0x35e308){return _0x1656d3;}}function cloudEnabledTasksRunner(_0xe325fc,_0x374492,_0xb8381b,_0x1e0ce3=![]){const _0x4a53a1={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0xe325fc};const _0x48ba1f=_0x374492[a1_0x3272('0x1a')]===undefined;const _0x3dca6f=[];const _0x291820=new message_reporter_1[(a1_0x3272('0x17'))](_0x374492);const _0x35c528=createApi(_0x291820,_0x374492,_0x4a53a1);const _0x44de27=new end_of_run_message_1[(a1_0x3272('0x34'))](_0x4a53a1,_0x3dca6f);const _0x27019e=new output_obfuscator_1[(a1_0x3272('0x27'))](_0x374492[a1_0x3272('0xf')]);const _0xf0db41=_0xe325fc[a1_0x3272('0xc')](_0x130748=>_0x130748[a1_0x3272('0x20')])[a1_0x3272('0x3')](_0x34771a=>!!_0x34771a);const _0x253b4c=_0x35c528[a1_0x3272('0x39')](environment_1[a1_0x3272('0x2d')],_0xf0db41);_0xf0db41[a1_0x3272('0x2a')](_0x55184d=>{_0x4a53a1[a1_0x3272('0xa')][_0x55184d]=_0x253b4c;});const _0x3ad55d=new Date()['toISOString']();const _0x3a3d3b=createLifeCycle(_0x4a53a1,_0x374492,_0x27019e,_0x3dca6f);const _0x5c28f3=new e2e_encryption_1[(a1_0x3272('0x1e'))](environment_1['ENCRYPTION_KEY']||_0x374492['encryptionKey']);const _0x52a9ed=new error_reporter_api_1['ErrorReporterApi'](_0x374492);const _0x1ae756=new file_storage_1[(a1_0x3272('0x2e'))](_0x5c28f3,_0x52a9ed,![]);const _0x5334f2=new cloud_remote_cache_1['CloudRemoteCache'](_0x291820,_0x35c528,_0x4a53a1,_0x1ae756);delete process[a1_0x3272('0x3c')][a1_0x3272('0x2d')];const _0x3cd4ec=tasksRunner(_0xe325fc,Object[a1_0x3272('0x15')](Object[a1_0x3272('0x15')]({},_0x374492),{'remoteCache':_0x5334f2,'lifeCycle':_0x3a3d3b}),_0xb8381b);if(_0x3cd4ec[a1_0x3272('0x38')]){const {Subject}=require(a1_0x3272('0x10'));const _0x5e7bfc=new Subject();_0x3cd4ec['subscribe']({'next':_0x16eb4b=>_0x5e7bfc['next'](_0x16eb4b),'error':_0x57fe5a=>_0x5e7bfc[a1_0x3272('0x2f')](_0x57fe5a),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x3a3d3b,_0x374492,_0x5334f2,_0x35c528,_0x27019e,_0x3ad55d,_0x291820,_0x44de27,_0x3dca6f,_0x48ba1f,_0x1e0ce3);_0x5e7bfc[a1_0x3272('0x9')]();})});return _0x5e7bfc;}else{return _0x3cd4ec['then'](_0x4d88ee=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x3a3d3b,_0x374492,_0x5334f2,_0x35c528,_0x27019e,_0x3ad55d,_0x291820,_0x44de27,_0x3dca6f,_0x48ba1f,_0x1e0ce3);return _0x4d88ee;}))[a1_0x3272('0x23')](_0x56585d=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x3a3d3b,_0x374492,_0x5334f2,_0x35c528,_0x27019e,_0x3ad55d,_0x291820,_0x44de27,_0x3dca6f,_0x48ba1f,_0x1e0ce3);throw _0x56585d;}));}}exports[a1_0x3272('0x18')]=cloudEnabledTasksRunner;

@@ -1,113 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudRemoteCache = void 0;
const environment_1 = require("../../../utilities/environment");
const { output } = require('../../../utilities/nx-imports');
class CloudRemoteCache {
constructor(messages, api, runContext, fileStorage) {
this.messages = messages;
this.api = api;
this.runContext = runContext;
this.fileStorage = fileStorage;
this.storeRequests = [];
}
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;
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}. Read only token is used.`,
});
}
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(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, scheduledTaskHashesWithoutRequests);
scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
this.runContext.requests[taskHash] = request;
});
return (yield request)[hash];
}
});
}
waitForStoreRequestsToComplete() {
return Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
}
}
exports.CloudRemoteCache = CloudRemoteCache;
//# sourceMappingURL=cloud-remote-cache.js.map
const a2_0x5911=['VERBOSE_LOGGING','push','map','waitForStoreRequestsToComplete','next','then','defineProperty','note','messages','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','requests','forEach','__esModule','scheduledTasks','api','axiosException','remote-cache-hit','value','statuses','../../../utilities/environment','Nx\x20Cloud:\x20Cache\x20miss\x20','done','filter','extractErrorMessage','reduce','cacheError','.\x20Status\x20404.','runContext','retrieve','response','hash','storeRequests','storage','CloudRemoteCache','fileStorage','Nx\x20Cloud:\x20Skipping\x20storing\x20','startRun','.\x20Read\x20only\x20token\x20is\x20used.','hashUrls','store','put','apply','get'];(function(_0x454a66,_0x591138){const _0x40cef8=function(_0x5efe20){while(--_0x5efe20){_0x454a66['push'](_0x454a66['shift']());}};_0x40cef8(++_0x591138);}(a2_0x5911,0x187));const a2_0x40ce=function(_0x454a66,_0x591138){_0x454a66=_0x454a66-0x0;let _0x40cef8=a2_0x5911[_0x454a66];return _0x40cef8;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0xeb6ecb,_0x1b9586,_0x2ea17c,_0x56dfe4){function _0x29816f(_0x4eb2db){return _0x4eb2db instanceof _0x2ea17c?_0x4eb2db:new _0x2ea17c(function(_0x133dee){_0x133dee(_0x4eb2db);});}return new(_0x2ea17c||(_0x2ea17c=Promise))(function(_0x54757c,_0x270f5d){function _0x16f4e5(_0x37727f){try{_0x3bfdf9(_0x56dfe4[a2_0x40ce('0x0')](_0x37727f));}catch(_0x1cfcd2){_0x270f5d(_0x1cfcd2);}}function _0x552917(_0x4a7bef){try{_0x3bfdf9(_0x56dfe4['throw'](_0x4a7bef));}catch(_0x23f466){_0x270f5d(_0x23f466);}}function _0x3bfdf9(_0x5c1117){_0x5c1117[a2_0x40ce('0x11')]?_0x54757c(_0x5c1117[a2_0x40ce('0xd')]):_0x29816f(_0x5c1117[a2_0x40ce('0xd')])[a2_0x40ce('0x1')](_0x16f4e5,_0x552917);}_0x3bfdf9((_0x56dfe4=_0x56dfe4[a2_0x40ce('0x25')](_0xeb6ecb,_0x1b9586||[]))[a2_0x40ce('0x0')]());});};Object[a2_0x40ce('0x2')](exports,a2_0x40ce('0x8'),{'value':!![]});exports[a2_0x40ce('0x1d')]=void 0x0;const environment_1=require(a2_0x40ce('0xf'));const {output}=require('../../../utilities/nx-imports');class CloudRemoteCache{constructor(_0x482474,_0x2b27db,_0x19300a,_0x540d00){this[a2_0x40ce('0x4')]=_0x482474;this[a2_0x40ce('0xa')]=_0x2b27db;this['runContext']=_0x19300a;this[a2_0x40ce('0x1e')]=_0x540d00;this[a2_0x40ce('0x1b')]=[];}['retrieve'](_0x3fd3d6,_0x1f378d){var _0x8f2b65;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x40ce('0x4')]['cacheError'])return![];const _0x541b82=yield this[a2_0x40ce('0x22')](_0x3fd3d6);if(!_0x541b82||!_0x541b82[a2_0x40ce('0x26')]){if(environment_1[a2_0x40ce('0x27')]){output['note']({'title':a2_0x40ce('0x10')+_0x3fd3d6+'.'});}this[a2_0x40ce('0x17')][a2_0x40ce('0xe')][_0x3fd3d6]='cache-miss';return![];}try{yield this['fileStorage'][a2_0x40ce('0x18')](_0x3fd3d6,_0x541b82[a2_0x40ce('0x26')],_0x1f378d);this[a2_0x40ce('0x17')]['statuses'][_0x3fd3d6]=a2_0x40ce('0xc');return!![];}catch(_0x24d615){const _0x1db8dd=(_0x8f2b65=_0x24d615[a2_0x40ce('0xb')])!==null&&_0x8f2b65!==void 0x0?_0x8f2b65:_0x24d615;if(_0x1db8dd['response']&&_0x1db8dd[a2_0x40ce('0x19')]['status']===0x194){if(environment_1[a2_0x40ce('0x27')]){output[a2_0x40ce('0x3')]({'title':a2_0x40ce('0x10')+_0x3fd3d6+a2_0x40ce('0x16')});}}else{this[a2_0x40ce('0x4')][a2_0x40ce('0x15')]=this['messages'][a2_0x40ce('0x13')](_0x1db8dd,a2_0x40ce('0x1c'));}this[a2_0x40ce('0x17')][a2_0x40ce('0xe')][_0x3fd3d6]='cache-miss';return![];}});}['store'](_0x85ed4a,_0x260608){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x40ce('0x4')][a2_0x40ce('0x15')])return![];const _0x4cee95=Promise['resolve']()[a2_0x40ce('0x1')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x562b5a;const _0x1574b9=yield this[a2_0x40ce('0x22')](_0x85ed4a);if(!_0x1574b9)return![];if(!_0x1574b9['put']){if(environment_1[a2_0x40ce('0x27')]){output[a2_0x40ce('0x3')]({'title':a2_0x40ce('0x1f')+_0x85ed4a+a2_0x40ce('0x21')});}return!![];}try{yield this['fileStorage'][a2_0x40ce('0x23')](_0x85ed4a,_0x1574b9[a2_0x40ce('0x24')],_0x260608);return!![];}catch(_0x33fa09){const _0x258baf=(_0x562b5a=_0x33fa09[a2_0x40ce('0xb')])!==null&&_0x562b5a!==void 0x0?_0x562b5a:_0x33fa09;this[a2_0x40ce('0x4')]['cacheError']=this[a2_0x40ce('0x4')][a2_0x40ce('0x13')](_0x258baf,a2_0x40ce('0x1c'));return![];}}));this['storeRequests'][a2_0x40ce('0x28')](_0x4cee95);return _0x4cee95;});}[a2_0x40ce('0x22')](_0x4f2ed7){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x4f2ed7 in this[a2_0x40ce('0x17')][a2_0x40ce('0x6')]){return(yield this[a2_0x40ce('0x17')]['requests'][_0x4f2ed7])[_0x4f2ed7];}else{const _0x3cdd7e=this[a2_0x40ce('0x17')][a2_0x40ce('0x9')][a2_0x40ce('0x12')](_0x18d0d0=>!this['runContext'][a2_0x40ce('0x6')][_0x18d0d0[a2_0x40ce('0x1a')]])[a2_0x40ce('0x29')](_0x322895=>_0x322895[a2_0x40ce('0x1a')]);if(_0x3cdd7e['indexOf'](_0x4f2ed7)===-0x1){_0x3cdd7e[a2_0x40ce('0x28')](_0x4f2ed7);}const _0xe7e142=this[a2_0x40ce('0xa')][a2_0x40ce('0x20')](environment_1[a2_0x40ce('0x5')],_0x3cdd7e);_0x3cdd7e[a2_0x40ce('0x7')](_0x151b29=>{this[a2_0x40ce('0x17')]['requests'][_0x151b29]=_0xe7e142;});return(yield _0xe7e142)[_0x4f2ed7];}});}[a2_0x40ce('0x2a')](){return Promise['all'](this['storeRequests'])[a2_0x40ce('0x1')](_0x58957c=>_0x58957c[a2_0x40ce('0x14')]((_0x2e51ac,_0x1f8cb8)=>_0x2e51ac&&_0x1f8cb8,!![]));}}exports[a2_0x40ce('0x1d')]=CloudRemoteCache;

@@ -1,166 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudRunApi = void 0;
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const fs_1 = require("fs");
const zlib_1 = require("zlib");
const util_1 = require("util");
const metric_logger_1 = require("../../../utilities/metric-logger");
const { 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* () {
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)(),
distributedExecutionId,
hashes,
};
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'RunStart',
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
});
}
const resp = yield (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) {
const uncompressedReqBody = {
meta: {
nxCloudVersion: this.nxCloudVersion(),
},
tasks,
run: run,
machineInfo: this.machineInfo,
};
return JSON.stringify(uncompressedReqBody);
}
endRun(run, tasks) {
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);
// 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 }))));
}
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.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['@nrwl/nx-cloud'];
}
catch (e) {
return 'unknown';
}
}
}
exports.CloudRunApi = CloudRunApi;
//# sourceMappingURL=cloud-run.api.js.map
const a3_0x5c52=['axiosException','axiosMultipleTries','../../../utilities/axios','apply','/nx-cloud/runs/end','zlib','Invalid\x20Nx\x20Cloud\x20response:\x20','stack','nxCloudVersion','promisify','then','runUrl','endRun','Invalid\x20end\x20run\x20response:\x20','../../../utilities/environment','createMetricRecorder','throw','map','data','@nrwl/nx-cloud','...','assign','toString','status','post','terminalOutput','messages','getBranch','startRun','mapRespToPerfEntry','success','CloudRunApi','VERBOSE_LOGGING','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','RUNNER_FAILURE_PERF_ENTRY','value','../../../utilities/metric-logger','api','note','string','RunStart','Invalid\x20end\x20run\x20response','urls','defaults','Run\x20Details:','readFileSync','createReqBody','defineProperty','application/octet-stream','extractErrorMessage','recordMetric','parse','RunEnd.\x20Completed\x20tasks','headers','gzip','Run\x20completion\x20responded\x20with\x20`undefined`.','done','runContext','apiError','response','/nx-cloud/runs/start','package.json','next','message','length','stringify','apiAxiosInstance','__esModule','from','getRunGroup'];(function(_0x3abedc,_0x5c52d3){const _0x3783ff=function(_0x4ef6d1){while(--_0x4ef6d1){_0x3abedc['push'](_0x3abedc['shift']());}};_0x3783ff(++_0x5c52d3);}(a3_0x5c52,0x15a));const a3_0x3783=function(_0x3abedc,_0x5c52d3){_0x3abedc=_0x3abedc-0x0;let _0x3783ff=a3_0x5c52[_0x3abedc];return _0x3783ff;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x442996,_0x669a53,_0x28b404,_0x396d16){function _0x4cdb0e(_0x336c84){return _0x336c84 instanceof _0x28b404?_0x336c84:new _0x28b404(function(_0x5355c4){_0x5355c4(_0x336c84);});}return new(_0x28b404||(_0x28b404=Promise))(function(_0x3c3a0a,_0x163d50){function _0x22ef82(_0x50015b){try{_0x491483(_0x396d16[a3_0x3783('0x42')](_0x50015b));}catch(_0x9887c){_0x163d50(_0x9887c);}}function _0x36d8d0(_0x5e0d19){try{_0x491483(_0x396d16[a3_0x3783('0x14')](_0x5e0d19));}catch(_0x2b8d29){_0x163d50(_0x2b8d29);}}function _0x491483(_0x14c87b){_0x14c87b[a3_0x3783('0x3c')]?_0x3c3a0a(_0x14c87b['value']):_0x4cdb0e(_0x14c87b[a3_0x3783('0x27')])[a3_0x3783('0xe')](_0x22ef82,_0x36d8d0);}_0x491483((_0x396d16=_0x396d16[a3_0x3783('0x7')](_0x442996,_0x669a53||[]))['next']());});};Object[a3_0x3783('0x33')](exports,a3_0x3783('0x1'),{'value':!![]});exports[a3_0x3783('0x23')]=void 0x0;const axios_1=require(a3_0x3783('0x6'));const environment_1=require(a3_0x3783('0x12'));const fs_1=require('fs');const zlib_1=require(a3_0x3783('0x9'));const util_1=require('util');const metric_logger_1=require(a3_0x3783('0x28'));const {output}=require('../../../utilities/nx-imports');class CloudRunApi{constructor(_0x35b067,_0x439ead,_0x5171c9,_0x41a06e){this[a3_0x3783('0x1e')]=_0x35b067;this['runContext']=_0x439ead;this['machineInfo']=_0x41a06e;this[a3_0x3783('0x0')]=(0x0,axios_1['createApiAxiosInstance'])(_0x5171c9);}[a3_0x3783('0x20')](_0x153f99,_0x583548){var _0x5a27b6;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x271bff=(0x0,metric_logger_1[a3_0x3783('0x13')])('startRun');try{const _0x5288db={'meta':{'nxCloudVersion':this[a3_0x3783('0xc')]()},'branch':(0x0,environment_1[a3_0x3783('0x1f')])(),'runGroup':(0x0,environment_1[a3_0x3783('0x3')])(),'distributedExecutionId':_0x153f99,'hashes':_0x583548};if(environment_1[a3_0x3783('0x24')]){output[a3_0x3783('0x2a')]({'title':a3_0x3783('0x2c'),'bodyLines':['\x0a'+JSON['stringify'](_0x5288db,null,0x2)]});}const _0x2e7b98=yield(0x0,axios_1[a3_0x3783('0x5')])(()=>this[a3_0x3783('0x0')][a3_0x3783('0x1c')](a3_0x3783('0x40'),_0x5288db));_0x271bff[a3_0x3783('0x36')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x2e7b98));if(_0x2e7b98[a3_0x3783('0x16')]&&_0x2e7b98['data']['message']){this[a3_0x3783('0x1e')][a3_0x3783('0x43')]=_0x2e7b98[a3_0x3783('0x16')][a3_0x3783('0x43')];}if(!_0x2e7b98[a3_0x3783('0x16')]||!_0x2e7b98[a3_0x3783('0x16')][a3_0x3783('0x2e')]){this[a3_0x3783('0x1e')][a3_0x3783('0x3e')]=a3_0x3783('0xa')+JSON['stringify'](_0x2e7b98[a3_0x3783('0x16')]);return{};}return _0x2e7b98[a3_0x3783('0x16')][a3_0x3783('0x2e')];}catch(_0x3670aa){_0x271bff[a3_0x3783('0x36')](((_0x5a27b6=_0x3670aa===null||_0x3670aa===void 0x0?void 0x0:_0x3670aa[a3_0x3783('0x4')])===null||_0x5a27b6===void 0x0?void 0x0:_0x5a27b6[a3_0x3783('0x3f')])?(0x0,metric_logger_1[a3_0x3783('0x21')])(_0x3670aa[a3_0x3783('0x4')][a3_0x3783('0x3f')]):metric_logger_1[a3_0x3783('0x26')]);this[a3_0x3783('0x1e')][a3_0x3783('0x3e')]=this['messages'][a3_0x3783('0x35')](_0x3670aa,a3_0x3783('0x29'));return{};}});}[a3_0x3783('0x32')](_0x1c7da1,_0x56003a){const _0x5bae95={'meta':{'nxCloudVersion':this[a3_0x3783('0xc')]()},'tasks':_0x56003a,'run':_0x1c7da1,'machineInfo':this['machineInfo']};return JSON['stringify'](_0x5bae95);}[a3_0x3783('0x10')](_0x33ab0e,_0x55203b){var _0x5f26d1,_0x5efdbf;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a3_0x3783('0x3e')])return![];let _0x324212=this[a3_0x3783('0x32')](_0x33ab0e,_0x55203b);if(_0x324212[a3_0x3783('0x44')]>0x14*0x3e8*0x3e8){_0x324212=this[a3_0x3783('0x32')](_0x33ab0e,_0x55203b[a3_0x3783('0x15')](_0x584ce0=>Object['assign'](Object[a3_0x3783('0x19')]({},_0x584ce0),{'hashDetails':undefined})));}const _0x1dc9f5=Buffer[a3_0x3783('0x2')](_0x324212);const _0x19efe9=yield(0x0,util_1[a3_0x3783('0xd')])(zlib_1[a3_0x3783('0x3a')])(_0x1dc9f5);const _0x723f88=(0x0,metric_logger_1[a3_0x3783('0x13')])(a3_0x3783('0x10'));try{if(environment_1[a3_0x3783('0x24')]){const _0x2e33ac=_0x55203b[a3_0x3783('0x15')](_0x324e88=>{return Object[a3_0x3783('0x19')](Object[a3_0x3783('0x19')]({},_0x324e88),{'terminalOutput':_0x324e88[a3_0x3783('0x1d')]?_0x324e88[a3_0x3783('0x1d')]['slice'](0x0,0x14)+a3_0x3783('0x18'):undefined});});output[a3_0x3783('0x2a')]({'title':a3_0x3783('0x38'),'bodyLines':['\x0a'+JSON[a3_0x3783('0x45')](_0x2e33ac,null,0x2)]});}const _0xd81e8b=yield(0x0,axios_1[a3_0x3783('0x5')])(()=>this[a3_0x3783('0x0')][a3_0x3783('0x1c')](a3_0x3783('0x8'),_0x19efe9,{'headers':Object[a3_0x3783('0x19')](Object[a3_0x3783('0x19')]({},this[a3_0x3783('0x0')][a3_0x3783('0x2f')][a3_0x3783('0x39')]),{'Content-Encoding':a3_0x3783('0x3a'),'Content-Type':a3_0x3783('0x34')})}));if(_0xd81e8b){_0x723f88['recordMetric']((0x0,metric_logger_1[a3_0x3783('0x21')])(_0xd81e8b));if(_0xd81e8b[a3_0x3783('0x16')]&&_0xd81e8b[a3_0x3783('0x16')]['runUrl']&&_0xd81e8b[a3_0x3783('0x16')]['status']===a3_0x3783('0x22')){this[a3_0x3783('0x3d')][a3_0x3783('0xf')]=_0xd81e8b[a3_0x3783('0x16')][a3_0x3783('0xf')];return!![];}if(_0xd81e8b['data']&&_0xd81e8b[a3_0x3783('0x16')][a3_0x3783('0x1b')]){this[a3_0x3783('0x1e')]['apiError']=a3_0x3783('0x11')+JSON[a3_0x3783('0x45')](_0xd81e8b[a3_0x3783('0x16')]['message']);}else if(_0xd81e8b[a3_0x3783('0x16')]&&typeof _0xd81e8b[a3_0x3783('0x16')]===a3_0x3783('0x2b')){if(_0xd81e8b['data']!=='success'){this[a3_0x3783('0x1e')][a3_0x3783('0x3e')]=a3_0x3783('0x11')+JSON[a3_0x3783('0x45')](_0xd81e8b[a3_0x3783('0x16')]);}}else{this[a3_0x3783('0x1e')][a3_0x3783('0x3e')]=a3_0x3783('0x11')+JSON[a3_0x3783('0x45')](_0xd81e8b[a3_0x3783('0x16')]);}if(environment_1[a3_0x3783('0x24')]){output[a3_0x3783('0x2a')]({'title':a3_0x3783('0x2d'),'bodyLines':[JSON[a3_0x3783('0x45')](_0xd81e8b[a3_0x3783('0x16')],null,0x2)]});}}else{output['error']({'title':a3_0x3783('0x25'),'bodyLines':[a3_0x3783('0x3b'),a3_0x3783('0x30'),JSON[a3_0x3783('0x45')](_0x33ab0e,null,0x2),'Stack\x20Trace:',JSON[a3_0x3783('0x45')](new Error()[a3_0x3783('0xb')],null,0x2)]});}return![];}catch(_0x512c41){_0x723f88[a3_0x3783('0x36')](((_0x5f26d1=_0x512c41===null||_0x512c41===void 0x0?void 0x0:_0x512c41[a3_0x3783('0x4')])===null||_0x5f26d1===void 0x0?void 0x0:_0x5f26d1[a3_0x3783('0x3f')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x512c41[a3_0x3783('0x4')][a3_0x3783('0x3f')]):metric_logger_1[a3_0x3783('0x26')]);const _0x5f5720=(_0x5efdbf=_0x512c41['axiosException'])!==null&&_0x5efdbf!==void 0x0?_0x5efdbf:_0x512c41;this[a3_0x3783('0x1e')][a3_0x3783('0x3e')]=this['messages'][a3_0x3783('0x35')](_0x5f5720,a3_0x3783('0x29'));return![];}});}[a3_0x3783('0xc')](){try{const _0x5726ba=JSON[a3_0x3783('0x37')]((0x0,fs_1[a3_0x3783('0x31')])(a3_0x3783('0x41'))[a3_0x3783('0x1a')]());return _0x5726ba['devDependencies'][a3_0x3783('0x17')];}catch(_0x7307df){return'unknown';}}}exports[a3_0x3783('0x23')]=CloudRunApi;

@@ -1,79 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DistributedAgentApi = void 0;
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const metric_logger_1 = require("../../../utilities/metric-logger");
const { output } = require('../../../utilities/nx-imports');
class DistributedAgentApi {
constructor(options, runGroup, agentName) {
this.runGroup = runGroup;
this.agentName = agentName;
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
tasks(executionId, statusCode, completedTasks) {
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,
agentName: this.agentName,
executionId,
statusCode,
completedTasks,
}));
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 run group with an error',
bodyLines: [`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', {
runGroup: this.runGroup,
agentName: this.agentName,
criticalErrorMessage: error,
}));
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Completed run group with an error',
});
}
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
console.error(e);
}
});
}
}
exports.DistributedAgentApi = DistributedAgentApi;
//# sourceMappingURL=distributed-agent.api.js.map
const a4_0x110b=['runGroup','Completing\x20run\x20group\x20with\x20an\x20error','agentName','../../../utilities/axios','next','/nx-cloud/executions/tasks','response','error','tasks','runGroup:\x20','done','throw','post','DistributedAgentApi','../../../utilities/environment','VERBOSE_LOGGING','axiosException','recordMetric','note','createMetricRecorder','defineProperty','RUNNER_FAILURE_PERF_ENTRY','__esModule','axiosMultipleTries','mapRespToPerfEntry','apiAxiosInstance','../../../utilities/metric-logger','error:\x20','dtePollTasks','createApiAxiosInstance','value','../../../utilities/nx-imports','completeRunGroupWithError'];(function(_0x5b1419,_0x110b78){const _0x275724=function(_0x4aca03){while(--_0x4aca03){_0x5b1419['push'](_0x5b1419['shift']());}};_0x275724(++_0x110b78);}(a4_0x110b,0x1e2));const a4_0x2757=function(_0x5b1419,_0x110b78){_0x5b1419=_0x5b1419-0x0;let _0x275724=a4_0x110b[_0x5b1419];return _0x275724;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x196629,_0x3ac7e8,_0x165c45,_0x1cb672){function _0x390f0b(_0x53c26c){return _0x53c26c instanceof _0x165c45?_0x53c26c:new _0x165c45(function(_0x43a919){_0x43a919(_0x53c26c);});}return new(_0x165c45||(_0x165c45=Promise))(function(_0x12e056,_0x1d0358){function _0x19a4a5(_0xc2e501){try{_0x1efa97(_0x1cb672[a4_0x2757('0x11')](_0xc2e501));}catch(_0x4b536c){_0x1d0358(_0x4b536c);}}function _0x2d5e5e(_0x35cfe5){try{_0x1efa97(_0x1cb672[a4_0x2757('0x18')](_0x35cfe5));}catch(_0x129744){_0x1d0358(_0x129744);}}function _0x1efa97(_0x3433ce){_0x3433ce[a4_0x2757('0x17')]?_0x12e056(_0x3433ce[a4_0x2757('0xa')]):_0x390f0b(_0x3433ce[a4_0x2757('0xa')])['then'](_0x19a4a5,_0x2d5e5e);}_0x1efa97((_0x1cb672=_0x1cb672['apply'](_0x196629,_0x3ac7e8||[]))[a4_0x2757('0x11')]());});};Object[a4_0x2757('0x0')](exports,a4_0x2757('0x2'),{'value':!![]});exports[a4_0x2757('0x1a')]=void 0x0;const axios_1=require(a4_0x2757('0x10'));const environment_1=require(a4_0x2757('0x1b'));const metric_logger_1=require(a4_0x2757('0x6'));const {output}=require(a4_0x2757('0xb'));class DistributedAgentApi{constructor(_0x167b5a,_0xcf3b8d,_0x465bba){this[a4_0x2757('0xd')]=_0xcf3b8d;this[a4_0x2757('0xf')]=_0x465bba;this['apiAxiosInstance']=(0x0,axios_1[a4_0x2757('0x9')])(_0x167b5a);}[a4_0x2757('0x15')](_0x537771,_0xf93c84,_0x2ff4e6){var _0x2990b6;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4a5e48=(0x0,metric_logger_1['createMetricRecorder'])(a4_0x2757('0x8'));try{const _0x364200=yield(0x0,axios_1[a4_0x2757('0x3')])(()=>this[a4_0x2757('0x5')][a4_0x2757('0x19')](a4_0x2757('0x12'),{'runGroup':this[a4_0x2757('0xd')],'agentName':this['agentName'],'executionId':_0x537771,'statusCode':_0xf93c84,'completedTasks':_0x2ff4e6}));_0x4a5e48[a4_0x2757('0x1e')]((0x0,metric_logger_1[a4_0x2757('0x4')])(_0x364200));return _0x364200['data'];}catch(_0x16eac5){_0x4a5e48[a4_0x2757('0x1e')](((_0x2990b6=_0x16eac5===null||_0x16eac5===void 0x0?void 0x0:_0x16eac5['axiosException'])===null||_0x2990b6===void 0x0?void 0x0:_0x2990b6['response'])?(0x0,metric_logger_1[a4_0x2757('0x4')])(_0x16eac5[a4_0x2757('0x1d')][a4_0x2757('0x13')]):metric_logger_1[a4_0x2757('0x1')]);throw _0x16eac5;}});}[a4_0x2757('0xc')](_0x18aaf1){var _0xa10b35;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a4_0x2757('0x1c')]){output['note']({'title':a4_0x2757('0xe'),'bodyLines':[a4_0x2757('0x16')+this[a4_0x2757('0xd')],a4_0x2757('0x7')+_0x18aaf1]});}const _0xfd8542=(0x0,metric_logger_1[a4_0x2757('0x20')])('completeRunGroup');try{const _0x40ef01=yield(0x0,axios_1[a4_0x2757('0x3')])(()=>this[a4_0x2757('0x5')]['post']('/nx-cloud/executions/complete-run-group',{'runGroup':this[a4_0x2757('0xd')],'agentName':this[a4_0x2757('0xf')],'criticalErrorMessage':_0x18aaf1}));if(environment_1['VERBOSE_LOGGING']){output[a4_0x2757('0x1f')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0xfd8542[a4_0x2757('0x1e')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x40ef01));}catch(_0x1ae153){_0xfd8542['recordMetric'](((_0xa10b35=_0x1ae153===null||_0x1ae153===void 0x0?void 0x0:_0x1ae153[a4_0x2757('0x1d')])===null||_0xa10b35===void 0x0?void 0x0:_0xa10b35[a4_0x2757('0x13')])?(0x0,metric_logger_1[a4_0x2757('0x4')])(_0x1ae153[a4_0x2757('0x1d')]['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);console[a4_0x2757('0x14')](_0x1ae153);}});}}exports[a4_0x2757('0x1a')]=DistributedAgentApi;

@@ -1,240 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.startAgent = void 0;
const child_process_1 = require("child_process");
const stripJsonComments = require("strip-json-comments");
const distributed_agent_api_1 = require("./distributed-agent.api");
const waiter_1 = require("../../../utilities/waiter");
const environment_1 = require("../../../utilities/environment");
const print_run_group_error_1 = require("../../error/print-run-group-error");
const create_no_new_messages_timeout_1 = require("../../../utilities/create-no-new-messages-timeout");
const fs_1 = require("fs");
const metric_logger_1 = require("../../../utilities/metric-logger");
const { output, workspaceRoot } = require('../../../utilities/nx-imports');
function executeTasks(options, api) {
return __awaiter(this, void 0, void 0, function* () {
let completedStatusCode = 0;
let apiResponse = null;
const failIfSameTasksIn30Mins = (0, create_no_new_messages_timeout_1.createNoNewMessagesTimeout)();
const waiter = new waiter_1.Waiter();
let completedTasks = [];
const startTime = new Date();
let executedAnyTasks = false;
while (true) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Fetching tasks...',
});
}
apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks);
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'API Response',
bodyLines: [
`completed: ${apiResponse.completed}`,
`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.completed)
return;
failIfSameTasksIn30Mins(apiResponse.tasks.map((t) => t.taskId).join(''));
if (!apiResponse.executionId) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Waiting...',
});
}
yield waiter.wait();
completedStatusCode = 0;
completedTasks = [];
continue;
}
waiter.reset();
executedAnyTasks = true;
const r = invokeTasksUsingRunMany(options, apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
completedStatusCode = r.completedStatusCode;
completedTasks = r.completedTasks;
}
});
}
function readCompletedTasks(options, distributedExecutionId) {
const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
let completedTasks;
try {
const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
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;
}
function invokeTasksUsingRunMany(options, executionId, tasks, maxParallel) {
let completedStatusCode = 0;
const completedTasks = [];
for (const g of groupByTarget(tasks)) {
const config = g.configuration ? `--configuration=${g.configuration}` : ``;
const parallel = maxParallel > 1 ? ` --parallel --max-parallel=${maxParallel}` : ``;
// TODO use pnpx or yarn when needed
const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallel}`;
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Executing: '${command}'`,
});
}
try {
(0, child_process_1.execSync)(command, {
stdio: ['inherit', 'inherit', 'inherit'],
env: Object.assign(Object.assign({}, process.env), { NX_CACHE_FAILURES: 'true', NX_CLOUD_DISTRIBUTED_EXECUTION_ID: executionId }),
});
}
catch (e) {
if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
throw e;
}
else {
completedStatusCode = 1;
}
}
finally {
completedTasks.push(...readCompletedTasks(options, executionId));
}
}
return { completedStatusCode, completedTasks };
}
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 getAgentName() {
if (process.env.NX_AGENT_NAME !== undefined) {
return process.env.NX_AGENT_NAME;
}
else if (process.env.CIRCLECI !== undefined) {
return process.env.CIRCLE_STAGE;
}
else {
return `Agent ${Math.floor(Math.random() * 100000)}`;
}
}
function createAgentLockfile(options, agentName) {
const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
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('SIGINT', () => cleanupAgentLockfile(lockFilePath, 0));
}
function cleanupAgentLockfile(lockFilePath, code) {
if ((0, fs_1.existsSync)(lockFilePath)) {
(0, fs_1.unlinkSync)(lockFilePath);
process.exit(code);
}
}
function startAgent() {
return __awaiter(this, void 0, void 0, function* () {
const runGroup = (0, environment_1.getRunGroup)();
if (!runGroup) {
(0, print_run_group_error_1.printRunGroupError)();
return process.exit(1);
}
output.note({
title: 'Starting an agent for running Nx tasks',
});
const options = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default.options;
const agentName = getAgentName();
createAgentLockfile(options, agentName);
const api = new distributed_agent_api_1.DistributedAgentApi(options, runGroup, agentName);
return executeTasks(options, api)
.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;
//# sourceMappingURL=distributed-agent.impl.js.map
const a5_0x3495=['API\x20Response','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','CIRCLE_STAGE','options','then','completed','env','assign','Critical\x20Error\x20in\x20Agent:\x20\x22','apply','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','params','__esModule','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','push','../../../utilities/nx-imports','child_process','unlinkSync','inherit','note','toString','configuration','CIRCLECI','error:\x20','startAgent','./node_modules/.cache/nx','projectName','default','projects','maxParallel:\x20','executionId','cacheDirectory','executionId:\x20','Distributed\x20Execution\x20Terminated','/lockfiles','./distributed-agent.api','retryDuring','criticalErrorMessage','exit','\x20--parallel\x20--max-parallel=','getTime','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','includes','Waiting...','../../../utilities/waiter','throw','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','Error:','printRunGroupError','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','wait','existsSync','status','Fetching\x20tasks...','maxParallel','Waiter','\x20--projects=','error','length','.lock','next','join','reset','/nx.json','/tasks-hashes-','tasksRunnerOptions','mkdirSync','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','number\x20of\x20tasks:\x20','Duplicate\x20Agent\x20ID\x20Detected','writeFileSync','strip-json-comments','NX_AGENT_NAME','warn','npx\x20nx\x20run-many\x20--target=','completedTasks','Executing:\x20\x27','readFileSync','completeRunGroupWithError','../../../utilities/environment','taskId','VERBOSE_LOGGING','tasks','getRunGroup','completed:\x20','value','DistributedAgentApi','../../../utilities/metric-logger','submitRunMetrics','target','find','parse'];(function(_0x557cb8,_0x34956e){const _0x313c1b=function(_0x4c1e90){while(--_0x4c1e90){_0x557cb8['push'](_0x557cb8['shift']());}};_0x313c1b(++_0x34956e);}(a5_0x3495,0x1cb));const a5_0x313c=function(_0x557cb8,_0x34956e){_0x557cb8=_0x557cb8-0x0;let _0x313c1b=a5_0x3495[_0x557cb8];return _0x313c1b;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x273d69,_0x55a5c9,_0x2d731b,_0x1fd206){function _0x49ca25(_0x417828){return _0x417828 instanceof _0x2d731b?_0x417828:new _0x2d731b(function(_0x3ad566){_0x3ad566(_0x417828);});}return new(_0x2d731b||(_0x2d731b=Promise))(function(_0x399e4f,_0x5082f9){function _0x4bd769(_0x283cf6){try{_0x4f2288(_0x1fd206['next'](_0x283cf6));}catch(_0x45c81e){_0x5082f9(_0x45c81e);}}function _0x3ec6cc(_0x2bce0c){try{_0x4f2288(_0x1fd206[a5_0x313c('0x2e')](_0x2bce0c));}catch(_0x33adc2){_0x5082f9(_0x33adc2);}}function _0x4f2288(_0x470d18){_0x470d18['done']?_0x399e4f(_0x470d18[a5_0x313c('0x56')]):_0x49ca25(_0x470d18[a5_0x313c('0x56')])[a5_0x313c('0x5')](_0x4bd769,_0x3ec6cc);}_0x4f2288((_0x1fd206=_0x1fd206[a5_0x313c('0xa')](_0x273d69,_0x55a5c9||[]))[a5_0x313c('0x3d')]());});};Object['defineProperty'](exports,a5_0x313c('0xd'),{'value':!![]});exports[a5_0x313c('0x19')]=void 0x0;const child_process_1=require(a5_0x313c('0x11'));const stripJsonComments=require(a5_0x313c('0x48'));const distributed_agent_api_1=require(a5_0x313c('0x24'));const waiter_1=require(a5_0x313c('0x2d'));const environment_1=require(a5_0x313c('0x50'));const print_run_group_error_1=require('../../error/print-run-group-error');const create_no_new_messages_timeout_1=require('../../../utilities/create-no-new-messages-timeout');const fs_1=require('fs');const metric_logger_1=require(a5_0x313c('0x58'));const {output,workspaceRoot}=require(a5_0x313c('0x10'));function executeTasks(_0x4edf97,_0x205338){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x47c2dd=0x0;let _0x54e799=null;const _0x523165=(0x0,create_no_new_messages_timeout_1['createNoNewMessagesTimeout'])();const _0x5f15e9=new waiter_1[(a5_0x313c('0x38'))]();let _0xdb262a=[];const _0x16097e=new Date();let _0x1b1193=![];while(!![]){if(environment_1[a5_0x313c('0x52')]){output['note']({'title':a5_0x313c('0x36')});}_0x54e799=yield _0x205338[a5_0x313c('0x53')](_0x54e799?_0x54e799[a5_0x313c('0x1f')]:null,_0x47c2dd,_0xdb262a);if(environment_1[a5_0x313c('0x52')]){output[a5_0x313c('0x14')]({'title':a5_0x313c('0x1'),'bodyLines':[a5_0x313c('0x55')+_0x54e799['completed'],'retryDuring:\x20'+_0x54e799[a5_0x313c('0x25')],a5_0x313c('0x21')+_0x54e799[a5_0x313c('0x1f')],a5_0x313c('0x45')+_0x54e799['tasks'][a5_0x313c('0x3b')],a5_0x313c('0x18')+_0x54e799['criticalErrorMessage'],a5_0x313c('0x1e')+_0x54e799[a5_0x313c('0x37')]]});}if(_0x54e799[a5_0x313c('0x26')]){output[a5_0x313c('0x3a')]({'title':a5_0x313c('0x22'),'bodyLines':[a5_0x313c('0x30'),_0x54e799['criticalErrorMessage']]});process[a5_0x313c('0x27')](0x0);}if((_0x54e799===null||_0x54e799===void 0x0?void 0x0:_0x54e799[a5_0x313c('0x25')])&&(_0x54e799===null||_0x54e799===void 0x0?void 0x0:_0x54e799[a5_0x313c('0x25')])!==0x0&&!_0x1b1193&&new Date()[a5_0x313c('0x29')]()-_0x16097e[a5_0x313c('0x29')]()>_0x54e799[a5_0x313c('0x25')]){yield _0x5f15e9[a5_0x313c('0x33')]();continue;}if(_0x54e799[a5_0x313c('0x6')])return;_0x523165(_0x54e799['tasks']['map'](_0x44cbc1=>_0x44cbc1[a5_0x313c('0x51')])[a5_0x313c('0x3e')](''));if(!_0x54e799['executionId']){if(environment_1[a5_0x313c('0x52')]){output['note']({'title':a5_0x313c('0x2c')});}yield _0x5f15e9['wait']();_0x47c2dd=0x0;_0xdb262a=[];continue;}_0x5f15e9[a5_0x313c('0x3f')]();_0x1b1193=!![];const _0x3fb97d=invokeTasksUsingRunMany(_0x4edf97,_0x54e799[a5_0x313c('0x1f')],_0x54e799[a5_0x313c('0x53')],_0x54e799['maxParallel']);_0x47c2dd=_0x3fb97d['completedStatusCode'];_0xdb262a=_0x3fb97d[a5_0x313c('0x4c')];}});}function readCompletedTasks(_0xcef947,_0x5147a6){const _0x5f5d95='Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20'+_0x5147a6+').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.';let _0x6c8643;try{const _0x52a3ec=_0xcef947[a5_0x313c('0x20')]||a5_0x313c('0x1a');const _0x2f86fc=_0x52a3ec+a5_0x313c('0x41')+_0x5147a6;_0x6c8643=JSON[a5_0x313c('0x0')]((0x0,fs_1['readFileSync'])(_0x2f86fc)[a5_0x313c('0x15')]());(0x0,fs_1[a5_0x313c('0x12')])(_0x2f86fc);}catch(_0x44b557){throw new Error(_0x5f5d95);}if(_0x6c8643['length']==0x0){throw new Error(_0x5f5d95);}return _0x6c8643;}function invokeTasksUsingRunMany(_0xb9470a,_0x39103f,_0x386a7e,_0x1164e6){let _0x475421=0x0;const _0x40c8cc=[];for(const _0x53d375 of groupByTarget(_0x386a7e)){const _0x331bbb=_0x53d375[a5_0x313c('0x16')]?'--configuration='+_0x53d375[a5_0x313c('0x16')]:'';const _0x40870c=_0x1164e6>0x1?a5_0x313c('0x28')+_0x1164e6:'';const _0x289345=a5_0x313c('0x4b')+_0x53d375[a5_0x313c('0x5a')]+'\x20'+_0x331bbb+a5_0x313c('0x39')+_0x53d375[a5_0x313c('0x1d')]['join'](',')+'\x20'+_0x53d375[a5_0x313c('0xc')]+_0x40870c;if(environment_1[a5_0x313c('0x52')]){output['note']({'title':a5_0x313c('0x4d')+_0x289345+'\x27'});}try{(0x0,child_process_1['execSync'])(_0x289345,{'stdio':[a5_0x313c('0x13'),a5_0x313c('0x13'),'inherit'],'env':Object['assign'](Object[a5_0x313c('0x8')]({},process[a5_0x313c('0x7')]),{'NX_CACHE_FAILURES':'true','NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x39103f})});}catch(_0x29ca74){if(_0x29ca74[a5_0x313c('0x35')]===environment_1[a5_0x313c('0xe')]){throw _0x29ca74;}else{_0x475421=0x1;}}finally{_0x40c8cc[a5_0x313c('0xf')](...readCompletedTasks(_0xb9470a,_0x39103f));}}return{'completedStatusCode':_0x475421,'completedTasks':_0x40c8cc};}function groupByTarget(_0x3abbf8){const _0x26269b=[];_0x3abbf8['forEach'](_0x421d5f=>{const _0x4dbbc9=_0x26269b[a5_0x313c('0x5b')](_0x5e7e6a=>_0x5e7e6a[a5_0x313c('0x5a')]===_0x421d5f[a5_0x313c('0x5a')]&&_0x5e7e6a[a5_0x313c('0x16')]===_0x421d5f[a5_0x313c('0x16')]);if(_0x4dbbc9){_0x4dbbc9[a5_0x313c('0x1d')][a5_0x313c('0xf')](_0x421d5f[a5_0x313c('0x1b')]);}else{_0x26269b[a5_0x313c('0xf')]({'target':_0x421d5f[a5_0x313c('0x5a')],'projects':[_0x421d5f['projectName']],'params':_0x421d5f[a5_0x313c('0xc')],'configuration':_0x421d5f[a5_0x313c('0x16')]});}});return _0x26269b;}function getAgentName(){if(process[a5_0x313c('0x7')][a5_0x313c('0x49')]!==undefined){return process['env'][a5_0x313c('0x49')];}else if(process[a5_0x313c('0x7')][a5_0x313c('0x17')]!==undefined){return process[a5_0x313c('0x7')][a5_0x313c('0x3')];}else{return'Agent\x20'+Math['floor'](Math['random']()*0x186a0);}}function createAgentLockfile(_0x2774bd,_0x516a94){const _0x1c0ae4=_0x2774bd[a5_0x313c('0x20')]||'./node_modules/.cache/nx';const _0x526efe=_0x1c0ae4+a5_0x313c('0x23');const _0x475782=_0x526efe+'/'+_0x516a94+a5_0x313c('0x3c');if(!(0x0,fs_1[a5_0x313c('0x34')])(_0x526efe)){(0x0,fs_1[a5_0x313c('0x43')])(_0x526efe,{'recursive':!![]});}const _0x585cd7=(0x0,fs_1['readdirSync'])(_0x526efe);if(_0x585cd7['length']){if(_0x585cd7[a5_0x313c('0x2b')](_0x516a94+'.lock')){output[a5_0x313c('0x3a')]({'title':a5_0x313c('0x46'),'bodyLines':[a5_0x313c('0x2f'),'',a5_0x313c('0xb')]});process[a5_0x313c('0x27')](0x1);}output[a5_0x313c('0x4a')]({'title':'Other\x20Nx\x20Cloud\x20Agents\x20Detected','bodyLines':[a5_0x313c('0x2a'),'',a5_0x313c('0x2'),a5_0x313c('0x44')]});}(0x0,fs_1[a5_0x313c('0x47')])(_0x475782,'');process['on'](a5_0x313c('0x27'),_0x5c7f12=>cleanupAgentLockfile(_0x475782,_0x5c7f12));process['on']('SIGINT',()=>cleanupAgentLockfile(_0x475782,0x0));}function cleanupAgentLockfile(_0x50c368,_0x536f1f){if((0x0,fs_1[a5_0x313c('0x34')])(_0x50c368)){(0x0,fs_1[a5_0x313c('0x12')])(_0x50c368);process[a5_0x313c('0x27')](_0x536f1f);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x31a296=(0x0,environment_1[a5_0x313c('0x54')])();if(!_0x31a296){(0x0,print_run_group_error_1[a5_0x313c('0x31')])();return process[a5_0x313c('0x27')](0x1);}output[a5_0x313c('0x14')]({'title':a5_0x313c('0x32')});const _0x42e8ce=JSON[a5_0x313c('0x0')](stripJsonComments((0x0,fs_1[a5_0x313c('0x4e')])(workspaceRoot+a5_0x313c('0x40'))['toString']()))[a5_0x313c('0x42')][a5_0x313c('0x1c')][a5_0x313c('0x4')];const _0x2f6fda=getAgentName();createAgentLockfile(_0x42e8ce,_0x2f6fda);const _0x56d334=new distributed_agent_api_1[(a5_0x313c('0x57'))](_0x42e8ce,_0x31a296,_0x2f6fda);return executeTasks(_0x42e8ce,_0x56d334)[a5_0x313c('0x5')](_0x116942=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a5_0x313c('0x59')])(_0x42e8ce);return _0x116942;}))['catch'](_0x3f6f87=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x56d334[a5_0x313c('0x4f')](a5_0x313c('0x9')+_0x3f6f87['message']+'\x22');throw _0x3f6f87;}));});}exports['startAgent']=startAgent;

@@ -1,130 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createStartRequest = exports.DistributedExecutionApi = void 0;
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const metric_logger_1 = require("../../../utilities/metric-logger");
const { output, unparse } = 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;
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(runGroup, error) {
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', {
runGroup: runGroup,
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(runGroup, task, options) {
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: unparse(t.overrides).join(' '),
};
});
});
const request = {
command: (0, environment_1.parseCommand)(),
branch: (0, environment_1.getBranch)(),
runGroup,
tasks: tasksToExecute,
maxParallel: calculateMaxParallel(options),
};
if (environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT) {
request.agentCount = environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT;
}
if (!environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE) {
request.stopAgentsOnFailure = false;
}
return request;
}
exports.createStartRequest = createStartRequest;
function calculateMaxParallel(options) {
if (options.parallel === 'false' || options.parallel === false) {
return 1;
}
else if (options.parallel === 'true' || options.parallel === true) {
return Number(options.maxParallel || 3);
}
else if (options.parallel === undefined) {
return options.maxParallel ? Number(options.maxParallel) : 3;
}
else {
return Number(options.parallel) || 3;
}
}
//# sourceMappingURL=distributed-execution.api.js.map
const a6_0x53f2=['post','target','parallel','completeRunGroup','../../../utilities/nx-imports','true','then','configuration','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','response','map','next','false','parseCommand','DistributedExecutionApi','/nx-cloud/executions/status','apiAxiosInstance','dteStart','value','NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE','enabled','axiosException','/nx-cloud/executions/start','defineProperty','join','axiosMultipleTries','data','../../../utilities/axios','createStartRequest','createApiAxiosInstance','project','getBranch','status','RUNNER_FAILURE_PERF_ENTRY','agentCount','__awaiter','hash','mapRespToPerfEntry','recordMetric','/nx-cloud/executions/complete-run-group','error','maxParallel','exit'];(function(_0xc5b392,_0x53f244){const _0x4122b4=function(_0x1285d3){while(--_0x1285d3){_0xc5b392['push'](_0xc5b392['shift']());}};_0x4122b4(++_0x53f244);}(a6_0x53f2,0x97));const a6_0x4122=function(_0xc5b392,_0x53f244){_0xc5b392=_0xc5b392-0x0;let _0x4122b4=a6_0x53f2[_0xc5b392];return _0x4122b4;};'use strict';var __awaiter=this&&this[a6_0x4122('0xd')]||function(_0x57cd48,_0x1af7ee,_0x18e74b,_0x4e3c9c){function _0x32b6d9(_0x59e0a0){return _0x59e0a0 instanceof _0x18e74b?_0x59e0a0:new _0x18e74b(function(_0x4b5049){_0x4b5049(_0x59e0a0);});}return new(_0x18e74b||(_0x18e74b=Promise))(function(_0x35079f,_0x173f23){function _0x5d6ffa(_0x3b1138){try{_0x1c6ee8(_0x4e3c9c['next'](_0x3b1138));}catch(_0x200601){_0x173f23(_0x200601);}}function _0x54d33f(_0x4ef085){try{_0x1c6ee8(_0x4e3c9c['throw'](_0x4ef085));}catch(_0x713ca7){_0x173f23(_0x713ca7);}}function _0x1c6ee8(_0x5879a1){_0x5879a1['done']?_0x35079f(_0x5879a1[a6_0x4122('0x27')]):_0x32b6d9(_0x5879a1[a6_0x4122('0x27')])[a6_0x4122('0x1b')](_0x5d6ffa,_0x54d33f);}_0x1c6ee8((_0x4e3c9c=_0x4e3c9c['apply'](_0x57cd48,_0x1af7ee||[]))[a6_0x4122('0x20')]());});};Object[a6_0x4122('0x1')](exports,'__esModule',{'value':!![]});exports[a6_0x4122('0x6')]=exports[a6_0x4122('0x23')]=void 0x0;const axios_1=require(a6_0x4122('0x5'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require('../../../utilities/metric-logger');const {output,unparse}=require(a6_0x4122('0x19'));class DistributedExecutionApi{constructor(_0x1dbb75){this['apiAxiosInstance']=(0x0,axios_1[a6_0x4122('0x7')])(_0x1dbb75);}['start'](_0x55b613){var _0x2e07d8;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4f2c04=(0x0,metric_logger_1['createMetricRecorder'])(a6_0x4122('0x26'));let _0x254e25;try{_0x254e25=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a6_0x4122('0x25')][a6_0x4122('0x15')](a6_0x4122('0x0'),_0x55b613));_0x4f2c04[a6_0x4122('0x10')]((0x0,metric_logger_1[a6_0x4122('0xf')])(_0x254e25));}catch(_0x5cd8da){_0x4f2c04[a6_0x4122('0x10')](((_0x2e07d8=_0x5cd8da===null||_0x5cd8da===void 0x0?void 0x0:_0x5cd8da[a6_0x4122('0x2a')])===null||_0x2e07d8===void 0x0?void 0x0:_0x2e07d8[a6_0x4122('0x1e')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x5cd8da[a6_0x4122('0x2a')][a6_0x4122('0x1e')]):metric_logger_1[a6_0x4122('0xb')]);throw _0x5cd8da;}if(!_0x254e25[a6_0x4122('0x4')][a6_0x4122('0x29')]){throw new Error('Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.');}if(_0x254e25[a6_0x4122('0x4')]['error']){throw new Error(_0x254e25[a6_0x4122('0x4')]['error']);}return _0x254e25['data']['id'];});}[a6_0x4122('0xa')](_0x30cf26){var _0x4b155d;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x59aca0=(0x0,metric_logger_1['createMetricRecorder'])('dteStatus');try{const _0x282092=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a6_0x4122('0x25')][a6_0x4122('0x15')](a6_0x4122('0x24'),{'id':_0x30cf26}));_0x59aca0['recordMetric']((0x0,metric_logger_1[a6_0x4122('0xf')])(_0x282092));return _0x282092[a6_0x4122('0x4')];}catch(_0x1a86f3){_0x59aca0['recordMetric'](((_0x4b155d=_0x1a86f3===null||_0x1a86f3===void 0x0?void 0x0:_0x1a86f3[a6_0x4122('0x2a')])===null||_0x4b155d===void 0x0?void 0x0:_0x4b155d['response'])?(0x0,metric_logger_1[a6_0x4122('0xf')])(_0x1a86f3['axiosException'][a6_0x4122('0x1e')]):metric_logger_1[a6_0x4122('0xb')]);output[a6_0x4122('0x12')]({'title':_0x1a86f3['message']});process[a6_0x4122('0x14')](0x1);}});}['completeRunGroupWithError'](_0x4dc7b8,_0x296030){var _0x272d8a;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2b08da=(0x0,metric_logger_1['createMetricRecorder'])(a6_0x4122('0x18'));try{const _0x357ffc=yield(0x0,axios_1[a6_0x4122('0x3')])(()=>this['apiAxiosInstance'][a6_0x4122('0x15')](a6_0x4122('0x11'),{'runGroup':_0x4dc7b8,'criticalErrorMessage':_0x296030}),0x3);_0x2b08da['recordMetric']((0x0,metric_logger_1[a6_0x4122('0xf')])(_0x357ffc));}catch(_0x2b3ae0){_0x2b08da['recordMetric'](((_0x272d8a=_0x2b3ae0===null||_0x2b3ae0===void 0x0?void 0x0:_0x2b3ae0[a6_0x4122('0x2a')])===null||_0x272d8a===void 0x0?void 0x0:_0x272d8a[a6_0x4122('0x1e')])?(0x0,metric_logger_1[a6_0x4122('0xf')])(_0x2b3ae0[a6_0x4122('0x2a')]['response']):metric_logger_1[a6_0x4122('0xb')]);}});}}exports[a6_0x4122('0x23')]=DistributedExecutionApi;function createStartRequest(_0xe7eacd,_0x573831,_0xb27ecb){const _0x3c7c5f=_0x573831[a6_0x4122('0x1f')](_0x4727ed=>{return _0x4727ed[a6_0x4122('0x1f')](_0x5536a2=>{return{'taskId':_0x5536a2['id'],'hash':_0x5536a2[a6_0x4122('0xe')],'projectName':_0x5536a2['target'][a6_0x4122('0x8')],'target':_0x5536a2['target'][a6_0x4122('0x16')],'configuration':_0x5536a2[a6_0x4122('0x16')][a6_0x4122('0x1c')]||null,'params':unparse(_0x5536a2['overrides'])[a6_0x4122('0x2')]('\x20')};});});const _0x448a8e={'command':(0x0,environment_1[a6_0x4122('0x22')])(),'branch':(0x0,environment_1[a6_0x4122('0x9')])(),'runGroup':_0xe7eacd,'tasks':_0x3c7c5f,'maxParallel':calculateMaxParallel(_0xb27ecb)};if(environment_1[a6_0x4122('0x1d')]){_0x448a8e[a6_0x4122('0xc')]=environment_1[a6_0x4122('0x1d')];}if(!environment_1[a6_0x4122('0x28')]){_0x448a8e['stopAgentsOnFailure']=![];}return _0x448a8e;}exports['createStartRequest']=createStartRequest;function calculateMaxParallel(_0xf8c564){if(_0xf8c564[a6_0x4122('0x17')]===a6_0x4122('0x21')||_0xf8c564[a6_0x4122('0x17')]===![]){return 0x1;}else if(_0xf8c564['parallel']===a6_0x4122('0x1a')||_0xf8c564['parallel']===!![]){return Number(_0xf8c564[a6_0x4122('0x13')]||0x3);}else if(_0xf8c564[a6_0x4122('0x17')]===undefined){return _0xf8c564[a6_0x4122('0x13')]?Number(_0xf8c564[a6_0x4122('0x13')]):0x3;}else{return Number(_0xf8c564[a6_0x4122('0x17')])||0x3;}}

@@ -1,309 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskGraphCreator = exports.nxCloudDistributedTasksRunner = void 0;
const stripJsonComments = require("strip-json-comments");
const fs_1 = require("fs");
const distributed_execution_api_1 = require("./distributed-execution.api");
const file_storage_1 = require("../../file-storage/file-storage");
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
const waiter_1 = require("../../../utilities/waiter");
const environment_1 = require("../../../utilities/environment");
const print_run_group_error_1 = require("../../error/print-run-group-error");
const create_no_new_messages_timeout_1 = require("../../../utilities/create-no-new-messages-timeout");
const metric_logger_1 = require("../../../utilities/metric-logger");
const error_reporter_api_1 = require("../../api/error-reporter.api");
const { output, workspaceRoot, getDependencyConfigs, getOutputs, unparse, Cache, } = require('../../../utilities/nx-imports');
class NoopLifeCycle {
scheduleTask(task) { }
startTask(task) { }
endTask(task, code) { }
}
function runDistributedExecution(api, options, context, fileStorage, cache, runGroup, tasks) {
return __awaiter(this, void 0, void 0, function* () {
const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString()));
const stages = new TaskOrderer(context.projectGraph, getDefaultDependencyConfigs(nxjson, options)).splitTasksIntoStages(tasks);
const id = yield api.start((0, distributed_execution_api_1.createStartRequest)(runGroup, stages, options));
return yield processTasks(api, fileStorage, cache, options, id, tasks, context);
});
}
function processTasks(api, fileStorage, cache, options, executionId, tasks, context) {
return __awaiter(this, void 0, void 0, function* () {
const processedTasks = {};
const failIfNumberOfCompletedTasksDoesNotChangeIn30Mins = (0, create_no_new_messages_timeout_1.createNoNewMessagesTimeout)();
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);
}
failIfNumberOfCompletedTasksDoesNotChangeIn30Mins(r.completedTasks.length);
for (const t of r.completedTasks) {
if (processedTasks[t.taskId])
continue;
yield processTask(fileStorage, cache, context, options, tasks, t);
waiter.reset();
processedTasks[t.taskId] = true;
}
if (r.executionStatus === 'COMPLETED') {
return { commandStatus: r.commandStatus, runUrl: r.runUrl };
}
}
});
}
function processTask(fileStorage, cache, context, options, 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}`);
}
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Retrieving artifacts from ${completedTask.url}`,
});
}
yield fileStorage.retrieve(completedTask.hash, completedTask.url, options.cacheDirectory || './node_modules/.cache/nx');
const cachedResult = yield cache.get(Object.assign(Object.assign({}, matchingTask), { hash: completedTask.hash }));
const outputs = getOutputs(context.projectGraph.nodes, matchingTask);
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Extracting artifacts`,
bodyLines: outputs,
});
}
yield cache.copyFilesFromCache(completedTask.hash, cachedResult, outputs);
output.logCommand(getCommand(matchingTask));
process.stdout.write(cachedResult.terminalOutput);
output.addVerticalSeparator();
});
}
function getCommand(task) {
const args = unparse(task.overrides || {});
const config = task.target.configuration
? `:${task.target.configuration}`
: '';
return [
'nx',
'run',
`${task.target.project}:${task.target.target}${config}`,
...args,
].join(' ');
}
const nxCloudDistributedTasksRunner = (tasks, options, context) => __awaiter(void 0, void 0, void 0, function* () {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Starting distributed command execution',
});
}
options.lifeCycle = new NoopLifeCycle();
const runGroup = (0, environment_1.getRunGroup)();
if (!runGroup) {
(0, print_run_group_error_1.printRunGroupError)();
return 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 fileStorage = new file_storage_1.FileStorage(encryption, errorReporter, true);
const cache = new Cache(options);
const api = new distributed_execution_api_1.DistributedExecutionApi(options);
try {
const r = yield runDistributedExecution(api, options, context, fileStorage, cache, runGroup, tasks);
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(runGroup, `Main job terminated with an error: "${e.message}"`);
}
finally {
process.exit(1);
}
}
});
exports.nxCloudDistributedTasksRunner = nxCloudDistributedTasksRunner;
class TaskOrderer {
constructor(projectGraph, defaultTargetDependencies) {
this.projectGraph = projectGraph;
this.defaultTargetDependencies = defaultTargetDependencies;
}
splitTasksIntoStages(tasks) {
if (tasks.length === 0)
return [];
const stages = [];
const taskGraph = this.createTaskGraph(tasks);
const notStagedTaskIds = new Set(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;
}
createTaskGraph(tasks) {
const t = new TaskGraphCreator(this.projectGraph, this.defaultTargetDependencies);
return t.createTaskGraph(tasks);
}
}
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;
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;
}
//# sourceMappingURL=distributed-execution.runner.js.map
const a7_0x2ced=['error:\x20','../../../utilities/nx-imports','nxCloudDistributedTasksRunner','find','next','Processing\x20task\x20','FileStorage','error','push','exit','strictlyOrderedTargets','Successfully\x20completed\x20running\x20the\x20command.','Status\x20update','map','length','Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','roots','Error:','ErrorReporterApi','retrieve','completedTasks','E2EEncryption','scheduleTask','executionStatus','../../file-storage/e2e-encryption','target','has','findTask','Found\x20unknown\x20task:\x20','projectGraph','delete','executionStatus:\x20','../../error/print-run-group-error','hash','terminalOutput','logCommand','filter','See\x20run\x20details\x20at\x20','splitTasksIntoStages','../../../utilities/create-no-new-messages-timeout','strip-json-comments','addDependencies','completeRunGroupWithError','taskId','message','addTaskDependencies','number\x20of\x20completed\x20tasks:\x20','Starting\x20distributed\x20command\x20execution','../../../utilities/waiter','status','dependencies','__esModule','stdout','copyFilesFromCache','apply','startTask','value','addVerticalSeparator','reset','run','../../../utilities/metric-logger','criticalErrorMessage','defaultTargetDependencies','toString','commandStatus','executionId:\x20','Unable\x20to\x20complete\x20a\x20run.','../../api/error-reporter.api','write','parse','note','encryptionKey','VERBOSE_LOGGING','createTaskGraph','addTaskToGraph','Extracting\x20artifacts','projects','createNoNewMessagesTimeout','axiosException','/nx.json','get','./node_modules/.cache/nx','url','wait','log','ENCRYPTION_KEY','printRunGroupError','createStartRequest','runUrl','start','project','size','Waiting...','COMPLETED','done','add','configuration','defineProperty','keys','../../../utilities/environment','DistributedExecutionApi'];(function(_0xbf4dc4,_0x2ced8a){const _0x2fab7a=function(_0x487e3d){while(--_0x487e3d){_0xbf4dc4['push'](_0xbf4dc4['shift']());}};_0x2fab7a(++_0x2ced8a);}(a7_0x2ced,0x96));const a7_0x2fab=function(_0xbf4dc4,_0x2ced8a){_0xbf4dc4=_0xbf4dc4-0x0;let _0x2fab7a=a7_0x2ced[_0xbf4dc4];return _0x2fab7a;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x42a9e3,_0xae2d89,_0x29f09a,_0x212847){function _0x57a8b1(_0xdc47ff){return _0xdc47ff instanceof _0x29f09a?_0xdc47ff:new _0x29f09a(function(_0x531132){_0x531132(_0xdc47ff);});}return new(_0x29f09a||(_0x29f09a=Promise))(function(_0x2b9e29,_0x586c0a){function _0x88942b(_0x3fc65f){try{_0x3d9cb7(_0x212847[a7_0x2fab('0x38')](_0x3fc65f));}catch(_0x54f3b2){_0x586c0a(_0x54f3b2);}}function _0x34b3c4(_0x79d45f){try{_0x3d9cb7(_0x212847['throw'](_0x79d45f));}catch(_0x40291a){_0x586c0a(_0x40291a);}}function _0x3d9cb7(_0x16c20e){_0x16c20e[a7_0x2fab('0x2d')]?_0x2b9e29(_0x16c20e['value']):_0x57a8b1(_0x16c20e[a7_0x2fab('0x7')])['then'](_0x88942b,_0x34b3c4);}_0x3d9cb7((_0x212847=_0x212847[a7_0x2fab('0x5')](_0x42a9e3,_0xae2d89||[]))['next']());});};Object[a7_0x2fab('0x30')](exports,a7_0x2fab('0x2'),{'value':!![]});exports['TaskGraphCreator']=exports[a7_0x2fab('0x36')]=void 0x0;const stripJsonComments=require(a7_0x2fab('0x5c'));const fs_1=require('fs');const distributed_execution_api_1=require('./distributed-execution.api');const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a7_0x2fab('0x4c'));const waiter_1=require(a7_0x2fab('0x64'));const environment_1=require(a7_0x2fab('0x32'));const print_run_group_error_1=require(a7_0x2fab('0x54'));const create_no_new_messages_timeout_1=require(a7_0x2fab('0x5b'));const metric_logger_1=require(a7_0x2fab('0xb'));const error_reporter_api_1=require(a7_0x2fab('0x12'));const {output,workspaceRoot,getDependencyConfigs,getOutputs,unparse,Cache}=require(a7_0x2fab('0x35'));class NoopLifeCycle{[a7_0x2fab('0x4a')](_0x3ec705){}[a7_0x2fab('0x6')](_0xb18882){}['endTask'](_0x2f70c0,_0x51d9ef){}}function runDistributedExecution(_0xd496a5,_0x228471,_0xd3432,_0x3f51c8,_0x10dbd4,_0x5eda5e,_0x379547){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x433a5c=JSON[a7_0x2fab('0x14')](stripJsonComments((0x0,fs_1['readFileSync'])(workspaceRoot+a7_0x2fab('0x1e'))[a7_0x2fab('0xe')]()));const _0x31dcb0=new TaskOrderer(_0xd3432[a7_0x2fab('0x51')],getDefaultDependencyConfigs(_0x433a5c,_0x228471))[a7_0x2fab('0x5a')](_0x379547);const _0x4dad9c=yield _0xd496a5[a7_0x2fab('0x28')]((0x0,distributed_execution_api_1[a7_0x2fab('0x26')])(_0x5eda5e,_0x31dcb0,_0x228471));return yield processTasks(_0xd496a5,_0x3f51c8,_0x10dbd4,_0x228471,_0x4dad9c,_0x379547,_0xd3432);});}function processTasks(_0x51301d,_0x13e6fe,_0x52e804,_0x391133,_0x5c5425,_0x1b9af4,_0x397851){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x46a82f={};const _0x13d4f5=(0x0,create_no_new_messages_timeout_1[a7_0x2fab('0x1c')])();const _0x263981=new waiter_1['Waiter']();while(!![]){if(environment_1[a7_0x2fab('0x17')]){output[a7_0x2fab('0x15')]({'title':a7_0x2fab('0x2b')});}yield _0x263981[a7_0x2fab('0x22')]();const _0x4fbbbe=yield _0x51301d[a7_0x2fab('0x0')](_0x5c5425);if(environment_1[a7_0x2fab('0x17')]){output[a7_0x2fab('0x15')]({'title':a7_0x2fab('0x40'),'bodyLines':[a7_0x2fab('0x10')+_0x5c5425,a7_0x2fab('0x53')+_0x4fbbbe[a7_0x2fab('0x4b')],a7_0x2fab('0x62')+_0x4fbbbe['completedTasks']['length'],a7_0x2fab('0x34')+_0x4fbbbe[a7_0x2fab('0xc')]]});}if(_0x4fbbbe['criticalErrorMessage']){output[a7_0x2fab('0x3b')]({'title':'Distributed\x20Execution\x20Terminated','bodyLines':[a7_0x2fab('0x45'),_0x4fbbbe[a7_0x2fab('0xc')]]});process['exit'](0x1);}_0x13d4f5(_0x4fbbbe[a7_0x2fab('0x48')][a7_0x2fab('0x42')]);for(const _0x509b95 of _0x4fbbbe['completedTasks']){if(_0x46a82f[_0x509b95['taskId']])continue;yield processTask(_0x13e6fe,_0x52e804,_0x397851,_0x391133,_0x1b9af4,_0x509b95);_0x263981[a7_0x2fab('0x9')]();_0x46a82f[_0x509b95[a7_0x2fab('0x5f')]]=!![];}if(_0x4fbbbe['executionStatus']===a7_0x2fab('0x2c')){return{'commandStatus':_0x4fbbbe[a7_0x2fab('0xf')],'runUrl':_0x4fbbbe[a7_0x2fab('0x27')]};}}});}function processTask(_0x5189b1,_0x5b5a15,_0x24de8f,_0x1a4290,_0x298dd2,_0x56b614){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1['VERBOSE_LOGGING']){output[a7_0x2fab('0x15')]({'title':a7_0x2fab('0x39')+_0x56b614[a7_0x2fab('0x5f')]});}const _0x5696e6=_0x298dd2[a7_0x2fab('0x37')](_0x161073=>_0x56b614['taskId']===_0x161073['id']);if(!_0x5696e6){throw new Error(a7_0x2fab('0x50')+_0x56b614[a7_0x2fab('0x5f')]);}if(environment_1[a7_0x2fab('0x17')]){output['note']({'title':'Retrieving\x20artifacts\x20from\x20'+_0x56b614[a7_0x2fab('0x21')]});}yield _0x5189b1[a7_0x2fab('0x47')](_0x56b614[a7_0x2fab('0x55')],_0x56b614['url'],_0x1a4290['cacheDirectory']||a7_0x2fab('0x20'));const _0x28f945=yield _0x5b5a15[a7_0x2fab('0x1f')](Object['assign'](Object['assign']({},_0x5696e6),{'hash':_0x56b614[a7_0x2fab('0x55')]}));const _0x3713be=getOutputs(_0x24de8f[a7_0x2fab('0x51')]['nodes'],_0x5696e6);if(environment_1['VERBOSE_LOGGING']){output[a7_0x2fab('0x15')]({'title':a7_0x2fab('0x1a'),'bodyLines':_0x3713be});}yield _0x5b5a15[a7_0x2fab('0x4')](_0x56b614[a7_0x2fab('0x55')],_0x28f945,_0x3713be);output[a7_0x2fab('0x57')](getCommand(_0x5696e6));process[a7_0x2fab('0x3')][a7_0x2fab('0x13')](_0x28f945[a7_0x2fab('0x56')]);output[a7_0x2fab('0x8')]();});}function getCommand(_0x51b8ed){const _0x3c58b5=unparse(_0x51b8ed['overrides']||{});const _0x8a27bb=_0x51b8ed[a7_0x2fab('0x4d')][a7_0x2fab('0x2f')]?':'+_0x51b8ed[a7_0x2fab('0x4d')]['configuration']:'';return['nx',a7_0x2fab('0xa'),_0x51b8ed[a7_0x2fab('0x4d')][a7_0x2fab('0x29')]+':'+_0x51b8ed[a7_0x2fab('0x4d')][a7_0x2fab('0x4d')]+_0x8a27bb,..._0x3c58b5]['join']('\x20');}const nxCloudDistributedTasksRunner=(_0x4b200d,_0x419918,_0x471125)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(environment_1[a7_0x2fab('0x17')]){output['note']({'title':a7_0x2fab('0x63')});}_0x419918['lifeCycle']=new NoopLifeCycle();const _0x3c92ad=(0x0,environment_1['getRunGroup'])();if(!_0x3c92ad){(0x0,print_run_group_error_1[a7_0x2fab('0x25')])();return process[a7_0x2fab('0x3d')](0x1);}const _0x4fa275=new e2e_encryption_1[(a7_0x2fab('0x49'))](environment_1[a7_0x2fab('0x24')]||_0x419918[a7_0x2fab('0x16')]);const _0xa8db4=new error_reporter_api_1[(a7_0x2fab('0x46'))](_0x419918);const _0x5dc0c7=new file_storage_1[(a7_0x2fab('0x3a'))](_0x4fa275,_0xa8db4,!![]);const _0x3b5599=new Cache(_0x419918);const _0x2ebc4b=new distributed_execution_api_1[(a7_0x2fab('0x33'))](_0x419918);try{const _0x40a53c=yield runDistributedExecution(_0x2ebc4b,_0x419918,_0x471125,_0x5dc0c7,_0x3b5599,_0x3c92ad,_0x4b200d);if(_0x40a53c[a7_0x2fab('0xf')]===0x0){output['success']({'title':a7_0x2fab('0x3f'),'bodyLines':[a7_0x2fab('0x59')+_0x40a53c[a7_0x2fab('0x27')]]});}else{output[a7_0x2fab('0x3b')]({'title':'Command\x20execution\x20failed.','bodyLines':['See\x20run\x20details\x20at\x20'+_0x40a53c[a7_0x2fab('0x27')]]});}yield(0x0,metric_logger_1['submitRunMetrics'])(_0x419918);process[a7_0x2fab('0x3d')](_0x40a53c[a7_0x2fab('0xf')]);}catch(_0x787622){output[a7_0x2fab('0x3b')]({'title':a7_0x2fab('0x11'),'bodyLines':[_0x787622[a7_0x2fab('0x60')]]});if(_0x787622['axiosException']){console[a7_0x2fab('0x23')](_0x787622[a7_0x2fab('0x1d')]);}else{console[a7_0x2fab('0x23')](_0x787622);}try{yield _0x2ebc4b[a7_0x2fab('0x5e')](_0x3c92ad,a7_0x2fab('0x43')+_0x787622[a7_0x2fab('0x60')]+'\x22');}finally{process[a7_0x2fab('0x3d')](0x1);}}});exports[a7_0x2fab('0x36')]=nxCloudDistributedTasksRunner;class TaskOrderer{constructor(_0x38e04f,_0x11aac6){this[a7_0x2fab('0x51')]=_0x38e04f;this[a7_0x2fab('0xd')]=_0x11aac6;}['splitTasksIntoStages'](_0x1c452f){if(_0x1c452f[a7_0x2fab('0x42')]===0x0)return[];const _0x486cb4=[];const _0xfa7f8e=this[a7_0x2fab('0x18')](_0x1c452f);const _0x520ec8=new Set(_0x1c452f['map'](_0x29c760=>_0x29c760['id']));let _0x2bfff1=0x0;while(_0x520ec8[a7_0x2fab('0x2a')]>0x0){const _0x383f42=_0x486cb4[_0x2bfff1]=[];for(const _0x1018b6 of _0x520ec8){let _0x2aba8c=!![];for(const _0x5f28bf of _0xfa7f8e[a7_0x2fab('0x1')][_0x1018b6]){if(_0x520ec8[a7_0x2fab('0x4e')](_0x5f28bf)){_0x2aba8c=![];break;}}if(!_0x2aba8c){continue;}const _0x259dd3=_0xfa7f8e['tasks'][_0x1018b6];_0x383f42[a7_0x2fab('0x3c')](_0x259dd3);}for(const _0x262c46 of _0x383f42){_0x520ec8[a7_0x2fab('0x52')](_0x262c46['id']);}_0x2bfff1++;}return _0x486cb4;}[a7_0x2fab('0x18')](_0xa00008){const _0x220928=new TaskGraphCreator(this['projectGraph'],this['defaultTargetDependencies']);return _0x220928[a7_0x2fab('0x18')](_0xa00008);}}class TaskGraphCreator{constructor(_0x5d6a8d,_0x3eae16){this['projectGraph']=_0x5d6a8d;this[a7_0x2fab('0xd')]=_0x3eae16;}[a7_0x2fab('0x18')](_0x49d376){const _0x2b2b26={'roots':[],'tasks':{},'dependencies':{}};for(const _0x14a137 of _0x49d376){this[a7_0x2fab('0x19')](_0x14a137,_0x2b2b26);const _0x339e80=getDependencyConfigs(_0x14a137[a7_0x2fab('0x4d')],this[a7_0x2fab('0xd')],this['projectGraph']);if(!_0x339e80){continue;}this[a7_0x2fab('0x61')](_0x14a137,_0x339e80,_0x49d376,_0x2b2b26);}_0x2b2b26[a7_0x2fab('0x44')]=Object[a7_0x2fab('0x31')](_0x2b2b26['dependencies'])[a7_0x2fab('0x58')](_0x4a8971=>_0x2b2b26[a7_0x2fab('0x1')][_0x4a8971][a7_0x2fab('0x42')]===0x0);return _0x2b2b26;}[a7_0x2fab('0x61')](_0x343b2b,_0x4bb119,_0x18630d,_0x5361c3){for(const _0x5598f0 of _0x4bb119){if(_0x5598f0['projects']==='self'){for(const _0x56138a of _0x18630d){if(_0x56138a[a7_0x2fab('0x4d')][a7_0x2fab('0x29')]===_0x343b2b['target'][a7_0x2fab('0x29')]&&_0x56138a[a7_0x2fab('0x4d')][a7_0x2fab('0x4d')]===_0x5598f0[a7_0x2fab('0x4d')]){_0x5361c3[a7_0x2fab('0x1')][_0x343b2b['id']][a7_0x2fab('0x3c')](_0x56138a['id']);}}}else if(_0x5598f0[a7_0x2fab('0x1b')]===a7_0x2fab('0x1')){const _0x4608d9=new Set();this[a7_0x2fab('0x5d')](_0x343b2b['target'][a7_0x2fab('0x29')],_0x5598f0['target'],_0x18630d,_0x5361c3,_0x343b2b['id'],_0x4608d9);}}}[a7_0x2fab('0x5d')](_0x3639a4,_0x534373,_0x3f71df,_0x35a484,_0x57b76c,_0x58a094){_0x58a094[a7_0x2fab('0x2e')](_0x3639a4);const _0x204852=this[a7_0x2fab('0x51')][a7_0x2fab('0x1')][_0x3639a4];if(_0x204852){const _0x5ca87e=_0x204852[a7_0x2fab('0x41')](_0xaf9ced=>_0xaf9ced[a7_0x2fab('0x4d')]);for(const _0x463308 of _0x5ca87e){if(_0x58a094[a7_0x2fab('0x4e')](_0x463308)){continue;}const _0x1839ea=this[a7_0x2fab('0x4f')]({'project':_0x463308,'target':_0x534373},_0x3f71df);if(_0x1839ea){if(_0x35a484[a7_0x2fab('0x1')][_0x57b76c]['indexOf'](_0x1839ea['id'])===-0x1){_0x35a484[a7_0x2fab('0x1')][_0x57b76c][a7_0x2fab('0x3c')](_0x1839ea['id']);}}else{this['addDependencies'](_0x463308,_0x534373,_0x3f71df,_0x35a484,_0x57b76c,_0x58a094);}}}}[a7_0x2fab('0x4f')]({project,target},_0x45265d){return _0x45265d[a7_0x2fab('0x37')](_0x3fdcdd=>_0x3fdcdd[a7_0x2fab('0x4d')]['project']===project&&_0x3fdcdd[a7_0x2fab('0x4d')]['target']===target);}[a7_0x2fab('0x19')](_0x566639,_0x45f42e){_0x45f42e['tasks'][_0x566639['id']]=_0x566639;_0x45f42e[a7_0x2fab('0x1')][_0x566639['id']]=[];}}exports['TaskGraphCreator']=TaskGraphCreator;function getDefaultDependencyConfigs(_0x296c5e,_0x35292e){var _0x2fbd29,_0x1c7b36;const _0x73d235=(_0x2fbd29=_0x296c5e['targetDependencies'])!==null&&_0x2fbd29!==void 0x0?_0x2fbd29:{};const _0x59dac3=_0x35292e?(_0x1c7b36=_0x35292e[a7_0x2fab('0x3e')])!==null&&_0x1c7b36!==void 0x0?_0x1c7b36:['build']:[];for(const _0x26ca8e of _0x59dac3){_0x73d235[_0x26ca8e]=_0x73d235[_0x26ca8e]||[];_0x73d235[_0x26ca8e][a7_0x2fab('0x3c')]({'target':_0x26ca8e,'projects':a7_0x2fab('0x1')});}return _0x73d235;}

10

lib/utilities/nx-imports.js
"use strict";
try {
const { output } = require('nx/src/utils/output');
const { workspaceRoot } = require('nx/src/utils/app-root');
let workspaceRoot;
try {
workspaceRoot = require('nx/src/utils/app-root').workspaceRoot;
}
catch (_a) {
workspaceRoot = require('nx/src/utils/workspace-root').workspaceRoot;
}
const { unparse, getDependencyConfigs, getOutputs, } = require('nx/src/tasks-runner/utils');

@@ -19,3 +25,3 @@ const { Cache } = require('nx/src/tasks-runner/cache');

}
catch (_a) {
catch (_b) {
const { output } = require('@nrwl/workspace/src/utilities/output');

@@ -22,0 +28,0 @@ const { appRootPath } = require('@nrwl/tao/src/utils/app-root');

{
"name": "nx-cloud",
"version": "14.0.6-beta.1",
"version": "14.0.6",
"description": "Nx Cloud plugin for Nx",

@@ -5,0 +5,0 @@ "keywords": [

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