Comparing version 16.0.0-beta.8 to 16.0.0
@@ -1,36 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ErrorReporterApi = void 0; | ||
const axios_1 = require("../../utilities/axios"); | ||
const { output } = require('../../utilities/nx-imports'); | ||
class ErrorReporterApi { | ||
constructor(options) { | ||
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options); | ||
} | ||
reportError(message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', { | ||
message, | ||
})); | ||
} | ||
catch (e) { | ||
output.warn({ | ||
title: `Unable to record the following error: '${message}'`, | ||
bodyLines: [e.message], | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
exports.ErrorReporterApi = ErrorReporterApi; | ||
//# sourceMappingURL=error-reporter.api.js.map | ||
const a0_0x29f6=['__awaiter','warn','../../utilities/axios','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','apiAxiosInstance','__esModule','message','reportError','createApiAxiosInstance','axiosMultipleTries','value','../../utilities/nx-imports','next','apply','post','then','ErrorReporterApi'];(function(_0x707595,_0x29f6d1){const _0x5aab6d=function(_0x184ad1){while(--_0x184ad1){_0x707595['push'](_0x707595['shift']());}};_0x5aab6d(++_0x29f6d1);}(a0_0x29f6,0x81));const a0_0x5aab=function(_0x707595,_0x29f6d1){_0x707595=_0x707595-0x0;let _0x5aab6d=a0_0x29f6[_0x707595];return _0x5aab6d;};'use strict';var __awaiter=this&&this[a0_0x5aab('0x7')]||function(_0x23a38f,_0x10de93,_0x45dec5,_0x3de214){function _0x5c2732(_0x4497cd){return _0x4497cd instanceof _0x45dec5?_0x4497cd:new _0x45dec5(function(_0x95532d){_0x95532d(_0x4497cd);});}return new(_0x45dec5||(_0x45dec5=Promise))(function(_0x4ca6a3,_0xc7debf){function _0x3a596b(_0x4c3bfa){try{_0x137c42(_0x3de214[a0_0x5aab('0x2')](_0x4c3bfa));}catch(_0x2ae7c9){_0xc7debf(_0x2ae7c9);}}function _0x45ec46(_0x13fc92){try{_0x137c42(_0x3de214['throw'](_0x13fc92));}catch(_0x325c45){_0xc7debf(_0x325c45);}}function _0x137c42(_0x37552f){_0x37552f['done']?_0x4ca6a3(_0x37552f[a0_0x5aab('0x0')]):_0x5c2732(_0x37552f[a0_0x5aab('0x0')])[a0_0x5aab('0x5')](_0x3a596b,_0x45ec46);}_0x137c42((_0x3de214=_0x3de214[a0_0x5aab('0x3')](_0x23a38f,_0x10de93||[]))['next']());});};Object['defineProperty'](exports,a0_0x5aab('0xc'),{'value':!![]});exports[a0_0x5aab('0x6')]=void 0x0;const axios_1=require(a0_0x5aab('0x9'));const {output}=require(a0_0x5aab('0x1'));class ErrorReporterApi{constructor(_0x4ef935){this['apiAxiosInstance']=(0x0,axios_1[a0_0x5aab('0xf')])(_0x4ef935);}[a0_0x5aab('0xe')](_0x3a2c0a){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x5aab('0x10')])(()=>this[a0_0x5aab('0xb')][a0_0x5aab('0x4')]('/nx-cloud/report-client-error',{'message':_0x3a2c0a}));}catch(_0x2fac11){output[a0_0x5aab('0x8')]({'title':a0_0x5aab('0xa')+_0x3a2c0a+'\x27','bodyLines':[_0x2fac11[a0_0x5aab('0xd')]]});}});}}exports['ErrorReporterApi']=ErrorReporterApi; |
@@ -1,73 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RunGroupApi = void 0; | ||
const axios_1 = require("../../utilities/axios"); | ||
const metric_logger_1 = require("../../utilities/metric-logger"); | ||
const { output } = require('../../utilities/nx-imports'); | ||
class RunGroupApi { | ||
constructor(options) { | ||
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options); | ||
} | ||
createRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv, stopAgentsOnFailure, agentCount, stopAgentsAfter) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup'); | ||
try { | ||
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', { | ||
branch, | ||
runGroup, | ||
ciExecutionId, | ||
ciExecutionEnv, | ||
stopAgentsOnFailure, | ||
agentCount, | ||
stopAgentsAfter, | ||
})); | ||
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp)); | ||
} | ||
catch (e) { | ||
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response) | ||
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response) | ||
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY); | ||
output.error({ | ||
title: e.message, | ||
}); | ||
process.exit(1); | ||
} | ||
}); | ||
} | ||
completeRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup'); | ||
try { | ||
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', { | ||
branch, | ||
runGroup, | ||
ciExecutionId, | ||
ciExecutionEnv, | ||
})); | ||
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp)); | ||
} | ||
catch (e) { | ||
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response) | ||
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response) | ||
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY); | ||
output.error({ | ||
title: e.message, | ||
}); | ||
process.exit(1); | ||
} | ||
}); | ||
} | ||
} | ||
exports.RunGroupApi = RunGroupApi; | ||
//# sourceMappingURL=run-group.api.js.map | ||
const a1_0x32b6=['next','value','completeRunGroup','post','apply','/nx-cloud/executions/create-run-group','mapRespToPerfEntry','message','../../utilities/nx-imports','apiAxiosInstance','__esModule','axiosException','createApiAxiosInstance','axiosMultipleTries','then','__awaiter','throw','response','defineProperty','RunGroupApi','RUNNER_FAILURE_PERF_ENTRY','/nx-cloud/executions/complete-run-group','error','exit','recordMetric'];(function(_0x185a82,_0x32b67d){const _0xcff0de=function(_0x9a6edd){while(--_0x9a6edd){_0x185a82['push'](_0x185a82['shift']());}};_0xcff0de(++_0x32b67d);}(a1_0x32b6,0xca));const a1_0xcff0=function(_0x185a82,_0x32b67d){_0x185a82=_0x185a82-0x0;let _0xcff0de=a1_0x32b6[_0x185a82];return _0xcff0de;};'use strict';var __awaiter=this&&this[a1_0xcff0('0xd')]||function(_0x41fb53,_0x2abd3f,_0xf221e3,_0x5495c1){function _0x17718f(_0x4a0896){return _0x4a0896 instanceof _0xf221e3?_0x4a0896:new _0xf221e3(function(_0x53e886){_0x53e886(_0x4a0896);});}return new(_0xf221e3||(_0xf221e3=Promise))(function(_0x188507,_0x3c38e1){function _0x5741b7(_0x5ad4d1){try{_0x53b6dd(_0x5495c1[a1_0xcff0('0x17')](_0x5ad4d1));}catch(_0x3a73ac){_0x3c38e1(_0x3a73ac);}}function _0x3137f1(_0x19b23a){try{_0x53b6dd(_0x5495c1[a1_0xcff0('0xe')](_0x19b23a));}catch(_0x1c0b1a){_0x3c38e1(_0x1c0b1a);}}function _0x53b6dd(_0x34dd8b){_0x34dd8b['done']?_0x188507(_0x34dd8b[a1_0xcff0('0x18')]):_0x17718f(_0x34dd8b[a1_0xcff0('0x18')])[a1_0xcff0('0xc')](_0x5741b7,_0x3137f1);}_0x53b6dd((_0x5495c1=_0x5495c1[a1_0xcff0('0x2')](_0x41fb53,_0x2abd3f||[]))[a1_0xcff0('0x17')]());});};Object[a1_0xcff0('0x10')](exports,a1_0xcff0('0x8'),{'value':!![]});exports['RunGroupApi']=void 0x0;const axios_1=require('../../utilities/axios');const metric_logger_1=require('../../utilities/metric-logger');const {output}=require(a1_0xcff0('0x6'));class RunGroupApi{constructor(_0x113756){this[a1_0xcff0('0x7')]=(0x0,axios_1[a1_0xcff0('0xa')])(_0x113756);}['createRunGroup'](_0x50d157,_0x3b5345,_0x4e5857,_0x23d5c0,_0xac4c33,_0x42cc08,_0x25be56){var _0x55c35d;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3869bd=(0x0,metric_logger_1['createMetricRecorder'])('createRunGroup');try{const _0x575235=yield(0x0,axios_1[a1_0xcff0('0xb')])(()=>this['apiAxiosInstance'][a1_0xcff0('0x1')](a1_0xcff0('0x3'),{'branch':_0x50d157,'runGroup':_0x3b5345,'ciExecutionId':_0x4e5857,'ciExecutionEnv':_0x23d5c0,'stopAgentsOnFailure':_0xac4c33,'agentCount':_0x42cc08,'stopAgentsAfter':_0x25be56}));_0x3869bd[a1_0xcff0('0x16')]((0x0,metric_logger_1[a1_0xcff0('0x4')])(_0x575235));}catch(_0x572720){_0x3869bd[a1_0xcff0('0x16')](((_0x55c35d=_0x572720===null||_0x572720===void 0x0?void 0x0:_0x572720['axiosException'])===null||_0x55c35d===void 0x0?void 0x0:_0x55c35d[a1_0xcff0('0xf')])?(0x0,metric_logger_1[a1_0xcff0('0x4')])(_0x572720[a1_0xcff0('0x9')]['response']):metric_logger_1[a1_0xcff0('0x12')]);output[a1_0xcff0('0x14')]({'title':_0x572720[a1_0xcff0('0x5')]});process[a1_0xcff0('0x15')](0x1);}});}[a1_0xcff0('0x0')](_0x2cef40,_0x4b38b5,_0x554c51,_0x4320e0){var _0x445601;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4e2aa2=(0x0,metric_logger_1['createMetricRecorder'])(a1_0xcff0('0x0'));try{const _0x1da499=yield(0x0,axios_1[a1_0xcff0('0xb')])(()=>this[a1_0xcff0('0x7')]['post'](a1_0xcff0('0x13'),{'branch':_0x2cef40,'runGroup':_0x4b38b5,'ciExecutionId':_0x554c51,'ciExecutionEnv':_0x4320e0}));_0x4e2aa2[a1_0xcff0('0x16')]((0x0,metric_logger_1[a1_0xcff0('0x4')])(_0x1da499));}catch(_0x527a1d){_0x4e2aa2['recordMetric'](((_0x445601=_0x527a1d===null||_0x527a1d===void 0x0?void 0x0:_0x527a1d[a1_0xcff0('0x9')])===null||_0x445601===void 0x0?void 0x0:_0x445601[a1_0xcff0('0xf')])?(0x0,metric_logger_1[a1_0xcff0('0x4')])(_0x527a1d['axiosException'][a1_0xcff0('0xf')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output['error']({'title':_0x527a1d[a1_0xcff0('0x5')]});process[a1_0xcff0('0x15')](0x1);}});}}exports[a1_0xcff0('0x11')]=RunGroupApi; |
@@ -23,2 +23,3 @@ "use strict"; | ||
const stripJsonComments = require("strip-json-comments"); | ||
const remove_trailing_slash_1 = require("../../utilities/remove-trailing-slash"); | ||
const { workspaceRoot, output } = require('../../utilities/nx-imports'); | ||
@@ -43,3 +44,3 @@ function uploadRunDetails(options) { | ||
}, linkId); | ||
return `${options.url || 'https://nx.app'}/runs/${linkId}`; | ||
return `${(0, remove_trailing_slash_1.removeTrailingSlash)(options.url || 'https://nx.app')}/runs/${linkId}`; | ||
}); | ||
@@ -46,0 +47,0 @@ } |
@@ -59,3 +59,3 @@ "use strict"; | ||
output.note({ | ||
title: `A 404 error occurred in the DTE context. Hash: ${hash}. Url: ${url}.`, | ||
title: `An error occurred while trying to download artifacts in the DTE context. Hash: ${hash}. Url: ${url}.`, | ||
bodyLines: [ | ||
@@ -62,0 +62,0 @@ `- Please update the nx-cloud package to the latest version.`, |
@@ -1,93 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CloudEnabledLifeCycle = void 0; | ||
const serializer_overrides_1 = require("../../../utilities/serializer-overrides"); | ||
const read_task_terminal_output_1 = require("../../terminal-output/read-task-terminal-output"); | ||
class CloudEnabledLifeCycle { | ||
constructor(runContext, cacheDirectory, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) { | ||
this.runContext = runContext; | ||
this.cacheDirectory = cacheDirectory; | ||
this.collectTerminalOutput = collectTerminalOutput; | ||
this.cacheableOperations = cacheableOperations; | ||
this.outputObfuscator = outputObfuscator; | ||
this.tasks = tasks; | ||
} | ||
scheduleTask(task) { | ||
this.runContext.scheduledTasks.push(task); | ||
} | ||
// this gets called for every tasks that starts. | ||
startTask(task) { | ||
this.tasks.push({ | ||
taskId: task.id, | ||
startTime: new Date().toISOString(), | ||
target: task.target.target, | ||
projectName: task.target.project, | ||
hash: task.hash, | ||
hashDetails: this.cleanUpHashDetails(task.hashDetails), | ||
params: (0, serializer_overrides_1.serializeOverrides)(task), | ||
uploadedToStorage: false, | ||
}); | ||
} | ||
endTasks(tasks) { | ||
// this can be called multiple times changing this time. | ||
for (let t of tasks) { | ||
let cacheStatus; | ||
const taskIsRemoteCacheHit = t.status === 'remote-cache'; | ||
const taskIsLocalCacheHitPreNx135 = t.status === 'cache'; | ||
const taskIsLocalCacheHit = t.status === 'local-cache' || | ||
t.status === 'local-cache-kept-existing' || | ||
taskIsLocalCacheHitPreNx135; | ||
if (this.runContext.statuses[t.task.hash]) { | ||
cacheStatus = this.runContext.statuses[t.task.hash]; | ||
} | ||
else if (taskIsRemoteCacheHit) { | ||
cacheStatus = 'remote-cache-hit'; | ||
} | ||
else if (taskIsLocalCacheHit) { | ||
cacheStatus = 'local-cache-hit'; | ||
} | ||
else { | ||
cacheStatus = 'cache-miss'; | ||
} | ||
this.updateStartedTask(t, cacheStatus); | ||
} | ||
} | ||
endCommand() { } | ||
updateStartedTask(result, cacheStatus) { | ||
const startedTask = this.tasks.find((t) => t.taskId === result.task.id); | ||
if (!startedTask) { | ||
throw new Error(`Cannot find task ${result.task.id}`); | ||
} | ||
if ((result === null || result === void 0 ? void 0 : result.startTime) && (result === null || result === void 0 ? void 0 : result.endTime)) { | ||
startedTask.startTime = new Date(result.startTime).toISOString(); | ||
startedTask.endTime = new Date(result.endTime).toISOString(); | ||
} | ||
else { | ||
startedTask.endTime = new Date().toISOString(); | ||
} | ||
startedTask.status = result.code; | ||
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params); | ||
startedTask.cacheStatus = cacheStatus; | ||
if (this.collectTerminalOutput) { | ||
startedTask.terminalOutput = this.getTerminalOutput(result.task.hash, startedTask.cacheStatus, result.code); | ||
} | ||
} | ||
getTerminalOutput(hash, cacheStatus, code) { | ||
return (0, read_task_terminal_output_1.readTaskTerminalOutput)(this.cacheDirectory, this.outputObfuscator, hash, cacheStatus, code); | ||
} | ||
cleanUpHashDetails(hashDetails) { | ||
const nodes = {}; | ||
Object.keys(hashDetails.nodes) | ||
.filter((k) => !k.startsWith('npm:')) | ||
.forEach((k) => { | ||
nodes[k] = hashDetails.nodes[k]; | ||
}); | ||
return { | ||
nodes, | ||
runtime: hashDetails.runtime, | ||
implicitDeps: hashDetails.implicitDeps, | ||
}; | ||
} | ||
} | ||
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle; | ||
//# sourceMappingURL=cloud-enabled-life-cycle.js.map | ||
const a0_0x48d1=['CloudEnabledLifeCycle','outputObfuscator','toISOString','remote-cache','project','cache','nodes','__esModule','code','startTime','filter','endTime','terminalOutput','taskId','getTerminalOutput','Cannot\x20find\x20task\x20','status','obfuscate','updateStartedTask','cacheableOperations','runContext','local-cache','remote-cache-hit','cacheDirectory','find','cacheStatus','tasks','local-cache-kept-existing','local-cache-hit','../../terminal-output/read-task-terminal-output','push','target','hash','params','task','cleanUpHashDetails','endCommand','implicitDeps','../../../utilities/serializer-overrides','npm:','startsWith','statuses','scheduleTask','cache-miss','collectTerminalOutput','runtime'];(function(_0x510f12,_0x48d1fd){const _0x3e9861=function(_0x58994c){while(--_0x58994c){_0x510f12['push'](_0x510f12['shift']());}};_0x3e9861(++_0x48d1fd);}(a0_0x48d1,0x1b8));const a0_0x3e98=function(_0x510f12,_0x48d1fd){_0x510f12=_0x510f12-0x0;let _0x3e9861=a0_0x48d1[_0x510f12];return _0x3e9861;};'use strict';Object['defineProperty'](exports,a0_0x3e98('0x1b'),{'value':!![]});exports[a0_0x3e98('0x14')]=void 0x0;const serializer_overrides_1=require(a0_0x3e98('0xc'));const read_task_terminal_output_1=require(a0_0x3e98('0x3'));class CloudEnabledLifeCycle{constructor(_0x3f9725,_0x540f7c,_0x3711e0,_0x136fad,_0x1601e7,_0x4c3bba){this[a0_0x3e98('0x28')]=_0x3f9725;this[a0_0x3e98('0x2b')]=_0x540f7c;this[a0_0x3e98('0x12')]=_0x3711e0;this[a0_0x3e98('0x27')]=_0x136fad;this[a0_0x3e98('0x15')]=_0x1601e7;this[a0_0x3e98('0x0')]=_0x4c3bba;}[a0_0x3e98('0x10')](_0x9afe7c){this[a0_0x3e98('0x28')]['scheduledTasks'][a0_0x3e98('0x4')](_0x9afe7c);}['startTask'](_0x3a4c20){this[a0_0x3e98('0x0')]['push']({'taskId':_0x3a4c20['id'],'startTime':new Date()[a0_0x3e98('0x16')](),'target':_0x3a4c20[a0_0x3e98('0x5')][a0_0x3e98('0x5')],'projectName':_0x3a4c20[a0_0x3e98('0x5')][a0_0x3e98('0x18')],'hash':_0x3a4c20[a0_0x3e98('0x6')],'hashDetails':this[a0_0x3e98('0x9')](_0x3a4c20['hashDetails']),'params':(0x0,serializer_overrides_1['serializeOverrides'])(_0x3a4c20),'uploadedToStorage':![]});}['endTasks'](_0x3d3f99){for(let _0x171aea of _0x3d3f99){let _0x31c66d;const _0x294517=_0x171aea[a0_0x3e98('0x24')]===a0_0x3e98('0x17');const _0x49ca6e=_0x171aea[a0_0x3e98('0x24')]===a0_0x3e98('0x19');const _0x43e8f0=_0x171aea[a0_0x3e98('0x24')]===a0_0x3e98('0x29')||_0x171aea[a0_0x3e98('0x24')]===a0_0x3e98('0x1')||_0x49ca6e;if(this[a0_0x3e98('0x28')][a0_0x3e98('0xf')][_0x171aea[a0_0x3e98('0x8')][a0_0x3e98('0x6')]]){_0x31c66d=this['runContext'][a0_0x3e98('0xf')][_0x171aea['task'][a0_0x3e98('0x6')]];}else if(_0x294517){_0x31c66d=a0_0x3e98('0x2a');}else if(_0x43e8f0){_0x31c66d=a0_0x3e98('0x2');}else{_0x31c66d=a0_0x3e98('0x11');}this['updateStartedTask'](_0x171aea,_0x31c66d);}}[a0_0x3e98('0xa')](){}[a0_0x3e98('0x26')](_0x5135ea,_0x899409){const _0x208bb4=this[a0_0x3e98('0x0')][a0_0x3e98('0x2c')](_0x5c1cf5=>_0x5c1cf5[a0_0x3e98('0x21')]===_0x5135ea[a0_0x3e98('0x8')]['id']);if(!_0x208bb4){throw new Error(a0_0x3e98('0x23')+_0x5135ea[a0_0x3e98('0x8')]['id']);}if((_0x5135ea===null||_0x5135ea===void 0x0?void 0x0:_0x5135ea[a0_0x3e98('0x1d')])&&(_0x5135ea===null||_0x5135ea===void 0x0?void 0x0:_0x5135ea[a0_0x3e98('0x1f')])){_0x208bb4[a0_0x3e98('0x1d')]=new Date(_0x5135ea[a0_0x3e98('0x1d')])[a0_0x3e98('0x16')]();_0x208bb4['endTime']=new Date(_0x5135ea[a0_0x3e98('0x1f')])['toISOString']();}else{_0x208bb4['endTime']=new Date()[a0_0x3e98('0x16')]();}_0x208bb4[a0_0x3e98('0x24')]=_0x5135ea[a0_0x3e98('0x1c')];_0x208bb4[a0_0x3e98('0x7')]=this['outputObfuscator'][a0_0x3e98('0x25')](_0x208bb4['params']);_0x208bb4[a0_0x3e98('0x2d')]=_0x899409;if(this[a0_0x3e98('0x12')]){_0x208bb4[a0_0x3e98('0x20')]=this[a0_0x3e98('0x22')](_0x5135ea['task'][a0_0x3e98('0x6')],_0x208bb4[a0_0x3e98('0x2d')],_0x5135ea['code']);}}[a0_0x3e98('0x22')](_0x239473,_0x161301,_0x340fa4){return(0x0,read_task_terminal_output_1['readTaskTerminalOutput'])(this[a0_0x3e98('0x2b')],this[a0_0x3e98('0x15')],_0x239473,_0x161301,_0x340fa4);}[a0_0x3e98('0x9')](_0x2e0c0e){const _0x519d9d={};Object['keys'](_0x2e0c0e['nodes'])[a0_0x3e98('0x1e')](_0x3f5e8a=>!_0x3f5e8a[a0_0x3e98('0xe')](a0_0x3e98('0xd')))['forEach'](_0x391140=>{_0x519d9d[_0x391140]=_0x2e0c0e[a0_0x3e98('0x1a')][_0x391140];});return{'nodes':_0x519d9d,'runtime':_0x2e0c0e[a0_0x3e98('0x13')],'implicitDeps':_0x2e0c0e[a0_0x3e98('0xb')]};}}exports[a0_0x3e98('0x14')]=CloudEnabledLifeCycle; |
@@ -1,320 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cloudEnabledTasksRunner = void 0; | ||
const message_reporter_1 = require("../../terminal-output/message-reporter"); | ||
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message"); | ||
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator"); | ||
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle"); | ||
const file_storage_1 = require("../../file-storage/file-storage"); | ||
const e2e_encryption_1 = require("../../file-storage/e2e-encryption"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const cloud_remote_cache_1 = require("./cloud-remote-cache"); | ||
const cloud_run_api_1 = require("./cloud-run.api"); | ||
const fs_1 = require("fs"); | ||
const path = require("path"); | ||
const path_1 = require("path"); | ||
const metric_logger_1 = require("../../../utilities/metric-logger"); | ||
const error_reporter_api_1 = require("../../api/error-reporter.api"); | ||
const fs_extra_1 = require("fs-extra"); | ||
const id_generator_1 = require("./id-generator"); | ||
const { 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); | ||
} | ||
/* | ||
* It can happen that a task is executed multiple times on an agent, say for DTE1 and DTE2. | ||
* When it runs for DTE2, it will be a local cache hit, so it will be marked as completed. | ||
* However, Nx won't upload an artifact to S3 in this case. Usually this isn't a problem, | ||
* cause the first DTE would have uploaded it. But if you are using a DTE, with a read-only token, | ||
* the uploaded artifact will have a different scoped hash. | ||
* | ||
* To address this: we are finding all local cache hits, and upload everything that has a put url. | ||
*/ | ||
function storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory) { | ||
const hashes = taskExecutions | ||
.filter((t) => t.cacheStatus === 'local-cache-hit') | ||
.map((t) => t.hash); | ||
hashes.forEach((hash) => remoteCache.store(hash, nxCacheDirectory)); | ||
} | ||
function onComplete({ daemon, options, fileStorage, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner, encryptionKey, storeInCurrentProcess, distributedExecutionId, runContext, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const runEndTime = new Date().toISOString(); | ||
const branch = (0, environment_1.getBranch)(); | ||
const runData = { | ||
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()), | ||
startTime: runStartTime, | ||
endTime: runEndTime, | ||
distributedExecutionId, | ||
branch: branch, | ||
runGroup: (0, environment_1.getRunGroup)(), | ||
// only set sha if branch is set because we invoke a separate process, | ||
// which adds a few millis | ||
sha: branch ? (0, environment_1.extractGitSha)() : undefined, | ||
inner: inner, | ||
}; | ||
const ciExecutionContext = { | ||
branch: branch, | ||
runGroup: (0, environment_1.getRunGroup)(), | ||
ciExecutionId: (0, environment_1.getCIExecutionId)(), | ||
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(), | ||
}; | ||
if (storeInCurrentProcess) { | ||
if ((0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) { | ||
const nxCacheDirectory = (0, environment_1.getNxCacheDirectory)(options); | ||
storeTaskHashes(taskExecutions, nxCacheDirectory, distributedExecutionId); | ||
storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory); | ||
} | ||
try { | ||
yield remoteCache.waitForStoreRequestsToComplete(); | ||
} | ||
catch (e) { | ||
output.error({ | ||
title: `Nx Cloud wasn't able to store artifacts.`, | ||
}); | ||
messages.printMessages(); | ||
return false; | ||
} | ||
for (const hash of fileStorage.storedHashes) { | ||
const matchingTask = taskExecutions.find((t) => t.hash === hash); | ||
if (!matchingTask) { | ||
throw new Error(`Task with hash ${hash} isn't recorded`); | ||
} | ||
matchingTask.uploadedToStorage = true; | ||
} | ||
try { | ||
yield api.endRun(runData, taskExecutions, ciExecutionContext); | ||
} | ||
catch (e) { | ||
output.error({ | ||
title: `Nx Cloud wasn't able to record its run.`, | ||
}); | ||
messages.printMessages(); | ||
return false; | ||
} | ||
yield (0, metric_logger_1.submitRunMetrics)(options); | ||
} | ||
else { | ||
try { | ||
const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken; | ||
const linkId = (0, id_generator_1.generateUniqueLinkId)(); | ||
yield daemon.processInBackground('nx-cloud/lib/daemon/process-run-end', { | ||
encryptionKey, | ||
runnerOptions: Object.assign(Object.assign({}, options), { accessToken }), | ||
delayedStoreRequests: remoteCache.delayedStoreRequests, | ||
ciExecutionContext, | ||
runEnd: { | ||
runData, | ||
taskExecutions, | ||
linkId, | ||
}, | ||
}); | ||
runContext.runUrl = `${options.url || 'https://nx.app'}/runs/${linkId}`; | ||
} | ||
catch (e) { | ||
output.warn({ | ||
title: `Nx Cloud Problems`, | ||
bodyLines: [e.message || e.toString()], | ||
}); | ||
return false; | ||
} | ||
} | ||
// this workaround is required because prior to Nx 13.3 we printed | ||
// the end message after the runner completes, so we need to wait for the | ||
// message to appear in the right place | ||
if (versionOfNxBefore133) { | ||
setTimeout(() => { | ||
messages.printMessages(); | ||
if (!messages.anyErrors && !inner) { | ||
endOfRunMessage.printCacheHitsMessage(); | ||
} | ||
}, 0); | ||
} | ||
else { | ||
messages.printMessages(); | ||
if (!messages.anyErrors && !inner) { | ||
endOfRunMessage.printCacheHitsMessage(); | ||
} | ||
} | ||
return true; | ||
}); | ||
} | ||
function createLifeCycle(runContext, options, outputObfuscator, tasks) { | ||
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, (0, environment_1.getNxCacheDirectory)(options), true, options.cacheableOperations || [], outputObfuscator, tasks); | ||
try { | ||
const { CompositeLifeCycle } = require('../../../utilities/nx-imports'); | ||
if (!CompositeLifeCycle) | ||
return cloudEnabledLifeCycle; | ||
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]); | ||
} | ||
catch (e) { | ||
return cloudEnabledLifeCycle; | ||
} | ||
} | ||
function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (options.skipNxCache) | ||
return; | ||
let hashes = tasks.map((t) => t.hash).filter((h) => !!h); | ||
const cachePath = (0, environment_1.getNxCacheDirectory)(options); | ||
// filter out the urls that don't have artifact stored locally | ||
const exists = yield Promise.all(hashes.map((hash) => { | ||
const tdCommit = (0, path_1.join)(cachePath, `${hash}.commit`); | ||
return (0, fs_extra_1.pathExists)(tdCommit); | ||
})); | ||
const missingHashes = []; | ||
for (let i = 0; i < exists.length; ++i) { | ||
if (!exists[i]) { | ||
missingHashes.push(hashes[i]); | ||
} | ||
} | ||
if (missingHashes.length > 0) { | ||
const startRunRequest = api.startRun(distributedExecutionId, missingHashes); | ||
for (const hash of missingHashes) { | ||
runContext.requests[hash] = startRunRequest; | ||
} | ||
} | ||
}); | ||
} | ||
function cloudEnabledTasksRunner(tasks, options, context, inner = false) { | ||
var _a; | ||
const distributedExecutionId = process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID; | ||
const runContext = { | ||
statuses: {}, | ||
scheduledTasks: [], | ||
requests: {}, | ||
allTasks: tasks, | ||
}; | ||
const versionOfNxBefore133 = options.lifeCycle === undefined; | ||
const taskExecutions = []; | ||
const messages = new message_reporter_1.MessageReporter(options); | ||
const api = createApi(messages, options, runContext); | ||
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions, distributedExecutionId); | ||
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties); | ||
const runStartTime = new Date().toISOString(); | ||
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions); | ||
const encryptionKey = environment_1.ENCRYPTION_KEY || options.encryptionKey; | ||
const encryption = new e2e_encryption_1.E2EEncryption(encryptionKey); | ||
const errorApi = new error_reporter_api_1.ErrorReporterApi(options); | ||
const storeInCurrentProcess = (0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId) || | ||
!((_a = context.daemon) === null || _a === void 0 ? void 0 : _a.enabled()); | ||
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, options, 'cloud-enabled-runner'); | ||
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess); | ||
// we don't await for it cause this step is optional | ||
fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId); | ||
// have to reset it so we don't capture inner tasks | ||
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID; | ||
const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context); | ||
// observable -> legacy | ||
if (res.subscribe) { | ||
const { Subject } = require('rxjs/internal/Subject'); | ||
const wrappedRes = new Subject(); | ||
res.subscribe({ | ||
next: (value) => wrappedRes.next(value), | ||
error: (err) => wrappedRes.error(err), | ||
complete: () => __awaiter(this, void 0, void 0, function* () { | ||
const success = yield onComplete({ | ||
daemon: context.daemon, | ||
options, | ||
fileStorage, | ||
remoteCache, | ||
api, | ||
outputObfuscator, | ||
runStartTime, | ||
messages, | ||
endOfRunMessage, | ||
taskExecutions, | ||
versionOfNxBefore133, | ||
inner, | ||
encryptionKey, | ||
storeInCurrentProcess, | ||
runContext, | ||
distributedExecutionId, | ||
}); | ||
if (!success && | ||
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) { | ||
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE); | ||
} | ||
wrappedRes.complete(); | ||
}), | ||
}); | ||
return wrappedRes; | ||
// promise | ||
} | ||
else { | ||
return res | ||
.then((r) => __awaiter(this, void 0, void 0, function* () { | ||
const success = yield onComplete({ | ||
daemon: context.daemon, | ||
options, | ||
fileStorage, | ||
remoteCache, | ||
api, | ||
outputObfuscator, | ||
runStartTime, | ||
messages, | ||
endOfRunMessage, | ||
taskExecutions, | ||
versionOfNxBefore133, | ||
inner, | ||
encryptionKey, | ||
storeInCurrentProcess, | ||
runContext, | ||
distributedExecutionId, | ||
}); | ||
if (!success && | ||
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) { | ||
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE); | ||
} | ||
return r; | ||
})) | ||
.catch((e) => __awaiter(this, void 0, void 0, function* () { | ||
const success = yield onComplete({ | ||
daemon: context.daemon, | ||
options, | ||
fileStorage, | ||
remoteCache, | ||
api, | ||
outputObfuscator, | ||
runStartTime, | ||
messages, | ||
endOfRunMessage, | ||
taskExecutions, | ||
versionOfNxBefore133, | ||
inner, | ||
encryptionKey, | ||
storeInCurrentProcess, | ||
runContext, | ||
distributedExecutionId, | ||
}); | ||
if (!success && | ||
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) { | ||
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE); | ||
} | ||
throw e; | ||
})); | ||
} | ||
} | ||
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner; | ||
//# sourceMappingURL=cloud-enabled.runner.js.map | ||
const a1_0x3e79=['pathExists','cacheableOperations','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','../../file-storage/file-storage','OutputObfuscator','./id-generator','\x20isn\x27t\x20recorded','ACCESS_TOKEN','lifeCycle','apply','./cloud-enabled-life-cycle','startRun','cloud-enabled-runner','encryptionKey','delayedStoreRequests','all','toISOString','__esModule','store','../../terminal-output/end-of-run-message','cacheStatus','maskedProperties','error','getRunGroup','VERBOSE_LOGGING','parseCommand','submitRunMetrics','exit','MessageReporter','toString','getCIExecutionEnv','defineProperty','printCacheHitsMessage','Executed\x20tasks\x20with\x20hashes:\x20','next','then','removeTrailingSlash','accessToken','printMessages','.commit','assign','uploadedToStorage','hash','getBranch','https://nx.app','getCIExecutionId','../../api/error-reporter.api','E2EEncryption','complete','push','./cloud-remote-cache','enabled','length','forEach','catch','agentRunningInDistributedExecution','processInBackground','cloudEnabledTasksRunner','anyErrors','getNxCacheDirectory','path','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','fs-extra','requests','EndOfRunMessage','__awaiter','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','env','writeFileSync','daemon','runUrl','map','obfuscate','filter','endRun','warn','/runs/','skipNxCache','storedHashes','rxjs/internal/Subject','url','join','taskId','../../terminal-output/output-obfuscator','extractGitSha','value','local-cache-hit','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','../../../utilities/nx-imports','subscribe'];(function(_0x1f9946,_0x3e79e8){const _0x3be4d7=function(_0x3c6d0d){while(--_0x3c6d0d){_0x1f9946['push'](_0x1f9946['shift']());}};_0x3be4d7(++_0x3e79e8);}(a1_0x3e79,0xe8));const a1_0x3be4=function(_0x1f9946,_0x3e79e8){_0x1f9946=_0x1f9946-0x0;let _0x3be4d7=a1_0x3e79[_0x1f9946];return _0x3be4d7;};'use strict';var __awaiter=this&&this[a1_0x3be4('0xd')]||function(_0x28ba0e,_0x295efe,_0x202f34,_0x428441){function _0x1573d5(_0x52a44f){return _0x52a44f instanceof _0x202f34?_0x52a44f:new _0x202f34(function(_0x38278c){_0x38278c(_0x52a44f);});}return new(_0x202f34||(_0x202f34=Promise))(function(_0x52bb0f,_0x58c11f){function _0x4f7a0a(_0x301ac9){try{_0x59eb0f(_0x428441[a1_0x3be4('0x48')](_0x301ac9));}catch(_0x18ad8d){_0x58c11f(_0x18ad8d);}}function _0x402bbd(_0x26b9e9){try{_0x59eb0f(_0x428441['throw'](_0x26b9e9));}catch(_0x1fd94a){_0x58c11f(_0x1fd94a);}}function _0x59eb0f(_0x77fc83){_0x77fc83['done']?_0x52bb0f(_0x77fc83[a1_0x3be4('0x21')]):_0x1573d5(_0x77fc83[a1_0x3be4('0x21')])[a1_0x3be4('0x49')](_0x4f7a0a,_0x402bbd);}_0x59eb0f((_0x428441=_0x428441[a1_0x3be4('0x2f')](_0x28ba0e,_0x295efe||[]))[a1_0x3be4('0x48')]());});};Object[a1_0x3be4('0x45')](exports,a1_0x3be4('0x37'),{'value':!![]});exports[a1_0x3be4('0x5')]=void 0x0;const message_reporter_1=require('../../terminal-output/message-reporter');const end_of_run_message_1=require(a1_0x3be4('0x39'));const output_obfuscator_1=require(a1_0x3be4('0x1f'));const cloud_enabled_life_cycle_1=require(a1_0x3be4('0x30'));const file_storage_1=require(a1_0x3be4('0x29'));const e2e_encryption_1=require('../../file-storage/e2e-encryption');const environment_1=require('../../../utilities/environment');const cloud_remote_cache_1=require(a1_0x3be4('0x58'));const cloud_run_api_1=require('./cloud-run.api');const fs_1=require('fs');const path=require(a1_0x3be4('0x8'));const path_1=require(a1_0x3be4('0x8'));const metric_logger_1=require('../../../utilities/metric-logger');const error_reporter_api_1=require(a1_0x3be4('0x54'));const fs_extra_1=require(a1_0x3be4('0xa'));const id_generator_1=require(a1_0x3be4('0x2b'));const remove_trailing_slash_1=require('../../../utilities/remove-trailing-slash');const {tasksRunner,output}=require(a1_0x3be4('0x24'));function createApi(_0x41655b,_0x71fd2c,_0x4e23b0){const _0x5ba6b6=(0x0,environment_1['getMachineInfo'])(_0x71fd2c);return new cloud_run_api_1['CloudRunApi'](_0x41655b,_0x4e23b0,_0x71fd2c,_0x5ba6b6);}function storeTaskHashes(_0x894e3e,_0x1b2a73,_0x186d27){const _0x5a478a=JSON['stringify'](_0x894e3e[a1_0x3be4('0x13')](_0x5553fc=>({'taskId':_0x5553fc[a1_0x3be4('0x1e')],'hash':_0x5553fc['hash']})));if(environment_1[a1_0x3be4('0x3e')]){output['note']({'title':a1_0x3be4('0x47')+_0x5a478a});}(0x0,fs_1[a1_0x3be4('0x10')])(path[a1_0x3be4('0x1d')](_0x1b2a73,'tasks-hashes-'+_0x186d27),_0x5a478a);}function storeLocalCacheHits(_0x22066,_0x3e5374,_0x24f4d6){const _0x375cf3=_0x22066[a1_0x3be4('0x15')](_0x1dfadc=>_0x1dfadc[a1_0x3be4('0x3a')]===a1_0x3be4('0x22'))[a1_0x3be4('0x13')](_0x51dd7d=>_0x51dd7d['hash']);_0x375cf3[a1_0x3be4('0x1')](_0x4a1572=>_0x3e5374[a1_0x3be4('0x38')](_0x4a1572,_0x24f4d6));}function onComplete({daemon,options,fileStorage,remoteCache,api,outputObfuscator,runStartTime,messages,endOfRunMessage,taskExecutions,versionOfNxBefore133,inner,encryptionKey,storeInCurrentProcess,distributedExecutionId,runContext}){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3e5aa2=new Date()[a1_0x3be4('0x36')]();const _0x4c3679=(0x0,environment_1[a1_0x3be4('0x51')])();const _0x36d9d8={'command':outputObfuscator[a1_0x3be4('0x14')]((0x0,environment_1[a1_0x3be4('0x3f')])()),'startTime':runStartTime,'endTime':_0x3e5aa2,'distributedExecutionId':distributedExecutionId,'branch':_0x4c3679,'runGroup':(0x0,environment_1['getRunGroup'])(),'sha':_0x4c3679?(0x0,environment_1[a1_0x3be4('0x20')])():undefined,'inner':inner};const _0x1b625c={'branch':_0x4c3679,'runGroup':(0x0,environment_1[a1_0x3be4('0x3d')])(),'ciExecutionId':(0x0,environment_1[a1_0x3be4('0x53')])(),'ciExecutionEnv':(0x0,environment_1[a1_0x3be4('0x44')])()};if(storeInCurrentProcess){if((0x0,environment_1['agentRunningInDistributedExecution'])(distributedExecutionId)){const _0x1b619e=(0x0,environment_1['getNxCacheDirectory'])(options);storeTaskHashes(taskExecutions,_0x1b619e,distributedExecutionId);storeLocalCacheHits(taskExecutions,remoteCache,_0x1b619e);}try{yield remoteCache['waitForStoreRequestsToComplete']();}catch(_0x4179c7){output[a1_0x3be4('0x3c')]({'title':a1_0x3be4('0x9')});messages['printMessages']();return![];}for(const _0x1c6f66 of fileStorage[a1_0x3be4('0x1a')]){const _0x2909a7=taskExecutions['find'](_0x27fe97=>_0x27fe97[a1_0x3be4('0x50')]===_0x1c6f66);if(!_0x2909a7){throw new Error('Task\x20with\x20hash\x20'+_0x1c6f66+a1_0x3be4('0x2c'));}_0x2909a7[a1_0x3be4('0x4f')]=!![];}try{yield api[a1_0x3be4('0x16')](_0x36d9d8,taskExecutions,_0x1b625c);}catch(_0x34ccd8){output[a1_0x3be4('0x3c')]({'title':a1_0x3be4('0x28')});messages[a1_0x3be4('0x4c')]();return![];}yield(0x0,metric_logger_1[a1_0x3be4('0x40')])(options);}else{try{const _0x1eea7b=environment_1['ACCESS_TOKEN']?environment_1[a1_0x3be4('0x2d')]:options[a1_0x3be4('0x4b')];const _0x1177cc=(0x0,id_generator_1['generateUniqueLinkId'])();yield daemon[a1_0x3be4('0x4')]('nx-cloud/lib/daemon/process-run-end',{'encryptionKey':encryptionKey,'runnerOptions':Object[a1_0x3be4('0x4e')](Object[a1_0x3be4('0x4e')]({},options),{'accessToken':_0x1eea7b}),'delayedStoreRequests':remoteCache[a1_0x3be4('0x34')],'ciExecutionContext':_0x1b625c,'runEnd':{'runData':_0x36d9d8,'taskExecutions':taskExecutions,'linkId':_0x1177cc}});runContext[a1_0x3be4('0x12')]=(0x0,remove_trailing_slash_1[a1_0x3be4('0x4a')])(options[a1_0x3be4('0x1c')]||a1_0x3be4('0x52'))+a1_0x3be4('0x18')+_0x1177cc;}catch(_0x19964f){output[a1_0x3be4('0x17')]({'title':'Nx\x20Cloud\x20Problems','bodyLines':[_0x19964f['message']||_0x19964f[a1_0x3be4('0x43')]()]});return![];}}if(versionOfNxBefore133){setTimeout(()=>{messages['printMessages']();if(!messages[a1_0x3be4('0x6')]&&!inner){endOfRunMessage[a1_0x3be4('0x46')]();}},0x0);}else{messages[a1_0x3be4('0x4c')]();if(!messages[a1_0x3be4('0x6')]&&!inner){endOfRunMessage['printCacheHitsMessage']();}}return!![];});}function createLifeCycle(_0xf82dc1,_0xd223ad,_0x32c751,_0x1cc96b){const _0x5a2ff3=new cloud_enabled_life_cycle_1['CloudEnabledLifeCycle'](_0xf82dc1,(0x0,environment_1[a1_0x3be4('0x7')])(_0xd223ad),!![],_0xd223ad[a1_0x3be4('0x27')]||[],_0x32c751,_0x1cc96b);try{const {CompositeLifeCycle}=require(a1_0x3be4('0x24'));if(!CompositeLifeCycle)return _0x5a2ff3;return new CompositeLifeCycle([_0xd223ad[a1_0x3be4('0x2e')],_0x5a2ff3]);}catch(_0x41b2ce){return _0x5a2ff3;}}function fetchUrlsForKnownHashesUpfront(_0xf09571,_0x1a4b34,_0x4019ed,_0xfed4d,_0x3939e7){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0xfed4d[a1_0x3be4('0x19')])return;let _0x38b754=_0x4019ed[a1_0x3be4('0x13')](_0x41afb3=>_0x41afb3['hash'])[a1_0x3be4('0x15')](_0x37a70d=>!!_0x37a70d);const _0x44a88d=(0x0,environment_1[a1_0x3be4('0x7')])(_0xfed4d);const _0x5f40f8=yield Promise[a1_0x3be4('0x35')](_0x38b754[a1_0x3be4('0x13')](_0x2d1074=>{const _0x342ea6=(0x0,path_1['join'])(_0x44a88d,_0x2d1074+a1_0x3be4('0x4d'));return(0x0,fs_extra_1[a1_0x3be4('0x26')])(_0x342ea6);}));const _0x2c188b=[];for(let _0x15b905=0x0;_0x15b905<_0x5f40f8[a1_0x3be4('0x0')];++_0x15b905){if(!_0x5f40f8[_0x15b905]){_0x2c188b[a1_0x3be4('0x57')](_0x38b754[_0x15b905]);}}if(_0x2c188b['length']>0x0){const _0x3a591e=_0xf09571[a1_0x3be4('0x31')](_0x3939e7,_0x2c188b);for(const _0xa99f16 of _0x2c188b){_0x1a4b34[a1_0x3be4('0xb')][_0xa99f16]=_0x3a591e;}}});}function cloudEnabledTasksRunner(_0x3da403,_0x31a851,_0x3b9275,_0x21805b=![]){var _0x4977dd;const _0x50a99f=process[a1_0x3be4('0xf')][a1_0x3be4('0x23')];const _0x4a0a79={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x3da403};const _0x5135c0=_0x31a851[a1_0x3be4('0x2e')]===undefined;const _0x32f926=[];const _0x25ca93=new message_reporter_1[(a1_0x3be4('0x42'))](_0x31a851);const _0x11bf8e=createApi(_0x25ca93,_0x31a851,_0x4a0a79);const _0x35ac1f=new end_of_run_message_1[(a1_0x3be4('0xc'))](_0x4a0a79,_0x32f926,_0x50a99f);const _0x140ee2=new output_obfuscator_1[(a1_0x3be4('0x2a'))](_0x31a851[a1_0x3be4('0x3b')]);const _0x3e50ff=new Date()[a1_0x3be4('0x36')]();const _0xff3ec7=createLifeCycle(_0x4a0a79,_0x31a851,_0x140ee2,_0x32f926);const _0x5261e9=environment_1['ENCRYPTION_KEY']||_0x31a851[a1_0x3be4('0x33')];const _0x4d1d5a=new e2e_encryption_1[(a1_0x3be4('0x55'))](_0x5261e9);const _0x1def89=new error_reporter_api_1['ErrorReporterApi'](_0x31a851);const _0xc31468=(0x0,environment_1['agentRunningInDistributedExecution'])(_0x50a99f)||!((_0x4977dd=_0x3b9275['daemon'])===null||_0x4977dd===void 0x0?void 0x0:_0x4977dd[a1_0x3be4('0x59')]());const _0x243a7c=new file_storage_1['FileStorage'](_0x4d1d5a,_0x1def89,_0x31a851,a1_0x3be4('0x32'));const _0x5a5ac4=new cloud_remote_cache_1['CloudRemoteCache'](_0x25ca93,_0x11bf8e,_0x4a0a79,_0x243a7c,_0x50a99f,_0xc31468);fetchUrlsForKnownHashesUpfront(_0x11bf8e,_0x4a0a79,_0x3da403,_0x31a851,_0x50a99f);delete process[a1_0x3be4('0xf')][a1_0x3be4('0x23')];const _0x1cda11=tasksRunner(_0x3da403,Object[a1_0x3be4('0x4e')](Object[a1_0x3be4('0x4e')]({},_0x31a851),{'remoteCache':_0x5a5ac4,'lifeCycle':_0xff3ec7}),_0x3b9275);if(_0x1cda11[a1_0x3be4('0x25')]){const {Subject}=require(a1_0x3be4('0x1b'));const _0x4e197a=new Subject();_0x1cda11[a1_0x3be4('0x25')]({'next':_0x856c9c=>_0x4e197a['next'](_0x856c9c),'error':_0x4beaee=>_0x4e197a[a1_0x3be4('0x3c')](_0x4beaee),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x34ae35=yield onComplete({'daemon':_0x3b9275[a1_0x3be4('0x11')],'options':_0x31a851,'fileStorage':_0x243a7c,'remoteCache':_0x5a5ac4,'api':_0x11bf8e,'outputObfuscator':_0x140ee2,'runStartTime':_0x3e50ff,'messages':_0x25ca93,'endOfRunMessage':_0x35ac1f,'taskExecutions':_0x32f926,'versionOfNxBefore133':_0x5135c0,'inner':_0x21805b,'encryptionKey':_0x5261e9,'storeInCurrentProcess':_0xc31468,'runContext':_0x4a0a79,'distributedExecutionId':_0x50a99f});if(!_0x34ae35&&(0x0,environment_1[a1_0x3be4('0x3')])(_0x50a99f)){process[a1_0x3be4('0x41')](environment_1[a1_0x3be4('0xe')]);}_0x4e197a[a1_0x3be4('0x56')]();})});return _0x4e197a;}else{return _0x1cda11['then'](_0x3a1d3f=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x91ae75=yield onComplete({'daemon':_0x3b9275['daemon'],'options':_0x31a851,'fileStorage':_0x243a7c,'remoteCache':_0x5a5ac4,'api':_0x11bf8e,'outputObfuscator':_0x140ee2,'runStartTime':_0x3e50ff,'messages':_0x25ca93,'endOfRunMessage':_0x35ac1f,'taskExecutions':_0x32f926,'versionOfNxBefore133':_0x5135c0,'inner':_0x21805b,'encryptionKey':_0x5261e9,'storeInCurrentProcess':_0xc31468,'runContext':_0x4a0a79,'distributedExecutionId':_0x50a99f});if(!_0x91ae75&&(0x0,environment_1[a1_0x3be4('0x3')])(_0x50a99f)){process[a1_0x3be4('0x41')](environment_1[a1_0x3be4('0xe')]);}return _0x3a1d3f;}))[a1_0x3be4('0x2')](_0x18956c=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x4a1551=yield onComplete({'daemon':_0x3b9275[a1_0x3be4('0x11')],'options':_0x31a851,'fileStorage':_0x243a7c,'remoteCache':_0x5a5ac4,'api':_0x11bf8e,'outputObfuscator':_0x140ee2,'runStartTime':_0x3e50ff,'messages':_0x25ca93,'endOfRunMessage':_0x35ac1f,'taskExecutions':_0x32f926,'versionOfNxBefore133':_0x5135c0,'inner':_0x21805b,'encryptionKey':_0x5261e9,'storeInCurrentProcess':_0xc31468,'runContext':_0x4a0a79,'distributedExecutionId':_0x50a99f});if(!_0x4a1551&&(0x0,environment_1[a1_0x3be4('0x3')])(_0x50a99f)){process[a1_0x3be4('0x41')](environment_1[a1_0x3be4('0xe')]);}throw _0x18956c;}));}}exports['cloudEnabledTasksRunner']=cloudEnabledTasksRunner; |
@@ -1,133 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CloudRemoteCache = void 0; | ||
const environment_1 = require("../../../utilities/environment"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
class CloudRemoteCache { | ||
constructor(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess) { | ||
this.messages = messages; | ||
this.api = api; | ||
this.runContext = runContext; | ||
this.fileStorage = fileStorage; | ||
this.distributedExecutionId = distributedExecutionId; | ||
this.storeInCurrentProcess = storeInCurrentProcess; | ||
this.storeRequests = []; | ||
this.delayedStoreRequests = []; | ||
} | ||
retrieve(hash, cacheDirectory) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.messages.cacheError) | ||
return false; | ||
const hashUrls = yield this.hashUrls(hash); | ||
if (!hashUrls || !hashUrls.get) { | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ title: `Nx Cloud: Cache miss ${hash}.` }); | ||
} | ||
this.runContext.statuses[hash] = 'cache-miss'; | ||
return false; | ||
} | ||
try { | ||
yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory); | ||
this.runContext.statuses[hash] = 'remote-cache-hit'; | ||
return true; | ||
} | ||
catch (ee) { | ||
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee; | ||
// TODO: vsavkin remove this handling Oct 2023 | ||
// 404 indicates that something is broken, but older versions | ||
// of the api can result in such errors | ||
// we ignore them for now | ||
if (e.response && e.response.status === 404) { | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` }); | ||
} | ||
// cache miss. print nothing | ||
} | ||
else { | ||
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage'); | ||
} | ||
this.runContext.statuses[hash] = 'cache-miss'; | ||
return false; | ||
} | ||
}); | ||
} | ||
store(hash, cacheDirectory) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.messages.cacheError) | ||
return false; | ||
const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () { | ||
var _a; | ||
const hashUrls = yield this.hashUrls(hash); | ||
if (!hashUrls) | ||
return false; | ||
if (!hashUrls.put) { | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: `Nx Cloud: Skipping storing ${hash}.`, | ||
bodyLines: [ | ||
`There are several reasons why this can happen.`, | ||
`Maybe you are using a read-only token or the artifact has already being uploaded.`, | ||
], | ||
}); | ||
} | ||
return true; | ||
} | ||
if (!this.storeInCurrentProcess) { | ||
this.delayedStoreRequests.push({ hash: hash, url: hashUrls.put }); | ||
return true; | ||
} | ||
try { | ||
yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory); | ||
return true; | ||
} | ||
catch (ee) { | ||
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee; | ||
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage'); | ||
return false; | ||
} | ||
})); | ||
this.storeRequests.push(res); | ||
return res; | ||
}); | ||
} | ||
hashUrls(hash) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (hash in this.runContext.requests) { | ||
return (yield this.runContext.requests[hash])[hash]; | ||
} | ||
else { | ||
const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks | ||
.filter((t) => !this.runContext.requests[t.hash]) | ||
.map((t) => t.hash); | ||
if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) { | ||
scheduledTaskHashesWithoutRequests.push(hash); | ||
} | ||
const request = this.api.startRun(this.distributedExecutionId, scheduledTaskHashesWithoutRequests); | ||
scheduledTaskHashesWithoutRequests.forEach((taskHash) => { | ||
this.runContext.requests[taskHash] = request; | ||
}); | ||
return (yield request)[hash]; | ||
} | ||
}); | ||
} | ||
waitForStoreRequestsToComplete() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true)); | ||
if (!res) { | ||
throw new Error(`Error when storing artifacts`); | ||
} | ||
}); | ||
} | ||
} | ||
exports.CloudRemoteCache = CloudRemoteCache; | ||
//# sourceMappingURL=cloud-remote-cache.js.map | ||
const a2_0x5018=['hash','Error\x20when\x20storing\x20artifacts','apply','api','distributedExecutionId','storeRequests','CloudRemoteCache','waitForStoreRequestsToComplete','next','get','then','Maybe\x20you\x20are\x20using\x20a\x20read-only\x20token\x20or\x20the\x20artifact\x20has\x20already\x20being\x20uploaded.','runContext','resolve','indexOf','__awaiter','VERBOSE_LOGGING','cache-miss','messages','startRun','cacheError','push','value','axiosException','map','remote-cache-hit','../../../utilities/environment','requests','storage','delayedStoreRequests','scheduledTasks','statuses','Nx\x20Cloud:\x20Skipping\x20storing\x20','store','.\x20Status\x20404.','retrieve','fileStorage','throw','response','Nx\x20Cloud:\x20Cache\x20miss\x20','storeInCurrentProcess','hashUrls','forEach','note','__esModule','put'];(function(_0x27e093,_0x501845){const _0x5cb5b3=function(_0xd207b){while(--_0xd207b){_0x27e093['push'](_0x27e093['shift']());}};_0x5cb5b3(++_0x501845);}(a2_0x5018,0x10b));const a2_0x5cb5=function(_0x27e093,_0x501845){_0x27e093=_0x27e093-0x0;let _0x5cb5b3=a2_0x5018[_0x27e093];return _0x5cb5b3;};'use strict';var __awaiter=this&&this[a2_0x5cb5('0x18')]||function(_0x973dca,_0x1df246,_0x218732,_0x16361d){function _0x432e94(_0x190075){return _0x190075 instanceof _0x218732?_0x190075:new _0x218732(function(_0xf93822){_0xf93822(_0x190075);});}return new(_0x218732||(_0x218732=Promise))(function(_0x114b49,_0x2529c5){function _0x793aac(_0x692111){try{_0x20b6a7(_0x16361d['next'](_0x692111));}catch(_0xfa5fce){_0x2529c5(_0xfa5fce);}}function _0x2e5fe4(_0x5f3697){try{_0x20b6a7(_0x16361d[a2_0x5cb5('0x0')](_0x5f3697));}catch(_0x2b3d7b){_0x2529c5(_0x2b3d7b);}}function _0x20b6a7(_0xb8cee8){_0xb8cee8['done']?_0x114b49(_0xb8cee8[a2_0x5cb5('0x1f')]):_0x432e94(_0xb8cee8['value'])['then'](_0x793aac,_0x2e5fe4);}_0x20b6a7((_0x16361d=_0x16361d[a2_0x5cb5('0xb')](_0x973dca,_0x1df246||[]))[a2_0x5cb5('0x11')]());});};Object['defineProperty'](exports,a2_0x5cb5('0x7'),{'value':!![]});exports[a2_0x5cb5('0xf')]=void 0x0;const environment_1=require(a2_0x5cb5('0x23'));const {output}=require('../../../utilities/nx-imports');class CloudRemoteCache{constructor(_0x3ee6e3,_0x2edcbe,_0x2806c8,_0x59f363,_0x1ff3b5,_0x17b387){this[a2_0x5cb5('0x1b')]=_0x3ee6e3;this[a2_0x5cb5('0xc')]=_0x2edcbe;this[a2_0x5cb5('0x15')]=_0x2806c8;this[a2_0x5cb5('0x2d')]=_0x59f363;this[a2_0x5cb5('0xd')]=_0x1ff3b5;this[a2_0x5cb5('0x3')]=_0x17b387;this[a2_0x5cb5('0xe')]=[];this['delayedStoreRequests']=[];}[a2_0x5cb5('0x2c')](_0x51262c,_0x531930){var _0x4a152f;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x5cb5('0x1b')]['cacheError'])return![];const _0x33e612=yield this['hashUrls'](_0x51262c);if(!_0x33e612||!_0x33e612[a2_0x5cb5('0x12')]){if(environment_1['VERBOSE_LOGGING']){output[a2_0x5cb5('0x6')]({'title':a2_0x5cb5('0x2')+_0x51262c+'.'});}this[a2_0x5cb5('0x15')]['statuses'][_0x51262c]='cache-miss';return![];}try{yield this[a2_0x5cb5('0x2d')][a2_0x5cb5('0x2c')](_0x51262c,_0x33e612[a2_0x5cb5('0x12')],_0x531930);this[a2_0x5cb5('0x15')]['statuses'][_0x51262c]=a2_0x5cb5('0x22');return!![];}catch(_0x31ddb0){const _0x1aeb38=(_0x4a152f=_0x31ddb0[a2_0x5cb5('0x20')])!==null&&_0x4a152f!==void 0x0?_0x4a152f:_0x31ddb0;if(_0x1aeb38[a2_0x5cb5('0x1')]&&_0x1aeb38[a2_0x5cb5('0x1')]['status']===0x194){if(environment_1['VERBOSE_LOGGING']){output[a2_0x5cb5('0x6')]({'title':'Nx\x20Cloud:\x20Cache\x20miss\x20'+_0x51262c+a2_0x5cb5('0x2b')});}}else{this['messages'][a2_0x5cb5('0x1d')]=this[a2_0x5cb5('0x1b')]['extractErrorMessage'](_0x1aeb38,a2_0x5cb5('0x25'));}this[a2_0x5cb5('0x15')][a2_0x5cb5('0x28')][_0x51262c]=a2_0x5cb5('0x1a');return![];}});}[a2_0x5cb5('0x2a')](_0x3a5059,_0x5a26ec){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x5cb5('0x1b')][a2_0x5cb5('0x1d')])return![];const _0x4bdd65=Promise[a2_0x5cb5('0x16')]()[a2_0x5cb5('0x13')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0xc8a395;const _0x2b356d=yield this[a2_0x5cb5('0x4')](_0x3a5059);if(!_0x2b356d)return![];if(!_0x2b356d[a2_0x5cb5('0x8')]){if(environment_1[a2_0x5cb5('0x19')]){output[a2_0x5cb5('0x6')]({'title':a2_0x5cb5('0x29')+_0x3a5059+'.','bodyLines':['There\x20are\x20several\x20reasons\x20why\x20this\x20can\x20happen.',a2_0x5cb5('0x14')]});}return!![];}if(!this[a2_0x5cb5('0x3')]){this[a2_0x5cb5('0x26')][a2_0x5cb5('0x1e')]({'hash':_0x3a5059,'url':_0x2b356d[a2_0x5cb5('0x8')]});return!![];}try{yield this[a2_0x5cb5('0x2d')][a2_0x5cb5('0x2a')](_0x3a5059,_0x2b356d['put'],_0x5a26ec);return!![];}catch(_0x3b2fb1){const _0x17a724=(_0xc8a395=_0x3b2fb1[a2_0x5cb5('0x20')])!==null&&_0xc8a395!==void 0x0?_0xc8a395:_0x3b2fb1;this[a2_0x5cb5('0x1b')]['cacheError']=this[a2_0x5cb5('0x1b')]['extractErrorMessage'](_0x17a724,a2_0x5cb5('0x25'));return![];}}));this[a2_0x5cb5('0xe')][a2_0x5cb5('0x1e')](_0x4bdd65);return _0x4bdd65;});}[a2_0x5cb5('0x4')](_0x48ca48){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x48ca48 in this[a2_0x5cb5('0x15')][a2_0x5cb5('0x24')]){return(yield this[a2_0x5cb5('0x15')][a2_0x5cb5('0x24')][_0x48ca48])[_0x48ca48];}else{const _0xd248ca=this[a2_0x5cb5('0x15')][a2_0x5cb5('0x27')]['filter'](_0x33ae10=>!this['runContext'][a2_0x5cb5('0x24')][_0x33ae10['hash']])[a2_0x5cb5('0x21')](_0x903b68=>_0x903b68[a2_0x5cb5('0x9')]);if(_0xd248ca[a2_0x5cb5('0x17')](_0x48ca48)===-0x1){_0xd248ca[a2_0x5cb5('0x1e')](_0x48ca48);}const _0x338480=this[a2_0x5cb5('0xc')][a2_0x5cb5('0x1c')](this[a2_0x5cb5('0xd')],_0xd248ca);_0xd248ca[a2_0x5cb5('0x5')](_0x24933f=>{this[a2_0x5cb5('0x15')][a2_0x5cb5('0x24')][_0x24933f]=_0x338480;});return(yield _0x338480)[_0x48ca48];}});}[a2_0x5cb5('0x10')](){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x307897=yield Promise['all'](this[a2_0x5cb5('0xe')])[a2_0x5cb5('0x13')](_0x303290=>_0x303290['reduce']((_0x4533ef,_0x4b4742)=>_0x4533ef&&_0x4b4742,!![]));if(!_0x307897){throw new Error(a2_0x5cb5('0xa'));}});}}exports[a2_0x5cb5('0xf')]=CloudRemoteCache; |
@@ -1,174 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CloudRunApi = void 0; | ||
const axios_1 = require("../../../utilities/axios"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const fs_1 = require("fs"); | ||
const zlib_1 = require("zlib"); | ||
const util_1 = require("util"); | ||
const metric_logger_1 = require("../../../utilities/metric-logger"); | ||
const is_private_cloud_1 = require("../../../utilities/is-private-cloud"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
class CloudRunApi { | ||
constructor(messages, runContext, options, machineInfo) { | ||
this.messages = messages; | ||
this.runContext = runContext; | ||
this.machineInfo = machineInfo; | ||
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options); | ||
} | ||
startRun(distributedExecutionId, hashes) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// API is not working, don't make the end request | ||
if (this.messages.apiError) | ||
return {}; | ||
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun'); | ||
try { | ||
const request = { | ||
meta: { | ||
nxCloudVersion: this.nxCloudVersion(), | ||
}, | ||
branch: (0, environment_1.getBranch)(), | ||
runGroup: (0, environment_1.getRunGroup)(), | ||
ciExecutionId: (0, environment_1.getCIExecutionId)(), | ||
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(), | ||
distributedExecutionId, | ||
hashes, | ||
}; | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: 'RunStart', | ||
bodyLines: ['\n' + JSON.stringify(request, null, 2)], | ||
}); | ||
} | ||
const resp = yield (0, axios_1.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request))); | ||
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp)); | ||
if (resp.data && resp.data.message) { | ||
this.messages.message = resp.data.message; | ||
} | ||
if (!resp.data || !resp.data.urls) { | ||
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`; | ||
return {}; | ||
} | ||
return resp.data.urls; | ||
} | ||
catch (e) { | ||
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response) | ||
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response) | ||
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY); | ||
this.messages.apiError = this.messages.extractErrorMessage(e, 'api'); | ||
return {}; | ||
} | ||
}); | ||
} | ||
createReqBody(run, tasks, ciExecutionContext, linkId) { | ||
if ((0, is_private_cloud_1.isConnectedToPrivateCloud)()) { | ||
for (let t of tasks) { | ||
delete t.uploadedToStorage; | ||
} | ||
} | ||
const uncompressedReqBody = Object.assign(Object.assign({ meta: { | ||
nxCloudVersion: this.nxCloudVersion(), | ||
}, tasks, | ||
run, | ||
linkId }, ((0, is_private_cloud_1.isConnectedToPrivateCloud)() ? {} : ciExecutionContext)), { machineInfo: this.machineInfo }); | ||
return JSON.stringify(uncompressedReqBody); | ||
} | ||
endRun(run, tasks, ciExecutionContext, linkId) { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// API is not working, don't make the end request | ||
if (this.messages.apiError) | ||
return false; | ||
let uncompressedBodyString = this.createReqBody(run, tasks, ciExecutionContext, linkId); | ||
// if the req body is > 20mb, remove hashDetails | ||
if (uncompressedBodyString.length > 20 * 1000 * 1000) { | ||
uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))), ciExecutionContext, linkId); | ||
} | ||
const uncompressedBuffer = Buffer.from(uncompressedBodyString); | ||
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer); | ||
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun'); | ||
try { | ||
if (environment_1.VERBOSE_LOGGING) { | ||
const t = tasks.map((tt) => { | ||
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput | ||
? `${tt.terminalOutput.slice(0, 20)}...` | ||
: undefined }); | ||
}); | ||
output.note({ | ||
title: 'RunEnd. Completed tasks', | ||
bodyLines: ['\n' + JSON.stringify(t, null, 2)], | ||
}); | ||
} | ||
const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, { | ||
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }), | ||
}))); | ||
if (resp) { | ||
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp)); | ||
if (resp.data && resp.data.runUrl && resp.data.status === 'success') { | ||
this.runContext.runUrl = resp.data.runUrl; | ||
return true; | ||
} | ||
if (resp.data && resp.data.status) { | ||
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`; | ||
} | ||
else if (resp.data && typeof resp.data === 'string') { | ||
if (resp.data !== 'success') { | ||
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`; | ||
} | ||
} | ||
else { | ||
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`; | ||
} | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: 'Invalid end run response', | ||
bodyLines: [JSON.stringify(resp.data, null, 2)], | ||
}); | ||
} | ||
} | ||
else { | ||
output.error({ | ||
title: 'Nx Cloud: Unknown Error Occurred', | ||
bodyLines: [ | ||
'Run completion responded with `undefined`.', | ||
'Run Details:', | ||
JSON.stringify(run, null, 2), | ||
'Stack Trace:', | ||
JSON.stringify(new Error().stack, null, 2), | ||
], | ||
}); | ||
} | ||
return false; | ||
} | ||
catch (ee) { | ||
recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response) | ||
? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response) | ||
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY); | ||
const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee; | ||
this.messages.apiError = this.messages.extractErrorMessage(e, 'api'); | ||
return false; | ||
} | ||
}); | ||
} | ||
nxCloudVersion() { | ||
try { | ||
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString()); | ||
return (v.devDependencies['nx-cloud'] || v.devDependencies['@nrwl/nx-cloud']); | ||
} | ||
catch (e) { | ||
return 'unknown'; | ||
} | ||
} | ||
} | ||
exports.CloudRunApi = CloudRunApi; | ||
//# sourceMappingURL=cloud-run.api.js.map | ||
const a3_0x1a77=['value','uploadedToStorage','Stack\x20Trace:','note','printDuration','apply','RunEnd.\x20Completed\x20tasks','application/octet-stream','../../../utilities/is-private-cloud','isConnectedToPrivateCloud','length','data','gzip','createReqBody','message','messages','devDependencies','toString','map','__awaiter','assign','defaults','util','/nx-cloud/runs/end','getCIExecutionEnv','mapRespToPerfEntry','recordMetric','Run\x20completion\x20responded\x20with\x20`undefined`.','api','axiosException','stringify','promisify','urls','../../../utilities/environment','post','getBranch','next','Run\x20Details:','getRunGroup','__esModule','CloudRunApi','zlib','RunStart','startRun','apiError','terminalOutput','stack','runContext','Invalid\x20end\x20run\x20response','VERBOSE_LOGGING','apiAxiosInstance','../../../utilities/metric-logger','error','...','RunEnd\x20duration','throw','RUNNER_FAILURE_PERF_ENTRY','unknown','Invalid\x20end\x20run\x20response:\x20','endRun','../../../utilities/axios','Invalid\x20Nx\x20Cloud\x20response:\x20','status','machineInfo','createApiAxiosInstance','done','package.json','response','then','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','extractErrorMessage','RunStart\x20duration','slice','headers','defineProperty','nxCloudVersion','success','string','/nx-cloud/runs/start','getCIExecutionId'];(function(_0x30c87f,_0x1a7735){const _0x5e2688=function(_0xe3b9d0){while(--_0xe3b9d0){_0x30c87f['push'](_0x30c87f['shift']());}};_0x5e2688(++_0x1a7735);}(a3_0x1a77,0x131));const a3_0x5e26=function(_0x30c87f,_0x1a7735){_0x30c87f=_0x30c87f-0x0;let _0x5e2688=a3_0x1a77[_0x30c87f];return _0x5e2688;};'use strict';var __awaiter=this&&this[a3_0x5e26('0x22')]||function(_0x3fe715,_0x54fa50,_0x3d0054,_0x39eab9){function _0x5d46b6(_0x37c6bc){return _0x37c6bc instanceof _0x3d0054?_0x37c6bc:new _0x3d0054(function(_0x29be06){_0x29be06(_0x37c6bc);});}return new(_0x3d0054||(_0x3d0054=Promise))(function(_0x4a79cb,_0x2a5023){function _0x144858(_0x55d922){try{_0x5e9b7e(_0x39eab9[a3_0x5e26('0x33')](_0x55d922));}catch(_0xe55d22){_0x2a5023(_0xe55d22);}}function _0x300cbe(_0xa0676f){try{_0x5e9b7e(_0x39eab9[a3_0x5e26('0x46')](_0xa0676f));}catch(_0x30eb90){_0x2a5023(_0x30eb90);}}function _0x5e9b7e(_0x509bba){_0x509bba[a3_0x5e26('0x0')]?_0x4a79cb(_0x509bba[a3_0x5e26('0xf')]):_0x5d46b6(_0x509bba[a3_0x5e26('0xf')])[a3_0x5e26('0x3')](_0x144858,_0x300cbe);}_0x5e9b7e((_0x39eab9=_0x39eab9[a3_0x5e26('0x14')](_0x3fe715,_0x54fa50||[]))[a3_0x5e26('0x33')]());});};Object[a3_0x5e26('0x9')](exports,a3_0x5e26('0x36'),{'value':!![]});exports[a3_0x5e26('0x37')]=void 0x0;const axios_1=require(a3_0x5e26('0x4b'));const environment_1=require(a3_0x5e26('0x30'));const fs_1=require('fs');const zlib_1=require(a3_0x5e26('0x38'));const util_1=require(a3_0x5e26('0x25'));const metric_logger_1=require(a3_0x5e26('0x42'));const is_private_cloud_1=require(a3_0x5e26('0x17'));const {output}=require('../../../utilities/nx-imports');class CloudRunApi{constructor(_0x195356,_0x168a5a,_0x3e77f3,_0x5cfef3){this[a3_0x5e26('0x1e')]=_0x195356;this['runContext']=_0x168a5a;this[a3_0x5e26('0x4e')]=_0x5cfef3;this['apiAxiosInstance']=(0x0,axios_1[a3_0x5e26('0x4f')])(_0x3e77f3);}[a3_0x5e26('0x3a')](_0x2d06b8,_0x4ba7e2){var _0x542268;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x5e26('0x1e')]['apiError'])return{};const _0x198b5b=(0x0,metric_logger_1['createMetricRecorder'])(a3_0x5e26('0x3a'));try{const _0x510b85={'meta':{'nxCloudVersion':this[a3_0x5e26('0xa')]()},'branch':(0x0,environment_1[a3_0x5e26('0x32')])(),'runGroup':(0x0,environment_1[a3_0x5e26('0x35')])(),'ciExecutionId':(0x0,environment_1[a3_0x5e26('0xe')])(),'ciExecutionEnv':(0x0,environment_1[a3_0x5e26('0x27')])(),'distributedExecutionId':_0x2d06b8,'hashes':_0x4ba7e2};if(environment_1[a3_0x5e26('0x40')]){output[a3_0x5e26('0x12')]({'title':a3_0x5e26('0x39'),'bodyLines':['\x0a'+JSON['stringify'](_0x510b85,null,0x2)]});}const _0x3b54ad=yield(0x0,axios_1[a3_0x5e26('0x13')])(a3_0x5e26('0x6'),()=>(0x0,axios_1['axiosMultipleTries'])(()=>this[a3_0x5e26('0x41')][a3_0x5e26('0x31')](a3_0x5e26('0xd'),_0x510b85)));_0x198b5b[a3_0x5e26('0x29')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x3b54ad));if(_0x3b54ad[a3_0x5e26('0x1a')]&&_0x3b54ad[a3_0x5e26('0x1a')]['message']){this[a3_0x5e26('0x1e')][a3_0x5e26('0x1d')]=_0x3b54ad[a3_0x5e26('0x1a')][a3_0x5e26('0x1d')];}if(!_0x3b54ad[a3_0x5e26('0x1a')]||!_0x3b54ad['data'][a3_0x5e26('0x2f')]){this[a3_0x5e26('0x1e')]['apiError']=a3_0x5e26('0x4c')+JSON['stringify'](_0x3b54ad['data']);return{};}return _0x3b54ad[a3_0x5e26('0x1a')][a3_0x5e26('0x2f')];}catch(_0x2282d8){_0x198b5b[a3_0x5e26('0x29')](((_0x542268=_0x2282d8===null||_0x2282d8===void 0x0?void 0x0:_0x2282d8[a3_0x5e26('0x2c')])===null||_0x542268===void 0x0?void 0x0:_0x542268['response'])?(0x0,metric_logger_1[a3_0x5e26('0x28')])(_0x2282d8[a3_0x5e26('0x2c')]['response']):metric_logger_1[a3_0x5e26('0x47')]);this[a3_0x5e26('0x1e')][a3_0x5e26('0x3b')]=this[a3_0x5e26('0x1e')][a3_0x5e26('0x5')](_0x2282d8,a3_0x5e26('0x2b'));return{};}});}[a3_0x5e26('0x1c')](_0x3893fa,_0x11a0a0,_0x1efbad,_0x5c4179){if((0x0,is_private_cloud_1[a3_0x5e26('0x18')])()){for(let _0x5e578f of _0x11a0a0){delete _0x5e578f[a3_0x5e26('0x10')];}}const _0xb5786d=Object[a3_0x5e26('0x23')](Object[a3_0x5e26('0x23')]({'meta':{'nxCloudVersion':this[a3_0x5e26('0xa')]()},'tasks':_0x11a0a0,'run':_0x3893fa,'linkId':_0x5c4179},(0x0,is_private_cloud_1[a3_0x5e26('0x18')])()?{}:_0x1efbad),{'machineInfo':this[a3_0x5e26('0x4e')]});return JSON[a3_0x5e26('0x2d')](_0xb5786d);}[a3_0x5e26('0x4a')](_0x79c23b,_0x2a49e8,_0x272978,_0x28da55){var _0x4eb1cd,_0xbf5b4a;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x5e26('0x1e')][a3_0x5e26('0x3b')])return![];let _0x1fe0ea=this[a3_0x5e26('0x1c')](_0x79c23b,_0x2a49e8,_0x272978,_0x28da55);if(_0x1fe0ea[a3_0x5e26('0x19')]>0x14*0x3e8*0x3e8){_0x1fe0ea=this[a3_0x5e26('0x1c')](_0x79c23b,_0x2a49e8[a3_0x5e26('0x21')](_0x25de60=>Object[a3_0x5e26('0x23')](Object['assign']({},_0x25de60),{'hashDetails':undefined})),_0x272978,_0x28da55);}const _0x5e0c79=Buffer['from'](_0x1fe0ea);const _0x3b0f9d=yield(0x0,util_1[a3_0x5e26('0x2e')])(zlib_1[a3_0x5e26('0x1b')])(_0x5e0c79);const _0x1cd780=(0x0,metric_logger_1['createMetricRecorder'])('endRun');try{if(environment_1['VERBOSE_LOGGING']){const _0x44c760=_0x2a49e8[a3_0x5e26('0x21')](_0x1caccc=>{return Object[a3_0x5e26('0x23')](Object[a3_0x5e26('0x23')]({},_0x1caccc),{'terminalOutput':_0x1caccc[a3_0x5e26('0x3c')]?_0x1caccc[a3_0x5e26('0x3c')][a3_0x5e26('0x7')](0x0,0x14)+a3_0x5e26('0x44'):undefined});});output[a3_0x5e26('0x12')]({'title':a3_0x5e26('0x15'),'bodyLines':['\x0a'+JSON[a3_0x5e26('0x2d')](_0x44c760,null,0x2)]});}const _0xf5aa0f=yield(0x0,axios_1[a3_0x5e26('0x13')])(a3_0x5e26('0x45'),()=>(0x0,axios_1['axiosMultipleTries'])(()=>this['apiAxiosInstance'][a3_0x5e26('0x31')](a3_0x5e26('0x26'),_0x3b0f9d,{'headers':Object[a3_0x5e26('0x23')](Object[a3_0x5e26('0x23')]({},this[a3_0x5e26('0x41')][a3_0x5e26('0x24')][a3_0x5e26('0x8')]),{'Content-Encoding':'gzip','Content-Type':a3_0x5e26('0x16')})})));if(_0xf5aa0f){_0x1cd780[a3_0x5e26('0x29')]((0x0,metric_logger_1[a3_0x5e26('0x28')])(_0xf5aa0f));if(_0xf5aa0f[a3_0x5e26('0x1a')]&&_0xf5aa0f[a3_0x5e26('0x1a')]['runUrl']&&_0xf5aa0f[a3_0x5e26('0x1a')][a3_0x5e26('0x4d')]==='success'){this[a3_0x5e26('0x3e')]['runUrl']=_0xf5aa0f['data']['runUrl'];return!![];}if(_0xf5aa0f['data']&&_0xf5aa0f[a3_0x5e26('0x1a')][a3_0x5e26('0x4d')]){this[a3_0x5e26('0x1e')]['apiError']=a3_0x5e26('0x49')+JSON['stringify'](_0xf5aa0f[a3_0x5e26('0x1a')]['message']);}else if(_0xf5aa0f[a3_0x5e26('0x1a')]&&typeof _0xf5aa0f[a3_0x5e26('0x1a')]===a3_0x5e26('0xc')){if(_0xf5aa0f[a3_0x5e26('0x1a')]!==a3_0x5e26('0xb')){this['messages'][a3_0x5e26('0x3b')]=a3_0x5e26('0x49')+JSON[a3_0x5e26('0x2d')](_0xf5aa0f[a3_0x5e26('0x1a')]);}}else{this[a3_0x5e26('0x1e')][a3_0x5e26('0x3b')]=a3_0x5e26('0x49')+JSON['stringify'](_0xf5aa0f[a3_0x5e26('0x1a')]);}if(environment_1[a3_0x5e26('0x40')]){output[a3_0x5e26('0x12')]({'title':a3_0x5e26('0x3f'),'bodyLines':[JSON[a3_0x5e26('0x2d')](_0xf5aa0f[a3_0x5e26('0x1a')],null,0x2)]});}}else{output[a3_0x5e26('0x43')]({'title':a3_0x5e26('0x4'),'bodyLines':[a3_0x5e26('0x2a'),a3_0x5e26('0x34'),JSON[a3_0x5e26('0x2d')](_0x79c23b,null,0x2),a3_0x5e26('0x11'),JSON['stringify'](new Error()[a3_0x5e26('0x3d')],null,0x2)]});}return![];}catch(_0x5c149c){_0x1cd780[a3_0x5e26('0x29')](((_0x4eb1cd=_0x5c149c===null||_0x5c149c===void 0x0?void 0x0:_0x5c149c[a3_0x5e26('0x2c')])===null||_0x4eb1cd===void 0x0?void 0x0:_0x4eb1cd[a3_0x5e26('0x2')])?(0x0,metric_logger_1[a3_0x5e26('0x28')])(_0x5c149c['axiosException']['response']):metric_logger_1[a3_0x5e26('0x47')]);const _0x2a7b87=(_0xbf5b4a=_0x5c149c[a3_0x5e26('0x2c')])!==null&&_0xbf5b4a!==void 0x0?_0xbf5b4a:_0x5c149c;this['messages'][a3_0x5e26('0x3b')]=this[a3_0x5e26('0x1e')][a3_0x5e26('0x5')](_0x2a7b87,a3_0x5e26('0x2b'));return![];}});}[a3_0x5e26('0xa')](){try{const _0x2c87c5=JSON['parse']((0x0,fs_1['readFileSync'])(a3_0x5e26('0x1'))[a3_0x5e26('0x20')]());return _0x2c87c5[a3_0x5e26('0x1f')]['nx-cloud']||_0x2c87c5[a3_0x5e26('0x1f')]['@nrwl/nx-cloud'];}catch(_0x39ed5f){return a3_0x5e26('0x48');}}}exports[a3_0x5e26('0x37')]=CloudRunApi; |
@@ -1,16 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateUniqueLinkId = void 0; | ||
const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||
const digits = '0123456789'; | ||
const lower = upper.toLowerCase(); | ||
const alphanum = upper + lower + digits; | ||
function generateUniqueLinkId() { | ||
let res = ''; | ||
for (let i = 0; i < 10; ++i) { | ||
res += alphanum[Math.floor(Math.random() * alphanum.length)]; | ||
} | ||
return res; | ||
} | ||
exports.generateUniqueLinkId = generateUniqueLinkId; | ||
//# sourceMappingURL=id-generator.js.map | ||
const a4_0x3e60=['floor','toLowerCase','__esModule','defineProperty','0123456789','ABCDEFGHIJKLMNOPQRSTUVWXYZ','generateUniqueLinkId'];(function(_0x11e932,_0x3e60e8){const _0x3cd220=function(_0x13c9da){while(--_0x13c9da){_0x11e932['push'](_0x11e932['shift']());}};_0x3cd220(++_0x3e60e8);}(a4_0x3e60,0xaf));const a4_0x3cd2=function(_0x11e932,_0x3e60e8){_0x11e932=_0x11e932-0x0;let _0x3cd220=a4_0x3e60[_0x11e932];return _0x3cd220;};'use strict';Object[a4_0x3cd2('0x3')](exports,a4_0x3cd2('0x2'),{'value':!![]});exports['generateUniqueLinkId']=void 0x0;const upper=a4_0x3cd2('0x5');const digits=a4_0x3cd2('0x4');const lower=upper[a4_0x3cd2('0x1')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0xb7373c='';for(let _0x42a43e=0x0;_0x42a43e<0xa;++_0x42a43e){_0xb7373c+=alphanum[Math[a4_0x3cd2('0x0')](Math['random']()*alphanum['length'])];}return _0xb7373c;}exports[a4_0x3cd2('0x6')]=generateUniqueLinkId; |
@@ -1,93 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DistributedAgentApi = void 0; | ||
const axios_1 = require("../../../utilities/axios"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const metric_logger_1 = require("../../../utilities/metric-logger"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
class DistributedAgentApi { | ||
constructor(options, branch, runGroup, ciExecutionId, ciExecutionEnv, agentName) { | ||
this.branch = branch; | ||
this.runGroup = runGroup; | ||
this.ciExecutionId = ciExecutionId; | ||
this.ciExecutionEnv = ciExecutionEnv; | ||
this.agentName = agentName; | ||
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options); | ||
} | ||
tasks(executionId, statusCode, completedTasks, targets) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks'); | ||
try { | ||
const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', { | ||
runGroup: this.runGroup, | ||
ciExecutionId: this.ciExecutionId, | ||
ciExecutionEnv: this.ciExecutionEnv, | ||
agentName: this.agentName, | ||
executionId, | ||
statusCode, | ||
completedTasks, | ||
targets, | ||
})); | ||
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res)); | ||
return res.data; | ||
} | ||
catch (e) { | ||
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response) | ||
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response) | ||
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY); | ||
throw e; | ||
} | ||
}); | ||
} | ||
completeRunGroupWithError(error) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: 'Completing with an error', | ||
bodyLines: [ | ||
`ciExecutionId: ${this.ciExecutionId}`, | ||
`ciExecutionEnv: ${this.ciExecutionEnv}`, | ||
`runGroup: ${this.runGroup}`, | ||
`error: ${error}`, | ||
], | ||
}); | ||
} | ||
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup'); | ||
try { | ||
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', { | ||
branch: this.branch, | ||
runGroup: this.runGroup, | ||
ciExecutionId: this.ciExecutionId, | ||
ciExecutionEnv: this.ciExecutionEnv, | ||
agentName: this.agentName, | ||
criticalErrorMessage: error, | ||
})); | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: 'Completed run group with an error', | ||
}); | ||
} | ||
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp)); | ||
} | ||
catch (e) { | ||
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response) | ||
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response) | ||
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY); | ||
console.error(e); | ||
} | ||
}); | ||
} | ||
} | ||
exports.DistributedAgentApi = DistributedAgentApi; | ||
//# sourceMappingURL=distributed-agent.api.js.map | ||
const a5_0x2c93=['done','completeRunGroup','data','ciExecutionId','mapRespToPerfEntry','post','then','value','Completing\x20with\x20an\x20error','agentName','branch','DistributedAgentApi','RUNNER_FAILURE_PERF_ENTRY','runGroup:\x20','__esModule','recordMetric','throw','../../../utilities/metric-logger','Completed\x20run\x20group\x20with\x20an\x20error','defineProperty','note','ciExecutionId:\x20','createMetricRecorder','ciExecutionEnv','completeRunGroupWithError','apiAxiosInstance','VERBOSE_LOGGING','axiosMultipleTries','error','ciExecutionEnv:\x20','/nx-cloud/executions/complete-run-group','error:\x20','../../../utilities/nx-imports','next','response','dtePollTasks','runGroup','../../../utilities/environment','../../../utilities/axios'];(function(_0x112688,_0x2c93d3){const _0x5efd86=function(_0x567de2){while(--_0x567de2){_0x112688['push'](_0x112688['shift']());}};_0x5efd86(++_0x2c93d3);}(a5_0x2c93,0xac));const a5_0x5efd=function(_0x112688,_0x2c93d3){_0x112688=_0x112688-0x0;let _0x5efd86=a5_0x2c93[_0x112688];return _0x5efd86;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0xb7bea6,_0x4726ed,_0x35d130,_0x16eb19){function _0x3e1f04(_0x53c47d){return _0x53c47d instanceof _0x35d130?_0x53c47d:new _0x35d130(function(_0x29aeac){_0x29aeac(_0x53c47d);});}return new(_0x35d130||(_0x35d130=Promise))(function(_0x481fa5,_0x5e8659){function _0x29ba4d(_0x50edb7){try{_0x3af40d(_0x16eb19['next'](_0x50edb7));}catch(_0x262e1f){_0x5e8659(_0x262e1f);}}function _0x2ca9a7(_0x1f8efc){try{_0x3af40d(_0x16eb19[a5_0x5efd('0x0')](_0x1f8efc));}catch(_0x3a76af){_0x5e8659(_0x3a76af);}}function _0x3af40d(_0x3afd94){_0x3afd94[a5_0x5efd('0x17')]?_0x481fa5(_0x3afd94[a5_0x5efd('0x1e')]):_0x3e1f04(_0x3afd94[a5_0x5efd('0x1e')])[a5_0x5efd('0x1d')](_0x29ba4d,_0x2ca9a7);}_0x3af40d((_0x16eb19=_0x16eb19['apply'](_0xb7bea6,_0x4726ed||[]))[a5_0x5efd('0x11')]());});};Object[a5_0x5efd('0x3')](exports,a5_0x5efd('0x25'),{'value':!![]});exports[a5_0x5efd('0x22')]=void 0x0;const axios_1=require(a5_0x5efd('0x16'));const environment_1=require(a5_0x5efd('0x15'));const metric_logger_1=require(a5_0x5efd('0x1'));const {output}=require(a5_0x5efd('0x10'));class DistributedAgentApi{constructor(_0x4902e0,_0x13b63d,_0x14be29,_0x5c2dc6,_0x557b1f,_0x501bca){this['branch']=_0x13b63d;this['runGroup']=_0x14be29;this[a5_0x5efd('0x1a')]=_0x5c2dc6;this[a5_0x5efd('0x7')]=_0x557b1f;this[a5_0x5efd('0x20')]=_0x501bca;this[a5_0x5efd('0x9')]=(0x0,axios_1['createApiAxiosInstance'])(_0x4902e0);}['tasks'](_0x14c0de,_0xb91a53,_0x3d9816,_0x5cd2f1){var _0x315ebd;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x432150=(0x0,metric_logger_1['createMetricRecorder'])(a5_0x5efd('0x13'));try{const _0x5be4d5=yield(0x0,axios_1[a5_0x5efd('0xb')])(()=>this[a5_0x5efd('0x9')][a5_0x5efd('0x1c')]('/nx-cloud/executions/tasks',{'runGroup':this[a5_0x5efd('0x14')],'ciExecutionId':this[a5_0x5efd('0x1a')],'ciExecutionEnv':this[a5_0x5efd('0x7')],'agentName':this[a5_0x5efd('0x20')],'executionId':_0x14c0de,'statusCode':_0xb91a53,'completedTasks':_0x3d9816,'targets':_0x5cd2f1}));_0x432150[a5_0x5efd('0x26')]((0x0,metric_logger_1[a5_0x5efd('0x1b')])(_0x5be4d5));return _0x5be4d5[a5_0x5efd('0x19')];}catch(_0x54f710){_0x432150[a5_0x5efd('0x26')](((_0x315ebd=_0x54f710===null||_0x54f710===void 0x0?void 0x0:_0x54f710['axiosException'])===null||_0x315ebd===void 0x0?void 0x0:_0x315ebd[a5_0x5efd('0x12')])?(0x0,metric_logger_1[a5_0x5efd('0x1b')])(_0x54f710['axiosException'][a5_0x5efd('0x12')]):metric_logger_1[a5_0x5efd('0x23')]);throw _0x54f710;}});}[a5_0x5efd('0x8')](_0x5a9074){var _0x44a342;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a5_0x5efd('0xa')]){output['note']({'title':a5_0x5efd('0x1f'),'bodyLines':[a5_0x5efd('0x5')+this[a5_0x5efd('0x1a')],a5_0x5efd('0xd')+this['ciExecutionEnv'],a5_0x5efd('0x24')+this['runGroup'],a5_0x5efd('0xf')+_0x5a9074]});}const _0x58905e=(0x0,metric_logger_1[a5_0x5efd('0x6')])(a5_0x5efd('0x18'));try{const _0x54efd7=yield(0x0,axios_1[a5_0x5efd('0xb')])(()=>this[a5_0x5efd('0x9')][a5_0x5efd('0x1c')](a5_0x5efd('0xe'),{'branch':this[a5_0x5efd('0x21')],'runGroup':this[a5_0x5efd('0x14')],'ciExecutionId':this[a5_0x5efd('0x1a')],'ciExecutionEnv':this[a5_0x5efd('0x7')],'agentName':this['agentName'],'criticalErrorMessage':_0x5a9074}));if(environment_1[a5_0x5efd('0xa')]){output[a5_0x5efd('0x4')]({'title':a5_0x5efd('0x2')});}_0x58905e[a5_0x5efd('0x26')]((0x0,metric_logger_1[a5_0x5efd('0x1b')])(_0x54efd7));}catch(_0x3ab602){_0x58905e[a5_0x5efd('0x26')](((_0x44a342=_0x3ab602===null||_0x3ab602===void 0x0?void 0x0:_0x3ab602['axiosException'])===null||_0x44a342===void 0x0?void 0x0:_0x44a342[a5_0x5efd('0x12')])?(0x0,metric_logger_1[a5_0x5efd('0x1b')])(_0x3ab602['axiosException'][a5_0x5efd('0x12')]):metric_logger_1[a5_0x5efd('0x23')]);console[a5_0x5efd('0xc')](_0x3ab602);}});}}exports[a5_0x5efd('0x22')]=DistributedAgentApi; |
@@ -1,158 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.startAgent = void 0; | ||
const fs_1 = require("fs"); | ||
const stripJsonComments = require("strip-json-comments"); | ||
const yargsParser = require("yargs-parser"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const metric_logger_1 = require("../../../utilities/metric-logger"); | ||
const print_cacheable_targets_error_1 = require("../../error/print-cacheable-targets-error"); | ||
const print_invalid_runner_error_1 = require("../../error/print-invalid-runner-error"); | ||
const print_run_group_error_1 = require("../../error/print-run-group-error"); | ||
const distributed_agent_api_1 = require("./distributed-agent.api"); | ||
const execute_tasks_1 = require("./execute-tasks"); | ||
const dte_artifact_storage_1 = require("../../../utilities/dte-artifact-storage"); | ||
const file_storage_1 = require("../../file-storage/file-storage"); | ||
const e2e_encryption_1 = require("../../file-storage/e2e-encryption"); | ||
const error_reporter_api_1 = require("../../api/error-reporter.api"); | ||
const invoke_tasks_using_run_many_1 = require("./invoke-tasks-using-run-many"); | ||
const invoke_tasks_using_nx_imperative_api_1 = require("./invoke-tasks-using-nx-imperative-api"); | ||
const { output, initTasksRunner, workspaceRoot, } = require('../../../utilities/nx-imports'); | ||
const args = yargsParser(process.argv, { | ||
array: ['targets'], | ||
default: {}, | ||
}); | ||
// just in case someone passes the args with commas | ||
// cf. https://github.com/yargs/yargs/issues/846 | ||
if (args.targets && args.targets.length === 1) { | ||
args.targets = args.targets[0].split(',').map((x) => x.trim()); | ||
} | ||
function startAgent() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const branch = (0, environment_1.getBranch)(); | ||
const runGroup = (0, environment_1.getRunGroup)(); | ||
const ciExecutionId = (0, environment_1.getCIExecutionId)(); | ||
const ciExecutionEnv = (0, environment_1.getCIExecutionEnv)(); | ||
if (!(0, print_run_group_error_1.canDetectRunGroup)(runGroup, ciExecutionId)) { | ||
(0, print_run_group_error_1.printRunGroupError)(); | ||
process.exit(1); | ||
} | ||
if (args.targets && args.targets.length) { | ||
output.note({ | ||
title: `Starting an agent for running Nx target(s) [${args.targets.join(', ')}]`, | ||
}); | ||
} | ||
else { | ||
output.note({ | ||
title: 'Starting an agent for running Nx tasks', | ||
}); | ||
} | ||
const defaultRunnerConfig = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default; | ||
if (defaultRunnerConfig.runner !== 'nx-cloud' && | ||
defaultRunnerConfig.runner !== '@nrwl/nx-cloud') { | ||
(0, print_invalid_runner_error_1.printInvalidRunnerError)(); | ||
return process.exit(1); | ||
} | ||
const options = defaultRunnerConfig.options; | ||
if (args.targets && | ||
args.targets.some((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); })) { | ||
const wrongTargets = args.targets.filter((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); }); | ||
(0, print_cacheable_targets_error_1.printCacheableTargetsError)(wrongTargets); | ||
return process.exit(1); | ||
} | ||
const agentName = getAgentName(); | ||
const api = new distributed_agent_api_1.DistributedAgentApi(options, branch, runGroup, ciExecutionId, ciExecutionEnv, agentName); | ||
createAgentLockfileAndSetUpListeners(api, options, agentName); | ||
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey); | ||
const errorReporter = new error_reporter_api_1.ErrorReporterApi(options); | ||
const dteArtifactStorage = new dte_artifact_storage_1.DteArtifactStorage(new file_storage_1.FileStorage(encryption, errorReporter, options, 'dte-agent'), (0, environment_1.getNxCacheDirectory)(options)); | ||
const invokeTasks = initTasksRunner | ||
? yield (0, invoke_tasks_using_nx_imperative_api_1.invokeTasksUsingNxImperativeApi)(options) | ||
: yield (0, invoke_tasks_using_run_many_1.invokeTasksUsingRunMany)(options); | ||
return (0, execute_tasks_1.executeTasks)(agentName, api, dteArtifactStorage, invokeTasks, args.targets) | ||
.then((res) => __awaiter(this, void 0, void 0, function* () { | ||
yield (0, metric_logger_1.submitRunMetrics)(options); | ||
return res; | ||
})) | ||
.catch((e) => __awaiter(this, void 0, void 0, function* () { | ||
yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`); | ||
throw e; | ||
})); | ||
}); | ||
} | ||
exports.startAgent = startAgent; | ||
function getAgentName() { | ||
if (process.env.NX_AGENT_NAME !== undefined) { | ||
return process.env.NX_AGENT_NAME; | ||
} | ||
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_STAGE) { | ||
return process.env.CIRCLE_STAGE; | ||
} | ||
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_JOB) { | ||
return process.env.CIRCLE_JOB; | ||
} | ||
else { | ||
return `Agent ${Math.floor(Math.random() * 100000)}`; | ||
} | ||
} | ||
function createAgentLockfileAndSetUpListeners(api, options, agentName) { | ||
const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options); | ||
const lockFileDirectory = `${cacheDirectory}/lockfiles`; | ||
const lockFilePath = `${lockFileDirectory}/${agentName}.lock`; | ||
if (!(0, fs_1.existsSync)(lockFileDirectory)) { | ||
(0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true }); | ||
} | ||
// Check for other agents' lockfiles and warn if exist | ||
const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory); | ||
if (lockFiles.length) { | ||
// Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this) | ||
if (lockFiles.includes(`${agentName}.lock`)) { | ||
output.error({ | ||
title: 'Duplicate Agent ID Detected', | ||
bodyLines: [ | ||
'We have detected another agent with this ID running in this workspace. This should not happen.', | ||
'', | ||
'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.', | ||
], | ||
}); | ||
process.exit(1); | ||
} | ||
output.warn({ | ||
title: 'Other Nx Cloud Agents Detected', | ||
bodyLines: [ | ||
'We have detected other agents running in this workspace. This can cause unexpected behavior.', | ||
'', | ||
'This can also be a false positive caused by agents that did not shut down correctly.', | ||
'If you believe this is the case, run "npx nx-cloud clean-up-agents".', | ||
], | ||
}); | ||
} | ||
(0, fs_1.writeFileSync)(lockFilePath, ''); | ||
process.on('exit', (code) => { | ||
cleanupAgentLockfile(lockFilePath, code); | ||
}); | ||
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () { | ||
yield api.completeRunGroupWithError('Agent was terminated via SIGTERM'); | ||
cleanupAgentLockfile(lockFilePath, 1); | ||
})); | ||
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () { | ||
yield api.completeRunGroupWithError('Agent was terminated via SIGINT'); | ||
cleanupAgentLockfile(lockFilePath, 1); | ||
})); | ||
} | ||
function cleanupAgentLockfile(lockFilePath, code) { | ||
if ((0, fs_1.existsSync)(lockFilePath)) { | ||
(0, fs_1.unlinkSync)(lockFilePath); | ||
process.exit(code); | ||
} | ||
} | ||
//# sourceMappingURL=distributed-agent.impl.js.map | ||
const a6_0x3f79=['Agent\x20','./invoke-tasks-using-nx-imperative-api','../../error/print-cacheable-targets-error','cacheableOperations','join','getBranch','strip-json-comments','E2EEncryption','canDetectRunGroup','tasksRunnerOptions','getCIExecutionId','filter','../../error/print-run-group-error','apply','/nx.json','printRunGroupError','encryptionKey','writeFileSync','dte-agent','../../../utilities/environment','CIRCLECI','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','Agent\x20was\x20terminated\x20via\x20SIGINT','executeTasks','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','value','NX_AGENT_NAME','Agent\x20was\x20terminated\x20via\x20SIGTERM','../../error/print-invalid-runner-error','.lock','__awaiter','printCacheableTargetsError','completeRunGroupWithError','DteArtifactStorage','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20[','__esModule','CIRCLE_STAGE','note','length','./distributed-agent.api','invokeTasksUsingNxImperativeApi','map','../../file-storage/e2e-encryption','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','../../api/error-reporter.api','../../../utilities/nx-imports','env','readdirSync','defineProperty','ErrorReporterApi','Duplicate\x20Agent\x20ID\x20Detected','some','next','targets','default','./execute-tasks','DistributedAgentApi','then','trim','submitRunMetrics','ENCRYPTION_KEY','getNxCacheDirectory','startAgent','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','FileStorage','random','done','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','../../../utilities/metric-logger','runner','../../../utilities/dte-artifact-storage','./invoke-tasks-using-run-many','invokeTasksUsingRunMany','Critical\x20Error\x20in\x20Agent:\x20\x22','exit','SIGINT','getCIExecutionEnv','@nrwl/nx-cloud','parse','options'];(function(_0x20e953,_0x3f79fc){const _0x208893=function(_0x2e0091){while(--_0x2e0091){_0x20e953['push'](_0x20e953['shift']());}};_0x208893(++_0x3f79fc);}(a6_0x3f79,0xee));const a6_0x2088=function(_0x20e953,_0x3f79fc){_0x20e953=_0x20e953-0x0;let _0x208893=a6_0x3f79[_0x20e953];return _0x208893;};'use strict';var __awaiter=this&&this[a6_0x2088('0x20')]||function(_0x354212,_0x4f7fa2,_0x1895bc,_0x53c6de){function _0x4132e8(_0xdc8a4b){return _0xdc8a4b instanceof _0x1895bc?_0xdc8a4b:new _0x1895bc(function(_0x5b6d73){_0x5b6d73(_0xdc8a4b);});}return new(_0x1895bc||(_0x1895bc=Promise))(function(_0x1dffba,_0x2efda2){function _0x587367(_0x3de4ac){try{_0x168e3a(_0x53c6de[a6_0x2088('0x36')](_0x3de4ac));}catch(_0x47640d){_0x2efda2(_0x47640d);}}function _0x568023(_0x57cb95){try{_0x168e3a(_0x53c6de['throw'](_0x57cb95));}catch(_0x141aa1){_0x2efda2(_0x141aa1);}}function _0x168e3a(_0x55a26f){_0x55a26f[a6_0x2088('0x44')]?_0x1dffba(_0x55a26f[a6_0x2088('0x1b')]):_0x4132e8(_0x55a26f[a6_0x2088('0x1b')])[a6_0x2088('0x3b')](_0x587367,_0x568023);}_0x168e3a((_0x53c6de=_0x53c6de[a6_0x2088('0xf')](_0x354212,_0x4f7fa2||[]))['next']());});};Object[a6_0x2088('0x32')](exports,a6_0x2088('0x25'),{'value':!![]});exports[a6_0x2088('0x40')]=void 0x0;const fs_1=require('fs');const stripJsonComments=require(a6_0x2088('0x8'));const yargsParser=require('yargs-parser');const environment_1=require(a6_0x2088('0x15'));const metric_logger_1=require(a6_0x2088('0x46'));const print_cacheable_targets_error_1=require(a6_0x2088('0x4'));const print_invalid_runner_error_1=require(a6_0x2088('0x1e'));const print_run_group_error_1=require(a6_0x2088('0xe'));const distributed_agent_api_1=require(a6_0x2088('0x29'));const execute_tasks_1=require(a6_0x2088('0x39'));const dte_artifact_storage_1=require(a6_0x2088('0x48'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a6_0x2088('0x2c'));const error_reporter_api_1=require(a6_0x2088('0x2e'));const invoke_tasks_using_run_many_1=require(a6_0x2088('0x49'));const invoke_tasks_using_nx_imperative_api_1=require(a6_0x2088('0x3'));const {output,initTasksRunner,workspaceRoot}=require(a6_0x2088('0x2f'));const args=yargsParser(process['argv'],{'array':[a6_0x2088('0x37')],'default':{}});if(args[a6_0x2088('0x37')]&&args[a6_0x2088('0x37')]['length']===0x1){args[a6_0x2088('0x37')]=args[a6_0x2088('0x37')][0x0]['split'](',')[a6_0x2088('0x2b')](_0x29b3ff=>_0x29b3ff[a6_0x2088('0x3c')]());}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1a9ff4=(0x0,environment_1[a6_0x2088('0x7')])();const _0x2b3b0d=(0x0,environment_1['getRunGroup'])();const _0x5b2007=(0x0,environment_1[a6_0x2088('0xc')])();const _0x26ceae=(0x0,environment_1[a6_0x2088('0x4e')])();if(!(0x0,print_run_group_error_1[a6_0x2088('0xa')])(_0x2b3b0d,_0x5b2007)){(0x0,print_run_group_error_1[a6_0x2088('0x11')])();process[a6_0x2088('0x4c')](0x1);}if(args[a6_0x2088('0x37')]&&args[a6_0x2088('0x37')][a6_0x2088('0x28')]){output[a6_0x2088('0x27')]({'title':a6_0x2088('0x24')+args[a6_0x2088('0x37')][a6_0x2088('0x6')](',\x20')+']'});}else{output[a6_0x2088('0x27')]({'title':a6_0x2088('0x45')});}const _0x45fc9c=JSON[a6_0x2088('0x0')](stripJsonComments((0x0,fs_1['readFileSync'])(workspaceRoot+a6_0x2088('0x10'))['toString']()))[a6_0x2088('0xb')][a6_0x2088('0x38')];if(_0x45fc9c['runner']!=='nx-cloud'&&_0x45fc9c[a6_0x2088('0x47')]!==a6_0x2088('0x4f')){(0x0,print_invalid_runner_error_1['printInvalidRunnerError'])();return process['exit'](0x1);}const _0x4d33ce=_0x45fc9c[a6_0x2088('0x1')];if(args[a6_0x2088('0x37')]&&args[a6_0x2088('0x37')][a6_0x2088('0x35')](_0x273224=>{var _0x20ddb0;return!((_0x20ddb0=_0x4d33ce['cacheableOperations'])===null||_0x20ddb0===void 0x0?void 0x0:_0x20ddb0['includes'](_0x273224));})){const _0x244b97=args['targets'][a6_0x2088('0xd')](_0x548ac8=>{var _0x5b17ac;return!((_0x5b17ac=_0x4d33ce[a6_0x2088('0x5')])===null||_0x5b17ac===void 0x0?void 0x0:_0x5b17ac['includes'](_0x548ac8));});(0x0,print_cacheable_targets_error_1[a6_0x2088('0x21')])(_0x244b97);return process[a6_0x2088('0x4c')](0x1);}const _0x3c3904=getAgentName();const _0x36a062=new distributed_agent_api_1[(a6_0x2088('0x3a'))](_0x4d33ce,_0x1a9ff4,_0x2b3b0d,_0x5b2007,_0x26ceae,_0x3c3904);createAgentLockfileAndSetUpListeners(_0x36a062,_0x4d33ce,_0x3c3904);const _0x58c551=new e2e_encryption_1[(a6_0x2088('0x9'))](environment_1[a6_0x2088('0x3e')]||_0x4d33ce[a6_0x2088('0x12')]);const _0x58e45f=new error_reporter_api_1[(a6_0x2088('0x33'))](_0x4d33ce);const _0x5d9165=new dte_artifact_storage_1[(a6_0x2088('0x23'))](new file_storage_1[(a6_0x2088('0x42'))](_0x58c551,_0x58e45f,_0x4d33ce,a6_0x2088('0x14')),(0x0,environment_1[a6_0x2088('0x3f')])(_0x4d33ce));const _0x38f394=initTasksRunner?yield(0x0,invoke_tasks_using_nx_imperative_api_1[a6_0x2088('0x2a')])(_0x4d33ce):yield(0x0,invoke_tasks_using_run_many_1[a6_0x2088('0x4a')])(_0x4d33ce);return(0x0,execute_tasks_1[a6_0x2088('0x19')])(_0x3c3904,_0x36a062,_0x5d9165,_0x38f394,args[a6_0x2088('0x37')])[a6_0x2088('0x3b')](_0x5a9637=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a6_0x2088('0x3d')])(_0x4d33ce);return _0x5a9637;}))['catch'](_0x1088c3=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x36a062[a6_0x2088('0x22')](a6_0x2088('0x4b')+_0x1088c3['message']+'\x22');throw _0x1088c3;}));});}exports[a6_0x2088('0x40')]=startAgent;function getAgentName(){if(process['env'][a6_0x2088('0x1c')]!==undefined){return process[a6_0x2088('0x30')][a6_0x2088('0x1c')];}else if(process[a6_0x2088('0x30')][a6_0x2088('0x16')]!==undefined&&process[a6_0x2088('0x30')][a6_0x2088('0x26')]){return process[a6_0x2088('0x30')]['CIRCLE_STAGE'];}else if(process[a6_0x2088('0x30')][a6_0x2088('0x16')]!==undefined&&process[a6_0x2088('0x30')]['CIRCLE_JOB']){return process['env']['CIRCLE_JOB'];}else{return a6_0x2088('0x2')+Math['floor'](Math[a6_0x2088('0x43')]()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x3a732e,_0x13c797,_0x2650c8){const _0x39d4fb=(0x0,environment_1['getNxCacheDirectory'])(_0x13c797);const _0x1b874f=_0x39d4fb+'/lockfiles';const _0x51c2f6=_0x1b874f+'/'+_0x2650c8+a6_0x2088('0x1f');if(!(0x0,fs_1['existsSync'])(_0x1b874f)){(0x0,fs_1['mkdirSync'])(_0x1b874f,{'recursive':!![]});}const _0x39e709=(0x0,fs_1[a6_0x2088('0x31')])(_0x1b874f);if(_0x39e709[a6_0x2088('0x28')]){if(_0x39e709['includes'](_0x2650c8+a6_0x2088('0x1f'))){output['error']({'title':a6_0x2088('0x34'),'bodyLines':[a6_0x2088('0x41'),'',a6_0x2088('0x2d')]});process[a6_0x2088('0x4c')](0x1);}output['warn']({'title':'Other\x20Nx\x20Cloud\x20Agents\x20Detected','bodyLines':[a6_0x2088('0x17'),'',a6_0x2088('0x1a'),'If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.']});}(0x0,fs_1[a6_0x2088('0x13')])(_0x51c2f6,'');process['on'](a6_0x2088('0x4c'),_0x50478c=>{cleanupAgentLockfile(_0x51c2f6,_0x50478c);});process['on']('SIGTERM',()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x3a732e[a6_0x2088('0x22')](a6_0x2088('0x1d'));cleanupAgentLockfile(_0x51c2f6,0x1);}));process['on'](a6_0x2088('0x4d'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x3a732e[a6_0x2088('0x22')](a6_0x2088('0x18'));cleanupAgentLockfile(_0x51c2f6,0x1);}));}function cleanupAgentLockfile(_0x278346,_0x147c3b){if((0x0,fs_1['existsSync'])(_0x278346)){(0x0,fs_1['unlinkSync'])(_0x278346);process[a6_0x2088('0x4c')](_0x147c3b);}} |
@@ -1,114 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.executeTasks = void 0; | ||
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const waiter_1 = require("../../../utilities/waiter"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
function executeTasks(agentName, api, dteArtifactStorage, invokeTasks, targets) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let completedStatusCode = 0; | ||
let apiResponse = null; | ||
const failIfSameTasksAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({ | ||
title: `No new messages received after ${environment_1.NO_MESSAGES_TIMEOUT / 1000} seconds`, | ||
timeout: environment_1.NO_MESSAGES_TIMEOUT, | ||
}); | ||
const waiter = new waiter_1.Waiter(); | ||
let completedTasks = []; | ||
const startTime = new Date(); | ||
let executedAnyTasks = false; | ||
const processedTasks = {}; | ||
while (true) { | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: `${agentName} fetching tasks...`, | ||
}); | ||
} | ||
apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks, targets); | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: `${agentName} received an API Response`, | ||
bodyLines: [ | ||
`completed: ${apiResponse.completed}`, | ||
`status: ${apiResponse.status}`, | ||
`retryDuring: ${apiResponse.retryDuring}`, | ||
`executionId: ${apiResponse.executionId}`, | ||
`number of tasks: ${apiResponse.tasks.length}`, | ||
`error: ${apiResponse.criticalErrorMessage}`, | ||
`maxParallel: ${apiResponse.maxParallel}`, | ||
], | ||
}); | ||
} | ||
if (apiResponse.criticalErrorMessage) { | ||
output.error({ | ||
title: 'Distributed Execution Terminated', | ||
bodyLines: ['Error:', apiResponse.criticalErrorMessage], | ||
}); | ||
process.exit(0); | ||
} | ||
// run group is completed but it might be a rerun | ||
// we will try several times before going further and | ||
// completed the response | ||
// we only do it if we haven't executed any tasks | ||
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) && | ||
(apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 && | ||
!executedAnyTasks && | ||
new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) { | ||
yield waiter.wait(); | ||
continue; | ||
} | ||
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.status) !== undefined) { | ||
if (apiResponse.status === 'RUN_GROUP_COMPLETED' || | ||
apiResponse.status === 'NO_FURTHER_TASKS_TO_RUN') { | ||
return; | ||
} | ||
} | ||
else if (apiResponse.completed) { | ||
return; | ||
} | ||
// if status is present that use the status instead of completed, otherwise use completed | ||
failIfSameTasksAfterTimeout(apiResponse.tasks.map((t) => t.taskId).join('')); | ||
if (!apiResponse.executionId) { | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: `${agentName} waiting...`, | ||
}); | ||
} | ||
yield waiter.wait(); | ||
completedStatusCode = 0; | ||
completedTasks = []; | ||
continue; | ||
} | ||
waiter.reset(); | ||
executedAnyTasks = true; | ||
if (apiResponse.completedTasks) { | ||
for (const t of apiResponse.completedTasks) { | ||
if (processedTasks[t.taskId]) | ||
continue; | ||
output.note({ | ||
title: `${agentName} downloading artifacts for ${t.taskId} Hash: ${t.hash} Url: ${t.url}`, | ||
}); | ||
yield dteArtifactStorage.retrieveAndExtract(t.hash, t.url); | ||
processedTasks[t.taskId] = true; | ||
} | ||
} | ||
const r = yield invokeTasks(apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel); | ||
for (const t of r.completedTasks) { | ||
processedTasks[t.taskId] = true; | ||
} | ||
completedStatusCode = r.completedStatusCode; | ||
completedTasks = r.completedTasks; | ||
} | ||
}); | ||
} | ||
exports.executeTasks = executeTasks; | ||
//# sourceMappingURL=execute-tasks.js.map | ||
const a7_0x5ee3=['error','executeTasks','status','completedTasks','throw','../../../utilities/nx-imports','NO_FURTHER_TASKS_TO_RUN','__awaiter','executionId:\x20','retryDuring','hash','RUN_GROUP_COMPLETED','VERBOSE_LOGGING','executionId','length','completed','maxParallel','\x20waiting...','error:\x20','then','NO_MESSAGES_TIMEOUT','\x20seconds','criticalErrorMessage','number\x20of\x20tasks:\x20','exit','retrieveAndExtract','../../../utilities/create-unchanged-value-timeout','status:\x20','taskId','\x20Url:\x20','defineProperty','getTime','next','value','tasks','completed:\x20','\x20fetching\x20tasks...','completedStatusCode','note','wait','../../../utilities/environment','url','join'];(function(_0x488994,_0x5ee345){const _0x4333a2=function(_0x5a7d45){while(--_0x5a7d45){_0x488994['push'](_0x488994['shift']());}};_0x4333a2(++_0x5ee345);}(a7_0x5ee3,0x194));const a7_0x4333=function(_0x488994,_0x5ee345){_0x488994=_0x488994-0x0;let _0x4333a2=a7_0x5ee3[_0x488994];return _0x4333a2;};'use strict';var __awaiter=this&&this[a7_0x4333('0x21')]||function(_0x1464b7,_0x196ca5,_0x7d8824,_0x2f22e9){function _0x314d3e(_0x1da0bd){return _0x1da0bd instanceof _0x7d8824?_0x1da0bd:new _0x7d8824(function(_0x400784){_0x400784(_0x1da0bd);});}return new(_0x7d8824||(_0x7d8824=Promise))(function(_0x2d7901,_0x44c505){function _0x2a883e(_0x368bea){try{_0x4673f6(_0x2f22e9[a7_0x4333('0xf')](_0x368bea));}catch(_0x436dc0){_0x44c505(_0x436dc0);}}function _0x1cba3e(_0x167fb7){try{_0x4673f6(_0x2f22e9[a7_0x4333('0x1e')](_0x167fb7));}catch(_0x2371b3){_0x44c505(_0x2371b3);}}function _0x4673f6(_0x1a2838){_0x1a2838['done']?_0x2d7901(_0x1a2838['value']):_0x314d3e(_0x1a2838[a7_0x4333('0x10')])[a7_0x4333('0x2')](_0x2a883e,_0x1cba3e);}_0x4673f6((_0x2f22e9=_0x2f22e9['apply'](_0x1464b7,_0x196ca5||[]))[a7_0x4333('0xf')]());});};Object[a7_0x4333('0xd')](exports,'__esModule',{'value':!![]});exports[a7_0x4333('0x1b')]=void 0x0;const create_unchanged_value_timeout_1=require(a7_0x4333('0x9'));const environment_1=require(a7_0x4333('0x17'));const waiter_1=require('../../../utilities/waiter');const {output}=require(a7_0x4333('0x1f'));function executeTasks(_0x56f16d,_0x3af8cf,_0x28208a,_0x498854,_0x446262){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x36d6e0=0x0;let _0x459872=null;const _0x19879c=(0x0,create_unchanged_value_timeout_1['createUnchangedValueTimeout'])({'title':'No\x20new\x20messages\x20received\x20after\x20'+environment_1[a7_0x4333('0x3')]/0x3e8+a7_0x4333('0x4'),'timeout':environment_1[a7_0x4333('0x3')]});const _0x3cc8f2=new waiter_1['Waiter']();let _0x215145=[];const _0x4feb41=new Date();let _0x37f436=![];const _0x294525={};while(!![]){if(environment_1[a7_0x4333('0x26')]){output[a7_0x4333('0x15')]({'title':_0x56f16d+a7_0x4333('0x13')});}_0x459872=yield _0x3af8cf[a7_0x4333('0x11')](_0x459872?_0x459872[a7_0x4333('0x27')]:null,_0x36d6e0,_0x215145,_0x446262);if(environment_1['VERBOSE_LOGGING']){output['note']({'title':_0x56f16d+'\x20received\x20an\x20API\x20Response','bodyLines':[a7_0x4333('0x12')+_0x459872[a7_0x4333('0x29')],a7_0x4333('0xa')+_0x459872[a7_0x4333('0x1c')],'retryDuring:\x20'+_0x459872[a7_0x4333('0x23')],a7_0x4333('0x22')+_0x459872[a7_0x4333('0x27')],a7_0x4333('0x6')+_0x459872[a7_0x4333('0x11')][a7_0x4333('0x28')],a7_0x4333('0x1')+_0x459872[a7_0x4333('0x5')],'maxParallel:\x20'+_0x459872[a7_0x4333('0x2a')]]});}if(_0x459872[a7_0x4333('0x5')]){output[a7_0x4333('0x1a')]({'title':'Distributed\x20Execution\x20Terminated','bodyLines':['Error:',_0x459872[a7_0x4333('0x5')]]});process[a7_0x4333('0x7')](0x0);}if((_0x459872===null||_0x459872===void 0x0?void 0x0:_0x459872[a7_0x4333('0x23')])&&(_0x459872===null||_0x459872===void 0x0?void 0x0:_0x459872[a7_0x4333('0x23')])!==0x0&&!_0x37f436&&new Date()[a7_0x4333('0xe')]()-_0x4feb41[a7_0x4333('0xe')]()>_0x459872[a7_0x4333('0x23')]){yield _0x3cc8f2[a7_0x4333('0x16')]();continue;}if((_0x459872===null||_0x459872===void 0x0?void 0x0:_0x459872[a7_0x4333('0x1c')])!==undefined){if(_0x459872[a7_0x4333('0x1c')]===a7_0x4333('0x25')||_0x459872[a7_0x4333('0x1c')]===a7_0x4333('0x20')){return;}}else if(_0x459872[a7_0x4333('0x29')]){return;}_0x19879c(_0x459872[a7_0x4333('0x11')]['map'](_0x38da9b=>_0x38da9b[a7_0x4333('0xb')])[a7_0x4333('0x19')](''));if(!_0x459872[a7_0x4333('0x27')]){if(environment_1[a7_0x4333('0x26')]){output[a7_0x4333('0x15')]({'title':_0x56f16d+a7_0x4333('0x0')});}yield _0x3cc8f2[a7_0x4333('0x16')]();_0x36d6e0=0x0;_0x215145=[];continue;}_0x3cc8f2['reset']();_0x37f436=!![];if(_0x459872[a7_0x4333('0x1d')]){for(const _0x640dec of _0x459872[a7_0x4333('0x1d')]){if(_0x294525[_0x640dec['taskId']])continue;output['note']({'title':_0x56f16d+'\x20downloading\x20artifacts\x20for\x20'+_0x640dec['taskId']+'\x20Hash:\x20'+_0x640dec[a7_0x4333('0x24')]+a7_0x4333('0xc')+_0x640dec[a7_0x4333('0x18')]});yield _0x28208a[a7_0x4333('0x8')](_0x640dec[a7_0x4333('0x24')],_0x640dec[a7_0x4333('0x18')]);_0x294525[_0x640dec['taskId']]=!![];}}const _0x4f7068=yield _0x498854(_0x459872[a7_0x4333('0x27')],_0x459872[a7_0x4333('0x11')],_0x459872['maxParallel']);for(const _0xc4a47f of _0x4f7068['completedTasks']){_0x294525[_0xc4a47f[a7_0x4333('0xb')]]=!![];}_0x36d6e0=_0x4f7068[a7_0x4333('0x14')];_0x215145=_0x4f7068['completedTasks'];}});}exports[a7_0x4333('0x1b')]=executeTasks; |
@@ -1,58 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.invokeTasksUsingNxImperativeApi = void 0; | ||
const { initTasksRunner } = require('../../../utilities/nx-imports'); | ||
const parser = require("yargs-parser"); | ||
const serializer_overrides_1 = require("../../../utilities/serializer-overrides"); | ||
function invokeTasksUsingNxImperativeApi(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const tasksRunner = yield initTasksRunner(options); | ||
return (executionId, tasksToExecute, parallel) => __awaiter(this, void 0, void 0, function* () { | ||
const tasks = tasksToExecute.map((t) => { | ||
const params = parser(t.params, { | ||
configuration: { | ||
'camel-case-expansion': false, | ||
'dot-notation': true, | ||
}, | ||
}); | ||
const unparsed = (0, serializer_overrides_1.unparse)(params); | ||
if (params._.length == 0) { | ||
delete params._; | ||
} | ||
return { | ||
id: t.taskId, | ||
target: { | ||
project: t.projectName, | ||
target: t.target, | ||
configuration: t.configuration, | ||
}, | ||
overrides: Object.assign(Object.assign({}, params), { __overrides_unparsed__: unparsed }), | ||
}; | ||
}); | ||
process.env.NX_CACHE_FAILURES = 'true'; // this is only requires because of how we do uploads | ||
process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID = executionId; | ||
process.env.NX_STREAM_OUTPUT = 'true'; | ||
process.env.NX_PREFIX_OUTPUT = 'true'; | ||
const r = yield tasksRunner.invoke({ tasks, parallel }); | ||
const completedTasks = Object.values(r.taskGraph.tasks); | ||
return { | ||
completedTasks: completedTasks.map((t) => ({ | ||
taskId: t.id, | ||
hash: t.hash, | ||
})), | ||
completedStatusCode: r.status, | ||
}; | ||
}); | ||
}); | ||
} | ||
exports.invokeTasksUsingNxImperativeApi = invokeTasksUsingNxImperativeApi; | ||
//# sourceMappingURL=invoke-tasks-using-nx-imperative-api.js.map | ||
const a8_0x5c98=['invokeTasksUsingNxImperativeApi','next','taskId','target','env','params','true','invoke','../../../utilities/serializer-overrides','taskGraph','defineProperty','apply','__awaiter','NX_STREAM_OUTPUT','value','status','projectName','map','NX_PREFIX_OUTPUT','values','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','assign','configuration','NX_CACHE_FAILURES','length','yargs-parser','hash','then','__esModule'];(function(_0x21d333,_0x5c9824){const _0x4ab043=function(_0x2e1184){while(--_0x2e1184){_0x21d333['push'](_0x21d333['shift']());}};_0x4ab043(++_0x5c9824);}(a8_0x5c98,0xf2));const a8_0x4ab0=function(_0x21d333,_0x5c9824){_0x21d333=_0x21d333-0x0;let _0x4ab043=a8_0x5c98[_0x21d333];return _0x4ab043;};'use strict';var __awaiter=this&&this[a8_0x4ab0('0x2')]||function(_0x228619,_0x2cd8d5,_0x39c977,_0x5532c9){function _0x27d43d(_0x5a3ce9){return _0x5a3ce9 instanceof _0x39c977?_0x5a3ce9:new _0x39c977(function(_0x34dcf2){_0x34dcf2(_0x5a3ce9);});}return new(_0x39c977||(_0x39c977=Promise))(function(_0x45e23e,_0xc0efe7){function _0x23e4f9(_0x383046){try{_0x2db0f5(_0x5532c9['next'](_0x383046));}catch(_0x509cc2){_0xc0efe7(_0x509cc2);}}function _0x52bfed(_0x58891f){try{_0x2db0f5(_0x5532c9['throw'](_0x58891f));}catch(_0x28b005){_0xc0efe7(_0x28b005);}}function _0x2db0f5(_0x594096){_0x594096['done']?_0x45e23e(_0x594096[a8_0x4ab0('0x4')]):_0x27d43d(_0x594096[a8_0x4ab0('0x4')])[a8_0x4ab0('0x11')](_0x23e4f9,_0x52bfed);}_0x2db0f5((_0x5532c9=_0x5532c9[a8_0x4ab0('0x1')](_0x228619,_0x2cd8d5||[]))[a8_0x4ab0('0x14')]());});};Object[a8_0x4ab0('0x0')](exports,a8_0x4ab0('0x12'),{'value':!![]});exports['invokeTasksUsingNxImperativeApi']=void 0x0;const {initTasksRunner}=require('../../../utilities/nx-imports');const parser=require(a8_0x4ab0('0xf'));const serializer_overrides_1=require(a8_0x4ab0('0x1b'));function invokeTasksUsingNxImperativeApi(_0x588b59){return __awaiter(this,void 0x0,void 0x0,function*(){const _0xcd7545=yield initTasksRunner(_0x588b59);return(_0x561abe,_0x2248f6,_0x453d24)=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x29fead=_0x2248f6[a8_0x4ab0('0x7')](_0x405c6a=>{const _0x4e3a8c=parser(_0x405c6a[a8_0x4ab0('0x18')],{'configuration':{'camel-case-expansion':![],'dot-notation':!![]}});const _0x5e4244=(0x0,serializer_overrides_1['unparse'])(_0x4e3a8c);if(_0x4e3a8c['_'][a8_0x4ab0('0xe')]==0x0){delete _0x4e3a8c['_'];}return{'id':_0x405c6a[a8_0x4ab0('0x15')],'target':{'project':_0x405c6a[a8_0x4ab0('0x6')],'target':_0x405c6a[a8_0x4ab0('0x16')],'configuration':_0x405c6a[a8_0x4ab0('0xc')]},'overrides':Object[a8_0x4ab0('0xb')](Object[a8_0x4ab0('0xb')]({},_0x4e3a8c),{'__overrides_unparsed__':_0x5e4244})};});process['env'][a8_0x4ab0('0xd')]=a8_0x4ab0('0x19');process['env'][a8_0x4ab0('0xa')]=_0x561abe;process[a8_0x4ab0('0x17')][a8_0x4ab0('0x3')]=a8_0x4ab0('0x19');process[a8_0x4ab0('0x17')][a8_0x4ab0('0x8')]=a8_0x4ab0('0x19');const _0x4b5fad=yield _0xcd7545[a8_0x4ab0('0x1a')]({'tasks':_0x29fead,'parallel':_0x453d24});const _0x444a24=Object[a8_0x4ab0('0x9')](_0x4b5fad[a8_0x4ab0('0x1c')]['tasks']);return{'completedTasks':_0x444a24[a8_0x4ab0('0x7')](_0x3b654c=>({'taskId':_0x3b654c['id'],'hash':_0x3b654c[a8_0x4ab0('0x10')]})),'completedStatusCode':_0x4b5fad[a8_0x4ab0('0x5')]};});});}exports[a8_0x4ab0('0x13')]=invokeTasksUsingNxImperativeApi; |
@@ -1,97 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.invokeTasksUsingRunMany = void 0; | ||
const environment_1 = require("../../../utilities/environment"); | ||
const child_process_1 = require("child_process"); | ||
const fs_1 = require("fs"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
function invokeTasksUsingRunMany(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const readCompleted = completedTasksReader(options); | ||
return function invokeTasksUsingRunMany(executionId, tasksToExecute, parallel) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let completedStatusCode = 0; | ||
const completedTasks = []; | ||
for (const g of groupByTarget(tasksToExecute)) { | ||
const config = g.configuration | ||
? `--configuration=${g.configuration}` | ||
: ``; | ||
const parallelStr = parallel > 1 ? ` --parallel --max-parallel=${parallel}` : ``; | ||
// TODO use pnpx or yarn when needed | ||
const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallelStr}`; | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: `Executing: '${command}'`, | ||
}); | ||
} | ||
try { | ||
(0, child_process_1.execSync)(command, { | ||
stdio: ['ignore', 'inherit', 'inherit'], | ||
env: Object.assign(Object.assign({}, process.env), { NX_CACHE_FAILURES: 'true', NX_CLOUD_DISTRIBUTED_EXECUTION_ID: executionId, NX_STREAM_OUTPUT: 'true', NX_PREFIX_OUTPUT: 'true' }), | ||
}); | ||
completedTasks.push(...readCompleted(executionId)); | ||
} | ||
catch (e) { | ||
if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) { | ||
throw e; | ||
} | ||
else { | ||
completedStatusCode = 1; | ||
completedTasks.push(...readCompleted(executionId)); | ||
} | ||
} | ||
} | ||
return { completedStatusCode, completedTasks }; | ||
}); | ||
}; | ||
}); | ||
} | ||
exports.invokeTasksUsingRunMany = invokeTasksUsingRunMany; | ||
function groupByTarget(tasks) { | ||
const res = []; | ||
tasks.forEach((t) => { | ||
const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration); | ||
if (r) { | ||
r.projects.push(t.projectName); | ||
} | ||
else { | ||
res.push({ | ||
target: t.target, | ||
projects: [t.projectName], | ||
params: t.params, | ||
configuration: t.configuration, | ||
}); | ||
} | ||
}); | ||
return res; | ||
} | ||
function completedTasksReader(options) { | ||
const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options); | ||
return (distributedExecutionId) => { | ||
const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`; | ||
let completedTasks; | ||
try { | ||
const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`; | ||
completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString()); | ||
// remove it such that if the next command crashes we don't read an obsolete file | ||
(0, fs_1.unlinkSync)(taskHashesFile); | ||
} | ||
catch (e) { | ||
throw new Error(errorMessage); | ||
} | ||
if (completedTasks.length == 0) { | ||
throw new Error(errorMessage); | ||
} | ||
return completedTasks; | ||
}; | ||
} | ||
//# sourceMappingURL=invoke-tasks-using-run-many.js.map | ||
const a9_0x3b21=['../../../utilities/environment','value','../../../utilities/nx-imports','inherit','VERBOSE_LOGGING','npx\x20nx\x20run-many\x20--target=','--configuration=',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','target','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','true','push','Executing:\x20\x27','invokeTasksUsingRunMany','params','\x20--projects=','projects','readFileSync','env','ignore','done','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','execSync','defineProperty','throw','find','status','assign','child_process','__esModule','apply','next','\x20--parallel\x20--max-parallel=','configuration','projectName','parse','getNxCacheDirectory','toString'];(function(_0x1d4a7b,_0x3b21be){const _0x532341=function(_0x55b6cf){while(--_0x55b6cf){_0x1d4a7b['push'](_0x1d4a7b['shift']());}};_0x532341(++_0x3b21be);}(a9_0x3b21,0xdf));const a9_0x5323=function(_0x1d4a7b,_0x3b21be){_0x1d4a7b=_0x1d4a7b-0x0;let _0x532341=a9_0x3b21[_0x1d4a7b];return _0x532341;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x51b674,_0x1f90f7,_0x181c24,_0x53566d){function _0x10b970(_0x4e69d6){return _0x4e69d6 instanceof _0x181c24?_0x4e69d6:new _0x181c24(function(_0x42f0d8){_0x42f0d8(_0x4e69d6);});}return new(_0x181c24||(_0x181c24=Promise))(function(_0x588e0e,_0x1e3eb4){function _0x3c6bc6(_0x2d0eb6){try{_0x3af48e(_0x53566d['next'](_0x2d0eb6));}catch(_0x3838bb){_0x1e3eb4(_0x3838bb);}}function _0x378c16(_0x33eef7){try{_0x3af48e(_0x53566d[a9_0x5323('0x1d')](_0x33eef7));}catch(_0x5932ec){_0x1e3eb4(_0x5932ec);}}function _0x3af48e(_0x3faf8d){_0x3faf8d[a9_0x5323('0x19')]?_0x588e0e(_0x3faf8d[a9_0x5323('0x6')]):_0x10b970(_0x3faf8d[a9_0x5323('0x6')])['then'](_0x3c6bc6,_0x378c16);}_0x3af48e((_0x53566d=_0x53566d[a9_0x5323('0x23')](_0x51b674,_0x1f90f7||[]))[a9_0x5323('0x24')]());});};Object[a9_0x5323('0x1c')](exports,a9_0x5323('0x22'),{'value':!![]});exports[a9_0x5323('0x12')]=void 0x0;const environment_1=require(a9_0x5323('0x5'));const child_process_1=require(a9_0x5323('0x21'));const fs_1=require('fs');const {output}=require(a9_0x5323('0x7'));function invokeTasksUsingRunMany(_0x183fd3){return __awaiter(this,void 0x0,void 0x0,function*(){const _0xf54f20=completedTasksReader(_0x183fd3);return function _0x2c360f(_0x2c12e1,_0x1f1bcb,_0x1de965){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x4f9a9a=0x0;const _0x343c46=[];for(const _0xd424e3 of groupByTarget(_0x1f1bcb)){const _0x53e564=_0xd424e3[a9_0x5323('0x0')]?a9_0x5323('0xb')+_0xd424e3[a9_0x5323('0x0')]:'';const _0xd07383=_0x1de965>0x1?a9_0x5323('0x25')+_0x1de965:'';const _0x35650e=a9_0x5323('0xa')+_0xd424e3[a9_0x5323('0xd')]+'\x20'+_0x53e564+a9_0x5323('0x14')+_0xd424e3[a9_0x5323('0x15')]['join'](',')+'\x20'+_0xd424e3['params']+_0xd07383;if(environment_1[a9_0x5323('0x9')]){output['note']({'title':a9_0x5323('0x11')+_0x35650e+'\x27'});}try{(0x0,child_process_1[a9_0x5323('0x1b')])(_0x35650e,{'stdio':[a9_0x5323('0x18'),a9_0x5323('0x8'),a9_0x5323('0x8')],'env':Object[a9_0x5323('0x20')](Object[a9_0x5323('0x20')]({},process[a9_0x5323('0x17')]),{'NX_CACHE_FAILURES':a9_0x5323('0xf'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x2c12e1,'NX_STREAM_OUTPUT':a9_0x5323('0xf'),'NX_PREFIX_OUTPUT':a9_0x5323('0xf')})});_0x343c46[a9_0x5323('0x10')](..._0xf54f20(_0x2c12e1));}catch(_0x2e010c){if(_0x2e010c[a9_0x5323('0x1f')]===environment_1[a9_0x5323('0x1a')]){throw _0x2e010c;}else{_0x4f9a9a=0x1;_0x343c46[a9_0x5323('0x10')](..._0xf54f20(_0x2c12e1));}}}return{'completedStatusCode':_0x4f9a9a,'completedTasks':_0x343c46};});};});}exports[a9_0x5323('0x12')]=invokeTasksUsingRunMany;function groupByTarget(_0x15a5dc){const _0x7e7c2f=[];_0x15a5dc['forEach'](_0x335f80=>{const _0x4f7c70=_0x7e7c2f[a9_0x5323('0x1e')](_0x89e818=>_0x89e818['target']===_0x335f80[a9_0x5323('0xd')]&&_0x89e818[a9_0x5323('0x0')]===_0x335f80[a9_0x5323('0x0')]);if(_0x4f7c70){_0x4f7c70[a9_0x5323('0x15')][a9_0x5323('0x10')](_0x335f80[a9_0x5323('0x1')]);}else{_0x7e7c2f[a9_0x5323('0x10')]({'target':_0x335f80[a9_0x5323('0xd')],'projects':[_0x335f80['projectName']],'params':_0x335f80[a9_0x5323('0x13')],'configuration':_0x335f80[a9_0x5323('0x0')]});}});return _0x7e7c2f;}function completedTasksReader(_0x47acca){const _0x2c0b18=(0x0,environment_1[a9_0x5323('0x3')])(_0x47acca);return _0x5b81a3=>{const _0x5237e0=a9_0x5323('0xe')+_0x5b81a3+a9_0x5323('0xc');let _0x578b2d;try{const _0xfdaf50=_0x2c0b18+'/tasks-hashes-'+_0x5b81a3;_0x578b2d=JSON[a9_0x5323('0x2')]((0x0,fs_1[a9_0x5323('0x16')])(_0xfdaf50)[a9_0x5323('0x4')]());(0x0,fs_1['unlinkSync'])(_0xfdaf50);}catch(_0x8e299b){throw new Error(_0x5237e0);}if(_0x578b2d['length']==0x0){throw new Error(_0x5237e0);}return _0x578b2d;};} |
@@ -1,152 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createStartRequest = exports.DistributedExecutionApi = void 0; | ||
const axios_1 = require("../../../utilities/axios"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const metric_logger_1 = require("../../../utilities/metric-logger"); | ||
const serializer_overrides_1 = require("../../../utilities/serializer-overrides"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
class DistributedExecutionApi { | ||
constructor(options) { | ||
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options); | ||
} | ||
start(params) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const recorder = (0, metric_logger_1.createMetricRecorder)('dteStart'); | ||
let resp; | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: 'Starting a distributed execution', | ||
bodyLines: [JSON.stringify(params, null, 2)], | ||
}); | ||
} | ||
try { | ||
resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/start', params)); | ||
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp)); | ||
} | ||
catch (e) { | ||
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response) | ||
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response) | ||
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY); | ||
throw e; | ||
} | ||
if (!resp.data.enabled) { | ||
throw new Error(`Workspace is disabled. Cannot perform distributed task executions.`); | ||
} | ||
if (resp.data.error) { | ||
throw new Error(resp.data.error); | ||
} | ||
return resp.data.id; | ||
}); | ||
} | ||
status(id) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const recorder = (0, metric_logger_1.createMetricRecorder)('dteStatus'); | ||
try { | ||
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/status', { | ||
id, | ||
})); | ||
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp)); | ||
return resp.data; | ||
} | ||
catch (e) { | ||
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response) | ||
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response) | ||
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY); | ||
output.error({ | ||
title: e.message, | ||
}); | ||
process.exit(1); | ||
} | ||
}); | ||
} | ||
completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, error) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup'); | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: 'Completing with an error', | ||
bodyLines: [ | ||
`ciExecutionId: ${ciExecutionId}`, | ||
`ciExecutionEnv: ${ciExecutionEnv}`, | ||
`runGroup: ${runGroup}`, | ||
`error: ${error}`, | ||
], | ||
}); | ||
} | ||
try { | ||
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', { | ||
runGroup, | ||
ciExecutionId, | ||
ciExecutionEnv, | ||
criticalErrorMessage: error, | ||
}), 3); | ||
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp)); | ||
} | ||
catch (e) { | ||
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response) | ||
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response) | ||
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY); | ||
} | ||
}); | ||
} | ||
} | ||
exports.DistributedExecutionApi = DistributedExecutionApi; | ||
function createStartRequest(branch, runGroup, ciExecutionId, ciExecutionEnv, task, options) { | ||
const tasksToExecute = task.map((arr) => { | ||
return arr.map((t) => { | ||
return { | ||
taskId: t.id, | ||
hash: t.hash, | ||
projectName: t.target.project, | ||
target: t.target.target, | ||
configuration: t.target.configuration || null, | ||
params: (0, serializer_overrides_1.serializeOverrides)(t), | ||
}; | ||
}); | ||
}); | ||
const request = { | ||
command: (0, environment_1.parseCommand)(), | ||
branch, | ||
runGroup, | ||
ciExecutionId, | ||
ciExecutionEnv, | ||
tasks: tasksToExecute, | ||
maxParallel: calculateMaxParallel(options), | ||
}; | ||
if (environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT) { | ||
request.agentCount = environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT; | ||
} | ||
if (!environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE) { | ||
request.stopAgentsOnFailure = false; | ||
} | ||
return request; | ||
} | ||
exports.createStartRequest = createStartRequest; | ||
function calculateMaxParallel(options) { | ||
if (options.parallel === 'false' || options.parallel === false) { | ||
return 1; | ||
} | ||
else if (options.parallel === 'true' || options.parallel === true) { | ||
return Number(options.maxParallel || 3); | ||
} | ||
else if (options.parallel === undefined) { | ||
return options.maxParallel ? Number(options.maxParallel) : 3; | ||
} | ||
else { | ||
return Number(options.parallel) || 3; | ||
} | ||
} | ||
//# sourceMappingURL=distributed-execution.api.js.map | ||
const a10_0x472e=['error','agentCount','/nx-cloud/executions/start','VERBOSE_LOGGING','serializeOverrides','createStartRequest','createMetricRecorder','next','exit','project','NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE','status','axiosException','axiosMultipleTries','runGroup:\x20','../../../utilities/nx-imports','ciExecutionEnv:\x20','post','map','maxParallel','ciExecutionId:\x20','response','../../../utilities/axios','parallel','RUNNER_FAILURE_PERF_ENTRY','__awaiter','Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.','/nx-cloud/executions/complete-run-group','completeRunGroupWithError','Completing\x20with\x20an\x20error','target','/nx-cloud/executions/status','then','recordMetric','hash','../../../utilities/environment','__esModule','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','createApiAxiosInstance','value','done','completeRunGroup','DistributedExecutionApi','mapRespToPerfEntry','defineProperty','enabled','apiAxiosInstance','parseCommand','note','data','false','dteStatus','throw','Starting\x20a\x20distributed\x20execution','dteStart'];(function(_0x1990da,_0x472e84){const _0x26ae1a=function(_0x31e854){while(--_0x31e854){_0x1990da['push'](_0x1990da['shift']());}};_0x26ae1a(++_0x472e84);}(a10_0x472e,0xcf));const a10_0x26ae=function(_0x1990da,_0x472e84){_0x1990da=_0x1990da-0x0;let _0x26ae1a=a10_0x472e[_0x1990da];return _0x26ae1a;};'use strict';var __awaiter=this&&this[a10_0x26ae('0x26')]||function(_0x3f05ed,_0x38c4eb,_0x79bcf5,_0x417f25){function _0x5e29cb(_0x44fdd5){return _0x44fdd5 instanceof _0x79bcf5?_0x44fdd5:new _0x79bcf5(function(_0x16fdc0){_0x16fdc0(_0x44fdd5);});}return new(_0x79bcf5||(_0x79bcf5=Promise))(function(_0x104aaa,_0x1507dc){function _0x2f9279(_0x2d70ac){try{_0xabac0f(_0x417f25[a10_0x26ae('0x14')](_0x2d70ac));}catch(_0x469929){_0x1507dc(_0x469929);}}function _0x139e73(_0x19f6de){try{_0xabac0f(_0x417f25[a10_0x26ae('0xa')](_0x19f6de));}catch(_0x27a011){_0x1507dc(_0x27a011);}}function _0xabac0f(_0x37b073){_0x37b073[a10_0x26ae('0x35')]?_0x104aaa(_0x37b073[a10_0x26ae('0x34')]):_0x5e29cb(_0x37b073[a10_0x26ae('0x34')])[a10_0x26ae('0x2d')](_0x2f9279,_0x139e73);}_0xabac0f((_0x417f25=_0x417f25['apply'](_0x3f05ed,_0x38c4eb||[]))['next']());});};Object[a10_0x26ae('0x2')](exports,a10_0x26ae('0x31'),{'value':!![]});exports[a10_0x26ae('0x12')]=exports[a10_0x26ae('0x0')]=void 0x0;const axios_1=require(a10_0x26ae('0x23'));const environment_1=require(a10_0x26ae('0x30'));const metric_logger_1=require('../../../utilities/metric-logger');const serializer_overrides_1=require('../../../utilities/serializer-overrides');const {output}=require(a10_0x26ae('0x1c'));class DistributedExecutionApi{constructor(_0x53e92b){this[a10_0x26ae('0x4')]=(0x0,axios_1[a10_0x26ae('0x33')])(_0x53e92b);}['start'](_0x4256cc){var _0x2e9485;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4bdc35=(0x0,metric_logger_1[a10_0x26ae('0x13')])(a10_0x26ae('0xc'));let _0xf6e706;if(environment_1[a10_0x26ae('0x10')]){output[a10_0x26ae('0x6')]({'title':a10_0x26ae('0xb'),'bodyLines':[JSON['stringify'](_0x4256cc,null,0x2)]});}try{_0xf6e706=yield(0x0,axios_1[a10_0x26ae('0x1a')])(()=>this['apiAxiosInstance'][a10_0x26ae('0x1e')](a10_0x26ae('0xf'),_0x4256cc));_0x4bdc35[a10_0x26ae('0x2e')]((0x0,metric_logger_1[a10_0x26ae('0x1')])(_0xf6e706));}catch(_0x4bca0f){_0x4bdc35['recordMetric'](((_0x2e9485=_0x4bca0f===null||_0x4bca0f===void 0x0?void 0x0:_0x4bca0f[a10_0x26ae('0x19')])===null||_0x2e9485===void 0x0?void 0x0:_0x2e9485[a10_0x26ae('0x22')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x4bca0f['axiosException']['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);throw _0x4bca0f;}if(!_0xf6e706['data'][a10_0x26ae('0x3')]){throw new Error(a10_0x26ae('0x27'));}if(_0xf6e706[a10_0x26ae('0x7')]['error']){throw new Error(_0xf6e706[a10_0x26ae('0x7')][a10_0x26ae('0xd')]);}return _0xf6e706[a10_0x26ae('0x7')]['id'];});}[a10_0x26ae('0x18')](_0x226763){var _0x5674fa;return __awaiter(this,void 0x0,void 0x0,function*(){const _0xa977f=(0x0,metric_logger_1[a10_0x26ae('0x13')])(a10_0x26ae('0x9'));try{const _0x1c3a09=yield(0x0,axios_1[a10_0x26ae('0x1a')])(()=>this[a10_0x26ae('0x4')]['post'](a10_0x26ae('0x2c'),{'id':_0x226763}));_0xa977f['recordMetric']((0x0,metric_logger_1[a10_0x26ae('0x1')])(_0x1c3a09));return _0x1c3a09['data'];}catch(_0x210693){_0xa977f['recordMetric'](((_0x5674fa=_0x210693===null||_0x210693===void 0x0?void 0x0:_0x210693[a10_0x26ae('0x19')])===null||_0x5674fa===void 0x0?void 0x0:_0x5674fa[a10_0x26ae('0x22')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x210693[a10_0x26ae('0x19')][a10_0x26ae('0x22')]):metric_logger_1[a10_0x26ae('0x25')]);output[a10_0x26ae('0xd')]({'title':_0x210693['message']});process[a10_0x26ae('0x15')](0x1);}});}[a10_0x26ae('0x29')](_0x1a1f7a,_0x39eefb,_0x192fc4,_0x557a37,_0x84ea95){var _0x1c7428;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1e9d76=(0x0,metric_logger_1[a10_0x26ae('0x13')])(a10_0x26ae('0x36'));if(environment_1[a10_0x26ae('0x10')]){output['note']({'title':a10_0x26ae('0x2a'),'bodyLines':[a10_0x26ae('0x21')+_0x192fc4,a10_0x26ae('0x1d')+_0x557a37,a10_0x26ae('0x1b')+_0x39eefb,'error:\x20'+_0x84ea95]});}try{const _0x5450bb=yield(0x0,axios_1[a10_0x26ae('0x1a')])(()=>this[a10_0x26ae('0x4')][a10_0x26ae('0x1e')](a10_0x26ae('0x28'),{'runGroup':_0x39eefb,'ciExecutionId':_0x192fc4,'ciExecutionEnv':_0x557a37,'criticalErrorMessage':_0x84ea95}),0x3);_0x1e9d76['recordMetric']((0x0,metric_logger_1[a10_0x26ae('0x1')])(_0x5450bb));}catch(_0x49aafd){_0x1e9d76['recordMetric'](((_0x1c7428=_0x49aafd===null||_0x49aafd===void 0x0?void 0x0:_0x49aafd[a10_0x26ae('0x19')])===null||_0x1c7428===void 0x0?void 0x0:_0x1c7428[a10_0x26ae('0x22')])?(0x0,metric_logger_1[a10_0x26ae('0x1')])(_0x49aafd[a10_0x26ae('0x19')][a10_0x26ae('0x22')]):metric_logger_1[a10_0x26ae('0x25')]);}});}}exports[a10_0x26ae('0x0')]=DistributedExecutionApi;function createStartRequest(_0x3e8b04,_0x18b2ad,_0x430d62,_0x390baa,_0x1a844c,_0x44c157){const _0x2204b0=_0x1a844c[a10_0x26ae('0x1f')](_0x1104c0=>{return _0x1104c0['map'](_0x8c7a18=>{return{'taskId':_0x8c7a18['id'],'hash':_0x8c7a18[a10_0x26ae('0x2f')],'projectName':_0x8c7a18[a10_0x26ae('0x2b')][a10_0x26ae('0x16')],'target':_0x8c7a18[a10_0x26ae('0x2b')]['target'],'configuration':_0x8c7a18['target']['configuration']||null,'params':(0x0,serializer_overrides_1[a10_0x26ae('0x11')])(_0x8c7a18)};});});const _0x52cf14={'command':(0x0,environment_1[a10_0x26ae('0x5')])(),'branch':_0x3e8b04,'runGroup':_0x18b2ad,'ciExecutionId':_0x430d62,'ciExecutionEnv':_0x390baa,'tasks':_0x2204b0,'maxParallel':calculateMaxParallel(_0x44c157)};if(environment_1[a10_0x26ae('0x32')]){_0x52cf14[a10_0x26ae('0xe')]=environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT'];}if(!environment_1[a10_0x26ae('0x17')]){_0x52cf14['stopAgentsOnFailure']=![];}return _0x52cf14;}exports['createStartRequest']=createStartRequest;function calculateMaxParallel(_0x314e15){if(_0x314e15[a10_0x26ae('0x24')]===a10_0x26ae('0x8')||_0x314e15['parallel']===![]){return 0x1;}else if(_0x314e15['parallel']==='true'||_0x314e15[a10_0x26ae('0x24')]===!![]){return Number(_0x314e15[a10_0x26ae('0x20')]||0x3);}else if(_0x314e15['parallel']===undefined){return _0x314e15[a10_0x26ae('0x20')]?Number(_0x314e15['maxParallel']):0x3;}else{return Number(_0x314e15['parallel'])||0x3;}} |
@@ -1,118 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nxCloudDistributedTasksRunner = void 0; | ||
const environment_1 = require("../../../utilities/environment"); | ||
const metric_logger_1 = require("../../../utilities/metric-logger"); | ||
const error_reporter_api_1 = require("../../api/error-reporter.api"); | ||
const print_run_group_error_1 = require("../../error/print-run-group-error"); | ||
const e2e_encryption_1 = require("../../file-storage/e2e-encryption"); | ||
const file_storage_1 = require("../../file-storage/file-storage"); | ||
const distributed_execution_api_1 = require("./distributed-execution.api"); | ||
const split_task_graph_into_stages_1 = require("./split-task-graph-into-stages"); | ||
const task_graph_creator_1 = require("./task-graph-creator"); | ||
const process_tasks_1 = require("./process-tasks"); | ||
const dte_artifact_storage_1 = require("../../../utilities/dte-artifact-storage"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
class NoopLifeCycle { | ||
scheduleTask(task) { } | ||
startTask(task) { } | ||
endTasks(tasks) { } | ||
} | ||
const nxCloudDistributedTasksRunner = (tasks, options, context) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (options.skipNxCache) { | ||
output.warn({ | ||
title: `--skip-nx-cache is ignored when using distributed tasks execution (DTE).`, | ||
bodyLine: [`DTE needs the cache to share files between agents.`], | ||
}); | ||
} | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: 'Starting distributed command execution', | ||
}); | ||
} | ||
options.lifeCycle = new NoopLifeCycle(); | ||
const branch = (0, environment_1.getBranch)(); | ||
const runGroup = (0, environment_1.getRunGroup)(); | ||
const ciExecutionId = (0, environment_1.getCIExecutionId)(); | ||
const ciExecutionEnv = (0, environment_1.getCIExecutionEnv)(); | ||
if (!(0, print_run_group_error_1.canDetectRunGroup)(runGroup, ciExecutionId)) { | ||
(0, print_run_group_error_1.printRunGroupError)(); | ||
process.exit(1); | ||
} | ||
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey); | ||
const errorReporter = new error_reporter_api_1.ErrorReporterApi(options); | ||
const dteArtifactStorage = new dte_artifact_storage_1.DteArtifactStorage(new file_storage_1.FileStorage(encryption, errorReporter, options, 'dte-main'), (0, environment_1.getNxCacheDirectory)(options)); | ||
const api = new distributed_execution_api_1.DistributedExecutionApi(options); | ||
attachSignalListenersToCompleteRunGroupOnError(api, branch, runGroup, ciExecutionId, ciExecutionEnv); | ||
try { | ||
const taskGraph = getTaskGraph(context, tasks, options); | ||
const r = yield runDistributedExecution(api, options, dteArtifactStorage, branch, runGroup, ciExecutionId, ciExecutionEnv, taskGraph); | ||
if (r.commandStatus === 0) { | ||
output.success({ | ||
title: 'Successfully completed running the command.', | ||
bodyLines: [`See run details at ${r.runUrl}`], | ||
}); | ||
} | ||
else { | ||
output.error({ | ||
title: 'Command execution failed.', | ||
bodyLines: [`See run details at ${r.runUrl}`], | ||
}); | ||
} | ||
yield (0, metric_logger_1.submitRunMetrics)(options); | ||
process.exit(r.commandStatus); | ||
} | ||
catch (e) { | ||
output.error({ | ||
title: 'Unable to complete a run.', | ||
bodyLines: [e.message], | ||
}); | ||
if (e.axiosException) { | ||
console.log(e.axiosException); | ||
} | ||
else { | ||
console.log(e); | ||
} | ||
try { | ||
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, `Main job terminated with an error: "${e.message}"`); | ||
} | ||
finally { | ||
process.exit(1); | ||
} | ||
} | ||
}); | ||
exports.nxCloudDistributedTasksRunner = nxCloudDistributedTasksRunner; | ||
function getTaskGraph(context, tasks, options) { | ||
if (context.taskGraph) { | ||
return context.taskGraph; | ||
} | ||
else { | ||
return (0, task_graph_creator_1.createTaskGraphCompat)(options, context.projectGraph, tasks); | ||
} | ||
} | ||
function attachSignalListenersToCompleteRunGroupOnError(api, branch, runGroup, ciExecutionId, ciExecutionEnv) { | ||
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () { | ||
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, 'Main job was terminated via SIGINT'); | ||
process.exit(1); | ||
})); | ||
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () { | ||
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, 'Main job was terminated via SIGTERM'); | ||
process.exit(1); | ||
})); | ||
} | ||
function runDistributedExecution(api, options, dteArtifactStorage, branch, runGroup, ciExecutionId, ciExecutionEnv, taskGraph) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const id = yield api.start((0, distributed_execution_api_1.createStartRequest)(branch, runGroup, ciExecutionId, ciExecutionEnv, (0, split_task_graph_into_stages_1.splitTasksIntoStages)(taskGraph), options)); | ||
return yield (0, process_tasks_1.processTasks)(api, dteArtifactStorage, id, Object.values(taskGraph.tasks)); | ||
}); | ||
} | ||
//# sourceMappingURL=distributed-execution.runner.js.map | ||
const a11_0xa71d=['endTasks','../../../utilities/metric-logger','projectGraph','./distributed-execution.api','Starting\x20distributed\x20command\x20execution','done','./process-tasks','__esModule','getRunGroup','value','axiosException','FileStorage','exit','values','startTask','../../file-storage/file-storage','DteArtifactStorage','getBranch','../../file-storage/e2e-encryption','VERBOSE_LOGGING','Unable\x20to\x20complete\x20a\x20run.','Successfully\x20completed\x20running\x20the\x20command.','Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','completeRunGroupWithError','success','canDetectRunGroup','taskGraph','log','SIGTERM','See\x20run\x20details\x20at\x20','Command\x20execution\x20failed.','createStartRequest','Main\x20job\x20was\x20terminated\x20via\x20SIGINT','./split-task-graph-into-stages','getNxCacheDirectory','encryptionKey','../../../utilities/nx-imports','processTasks','DTE\x20needs\x20the\x20cache\x20to\x20share\x20files\x20between\x20agents.','E2EEncryption','apply','submitRunMetrics','../../../utilities/dte-artifact-storage','message','error','../../../utilities/environment','warn','./task-graph-creator','throw','SIGINT','next','runUrl','tasks','then','scheduleTask','lifeCycle'];(function(_0x51c846,_0xa71dea){const _0x355ed2=function(_0x5a9f5a){while(--_0x5a9f5a){_0x51c846['push'](_0x51c846['shift']());}};_0x355ed2(++_0xa71dea);}(a11_0xa71d,0x1bb));const a11_0x355e=function(_0x51c846,_0xa71dea){_0x51c846=_0x51c846-0x0;let _0x355ed2=a11_0xa71d[_0x51c846];return _0x355ed2;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x40095e,_0x1ad4ca,_0x5c8017,_0x558c4f){function _0x3b7a19(_0x12fc3a){return _0x12fc3a instanceof _0x5c8017?_0x12fc3a:new _0x5c8017(function(_0x3a2db2){_0x3a2db2(_0x12fc3a);});}return new(_0x5c8017||(_0x5c8017=Promise))(function(_0x2aa6e8,_0xb12d43){function _0x528eee(_0x445e50){try{_0x5a033e(_0x558c4f[a11_0x355e('0x37')](_0x445e50));}catch(_0x479f89){_0xb12d43(_0x479f89);}}function _0x159d48(_0x3d0b53){try{_0x5a033e(_0x558c4f[a11_0x355e('0x35')](_0x3d0b53));}catch(_0x3e2c98){_0xb12d43(_0x3e2c98);}}function _0x5a033e(_0x133832){_0x133832[a11_0x355e('0xa')]?_0x2aa6e8(_0x133832[a11_0x355e('0xe')]):_0x3b7a19(_0x133832[a11_0x355e('0xe')])[a11_0x355e('0x2')](_0x528eee,_0x159d48);}_0x5a033e((_0x558c4f=_0x558c4f[a11_0x355e('0x2d')](_0x40095e,_0x1ad4ca||[]))[a11_0x355e('0x37')]());});};Object['defineProperty'](exports,a11_0x355e('0xc'),{'value':!![]});exports['nxCloudDistributedTasksRunner']=void 0x0;const environment_1=require(a11_0x355e('0x32'));const metric_logger_1=require(a11_0x355e('0x6'));const error_reporter_api_1=require('../../api/error-reporter.api');const print_run_group_error_1=require('../../error/print-run-group-error');const e2e_encryption_1=require(a11_0x355e('0x17'));const file_storage_1=require(a11_0x355e('0x14'));const distributed_execution_api_1=require(a11_0x355e('0x8'));const split_task_graph_into_stages_1=require(a11_0x355e('0x26'));const task_graph_creator_1=require(a11_0x355e('0x34'));const process_tasks_1=require(a11_0x355e('0xb'));const dte_artifact_storage_1=require(a11_0x355e('0x2f'));const {output}=require(a11_0x355e('0x29'));class NoopLifeCycle{[a11_0x355e('0x3')](_0x22fe67){}[a11_0x355e('0x13')](_0x378cb0){}[a11_0x355e('0x5')](_0xef110a){}}const nxCloudDistributedTasksRunner=(_0xff42a,_0x34228d,_0x4f6735)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(_0x34228d['skipNxCache']){output[a11_0x355e('0x33')]({'title':'--skip-nx-cache\x20is\x20ignored\x20when\x20using\x20distributed\x20tasks\x20execution\x20(DTE).','bodyLine':[a11_0x355e('0x2b')]});}if(environment_1[a11_0x355e('0x18')]){output['note']({'title':a11_0x355e('0x9')});}_0x34228d[a11_0x355e('0x4')]=new NoopLifeCycle();const _0x402198=(0x0,environment_1[a11_0x355e('0x16')])();const _0x3e2f2f=(0x0,environment_1[a11_0x355e('0xd')])();const _0x4e9515=(0x0,environment_1['getCIExecutionId'])();const _0x2af0ce=(0x0,environment_1['getCIExecutionEnv'])();if(!(0x0,print_run_group_error_1[a11_0x355e('0x1e')])(_0x3e2f2f,_0x4e9515)){(0x0,print_run_group_error_1['printRunGroupError'])();process['exit'](0x1);}const _0x2b829c=new e2e_encryption_1[(a11_0x355e('0x2c'))](environment_1['ENCRYPTION_KEY']||_0x34228d[a11_0x355e('0x28')]);const _0xbb6cd9=new error_reporter_api_1['ErrorReporterApi'](_0x34228d);const _0x9f2225=new dte_artifact_storage_1[(a11_0x355e('0x15'))](new file_storage_1[(a11_0x355e('0x10'))](_0x2b829c,_0xbb6cd9,_0x34228d,'dte-main'),(0x0,environment_1[a11_0x355e('0x27')])(_0x34228d));const _0x1e1248=new distributed_execution_api_1['DistributedExecutionApi'](_0x34228d);attachSignalListenersToCompleteRunGroupOnError(_0x1e1248,_0x402198,_0x3e2f2f,_0x4e9515,_0x2af0ce);try{const _0x394efb=getTaskGraph(_0x4f6735,_0xff42a,_0x34228d);const _0x22558c=yield runDistributedExecution(_0x1e1248,_0x34228d,_0x9f2225,_0x402198,_0x3e2f2f,_0x4e9515,_0x2af0ce,_0x394efb);if(_0x22558c['commandStatus']===0x0){output[a11_0x355e('0x1d')]({'title':a11_0x355e('0x1a'),'bodyLines':[a11_0x355e('0x22')+_0x22558c[a11_0x355e('0x0')]]});}else{output[a11_0x355e('0x31')]({'title':a11_0x355e('0x23'),'bodyLines':[a11_0x355e('0x22')+_0x22558c[a11_0x355e('0x0')]]});}yield(0x0,metric_logger_1[a11_0x355e('0x2e')])(_0x34228d);process['exit'](_0x22558c['commandStatus']);}catch(_0x29f926){output[a11_0x355e('0x31')]({'title':a11_0x355e('0x19'),'bodyLines':[_0x29f926[a11_0x355e('0x30')]]});if(_0x29f926[a11_0x355e('0xf')]){console[a11_0x355e('0x20')](_0x29f926[a11_0x355e('0xf')]);}else{console[a11_0x355e('0x20')](_0x29f926);}try{yield _0x1e1248[a11_0x355e('0x1c')](_0x402198,_0x3e2f2f,_0x4e9515,_0x2af0ce,a11_0x355e('0x1b')+_0x29f926['message']+'\x22');}finally{process[a11_0x355e('0x11')](0x1);}}});exports['nxCloudDistributedTasksRunner']=nxCloudDistributedTasksRunner;function getTaskGraph(_0x393c48,_0x4f5d18,_0x52e001){if(_0x393c48[a11_0x355e('0x1f')]){return _0x393c48[a11_0x355e('0x1f')];}else{return(0x0,task_graph_creator_1['createTaskGraphCompat'])(_0x52e001,_0x393c48[a11_0x355e('0x7')],_0x4f5d18);}}function attachSignalListenersToCompleteRunGroupOnError(_0x194b60,_0x2ec428,_0x2f9c03,_0x13e1ff,_0x38e9b6){process['on'](a11_0x355e('0x36'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x194b60[a11_0x355e('0x1c')](_0x2ec428,_0x2f9c03,_0x13e1ff,_0x38e9b6,a11_0x355e('0x25'));process[a11_0x355e('0x11')](0x1);}));process['on'](a11_0x355e('0x21'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x194b60[a11_0x355e('0x1c')](_0x2ec428,_0x2f9c03,_0x13e1ff,_0x38e9b6,'Main\x20job\x20was\x20terminated\x20via\x20SIGTERM');process['exit'](0x1);}));}function runDistributedExecution(_0x5a6eb5,_0xa43312,_0x4522cb,_0x8bbdeb,_0x5c584c,_0x41e56d,_0x321207,_0xc79c22){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x35e3e=yield _0x5a6eb5['start']((0x0,distributed_execution_api_1[a11_0x355e('0x24')])(_0x8bbdeb,_0x5c584c,_0x41e56d,_0x321207,(0x0,split_task_graph_into_stages_1['splitTasksIntoStages'])(_0xc79c22),_0xa43312));return yield(0x0,process_tasks_1[a11_0x355e('0x2a')])(_0x5a6eb5,_0x4522cb,_0x35e3e,Object[a11_0x355e('0x12')](_0xc79c22[a11_0x355e('0x1')]));});} |
@@ -1,45 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.processTask = void 0; | ||
const environment_1 = require("../../../utilities/environment"); | ||
const serializer_overrides_1 = require("../../../utilities/serializer-overrides"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
function processTask(dteArtifactStorage, tasks, completedTask) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: `Processing task ${completedTask.taskId}`, | ||
}); | ||
} | ||
const matchingTask = tasks.find((tt) => completedTask.taskId === tt.id); | ||
if (!matchingTask) { | ||
throw new Error(`Found unknown task: ${completedTask.taskId}`); | ||
} | ||
const terminalOutput = yield dteArtifactStorage.retrieveAndExtract(completedTask.hash, completedTask.url); | ||
output.logCommand(getCommand(matchingTask)); | ||
process.stdout.write(terminalOutput); | ||
output.addVerticalSeparator(); | ||
}); | ||
} | ||
exports.processTask = processTask; | ||
function getCommand(task) { | ||
const config = task.target.configuration | ||
? `:${task.target.configuration}` | ||
: ''; | ||
return [ | ||
'nx', | ||
'run', | ||
`${task.target.project}:${task.target.target}${config}`, | ||
(0, serializer_overrides_1.serializeOverrides)(task), | ||
].join(' '); | ||
} | ||
//# sourceMappingURL=process-task.js.map | ||
const a12_0x5b17=['url','../../../utilities/environment','note','__esModule','throw','find','__awaiter','taskId','../../../utilities/serializer-overrides','VERBOSE_LOGGING','addVerticalSeparator','project','../../../utilities/nx-imports','apply','write','target','done','next','stdout','hash','join','then','configuration','run','value','defineProperty','processTask'];(function(_0x336934,_0x5b17c9){const _0x4a9dd7=function(_0x379223){while(--_0x379223){_0x336934['push'](_0x336934['shift']());}};_0x4a9dd7(++_0x5b17c9);}(a12_0x5b17,0x13c));const a12_0x4a9d=function(_0x336934,_0x5b17c9){_0x336934=_0x336934-0x0;let _0x4a9dd7=a12_0x5b17[_0x336934];return _0x4a9dd7;};'use strict';var __awaiter=this&&this[a12_0x4a9d('0xe')]||function(_0x438dc8,_0x1694ee,_0x5ef97e,_0x472ad7){function _0x15d5de(_0x3aa520){return _0x3aa520 instanceof _0x5ef97e?_0x3aa520:new _0x5ef97e(function(_0x1f3f76){_0x1f3f76(_0x3aa520);});}return new(_0x5ef97e||(_0x5ef97e=Promise))(function(_0x558ad8,_0x1633a1){function _0x4e3cbc(_0x58a117){try{_0x5bc542(_0x472ad7[a12_0x4a9d('0x19')](_0x58a117));}catch(_0x6803f5){_0x1633a1(_0x6803f5);}}function _0xb7592f(_0x49f921){try{_0x5bc542(_0x472ad7[a12_0x4a9d('0xc')](_0x49f921));}catch(_0x2b6036){_0x1633a1(_0x2b6036);}}function _0x5bc542(_0x12d9f1){_0x12d9f1[a12_0x4a9d('0x18')]?_0x558ad8(_0x12d9f1[a12_0x4a9d('0x5')]):_0x15d5de(_0x12d9f1['value'])[a12_0x4a9d('0x2')](_0x4e3cbc,_0xb7592f);}_0x5bc542((_0x472ad7=_0x472ad7[a12_0x4a9d('0x15')](_0x438dc8,_0x1694ee||[]))[a12_0x4a9d('0x19')]());});};Object[a12_0x4a9d('0x6')](exports,a12_0x4a9d('0xb'),{'value':!![]});exports[a12_0x4a9d('0x7')]=void 0x0;const environment_1=require(a12_0x4a9d('0x9'));const serializer_overrides_1=require(a12_0x4a9d('0x10'));const {output}=require(a12_0x4a9d('0x14'));function processTask(_0x356668,_0x560ed6,_0x5adf17){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a12_0x4a9d('0x11')]){output[a12_0x4a9d('0xa')]({'title':'Processing\x20task\x20'+_0x5adf17['taskId']});}const _0x5a962b=_0x560ed6[a12_0x4a9d('0xd')](_0x154e90=>_0x5adf17[a12_0x4a9d('0xf')]===_0x154e90['id']);if(!_0x5a962b){throw new Error('Found\x20unknown\x20task:\x20'+_0x5adf17['taskId']);}const _0x34de45=yield _0x356668['retrieveAndExtract'](_0x5adf17[a12_0x4a9d('0x0')],_0x5adf17[a12_0x4a9d('0x8')]);output['logCommand'](getCommand(_0x5a962b));process[a12_0x4a9d('0x1a')][a12_0x4a9d('0x16')](_0x34de45);output[a12_0x4a9d('0x12')]();});}exports[a12_0x4a9d('0x7')]=processTask;function getCommand(_0x1bdfe0){const _0x366b1d=_0x1bdfe0[a12_0x4a9d('0x17')][a12_0x4a9d('0x3')]?':'+_0x1bdfe0[a12_0x4a9d('0x17')][a12_0x4a9d('0x3')]:'';return['nx',a12_0x4a9d('0x4'),_0x1bdfe0['target'][a12_0x4a9d('0x13')]+':'+_0x1bdfe0[a12_0x4a9d('0x17')][a12_0x4a9d('0x17')]+_0x366b1d,(0x0,serializer_overrides_1['serializeOverrides'])(_0x1bdfe0)][a12_0x4a9d('0x1')]('\x20');} |
@@ -1,67 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.processTasks = void 0; | ||
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout"); | ||
const environment_1 = require("../../../utilities/environment"); | ||
const waiter_1 = require("../../../utilities/waiter"); | ||
const process_task_1 = require("./process-task"); | ||
const { output } = require('../../../utilities/nx-imports'); | ||
function processTasks(api, dteArtifactStorage, executionId, tasks) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const processedTasks = {}; | ||
const failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({ | ||
title: `No new completed tasks after ${environment_1.NO_COMPLETED_TASKS_TIMEOUT / 1000} seconds.`, | ||
timeout: environment_1.NO_COMPLETED_TASKS_TIMEOUT, | ||
}); | ||
const waiter = new waiter_1.Waiter(); | ||
while (true) { | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: 'Waiting...', | ||
}); | ||
} | ||
yield waiter.wait(); | ||
const r = yield api.status(executionId); | ||
if (environment_1.VERBOSE_LOGGING) { | ||
output.note({ | ||
title: `Status update`, | ||
bodyLines: [ | ||
`executionId: ${executionId}`, | ||
`executionStatus: ${r.executionStatus}`, | ||
`number of completed tasks: ${r.completedTasks.length}`, | ||
`error: ${r.criticalErrorMessage}`, | ||
], | ||
}); | ||
} | ||
if (r.criticalErrorMessage) { | ||
output.error({ | ||
title: 'Distributed Execution Terminated', | ||
bodyLines: ['Error:', r.criticalErrorMessage], | ||
}); | ||
process.exit(1); | ||
} | ||
failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout(r.completedTasks.length); | ||
for (const t of r.completedTasks) { | ||
if (processedTasks[t.taskId]) | ||
continue; | ||
yield (0, process_task_1.processTask)(dteArtifactStorage, tasks, t); | ||
waiter.reset(); | ||
processedTasks[t.taskId] = true; | ||
} | ||
if (r.executionStatus === 'COMPLETED') { | ||
return { commandStatus: r.commandStatus, runUrl: r.runUrl }; | ||
} | ||
} | ||
}); | ||
} | ||
exports.processTasks = processTasks; | ||
//# sourceMappingURL=process-tasks.js.map | ||
const a13_0x8a45=['completedTasks','Waiter','executionId:\x20','NO_COMPLETED_TASKS_TIMEOUT','criticalErrorMessage','__esModule','No\x20new\x20completed\x20tasks\x20after\x20','processTasks','defineProperty','executionStatus','error:\x20','Error:','../../../utilities/waiter','COMPLETED','taskId','Waiting...','number\x20of\x20completed\x20tasks:\x20','../../../utilities/environment','Status\x20update','\x20seconds.','then','next','throw','apply','note','length','exit','value','reset','commandStatus','processTask','../../../utilities/nx-imports'];(function(_0x231fd8,_0x8a45c4){const _0x4fc065=function(_0x4de68d){while(--_0x4de68d){_0x231fd8['push'](_0x231fd8['shift']());}};_0x4fc065(++_0x8a45c4);}(a13_0x8a45,0xf7));const a13_0x4fc0=function(_0x231fd8,_0x8a45c4){_0x231fd8=_0x231fd8-0x0;let _0x4fc065=a13_0x8a45[_0x231fd8];return _0x4fc065;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x22c645,_0x3bdbce,_0x371764,_0x5f5415){function _0x543d96(_0x6a9ad9){return _0x6a9ad9 instanceof _0x371764?_0x6a9ad9:new _0x371764(function(_0x4830e9){_0x4830e9(_0x6a9ad9);});}return new(_0x371764||(_0x371764=Promise))(function(_0x2bf80b,_0x38498a){function _0x296260(_0x508104){try{_0x11780e(_0x5f5415[a13_0x4fc0('0x1e')](_0x508104));}catch(_0x359157){_0x38498a(_0x359157);}}function _0x3acd2c(_0x522442){try{_0x11780e(_0x5f5415[a13_0x4fc0('0x1f')](_0x522442));}catch(_0xa4e61d){_0x38498a(_0xa4e61d);}}function _0x11780e(_0x3347cf){_0x3347cf['done']?_0x2bf80b(_0x3347cf[a13_0x4fc0('0x4')]):_0x543d96(_0x3347cf[a13_0x4fc0('0x4')])[a13_0x4fc0('0x1d')](_0x296260,_0x3acd2c);}_0x11780e((_0x5f5415=_0x5f5415[a13_0x4fc0('0x0')](_0x22c645,_0x3bdbce||[]))['next']());});};Object[a13_0x4fc0('0x11')](exports,a13_0x4fc0('0xe'),{'value':!![]});exports[a13_0x4fc0('0x10')]=void 0x0;const create_unchanged_value_timeout_1=require('../../../utilities/create-unchanged-value-timeout');const environment_1=require(a13_0x4fc0('0x1a'));const waiter_1=require(a13_0x4fc0('0x15'));const process_task_1=require('./process-task');const {output}=require(a13_0x4fc0('0x8'));function processTasks(_0x13592d,_0x1bfb18,_0x328fa1,_0x326029){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1cd616={};const _0x56cabb=(0x0,create_unchanged_value_timeout_1['createUnchangedValueTimeout'])({'title':a13_0x4fc0('0xf')+environment_1['NO_COMPLETED_TASKS_TIMEOUT']/0x3e8+a13_0x4fc0('0x1c'),'timeout':environment_1[a13_0x4fc0('0xc')]});const _0x1efcf8=new waiter_1[(a13_0x4fc0('0xa'))]();while(!![]){if(environment_1['VERBOSE_LOGGING']){output[a13_0x4fc0('0x1')]({'title':a13_0x4fc0('0x18')});}yield _0x1efcf8['wait']();const _0x4a3624=yield _0x13592d['status'](_0x328fa1);if(environment_1['VERBOSE_LOGGING']){output[a13_0x4fc0('0x1')]({'title':a13_0x4fc0('0x1b'),'bodyLines':[a13_0x4fc0('0xb')+_0x328fa1,'executionStatus:\x20'+_0x4a3624[a13_0x4fc0('0x12')],a13_0x4fc0('0x19')+_0x4a3624[a13_0x4fc0('0x9')]['length'],a13_0x4fc0('0x13')+_0x4a3624['criticalErrorMessage']]});}if(_0x4a3624[a13_0x4fc0('0xd')]){output['error']({'title':'Distributed\x20Execution\x20Terminated','bodyLines':[a13_0x4fc0('0x14'),_0x4a3624[a13_0x4fc0('0xd')]]});process[a13_0x4fc0('0x3')](0x1);}_0x56cabb(_0x4a3624[a13_0x4fc0('0x9')][a13_0x4fc0('0x2')]);for(const _0x11533a of _0x4a3624[a13_0x4fc0('0x9')]){if(_0x1cd616[_0x11533a['taskId']])continue;yield(0x0,process_task_1[a13_0x4fc0('0x7')])(_0x1bfb18,_0x326029,_0x11533a);_0x1efcf8[a13_0x4fc0('0x5')]();_0x1cd616[_0x11533a[a13_0x4fc0('0x17')]]=!![];}if(_0x4a3624[a13_0x4fc0('0x12')]===a13_0x4fc0('0x16')){return{'commandStatus':_0x4a3624[a13_0x4fc0('0x6')],'runUrl':_0x4a3624['runUrl']};}}});}exports[a13_0x4fc0('0x10')]=processTasks; |
@@ -1,37 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.splitTasksIntoStages = void 0; | ||
function splitTasksIntoStages(taskGraph) { | ||
const stages = []; | ||
const notStagedTaskIds = new Set(Object.values(taskGraph.tasks).map((t) => t.id)); | ||
let stageIndex = 0; | ||
// Loop through tasks and try to stage them. As tasks are staged, they are removed from the loop | ||
while (notStagedTaskIds.size > 0) { | ||
const currentStage = (stages[stageIndex] = []); | ||
for (const taskId of notStagedTaskIds) { | ||
let ready = true; | ||
for (const dependency of taskGraph.dependencies[taskId]) { | ||
if (notStagedTaskIds.has(dependency)) { | ||
// dependency has not been staged yet, this task is not ready to be staged. | ||
ready = false; | ||
break; | ||
} | ||
} | ||
// Some dependency still has not been staged, skip it for now, it will be processed again | ||
if (!ready) { | ||
continue; | ||
} | ||
// All the dependencies have been staged, let's stage it. | ||
const task = taskGraph.tasks[taskId]; | ||
currentStage.push(task); | ||
} | ||
// Remove the entire new stage of tasks from the list | ||
for (const task of currentStage) { | ||
notStagedTaskIds.delete(task.id); | ||
} | ||
stageIndex++; | ||
} | ||
return stages; | ||
} | ||
exports.splitTasksIntoStages = splitTasksIntoStages; | ||
//# sourceMappingURL=split-task-graph-into-stages.js.map | ||
const a14_0xf7e3=['__esModule','values','push','splitTasksIntoStages','tasks','delete','dependencies','defineProperty'];(function(_0xe9565b,_0xf7e393){const _0x3a48d3=function(_0x102fea){while(--_0x102fea){_0xe9565b['push'](_0xe9565b['shift']());}};_0x3a48d3(++_0xf7e393);}(a14_0xf7e3,0xa1));const a14_0x3a48=function(_0xe9565b,_0xf7e393){_0xe9565b=_0xe9565b-0x0;let _0x3a48d3=a14_0xf7e3[_0xe9565b];return _0x3a48d3;};'use strict';Object[a14_0x3a48('0x6')](exports,a14_0x3a48('0x7'),{'value':!![]});exports[a14_0x3a48('0x2')]=void 0x0;function splitTasksIntoStages(_0x109006){const _0x44f291=[];const _0x574998=new Set(Object[a14_0x3a48('0x0')](_0x109006[a14_0x3a48('0x3')])['map'](_0xf37eee=>_0xf37eee['id']));let _0x2b260a=0x0;while(_0x574998['size']>0x0){const _0x373908=_0x44f291[_0x2b260a]=[];for(const _0x594a85 of _0x574998){let _0x584a98=!![];for(const _0xbaefd2 of _0x109006[a14_0x3a48('0x5')][_0x594a85]){if(_0x574998['has'](_0xbaefd2)){_0x584a98=![];break;}}if(!_0x584a98){continue;}const _0x40c659=_0x109006[a14_0x3a48('0x3')][_0x594a85];_0x373908[a14_0x3a48('0x1')](_0x40c659);}for(const _0x506c1c of _0x373908){_0x574998[a14_0x3a48('0x4')](_0x506c1c['id']);}_0x2b260a++;}return _0x44f291;}exports[a14_0x3a48('0x2')]=splitTasksIntoStages; |
@@ -1,100 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TaskGraphCreator = exports.createTaskGraphCompat = void 0; | ||
const stripJsonComments = require("strip-json-comments"); | ||
const fs_1 = require("fs"); | ||
const { getDependencyConfigs, workspaceRoot, } = require('../../../utilities/nx-imports'); | ||
function createTaskGraphCompat(options, projectGraph, tasks) { | ||
const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())); | ||
return new TaskGraphCreator(projectGraph, getDefaultDependencyConfigs(nxjson, options)).createTaskGraph(tasks); | ||
} | ||
exports.createTaskGraphCompat = createTaskGraphCompat; | ||
function getDefaultDependencyConfigs(nxJson, runnerOptions) { | ||
var _a, _b; | ||
const defaults = (_a = nxJson.targetDependencies) !== null && _a !== void 0 ? _a : {}; | ||
const strictlyOrderedTargets = runnerOptions | ||
? (_b = runnerOptions.strictlyOrderedTargets) !== null && _b !== void 0 ? _b : ['build'] | ||
: []; | ||
// Strictly Ordered Targets depend on their dependencies | ||
for (const target of strictlyOrderedTargets) { | ||
defaults[target] = defaults[target] || []; | ||
defaults[target].push({ | ||
target, | ||
projects: 'dependencies', | ||
}); | ||
} | ||
return defaults; | ||
} | ||
/** | ||
* This is only used for versions of Nx prior to 14 where the task graph | ||
* wasn't part of the context so we have to recreate it | ||
*/ | ||
class TaskGraphCreator { | ||
constructor(projectGraph, defaultTargetDependencies) { | ||
this.projectGraph = projectGraph; | ||
this.defaultTargetDependencies = defaultTargetDependencies; | ||
} | ||
createTaskGraph(tasks) { | ||
const graph = { | ||
roots: [], | ||
tasks: {}, | ||
dependencies: {}, | ||
}; | ||
for (const task of tasks) { | ||
this.addTaskToGraph(task, graph); | ||
const dependencyConfigs = getDependencyConfigs(task.target, this.defaultTargetDependencies, this.projectGraph); | ||
if (!dependencyConfigs) { | ||
continue; | ||
} | ||
this.addTaskDependencies(task, dependencyConfigs, tasks, graph); | ||
} | ||
graph.roots = Object.keys(graph.dependencies).filter((k) => graph.dependencies[k].length === 0); | ||
return graph; | ||
} | ||
addTaskDependencies(task, dependencyConfigs, tasks, graph) { | ||
for (const dependencyConfig of dependencyConfigs) { | ||
if (dependencyConfig.projects === 'self') { | ||
for (const t of tasks) { | ||
if (t.target.project === task.target.project && | ||
t.target.target === dependencyConfig.target) { | ||
graph.dependencies[task.id].push(t.id); | ||
} | ||
} | ||
} | ||
else if (dependencyConfig.projects === 'dependencies') { | ||
const seen = new Set(); | ||
this.addDependencies(task.target.project, dependencyConfig.target, tasks, graph, task.id, seen); | ||
} | ||
} | ||
} | ||
addDependencies(project, target, tasks, graph, taskId, seen) { | ||
seen.add(project); | ||
const dependencies = this.projectGraph.dependencies[project]; | ||
if (dependencies) { | ||
const projectDependencies = dependencies.map((dependency) => dependency.target); | ||
for (const projectDependency of projectDependencies) { | ||
if (seen.has(projectDependency)) { | ||
continue; | ||
} | ||
const dependency = this.findTask({ project: projectDependency, target }, tasks); | ||
if (dependency) { | ||
if (graph.dependencies[taskId].indexOf(dependency.id) === -1) { | ||
graph.dependencies[taskId].push(dependency.id); | ||
} | ||
} | ||
else { | ||
this.addDependencies(projectDependency, target, tasks, graph, taskId, seen); | ||
} | ||
} | ||
} | ||
} | ||
findTask({ project, target }, tasks) { | ||
return tasks.find((t) => t.target.project === project && t.target.target === target); | ||
} | ||
addTaskToGraph(task, graph) { | ||
graph.tasks[task.id] = task; | ||
graph.dependencies[task.id] = []; | ||
} | ||
} | ||
exports.TaskGraphCreator = TaskGraphCreator; | ||
//# sourceMappingURL=task-graph-creator.js.map | ||
const a15_0x207a=['tasks','readFileSync','createTaskGraphCompat','addTaskToGraph','project','addTaskDependencies','strip-json-comments','../../../utilities/nx-imports','map','/nx.json','toString','roots','projectGraph','TaskGraphCreator','__esModule','dependencies','push','filter','targetDependencies','findTask','keys','target','strictlyOrderedTargets','defineProperty','defaultTargetDependencies','parse','addDependencies','add','projects'];(function(_0x54327a,_0x207a1c){const _0x2fdce2=function(_0xad14bb){while(--_0xad14bb){_0x54327a['push'](_0x54327a['shift']());}};_0x2fdce2(++_0x207a1c);}(a15_0x207a,0x1c6));const a15_0x2fdc=function(_0x54327a,_0x207a1c){_0x54327a=_0x54327a-0x0;let _0x2fdce2=a15_0x207a[_0x54327a];return _0x2fdce2;};'use strict';Object[a15_0x2fdc('0x4')](exports,a15_0x2fdc('0x18'),{'value':!![]});exports['TaskGraphCreator']=exports['createTaskGraphCompat']=void 0x0;const stripJsonComments=require(a15_0x2fdc('0x10'));const fs_1=require('fs');const {getDependencyConfigs,workspaceRoot}=require(a15_0x2fdc('0x11'));function createTaskGraphCompat(_0x37927c,_0x2cde77,_0xa01ebe){const _0x5e594b=JSON[a15_0x2fdc('0x6')](stripJsonComments((0x0,fs_1[a15_0x2fdc('0xb')])(workspaceRoot+a15_0x2fdc('0x13'))[a15_0x2fdc('0x14')]()));return new TaskGraphCreator(_0x2cde77,getDefaultDependencyConfigs(_0x5e594b,_0x37927c))['createTaskGraph'](_0xa01ebe);}exports[a15_0x2fdc('0xc')]=createTaskGraphCompat;function getDefaultDependencyConfigs(_0xbc08ff,_0x232ee2){var _0x5f5643,_0x27ba7e;const _0xb0720b=(_0x5f5643=_0xbc08ff[a15_0x2fdc('0x1c')])!==null&&_0x5f5643!==void 0x0?_0x5f5643:{};const _0x4f847a=_0x232ee2?(_0x27ba7e=_0x232ee2[a15_0x2fdc('0x3')])!==null&&_0x27ba7e!==void 0x0?_0x27ba7e:['build']:[];for(const _0xde233b of _0x4f847a){_0xb0720b[_0xde233b]=_0xb0720b[_0xde233b]||[];_0xb0720b[_0xde233b][a15_0x2fdc('0x1a')]({'target':_0xde233b,'projects':a15_0x2fdc('0x19')});}return _0xb0720b;}class TaskGraphCreator{constructor(_0x5bfdc2,_0x2c80cc){this[a15_0x2fdc('0x16')]=_0x5bfdc2;this[a15_0x2fdc('0x5')]=_0x2c80cc;}['createTaskGraph'](_0x4bd3f8){const _0x4e2a26={'roots':[],'tasks':{},'dependencies':{}};for(const _0x2d8a41 of _0x4bd3f8){this[a15_0x2fdc('0xd')](_0x2d8a41,_0x4e2a26);const _0x3d1307=getDependencyConfigs(_0x2d8a41[a15_0x2fdc('0x2')],this[a15_0x2fdc('0x5')],this[a15_0x2fdc('0x16')]);if(!_0x3d1307){continue;}this[a15_0x2fdc('0xf')](_0x2d8a41,_0x3d1307,_0x4bd3f8,_0x4e2a26);}_0x4e2a26[a15_0x2fdc('0x15')]=Object[a15_0x2fdc('0x1')](_0x4e2a26['dependencies'])[a15_0x2fdc('0x1b')](_0x3eb998=>_0x4e2a26[a15_0x2fdc('0x19')][_0x3eb998]['length']===0x0);return _0x4e2a26;}[a15_0x2fdc('0xf')](_0x516325,_0x1d497e,_0x2af2ac,_0x3d579b){for(const _0x372fa3 of _0x1d497e){if(_0x372fa3[a15_0x2fdc('0x9')]==='self'){for(const _0xc22392 of _0x2af2ac){if(_0xc22392[a15_0x2fdc('0x2')][a15_0x2fdc('0xe')]===_0x516325[a15_0x2fdc('0x2')][a15_0x2fdc('0xe')]&&_0xc22392['target']['target']===_0x372fa3[a15_0x2fdc('0x2')]){_0x3d579b['dependencies'][_0x516325['id']][a15_0x2fdc('0x1a')](_0xc22392['id']);}}}else if(_0x372fa3['projects']===a15_0x2fdc('0x19')){const _0x4fc5b8=new Set();this[a15_0x2fdc('0x7')](_0x516325['target'][a15_0x2fdc('0xe')],_0x372fa3[a15_0x2fdc('0x2')],_0x2af2ac,_0x3d579b,_0x516325['id'],_0x4fc5b8);}}}[a15_0x2fdc('0x7')](_0x5e629e,_0x42d1bd,_0x4af056,_0x23313a,_0x1b3b3a,_0x14cac7){_0x14cac7[a15_0x2fdc('0x8')](_0x5e629e);const _0x266c86=this[a15_0x2fdc('0x16')][a15_0x2fdc('0x19')][_0x5e629e];if(_0x266c86){const _0x478518=_0x266c86[a15_0x2fdc('0x12')](_0x5a751f=>_0x5a751f['target']);for(const _0x1c855e of _0x478518){if(_0x14cac7['has'](_0x1c855e)){continue;}const _0x332210=this['findTask']({'project':_0x1c855e,'target':_0x42d1bd},_0x4af056);if(_0x332210){if(_0x23313a[a15_0x2fdc('0x19')][_0x1b3b3a]['indexOf'](_0x332210['id'])===-0x1){_0x23313a[a15_0x2fdc('0x19')][_0x1b3b3a][a15_0x2fdc('0x1a')](_0x332210['id']);}}else{this[a15_0x2fdc('0x7')](_0x1c855e,_0x42d1bd,_0x4af056,_0x23313a,_0x1b3b3a,_0x14cac7);}}}}[a15_0x2fdc('0x0')]({project,target},_0x427769){return _0x427769['find'](_0x3a7104=>_0x3a7104['target'][a15_0x2fdc('0xe')]===project&&_0x3a7104[a15_0x2fdc('0x2')][a15_0x2fdc('0x2')]===target);}[a15_0x2fdc('0xd')](_0x2a6dd1,_0x4eaa2a){_0x4eaa2a[a15_0x2fdc('0xa')][_0x2a6dd1['id']]=_0x2a6dd1;_0x4eaa2a[a15_0x2fdc('0x19')][_0x2a6dd1['id']]=[];}}exports[a15_0x2fdc('0x17')]=TaskGraphCreator; |
{ | ||
"name": "nx-cloud", | ||
"version": "16.0.0-beta.8", | ||
"version": "16.0.0", | ||
"description": "Distributed caching and task execution for Lerna and Nx", | ||
@@ -31,4 +31,4 @@ "keywords": [ | ||
"fs-extra": "^11.1.0", | ||
"@nrwl/nx-cloud": "16.0.0-beta.8" | ||
"@nrwl/nx-cloud": "16.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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 5 instances 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
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 7 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
356488
190
2
2827
12
5
184
+ Added@nrwl/nx-cloud@16.0.0(transitive)
- Removed@nrwl/nx-cloud@16.0.0-beta.8(transitive)
Updated@nrwl/nx-cloud@16.0.0