Comparing version 14.1.1 to 14.1.2-beta.1
@@ -1,1 +0,36 @@ | ||
const a0_0x500e=['ErrorReporterApi','value','defineProperty','then','throw','done','../../utilities/axios','axiosMultipleTries','/nx-cloud/report-client-error','../../utilities/nx-imports','createApiAxiosInstance','__awaiter','apiAxiosInstance','next'];(function(_0x5987c0,_0x500e2c){const _0xebf148=function(_0x676c8){while(--_0x676c8){_0x5987c0['push'](_0x5987c0['shift']());}};_0xebf148(++_0x500e2c);}(a0_0x500e,0x1dc));const a0_0xebf1=function(_0x5987c0,_0x500e2c){_0x5987c0=_0x5987c0-0x0;let _0xebf148=a0_0x500e[_0x5987c0];return _0xebf148;};'use strict';var __awaiter=this&&this[a0_0xebf1('0xb')]||function(_0x2fd8f8,_0x2957a6,_0x4ffa4c,_0x386a70){function _0x1a5deb(_0x3879bc){return _0x3879bc instanceof _0x4ffa4c?_0x3879bc:new _0x4ffa4c(function(_0x1dc675){_0x1dc675(_0x3879bc);});}return new(_0x4ffa4c||(_0x4ffa4c=Promise))(function(_0x3f476e,_0x3624a8){function _0x6ae019(_0x2cf01e){try{_0x8f1389(_0x386a70[a0_0xebf1('0xd')](_0x2cf01e));}catch(_0x5b5284){_0x3624a8(_0x5b5284);}}function _0x2864b0(_0x4f2e06){try{_0x8f1389(_0x386a70[a0_0xebf1('0x4')](_0x4f2e06));}catch(_0x4cfdc5){_0x3624a8(_0x4cfdc5);}}function _0x8f1389(_0x1652ed){_0x1652ed[a0_0xebf1('0x5')]?_0x3f476e(_0x1652ed[a0_0xebf1('0x1')]):_0x1a5deb(_0x1652ed[a0_0xebf1('0x1')])[a0_0xebf1('0x3')](_0x6ae019,_0x2864b0);}_0x8f1389((_0x386a70=_0x386a70['apply'](_0x2fd8f8,_0x2957a6||[]))[a0_0xebf1('0xd')]());});};Object[a0_0xebf1('0x2')](exports,'__esModule',{'value':!![]});exports[a0_0xebf1('0x0')]=void 0x0;const axios_1=require(a0_0xebf1('0x6'));const {output}=require(a0_0xebf1('0x9'));class ErrorReporterApi{constructor(_0x3bdd90){this[a0_0xebf1('0xc')]=(0x0,axios_1[a0_0xebf1('0xa')])(_0x3bdd90);}['reportError'](_0x118dee){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0xebf1('0x7')])(()=>this[a0_0xebf1('0xc')]['post'](a0_0xebf1('0x8'),{'message':_0x118dee}));}catch(_0x1dedc5){output['warn']({'title':'Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27'+_0x118dee+'\x27','bodyLines':[_0x1dedc5['message']]});}});}}exports[a0_0xebf1('0x0')]=ErrorReporterApi; | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ErrorReporterApi = void 0; | ||
const axios_1 = require("../../utilities/axios"); | ||
const { output } = require('../../utilities/nx-imports'); | ||
class ErrorReporterApi { | ||
constructor(options) { | ||
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options); | ||
} | ||
reportError(message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', { | ||
message, | ||
})); | ||
} | ||
catch (e) { | ||
output.warn({ | ||
title: `Unable to record the following error: '${message}'`, | ||
bodyLines: [e.message], | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
exports.ErrorReporterApi = ErrorReporterApi; | ||
//# sourceMappingURL=error-reporter.api.js.map |
@@ -1,1 +0,65 @@ | ||
const a1_0x4c8a=['../../utilities/nx-imports','__awaiter','recordMetric','axiosMultipleTries','../../utilities/axios','post','defineProperty','done','RUNNER_FAILURE_PERF_ENTRY','next','apiAxiosInstance','message','mapRespToPerfEntry','createApiAxiosInstance','error','axiosException','response','apply','../../utilities/metric-logger','createRunGroup','then','createMetricRecorder','/nx-cloud/executions/complete-run-group'];(function(_0x3e3955,_0x4c8a5d){const _0x4f06f0=function(_0x3faf1b){while(--_0x3faf1b){_0x3e3955['push'](_0x3e3955['shift']());}};_0x4f06f0(++_0x4c8a5d);}(a1_0x4c8a,0x169));const a1_0x4f06=function(_0x3e3955,_0x4c8a5d){_0x3e3955=_0x3e3955-0x0;let _0x4f06f0=a1_0x4c8a[_0x3e3955];return _0x4f06f0;};'use strict';var __awaiter=this&&this[a1_0x4f06('0x8')]||function(_0x15e226,_0x274e94,_0xca54d1,_0x26e01b){function _0x4031e9(_0x5508d7){return _0x5508d7 instanceof _0xca54d1?_0x5508d7:new _0xca54d1(function(_0x36a54f){_0x36a54f(_0x5508d7);});}return new(_0xca54d1||(_0xca54d1=Promise))(function(_0x373fb7,_0x40b329){function _0x68e4eb(_0x24527b){try{_0x3390d7(_0x26e01b[a1_0x4f06('0x10')](_0x24527b));}catch(_0x55c19b){_0x40b329(_0x55c19b);}}function _0x5dac55(_0x5d6c3a){try{_0x3390d7(_0x26e01b['throw'](_0x5d6c3a));}catch(_0x56d494){_0x40b329(_0x56d494);}}function _0x3390d7(_0x26ff9f){_0x26ff9f[a1_0x4f06('0xe')]?_0x373fb7(_0x26ff9f['value']):_0x4031e9(_0x26ff9f['value'])[a1_0x4f06('0x4')](_0x68e4eb,_0x5dac55);}_0x3390d7((_0x26e01b=_0x26e01b[a1_0x4f06('0x1')](_0x15e226,_0x274e94||[]))[a1_0x4f06('0x10')]());});};Object[a1_0x4f06('0xd')](exports,'__esModule',{'value':!![]});exports['RunGroupApi']=void 0x0;const axios_1=require(a1_0x4f06('0xb'));const metric_logger_1=require(a1_0x4f06('0x2'));const {output}=require(a1_0x4f06('0x7'));class RunGroupApi{constructor(_0x3eaf82){this[a1_0x4f06('0x11')]=(0x0,axios_1[a1_0x4f06('0x14')])(_0x3eaf82);}[a1_0x4f06('0x3')](_0x57202d,_0x32d89a){var _0x1845d2;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5a04ba=(0x0,metric_logger_1[a1_0x4f06('0x5')])('createRunGroup');try{const _0x2646bc=yield(0x0,axios_1[a1_0x4f06('0xa')])(()=>this[a1_0x4f06('0x11')][a1_0x4f06('0xc')]('/nx-cloud/executions/create-run-group',{'branch':_0x57202d,'runGroup':_0x32d89a}));_0x5a04ba[a1_0x4f06('0x9')]((0x0,metric_logger_1[a1_0x4f06('0x13')])(_0x2646bc));}catch(_0x3ae622){_0x5a04ba[a1_0x4f06('0x9')](((_0x1845d2=_0x3ae622===null||_0x3ae622===void 0x0?void 0x0:_0x3ae622['axiosException'])===null||_0x1845d2===void 0x0?void 0x0:_0x1845d2['response'])?(0x0,metric_logger_1[a1_0x4f06('0x13')])(_0x3ae622[a1_0x4f06('0x16')][a1_0x4f06('0x0')]):metric_logger_1[a1_0x4f06('0xf')]);output[a1_0x4f06('0x15')]({'title':_0x3ae622[a1_0x4f06('0x12')]});process['exit'](0x1);}});}['completeRunGroup'](_0x5436a5){var _0x3621c7;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x423550=(0x0,metric_logger_1[a1_0x4f06('0x5')])(a1_0x4f06('0x3'));try{const _0x4f73ae=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a1_0x4f06('0x11')][a1_0x4f06('0xc')](a1_0x4f06('0x6'),{'runGroup':_0x5436a5}));_0x423550[a1_0x4f06('0x9')]((0x0,metric_logger_1[a1_0x4f06('0x13')])(_0x4f73ae));}catch(_0x48f9f1){_0x423550['recordMetric'](((_0x3621c7=_0x48f9f1===null||_0x48f9f1===void 0x0?void 0x0:_0x48f9f1[a1_0x4f06('0x16')])===null||_0x3621c7===void 0x0?void 0x0:_0x3621c7[a1_0x4f06('0x0')])?(0x0,metric_logger_1[a1_0x4f06('0x13')])(_0x48f9f1[a1_0x4f06('0x16')]['response']):metric_logger_1[a1_0x4f06('0xf')]);output[a1_0x4f06('0x15')]({'title':_0x48f9f1[a1_0x4f06('0x12')]});process['exit'](0x1);}});}}exports['RunGroupApi']=RunGroupApi; | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RunGroupApi = void 0; | ||
const axios_1 = require("../../utilities/axios"); | ||
const metric_logger_1 = require("../../utilities/metric-logger"); | ||
const { output } = require('../../utilities/nx-imports'); | ||
class RunGroupApi { | ||
constructor(options) { | ||
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options); | ||
} | ||
createRunGroup(branch, runGroup) { | ||
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 |
@@ -1,1 +0,138 @@ | ||
const a0_0xd445=['terminalOutputs','scheduleTask','implicitDeps','length','updateStartedTask','runtime','../../../utilities/nx-imports','Cannot\x20find\x20task\x20','path','remote-cache','startTask','NX_CLOUD_UNLIMITED_OUTPUT','TRUNCATED\x0a\x0a','node_modules','code','outputObfuscator','remote-cache-hit','skipNxCache','terminalOutput','../../../utilities/serializer-overrides','hashDetails','endTask','target','MAX_CHARACTERS_CACHED_TASK','endCommand','MAX_CHARACTERS_FAILED_TASK','obfuscate','params','status','statuses','push','hash','startsWith','.cache','filter','slice','local-cache-kept-existing','npm:','readTerminalOutputFile','endTasks','find','cacheDirectory','defineProperty','task','cleanUpHashDetails','forEach','CloudEnabledLifeCycle','MAX_CHARACTERS_SUCCESSFUL_TASK','../../../utilities/environment','cache-miss','project','nodes','readFileSync','local-cache-hit','cacheStatus','cacheableOperations','getTerminalOutput','join','serializeOverrides','collectTerminalOutput','keys','toString','toISOString','endTime','tasks','runContext'];(function(_0x23bca8,_0xd4456c){const _0x178eb3=function(_0x25579d){while(--_0x25579d){_0x23bca8['push'](_0x23bca8['shift']());}};_0x178eb3(++_0xd4456c);}(a0_0xd445,0xfa));const a0_0x178e=function(_0x23bca8,_0xd4456c){_0x23bca8=_0x23bca8-0x0;let _0x178eb3=a0_0xd445[_0x23bca8];return _0x178eb3;};'use strict';Object[a0_0x178e('0x38')](exports,'__esModule',{'value':!![]});exports[a0_0x178e('0x3c')]=void 0x0;const path=require(a0_0x178e('0x16'));const path_1=require(a0_0x178e('0x16'));const fs_1=require('fs');const environment_1=require(a0_0x178e('0x3e'));const serializer_overrides_1=require(a0_0x178e('0x21'));const {workspaceRoot}=require(a0_0x178e('0x14'));class CloudEnabledLifeCycle{constructor(_0x148881,_0x12c0da,_0x3ac9c8,_0x5d970f,_0x1ecc4f,_0x5cb00d,_0xeb65f6){this[a0_0x178e('0xd')]=_0x148881;this['cacheDirectory']=_0x12c0da;this[a0_0x178e('0x1f')]=_0x3ac9c8;this[a0_0x178e('0x7')]=_0x5d970f;this[a0_0x178e('0x3')]=_0x1ecc4f;this[a0_0x178e('0x1d')]=_0x5cb00d;this[a0_0x178e('0xc')]=_0xeb65f6;}[a0_0x178e('0xf')](_0x586f4b){this['runContext']['scheduledTasks'][a0_0x178e('0x2c')](_0x586f4b);}[a0_0x178e('0x18')](_0x21769f){this['tasks'][a0_0x178e('0x2c')]({'taskId':_0x21769f['id'],'startTime':new Date()['toISOString'](),'target':_0x21769f[a0_0x178e('0x24')][a0_0x178e('0x24')],'projectName':_0x21769f['target'][a0_0x178e('0x40')],'hash':_0x21769f['hash'],'hashDetails':this[a0_0x178e('0x3a')](_0x21769f[a0_0x178e('0x22')]),'params':(0x0,serializer_overrides_1[a0_0x178e('0x6')])(_0x21769f)});}[a0_0x178e('0x23')](_0x558b24,_0x1d4511){let _0x5621db;if(this['runContext'][a0_0x178e('0x2b')][_0x558b24[a0_0x178e('0x2d')]]){_0x5621db=this[a0_0x178e('0xd')][a0_0x178e('0x2b')][_0x558b24[a0_0x178e('0x2d')]];}else{if(this[a0_0x178e('0x3')]['indexOf'](_0x558b24['target']['target'])>-0x1&&!this[a0_0x178e('0x1f')]){_0x5621db=a0_0x178e('0x1');}else{_0x5621db='cache-miss';}}this[a0_0x178e('0x12')](_0x558b24,_0x1d4511,_0x5621db);}[a0_0x178e('0x35')](_0x321ea6){for(let _0x1e09a6 of _0x321ea6){const _0x12d3dd=_0x1e09a6[a0_0x178e('0x2a')]===a0_0x178e('0x17')?a0_0x178e('0x1e'):_0x1e09a6[a0_0x178e('0x2a')]==='local-cache'||_0x1e09a6['status']===a0_0x178e('0x32')?a0_0x178e('0x1'):'cache-miss';this[a0_0x178e('0x12')](_0x1e09a6[a0_0x178e('0x39')],_0x1e09a6[a0_0x178e('0x1c')],_0x12d3dd);}}[a0_0x178e('0x26')](){}['updateStartedTask'](_0x45d305,_0x45c10c,_0x58baae){const _0x2241fc=this['tasks'][a0_0x178e('0x36')](_0x91e9f2=>_0x91e9f2['taskId']===_0x45d305['id']);if(!_0x2241fc){throw new Error(a0_0x178e('0x15')+_0x45d305['id']);}_0x2241fc[a0_0x178e('0xb')]=new Date()[a0_0x178e('0xa')]();_0x2241fc[a0_0x178e('0x2a')]=_0x45c10c;_0x2241fc[a0_0x178e('0x29')]=this[a0_0x178e('0x1d')][a0_0x178e('0x28')](_0x2241fc['params']);_0x2241fc[a0_0x178e('0x2')]=_0x58baae;if(this[a0_0x178e('0x7')]){_0x2241fc[a0_0x178e('0x20')]=this['getTerminalOutput'](_0x45d305[a0_0x178e('0x2d')],_0x2241fc[a0_0x178e('0x2')],_0x45c10c);}}[a0_0x178e('0x4')](_0x1f2079,_0x185061,_0x57d72c){let _0x3b6a5c;if(this[a0_0x178e('0x37')]){if(this[a0_0x178e('0x37')][a0_0x178e('0x2e')]('./')){_0x3b6a5c=(0x0,path_1['join'])(workspaceRoot,this['cacheDirectory']);}else{_0x3b6a5c=this[a0_0x178e('0x37')];}}else{_0x3b6a5c=(0x0,path_1[a0_0x178e('0x5')])(workspaceRoot,a0_0x178e('0x1b'),a0_0x178e('0x2f'),'nx');}try{const _0xf3ce82=this[a0_0x178e('0x34')](_0x3b6a5c,_0x1f2079);const _0x1c1bb4=this['outputObfuscator'][a0_0x178e('0x28')](_0xf3ce82);if(environment_1[a0_0x178e('0x19')])return _0x1c1bb4;const _0x120880=_0x185061===a0_0x178e('0x3f')?_0x57d72c===0x0?CloudEnabledLifeCycle[a0_0x178e('0x3d')]:CloudEnabledLifeCycle[a0_0x178e('0x27')]:CloudEnabledLifeCycle[a0_0x178e('0x25')];return _0x1c1bb4[a0_0x178e('0x11')]>_0x120880?a0_0x178e('0x1a')+_0x1c1bb4[a0_0x178e('0x31')](_0x1c1bb4[a0_0x178e('0x11')]-_0x120880):_0x1c1bb4;}catch(_0x3d804d){return'';}}[a0_0x178e('0x3a')](_0x166d62){const _0x30447f={};Object[a0_0x178e('0x8')](_0x166d62[a0_0x178e('0x41')])[a0_0x178e('0x30')](_0x373b33=>!_0x373b33['startsWith'](a0_0x178e('0x33')))[a0_0x178e('0x3b')](_0x45e829=>{_0x30447f[_0x45e829]=_0x166d62['nodes'][_0x45e829];});return{'nodes':_0x30447f,'runtime':_0x166d62[a0_0x178e('0x13')],'implicitDeps':_0x166d62[a0_0x178e('0x10')]};}[a0_0x178e('0x34')](_0x123cb3,_0x4f2301){try{return(0x0,fs_1[a0_0x178e('0x0')])(path[a0_0x178e('0x5')](_0x123cb3,a0_0x178e('0xe'),_0x4f2301))['toString']();}catch(_0x43abb7){try{return(0x0,fs_1['readFileSync'])(path['join'](_0x123cb3,_0x4f2301,a0_0x178e('0x20')))[a0_0x178e('0x9')]();}catch(_0x2227d1){return'';}}}}exports['CloudEnabledLifeCycle']=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x178e('0x27')]=0x30d40;CloudEnabledLifeCycle['MAX_CHARACTERS_SUCCESSFUL_TASK']=0x4e20;CloudEnabledLifeCycle[a0_0x178e('0x25')]=0x4e20; | ||
"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 serializer_overrides_1 = require("../../../utilities/serializer-overrides"); | ||
const { workspaceRoot } = 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) { | ||
this.tasks.push({ | ||
taskId: task.id, | ||
startTime: new Date().toISOString(), | ||
target: task.target.target, | ||
projectName: task.target.project, | ||
hash: task.hash, | ||
hashDetails: this.cleanUpHashDetails(task.hashDetails), | ||
params: (0, serializer_overrides_1.serializeOverrides)(task), | ||
}); | ||
} | ||
// 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 |
@@ -1,1 +0,169 @@ | ||
const a1_0x1a20=['./cloud-run.api','maskedProperties','Executed\x20tasks\x20with\x20hashes:\x20','waitForStoreRequestsToComplete','./cloud-enabled-life-cycle','EndOfRunMessage','map','throw','../../terminal-output/end-of-run-message','then','defineProperty','cacheableOperations','join','subscribe','printMessages','extractGitSha','lifeCycle','ENCRYPTION_KEY','CloudEnabledLifeCycle','printCacheHitsMessage','writeFileSync','done','__awaiter','hash','error','CloudRunApi','../../../utilities/nx-imports','assign','./node_modules/.cache/nx','toISOString','scan','value','../../file-storage/file-storage','next','FileStorage','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','../../terminal-output/message-reporter','note','exit','requests','../../api/error-reporter.api','catch','getMachineInfo','endRun','VERBOSE_LOGGING','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','path','forEach','encryptionKey','parseCommand','../../terminal-output/output-obfuscator','skipNxCache','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','rxjs/internal/Subject','all','filter','cloudEnabledTasksRunner','./cloud-remote-cache','stringify','cacheDirectory','submitRunMetrics','obfuscate','../../file-storage/e2e-encryption','complete'];(function(_0x1e9c66,_0x1a205c){const _0x40abf7=function(_0x338440){while(--_0x338440){_0x1e9c66['push'](_0x1e9c66['shift']());}};_0x40abf7(++_0x1a205c);}(a1_0x1a20,0xe4));const a1_0x40ab=function(_0x1e9c66,_0x1a205c){_0x1e9c66=_0x1e9c66-0x0;let _0x40abf7=a1_0x1a20[_0x1e9c66];return _0x40abf7;};'use strict';var __awaiter=this&&this[a1_0x40ab('0x32')]||function(_0x2f4642,_0x22efcf,_0x254a1c,_0x1b561b){function _0x727bdc(_0x568165){return _0x568165 instanceof _0x254a1c?_0x568165:new _0x254a1c(function(_0x2c67a5){_0x2c67a5(_0x568165);});}return new(_0x254a1c||(_0x254a1c=Promise))(function(_0x52b960,_0x1148ec){function _0xc106c(_0x3dff85){try{_0x469fd(_0x1b561b[a1_0x40ab('0x3d')](_0x3dff85));}catch(_0x382d97){_0x1148ec(_0x382d97);}}function _0x82777a(_0xae8d04){try{_0x469fd(_0x1b561b[a1_0x40ab('0x23')](_0xae8d04));}catch(_0x4f8859){_0x1148ec(_0x4f8859);}}function _0x469fd(_0x5bc22c){_0x5bc22c[a1_0x40ab('0x31')]?_0x52b960(_0x5bc22c[a1_0x40ab('0x3b')]):_0x727bdc(_0x5bc22c[a1_0x40ab('0x3b')])[a1_0x40ab('0x25')](_0xc106c,_0x82777a);}_0x469fd((_0x1b561b=_0x1b561b['apply'](_0x2f4642,_0x22efcf||[]))['next']());});};Object[a1_0x40ab('0x26')](exports,'__esModule',{'value':!![]});exports[a1_0x40ab('0x14')]=void 0x0;const message_reporter_1=require(a1_0x40ab('0x0'));const end_of_run_message_1=require(a1_0x40ab('0x24'));const output_obfuscator_1=require(a1_0x40ab('0xe'));const cloud_enabled_life_cycle_1=require(a1_0x40ab('0x20'));const file_storage_1=require(a1_0x40ab('0x3c'));const e2e_encryption_1=require(a1_0x40ab('0x1a'));const environment_1=require('../../../utilities/environment');const cloud_remote_cache_1=require(a1_0x40ab('0x15'));const cloud_run_api_1=require(a1_0x40ab('0x1c'));const fs_1=require('fs');const path=require(a1_0x40ab('0xa'));const metric_logger_1=require('../../../utilities/metric-logger');const error_reporter_api_1=require(a1_0x40ab('0x4'));const {tasksRunner,output}=require('../../../utilities/nx-imports');function createApi(_0x1e7909,_0x304fdb,_0x372d2e){const _0x27203c=(0x0,environment_1[a1_0x40ab('0x6')])(_0x304fdb);return new cloud_run_api_1[(a1_0x40ab('0x35'))](_0x1e7909,_0x372d2e,_0x304fdb,_0x27203c);}function storeTaskHashes(_0x5c99d9,_0x5c4650,_0x1b3310){const _0x34b32c=JSON[a1_0x40ab('0x16')](_0x5c99d9['map'](_0x4efe84=>({'taskId':_0x4efe84['taskId'],'hash':_0x4efe84[a1_0x40ab('0x33')]})));if(environment_1[a1_0x40ab('0x8')]){output[a1_0x40ab('0x1')]({'title':a1_0x40ab('0x1e')+_0x34b32c});}(0x0,fs_1[a1_0x40ab('0x30')])(path[a1_0x40ab('0x28')](_0x5c4650,'tasks-hashes-'+_0x1b3310),_0x34b32c);}function onComplete(_0x496f9b,_0x117bff,_0x9a73f1,_0xdc7bb0,_0x7a4441,_0x97dee,_0x34364d,_0x57cc0e,_0x2193d3,_0x1ff5d4,_0x383311){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x38009b=new Date()[a1_0x40ab('0x39')]();if(environment_1[a1_0x40ab('0x3f')]){storeTaskHashes(_0x2193d3,_0x117bff[a1_0x40ab('0x17')]||a1_0x40ab('0x38'),environment_1[a1_0x40ab('0x9')]);}const _0x385f5c=(0x0,environment_1['getBranch'])();const _0x306df2=yield Promise[a1_0x40ab('0x12')]([_0x9a73f1[a1_0x40ab('0x1f')](),_0xdc7bb0[a1_0x40ab('0x7')]({'command':_0x7a4441[a1_0x40ab('0x19')]((0x0,environment_1[a1_0x40ab('0xd')])()),'startTime':_0x97dee,'endTime':_0x38009b,'distributedExecutionId':environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],'branch':_0x385f5c,'scan':!![],'runGroup':(0x0,environment_1['getRunGroup'])(),'sha':_0x385f5c?(0x0,environment_1[a1_0x40ab('0x2b')])():undefined,'inner':_0x383311},_0x2193d3)]);if(_0x1ff5d4){setTimeout(()=>{_0x34364d[a1_0x40ab('0x2a')]();if(!_0x34364d['anyErrors']&&!_0x383311){_0x57cc0e[a1_0x40ab('0x2f')]();}},0x0);}else{_0x34364d[a1_0x40ab('0x2a')]();if(!_0x34364d['anyErrors']&&!_0x383311){_0x57cc0e[a1_0x40ab('0x2f')]();}}if(environment_1[a1_0x40ab('0x3f')]){if(!_0x306df2[0x0]){output['error']({'title':'Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts'});_0x34364d[a1_0x40ab('0x2a')]();process[a1_0x40ab('0x2')](environment_1[a1_0x40ab('0x10')]);}if(!_0x306df2[0x1]){output[a1_0x40ab('0x34')]({'title':'Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run'});_0x34364d[a1_0x40ab('0x2a')]();process[a1_0x40ab('0x2')](environment_1[a1_0x40ab('0x10')]);}}yield(0x0,metric_logger_1[a1_0x40ab('0x18')])(_0x117bff);});}function createLifeCycle(_0x364c52,_0x3ae4,_0x15a47e,_0x4a250f){const _0x42b8dc=new cloud_enabled_life_cycle_1[(a1_0x40ab('0x2e'))](_0x364c52,_0x3ae4['cacheDirectory'],!!_0x3ae4[a1_0x40ab('0xf')],_0x3ae4['scan']===undefined?!![]:_0x3ae4[a1_0x40ab('0x3a')],_0x3ae4[a1_0x40ab('0x27')]||[],_0x15a47e,_0x4a250f);try{const {CompositeLifeCycle}=require(a1_0x40ab('0x36'));if(!CompositeLifeCycle)return _0x42b8dc;return new CompositeLifeCycle([_0x3ae4[a1_0x40ab('0x2c')],_0x42b8dc]);}catch(_0x5af33f){return _0x42b8dc;}}function cloudEnabledTasksRunner(_0xf21d70,_0x160720,_0x1b08d6,_0xd570b8=![]){const _0x22688b={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0xf21d70};const _0x5d777a=_0x160720['lifeCycle']===undefined;const _0x3ec35b=[];const _0x27376c=new message_reporter_1['MessageReporter'](_0x160720);const _0x327e72=createApi(_0x27376c,_0x160720,_0x22688b);const _0xfc0e79=new end_of_run_message_1[(a1_0x40ab('0x21'))](_0x22688b,_0x3ec35b);const _0x4176b9=new output_obfuscator_1['OutputObfuscator'](_0x160720[a1_0x40ab('0x1d')]);const _0x2f45fe=_0xf21d70[a1_0x40ab('0x22')](_0x11395b=>_0x11395b[a1_0x40ab('0x33')])[a1_0x40ab('0x13')](_0x3cf7c7=>!!_0x3cf7c7);const _0x31a755=_0x327e72['startRun'](environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],_0x2f45fe);_0x2f45fe[a1_0x40ab('0xb')](_0x1275db=>{_0x22688b[a1_0x40ab('0x3')][_0x1275db]=_0x31a755;});const _0x216722=new Date()[a1_0x40ab('0x39')]();const _0xf7bf72=createLifeCycle(_0x22688b,_0x160720,_0x4176b9,_0x3ec35b);const _0x395002=new e2e_encryption_1['E2EEncryption'](environment_1[a1_0x40ab('0x2d')]||_0x160720[a1_0x40ab('0xc')]);const _0x10d74b=new error_reporter_api_1['ErrorReporterApi'](_0x160720);const _0x516c6b=new file_storage_1[(a1_0x40ab('0x3e'))](_0x395002,_0x10d74b,![]);const _0x20b98d=new cloud_remote_cache_1['CloudRemoteCache'](_0x27376c,_0x327e72,_0x22688b,_0x516c6b);delete process['env'][a1_0x40ab('0x9')];const _0xe6a7b=tasksRunner(_0xf21d70,Object[a1_0x40ab('0x37')](Object[a1_0x40ab('0x37')]({},_0x160720),{'remoteCache':_0x20b98d,'lifeCycle':_0xf7bf72}),_0x1b08d6);if(_0xe6a7b[a1_0x40ab('0x29')]){const {Subject}=require(a1_0x40ab('0x11'));const _0x11ebae=new Subject();_0xe6a7b[a1_0x40ab('0x29')]({'next':_0x34c05b=>_0x11ebae[a1_0x40ab('0x3d')](_0x34c05b),'error':_0x27d594=>_0x11ebae[a1_0x40ab('0x34')](_0x27d594),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0xf7bf72,_0x160720,_0x20b98d,_0x327e72,_0x4176b9,_0x216722,_0x27376c,_0xfc0e79,_0x3ec35b,_0x5d777a,_0xd570b8);_0x11ebae[a1_0x40ab('0x1b')]();})});return _0x11ebae;}else{return _0xe6a7b[a1_0x40ab('0x25')](_0x48991e=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0xf7bf72,_0x160720,_0x20b98d,_0x327e72,_0x4176b9,_0x216722,_0x27376c,_0xfc0e79,_0x3ec35b,_0x5d777a,_0xd570b8);return _0x48991e;}))[a1_0x40ab('0x5')](_0x4b1a5b=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0xf7bf72,_0x160720,_0x20b98d,_0x327e72,_0x4176b9,_0x216722,_0x27376c,_0xfc0e79,_0x3ec35b,_0x5d777a,_0xd570b8);throw _0x4b1a5b;}));}}exports[a1_0x40ab('0x14')]=cloudEnabledTasksRunner; | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cloudEnabledTasksRunner = void 0; | ||
const message_reporter_1 = require("../../terminal-output/message-reporter"); | ||
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message"); | ||
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator"); | ||
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle"); | ||
const file_storage_1 = require("../../file-storage/file-storage"); | ||
const e2e_encryption_1 = require("../../file-storage/e2e-encryption"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const cloud_remote_cache_1 = require("./cloud-remote-cache"); | ||
const cloud_run_api_1 = require("./cloud-run.api"); | ||
const fs_1 = require("fs"); | ||
const path = require("path"); | ||
const 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 |
@@ -1,1 +0,113 @@ | ||
const a2_0x421c=['cacheError','.\x20Read\x20only\x20token\x20is\x20used.','remote-cache-hit','../../../utilities/environment','indexOf','runContext','messages','storage','value','Nx\x20Cloud:\x20Skipping\x20storing\x20','note','retrieve','storeRequests','defineProperty','Nx\x20Cloud:\x20Cache\x20miss\x20','reduce','hashUrls','filter','forEach','response','done','axiosException','statuses','requests','throw','hash','waitForStoreRequestsToComplete','scheduledTasks','.\x20Status\x20404.','VERBOSE_LOGGING','__esModule','cache-miss','put','push','extractErrorMessage','map','apply','all','store','get','../../../utilities/nx-imports','then','api','__awaiter','fileStorage','CloudRemoteCache'];(function(_0x44acd7,_0x421cdc){const _0x2d59e0=function(_0x18a858){while(--_0x18a858){_0x44acd7['push'](_0x44acd7['shift']());}};_0x2d59e0(++_0x421cdc);}(a2_0x421c,0x184));const a2_0x2d59=function(_0x44acd7,_0x421cdc){_0x44acd7=_0x44acd7-0x0;let _0x2d59e0=a2_0x421c[_0x44acd7];return _0x2d59e0;};'use strict';var __awaiter=this&&this[a2_0x2d59('0x17')]||function(_0x4ca075,_0x2485e4,_0x419000,_0x1a5e8c){function _0x44fd4f(_0x184c08){return _0x184c08 instanceof _0x419000?_0x184c08:new _0x419000(function(_0x2feb1c){_0x2feb1c(_0x184c08);});}return new(_0x419000||(_0x419000=Promise))(function(_0x278c6a,_0x2ba408){function _0x5f36e7(_0x2d1c41){try{_0x4d2106(_0x1a5e8c['next'](_0x2d1c41));}catch(_0xbac0c7){_0x2ba408(_0xbac0c7);}}function _0x22a643(_0x52b67d){try{_0x4d2106(_0x1a5e8c[a2_0x2d59('0x4')](_0x52b67d));}catch(_0x3e540d){_0x2ba408(_0x3e540d);}}function _0x4d2106(_0x5f5d7d){_0x5f5d7d[a2_0x2d59('0x0')]?_0x278c6a(_0x5f5d7d[a2_0x2d59('0x22')]):_0x44fd4f(_0x5f5d7d[a2_0x2d59('0x22')])[a2_0x2d59('0x15')](_0x5f36e7,_0x22a643);}_0x4d2106((_0x1a5e8c=_0x1a5e8c[a2_0x2d59('0x10')](_0x4ca075,_0x2485e4||[]))['next']());});};Object[a2_0x2d59('0x27')](exports,a2_0x2d59('0xa'),{'value':!![]});exports[a2_0x2d59('0x19')]=void 0x0;const environment_1=require(a2_0x2d59('0x1d'));const {output}=require(a2_0x2d59('0x14'));class CloudRemoteCache{constructor(_0xa58f5d,_0x5107a9,_0x5e67e2,_0x56fa7c){this[a2_0x2d59('0x20')]=_0xa58f5d;this[a2_0x2d59('0x16')]=_0x5107a9;this[a2_0x2d59('0x1f')]=_0x5e67e2;this['fileStorage']=_0x56fa7c;this[a2_0x2d59('0x26')]=[];}[a2_0x2d59('0x25')](_0x43d141,_0x19dab8){var _0x5081a8;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x2d59('0x20')]['cacheError'])return![];const _0x2430b3=yield this[a2_0x2d59('0x2a')](_0x43d141);if(!_0x2430b3||!_0x2430b3[a2_0x2d59('0x13')]){if(environment_1[a2_0x2d59('0x9')]){output['note']({'title':a2_0x2d59('0x28')+_0x43d141+'.'});}this[a2_0x2d59('0x1f')][a2_0x2d59('0x2')][_0x43d141]=a2_0x2d59('0xb');return![];}try{yield this[a2_0x2d59('0x18')][a2_0x2d59('0x25')](_0x43d141,_0x2430b3[a2_0x2d59('0x13')],_0x19dab8);this[a2_0x2d59('0x1f')][a2_0x2d59('0x2')][_0x43d141]=a2_0x2d59('0x1c');return!![];}catch(_0x5bcaba){const _0x312e9b=(_0x5081a8=_0x5bcaba[a2_0x2d59('0x1')])!==null&&_0x5081a8!==void 0x0?_0x5081a8:_0x5bcaba;if(_0x312e9b['response']&&_0x312e9b[a2_0x2d59('0x2d')]['status']===0x194){if(environment_1[a2_0x2d59('0x9')]){output[a2_0x2d59('0x24')]({'title':a2_0x2d59('0x28')+_0x43d141+a2_0x2d59('0x8')});}}else{this['messages'][a2_0x2d59('0x1a')]=this[a2_0x2d59('0x20')][a2_0x2d59('0xe')](_0x312e9b,a2_0x2d59('0x21'));}this[a2_0x2d59('0x1f')]['statuses'][_0x43d141]=a2_0x2d59('0xb');return![];}});}[a2_0x2d59('0x12')](_0x233ee0,_0x534ffd){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x2d59('0x20')][a2_0x2d59('0x1a')])return![];const _0x44b2e2=Promise['resolve']()['then'](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x548f38;const _0x4d7b86=yield this[a2_0x2d59('0x2a')](_0x233ee0);if(!_0x4d7b86)return![];if(!_0x4d7b86[a2_0x2d59('0xc')]){if(environment_1[a2_0x2d59('0x9')]){output[a2_0x2d59('0x24')]({'title':a2_0x2d59('0x23')+_0x233ee0+a2_0x2d59('0x1b')});}return!![];}try{yield this[a2_0x2d59('0x18')][a2_0x2d59('0x12')](_0x233ee0,_0x4d7b86[a2_0x2d59('0xc')],_0x534ffd);return!![];}catch(_0x2a011b){const _0x167756=(_0x548f38=_0x2a011b[a2_0x2d59('0x1')])!==null&&_0x548f38!==void 0x0?_0x548f38:_0x2a011b;this[a2_0x2d59('0x20')][a2_0x2d59('0x1a')]=this['messages'][a2_0x2d59('0xe')](_0x167756,a2_0x2d59('0x21'));return![];}}));this['storeRequests'][a2_0x2d59('0xd')](_0x44b2e2);return _0x44b2e2;});}[a2_0x2d59('0x2a')](_0x194bb){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x194bb in this[a2_0x2d59('0x1f')][a2_0x2d59('0x3')]){return(yield this[a2_0x2d59('0x1f')][a2_0x2d59('0x3')][_0x194bb])[_0x194bb];}else{const _0x3498e6=this[a2_0x2d59('0x1f')][a2_0x2d59('0x7')][a2_0x2d59('0x2b')](_0x4ea2f3=>!this[a2_0x2d59('0x1f')][a2_0x2d59('0x3')][_0x4ea2f3[a2_0x2d59('0x5')]])[a2_0x2d59('0xf')](_0x34f46e=>_0x34f46e[a2_0x2d59('0x5')]);if(_0x3498e6[a2_0x2d59('0x1e')](_0x194bb)===-0x1){_0x3498e6[a2_0x2d59('0xd')](_0x194bb);}const _0x872ca2=this[a2_0x2d59('0x16')]['startRun'](environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],_0x3498e6);_0x3498e6[a2_0x2d59('0x2c')](_0x3e35b9=>{this[a2_0x2d59('0x1f')]['requests'][_0x3e35b9]=_0x872ca2;});return(yield _0x872ca2)[_0x194bb];}});}[a2_0x2d59('0x6')](){return Promise[a2_0x2d59('0x11')](this[a2_0x2d59('0x26')])['then'](_0x4d8446=>_0x4d8446[a2_0x2d59('0x29')]((_0x22b598,_0x38537d)=>_0x22b598&&_0x38537d,!![]));}}exports[a2_0x2d59('0x19')]=CloudRemoteCache; | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CloudRemoteCache = void 0; | ||
const environment_1 = require("../../../utilities/environment"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
class CloudRemoteCache { | ||
constructor(messages, api, runContext, fileStorage) { | ||
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 |
@@ -1,1 +0,166 @@ | ||
const a3_0x282f=['../../../utilities/metric-logger','machineInfo','runUrl','promisify','Run\x20completion\x20responded\x20with\x20`undefined`.','status','then','terminalOutput','note','startRun','apiAxiosInstance','headers','api','gzip','error','extractErrorMessage','defineProperty','length','/nx-cloud/runs/end','toString','__esModule','response','endRun','devDependencies','post','urls','@nrwl/nx-cloud','axiosMultipleTries','defaults','getBranch','runContext','message','/nx-cloud/runs/start','VERBOSE_LOGGING','../../../utilities/environment','CloudRunApi','RunEnd.\x20Completed\x20tasks','next','mapRespToPerfEntry','stringify','createApiAxiosInstance','value','done','createMetricRecorder','assign','apply','__awaiter','data','slice','stack','RUNNER_FAILURE_PERF_ENTRY','apiError','createReqBody','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','string','Invalid\x20Nx\x20Cloud\x20response:\x20','parse','Invalid\x20end\x20run\x20response:\x20','map','readFileSync','Invalid\x20end\x20run\x20response','messages','recordMetric','../../../utilities/axios','axiosException','throw','RunStart','nxCloudVersion','Run\x20Details:'];(function(_0xb2ceb7,_0x282fa4){const _0x25ce75=function(_0x39cc71){while(--_0x39cc71){_0xb2ceb7['push'](_0xb2ceb7['shift']());}};_0x25ce75(++_0x282fa4);}(a3_0x282f,0x92));const a3_0x25ce=function(_0xb2ceb7,_0x282fa4){_0xb2ceb7=_0xb2ceb7-0x0;let _0x25ce75=a3_0x282f[_0xb2ceb7];return _0x25ce75;};'use strict';var __awaiter=this&&this[a3_0x25ce('0x26')]||function(_0x6f15a3,_0x218ac8,_0x562cf8,_0x3f908f){function _0x106bdd(_0x8ecd81){return _0x8ecd81 instanceof _0x562cf8?_0x8ecd81:new _0x562cf8(function(_0x137b19){_0x137b19(_0x8ecd81);});}return new(_0x562cf8||(_0x562cf8=Promise))(function(_0x2f3f81,_0x4a948c){function _0x5e06c8(_0x2e5477){try{_0x197061(_0x3f908f[a3_0x25ce('0x1d')](_0x2e5477));}catch(_0x2f80f7){_0x4a948c(_0x2f80f7);}}function _0xecab94(_0xbef605){try{_0x197061(_0x3f908f[a3_0x25ce('0x39')](_0xbef605));}catch(_0x195544){_0x4a948c(_0x195544);}}function _0x197061(_0x49eafe){_0x49eafe[a3_0x25ce('0x22')]?_0x2f3f81(_0x49eafe[a3_0x25ce('0x21')]):_0x106bdd(_0x49eafe[a3_0x25ce('0x21')])[a3_0x25ce('0x43')](_0x5e06c8,_0xecab94);}_0x197061((_0x3f908f=_0x3f908f[a3_0x25ce('0x25')](_0x6f15a3,_0x218ac8||[]))['next']());});};Object[a3_0x25ce('0x8')](exports,a3_0x25ce('0xc'),{'value':!![]});exports[a3_0x25ce('0x1b')]=void 0x0;const axios_1=require(a3_0x25ce('0x37'));const environment_1=require(a3_0x25ce('0x1a'));const fs_1=require('fs');const zlib_1=require('zlib');const util_1=require('util');const metric_logger_1=require(a3_0x25ce('0x3d'));const {output}=require('../../../utilities/nx-imports');class CloudRunApi{constructor(_0x15ccbc,_0x9535d2,_0xd27f8c,_0x541beb){this[a3_0x25ce('0x35')]=_0x15ccbc;this['runContext']=_0x9535d2;this['machineInfo']=_0x541beb;this['apiAxiosInstance']=(0x0,axios_1[a3_0x25ce('0x20')])(_0xd27f8c);}['startRun'](_0x436d43,_0x5f9f8e){var _0x620b9f;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x100709=(0x0,metric_logger_1[a3_0x25ce('0x23')])(a3_0x25ce('0x1'));try{const _0x47bfc4={'meta':{'nxCloudVersion':this[a3_0x25ce('0x3b')]()},'branch':(0x0,environment_1[a3_0x25ce('0x15')])(),'runGroup':(0x0,environment_1['getRunGroup'])(),'distributedExecutionId':_0x436d43,'hashes':_0x5f9f8e};if(environment_1[a3_0x25ce('0x19')]){output[a3_0x25ce('0x0')]({'title':a3_0x25ce('0x3a'),'bodyLines':['\x0a'+JSON['stringify'](_0x47bfc4,null,0x2)]});}const _0x4e53a4=yield(0x0,axios_1[a3_0x25ce('0x13')])(()=>this[a3_0x25ce('0x2')][a3_0x25ce('0x10')](a3_0x25ce('0x18'),_0x47bfc4));_0x100709[a3_0x25ce('0x36')]((0x0,metric_logger_1[a3_0x25ce('0x1e')])(_0x4e53a4));if(_0x4e53a4[a3_0x25ce('0x27')]&&_0x4e53a4[a3_0x25ce('0x27')][a3_0x25ce('0x17')]){this[a3_0x25ce('0x35')][a3_0x25ce('0x17')]=_0x4e53a4[a3_0x25ce('0x27')]['message'];}if(!_0x4e53a4[a3_0x25ce('0x27')]||!_0x4e53a4[a3_0x25ce('0x27')][a3_0x25ce('0x11')]){this[a3_0x25ce('0x35')][a3_0x25ce('0x2b')]=a3_0x25ce('0x2f')+JSON[a3_0x25ce('0x1f')](_0x4e53a4[a3_0x25ce('0x27')]);return{};}return _0x4e53a4[a3_0x25ce('0x27')]['urls'];}catch(_0x5ce45c){_0x100709[a3_0x25ce('0x36')](((_0x620b9f=_0x5ce45c===null||_0x5ce45c===void 0x0?void 0x0:_0x5ce45c[a3_0x25ce('0x38')])===null||_0x620b9f===void 0x0?void 0x0:_0x620b9f['response'])?(0x0,metric_logger_1[a3_0x25ce('0x1e')])(_0x5ce45c[a3_0x25ce('0x38')][a3_0x25ce('0xd')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);this['messages'][a3_0x25ce('0x2b')]=this['messages'][a3_0x25ce('0x7')](_0x5ce45c,a3_0x25ce('0x4'));return{};}});}['createReqBody'](_0x3f453f,_0x2dd771){const _0x5e1f0c={'meta':{'nxCloudVersion':this['nxCloudVersion']()},'tasks':_0x2dd771,'run':_0x3f453f,'machineInfo':this[a3_0x25ce('0x3e')]};return JSON[a3_0x25ce('0x1f')](_0x5e1f0c);}['endRun'](_0xf0ace3,_0x37c29f){var _0x52b2a3,_0x215c1f;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x25ce('0x35')]['apiError'])return![];let _0x43d687=this[a3_0x25ce('0x2c')](_0xf0ace3,_0x37c29f);if(_0x43d687[a3_0x25ce('0x9')]>0x14*0x3e8*0x3e8){_0x43d687=this['createReqBody'](_0xf0ace3,_0x37c29f[a3_0x25ce('0x32')](_0x2ad1a6=>Object[a3_0x25ce('0x24')](Object['assign']({},_0x2ad1a6),{'hashDetails':undefined})));}const _0x20a42e=Buffer['from'](_0x43d687);const _0x524a3d=yield(0x0,util_1[a3_0x25ce('0x40')])(zlib_1[a3_0x25ce('0x5')])(_0x20a42e);const _0x567581=(0x0,metric_logger_1[a3_0x25ce('0x23')])(a3_0x25ce('0xe'));try{if(environment_1[a3_0x25ce('0x19')]){const _0x118858=_0x37c29f['map'](_0x50c675=>{return Object[a3_0x25ce('0x24')](Object['assign']({},_0x50c675),{'terminalOutput':_0x50c675[a3_0x25ce('0x44')]?_0x50c675[a3_0x25ce('0x44')][a3_0x25ce('0x28')](0x0,0x14)+'...':undefined});});output['note']({'title':a3_0x25ce('0x1c'),'bodyLines':['\x0a'+JSON[a3_0x25ce('0x1f')](_0x118858,null,0x2)]});}const _0x271555=yield(0x0,axios_1[a3_0x25ce('0x13')])(()=>this['apiAxiosInstance']['post'](a3_0x25ce('0xa'),_0x524a3d,{'headers':Object[a3_0x25ce('0x24')](Object['assign']({},this[a3_0x25ce('0x2')][a3_0x25ce('0x14')][a3_0x25ce('0x3')]),{'Content-Encoding':a3_0x25ce('0x5'),'Content-Type':'application/octet-stream'})}));if(_0x271555){_0x567581[a3_0x25ce('0x36')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x271555));if(_0x271555[a3_0x25ce('0x27')]&&_0x271555[a3_0x25ce('0x27')]['runUrl']&&_0x271555[a3_0x25ce('0x27')][a3_0x25ce('0x42')]==='success'){this[a3_0x25ce('0x16')][a3_0x25ce('0x3f')]=_0x271555[a3_0x25ce('0x27')][a3_0x25ce('0x3f')];return!![];}if(_0x271555[a3_0x25ce('0x27')]&&_0x271555[a3_0x25ce('0x27')]['status']){this['messages'][a3_0x25ce('0x2b')]='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0x25ce('0x1f')](_0x271555['data'][a3_0x25ce('0x17')]);}else if(_0x271555['data']&&typeof _0x271555[a3_0x25ce('0x27')]===a3_0x25ce('0x2e')){if(_0x271555[a3_0x25ce('0x27')]!=='success'){this[a3_0x25ce('0x35')][a3_0x25ce('0x2b')]='Invalid\x20end\x20run\x20response:\x20'+JSON['stringify'](_0x271555[a3_0x25ce('0x27')]);}}else{this[a3_0x25ce('0x35')]['apiError']=a3_0x25ce('0x31')+JSON['stringify'](_0x271555[a3_0x25ce('0x27')]);}if(environment_1[a3_0x25ce('0x19')]){output[a3_0x25ce('0x0')]({'title':a3_0x25ce('0x34'),'bodyLines':[JSON[a3_0x25ce('0x1f')](_0x271555[a3_0x25ce('0x27')],null,0x2)]});}}else{output[a3_0x25ce('0x6')]({'title':a3_0x25ce('0x2d'),'bodyLines':[a3_0x25ce('0x41'),a3_0x25ce('0x3c'),JSON['stringify'](_0xf0ace3,null,0x2),'Stack\x20Trace:',JSON['stringify'](new Error()[a3_0x25ce('0x29')],null,0x2)]});}return![];}catch(_0x15f903){_0x567581[a3_0x25ce('0x36')](((_0x52b2a3=_0x15f903===null||_0x15f903===void 0x0?void 0x0:_0x15f903[a3_0x25ce('0x38')])===null||_0x52b2a3===void 0x0?void 0x0:_0x52b2a3['response'])?(0x0,metric_logger_1[a3_0x25ce('0x1e')])(_0x15f903[a3_0x25ce('0x38')][a3_0x25ce('0xd')]):metric_logger_1[a3_0x25ce('0x2a')]);const _0x25fc06=(_0x215c1f=_0x15f903[a3_0x25ce('0x38')])!==null&&_0x215c1f!==void 0x0?_0x215c1f:_0x15f903;this[a3_0x25ce('0x35')][a3_0x25ce('0x2b')]=this[a3_0x25ce('0x35')]['extractErrorMessage'](_0x25fc06,a3_0x25ce('0x4'));return![];}});}['nxCloudVersion'](){try{const _0x254d70=JSON[a3_0x25ce('0x30')]((0x0,fs_1[a3_0x25ce('0x33')])('package.json')[a3_0x25ce('0xb')]());return _0x254d70[a3_0x25ce('0xf')][a3_0x25ce('0x12')];}catch(_0x4be345){return'unknown';}}}exports[a3_0x25ce('0x1b')]=CloudRunApi; | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CloudRunApi = void 0; | ||
const axios_1 = require("../../../utilities/axios"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const fs_1 = require("fs"); | ||
const zlib_1 = require("zlib"); | ||
const util_1 = require("util"); | ||
const metric_logger_1 = require("../../../utilities/metric-logger"); | ||
const { 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 |
@@ -1,1 +0,79 @@ | ||
const a4_0x3baa=['error','../../../utilities/nx-imports','value','completeRunGroupWithError','recordMetric','apply','tasks','response','throw','mapRespToPerfEntry','DistributedAgentApi','dtePollTasks','apiAxiosInstance','done','axiosMultipleTries','createMetricRecorder','data','then','../../../utilities/axios','../../../utilities/metric-logger','__awaiter','agentName','post','axiosException','__esModule','error:\x20','RUNNER_FAILURE_PERF_ENTRY','../../../utilities/environment','runGroup','Completing\x20run\x20group\x20with\x20an\x20error','createApiAxiosInstance','VERBOSE_LOGGING','note','next','completeRunGroup'];(function(_0x55369c,_0x3baa3d){const _0x2f4089=function(_0x1f084a){while(--_0x1f084a){_0x55369c['push'](_0x55369c['shift']());}};_0x2f4089(++_0x3baa3d);}(a4_0x3baa,0x1ca));const a4_0x2f40=function(_0x55369c,_0x3baa3d){_0x55369c=_0x55369c-0x0;let _0x2f4089=a4_0x3baa[_0x55369c];return _0x2f4089;};'use strict';var __awaiter=this&&this[a4_0x2f40('0x11')]||function(_0x176141,_0x141078,_0x4afb53,_0x2295e9){function _0x5147d1(_0xc6b668){return _0xc6b668 instanceof _0x4afb53?_0xc6b668:new _0x4afb53(function(_0x35321c){_0x35321c(_0xc6b668);});}return new(_0x4afb53||(_0x4afb53=Promise))(function(_0x3bd20a,_0x3d3a3d){function _0x3c5041(_0x1d241e){try{_0x2aa479(_0x2295e9['next'](_0x1d241e));}catch(_0x3334c0){_0x3d3a3d(_0x3334c0);}}function _0x476113(_0x40cf9f){try{_0x2aa479(_0x2295e9[a4_0x2f40('0x5')](_0x40cf9f));}catch(_0x275bb2){_0x3d3a3d(_0x275bb2);}}function _0x2aa479(_0x1a0ed8){_0x1a0ed8[a4_0x2f40('0xa')]?_0x3bd20a(_0x1a0ed8[a4_0x2f40('0x22')]):_0x5147d1(_0x1a0ed8[a4_0x2f40('0x22')])[a4_0x2f40('0xe')](_0x3c5041,_0x476113);}_0x2aa479((_0x2295e9=_0x2295e9[a4_0x2f40('0x2')](_0x176141,_0x141078||[]))[a4_0x2f40('0x1e')]());});};Object['defineProperty'](exports,a4_0x2f40('0x15'),{'value':!![]});exports[a4_0x2f40('0x7')]=void 0x0;const axios_1=require(a4_0x2f40('0xf'));const environment_1=require(a4_0x2f40('0x18'));const metric_logger_1=require(a4_0x2f40('0x10'));const {output}=require(a4_0x2f40('0x21'));class DistributedAgentApi{constructor(_0x13cc8a,_0x61498d,_0x4f323b){this[a4_0x2f40('0x19')]=_0x61498d;this[a4_0x2f40('0x12')]=_0x4f323b;this[a4_0x2f40('0x9')]=(0x0,axios_1[a4_0x2f40('0x1b')])(_0x13cc8a);}[a4_0x2f40('0x3')](_0x267ce9,_0x177e32,_0x73faf0){var _0x235280;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2ee516=(0x0,metric_logger_1[a4_0x2f40('0xc')])(a4_0x2f40('0x8'));try{const _0x200627=yield(0x0,axios_1[a4_0x2f40('0xb')])(()=>this[a4_0x2f40('0x9')][a4_0x2f40('0x13')]('/nx-cloud/executions/tasks',{'runGroup':this[a4_0x2f40('0x19')],'agentName':this[a4_0x2f40('0x12')],'executionId':_0x267ce9,'statusCode':_0x177e32,'completedTasks':_0x73faf0}));_0x2ee516['recordMetric']((0x0,metric_logger_1[a4_0x2f40('0x6')])(_0x200627));return _0x200627[a4_0x2f40('0xd')];}catch(_0x3858da){_0x2ee516[a4_0x2f40('0x1')](((_0x235280=_0x3858da===null||_0x3858da===void 0x0?void 0x0:_0x3858da[a4_0x2f40('0x14')])===null||_0x235280===void 0x0?void 0x0:_0x235280[a4_0x2f40('0x4')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x3858da[a4_0x2f40('0x14')][a4_0x2f40('0x4')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);throw _0x3858da;}});}[a4_0x2f40('0x0')](_0x51df94){var _0x11b67c;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1['VERBOSE_LOGGING']){output[a4_0x2f40('0x1d')]({'title':a4_0x2f40('0x1a'),'bodyLines':['runGroup:\x20'+this['runGroup'],a4_0x2f40('0x16')+_0x51df94]});}const _0x499449=(0x0,metric_logger_1['createMetricRecorder'])(a4_0x2f40('0x1f'));try{const _0xa7e8ed=yield(0x0,axios_1[a4_0x2f40('0xb')])(()=>this[a4_0x2f40('0x9')][a4_0x2f40('0x13')]('/nx-cloud/executions/complete-run-group',{'runGroup':this[a4_0x2f40('0x19')],'agentName':this[a4_0x2f40('0x12')],'criticalErrorMessage':_0x51df94}));if(environment_1[a4_0x2f40('0x1c')]){output[a4_0x2f40('0x1d')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0x499449[a4_0x2f40('0x1')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0xa7e8ed));}catch(_0x3baffc){_0x499449[a4_0x2f40('0x1')](((_0x11b67c=_0x3baffc===null||_0x3baffc===void 0x0?void 0x0:_0x3baffc[a4_0x2f40('0x14')])===null||_0x11b67c===void 0x0?void 0x0:_0x11b67c[a4_0x2f40('0x4')])?(0x0,metric_logger_1[a4_0x2f40('0x6')])(_0x3baffc[a4_0x2f40('0x14')]['response']):metric_logger_1[a4_0x2f40('0x17')]);console[a4_0x2f40('0x20')](_0x3baffc);}});}}exports[a4_0x2f40('0x7')]=DistributedAgentApi; | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DistributedAgentApi = void 0; | ||
const axios_1 = require("../../../utilities/axios"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const metric_logger_1 = require("../../../utilities/metric-logger"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
class DistributedAgentApi { | ||
constructor(options, 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 |
@@ -1,1 +0,240 @@ | ||
const a5_0x5e39=['push','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','VERBOSE_LOGGING','DistributedAgentApi','createNoNewMessagesTimeout','then','NX_AGENT_NAME','.lock','./node_modules/.cache/nx','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','startAgent','retryDuring','SIGINT','done','parse','../../../utilities/create-no-new-messages-timeout','readFileSync','criticalErrorMessage','tasks','catch','warn','__esModule','join','executionId','--configuration=','error','Waiting...','number\x20of\x20tasks:\x20','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','tasksRunnerOptions','../../error/print-run-group-error','wait','../../../utilities/nx-imports','Critical\x20Error\x20in\x20Agent:\x20\x22','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','Waiter','existsSync','../../../utilities/environment','/nx.json','maxParallel','throw','projects','toString','Agent\x20','completeRunGroupWithError','exit','env','CIRCLE_STAGE','completed','length','retryDuring:\x20','printRunGroupError','includes','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','projectName','Duplicate\x20Agent\x20ID\x20Detected','default','./distributed-agent.api','next','configuration','writeFileSync','\x20--parallel\x20--max-parallel=','random','API\x20Response','../../../utilities/metric-logger','taskId','completed:\x20','target','error:\x20','getTime','getRunGroup','npx\x20nx\x20run-many\x20--target=','note','mkdirSync','Other\x20Nx\x20Cloud\x20Agents\x20Detected','cacheDirectory','value','CIRCLECI','strip-json-comments','assign','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','inherit','completedTasks','true','reset','options','find'];(function(_0x45f85f,_0x5e3997){const _0x14a4b0=function(_0x5e20c6){while(--_0x5e20c6){_0x45f85f['push'](_0x45f85f['shift']());}};_0x14a4b0(++_0x5e3997);}(a5_0x5e39,0x18a));const a5_0x14a4=function(_0x45f85f,_0x5e3997){_0x45f85f=_0x45f85f-0x0;let _0x14a4b0=a5_0x5e39[_0x45f85f];return _0x14a4b0;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x5304c0,_0x3a88b0,_0x431342,_0x2f8b43){function _0x14571b(_0x5e3044){return _0x5e3044 instanceof _0x431342?_0x5e3044:new _0x431342(function(_0x333698){_0x333698(_0x5e3044);});}return new(_0x431342||(_0x431342=Promise))(function(_0x4953f2,_0x5a6d33){function _0x2ac5d3(_0x51d230){try{_0x7b80f8(_0x2f8b43['next'](_0x51d230));}catch(_0x24e87c){_0x5a6d33(_0x24e87c);}}function _0x394832(_0x230b56){try{_0x7b80f8(_0x2f8b43[a5_0x14a4('0x57')](_0x230b56));}catch(_0xeac8c3){_0x5a6d33(_0xeac8c3);}}function _0x7b80f8(_0x5b9054){_0x5b9054[a5_0x14a4('0x3b')]?_0x4953f2(_0x5b9054[a5_0x14a4('0x23')]):_0x14571b(_0x5b9054['value'])[a5_0x14a4('0x33')](_0x2ac5d3,_0x394832);}_0x7b80f8((_0x2f8b43=_0x2f8b43['apply'](_0x5304c0,_0x3a88b0||[]))[a5_0x14a4('0x11')]());});};Object['defineProperty'](exports,a5_0x14a4('0x43'),{'value':!![]});exports[a5_0x14a4('0x38')]=void 0x0;const child_process_1=require('child_process');const stripJsonComments=require(a5_0x14a4('0x25'));const distributed_agent_api_1=require(a5_0x14a4('0x10'));const waiter_1=require('../../../utilities/waiter');const environment_1=require(a5_0x14a4('0x54'));const print_run_group_error_1=require(a5_0x14a4('0x4d'));const create_no_new_messages_timeout_1=require(a5_0x14a4('0x3d'));const fs_1=require('fs');const metric_logger_1=require(a5_0x14a4('0x17'));const {output,workspaceRoot}=require(a5_0x14a4('0x4f'));function executeTasks(_0x37db75,_0x54c11e){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x1e07bc=0x0;let _0x153cda=null;const _0x196dba=(0x0,create_no_new_messages_timeout_1[a5_0x14a4('0x32')])();const _0x4535f9=new waiter_1[(a5_0x14a4('0x52'))]();let _0x194cf4=[];const _0x4b885e=new Date();let _0x4a9f62=![];while(!![]){if(environment_1[a5_0x14a4('0x30')]){output['note']({'title':'Fetching\x20tasks...'});}_0x153cda=yield _0x54c11e['tasks'](_0x153cda?_0x153cda[a5_0x14a4('0x45')]:null,_0x1e07bc,_0x194cf4);if(environment_1[a5_0x14a4('0x30')]){output[a5_0x14a4('0x1f')]({'title':a5_0x14a4('0x16'),'bodyLines':[a5_0x14a4('0x19')+_0x153cda[a5_0x14a4('0x7')],a5_0x14a4('0x9')+_0x153cda[a5_0x14a4('0x39')],'executionId:\x20'+_0x153cda[a5_0x14a4('0x45')],a5_0x14a4('0x49')+_0x153cda[a5_0x14a4('0x40')][a5_0x14a4('0x8')],a5_0x14a4('0x1b')+_0x153cda[a5_0x14a4('0x3f')],'maxParallel:\x20'+_0x153cda[a5_0x14a4('0x56')]]});}if(_0x153cda[a5_0x14a4('0x3f')]){output[a5_0x14a4('0x47')]({'title':'Distributed\x20Execution\x20Terminated','bodyLines':['Error:',_0x153cda[a5_0x14a4('0x3f')]]});process[a5_0x14a4('0x4')](0x0);}if((_0x153cda===null||_0x153cda===void 0x0?void 0x0:_0x153cda['retryDuring'])&&(_0x153cda===null||_0x153cda===void 0x0?void 0x0:_0x153cda[a5_0x14a4('0x39')])!==0x0&&!_0x4a9f62&&new Date()[a5_0x14a4('0x1c')]()-_0x4b885e[a5_0x14a4('0x1c')]()>_0x153cda['retryDuring']){yield _0x4535f9[a5_0x14a4('0x4e')]();continue;}if(_0x153cda['completed'])return;_0x196dba(_0x153cda[a5_0x14a4('0x40')]['map'](_0x3667be=>_0x3667be[a5_0x14a4('0x18')])['join'](''));if(!_0x153cda['executionId']){if(environment_1[a5_0x14a4('0x30')]){output[a5_0x14a4('0x1f')]({'title':a5_0x14a4('0x48')});}yield _0x4535f9['wait']();_0x1e07bc=0x0;_0x194cf4=[];continue;}_0x4535f9[a5_0x14a4('0x2b')]();_0x4a9f62=!![];const _0x1812eb=invokeTasksUsingRunMany(_0x37db75,_0x153cda[a5_0x14a4('0x45')],_0x153cda[a5_0x14a4('0x40')],_0x153cda[a5_0x14a4('0x56')]);_0x1e07bc=_0x1812eb['completedStatusCode'];_0x194cf4=_0x1812eb[a5_0x14a4('0x29')];}});}function readCompletedTasks(_0x4923b7,_0x2f7f14){const _0x15716d=a5_0x14a4('0xc')+_0x2f7f14+').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.';let _0x1820c4;try{const _0x14f6cd=_0x4923b7[a5_0x14a4('0x22')]||a5_0x14a4('0x36');const _0x421156=_0x14f6cd+'/tasks-hashes-'+_0x2f7f14;_0x1820c4=JSON['parse']((0x0,fs_1['readFileSync'])(_0x421156)[a5_0x14a4('0x1')]());(0x0,fs_1['unlinkSync'])(_0x421156);}catch(_0x1a39e8){throw new Error(_0x15716d);}if(_0x1820c4[a5_0x14a4('0x8')]==0x0){throw new Error(_0x15716d);}return _0x1820c4;}function invokeTasksUsingRunMany(_0x598e2e,_0x112559,_0x224607,_0x230b05){let _0x4ae99a=0x0;const _0xb10a8f=[];for(const _0x5c68a2 of groupByTarget(_0x224607)){const _0x304e0b=_0x5c68a2[a5_0x14a4('0x12')]?a5_0x14a4('0x46')+_0x5c68a2[a5_0x14a4('0x12')]:'';const _0x5a7b5d=_0x230b05>0x1?a5_0x14a4('0x14')+_0x230b05:'';const _0x39d3d=a5_0x14a4('0x1e')+_0x5c68a2['target']+'\x20'+_0x304e0b+'\x20--projects='+_0x5c68a2[a5_0x14a4('0x0')][a5_0x14a4('0x44')](',')+'\x20'+_0x5c68a2['params']+_0x5a7b5d;if(environment_1[a5_0x14a4('0x30')]){output[a5_0x14a4('0x1f')]({'title':'Executing:\x20\x27'+_0x39d3d+'\x27'});}try{(0x0,child_process_1['execSync'])(_0x39d3d,{'stdio':[a5_0x14a4('0x28'),a5_0x14a4('0x28'),a5_0x14a4('0x28')],'env':Object['assign'](Object[a5_0x14a4('0x26')]({},process['env']),{'NX_CACHE_FAILURES':a5_0x14a4('0x2a'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x112559})});}catch(_0x550d3e){if(_0x550d3e['status']===environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']){throw _0x550d3e;}else{_0x4ae99a=0x1;}}finally{_0xb10a8f[a5_0x14a4('0x2e')](...readCompletedTasks(_0x598e2e,_0x112559));}}return{'completedStatusCode':_0x4ae99a,'completedTasks':_0xb10a8f};}function groupByTarget(_0x136180){const _0x411bfc=[];_0x136180['forEach'](_0x2bf66d=>{const _0x2b5f3e=_0x411bfc[a5_0x14a4('0x2d')](_0x4c4c96=>_0x4c4c96[a5_0x14a4('0x1a')]===_0x2bf66d['target']&&_0x4c4c96[a5_0x14a4('0x12')]===_0x2bf66d[a5_0x14a4('0x12')]);if(_0x2b5f3e){_0x2b5f3e[a5_0x14a4('0x0')][a5_0x14a4('0x2e')](_0x2bf66d[a5_0x14a4('0xd')]);}else{_0x411bfc['push']({'target':_0x2bf66d[a5_0x14a4('0x1a')],'projects':[_0x2bf66d[a5_0x14a4('0xd')]],'params':_0x2bf66d['params'],'configuration':_0x2bf66d[a5_0x14a4('0x12')]});}});return _0x411bfc;}function getAgentName(){if(process[a5_0x14a4('0x5')][a5_0x14a4('0x34')]!==undefined){return process[a5_0x14a4('0x5')][a5_0x14a4('0x34')];}else if(process['env'][a5_0x14a4('0x24')]!==undefined){return process['env'][a5_0x14a4('0x6')];}else{return a5_0x14a4('0x2')+Math['floor'](Math[a5_0x14a4('0x15')]()*0x186a0);}}function createAgentLockfile(_0x5e7d3a,_0x3d87c){const _0x56b656=_0x5e7d3a[a5_0x14a4('0x22')]||a5_0x14a4('0x36');const _0x325c18=_0x56b656+'/lockfiles';const _0x10ec2d=_0x325c18+'/'+_0x3d87c+a5_0x14a4('0x35');if(!(0x0,fs_1[a5_0x14a4('0x53')])(_0x325c18)){(0x0,fs_1[a5_0x14a4('0x20')])(_0x325c18,{'recursive':!![]});}const _0x3dff9a=(0x0,fs_1['readdirSync'])(_0x325c18);if(_0x3dff9a[a5_0x14a4('0x8')]){if(_0x3dff9a[a5_0x14a4('0xb')](_0x3d87c+a5_0x14a4('0x35'))){output[a5_0x14a4('0x47')]({'title':a5_0x14a4('0xe'),'bodyLines':[a5_0x14a4('0x27'),'',a5_0x14a4('0x51')]});process['exit'](0x1);}output[a5_0x14a4('0x42')]({'title':a5_0x14a4('0x21'),'bodyLines':[a5_0x14a4('0x2f'),'',a5_0x14a4('0x37'),a5_0x14a4('0x4b')]});}(0x0,fs_1[a5_0x14a4('0x13')])(_0x10ec2d,'');process['on'](a5_0x14a4('0x4'),_0x49d307=>cleanupAgentLockfile(_0x10ec2d,_0x49d307));process['on'](a5_0x14a4('0x3a'),()=>cleanupAgentLockfile(_0x10ec2d,0x0));}function cleanupAgentLockfile(_0x4c4018,_0x2da441){if((0x0,fs_1[a5_0x14a4('0x53')])(_0x4c4018)){(0x0,fs_1['unlinkSync'])(_0x4c4018);process['exit'](_0x2da441);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x559b90=(0x0,environment_1[a5_0x14a4('0x1d')])();if(!_0x559b90){(0x0,print_run_group_error_1[a5_0x14a4('0xa')])();return process[a5_0x14a4('0x4')](0x1);}output[a5_0x14a4('0x1f')]({'title':a5_0x14a4('0x4a')});const _0x2c11b3=JSON[a5_0x14a4('0x3c')](stripJsonComments((0x0,fs_1[a5_0x14a4('0x3e')])(workspaceRoot+a5_0x14a4('0x55'))[a5_0x14a4('0x1')]()))[a5_0x14a4('0x4c')][a5_0x14a4('0xf')][a5_0x14a4('0x2c')];const _0x13ec20=getAgentName();createAgentLockfile(_0x2c11b3,_0x13ec20);const _0x59ec89=new distributed_agent_api_1[(a5_0x14a4('0x31'))](_0x2c11b3,_0x559b90,_0x13ec20);return executeTasks(_0x2c11b3,_0x59ec89)[a5_0x14a4('0x33')](_0x224b8d=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1['submitRunMetrics'])(_0x2c11b3);return _0x224b8d;}))[a5_0x14a4('0x41')](_0x7d9d0d=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x59ec89[a5_0x14a4('0x3')](a5_0x14a4('0x50')+_0x7d9d0d['message']+'\x22');throw _0x7d9d0d;}));});}exports[a5_0x14a4('0x38')]=startAgent; | ||
"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 |
@@ -1,1 +0,131 @@ | ||
const a6_0x367f=['done','parseCommand','__esModule','axiosException','/nx-cloud/executions/status','defineProperty','completeRunGroup','dteStatus','__awaiter','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','error','mapRespToPerfEntry','post','agentCount','enabled','recordMetric','response','apply','RUNNER_FAILURE_PERF_ENTRY','configuration','map','DistributedExecutionApi','../../../utilities/metric-logger','data','../../../utilities/axios','maxParallel','createMetricRecorder','message','/nx-cloud/executions/complete-run-group','completeRunGroupWithError','axiosMultipleTries','serializeOverrides','../../../utilities/serializer-overrides','parallel','target','next','createStartRequest','false','/nx-cloud/executions/start','project','apiAxiosInstance','then','dteStart','hash'];(function(_0x1ef86e,_0x367f7b){const _0x1e3cf3=function(_0x277aef){while(--_0x277aef){_0x1ef86e['push'](_0x1ef86e['shift']());}};_0x1e3cf3(++_0x367f7b);}(a6_0x367f,0xe6));const a6_0x1e3c=function(_0x1ef86e,_0x367f7b){_0x1ef86e=_0x1ef86e-0x0;let _0x1e3cf3=a6_0x367f[_0x1ef86e];return _0x1e3cf3;};'use strict';var __awaiter=this&&this[a6_0x1e3c('0x2a')]||function(_0x3beeaa,_0x53ecc5,_0x5593e5,_0xd4dd53){function _0x8c15fa(_0x17d969){return _0x17d969 instanceof _0x5593e5?_0x17d969:new _0x5593e5(function(_0x29cd22){_0x29cd22(_0x17d969);});}return new(_0x5593e5||(_0x5593e5=Promise))(function(_0xaa7910,_0x95e3c){function _0x25c7f3(_0xa0a714){try{_0x48314a(_0xd4dd53[a6_0x1e3c('0x19')](_0xa0a714));}catch(_0x4fbb4f){_0x95e3c(_0x4fbb4f);}}function _0x407087(_0xfd8cd2){try{_0x48314a(_0xd4dd53['throw'](_0xfd8cd2));}catch(_0x32ba57){_0x95e3c(_0x32ba57);}}function _0x48314a(_0x472208){_0x472208[a6_0x1e3c('0x22')]?_0xaa7910(_0x472208['value']):_0x8c15fa(_0x472208['value'])[a6_0x1e3c('0x1f')](_0x25c7f3,_0x407087);}_0x48314a((_0xd4dd53=_0xd4dd53[a6_0x1e3c('0x7')](_0x3beeaa,_0x53ecc5||[]))[a6_0x1e3c('0x19')]());});};Object[a6_0x1e3c('0x27')](exports,a6_0x1e3c('0x24'),{'value':!![]});exports[a6_0x1e3c('0x1a')]=exports[a6_0x1e3c('0xb')]=void 0x0;const axios_1=require(a6_0x1e3c('0xe'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a6_0x1e3c('0xc'));const serializer_overrides_1=require(a6_0x1e3c('0x16'));const {output,unparse}=require('../../../utilities/nx-imports');class DistributedExecutionApi{constructor(_0x2ea14e){this[a6_0x1e3c('0x1e')]=(0x0,axios_1['createApiAxiosInstance'])(_0x2ea14e);}['start'](_0x183129){var _0x57869e;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x52d064=(0x0,metric_logger_1['createMetricRecorder'])(a6_0x1e3c('0x20'));let _0x46a7d2;try{_0x46a7d2=yield(0x0,axios_1['axiosMultipleTries'])(()=>this['apiAxiosInstance'][a6_0x1e3c('0x2')](a6_0x1e3c('0x1c'),_0x183129));_0x52d064[a6_0x1e3c('0x5')]((0x0,metric_logger_1[a6_0x1e3c('0x1')])(_0x46a7d2));}catch(_0x25da13){_0x52d064['recordMetric'](((_0x57869e=_0x25da13===null||_0x25da13===void 0x0?void 0x0:_0x25da13[a6_0x1e3c('0x25')])===null||_0x57869e===void 0x0?void 0x0:_0x57869e['response'])?(0x0,metric_logger_1[a6_0x1e3c('0x1')])(_0x25da13[a6_0x1e3c('0x25')][a6_0x1e3c('0x6')]):metric_logger_1[a6_0x1e3c('0x8')]);throw _0x25da13;}if(!_0x46a7d2['data'][a6_0x1e3c('0x4')]){throw new Error('Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.');}if(_0x46a7d2[a6_0x1e3c('0xd')]['error']){throw new Error(_0x46a7d2[a6_0x1e3c('0xd')][a6_0x1e3c('0x0')]);}return _0x46a7d2[a6_0x1e3c('0xd')]['id'];});}['status'](_0x59556f){var _0x44eaf3;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x190dbd=(0x0,metric_logger_1[a6_0x1e3c('0x10')])(a6_0x1e3c('0x29'));try{const _0xb85f28=yield(0x0,axios_1[a6_0x1e3c('0x14')])(()=>this[a6_0x1e3c('0x1e')][a6_0x1e3c('0x2')](a6_0x1e3c('0x26'),{'id':_0x59556f}));_0x190dbd[a6_0x1e3c('0x5')]((0x0,metric_logger_1[a6_0x1e3c('0x1')])(_0xb85f28));return _0xb85f28[a6_0x1e3c('0xd')];}catch(_0x38fa56){_0x190dbd[a6_0x1e3c('0x5')](((_0x44eaf3=_0x38fa56===null||_0x38fa56===void 0x0?void 0x0:_0x38fa56[a6_0x1e3c('0x25')])===null||_0x44eaf3===void 0x0?void 0x0:_0x44eaf3[a6_0x1e3c('0x6')])?(0x0,metric_logger_1[a6_0x1e3c('0x1')])(_0x38fa56[a6_0x1e3c('0x25')]['response']):metric_logger_1[a6_0x1e3c('0x8')]);output[a6_0x1e3c('0x0')]({'title':_0x38fa56[a6_0x1e3c('0x11')]});process['exit'](0x1);}});}[a6_0x1e3c('0x13')](_0x2e76da,_0x49069e){var _0x193bc9;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x37ffd7=(0x0,metric_logger_1[a6_0x1e3c('0x10')])(a6_0x1e3c('0x28'));try{const _0x517e40=yield(0x0,axios_1[a6_0x1e3c('0x14')])(()=>this[a6_0x1e3c('0x1e')]['post'](a6_0x1e3c('0x12'),{'runGroup':_0x2e76da,'criticalErrorMessage':_0x49069e}),0x3);_0x37ffd7['recordMetric']((0x0,metric_logger_1[a6_0x1e3c('0x1')])(_0x517e40));}catch(_0x568df9){_0x37ffd7[a6_0x1e3c('0x5')](((_0x193bc9=_0x568df9===null||_0x568df9===void 0x0?void 0x0:_0x568df9['axiosException'])===null||_0x193bc9===void 0x0?void 0x0:_0x193bc9['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x568df9[a6_0x1e3c('0x25')]['response']):metric_logger_1[a6_0x1e3c('0x8')]);}});}}exports[a6_0x1e3c('0xb')]=DistributedExecutionApi;function createStartRequest(_0x8c369d,_0x1f4646,_0x139352){const _0x350dec=_0x1f4646[a6_0x1e3c('0xa')](_0x496aa2=>{return _0x496aa2[a6_0x1e3c('0xa')](_0x1c3bad=>{return{'taskId':_0x1c3bad['id'],'hash':_0x1c3bad[a6_0x1e3c('0x21')],'projectName':_0x1c3bad[a6_0x1e3c('0x18')][a6_0x1e3c('0x1d')],'target':_0x1c3bad[a6_0x1e3c('0x18')][a6_0x1e3c('0x18')],'configuration':_0x1c3bad[a6_0x1e3c('0x18')][a6_0x1e3c('0x9')]||null,'params':(0x0,serializer_overrides_1[a6_0x1e3c('0x15')])(_0x1c3bad)};});});const _0x2a929d={'command':(0x0,environment_1[a6_0x1e3c('0x23')])(),'branch':(0x0,environment_1['getBranch'])(),'runGroup':_0x8c369d,'tasks':_0x350dec,'maxParallel':calculateMaxParallel(_0x139352)};if(environment_1[a6_0x1e3c('0x2b')]){_0x2a929d[a6_0x1e3c('0x3')]=environment_1[a6_0x1e3c('0x2b')];}if(!environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE']){_0x2a929d['stopAgentsOnFailure']=![];}return _0x2a929d;}exports[a6_0x1e3c('0x1a')]=createStartRequest;function calculateMaxParallel(_0x3aca89){if(_0x3aca89['parallel']===a6_0x1e3c('0x1b')||_0x3aca89['parallel']===![]){return 0x1;}else if(_0x3aca89['parallel']==='true'||_0x3aca89[a6_0x1e3c('0x17')]===!![]){return Number(_0x3aca89[a6_0x1e3c('0xf')]||0x3);}else if(_0x3aca89[a6_0x1e3c('0x17')]===undefined){return _0x3aca89['maxParallel']?Number(_0x3aca89[a6_0x1e3c('0xf')]):0x3;}else{return Number(_0x3aca89['parallel'])||0x3;}} | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createStartRequest = exports.DistributedExecutionApi = void 0; | ||
const axios_1 = require("../../../utilities/axios"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const metric_logger_1 = require("../../../utilities/metric-logger"); | ||
const serializer_overrides_1 = require("../../../utilities/serializer-overrides"); | ||
const { output, 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: (0, serializer_overrides_1.serializeOverrides)(t), | ||
}; | ||
}); | ||
}); | ||
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 |
@@ -1,1 +0,309 @@ | ||
const a7_0x22f3=['submitRunMetrics','Retrieving\x20artifacts\x20from\x20','add','projectGraph','addVerticalSeparator','run','self','createStartRequest','getRunGroup','createTaskGraph','exit','scheduleTask','size','addTaskDependencies','findTask','../../../utilities/waiter','then','ENCRYPTION_KEY','retrieve','delete','completedTasks','filter','axiosException','endTask','Waiting...','terminalOutput','project','COMPLETED','DistributedExecutionApi','defineProperty','hash','./node_modules/.cache/nx','get','length','done','VERBOSE_LOGGING','find','indexOf','Error:','start','push','executionStatus:\x20','build','apply','serializeOverrides','completeRunGroupWithError','assign','defaultTargetDependencies','Extracting\x20artifacts','Unable\x20to\x20complete\x20a\x20run.','throw','Waiter','roots','Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','runUrl','criticalErrorMessage','number\x20of\x20completed\x20tasks:\x20','commandStatus','note','Successfully\x20completed\x20running\x20the\x20command.','message','__esModule','../../../utilities/environment','dependencies','../../error/print-run-group-error','TaskGraphCreator','executionId:\x20','nxCloudDistributedTasksRunner','success','taskId','../../api/error-reporter.api','addTaskToGraph','projects','ErrorReporterApi','nodes','addDependencies','Command\x20execution\x20failed.','value','logCommand','splitTasksIntoStages','../../file-storage/file-storage','has','../../../utilities/serializer-overrides','E2EEncryption','executionStatus','../../../utilities/create-no-new-messages-timeout','url','error','tasks','map','createNoNewMessagesTimeout','reset','../../../utilities/metric-logger','cacheDirectory','Status\x20update','log','toString','stdout','See\x20run\x20details\x20at\x20','target','__awaiter','parse'];(function(_0x58bfa2,_0x22f3d0){const _0x5d03ae=function(_0x3a1d02){while(--_0x3a1d02){_0x58bfa2['push'](_0x58bfa2['shift']());}};_0x5d03ae(++_0x22f3d0);}(a7_0x22f3,0x1d9));const a7_0x5d03=function(_0x58bfa2,_0x22f3d0){_0x58bfa2=_0x58bfa2-0x0;let _0x5d03ae=a7_0x22f3[_0x58bfa2];return _0x5d03ae;};'use strict';var __awaiter=this&&this[a7_0x5d03('0x23')]||function(_0x13f07c,_0x3aa58f,_0x14c70b,_0xe91c7b){function _0x811d69(_0xef6a48){return _0xef6a48 instanceof _0x14c70b?_0xef6a48:new _0x14c70b(function(_0x4efef5){_0x4efef5(_0xef6a48);});}return new(_0x14c70b||(_0x14c70b=Promise))(function(_0x260e61,_0x279032){function _0x53cc5c(_0x57c98b){try{_0x4ac07c(_0xe91c7b['next'](_0x57c98b));}catch(_0x27d304){_0x279032(_0x27d304);}}function _0x55e81c(_0x23defa){try{_0x4ac07c(_0xe91c7b[a7_0x5d03('0x57')](_0x23defa));}catch(_0x4f209d){_0x279032(_0x4f209d);}}function _0x4ac07c(_0x1b79e4){_0x1b79e4[a7_0x5d03('0x47')]?_0x260e61(_0x1b79e4[a7_0x5d03('0xc')]):_0x811d69(_0x1b79e4[a7_0x5d03('0xc')])[a7_0x5d03('0x35')](_0x53cc5c,_0x55e81c);}_0x4ac07c((_0xe91c7b=_0xe91c7b[a7_0x5d03('0x50')](_0x13f07c,_0x3aa58f||[]))['next']());});};Object[a7_0x5d03('0x42')](exports,a7_0x5d03('0x62'),{'value':!![]});exports[a7_0x5d03('0x0')]=exports[a7_0x5d03('0x2')]=void 0x0;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(a7_0x5d03('0xf'));const e2e_encryption_1=require('../../file-storage/e2e-encryption');const waiter_1=require(a7_0x5d03('0x34'));const environment_1=require(a7_0x5d03('0x63'));const print_run_group_error_1=require(a7_0x5d03('0x65'));const create_no_new_messages_timeout_1=require(a7_0x5d03('0x14'));const metric_logger_1=require(a7_0x5d03('0x1b'));const error_reporter_api_1=require(a7_0x5d03('0x5'));const serializer_overrides_1=require(a7_0x5d03('0x11'));const {output,workspaceRoot,getDependencyConfigs,getOutputs,unparse,Cache}=require('../../../utilities/nx-imports');class NoopLifeCycle{[a7_0x5d03('0x30')](_0x50f951){}['startTask'](_0xa5f40e){}[a7_0x5d03('0x3c')](_0x4ee58c,_0x399552){}}function runDistributedExecution(_0x32aba9,_0x554b1d,_0xdcc883,_0x4e81db,_0x244722,_0x32420d,_0x4f9c6f){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3d4ccb=JSON[a7_0x5d03('0x24')](stripJsonComments((0x0,fs_1['readFileSync'])(workspaceRoot+'/nx.json')[a7_0x5d03('0x1f')]()));const _0x4812b0=new TaskOrderer(_0xdcc883[a7_0x5d03('0x28')],getDefaultDependencyConfigs(_0x3d4ccb,_0x554b1d))[a7_0x5d03('0xe')](_0x4f9c6f);const _0x32a051=yield _0x32aba9[a7_0x5d03('0x4c')]((0x0,distributed_execution_api_1[a7_0x5d03('0x2c')])(_0x32420d,_0x4812b0,_0x554b1d));return yield processTasks(_0x32aba9,_0x4e81db,_0x244722,_0x554b1d,_0x32a051,_0x4f9c6f,_0xdcc883);});}function processTasks(_0x5016e6,_0x18bc22,_0x5947c6,_0x50e57d,_0x14d677,_0x29c531,_0x24ab7a){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5047a9={};const _0x260e5c=(0x0,create_no_new_messages_timeout_1[a7_0x5d03('0x19')])();const _0x4a4489=new waiter_1[(a7_0x5d03('0x58'))]();while(!![]){if(environment_1['VERBOSE_LOGGING']){output[a7_0x5d03('0x5f')]({'title':a7_0x5d03('0x3d')});}yield _0x4a4489['wait']();const _0x3742b9=yield _0x5016e6['status'](_0x14d677);if(environment_1[a7_0x5d03('0x48')]){output[a7_0x5d03('0x5f')]({'title':a7_0x5d03('0x1d'),'bodyLines':[a7_0x5d03('0x1')+_0x14d677,a7_0x5d03('0x4e')+_0x3742b9['executionStatus'],a7_0x5d03('0x5d')+_0x3742b9[a7_0x5d03('0x39')][a7_0x5d03('0x46')],'error:\x20'+_0x3742b9[a7_0x5d03('0x5c')]]});}if(_0x3742b9[a7_0x5d03('0x5c')]){output['error']({'title':'Distributed\x20Execution\x20Terminated','bodyLines':[a7_0x5d03('0x4b'),_0x3742b9[a7_0x5d03('0x5c')]]});process['exit'](0x1);}_0x260e5c(_0x3742b9[a7_0x5d03('0x39')][a7_0x5d03('0x46')]);for(const _0x2102dd of _0x3742b9[a7_0x5d03('0x39')]){if(_0x5047a9[_0x2102dd[a7_0x5d03('0x4')]])continue;yield processTask(_0x18bc22,_0x5947c6,_0x24ab7a,_0x50e57d,_0x29c531,_0x2102dd);_0x4a4489[a7_0x5d03('0x1a')]();_0x5047a9[_0x2102dd[a7_0x5d03('0x4')]]=!![];}if(_0x3742b9[a7_0x5d03('0x13')]===a7_0x5d03('0x40')){return{'commandStatus':_0x3742b9[a7_0x5d03('0x5e')],'runUrl':_0x3742b9['runUrl']};}}});}function processTask(_0xb1a59,_0x1de5a1,_0x6d8c00,_0xc8cfd,_0x50158c,_0x1b5690){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a7_0x5d03('0x48')]){output['note']({'title':'Processing\x20task\x20'+_0x1b5690[a7_0x5d03('0x4')]});}const _0x9727e7=_0x50158c[a7_0x5d03('0x49')](_0x12ab69=>_0x1b5690[a7_0x5d03('0x4')]===_0x12ab69['id']);if(!_0x9727e7){throw new Error('Found\x20unknown\x20task:\x20'+_0x1b5690['taskId']);}if(environment_1[a7_0x5d03('0x48')]){output[a7_0x5d03('0x5f')]({'title':a7_0x5d03('0x26')+_0x1b5690[a7_0x5d03('0x15')]});}yield _0xb1a59[a7_0x5d03('0x37')](_0x1b5690['hash'],_0x1b5690[a7_0x5d03('0x15')],_0xc8cfd[a7_0x5d03('0x1c')]||a7_0x5d03('0x44'));const _0x26c25c=yield _0x1de5a1[a7_0x5d03('0x45')](Object[a7_0x5d03('0x53')](Object['assign']({},_0x9727e7),{'hash':_0x1b5690[a7_0x5d03('0x43')]}));const _0x389f70=getOutputs(_0x6d8c00[a7_0x5d03('0x28')][a7_0x5d03('0x9')],_0x9727e7);if(environment_1[a7_0x5d03('0x48')]){output[a7_0x5d03('0x5f')]({'title':a7_0x5d03('0x55'),'bodyLines':_0x389f70});}yield _0x1de5a1['copyFilesFromCache'](_0x1b5690[a7_0x5d03('0x43')],_0x26c25c,_0x389f70);output[a7_0x5d03('0xd')](getCommand(_0x9727e7));process[a7_0x5d03('0x20')]['write'](_0x26c25c[a7_0x5d03('0x3e')]);output[a7_0x5d03('0x29')]();});}function getCommand(_0x1f8b97){const _0x3d0641=_0x1f8b97['target']['configuration']?':'+_0x1f8b97[a7_0x5d03('0x22')]['configuration']:'';return['nx',a7_0x5d03('0x2a'),_0x1f8b97['target'][a7_0x5d03('0x3f')]+':'+_0x1f8b97[a7_0x5d03('0x22')][a7_0x5d03('0x22')]+_0x3d0641,(0x0,serializer_overrides_1[a7_0x5d03('0x51')])(_0x1f8b97)]['join']('\x20');}const nxCloudDistributedTasksRunner=(_0x465ff5,_0x4a3c47,_0x52aa7a)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(environment_1[a7_0x5d03('0x48')]){output['note']({'title':'Starting\x20distributed\x20command\x20execution'});}_0x4a3c47['lifeCycle']=new NoopLifeCycle();const _0x3814ac=(0x0,environment_1[a7_0x5d03('0x2d')])();if(!_0x3814ac){(0x0,print_run_group_error_1['printRunGroupError'])();return process[a7_0x5d03('0x2f')](0x1);}const _0x1c2343=new e2e_encryption_1[(a7_0x5d03('0x12'))](environment_1[a7_0x5d03('0x36')]||_0x4a3c47['encryptionKey']);const _0x18f975=new error_reporter_api_1[(a7_0x5d03('0x8'))](_0x4a3c47);const _0x39bf25=new file_storage_1['FileStorage'](_0x1c2343,_0x18f975,!![]);const _0x20b5dc=new Cache(_0x4a3c47);const _0x274ea0=new distributed_execution_api_1[(a7_0x5d03('0x41'))](_0x4a3c47);try{const _0x421743=yield runDistributedExecution(_0x274ea0,_0x4a3c47,_0x52aa7a,_0x39bf25,_0x20b5dc,_0x3814ac,_0x465ff5);if(_0x421743[a7_0x5d03('0x5e')]===0x0){output[a7_0x5d03('0x3')]({'title':a7_0x5d03('0x60'),'bodyLines':[a7_0x5d03('0x21')+_0x421743[a7_0x5d03('0x5b')]]});}else{output[a7_0x5d03('0x16')]({'title':a7_0x5d03('0xb'),'bodyLines':[a7_0x5d03('0x21')+_0x421743['runUrl']]});}yield(0x0,metric_logger_1[a7_0x5d03('0x25')])(_0x4a3c47);process[a7_0x5d03('0x2f')](_0x421743[a7_0x5d03('0x5e')]);}catch(_0x25c923){output[a7_0x5d03('0x16')]({'title':a7_0x5d03('0x56'),'bodyLines':[_0x25c923[a7_0x5d03('0x61')]]});if(_0x25c923[a7_0x5d03('0x3b')]){console[a7_0x5d03('0x1e')](_0x25c923['axiosException']);}else{console['log'](_0x25c923);}try{yield _0x274ea0[a7_0x5d03('0x52')](_0x3814ac,a7_0x5d03('0x5a')+_0x25c923[a7_0x5d03('0x61')]+'\x22');}finally{process[a7_0x5d03('0x2f')](0x1);}}});exports[a7_0x5d03('0x2')]=nxCloudDistributedTasksRunner;class TaskOrderer{constructor(_0x241670,_0x1c69db){this[a7_0x5d03('0x28')]=_0x241670;this[a7_0x5d03('0x54')]=_0x1c69db;}[a7_0x5d03('0xe')](_0x17c723){if(_0x17c723[a7_0x5d03('0x46')]===0x0)return[];const _0x27ef39=[];const _0x38d9df=this['createTaskGraph'](_0x17c723);const _0x26bb72=new Set(_0x17c723[a7_0x5d03('0x18')](_0x68cfd4=>_0x68cfd4['id']));let _0x3f279=0x0;while(_0x26bb72[a7_0x5d03('0x31')]>0x0){const _0x5a7054=_0x27ef39[_0x3f279]=[];for(const _0x1771bc of _0x26bb72){let _0x288134=!![];for(const _0x2641ad of _0x38d9df[a7_0x5d03('0x64')][_0x1771bc]){if(_0x26bb72[a7_0x5d03('0x10')](_0x2641ad)){_0x288134=![];break;}}if(!_0x288134){continue;}const _0x5ac080=_0x38d9df[a7_0x5d03('0x17')][_0x1771bc];_0x5a7054['push'](_0x5ac080);}for(const _0xf9e6af of _0x5a7054){_0x26bb72[a7_0x5d03('0x38')](_0xf9e6af['id']);}_0x3f279++;}return _0x27ef39;}['createTaskGraph'](_0x5cda43){const _0x43fe2a=new TaskGraphCreator(this[a7_0x5d03('0x28')],this['defaultTargetDependencies']);return _0x43fe2a[a7_0x5d03('0x2e')](_0x5cda43);}}class TaskGraphCreator{constructor(_0x4014ac,_0x5e18a8){this[a7_0x5d03('0x28')]=_0x4014ac;this[a7_0x5d03('0x54')]=_0x5e18a8;}[a7_0x5d03('0x2e')](_0x1eec0d){const _0x4db79a={'roots':[],'tasks':{},'dependencies':{}};for(const _0x220bbf of _0x1eec0d){this[a7_0x5d03('0x6')](_0x220bbf,_0x4db79a);const _0x5cb693=getDependencyConfigs(_0x220bbf[a7_0x5d03('0x22')],this[a7_0x5d03('0x54')],this[a7_0x5d03('0x28')]);if(!_0x5cb693){continue;}this[a7_0x5d03('0x32')](_0x220bbf,_0x5cb693,_0x1eec0d,_0x4db79a);}_0x4db79a[a7_0x5d03('0x59')]=Object['keys'](_0x4db79a[a7_0x5d03('0x64')])[a7_0x5d03('0x3a')](_0x48c682=>_0x4db79a[a7_0x5d03('0x64')][_0x48c682][a7_0x5d03('0x46')]===0x0);return _0x4db79a;}['addTaskDependencies'](_0x2b1ab1,_0x2b2c91,_0x5c2d74,_0xa6e03e){for(const _0x555ed9 of _0x2b2c91){if(_0x555ed9[a7_0x5d03('0x7')]===a7_0x5d03('0x2b')){for(const _0x4d2a7e of _0x5c2d74){if(_0x4d2a7e[a7_0x5d03('0x22')][a7_0x5d03('0x3f')]===_0x2b1ab1[a7_0x5d03('0x22')]['project']&&_0x4d2a7e[a7_0x5d03('0x22')][a7_0x5d03('0x22')]===_0x555ed9[a7_0x5d03('0x22')]){_0xa6e03e['dependencies'][_0x2b1ab1['id']][a7_0x5d03('0x4d')](_0x4d2a7e['id']);}}}else if(_0x555ed9['projects']==='dependencies'){const _0x2273bb=new Set();this[a7_0x5d03('0xa')](_0x2b1ab1[a7_0x5d03('0x22')][a7_0x5d03('0x3f')],_0x555ed9[a7_0x5d03('0x22')],_0x5c2d74,_0xa6e03e,_0x2b1ab1['id'],_0x2273bb);}}}[a7_0x5d03('0xa')](_0x1a47ba,_0x4a3d62,_0x423553,_0x1d584c,_0x38b985,_0x593cc7){_0x593cc7[a7_0x5d03('0x27')](_0x1a47ba);const _0x3787cf=this[a7_0x5d03('0x28')][a7_0x5d03('0x64')][_0x1a47ba];if(_0x3787cf){const _0xcc745d=_0x3787cf[a7_0x5d03('0x18')](_0x25e86d=>_0x25e86d[a7_0x5d03('0x22')]);for(const _0xa04565 of _0xcc745d){if(_0x593cc7[a7_0x5d03('0x10')](_0xa04565)){continue;}const _0x2f2d26=this['findTask']({'project':_0xa04565,'target':_0x4a3d62},_0x423553);if(_0x2f2d26){if(_0x1d584c[a7_0x5d03('0x64')][_0x38b985][a7_0x5d03('0x4a')](_0x2f2d26['id'])===-0x1){_0x1d584c['dependencies'][_0x38b985]['push'](_0x2f2d26['id']);}}else{this['addDependencies'](_0xa04565,_0x4a3d62,_0x423553,_0x1d584c,_0x38b985,_0x593cc7);}}}}[a7_0x5d03('0x33')]({project,target},_0x3d6375){return _0x3d6375[a7_0x5d03('0x49')](_0x4dd596=>_0x4dd596['target'][a7_0x5d03('0x3f')]===project&&_0x4dd596['target'][a7_0x5d03('0x22')]===target);}[a7_0x5d03('0x6')](_0x3da078,_0x3b2d5c){_0x3b2d5c[a7_0x5d03('0x17')][_0x3da078['id']]=_0x3da078;_0x3b2d5c[a7_0x5d03('0x64')][_0x3da078['id']]=[];}}exports[a7_0x5d03('0x0')]=TaskGraphCreator;function getDefaultDependencyConfigs(_0x2e50fb,_0x262ea3){var _0xdad9df,_0x2ce6be;const _0x2f79f4=(_0xdad9df=_0x2e50fb['targetDependencies'])!==null&&_0xdad9df!==void 0x0?_0xdad9df:{};const _0x3b08ef=_0x262ea3?(_0x2ce6be=_0x262ea3['strictlyOrderedTargets'])!==null&&_0x2ce6be!==void 0x0?_0x2ce6be:[a7_0x5d03('0x4f')]:[];for(const _0x29a731 of _0x3b08ef){_0x2f79f4[_0x29a731]=_0x2f79f4[_0x29a731]||[];_0x2f79f4[_0x29a731]['push']({'target':_0x29a731,'projects':a7_0x5d03('0x64')});}return _0x2f79f4;} | ||
"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 serializer_overrides_1 = require("../../../utilities/serializer-overrides"); | ||
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 config = task.target.configuration | ||
? `:${task.target.configuration}` | ||
: ''; | ||
return [ | ||
'nx', | ||
'run', | ||
`${task.target.project}:${task.target.target}${config}`, | ||
(0, serializer_overrides_1.serializeOverrides)(task), | ||
].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 |
{ | ||
"name": "nx-cloud", | ||
"version": "14.1.1", | ||
"version": "14.1.2-beta.1", | ||
"description": "Nx Cloud plugin for Nx", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Obfuscated code
Supply chain riskObfuscated files are intentionally packed to hide their behavior. This could be a sign of malware.
Found 4 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
3420
2
0
91
259978