Socket
Socket
Sign inDemoInstall

nx-cloud

Package Overview
Dependencies
Maintainers
2
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nx-cloud - npm Package Compare versions

Comparing version 19.0.0 to 19.1.0-beta.1

37

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

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

const a0_0x58fc=['warn','defineProperty','apply','/nx-cloud/report-client-error','__awaiter','__esModule','apiAxiosInstance','../../utilities/axios','throw','then','value','../../utilities/nx-imports-light','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','post','axiosMultipleTries','createApiAxiosInstance'];(function(_0x148ccf,_0x58fc68){const _0x524f14=function(_0x2df0a5){while(--_0x2df0a5){_0x148ccf['push'](_0x148ccf['shift']());}};_0x524f14(++_0x58fc68);}(a0_0x58fc,0xba));const a0_0x524f=function(_0x148ccf,_0x58fc68){_0x148ccf=_0x148ccf-0x0;let _0x524f14=a0_0x58fc[_0x148ccf];return _0x524f14;};'use strict';var __awaiter=this&&this[a0_0x524f('0xa')]||function(_0x312051,_0x36ec56,_0x131d5a,_0x5ed1b5){function _0x55e03a(_0x1e561c){return _0x1e561c instanceof _0x131d5a?_0x1e561c:new _0x131d5a(function(_0x4d49b6){_0x4d49b6(_0x1e561c);});}return new(_0x131d5a||(_0x131d5a=Promise))(function(_0x27b1aa,_0x29b4d7){function _0x36bcc7(_0xc34f95){try{_0xa420c6(_0x5ed1b5['next'](_0xc34f95));}catch(_0x17a729){_0x29b4d7(_0x17a729);}}function _0x35f1f7(_0x3049e9){try{_0xa420c6(_0x5ed1b5[a0_0x524f('0xe')](_0x3049e9));}catch(_0x112cb1){_0x29b4d7(_0x112cb1);}}function _0xa420c6(_0x44d56c){_0x44d56c['done']?_0x27b1aa(_0x44d56c[a0_0x524f('0x0')]):_0x55e03a(_0x44d56c[a0_0x524f('0x0')])[a0_0x524f('0xf')](_0x36bcc7,_0x35f1f7);}_0xa420c6((_0x5ed1b5=_0x5ed1b5[a0_0x524f('0x8')](_0x312051,_0x36ec56||[]))['next']());});};Object[a0_0x524f('0x7')](exports,a0_0x524f('0xb'),{'value':!![]});exports['ErrorReporterApi']=void 0x0;const axios_1=require(a0_0x524f('0xd'));const {output}=require(a0_0x524f('0x1'));class ErrorReporterApi{constructor(_0x583dda){this[a0_0x524f('0xc')]=(0x0,axios_1[a0_0x524f('0x5')])(_0x583dda);}['reportError'](_0x4f2dcb){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x524f('0x4')])(()=>this['apiAxiosInstance'][a0_0x524f('0x3')](a0_0x524f('0x9'),{'message':_0x4f2dcb}));}catch(_0x5ddbc1){output[a0_0x524f('0x6')]({'title':a0_0x524f('0x2')+_0x4f2dcb+'\x27','bodyLines':[_0x5ddbc1['message']]});}});}}exports['ErrorReporterApi']=ErrorReporterApi;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorReporterApi = void 0;
const axios_1 = require("../../utilities/axios");
const { output } = require('../../utilities/nx-imports-light');
class ErrorReporterApi {
constructor(options) {
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
reportError(message) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', {
message,
}));
}
catch (e) {
output.warn({
title: `Unable to record the following error: '${message}'`,
bodyLines: [e.message],
});
}
});
}
}
exports.ErrorReporterApi = ErrorReporterApi;
//# sourceMappingURL=error-reporter.api.js.map

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

const a1_0x921a=['throw','createRunGroup','apiAxiosInstance','mapRespToPerfEntry','done','post','defineProperty','apply','../../utilities/metric-logger','response','message','RunGroupApi','then','completeRunGroup','axiosException','error','recordMetric','value','axiosMultipleTries','RUNNER_FAILURE_PERF_ENTRY','next','/nx-cloud/executions/create-run-group','../../utilities/axios'];(function(_0x21197b,_0x921af){const _0x2d4f86=function(_0x5dee4d){while(--_0x5dee4d){_0x21197b['push'](_0x21197b['shift']());}};_0x2d4f86(++_0x921af);}(a1_0x921a,0xef));const a1_0x2d4f=function(_0x21197b,_0x921af){_0x21197b=_0x21197b-0x0;let _0x2d4f86=a1_0x921a[_0x21197b];return _0x2d4f86;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x5c7ebd,_0x2e3489,_0x52c5fa,_0x1fd626){function _0x22bdb1(_0x142158){return _0x142158 instanceof _0x52c5fa?_0x142158:new _0x52c5fa(function(_0x5f3dce){_0x5f3dce(_0x142158);});}return new(_0x52c5fa||(_0x52c5fa=Promise))(function(_0x4cd796,_0x227ec5){function _0x23fe1c(_0x4f8986){try{_0x51aa7a(_0x1fd626[a1_0x2d4f('0xb')](_0x4f8986));}catch(_0xeb7e9a){_0x227ec5(_0xeb7e9a);}}function _0x204674(_0x284a21){try{_0x51aa7a(_0x1fd626[a1_0x2d4f('0xe')](_0x284a21));}catch(_0x1ceebd){_0x227ec5(_0x1ceebd);}}function _0x51aa7a(_0x38008c){_0x38008c[a1_0x2d4f('0x12')]?_0x4cd796(_0x38008c[a1_0x2d4f('0x8')]):_0x22bdb1(_0x38008c[a1_0x2d4f('0x8')])[a1_0x2d4f('0x3')](_0x23fe1c,_0x204674);}_0x51aa7a((_0x1fd626=_0x1fd626[a1_0x2d4f('0x15')](_0x5c7ebd,_0x2e3489||[]))['next']());});};Object[a1_0x2d4f('0x14')](exports,'__esModule',{'value':!![]});exports[a1_0x2d4f('0x2')]=void 0x0;const axios_1=require(a1_0x2d4f('0xd'));const metric_logger_1=require(a1_0x2d4f('0x16'));const {output}=require('../../utilities/nx-imports-light');class RunGroupApi{constructor(_0x2b9ba2){this[a1_0x2d4f('0x10')]=(0x0,axios_1['createApiAxiosInstance'])(_0x2b9ba2);}[a1_0x2d4f('0xf')](_0x1c4295,_0x3953ef,_0x345f00,_0x5f4677,_0x364c88,_0x4b5499,_0x117c24,_0x21b145,_0x458749){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x914385;const _0x41eae=(0x0,metric_logger_1['createMetricRecorder'])('createRunGroup');try{const _0x3770ee=yield(0x0,axios_1[a1_0x2d4f('0x9')])(()=>this[a1_0x2d4f('0x10')][a1_0x2d4f('0x13')](a1_0x2d4f('0xc'),{'branch':_0x1c4295,'runGroup':_0x3953ef,'ciExecutionId':_0x345f00,'ciExecutionEnv':_0x5f4677,'stopAgentsOnFailure':_0x364c88,'agentCount':_0x4b5499,'stopAgentsAfter':_0x117c24,'commitSha':_0x21b145}));_0x41eae[a1_0x2d4f('0x7')]((0x0,metric_logger_1[a1_0x2d4f('0x11')])(_0x3770ee));}catch(_0x33d184){_0x41eae[a1_0x2d4f('0x7')](((_0x914385=_0x33d184===null||_0x33d184===void 0x0?void 0x0:_0x33d184[a1_0x2d4f('0x5')])===null||_0x914385===void 0x0?void 0x0:_0x914385[a1_0x2d4f('0x0')])?(0x0,metric_logger_1[a1_0x2d4f('0x11')])(_0x33d184[a1_0x2d4f('0x5')][a1_0x2d4f('0x0')]):metric_logger_1[a1_0x2d4f('0xa')]);output[a1_0x2d4f('0x6')]({'title':_0x33d184[a1_0x2d4f('0x1')]});process['exit'](0x1);}});}['completeRunGroup'](_0x470ca9,_0x7e350d,_0x2a8347,_0x1a5679){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x3b3597;const _0x4f225c=(0x0,metric_logger_1['createMetricRecorder'])(a1_0x2d4f('0x4'));try{const _0xd99e=yield(0x0,axios_1[a1_0x2d4f('0x9')])(()=>this['apiAxiosInstance']['post']('/nx-cloud/executions/complete-run-group',{'branch':_0x470ca9,'runGroup':_0x7e350d,'ciExecutionId':_0x2a8347,'ciExecutionEnv':_0x1a5679}));_0x4f225c[a1_0x2d4f('0x7')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0xd99e));}catch(_0x11be02){_0x4f225c[a1_0x2d4f('0x7')](((_0x3b3597=_0x11be02===null||_0x11be02===void 0x0?void 0x0:_0x11be02[a1_0x2d4f('0x5')])===null||_0x3b3597===void 0x0?void 0x0:_0x3b3597['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x11be02['axiosException'][a1_0x2d4f('0x0')]):metric_logger_1[a1_0x2d4f('0xa')]);output[a1_0x2d4f('0x6')]({'title':_0x11be02[a1_0x2d4f('0x1')]});process['exit'](0x1);}});}}exports[a1_0x2d4f('0x2')]=RunGroupApi;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunGroupApi = void 0;
const axios_1 = require("../../utilities/axios");
const metric_logger_1 = require("../../utilities/metric-logger");
const { output } = require('../../utilities/nx-imports-light');
class RunGroupApi {
constructor(options) {
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
createRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv, stopAgentsOnFailure, agentCount, stopAgentsAfter, commitSha, commitRef) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
try {
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
branch,
runGroup,
ciExecutionId,
ciExecutionEnv,
stopAgentsOnFailure,
agentCount,
stopAgentsAfter,
commitSha,
}));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
output.error({
title: e.message,
});
process.exit(1);
}
});
}
completeRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
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

3

lib/core/file-storage/e2e-encryption.js

@@ -33,4 +33,3 @@ "use strict";

try {
const decipher = (0, crypto_1.createDecipheriv)('aes-256-cbc', this.encryptionKey, encryptedFileContents.slice(0, 16) // iv
);
const decipher = (0, crypto_1.createDecipheriv)('aes-256-cbc', this.encryptionKey, encryptedFileContents.slice(0, 16));
const encryptedText = encryptedFileContents.slice(16); // remove the iv

@@ -37,0 +36,0 @@ const d = decipher.update(encryptedText);

@@ -14,2 +14,3 @@ export interface DefaultTasksRunnerOptions {

accessToken?: string;
nxCloudId?: string;
canTrackAnalytics?: boolean;

@@ -16,0 +17,0 @@ encryptionKey?: string;

@@ -1,1 +0,104 @@

const a0_0x262f=['md5','digest','params','getTerminalOutput','updateStartedTask','toISOString','outputObfuscator','find','createHash','project','base64','hash','cache-miss','../../../utilities/serializer-overrides','scheduledTasks','taskId','startTime','../../terminal-output/read-task-terminal-output','update','code','status','hashDetails','endTime','cleanUpHashDetails','collectTerminalOutput','tasks','local-cache','keys','nodes','target','npm:','runContext','cache','CloudEnabledLifeCycle','readTaskTerminalOutput','sort','push','endCommand','remote-cache','crypto','cacheDirectory','startsWith','scheduleTask','__esModule','task','cacheableOperations','statuses'];(function(_0x140651,_0x262f72){const _0x1f6cb5=function(_0x5e23f5){while(--_0x5e23f5){_0x140651['push'](_0x140651['shift']());}};_0x1f6cb5(++_0x262f72);}(a0_0x262f,0xb8));const a0_0x1f6c=function(_0x140651,_0x262f72){_0x140651=_0x140651-0x0;let _0x1f6cb5=a0_0x262f[_0x140651];return _0x1f6cb5;};'use strict';Object['defineProperty'](exports,a0_0x1f6c('0x0'),{'value':!![]});exports[a0_0x1f6c('0x25')]=void 0x0;const crypto_1=require(a0_0x1f6c('0x2b'));const serializer_overrides_1=require(a0_0x1f6c('0x11'));const read_task_terminal_output_1=require(a0_0x1f6c('0x15'));class CloudEnabledLifeCycle{constructor(_0x154cba,_0x5aac9d,_0x40bbf0,_0x3cb2eb,_0x111bd1,_0x45a865){this[a0_0x1f6c('0x23')]=_0x154cba;this[a0_0x1f6c('0x2c')]=_0x5aac9d;this['collectTerminalOutput']=_0x40bbf0;this[a0_0x1f6c('0x2')]=_0x3cb2eb;this['outputObfuscator']=_0x111bd1;this[a0_0x1f6c('0x1d')]=_0x45a865;}[a0_0x1f6c('0x2e')](_0x43c9fc){this[a0_0x1f6c('0x23')][a0_0x1f6c('0x12')][a0_0x1f6c('0x28')](_0x43c9fc);}['startTask'](_0x20b201){this['tasks'][a0_0x1f6c('0x28')]({'taskId':_0x20b201['id'],'startTime':new Date()[a0_0x1f6c('0x9')](),'target':_0x20b201['target'][a0_0x1f6c('0x21')],'projectName':_0x20b201[a0_0x1f6c('0x21')][a0_0x1f6c('0xd')],'hash':_0x20b201[a0_0x1f6c('0xf')],'hashDetails':this['cleanUpHashDetails'](_0x20b201[a0_0x1f6c('0x19')]),'params':(0x0,serializer_overrides_1['serializeOverrides'])(_0x20b201),'uploadedToStorage':![]});}['endTasks'](_0x483b7e){for(let _0x1055ac of _0x483b7e){let _0x199fe7;const _0x2a7176=_0x1055ac[a0_0x1f6c('0x18')]===a0_0x1f6c('0x2a');const _0x4865df=_0x1055ac[a0_0x1f6c('0x18')]===a0_0x1f6c('0x24');const _0x13799f=_0x1055ac[a0_0x1f6c('0x18')]===a0_0x1f6c('0x1e')||_0x1055ac['status']==='local-cache-kept-existing'||_0x4865df;if(this[a0_0x1f6c('0x23')][a0_0x1f6c('0x3')][_0x1055ac[a0_0x1f6c('0x1')][a0_0x1f6c('0xf')]]){_0x199fe7=this[a0_0x1f6c('0x23')][a0_0x1f6c('0x3')][_0x1055ac[a0_0x1f6c('0x1')][a0_0x1f6c('0xf')]];}else if(_0x2a7176){_0x199fe7='remote-cache-hit';}else if(_0x13799f){_0x199fe7='local-cache-hit';}else{_0x199fe7=a0_0x1f6c('0x10');}this[a0_0x1f6c('0x8')](_0x1055ac,_0x199fe7);}}[a0_0x1f6c('0x29')](){}['updateStartedTask'](_0x19800,_0x571ca8){const _0x1f6ea0=this[a0_0x1f6c('0x1d')][a0_0x1f6c('0xb')](_0x24e703=>_0x24e703[a0_0x1f6c('0x13')]===_0x19800[a0_0x1f6c('0x1')]['id']);if(!_0x1f6ea0){throw new Error('Cannot\x20find\x20task\x20'+_0x19800['task']['id']);}if((_0x19800===null||_0x19800===void 0x0?void 0x0:_0x19800[a0_0x1f6c('0x14')])&&(_0x19800===null||_0x19800===void 0x0?void 0x0:_0x19800[a0_0x1f6c('0x1a')])){_0x1f6ea0[a0_0x1f6c('0x14')]=new Date(_0x19800['startTime'])[a0_0x1f6c('0x9')]();_0x1f6ea0['endTime']=new Date(_0x19800['endTime'])[a0_0x1f6c('0x9')]();}else{_0x1f6ea0[a0_0x1f6c('0x1a')]=new Date()['toISOString']();}_0x1f6ea0[a0_0x1f6c('0x18')]=_0x19800[a0_0x1f6c('0x17')];_0x1f6ea0[a0_0x1f6c('0x6')]=this[a0_0x1f6c('0xa')]['obfuscate'](_0x1f6ea0[a0_0x1f6c('0x6')]);_0x1f6ea0['cacheStatus']=_0x571ca8;if(this[a0_0x1f6c('0x1c')]){_0x1f6ea0['terminalOutput']=this[a0_0x1f6c('0x7')](_0x19800[a0_0x1f6c('0x1')][a0_0x1f6c('0xf')],_0x1f6ea0['cacheStatus'],_0x19800[a0_0x1f6c('0x17')]);}}[a0_0x1f6c('0x7')](_0x3c8b7,_0x2d30ae,_0x47f5c8){return(0x0,read_task_terminal_output_1[a0_0x1f6c('0x26')])(this[a0_0x1f6c('0x2c')],this[a0_0x1f6c('0xa')],_0x3c8b7,_0x2d30ae,_0x47f5c8);}[a0_0x1f6c('0x1b')](_0x13e368){const _0xb7a5d0={};const _0x2bec14=[];for(const _0x326f0e of Object[a0_0x1f6c('0x1f')](_0x13e368[a0_0x1f6c('0x20')])){if(_0x326f0e[a0_0x1f6c('0x2d')](a0_0x1f6c('0x22'))){_0x2bec14['push'](_0x13e368[a0_0x1f6c('0x20')][_0x326f0e]);}else{_0xb7a5d0[_0x326f0e]=_0x13e368[a0_0x1f6c('0x20')][_0x326f0e];}}_0x2bec14[a0_0x1f6c('0x27')]();if(_0x2bec14['length']>0x0){const _0x1e8f86=(0x0,crypto_1[a0_0x1f6c('0xc')])(a0_0x1f6c('0x4'));_0x1e8f86[a0_0x1f6c('0x16')](_0x2bec14['join']('|'));_0xb7a5d0['npmDependencies']=_0x1e8f86[a0_0x1f6c('0x5')](a0_0x1f6c('0xe'));}return{'nodes':_0xb7a5d0,'runtime':_0x13e368['runtime'],'implicitDeps':_0x13e368['implicitDeps']};}}exports[a0_0x1f6c('0x25')]=CloudEnabledLifeCycle;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudEnabledLifeCycle = void 0;
const crypto_1 = require("crypto");
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), // the case is needed if you use older version of Nx
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 = {};
const npm = [];
for (const k of Object.keys(hashDetails.nodes)) {
if (k.startsWith('npm:')) {
npm.push(hashDetails.nodes[k]);
}
else {
nodes[k] = hashDetails.nodes[k];
}
}
npm.sort();
if (npm.length > 0) {
const hasher = (0, crypto_1.createHash)('md5');
hasher.update(npm.join('|'));
nodes['npmDependencies'] = hasher.digest('base64');
}
return {
nodes,
runtime: hashDetails.runtime,
implicitDeps: hashDetails.implicitDeps,
};
}
}
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
//# sourceMappingURL=cloud-enabled-life-cycle.js.map

@@ -1,1 +0,321 @@

const a1_0x126b=['CloudRemoteCache','EndOfRunMessage','parseCommand','hash','getRunGroup','find','catch','stringify','__awaiter','pathExists','filter','defineProperty','throw','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','daemon','../../terminal-output/message-reporter','enabled','ENCRYPTION_KEY','../../file-storage/e2e-encryption','../../terminal-output/end-of-run-message','encryptionKey','requests','join','warn','url','submitRunMetrics','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','endRun','message','cacheStatus','error','map','value','apply','resolve','taskId','obfuscate','exit','done','OutputObfuscator','../../file-storage/file-storage','../../../utilities/metric-logger','__esModule','lifeCycle','note','processInBackground','complete','../../api/error-reporter.api','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','accessToken','agentRunningInDistributedExecution','CloudEnabledLifeCycle','ErrorReporterApi','./cloud-run.api','skipNxCache','./cloud-enabled-life-cycle','length','all','forEach','ACCESS_TOKEN','../../../utilities/nx-imports-light','getBranch','printMessages','tasks-hashes-','E2EEncryption','Executed\x20tasks\x20with\x20hashes:\x20','FileStorage','/runs/','waitForStoreRequestsToComplete','Task\x20with\x20hash\x20','then','env','../../../utilities/nx-imports','Nx\x20Cloud\x20Problems','runUrl','push','toISOString','path','toString','storedHashes','anyErrors','../../../utilities/environment','.commit','next','./cloud-remote-cache','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','maskedProperties','cloud-enabled-runner','assign','https://nx.app','\x20isn\x27t\x20recorded','./id-generator','local-cache-hit','subscribe'];(function(_0x1d9853,_0x126b59){const _0x2258eb=function(_0x2b619e){while(--_0x2b619e){_0x1d9853['push'](_0x1d9853['shift']());}};_0x2258eb(++_0x126b59);}(a1_0x126b,0xe0));const a1_0x2258=function(_0x1d9853,_0x126b59){_0x1d9853=_0x1d9853-0x0;let _0x2258eb=a1_0x126b[_0x1d9853];return _0x2258eb;};'use strict';var __awaiter=this&&this[a1_0x2258('0x42')]||function(_0x3c3f21,_0xdceb35,_0x17bd46,_0x5337e5){function _0xd5b529(_0x5f241d){return _0x5f241d instanceof _0x17bd46?_0x5f241d:new _0x17bd46(function(_0x33feea){_0x33feea(_0x5f241d);});}return new(_0x17bd46||(_0x17bd46=Promise))(function(_0x2e528f,_0x329b66){function _0x39bdee(_0xe1f71d){try{_0x4e7d9a(_0x5337e5[a1_0x2258('0x2f')](_0xe1f71d));}catch(_0xb656c1){_0x329b66(_0xb656c1);}}function _0x36b7cf(_0x2b1060){try{_0x4e7d9a(_0x5337e5[a1_0x2258('0x46')](_0x2b1060));}catch(_0x1ad6d8){_0x329b66(_0x1ad6d8);}}function _0x4e7d9a(_0x57afda){_0x57afda[a1_0x2258('0x2')]?_0x2e528f(_0x57afda[a1_0x2258('0x5a')]):_0xd5b529(_0x57afda[a1_0x2258('0x5a')])[a1_0x2258('0x22')](_0x39bdee,_0x36b7cf);}_0x4e7d9a((_0x5337e5=_0x5337e5[a1_0x2258('0x5b')](_0x3c3f21,_0xdceb35||[]))['next']());});};Object[a1_0x2258('0x45')](exports,a1_0x2258('0x6'),{'value':!![]});exports['cloudEnabledTasksRunner']=void 0x0;const fs_1=require('fs');const fs_extra_1=require('fs-extra');const path=require('path');const path_1=require(a1_0x2258('0x29'));const environment_1=require(a1_0x2258('0x2d'));const metric_logger_1=require(a1_0x2258('0x5'));const remove_trailing_slash_1=require('../../../utilities/remove-trailing-slash');const error_reporter_api_1=require(a1_0x2258('0xb'));const e2e_encryption_1=require(a1_0x2258('0x4c'));const file_storage_1=require(a1_0x2258('0x4'));const end_of_run_message_1=require(a1_0x2258('0x4d'));const message_reporter_1=require(a1_0x2258('0x49'));const output_obfuscator_1=require('../../terminal-output/output-obfuscator');const cloud_enabled_life_cycle_1=require(a1_0x2258('0x13'));const cloud_remote_cache_1=require(a1_0x2258('0x30'));const cloud_run_api_1=require(a1_0x2258('0x11'));const id_generator_1=require(a1_0x2258('0x37'));const {output}=require(a1_0x2258('0x18'));const {tasksRunner,cacheDirectory}=require(a1_0x2258('0x24'));function createApi(_0x22a302,_0x5cf32a,_0x1f23a9){const _0x11dd50=(0x0,environment_1['getMachineInfo'])();return new cloud_run_api_1['CloudRunApi'](_0x22a302,_0x1f23a9,_0x5cf32a,_0x11dd50);}function storeTaskHashes(_0x1c41aa,_0x9ace78,_0x22c26c){const _0x3dbb40=JSON[a1_0x2258('0x41')](_0x1c41aa[a1_0x2258('0x59')](_0x50433f=>({'taskId':_0x50433f[a1_0x2258('0x5d')],'hash':_0x50433f[a1_0x2258('0x3d')]})));if(environment_1['VERBOSE_LOGGING']){output[a1_0x2258('0x8')]({'title':a1_0x2258('0x1d')+_0x3dbb40});}(0x0,fs_1['writeFileSync'])(path[a1_0x2258('0x50')](_0x9ace78,a1_0x2258('0x1b')+_0x22c26c),_0x3dbb40);}function storeLocalCacheHits(_0x3225ce,_0x3bcc74,_0x50101f){const _0x45ab70=_0x3225ce[a1_0x2258('0x44')](_0x1a158f=>_0x1a158f[a1_0x2258('0x57')]===a1_0x2258('0x38'))[a1_0x2258('0x59')](_0x18a900=>_0x18a900[a1_0x2258('0x3d')]);_0x45ab70[a1_0x2258('0x16')](_0x460a35=>_0x3bcc74['store'](_0x460a35,_0x50101f));}function onComplete(_0xeb4f2e){return __awaiter(this,arguments,void 0x0,function*({daemon,options,fileStorage,remoteCache,api,outputObfuscator,runStartTime,messages,endOfRunMessage,taskExecutions,versionOfNxBefore133,inner,encryptionKey,storeInCurrentProcess,distributedExecutionId,runContext}){const _0x2b80eb=new Date()[a1_0x2258('0x28')]();const _0x5cf170=(0x0,environment_1[a1_0x2258('0x19')])();const _0x152517={'command':outputObfuscator[a1_0x2258('0x0')]((0x0,environment_1[a1_0x2258('0x3c')])()),'startTime':runStartTime,'endTime':_0x2b80eb,'distributedExecutionId':distributedExecutionId,'branch':_0x5cf170,'runGroup':(0x0,environment_1[a1_0x2258('0x3e')])(),'sha':_0x5cf170?(0x0,environment_1['extractGitSha'])():undefined,'inner':inner};const _0xffe157={'branch':_0x5cf170,'runGroup':(0x0,environment_1['getRunGroup'])(),'ciExecutionId':(0x0,environment_1['getCIExecutionId'])(),'ciExecutionEnv':(0x0,environment_1['getCIExecutionEnv'])()};if(storeInCurrentProcess){if((0x0,environment_1[a1_0x2258('0xe')])(distributedExecutionId)){storeTaskHashes(taskExecutions,cacheDirectory,distributedExecutionId);storeLocalCacheHits(taskExecutions,remoteCache,cacheDirectory);}try{yield remoteCache[a1_0x2258('0x20')]();}catch(_0x43bcb0){output[a1_0x2258('0x58')]({'title':a1_0x2258('0x47')});messages[a1_0x2258('0x1a')]();return![];}for(const _0x1b5add of fileStorage[a1_0x2258('0x2b')]){const _0x469a7d=taskExecutions[a1_0x2258('0x3f')](_0x26aa17=>_0x26aa17[a1_0x2258('0x3d')]===_0x1b5add);if(!_0x469a7d){throw new Error(a1_0x2258('0x21')+_0x1b5add+a1_0x2258('0x36'));}_0x469a7d['uploadedToStorage']=!![];}try{yield api[a1_0x2258('0x55')](_0x152517,taskExecutions,_0xffe157);}catch(_0x15e221){output['error']({'title':a1_0x2258('0x54')});messages['printMessages']();return![];}yield(0x0,metric_logger_1[a1_0x2258('0x53')])(options);}else{try{const _0x388394=environment_1[a1_0x2258('0x17')]?environment_1['ACCESS_TOKEN']:options[a1_0x2258('0xd')];const _0x501236=(0x0,id_generator_1['generateUniqueLinkId'])();const _0x3f256e=require[a1_0x2258('0x5c')]('nx-cloud/lib/daemon/process-run-end');yield daemon[a1_0x2258('0x9')](_0x3f256e,{'encryptionKey':encryptionKey,'runnerOptions':Object['assign'](Object[a1_0x2258('0x34')]({},options),{'accessToken':_0x388394}),'delayedStoreRequests':remoteCache['delayedStoreRequests'],'ciExecutionContext':_0xffe157,'runEnd':{'runData':_0x152517,'taskExecutions':taskExecutions,'linkId':_0x501236}});runContext[a1_0x2258('0x26')]=(0x0,remove_trailing_slash_1['removeTrailingSlash'])(options[a1_0x2258('0x52')]||a1_0x2258('0x35'))+a1_0x2258('0x1f')+_0x501236;}catch(_0x5a3380){output[a1_0x2258('0x51')]({'title':a1_0x2258('0x25'),'bodyLines':[_0x5a3380[a1_0x2258('0x56')]||_0x5a3380[a1_0x2258('0x2a')]()]});return![];}}if(versionOfNxBefore133){setTimeout(()=>{messages['printMessages']();if(!messages[a1_0x2258('0x2c')]&&!inner){endOfRunMessage['printCacheHitsMessage']();}},0x0);}else{messages[a1_0x2258('0x1a')]();if(!messages[a1_0x2258('0x2c')]&&!inner){endOfRunMessage['printCacheHitsMessage']();}}return!![];});}function createLifeCycle(_0x287009,_0x63315b,_0x27d484,_0x591b57){const _0x252ad9=new cloud_enabled_life_cycle_1[(a1_0x2258('0xf'))](_0x287009,cacheDirectory,!![],_0x63315b['cacheableOperations']||[],_0x27d484,_0x591b57);try{const {CompositeLifeCycle}=require(a1_0x2258('0x24'));if(!CompositeLifeCycle)return _0x252ad9;return new CompositeLifeCycle([_0x63315b[a1_0x2258('0x7')],_0x252ad9]);}catch(_0x58f1fa){return _0x252ad9;}}function fetchUrlsForKnownHashesUpfront(_0x2d847e,_0x4ded22,_0xf1f80a,_0x26cc95,_0x50bf7e){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x26cc95[a1_0x2258('0x12')])return;let _0x49b333=_0xf1f80a[a1_0x2258('0x59')](_0x3529b5=>_0x3529b5[a1_0x2258('0x3d')])['filter'](_0xd3982e=>!!_0xd3982e);const _0x53ec5e=yield Promise[a1_0x2258('0x15')](_0x49b333[a1_0x2258('0x59')](_0x285dc6=>{const _0x466bc8=(0x0,path_1['join'])(cacheDirectory,_0x285dc6+a1_0x2258('0x2e'));return(0x0,fs_extra_1[a1_0x2258('0x43')])(_0x466bc8);}));const _0x1fe91d=[];for(let _0x1d8373=0x0;_0x1d8373<_0x53ec5e[a1_0x2258('0x14')];++_0x1d8373){if(!_0x53ec5e[_0x1d8373]){_0x1fe91d[a1_0x2258('0x27')](_0x49b333[_0x1d8373]);}}if(_0x1fe91d[a1_0x2258('0x14')]>0x0){const _0x2eb1d8=_0x2d847e['startRun'](_0x50bf7e,_0x1fe91d);for(const _0x35a082 of _0x1fe91d){_0x4ded22[a1_0x2258('0x4f')][_0x35a082]=_0x2eb1d8;}}});}function cloudEnabledTasksRunner(_0x531d76,_0x4b10cc,_0x362ded,_0xd652b4=![]){var _0x20f530;const _0x2640ee=process[a1_0x2258('0x23')][a1_0x2258('0x31')];const _0x42d132={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x531d76};const _0x205690=_0x4b10cc[a1_0x2258('0x7')]===undefined;const _0x7894f6=[];const _0x8d3edd=new message_reporter_1['MessageReporter'](_0x4b10cc);const _0x4e1cef=createApi(_0x8d3edd,_0x4b10cc,_0x42d132);const _0x50a8d5=new end_of_run_message_1[(a1_0x2258('0x3b'))](_0x42d132,_0x7894f6,_0x2640ee);const _0x2ad964=new output_obfuscator_1[(a1_0x2258('0x3'))](_0x4b10cc[a1_0x2258('0x32')]);const _0x5ae865=new Date()[a1_0x2258('0x28')]();const _0x159878=createLifeCycle(_0x42d132,_0x4b10cc,_0x2ad964,_0x7894f6);const _0x5640b9=environment_1[a1_0x2258('0x4b')]||_0x4b10cc[a1_0x2258('0x4e')];const _0x1b5703=new e2e_encryption_1[(a1_0x2258('0x1c'))](_0x5640b9);const _0x477225=new error_reporter_api_1[(a1_0x2258('0x10'))](_0x4b10cc);const _0x3911ce=(0x0,environment_1[a1_0x2258('0xe')])(_0x2640ee)||!((_0x20f530=_0x362ded[a1_0x2258('0x48')])===null||_0x20f530===void 0x0?void 0x0:_0x20f530[a1_0x2258('0x4a')]());const _0xaf409e=new file_storage_1[(a1_0x2258('0x1e'))](_0x1b5703,_0x477225,_0x4b10cc,a1_0x2258('0x33'));const _0x5c7318=new cloud_remote_cache_1[(a1_0x2258('0x3a'))](_0x8d3edd,_0x4e1cef,_0x42d132,_0xaf409e,_0x2640ee,_0x3911ce);fetchUrlsForKnownHashesUpfront(_0x4e1cef,_0x42d132,_0x531d76,_0x4b10cc,_0x2640ee);delete process[a1_0x2258('0x23')][a1_0x2258('0x31')];const _0x780ce7=tasksRunner(_0x531d76,Object['assign'](Object[a1_0x2258('0x34')]({},_0x4b10cc),{'remoteCache':_0x5c7318,'lifeCycle':_0x159878}),_0x362ded);if(_0x780ce7['subscribe']){const {Subject}=require('rxjs/internal/Subject');const _0x5808b4=new Subject();_0x780ce7[a1_0x2258('0x39')]({'next':_0x31a650=>_0x5808b4[a1_0x2258('0x2f')](_0x31a650),'error':_0x28c681=>_0x5808b4[a1_0x2258('0x58')](_0x28c681),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x5581ba=yield onComplete({'daemon':_0x362ded[a1_0x2258('0x48')],'options':_0x4b10cc,'fileStorage':_0xaf409e,'remoteCache':_0x5c7318,'api':_0x4e1cef,'outputObfuscator':_0x2ad964,'runStartTime':_0x5ae865,'messages':_0x8d3edd,'endOfRunMessage':_0x50a8d5,'taskExecutions':_0x7894f6,'versionOfNxBefore133':_0x205690,'inner':_0xd652b4,'encryptionKey':_0x5640b9,'storeInCurrentProcess':_0x3911ce,'runContext':_0x42d132,'distributedExecutionId':_0x2640ee});if(!_0x5581ba&&(0x0,environment_1['agentRunningInDistributedExecution'])(_0x2640ee)){process[a1_0x2258('0x1')](environment_1[a1_0x2258('0xc')]);}_0x5808b4[a1_0x2258('0xa')]();})});return _0x5808b4;}else{return _0x780ce7['then'](_0xc3ad18=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x21d466=yield onComplete({'daemon':_0x362ded[a1_0x2258('0x48')],'options':_0x4b10cc,'fileStorage':_0xaf409e,'remoteCache':_0x5c7318,'api':_0x4e1cef,'outputObfuscator':_0x2ad964,'runStartTime':_0x5ae865,'messages':_0x8d3edd,'endOfRunMessage':_0x50a8d5,'taskExecutions':_0x7894f6,'versionOfNxBefore133':_0x205690,'inner':_0xd652b4,'encryptionKey':_0x5640b9,'storeInCurrentProcess':_0x3911ce,'runContext':_0x42d132,'distributedExecutionId':_0x2640ee});if(!_0x21d466&&(0x0,environment_1['agentRunningInDistributedExecution'])(_0x2640ee)){process[a1_0x2258('0x1')](environment_1[a1_0x2258('0xc')]);}return _0xc3ad18;}))[a1_0x2258('0x40')](_0x1e0fab=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x595267=yield onComplete({'daemon':_0x362ded['daemon'],'options':_0x4b10cc,'fileStorage':_0xaf409e,'remoteCache':_0x5c7318,'api':_0x4e1cef,'outputObfuscator':_0x2ad964,'runStartTime':_0x5ae865,'messages':_0x8d3edd,'endOfRunMessage':_0x50a8d5,'taskExecutions':_0x7894f6,'versionOfNxBefore133':_0x205690,'inner':_0xd652b4,'encryptionKey':_0x5640b9,'storeInCurrentProcess':_0x3911ce,'runContext':_0x42d132,'distributedExecutionId':_0x2640ee});if(!_0x595267&&(0x0,environment_1[a1_0x2258('0xe')])(_0x2640ee)){process[a1_0x2258('0x1')](environment_1[a1_0x2258('0xc')]);}throw _0x1e0fab;}));}}exports['cloudEnabledTasksRunner']=cloudEnabledTasksRunner;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloudEnabledTasksRunner = void 0;
const fs_1 = require("fs");
const fs_extra_1 = require("fs-extra");
const path = require("path");
const path_1 = require("path");
const environment_1 = require("../../../utilities/environment");
const metric_logger_1 = require("../../../utilities/metric-logger");
const remove_trailing_slash_1 = require("../../../utilities/remove-trailing-slash");
const error_reporter_api_1 = require("../../api/error-reporter.api");
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
const file_storage_1 = require("../../file-storage/file-storage");
const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
const message_reporter_1 = require("../../terminal-output/message-reporter");
const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
const cloud_remote_cache_1 = require("./cloud-remote-cache");
const cloud_run_api_1 = require("./cloud-run.api");
const id_generator_1 = require("./id-generator");
const { output } = require('../../../utilities/nx-imports-light');
const { tasksRunner, cacheDirectory, } = require('../../../utilities/nx-imports');
function createApi(errors, options, runContext) {
const machineInfo = (0, environment_1.getMachineInfo)();
return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
}
function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
const hashes = JSON.stringify(taskExecutions.map((t) => ({
taskId: t.taskId,
hash: t.hash,
})));
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Executed tasks with hashes: ${hashes}`,
});
}
(0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
}
/*
* It can happen that a task is executed multiple times on an agent, say for DTE1 and DTE2.
* When it runs for DTE2, it will be a local cache hit, so it will be marked as completed.
* However, Nx won't upload an artifact to S3 in this case. Usually this isn't a problem,
* cause the first DTE would have uploaded it. But if you are using a DTE, with a read-only token,
* the uploaded artifact will have a different scoped hash.
*
* To address this: we are finding all local cache hits, and upload everything that has a put url.
*/
function storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory) {
const hashes = taskExecutions
.filter((t) => t.cacheStatus === 'local-cache-hit')
.map((t) => t.hash);
hashes.forEach((hash) => remoteCache.store(hash, nxCacheDirectory));
}
function onComplete(_a) {
return __awaiter(this, arguments, void 0, function* ({ daemon, options, fileStorage, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner, encryptionKey, storeInCurrentProcess, distributedExecutionId, runContext, }) {
const runEndTime = new Date().toISOString();
const branch = (0, environment_1.getBranch)();
const runData = {
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
startTime: runStartTime,
endTime: runEndTime,
distributedExecutionId,
branch: branch,
runGroup: (0, environment_1.getRunGroup)(),
// only set sha if branch is set because we invoke a separate process,
// which adds a few millis
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
inner: inner,
};
const ciExecutionContext = {
branch: branch,
runGroup: (0, environment_1.getRunGroup)(),
ciExecutionId: (0, environment_1.getCIExecutionId)(),
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
};
if (storeInCurrentProcess) {
if ((0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
storeTaskHashes(taskExecutions, cacheDirectory, distributedExecutionId);
storeLocalCacheHits(taskExecutions, remoteCache, cacheDirectory);
}
try {
yield remoteCache.waitForStoreRequestsToComplete();
}
catch (e) {
output.error({
title: `Nx Cloud wasn't able to store artifacts.`,
});
messages.printMessages();
return false;
}
for (const hash of fileStorage.storedHashes) {
const matchingTask = taskExecutions.find((t) => t.hash === hash);
if (!matchingTask) {
throw new Error(`Task with hash ${hash} isn't recorded`);
}
matchingTask.uploadedToStorage = true;
}
try {
yield api.endRun(runData, taskExecutions, ciExecutionContext);
}
catch (e) {
output.error({
title: `Nx Cloud wasn't able to record its run.`,
});
messages.printMessages();
return false;
}
yield (0, metric_logger_1.submitRunMetrics)(options);
}
else {
try {
const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken;
const linkId = (0, id_generator_1.generateUniqueLinkId)();
const processRunEndFullPath = require.resolve('nx-cloud/lib/daemon/process-run-end');
yield daemon.processInBackground(processRunEndFullPath, {
encryptionKey,
runnerOptions: Object.assign(Object.assign({}, options), { accessToken }),
delayedStoreRequests: remoteCache.delayedStoreRequests,
ciExecutionContext,
runEnd: {
runData,
taskExecutions,
linkId,
},
});
runContext.runUrl = `${(0, remove_trailing_slash_1.removeTrailingSlash)(options.url || 'https://nx.app')}/runs/${linkId}`;
}
catch (e) {
output.warn({
title: `Nx Cloud Problems`,
bodyLines: [e.message || e.toString()],
});
return false;
}
}
// this workaround is required because prior to Nx 13.3 we printed
// the end message after the runner completes, so we need to wait for the
// message to appear in the right place
if (versionOfNxBefore133) {
setTimeout(() => {
messages.printMessages();
if (!messages.anyErrors && !inner) {
endOfRunMessage.printCacheHitsMessage();
}
}, 0);
}
else {
messages.printMessages();
if (!messages.anyErrors && !inner) {
endOfRunMessage.printCacheHitsMessage();
}
}
return true;
});
}
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, cacheDirectory, true, options.cacheableOperations || [], outputObfuscator, tasks);
try {
const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
if (!CompositeLifeCycle)
return cloudEnabledLifeCycle;
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
}
catch (e) {
return cloudEnabledLifeCycle;
}
}
function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId) {
return __awaiter(this, void 0, void 0, function* () {
if (options.skipNxCache)
return;
let hashes = tasks.map((t) => t.hash).filter((h) => !!h);
// filter out the urls that don't have artifact stored locally
const exists = yield Promise.all(hashes.map((hash) => {
const tdCommit = (0, path_1.join)(cacheDirectory, `${hash}.commit`);
return (0, fs_extra_1.pathExists)(tdCommit);
}));
const missingHashes = [];
for (let i = 0; i < exists.length; ++i) {
if (!exists[i]) {
missingHashes.push(hashes[i]);
}
}
if (missingHashes.length > 0) {
const startRunRequest = api.startRun(distributedExecutionId, missingHashes);
for (const hash of missingHashes) {
runContext.requests[hash] = startRunRequest;
}
}
});
}
function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
var _a;
const distributedExecutionId = process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
const runContext = {
statuses: {},
scheduledTasks: [],
requests: {},
allTasks: tasks,
};
const versionOfNxBefore133 = options.lifeCycle === undefined;
const taskExecutions = [];
const messages = new message_reporter_1.MessageReporter(options);
const api = createApi(messages, options, runContext);
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions, distributedExecutionId);
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
const runStartTime = new Date().toISOString();
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
const encryptionKey = environment_1.ENCRYPTION_KEY || options.encryptionKey;
const encryption = new e2e_encryption_1.E2EEncryption(encryptionKey);
const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
const storeInCurrentProcess = (0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId) ||
!((_a = context.daemon) === null || _a === void 0 ? void 0 : _a.enabled());
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, options, 'cloud-enabled-runner');
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess);
// we don't await for it cause this step is optional
fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId);
// have to reset it so we don't capture inner tasks
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
// observable -> legacy
if (res.subscribe) {
const { Subject } = require('rxjs/internal/Subject');
const wrappedRes = new Subject();
res.subscribe({
next: (value) => wrappedRes.next(value),
error: (err) => wrappedRes.error(err),
complete: () => __awaiter(this, void 0, void 0, function* () {
const success = yield onComplete({
daemon: context.daemon,
options,
fileStorage,
remoteCache,
api,
outputObfuscator,
runStartTime,
messages,
endOfRunMessage,
taskExecutions,
versionOfNxBefore133,
inner,
encryptionKey,
storeInCurrentProcess,
runContext,
distributedExecutionId,
});
if (!success &&
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
wrappedRes.complete();
}),
});
return wrappedRes;
// promise
}
else {
return res
.then((r) => __awaiter(this, void 0, void 0, function* () {
const success = yield onComplete({
daemon: context.daemon,
options,
fileStorage,
remoteCache,
api,
outputObfuscator,
runStartTime,
messages,
endOfRunMessage,
taskExecutions,
versionOfNxBefore133,
inner,
encryptionKey,
storeInCurrentProcess,
runContext,
distributedExecutionId,
});
if (!success &&
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
return r;
}))
.catch((e) => __awaiter(this, void 0, void 0, function* () {
const success = yield onComplete({
daemon: context.daemon,
options,
fileStorage,
remoteCache,
api,
outputObfuscator,
runStartTime,
messages,
endOfRunMessage,
taskExecutions,
versionOfNxBefore133,
inner,
encryptionKey,
storeInCurrentProcess,
runContext,
distributedExecutionId,
});
if (!success &&
(0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
}
throw e;
}));
}
}
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
//# sourceMappingURL=cloud-enabled.runner.js.map

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

const a2_0x5963=['fileStorage','map','put','../../../utilities/environment','Nx\x20Cloud:\x20Skipping\x20storing\x20','extractErrorMessage','Error\x20when\x20storing\x20artifacts','filter','statuses','delayedStoreRequests','done','waitForStoreRequestsToComplete','apply','api','defineProperty','startRun','value','retrieve','storeRequests','Nx\x20Cloud:\x20Cache\x20miss\x20','There\x20are\x20several\x20reasons\x20why\x20this\x20can\x20happen.','storage','requests','scheduledTasks','Maybe\x20you\x20are\x20using\x20a\x20read-only\x20token\x20or\x20the\x20artifact\x20has\x20already\x20being\x20uploaded.','storeInCurrentProcess','hashUrls','next','then','distributedExecutionId','status','push','__awaiter','get','cache-miss','cacheError','all','CloudRemoteCache','hash','throw','resolve','.\x20Status\x20404.','messages','store','axiosException','VERBOSE_LOGGING','note','runContext'];(function(_0x213fb4,_0x59630e){const _0x1725ec=function(_0x3acb44){while(--_0x3acb44){_0x213fb4['push'](_0x213fb4['shift']());}};_0x1725ec(++_0x59630e);}(a2_0x5963,0xef));const a2_0x1725=function(_0x213fb4,_0x59630e){_0x213fb4=_0x213fb4-0x0;let _0x1725ec=a2_0x5963[_0x213fb4];return _0x1725ec;};'use strict';var __awaiter=this&&this[a2_0x1725('0x21')]||function(_0x5a60fe,_0x3f8509,_0x484d35,_0x59ce69){function _0x2d6fb8(_0xa0b73c){return _0xa0b73c instanceof _0x484d35?_0xa0b73c:new _0x484d35(function(_0x570db2){_0x570db2(_0xa0b73c);});}return new(_0x484d35||(_0x484d35=Promise))(function(_0x4c1de9,_0x2d6b7b){function _0x960005(_0x10b40b){try{_0x6d4da2(_0x59ce69[a2_0x1725('0x1c')](_0x10b40b));}catch(_0x227b2c){_0x2d6b7b(_0x227b2c);}}function _0x14fe1c(_0x30bf54){try{_0x6d4da2(_0x59ce69[a2_0x1725('0x28')](_0x30bf54));}catch(_0x2e740f){_0x2d6b7b(_0x2e740f);}}function _0x6d4da2(_0x4e4dfc){_0x4e4dfc[a2_0x1725('0xb')]?_0x4c1de9(_0x4e4dfc[a2_0x1725('0x11')]):_0x2d6fb8(_0x4e4dfc['value'])[a2_0x1725('0x1d')](_0x960005,_0x14fe1c);}_0x6d4da2((_0x59ce69=_0x59ce69[a2_0x1725('0xd')](_0x5a60fe,_0x3f8509||[]))[a2_0x1725('0x1c')]());});};Object[a2_0x1725('0xf')](exports,'__esModule',{'value':!![]});exports[a2_0x1725('0x26')]=void 0x0;const environment_1=require(a2_0x1725('0x4'));const {output}=require('../../../utilities/nx-imports-light');class CloudRemoteCache{constructor(_0x5240fe,_0x2399aa,_0x2d339b,_0xa89fc6,_0x4b4a52,_0x4d8f21){this[a2_0x1725('0x2b')]=_0x5240fe;this[a2_0x1725('0xe')]=_0x2399aa;this[a2_0x1725('0x0')]=_0x2d339b;this[a2_0x1725('0x1')]=_0xa89fc6;this[a2_0x1725('0x1e')]=_0x4b4a52;this[a2_0x1725('0x1a')]=_0x4d8f21;this['storeRequests']=[];this[a2_0x1725('0xa')]=[];}[a2_0x1725('0x12')](_0x27de0a,_0x394904){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x30e8a9;if(this['messages']['cacheError'])return![];const _0x400c6e=yield this['hashUrls'](_0x27de0a);if(!_0x400c6e||!_0x400c6e[a2_0x1725('0x22')]){if(environment_1[a2_0x1725('0x2e')]){output[a2_0x1725('0x2f')]({'title':a2_0x1725('0x14')+_0x27de0a+'.'});}this[a2_0x1725('0x0')][a2_0x1725('0x9')][_0x27de0a]='cache-miss';return![];}try{yield this[a2_0x1725('0x1')][a2_0x1725('0x12')](_0x27de0a,_0x400c6e[a2_0x1725('0x22')],_0x394904);this[a2_0x1725('0x0')][a2_0x1725('0x9')][_0x27de0a]='remote-cache-hit';return!![];}catch(_0x225de6){const _0x9145d=(_0x30e8a9=_0x225de6[a2_0x1725('0x2d')])!==null&&_0x30e8a9!==void 0x0?_0x30e8a9:_0x225de6;if(_0x9145d['response']&&_0x9145d['response'][a2_0x1725('0x1f')]===0x194){if(environment_1['VERBOSE_LOGGING']){output[a2_0x1725('0x2f')]({'title':a2_0x1725('0x14')+_0x27de0a+a2_0x1725('0x2a')});}}else{this[a2_0x1725('0x2b')][a2_0x1725('0x24')]=this['messages']['extractErrorMessage'](_0x9145d,a2_0x1725('0x16'));}this[a2_0x1725('0x0')][a2_0x1725('0x9')][_0x27de0a]=a2_0x1725('0x23');return![];}});}[a2_0x1725('0x2c')](_0x3018a3,_0x286a78){return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a2_0x1725('0x24')])return![];const _0x57efc2=Promise[a2_0x1725('0x29')]()[a2_0x1725('0x1d')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x11fc5b;const _0x35798b=yield this[a2_0x1725('0x1b')](_0x3018a3);if(!_0x35798b)return![];if(!_0x35798b[a2_0x1725('0x3')]){if(environment_1[a2_0x1725('0x2e')]){output[a2_0x1725('0x2f')]({'title':a2_0x1725('0x5')+_0x3018a3+'.','bodyLines':[a2_0x1725('0x15'),a2_0x1725('0x19')]});}return!![];}if(!this[a2_0x1725('0x1a')]){this[a2_0x1725('0xa')][a2_0x1725('0x20')]({'hash':_0x3018a3,'url':_0x35798b['put']});return!![];}try{yield this[a2_0x1725('0x1')][a2_0x1725('0x2c')](_0x3018a3,_0x35798b['put'],_0x286a78);return!![];}catch(_0x35d72f){const _0x490d6c=(_0x11fc5b=_0x35d72f[a2_0x1725('0x2d')])!==null&&_0x11fc5b!==void 0x0?_0x11fc5b:_0x35d72f;this[a2_0x1725('0x2b')][a2_0x1725('0x24')]=this['messages'][a2_0x1725('0x6')](_0x490d6c,a2_0x1725('0x16'));return![];}}));this[a2_0x1725('0x13')][a2_0x1725('0x20')](_0x57efc2);return _0x57efc2;});}['hashUrls'](_0xa68944){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0xa68944 in this[a2_0x1725('0x0')][a2_0x1725('0x17')]){return(yield this[a2_0x1725('0x0')][a2_0x1725('0x17')][_0xa68944])[_0xa68944];}else{const _0x360fc3=this[a2_0x1725('0x0')][a2_0x1725('0x18')][a2_0x1725('0x8')](_0xdc1cc3=>!this[a2_0x1725('0x0')]['requests'][_0xdc1cc3['hash']])[a2_0x1725('0x2')](_0x7e103c=>_0x7e103c[a2_0x1725('0x27')]);if(_0x360fc3['indexOf'](_0xa68944)===-0x1){_0x360fc3[a2_0x1725('0x20')](_0xa68944);}const _0xaef652=this[a2_0x1725('0xe')][a2_0x1725('0x10')](this[a2_0x1725('0x1e')],_0x360fc3);_0x360fc3['forEach'](_0x5eb51d=>{this['runContext'][a2_0x1725('0x17')][_0x5eb51d]=_0xaef652;});return(yield _0xaef652)[_0xa68944];}});}[a2_0x1725('0xc')](){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x42786e=yield Promise[a2_0x1725('0x25')](this[a2_0x1725('0x13')])['then'](_0x9c4624=>_0x9c4624['reduce']((_0x206d20,_0x3ef308)=>_0x206d20&&_0x3ef308,!![]));if(!_0x42786e){throw new Error(a2_0x1725('0x7'));}});}}exports['CloudRemoteCache']=CloudRemoteCache;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudRemoteCache = void 0;
const environment_1 = require("../../../utilities/environment");
const { output } = require('../../../utilities/nx-imports-light');
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) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
if (this.messages.cacheError)
return false;
const hashUrls = yield this.hashUrls(hash);
if (!hashUrls || !hashUrls.get) {
if (environment_1.VERBOSE_LOGGING) {
output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
}
this.runContext.statuses[hash] = 'cache-miss';
return false;
}
try {
yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
this.runContext.statuses[hash] = 'remote-cache-hit';
return true;
}
catch (ee) {
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
// TODO: vsavkin remove this handling Oct 2023
// 404 indicates that something is broken, but older versions
// of the api can result in such errors
// we ignore them for now
if (e.response && e.response.status === 404) {
if (environment_1.VERBOSE_LOGGING) {
output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
}
// cache miss. print nothing
}
else {
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
}
this.runContext.statuses[hash] = 'cache-miss';
return false;
}
});
}
store(hash, cacheDirectory) {
return __awaiter(this, void 0, void 0, function* () {
if (this.messages.cacheError)
return false;
const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
var _a;
const hashUrls = yield this.hashUrls(hash);
if (!hashUrls)
return false;
if (!hashUrls.put) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Nx Cloud: Skipping storing ${hash}.`,
bodyLines: [
`There are several reasons why this can happen.`,
`Maybe you are using a read-only token or the artifact has already being uploaded.`,
],
});
}
return true;
}
if (!this.storeInCurrentProcess) {
this.delayedStoreRequests.push({ hash: hash, url: hashUrls.put });
return true;
}
try {
yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
return true;
}
catch (ee) {
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
return false;
}
}));
this.storeRequests.push(res);
return res;
});
}
hashUrls(hash) {
return __awaiter(this, void 0, void 0, function* () {
if (hash in this.runContext.requests) {
return (yield this.runContext.requests[hash])[hash];
}
else {
const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
.filter((t) => !this.runContext.requests[t.hash])
.map((t) => t.hash);
if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
scheduledTaskHashesWithoutRequests.push(hash);
}
const request = this.api.startRun(this.distributedExecutionId, scheduledTaskHashesWithoutRequests);
scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
this.runContext.requests[taskHash] = request;
});
return (yield request)[hash];
}
});
}
waitForStoreRequestsToComplete() {
return __awaiter(this, void 0, void 0, function* () {
const res = yield Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
if (!res) {
throw new Error(`Error when storing artifacts`);
}
});
}
}
exports.CloudRemoteCache = CloudRemoteCache;
//# sourceMappingURL=cloud-remote-cache.js.map

@@ -1,1 +0,175 @@

const a3_0x23f7=['data','parse','../../../utilities/metric-logger','note','../../../utilities/environment','next','devDependencies','/nx-cloud/runs/start','length','post','/nx-cloud/runs/end','string','../../../utilities/is-private-cloud','RunStart\x20duration','nxCloudVersion','...','createApiAxiosInstance','success','apiAxiosInstance','mapRespToPerfEntry','startRun','unknown','package.json','message','defaults','__esModule','from','throw','axiosMultipleTries','getRunGroup','error','apiError','messages','Invalid\x20Nx\x20Cloud\x20response:\x20','application/octet-stream','stringify','RUNNER_FAILURE_PERF_ENTRY','response','gzip','recordMetric','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','stack','readFileSync','printDuration','value','status','extractErrorMessage','map','CloudRunApi','runUrl','isConnectedToPrivateCloud','RunEnd.\x20Completed\x20tasks','createReqBody','done','toString','api','../../../utilities/axios','urls','assign','getCIExecutionId','createMetricRecorder','@nrwl/nx-cloud','defineProperty','Invalid\x20end\x20run\x20response:\x20','axiosException','getCIExecutionEnv','runContext','VERBOSE_LOGGING','slice','terminalOutput','endRun','machineInfo'];(function(_0x5e3d5f,_0x23f73e){const _0x2bc56f=function(_0x4d0cc2){while(--_0x4d0cc2){_0x5e3d5f['push'](_0x5e3d5f['shift']());}};_0x2bc56f(++_0x23f73e);}(a3_0x23f7,0x1f0));const a3_0x2bc5=function(_0x5e3d5f,_0x23f73e){_0x5e3d5f=_0x5e3d5f-0x0;let _0x2bc56f=a3_0x23f7[_0x5e3d5f];return _0x2bc56f;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x5a7e47,_0x535a3e,_0x51674c,_0x1ddc3c){function _0x59d5bb(_0x34f3ac){return _0x34f3ac instanceof _0x51674c?_0x34f3ac:new _0x51674c(function(_0xc5a469){_0xc5a469(_0x34f3ac);});}return new(_0x51674c||(_0x51674c=Promise))(function(_0x2a13f0,_0x33098e){function _0x2de7fd(_0x153095){try{_0x244a2c(_0x1ddc3c[a3_0x2bc5('0xd')](_0x153095));}catch(_0x6f2ad7){_0x33098e(_0x6f2ad7);}}function _0x175d1b(_0x43e364){try{_0x244a2c(_0x1ddc3c[a3_0x2bc5('0x23')](_0x43e364));}catch(_0x29afee){_0x33098e(_0x29afee);}}function _0x244a2c(_0x1477b3){_0x1477b3[a3_0x2bc5('0x3d')]?_0x2a13f0(_0x1477b3[a3_0x2bc5('0x34')]):_0x59d5bb(_0x1477b3[a3_0x2bc5('0x34')])['then'](_0x2de7fd,_0x175d1b);}_0x244a2c((_0x1ddc3c=_0x1ddc3c['apply'](_0x5a7e47,_0x535a3e||[]))[a3_0x2bc5('0xd')]());});};Object[a3_0x2bc5('0x46')](exports,a3_0x2bc5('0x21'),{'value':!![]});exports[a3_0x2bc5('0x38')]=void 0x0;const fs_1=require('fs');const util_1=require('util');const zlib_1=require('zlib');const axios_1=require(a3_0x2bc5('0x40'));const environment_1=require(a3_0x2bc5('0xc'));const is_private_cloud_1=require(a3_0x2bc5('0x14'));const metric_logger_1=require(a3_0x2bc5('0xa'));const {output}=require('../../../utilities/nx-imports-light');class CloudRunApi{constructor(_0x1cfd4e,_0x2b7397,_0x213c52,_0x2dec11){this[a3_0x2bc5('0x28')]=_0x1cfd4e;this[a3_0x2bc5('0x2')]=_0x2b7397;this[a3_0x2bc5('0x7')]=_0x2dec11;this[a3_0x2bc5('0x1a')]=(0x0,axios_1[a3_0x2bc5('0x18')])(_0x213c52);}[a3_0x2bc5('0x1c')](_0x4697bb,_0x26ef54){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x13a337;if(this[a3_0x2bc5('0x28')]['apiError'])return{};const _0x4b226c=(0x0,metric_logger_1[a3_0x2bc5('0x44')])('startRun');try{const _0x4b1ba2={'meta':{'nxCloudVersion':this[a3_0x2bc5('0x16')]()},'branch':(0x0,environment_1['getBranch'])(),'runGroup':(0x0,environment_1[a3_0x2bc5('0x25')])(),'ciExecutionId':(0x0,environment_1[a3_0x2bc5('0x43')])(),'ciExecutionEnv':(0x0,environment_1[a3_0x2bc5('0x1')])(),'distributedExecutionId':_0x4697bb,'hashes':_0x26ef54,'machineInfo':this[a3_0x2bc5('0x7')]};if(environment_1[a3_0x2bc5('0x3')]){output[a3_0x2bc5('0xb')]({'title':'RunStart','bodyLines':['\x0a'+JSON[a3_0x2bc5('0x2b')](_0x4b1ba2,null,0x2)]});}const _0x1fa83f=yield(0x0,axios_1[a3_0x2bc5('0x33')])(a3_0x2bc5('0x15'),()=>(0x0,axios_1[a3_0x2bc5('0x24')])(()=>this['apiAxiosInstance'][a3_0x2bc5('0x11')](a3_0x2bc5('0xf'),_0x4b1ba2)));_0x4b226c[a3_0x2bc5('0x2f')]((0x0,metric_logger_1[a3_0x2bc5('0x1b')])(_0x1fa83f));if(_0x1fa83f[a3_0x2bc5('0x8')]&&_0x1fa83f[a3_0x2bc5('0x8')][a3_0x2bc5('0x1f')]){this[a3_0x2bc5('0x28')][a3_0x2bc5('0x1f')]=_0x1fa83f['data'][a3_0x2bc5('0x1f')];}if(!_0x1fa83f['data']||!_0x1fa83f[a3_0x2bc5('0x8')][a3_0x2bc5('0x41')]){this[a3_0x2bc5('0x28')][a3_0x2bc5('0x27')]=a3_0x2bc5('0x29')+JSON['stringify'](_0x1fa83f[a3_0x2bc5('0x8')]);return{};}return _0x1fa83f[a3_0x2bc5('0x8')][a3_0x2bc5('0x41')];}catch(_0x462cc1){_0x4b226c[a3_0x2bc5('0x2f')](((_0x13a337=_0x462cc1===null||_0x462cc1===void 0x0?void 0x0:_0x462cc1[a3_0x2bc5('0x0')])===null||_0x13a337===void 0x0?void 0x0:_0x13a337[a3_0x2bc5('0x2d')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x462cc1[a3_0x2bc5('0x0')][a3_0x2bc5('0x2d')]):metric_logger_1[a3_0x2bc5('0x2c')]);this['messages']['apiError']=this[a3_0x2bc5('0x28')][a3_0x2bc5('0x36')](_0x462cc1,a3_0x2bc5('0x3f'));return{};}});}[a3_0x2bc5('0x3c')](_0x53acf2,_0x440e8a,_0x35eb4d,_0xb8760c){if((0x0,is_private_cloud_1[a3_0x2bc5('0x3a')])()){for(let _0x2b8d90 of _0x440e8a){delete _0x2b8d90['uploadedToStorage'];}}const _0x4fcd87=Object[a3_0x2bc5('0x42')](Object[a3_0x2bc5('0x42')]({'meta':{'nxCloudVersion':this[a3_0x2bc5('0x16')]()},'tasks':_0x440e8a,'run':_0x53acf2,'linkId':_0xb8760c},(0x0,is_private_cloud_1['isConnectedToPrivateCloud'])()?{}:_0x35eb4d),{'machineInfo':this['machineInfo']});return JSON[a3_0x2bc5('0x2b')](_0x4fcd87);}[a3_0x2bc5('0x6')](_0x1924b6,_0x25998e,_0xaaeb87,_0x5ae90d){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x31e91a,_0x5ee8e5;if(this[a3_0x2bc5('0x28')][a3_0x2bc5('0x27')])return![];let _0xa984a9=this[a3_0x2bc5('0x3c')](_0x1924b6,_0x25998e,_0xaaeb87,_0x5ae90d);if(_0xa984a9[a3_0x2bc5('0x10')]>0x14*0x3e8*0x3e8){_0xa984a9=this[a3_0x2bc5('0x3c')](_0x1924b6,_0x25998e[a3_0x2bc5('0x37')](_0x28e246=>Object['assign'](Object[a3_0x2bc5('0x42')]({},_0x28e246),{'hashDetails':undefined})),_0xaaeb87,_0x5ae90d);}const _0x372bdb=Buffer[a3_0x2bc5('0x22')](_0xa984a9);const _0x1d24c5=yield(0x0,util_1['promisify'])(zlib_1[a3_0x2bc5('0x2e')])(_0x372bdb);const _0x22a9ae=(0x0,metric_logger_1['createMetricRecorder'])(a3_0x2bc5('0x6'));try{if(environment_1[a3_0x2bc5('0x3')]){const _0x3e07d9=_0x25998e['map'](_0x49e5ee=>{return Object[a3_0x2bc5('0x42')](Object[a3_0x2bc5('0x42')]({},_0x49e5ee),{'terminalOutput':_0x49e5ee[a3_0x2bc5('0x5')]?_0x49e5ee['terminalOutput'][a3_0x2bc5('0x4')](0x0,0x14)+a3_0x2bc5('0x17'):undefined});});output[a3_0x2bc5('0xb')]({'title':a3_0x2bc5('0x3b'),'bodyLines':['\x0a'+JSON[a3_0x2bc5('0x2b')](_0x3e07d9,null,0x2)]});}const _0x32a03b=yield(0x0,axios_1[a3_0x2bc5('0x33')])('RunEnd\x20duration',()=>(0x0,axios_1[a3_0x2bc5('0x24')])(()=>this[a3_0x2bc5('0x1a')][a3_0x2bc5('0x11')](a3_0x2bc5('0x12'),_0x1d24c5,{'headers':Object[a3_0x2bc5('0x42')](Object[a3_0x2bc5('0x42')]({},this[a3_0x2bc5('0x1a')][a3_0x2bc5('0x20')]['headers']),{'Content-Encoding':a3_0x2bc5('0x2e'),'Content-Type':a3_0x2bc5('0x2a')})})));if(_0x32a03b){_0x22a9ae[a3_0x2bc5('0x2f')]((0x0,metric_logger_1[a3_0x2bc5('0x1b')])(_0x32a03b));if(_0x32a03b[a3_0x2bc5('0x8')]&&_0x32a03b[a3_0x2bc5('0x8')][a3_0x2bc5('0x39')]&&_0x32a03b[a3_0x2bc5('0x8')]['status']===a3_0x2bc5('0x19')){this[a3_0x2bc5('0x2')]['runUrl']=_0x32a03b[a3_0x2bc5('0x8')][a3_0x2bc5('0x39')];return!![];}if(_0x32a03b[a3_0x2bc5('0x8')]&&_0x32a03b[a3_0x2bc5('0x8')][a3_0x2bc5('0x35')]){this[a3_0x2bc5('0x28')][a3_0x2bc5('0x27')]=a3_0x2bc5('0x47')+JSON[a3_0x2bc5('0x2b')](_0x32a03b[a3_0x2bc5('0x8')][a3_0x2bc5('0x1f')]);}else if(_0x32a03b[a3_0x2bc5('0x8')]&&typeof _0x32a03b[a3_0x2bc5('0x8')]===a3_0x2bc5('0x13')){if(_0x32a03b[a3_0x2bc5('0x8')]!==a3_0x2bc5('0x19')){this[a3_0x2bc5('0x28')]['apiError']=a3_0x2bc5('0x47')+JSON[a3_0x2bc5('0x2b')](_0x32a03b[a3_0x2bc5('0x8')]);}}else{this[a3_0x2bc5('0x28')][a3_0x2bc5('0x27')]=a3_0x2bc5('0x47')+JSON['stringify'](_0x32a03b['data']);}if(environment_1[a3_0x2bc5('0x3')]){output[a3_0x2bc5('0xb')]({'title':'Invalid\x20end\x20run\x20response','bodyLines':[JSON['stringify'](_0x32a03b[a3_0x2bc5('0x8')],null,0x2)]});}}else{output[a3_0x2bc5('0x26')]({'title':a3_0x2bc5('0x30'),'bodyLines':['Run\x20completion\x20responded\x20with\x20`undefined`.','Run\x20Details:',JSON[a3_0x2bc5('0x2b')](_0x1924b6,null,0x2),'Stack\x20Trace:',JSON[a3_0x2bc5('0x2b')](new Error()[a3_0x2bc5('0x31')],null,0x2)]});}return![];}catch(_0x282820){_0x22a9ae[a3_0x2bc5('0x2f')](((_0x31e91a=_0x282820===null||_0x282820===void 0x0?void 0x0:_0x282820['axiosException'])===null||_0x31e91a===void 0x0?void 0x0:_0x31e91a[a3_0x2bc5('0x2d')])?(0x0,metric_logger_1[a3_0x2bc5('0x1b')])(_0x282820[a3_0x2bc5('0x0')][a3_0x2bc5('0x2d')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);const _0x5182f5=(_0x5ee8e5=_0x282820[a3_0x2bc5('0x0')])!==null&&_0x5ee8e5!==void 0x0?_0x5ee8e5:_0x282820;this[a3_0x2bc5('0x28')][a3_0x2bc5('0x27')]=this[a3_0x2bc5('0x28')]['extractErrorMessage'](_0x5182f5,a3_0x2bc5('0x3f'));return![];}});}['nxCloudVersion'](){try{const _0x111fc0=JSON[a3_0x2bc5('0x9')]((0x0,fs_1[a3_0x2bc5('0x32')])(a3_0x2bc5('0x1e'))[a3_0x2bc5('0x3e')]());return _0x111fc0[a3_0x2bc5('0xe')]['nx-cloud']||_0x111fc0[a3_0x2bc5('0xe')][a3_0x2bc5('0x45')];}catch(_0x3b3465){return a3_0x2bc5('0x1d');}}}exports['CloudRunApi']=CloudRunApi;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudRunApi = void 0;
const fs_1 = require("fs");
const util_1 = require("util");
const zlib_1 = require("zlib");
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const is_private_cloud_1 = require("../../../utilities/is-private-cloud");
const metric_logger_1 = require("../../../utilities/metric-logger");
const { output } = require('../../../utilities/nx-imports-light');
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) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
// API is not working, don't make the end request
if (this.messages.apiError)
return {};
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
try {
const request = {
meta: {
nxCloudVersion: this.nxCloudVersion(),
},
branch: (0, environment_1.getBranch)(),
runGroup: (0, environment_1.getRunGroup)(),
ciExecutionId: (0, environment_1.getCIExecutionId)(),
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
distributedExecutionId,
hashes,
machineInfo: this.machineInfo,
};
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'RunStart',
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
});
}
const resp = yield (0, axios_1.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request)));
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
if (resp.data && resp.data.message) {
this.messages.message = resp.data.message;
}
if (!resp.data || !resp.data.urls) {
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
return {};
}
return resp.data.urls;
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
return {};
}
});
}
createReqBody(run, tasks, ciExecutionContext, linkId) {
if ((0, is_private_cloud_1.isConnectedToPrivateCloud)()) {
for (let t of tasks) {
delete t.uploadedToStorage;
}
}
const uncompressedReqBody = Object.assign(Object.assign({ meta: {
nxCloudVersion: this.nxCloudVersion(),
}, tasks,
run,
linkId }, ((0, is_private_cloud_1.isConnectedToPrivateCloud)() ? {} : ciExecutionContext)), { machineInfo: this.machineInfo });
return JSON.stringify(uncompressedReqBody);
}
endRun(run, tasks, ciExecutionContext, linkId) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
// API is not working, don't make the end request
if (this.messages.apiError)
return false;
let uncompressedBodyString = this.createReqBody(run, tasks, ciExecutionContext, linkId);
// if the req body is > 20mb, remove hashDetails
if (uncompressedBodyString.length > 20 * 1000 * 1000) {
uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))), ciExecutionContext, linkId);
}
const uncompressedBuffer = Buffer.from(uncompressedBodyString);
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
try {
if (environment_1.VERBOSE_LOGGING) {
const t = tasks.map((tt) => {
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
? `${tt.terminalOutput.slice(0, 20)}...`
: undefined });
});
output.note({
title: 'RunEnd. Completed tasks',
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
});
}
const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
})));
if (resp) {
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
this.runContext.runUrl = resp.data.runUrl;
return true;
}
if (resp.data && resp.data.status) {
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
}
else if (resp.data && typeof resp.data === 'string') {
if (resp.data !== 'success') {
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
}
}
else {
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
}
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Invalid end run response',
bodyLines: [JSON.stringify(resp.data, null, 2)],
});
}
}
else {
output.error({
title: 'Nx Cloud: Unknown Error Occurred',
bodyLines: [
'Run completion responded with `undefined`.',
'Run Details:',
JSON.stringify(run, null, 2),
'Stack Trace:',
JSON.stringify(new Error().stack, null, 2),
],
});
}
return false;
}
catch (ee) {
recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
return false;
}
});
}
nxCloudVersion() {
try {
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
return (v.devDependencies['nx-cloud'] || v.devDependencies['@nrwl/nx-cloud']);
}
catch (e) {
return 'unknown';
}
}
}
exports.CloudRunApi = CloudRunApi;
//# sourceMappingURL=cloud-run.api.js.map

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

const a4_0x309d=['floor','length','defineProperty','generateUniqueLinkId','toLowerCase'];(function(_0x473c83,_0x309dc2){const _0x4c0c3d=function(_0x412aac){while(--_0x412aac){_0x473c83['push'](_0x473c83['shift']());}};_0x4c0c3d(++_0x309dc2);}(a4_0x309d,0x18f));const a4_0x4c0c=function(_0x473c83,_0x309dc2){_0x473c83=_0x473c83-0x0;let _0x4c0c3d=a4_0x309d[_0x473c83];return _0x4c0c3d;};'use strict';Object[a4_0x4c0c('0x3')](exports,'__esModule',{'value':!![]});exports[a4_0x4c0c('0x4')]=void 0x0;const upper='ABCDEFGHIJKLMNOPQRSTUVWXYZ';const digits='0123456789';const lower=upper[a4_0x4c0c('0x0')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x2506bb='';for(let _0x130ee4=0x0;_0x130ee4<0xa;++_0x130ee4){_0x2506bb+=alphanum[Math[a4_0x4c0c('0x1')](Math['random']()*alphanum[a4_0x4c0c('0x2')])];}return _0x2506bb;}exports[a4_0x4c0c('0x4')]=generateUniqueLinkId;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateUniqueLinkId = void 0;
const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const digits = '0123456789';
const lower = upper.toLowerCase();
const alphanum = upper + lower + digits;
function generateUniqueLinkId() {
let res = '';
for (let i = 0; i < 10; ++i) {
res += alphanum[Math.floor(Math.random() * alphanum.length)];
}
return res;
}
exports.generateUniqueLinkId = generateUniqueLinkId;
//# sourceMappingURL=id-generator.js.map

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

const a5_0x1890=['createApiAxiosInstance','apiAxiosInstance','tasks','DistributedAgentApi','axiosMultipleTries','branch','../../../utilities/axios','../../../utilities/environment','defineProperty','mapRespToPerfEntry','createMetricRecorder','axiosException','error','throw','post','/nx-cloud/executions/complete-run-group','next','data','done','VERBOSE_LOGGING','Completing\x20with\x20an\x20error','completeRunGroupWithError','error:\x20','agentName','ciExecutionId','runGroup:\x20','__esModule','ciExecutionId:\x20','value','../../../utilities/metric-logger','response','/nx-cloud/executions/tasks','runGroup','note','ciExecutionEnv:\x20','recordMetric','completeRunGroup','apply','RUNNER_FAILURE_PERF_ENTRY','ciExecutionEnv'];(function(_0x453e24,_0x189075){const _0x16a0f3=function(_0x5beeae){while(--_0x5beeae){_0x453e24['push'](_0x453e24['shift']());}};_0x16a0f3(++_0x189075);}(a5_0x1890,0x187));const a5_0x16a0=function(_0x453e24,_0x189075){_0x453e24=_0x453e24-0x0;let _0x16a0f3=a5_0x1890[_0x453e24];return _0x16a0f3;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x20a66a,_0x29d5e4,_0x590061,_0x321d58){function _0x37bfcc(_0x1fd3d3){return _0x1fd3d3 instanceof _0x590061?_0x1fd3d3:new _0x590061(function(_0xc4a773){_0xc4a773(_0x1fd3d3);});}return new(_0x590061||(_0x590061=Promise))(function(_0x483374,_0xa745a9){function _0x3adbeb(_0x52ee60){try{_0x173111(_0x321d58['next'](_0x52ee60));}catch(_0x2a1358){_0xa745a9(_0x2a1358);}}function _0x43aaf1(_0x3bd0cb){try{_0x173111(_0x321d58[a5_0x16a0('0x16')](_0x3bd0cb));}catch(_0x5de6a4){_0xa745a9(_0x5de6a4);}}function _0x173111(_0x246189){_0x246189[a5_0x16a0('0x1b')]?_0x483374(_0x246189[a5_0x16a0('0x25')]):_0x37bfcc(_0x246189[a5_0x16a0('0x25')])['then'](_0x3adbeb,_0x43aaf1);}_0x173111((_0x321d58=_0x321d58[a5_0x16a0('0x6')](_0x20a66a,_0x29d5e4||[]))[a5_0x16a0('0x19')]());});};Object[a5_0x16a0('0x11')](exports,a5_0x16a0('0x23'),{'value':!![]});exports[a5_0x16a0('0xc')]=void 0x0;const axios_1=require(a5_0x16a0('0xf'));const environment_1=require(a5_0x16a0('0x10'));const metric_logger_1=require(a5_0x16a0('0x26'));const {output}=require('../../../utilities/nx-imports-light');class DistributedAgentApi{constructor(_0x3a58c7,_0x1a1838,_0x23cab6,_0x58e4a0,_0x2dd3a4,_0x49e01a){this[a5_0x16a0('0xe')]=_0x1a1838;this['runGroup']=_0x23cab6;this[a5_0x16a0('0x21')]=_0x58e4a0;this[a5_0x16a0('0x8')]=_0x2dd3a4;this[a5_0x16a0('0x20')]=_0x49e01a;this['apiAxiosInstance']=(0x0,axios_1[a5_0x16a0('0x9')])(_0x3a58c7);}[a5_0x16a0('0xb')](_0x4ab42a,_0x46d566,_0x30f1bb,_0x6f11f2){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x308d80;const _0x4b465f=(0x0,metric_logger_1['createMetricRecorder'])('dtePollTasks');try{const _0x457ecb=yield(0x0,axios_1[a5_0x16a0('0xd')])(()=>this[a5_0x16a0('0xa')]['post'](a5_0x16a0('0x0'),{'runGroup':this[a5_0x16a0('0x1')],'ciExecutionId':this['ciExecutionId'],'ciExecutionEnv':this[a5_0x16a0('0x8')],'agentName':this[a5_0x16a0('0x20')],'executionId':_0x4ab42a,'statusCode':_0x46d566,'completedTasks':_0x30f1bb,'targets':_0x6f11f2}));_0x4b465f['recordMetric']((0x0,metric_logger_1[a5_0x16a0('0x12')])(_0x457ecb));return _0x457ecb[a5_0x16a0('0x1a')];}catch(_0x15f7ad){_0x4b465f[a5_0x16a0('0x4')](((_0x308d80=_0x15f7ad===null||_0x15f7ad===void 0x0?void 0x0:_0x15f7ad[a5_0x16a0('0x14')])===null||_0x308d80===void 0x0?void 0x0:_0x308d80['response'])?(0x0,metric_logger_1[a5_0x16a0('0x12')])(_0x15f7ad['axiosException'][a5_0x16a0('0x27')]):metric_logger_1[a5_0x16a0('0x7')]);throw _0x15f7ad;}});}[a5_0x16a0('0x1e')](_0x4ee949){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x43be37;if(environment_1[a5_0x16a0('0x1c')]){output[a5_0x16a0('0x2')]({'title':a5_0x16a0('0x1d'),'bodyLines':[a5_0x16a0('0x24')+this['ciExecutionId'],a5_0x16a0('0x3')+this[a5_0x16a0('0x8')],a5_0x16a0('0x22')+this[a5_0x16a0('0x1')],a5_0x16a0('0x1f')+_0x4ee949]});}const _0x5040ce=(0x0,metric_logger_1[a5_0x16a0('0x13')])(a5_0x16a0('0x5'));try{const _0x2eb223=yield(0x0,axios_1[a5_0x16a0('0xd')])(()=>this[a5_0x16a0('0xa')][a5_0x16a0('0x17')](a5_0x16a0('0x18'),{'branch':this[a5_0x16a0('0xe')],'runGroup':this[a5_0x16a0('0x1')],'ciExecutionId':this[a5_0x16a0('0x21')],'ciExecutionEnv':this[a5_0x16a0('0x8')],'agentName':this[a5_0x16a0('0x20')],'criticalErrorMessage':_0x4ee949}));if(environment_1[a5_0x16a0('0x1c')]){output[a5_0x16a0('0x2')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0x5040ce[a5_0x16a0('0x4')]((0x0,metric_logger_1[a5_0x16a0('0x12')])(_0x2eb223));}catch(_0x581ecd){_0x5040ce['recordMetric'](((_0x43be37=_0x581ecd===null||_0x581ecd===void 0x0?void 0x0:_0x581ecd['axiosException'])===null||_0x43be37===void 0x0?void 0x0:_0x43be37[a5_0x16a0('0x27')])?(0x0,metric_logger_1[a5_0x16a0('0x12')])(_0x581ecd[a5_0x16a0('0x14')][a5_0x16a0('0x27')]):metric_logger_1[a5_0x16a0('0x7')]);console[a5_0x16a0('0x15')](_0x581ecd);}});}}exports['DistributedAgentApi']=DistributedAgentApi;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DistributedAgentApi = void 0;
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const metric_logger_1 = require("../../../utilities/metric-logger");
const { output } = require('../../../utilities/nx-imports-light');
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) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
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) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Completing with an error',
bodyLines: [
`ciExecutionId: ${this.ciExecutionId}`,
`ciExecutionEnv: ${this.ciExecutionEnv}`,
`runGroup: ${this.runGroup}`,
`error: ${error}`,
],
});
}
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
try {
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
branch: this.branch,
runGroup: this.runGroup,
ciExecutionId: this.ciExecutionId,
ciExecutionEnv: this.ciExecutionEnv,
agentName: this.agentName,
criticalErrorMessage: error,
}));
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Completed run group with an error',
});
}
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
console.error(e);
}
});
}
}
exports.DistributedAgentApi = DistributedAgentApi;
//# sourceMappingURL=distributed-agent.api.js.map

@@ -1,1 +0,181 @@

const a6_0x40fc=['nxCloudAccessToken','then','note','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','executeTasks','tasksRunnerOptions','join','argv','message','__awaiter','random','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','dte-agent','printInvalidRunnerError','targets','encryptionKey','includes','Critical\x20Error\x20in\x20Agent:\x20\x22','../../../utilities/nx-imports-light','ErrorReporterApi','Distributed\x20Task\x20Execution\x20is\x20disabled\x20when\x20your\x20workspace\x20is\x20disabled','../../error/print-cacheable-targets-error','printRunGroupError','cacheableOperations','catch','../../../utilities/environment','canDetectRunGroup','./execute-tasks','some','../../error/print-invalid-runner-error','warn','Agent\x20was\x20terminated\x20via\x20SIGINT','NX_AGENT_NAME','Agent\x20was\x20terminated\x20via\x20SIGTERM','apply','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','isWorkspaceEnabled','./distributed-agent.api','./invoke-tasks-using-run-many','filter','completeRunGroupWithError','printCacheableTargetsError','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','length','getCloudOptions','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','mkdirSync','split','done','env','runner','DteArtifactStorage','map','getBranch','submitRunMetrics','getCIExecutionEnv','__esModule','Duplicate\x20Agent\x20ID\x20Detected','nx-cloud','startAgent','error','getRunGroup','floor','.lock','FileStorage','../../../utilities/metric-logger','next','default','throw','../../error/print-run-group-error','defineProperty','CIRCLE_STAGE','SIGINT','../../file-storage/file-storage','exit','E2EEncryption','Other\x20Nx\x20Cloud\x20Agents\x20Detected','CIRCLECI','CIRCLE_JOB','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20[','value','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','existsSync'];(function(_0x973931,_0x40fc51){const _0x1e4082=function(_0x178eb2){while(--_0x178eb2){_0x973931['push'](_0x973931['shift']());}};_0x1e4082(++_0x40fc51);}(a6_0x40fc,0x8b));const a6_0x1e40=function(_0x973931,_0x40fc51){_0x973931=_0x973931-0x0;let _0x1e4082=a6_0x40fc[_0x973931];return _0x1e4082;};'use strict';var __awaiter=this&&this[a6_0x1e40('0x24')]||function(_0x1f69e0,_0x5473f5,_0xd01843,_0xfb08fe){function _0x162764(_0x4fbacd){return _0x4fbacd instanceof _0xd01843?_0x4fbacd:new _0xd01843(function(_0x2c3dc7){_0x2c3dc7(_0x4fbacd);});}return new(_0xd01843||(_0xd01843=Promise))(function(_0x14b370,_0x467968){function _0x22fcbb(_0xca67d8){try{_0xbaa560(_0xfb08fe[a6_0x1e40('0xa')](_0xca67d8));}catch(_0x14d0bf){_0x467968(_0x14d0bf);}}function _0x5dbf51(_0x4b016f){try{_0xbaa560(_0xfb08fe[a6_0x1e40('0xc')](_0x4b016f));}catch(_0x233ba6){_0x467968(_0x233ba6);}}function _0xbaa560(_0x1a0013){_0x1a0013[a6_0x1e40('0x4b')]?_0x14b370(_0x1a0013[a6_0x1e40('0x18')]):_0x162764(_0x1a0013['value'])['then'](_0x22fcbb,_0x5dbf51);}_0xbaa560((_0xfb08fe=_0xfb08fe[a6_0x1e40('0x3d')](_0x1f69e0,_0x5473f5||[]))[a6_0x1e40('0xa')]());});};Object[a6_0x1e40('0xe')](exports,a6_0x1e40('0x0'),{'value':!![]});exports[a6_0x1e40('0x3')]=void 0x0;const fs_1=require('fs');const yargsParser=require('yargs-parser');const dte_artifact_storage_1=require('../../../utilities/dte-artifact-storage');const environment_1=require(a6_0x1e40('0x34'));const get_cloud_options_1=require('../../../utilities/get-cloud-options');const is_workspace_enabled_1=require('../../../utilities/is-workspace-enabled');const metric_logger_1=require(a6_0x1e40('0x9'));const error_reporter_api_1=require('../../api/error-reporter.api');const print_cacheable_targets_error_1=require(a6_0x1e40('0x30'));const print_invalid_runner_error_1=require(a6_0x1e40('0x38'));const print_run_group_error_1=require(a6_0x1e40('0xd'));const e2e_encryption_1=require('../../file-storage/e2e-encryption');const file_storage_1=require(a6_0x1e40('0x11'));const distributed_agent_api_1=require(a6_0x1e40('0x40'));const execute_tasks_1=require(a6_0x1e40('0x36'));const invoke_tasks_using_nx_imperative_api_1=require('./invoke-tasks-using-nx-imperative-api');const invoke_tasks_using_run_many_1=require(a6_0x1e40('0x41'));const {output}=require(a6_0x1e40('0x2d'));const {initTasksRunner,cacheDirectory}=require('../../../utilities/nx-imports');const args=yargsParser(process[a6_0x1e40('0x22')],{'array':[a6_0x1e40('0x29')],'default':{}});if(args[a6_0x1e40('0x29')]&&args[a6_0x1e40('0x29')][a6_0x1e40('0x46')]===0x1){args[a6_0x1e40('0x29')]=args[a6_0x1e40('0x29')][0x0][a6_0x1e40('0x4a')](',')[a6_0x1e40('0x4f')](_0x5b104e=>_0x5b104e['trim']());}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1a2e6d=(0x0,environment_1[a6_0x1e40('0x50')])();const _0x5d52a1=(0x0,environment_1[a6_0x1e40('0x5')])();const _0x19b5ef=(0x0,environment_1['getCIExecutionId'])();const _0xde99cd=(0x0,environment_1[a6_0x1e40('0x52')])();if(!(0x0,print_run_group_error_1[a6_0x1e40('0x35')])(_0x5d52a1,_0x19b5ef)){(0x0,print_run_group_error_1[a6_0x1e40('0x31')])();process[a6_0x1e40('0x12')](0x1);}if(args[a6_0x1e40('0x29')]&&args[a6_0x1e40('0x29')]['length']){output['note']({'title':a6_0x1e40('0x17')+args[a6_0x1e40('0x29')][a6_0x1e40('0x21')](',\x20')+']'});}else{output[a6_0x1e40('0x1d')]({'title':a6_0x1e40('0x1e')});}const {nxJson,nxCloudOptions:_0x2cd033}=(0x0,get_cloud_options_1[a6_0x1e40('0x47')])(a6_0x1e40('0xb'));function _0x1875cd(){var _0x116814;const _0x6e2adb=(_0x116814=nxJson[a6_0x1e40('0x20')])===null||_0x116814===void 0x0?void 0x0:_0x116814['default'];if(nxJson[a6_0x1e40('0x1b')]&&!_0x6e2adb){return!![];}return!(_0x6e2adb===null||_0x6e2adb===void 0x0?void 0x0:_0x6e2adb['runner'])&&process[a6_0x1e40('0x4c')]['NX_CLOUD_ACCESS_TOKEN']||!(_0x6e2adb===null||_0x6e2adb===void 0x0?void 0x0:_0x6e2adb['runner'])&&nxJson['nxCloudAccessToken']||(_0x6e2adb===null||_0x6e2adb===void 0x0?void 0x0:_0x6e2adb[a6_0x1e40('0x4d')])===a6_0x1e40('0x2')||(_0x6e2adb===null||_0x6e2adb===void 0x0?void 0x0:_0x6e2adb[a6_0x1e40('0x4d')])==='@nrwl/nx-cloud';}if(!_0x1875cd()){(0x0,print_invalid_runner_error_1[a6_0x1e40('0x28')])();return process['exit'](0x1);}if(args['targets']&&args['targets'][a6_0x1e40('0x37')](_0x3c05b2=>{var _0x59c2c3;return!((_0x59c2c3=_0x2cd033[a6_0x1e40('0x32')])===null||_0x59c2c3===void 0x0?void 0x0:_0x59c2c3['includes'](_0x3c05b2));})){const _0x27dd26=args[a6_0x1e40('0x29')][a6_0x1e40('0x42')](_0x298442=>{var _0x5561f9;return!((_0x5561f9=_0x2cd033[a6_0x1e40('0x32')])===null||_0x5561f9===void 0x0?void 0x0:_0x5561f9[a6_0x1e40('0x2b')](_0x298442));});(0x0,print_cacheable_targets_error_1[a6_0x1e40('0x44')])(_0x27dd26);return process[a6_0x1e40('0x12')](0x1);}const _0x518de8=yield(0x0,is_workspace_enabled_1[a6_0x1e40('0x3f')])(_0x2cd033);if(!_0x518de8){output[a6_0x1e40('0x4')]({'title':'Nx\x20Cloud:\x20Workspace\x20is\x20disabled','bodyLines':[a6_0x1e40('0x2f'),'','Organization\x20administrators\x20can\x20find\x20more\x20information\x20on\x20the\x20\x27Billing\x27\x20page\x20in\x20the\x20Nx\x20Cloud\x20Webapp']});process[a6_0x1e40('0x12')](0x1);}const _0x450f7d=getAgentName();const _0x3c5fc1=new distributed_agent_api_1['DistributedAgentApi'](_0x2cd033,_0x1a2e6d,_0x5d52a1,_0x19b5ef,_0xde99cd,_0x450f7d);createAgentLockfileAndSetUpListeners(_0x3c5fc1,_0x2cd033,_0x450f7d);const _0x1fd3c2=new e2e_encryption_1[(a6_0x1e40('0x13'))](environment_1['ENCRYPTION_KEY']||_0x2cd033[a6_0x1e40('0x2a')]);const _0x29bf86=new error_reporter_api_1[(a6_0x1e40('0x2e'))](_0x2cd033);const _0x39e5c0=new dte_artifact_storage_1[(a6_0x1e40('0x4e'))](new file_storage_1[(a6_0x1e40('0x8'))](_0x1fd3c2,_0x29bf86,_0x2cd033,a6_0x1e40('0x27')),cacheDirectory);const _0x214aad=initTasksRunner?yield(0x0,invoke_tasks_using_nx_imperative_api_1['invokeTasksUsingNxImperativeApi'])(_0x2cd033):yield(0x0,invoke_tasks_using_run_many_1['invokeTasksUsingRunMany'])();return(0x0,execute_tasks_1[a6_0x1e40('0x1f')])(_0x450f7d,_0x3c5fc1,_0x39e5c0,_0x214aad,args['targets'])[a6_0x1e40('0x1c')](_0x1278ff=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a6_0x1e40('0x51')])(_0x2cd033);return _0x1278ff;}))[a6_0x1e40('0x33')](_0xb946da=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x3c5fc1[a6_0x1e40('0x43')](a6_0x1e40('0x2c')+_0xb946da[a6_0x1e40('0x23')]+'\x22');throw _0xb946da;}));});}exports[a6_0x1e40('0x3')]=startAgent;function getAgentName(){if(process[a6_0x1e40('0x4c')][a6_0x1e40('0x3b')]!==undefined){return process[a6_0x1e40('0x4c')][a6_0x1e40('0x3b')];}else if(process[a6_0x1e40('0x4c')][a6_0x1e40('0x15')]!==undefined&&process[a6_0x1e40('0x4c')][a6_0x1e40('0xf')]){return process[a6_0x1e40('0x4c')][a6_0x1e40('0xf')];}else if(process['env'][a6_0x1e40('0x15')]!==undefined&&process[a6_0x1e40('0x4c')][a6_0x1e40('0x16')]){return process[a6_0x1e40('0x4c')][a6_0x1e40('0x16')];}else{return'Agent\x20'+Math[a6_0x1e40('0x6')](Math[a6_0x1e40('0x25')]()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x562d7a,_0x138402,_0x2546b4){const _0x4d54f8=cacheDirectory+'/lockfiles';const _0xa9d635=_0x4d54f8+'/'+_0x2546b4+a6_0x1e40('0x7');if(!(0x0,fs_1['existsSync'])(_0x4d54f8)){(0x0,fs_1[a6_0x1e40('0x49')])(_0x4d54f8,{'recursive':!![]});}const _0x5be956=(0x0,fs_1['readdirSync'])(_0x4d54f8);if(_0x5be956[a6_0x1e40('0x46')]){if(_0x5be956[a6_0x1e40('0x2b')](_0x2546b4+a6_0x1e40('0x7'))){output[a6_0x1e40('0x4')]({'title':a6_0x1e40('0x1'),'bodyLines':[a6_0x1e40('0x19'),'',a6_0x1e40('0x26')]});process[a6_0x1e40('0x12')](0x1);}output[a6_0x1e40('0x39')]({'title':a6_0x1e40('0x14'),'bodyLines':[a6_0x1e40('0x45'),'',a6_0x1e40('0x3e'),a6_0x1e40('0x48')]});}(0x0,fs_1['writeFileSync'])(_0xa9d635,'');process['on'](a6_0x1e40('0x12'),_0x35619b=>{cleanupAgentLockfile(_0xa9d635,_0x35619b);});process['on']('SIGTERM',()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x562d7a[a6_0x1e40('0x43')](a6_0x1e40('0x3c'));cleanupAgentLockfile(_0xa9d635,0x1);}));process['on'](a6_0x1e40('0x10'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x562d7a[a6_0x1e40('0x43')](a6_0x1e40('0x3a'));cleanupAgentLockfile(_0xa9d635,0x1);}));}function cleanupAgentLockfile(_0x51355e,_0x208449){if((0x0,fs_1[a6_0x1e40('0x1a')])(_0x51355e)){(0x0,fs_1['unlinkSync'])(_0x51355e);process['exit'](_0x208449);}}
"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 yargsParser = require("yargs-parser");
const dte_artifact_storage_1 = require("../../../utilities/dte-artifact-storage");
const environment_1 = require("../../../utilities/environment");
const get_cloud_options_1 = require("../../../utilities/get-cloud-options");
const is_workspace_enabled_1 = require("../../../utilities/is-workspace-enabled");
const metric_logger_1 = require("../../../utilities/metric-logger");
const error_reporter_api_1 = require("../../api/error-reporter.api");
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 e2e_encryption_1 = require("../../file-storage/e2e-encryption");
const file_storage_1 = require("../../file-storage/file-storage");
const distributed_agent_api_1 = require("./distributed-agent.api");
const execute_tasks_1 = require("./execute-tasks");
const invoke_tasks_using_nx_imperative_api_1 = require("./invoke-tasks-using-nx-imperative-api");
const invoke_tasks_using_run_many_1 = require("./invoke-tasks-using-run-many");
const { output } = require('../../../utilities/nx-imports-light');
const { initTasksRunner, cacheDirectory, } = require('../../../utilities/nx-imports');
const args = yargsParser(process.argv, {
array: ['targets'],
default: {},
});
// just in case someone passes the args with commas
// cf. https://github.com/yargs/yargs/issues/846
if (args.targets && args.targets.length === 1) {
args.targets = args.targets[0].split(',').map((x) => x.trim());
}
function startAgent() {
return __awaiter(this, void 0, void 0, function* () {
const branch = (0, environment_1.getBranch)();
const runGroup = (0, environment_1.getRunGroup)();
const ciExecutionId = (0, environment_1.getCIExecutionId)();
const ciExecutionEnv = (0, environment_1.getCIExecutionEnv)();
if (!(0, print_run_group_error_1.canDetectRunGroup)(runGroup, ciExecutionId)) {
(0, print_run_group_error_1.printRunGroupError)();
process.exit(1);
}
if (args.targets && args.targets.length) {
output.note({
title: `Starting an agent for running Nx target(s) [${args.targets.join(', ')}]`,
});
}
else {
output.note({
title: 'Starting an agent for running Nx tasks',
});
}
// TODO: Remove this as light client is default
const { nxJson, nxCloudOptions: options } = (0, get_cloud_options_1.getCloudOptions)('default');
function isNxCloudDefault() {
var _a;
const defaultRunnerConfig = (_a = nxJson.tasksRunnerOptions) === null || _a === void 0 ? void 0 : _a.default;
if (nxJson.nxCloudAccessToken && !defaultRunnerConfig) {
return true;
}
return ((!(defaultRunnerConfig === null || defaultRunnerConfig === void 0 ? void 0 : defaultRunnerConfig.runner) && process.env.NX_CLOUD_ACCESS_TOKEN) ||
(!(defaultRunnerConfig === null || defaultRunnerConfig === void 0 ? void 0 : defaultRunnerConfig.runner) && nxJson.nxCloudAccessToken) ||
(defaultRunnerConfig === null || defaultRunnerConfig === void 0 ? void 0 : defaultRunnerConfig.runner) === 'nx-cloud' ||
(defaultRunnerConfig === null || defaultRunnerConfig === void 0 ? void 0 : defaultRunnerConfig.runner) === '@nrwl/nx-cloud');
}
if (!isNxCloudDefault()) {
(0, print_invalid_runner_error_1.printInvalidRunnerError)();
return process.exit(1);
}
if (args.targets &&
args.targets.some((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); })) {
const wrongTargets = args.targets.filter((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); });
(0, print_cacheable_targets_error_1.printCacheableTargetsError)(wrongTargets);
return process.exit(1);
}
const workspaceEnabled = yield (0, is_workspace_enabled_1.isWorkspaceEnabled)(options);
if (!workspaceEnabled) {
output.error({
title: 'Nx Cloud: Workspace is disabled',
bodyLines: [
'Distributed Task Execution is disabled when your workspace is disabled',
'',
"Organization administrators can find more information on the 'Billing' page in the Nx Cloud Webapp",
],
});
process.exit(1);
}
const agentName = getAgentName();
const api = new distributed_agent_api_1.DistributedAgentApi(options, branch, runGroup, ciExecutionId, ciExecutionEnv, agentName);
createAgentLockfileAndSetUpListeners(api, options, agentName);
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
const errorReporter = new error_reporter_api_1.ErrorReporterApi(options);
const dteArtifactStorage = new dte_artifact_storage_1.DteArtifactStorage(new file_storage_1.FileStorage(encryption, errorReporter, options, 'dte-agent'), cacheDirectory);
const invokeTasks = initTasksRunner
? yield (0, invoke_tasks_using_nx_imperative_api_1.invokeTasksUsingNxImperativeApi)(options)
: yield (0, invoke_tasks_using_run_many_1.invokeTasksUsingRunMany)();
return (0, execute_tasks_1.executeTasks)(agentName, api, dteArtifactStorage, invokeTasks, args.targets)
.then((res) => __awaiter(this, void 0, void 0, function* () {
yield (0, metric_logger_1.submitRunMetrics)(options);
return res;
}))
.catch((e) => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
throw e;
}));
});
}
exports.startAgent = startAgent;
function getAgentName() {
if (process.env.NX_AGENT_NAME !== undefined) {
return process.env.NX_AGENT_NAME;
}
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_STAGE) {
return process.env.CIRCLE_STAGE;
}
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_JOB) {
return process.env.CIRCLE_JOB;
}
else {
return `Agent ${Math.floor(Math.random() * 100000)}`;
}
}
function createAgentLockfileAndSetUpListeners(api, options, agentName) {
const lockFileDirectory = `${cacheDirectory}/lockfiles`;
const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
if (!(0, fs_1.existsSync)(lockFileDirectory)) {
(0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
}
// Check for other agents' lockfiles and warn if exist
const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
if (lockFiles.length) {
// Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
if (lockFiles.includes(`${agentName}.lock`)) {
output.error({
title: 'Duplicate Agent ID Detected',
bodyLines: [
'We have detected another agent with this ID running in this workspace. This should not happen.',
'',
'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
],
});
process.exit(1);
}
output.warn({
title: 'Other Nx Cloud Agents Detected',
bodyLines: [
'We have detected other agents running in this workspace. This can cause unexpected behavior.',
'',
'This can also be a false positive caused by agents that did not shut down correctly.',
'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
],
});
}
(0, fs_1.writeFileSync)(lockFilePath, '');
process.on('exit', (code) => {
cleanupAgentLockfile(lockFilePath, code);
});
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError('Agent was terminated via SIGTERM');
cleanupAgentLockfile(lockFilePath, 1);
}));
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError('Agent was terminated via SIGINT');
cleanupAgentLockfile(lockFilePath, 1);
}));
}
function cleanupAgentLockfile(lockFilePath, code) {
if ((0, fs_1.existsSync)(lockFilePath)) {
(0, fs_1.unlinkSync)(lockFilePath);
process.exit(code);
}
}
//# sourceMappingURL=distributed-agent.impl.js.map

@@ -1,1 +0,114 @@

const a7_0x2d4a=['executeTasks','status:\x20','join','../../../utilities/nx-imports-light','value','retryDuring','apply','VERBOSE_LOGGING','length','completedTasks','done','\x20Hash:\x20','Waiter','url','\x20Url:\x20','then','note','taskId','\x20waiting...','NO_MESSAGES_TIMEOUT','executionId','RUN_GROUP_COMPLETED','createUnchangedValueTimeout','wait','retryDuring:\x20','map','\x20downloading\x20artifacts\x20for\x20','\x20seconds','../../../utilities/create-unchanged-value-timeout','error:\x20','hash','\x20fetching\x20tasks...','defineProperty','../../../utilities/environment','executionId:\x20','status','exit','throw','NO_FURTHER_TASKS_TO_RUN','next','error','getTime','criticalErrorMessage','tasks','completed','Distributed\x20Execution\x20Terminated','\x20received\x20an\x20API\x20Response','No\x20new\x20messages\x20received\x20after\x20','../../../utilities/waiter','maxParallel','reset'];(function(_0x417844,_0x2d4a70){const _0x36d930=function(_0x569840){while(--_0x569840){_0x417844['push'](_0x417844['shift']());}};_0x36d930(++_0x2d4a70);}(a7_0x2d4a,0x177));const a7_0x36d9=function(_0x417844,_0x2d4a70){_0x417844=_0x417844-0x0;let _0x36d930=a7_0x2d4a[_0x417844];return _0x36d930;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x15f3cf,_0x1bbb17,_0x5e79cf,_0x3223fe){function _0x246aec(_0x123689){return _0x123689 instanceof _0x5e79cf?_0x123689:new _0x5e79cf(function(_0x55635c){_0x55635c(_0x123689);});}return new(_0x5e79cf||(_0x5e79cf=Promise))(function(_0x341c3d,_0xbeefd){function _0x536422(_0x33360d){try{_0x49b0f4(_0x3223fe[a7_0x36d9('0x15')](_0x33360d));}catch(_0x5d7e4a){_0xbeefd(_0x5d7e4a);}}function _0x75409e(_0x76fb0c){try{_0x49b0f4(_0x3223fe[a7_0x36d9('0x13')](_0x76fb0c));}catch(_0x55f65e){_0xbeefd(_0x55f65e);}}function _0x49b0f4(_0xe5817e){_0xe5817e[a7_0x36d9('0x2b')]?_0x341c3d(_0xe5817e[a7_0x36d9('0x25')]):_0x246aec(_0xe5817e[a7_0x36d9('0x25')])[a7_0x36d9('0x30')](_0x536422,_0x75409e);}_0x49b0f4((_0x3223fe=_0x3223fe[a7_0x36d9('0x27')](_0x15f3cf,_0x1bbb17||[]))['next']());});};Object[a7_0x36d9('0xe')](exports,'__esModule',{'value':!![]});exports[a7_0x36d9('0x21')]=void 0x0;const create_unchanged_value_timeout_1=require(a7_0x36d9('0xa'));const environment_1=require(a7_0x36d9('0xf'));const waiter_1=require(a7_0x36d9('0x1e'));const {output}=require(a7_0x36d9('0x24'));function executeTasks(_0x44d116,_0x3f7506,_0x1e4815,_0x138a63,_0x2e3b3b){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x443b9f=0x0;let _0xc2672b=null;const _0xfd9080=(0x0,create_unchanged_value_timeout_1[a7_0x36d9('0x4')])({'title':a7_0x36d9('0x1d')+environment_1['NO_MESSAGES_TIMEOUT']/0x3e8+a7_0x36d9('0x9'),'timeout':environment_1[a7_0x36d9('0x1')]});const _0x5ac125=new waiter_1[(a7_0x36d9('0x2d'))]();let _0x2c567a=[];const _0xe8e4e=new Date();let _0x355e7b=![];const _0x57cf38={};while(!![]){if(environment_1['VERBOSE_LOGGING']){output['note']({'title':_0x44d116+a7_0x36d9('0xd')});}_0xc2672b=yield _0x3f7506[a7_0x36d9('0x19')](_0xc2672b?_0xc2672b[a7_0x36d9('0x2')]:null,_0x443b9f,_0x2c567a,_0x2e3b3b);if(environment_1[a7_0x36d9('0x28')]){output[a7_0x36d9('0x31')]({'title':_0x44d116+a7_0x36d9('0x1c'),'bodyLines':['completed:\x20'+_0xc2672b[a7_0x36d9('0x1a')],a7_0x36d9('0x22')+_0xc2672b[a7_0x36d9('0x11')],a7_0x36d9('0x6')+_0xc2672b[a7_0x36d9('0x26')],a7_0x36d9('0x10')+_0xc2672b[a7_0x36d9('0x2')],'number\x20of\x20tasks:\x20'+_0xc2672b[a7_0x36d9('0x19')][a7_0x36d9('0x29')],a7_0x36d9('0xb')+_0xc2672b[a7_0x36d9('0x18')],'maxParallel:\x20'+_0xc2672b['maxParallel']]});}if(_0xc2672b['criticalErrorMessage']){output[a7_0x36d9('0x16')]({'title':a7_0x36d9('0x1b'),'bodyLines':['Error:',_0xc2672b[a7_0x36d9('0x18')]]});process[a7_0x36d9('0x12')](0x1);}if((_0xc2672b===null||_0xc2672b===void 0x0?void 0x0:_0xc2672b[a7_0x36d9('0x26')])&&(_0xc2672b===null||_0xc2672b===void 0x0?void 0x0:_0xc2672b['retryDuring'])!==0x0&&!_0x355e7b&&new Date()[a7_0x36d9('0x17')]()-_0xe8e4e[a7_0x36d9('0x17')]()>_0xc2672b[a7_0x36d9('0x26')]){yield _0x5ac125[a7_0x36d9('0x5')]();continue;}if((_0xc2672b===null||_0xc2672b===void 0x0?void 0x0:_0xc2672b[a7_0x36d9('0x11')])!==undefined){if(_0xc2672b[a7_0x36d9('0x11')]===a7_0x36d9('0x3')||_0xc2672b[a7_0x36d9('0x11')]===a7_0x36d9('0x14')){return;}}else if(_0xc2672b[a7_0x36d9('0x1a')]){return;}_0xfd9080(_0xc2672b[a7_0x36d9('0x19')][a7_0x36d9('0x7')](_0xb01eff=>_0xb01eff[a7_0x36d9('0x32')])[a7_0x36d9('0x23')](''));if(!_0xc2672b[a7_0x36d9('0x2')]){if(environment_1['VERBOSE_LOGGING']){output['note']({'title':_0x44d116+a7_0x36d9('0x0')});}yield _0x5ac125['wait']();_0x443b9f=0x0;_0x2c567a=[];continue;}_0x5ac125[a7_0x36d9('0x20')]();_0x355e7b=!![];if(_0xc2672b[a7_0x36d9('0x2a')]){for(const _0x1615b5 of _0xc2672b[a7_0x36d9('0x2a')]){if(_0x57cf38[_0x1615b5[a7_0x36d9('0x32')]])continue;output[a7_0x36d9('0x31')]({'title':_0x44d116+a7_0x36d9('0x8')+_0x1615b5[a7_0x36d9('0x32')]+a7_0x36d9('0x2c')+_0x1615b5[a7_0x36d9('0xc')]+a7_0x36d9('0x2f')+_0x1615b5['url']});yield _0x1e4815['retrieveAndExtract'](_0x1615b5[a7_0x36d9('0xc')],_0x1615b5[a7_0x36d9('0x2e')]);_0x57cf38[_0x1615b5['taskId']]=!![];}}const _0x297aec=yield _0x138a63(_0xc2672b[a7_0x36d9('0x2')],_0xc2672b['tasks'],_0xc2672b[a7_0x36d9('0x1f')]);for(const _0x5086ce of _0x297aec[a7_0x36d9('0x2a')]){_0x57cf38[_0x5086ce[a7_0x36d9('0x32')]]=!![];}_0x443b9f=_0x297aec['completedStatusCode'];_0x2c567a=_0x297aec[a7_0x36d9('0x2a')];}});}exports[a7_0x36d9('0x21')]=executeTasks;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeTasks = void 0;
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
const environment_1 = require("../../../utilities/environment");
const waiter_1 = require("../../../utilities/waiter");
const { output } = require('../../../utilities/nx-imports-light');
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(1);
}
// run group is completed but it might be a rerun
// we will try several times before going further and
// completed the response
// we only do it if we haven't executed any tasks
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
(apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
!executedAnyTasks &&
new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
yield waiter.wait();
continue;
}
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.status) !== undefined) {
if (apiResponse.status === 'RUN_GROUP_COMPLETED' ||
apiResponse.status === 'NO_FURTHER_TASKS_TO_RUN') {
return;
}
}
else if (apiResponse.completed) {
return;
}
// if status is present that use the status instead of completed, otherwise use completed
failIfSameTasksAfterTimeout(apiResponse.tasks.map((t) => t.taskId).join(''));
if (!apiResponse.executionId) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `${agentName} waiting...`,
});
}
yield waiter.wait();
completedStatusCode = 0;
completedTasks = [];
continue;
}
waiter.reset();
executedAnyTasks = true;
if (apiResponse.completedTasks) {
for (const t of apiResponse.completedTasks) {
if (processedTasks[t.taskId])
continue;
output.note({
title: `${agentName} downloading artifacts for ${t.taskId} Hash: ${t.hash} Url: ${t.url}`,
});
yield dteArtifactStorage.retrieveAndExtract(t.hash, t.url);
processedTasks[t.taskId] = true;
}
}
const r = yield invokeTasks(apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
for (const t of r.completedTasks) {
processedTasks[t.taskId] = true;
}
completedStatusCode = r.completedStatusCode;
completedTasks = r.completedTasks;
}
});
}
exports.executeTasks = executeTasks;
//# sourceMappingURL=execute-tasks.js.map

@@ -1,1 +0,59 @@

const a8_0xb8bb=['projectName','__awaiter','invokeTasksUsingNxImperativeApi','status','assign','taskGraph','target','tasks','yargs-parser','../../../utilities/serializer-overrides','NX_PREFIX_OUTPUT','invoke','true','apply','value','NX_STREAM_OUTPUT','then','unparse','defineProperty','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','params','length','env','next','../../../utilities/nx-imports','NX_CACHE_FAILURES','map','done','configuration','taskId','__esModule'];(function(_0xcf932a,_0xb8bbcc){const _0x1c0786=function(_0x391751){while(--_0x391751){_0xcf932a['push'](_0xcf932a['shift']());}};_0x1c0786(++_0xb8bbcc);}(a8_0xb8bb,0x9a));const a8_0x1c07=function(_0xcf932a,_0xb8bbcc){_0xcf932a=_0xcf932a-0x0;let _0x1c0786=a8_0xb8bb[_0xcf932a];return _0x1c0786;};'use strict';var __awaiter=this&&this[a8_0x1c07('0x2')]||function(_0x7d48b7,_0x15c916,_0xcf1950,_0x46c75b){function _0x228e42(_0x3f490e){return _0x3f490e instanceof _0xcf1950?_0x3f490e:new _0xcf1950(function(_0x2c11d9){_0x2c11d9(_0x3f490e);});}return new(_0xcf1950||(_0xcf1950=Promise))(function(_0x162c73,_0x102fda){function _0x1c0105(_0x3f2710){try{_0x35083f(_0x46c75b[a8_0x1c07('0x18')](_0x3f2710));}catch(_0x94411e){_0x102fda(_0x94411e);}}function _0x5dbfab(_0x434c84){try{_0x35083f(_0x46c75b['throw'](_0x434c84));}catch(_0x2c6bf4){_0x102fda(_0x2c6bf4);}}function _0x35083f(_0x33a986){_0x33a986[a8_0x1c07('0x1c')]?_0x162c73(_0x33a986[a8_0x1c07('0xf')]):_0x228e42(_0x33a986['value'])[a8_0x1c07('0x11')](_0x1c0105,_0x5dbfab);}_0x35083f((_0x46c75b=_0x46c75b[a8_0x1c07('0xe')](_0x7d48b7,_0x15c916||[]))[a8_0x1c07('0x18')]());});};Object[a8_0x1c07('0x13')](exports,a8_0x1c07('0x0'),{'value':!![]});exports[a8_0x1c07('0x3')]=void 0x0;const parser=require(a8_0x1c07('0x9'));const serializer_overrides_1=require(a8_0x1c07('0xa'));const {initTasksRunner}=require(a8_0x1c07('0x19'));function invokeTasksUsingNxImperativeApi(_0x1aaaf7){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x432b80=yield initTasksRunner(_0x1aaaf7);return(_0x4116a7,_0x1c7a47,_0x2cee4b)=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x506713=_0x1c7a47[a8_0x1c07('0x1b')](_0x53044b=>{const _0x58370b=parser(_0x53044b[a8_0x1c07('0x15')],{'configuration':{'camel-case-expansion':![],'dot-notation':!![]}});const _0x5c37c4=(0x0,serializer_overrides_1[a8_0x1c07('0x12')])(_0x58370b);if(_0x58370b['_'][a8_0x1c07('0x16')]==0x0){delete _0x58370b['_'];}return{'id':_0x53044b[a8_0x1c07('0x1e')],'target':{'project':_0x53044b[a8_0x1c07('0x1')],'target':_0x53044b[a8_0x1c07('0x7')],'configuration':_0x53044b[a8_0x1c07('0x1d')]},'overrides':Object['assign'](Object[a8_0x1c07('0x5')]({},_0x58370b),{'__overrides_unparsed__':_0x5c37c4}),'projectRoot':_0x53044b['projectRoot']};});process[a8_0x1c07('0x17')][a8_0x1c07('0x1a')]=a8_0x1c07('0xd');process[a8_0x1c07('0x17')][a8_0x1c07('0x14')]=_0x4116a7;process[a8_0x1c07('0x17')][a8_0x1c07('0x10')]=a8_0x1c07('0xd');process[a8_0x1c07('0x17')][a8_0x1c07('0xb')]=a8_0x1c07('0xd');const _0xa4a07d=yield _0x432b80[a8_0x1c07('0xc')]({'tasks':_0x506713,'parallel':_0x2cee4b});const _0x5606c6=Object['values'](_0xa4a07d[a8_0x1c07('0x6')][a8_0x1c07('0x8')]);return{'completedTasks':_0x5606c6['map'](_0x2b0a25=>({'taskId':_0x2b0a25['id'],'hash':_0x2b0a25['hash']})),'completedStatusCode':_0xa4a07d[a8_0x1c07('0x4')]};});});}exports['invokeTasksUsingNxImperativeApi']=invokeTasksUsingNxImperativeApi;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.invokeTasksUsingNxImperativeApi = void 0;
const parser = require("yargs-parser");
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
const { initTasksRunner } = require('../../../utilities/nx-imports');
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 }),
projectRoot: t.projectRoot,
};
});
process.env.NX_CACHE_FAILURES = 'true'; // this is only requires because of how we do uploads
process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID = executionId;
process.env.NX_STREAM_OUTPUT = 'true';
process.env.NX_PREFIX_OUTPUT = 'true';
const r = yield tasksRunner.invoke({ tasks, parallel });
const completedTasks = Object.values(r.taskGraph.tasks);
return {
completedTasks: completedTasks.map((t) => ({
taskId: t.id,
hash: t.hash,
})),
completedStatusCode: r.status,
};
});
});
}
exports.invokeTasksUsingNxImperativeApi = invokeTasksUsingNxImperativeApi;
//# sourceMappingURL=invoke-tasks-using-nx-imperative-api.js.map

@@ -1,1 +0,97 @@

const a9_0x2226=['push','true','Executing:\x20\x27','then','assign','configuration','invokeTasksUsingRunMany','status','projectName','--configuration=','\x20--parallel\x20--max-parallel=','\x20--projects=','/tasks-hashes-','../../../utilities/nx-imports-light','unlinkSync','apply','execSync','ignore','npx\x20nx\x20run-many\x20--target=','child_process','value','next','target','VERBOSE_LOGGING','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','defineProperty','__awaiter','projects','params','../../../utilities/environment','__esModule','env'];(function(_0xc5471a,_0x22263e){const _0x39283c=function(_0x2b7508){while(--_0x2b7508){_0xc5471a['push'](_0xc5471a['shift']());}};_0x39283c(++_0x22263e);}(a9_0x2226,0x97));const a9_0x3928=function(_0xc5471a,_0x22263e){_0xc5471a=_0xc5471a-0x0;let _0x39283c=a9_0x2226[_0xc5471a];return _0x39283c;};'use strict';var __awaiter=this&&this[a9_0x3928('0x3')]||function(_0x49a17b,_0x14abb6,_0x478ab5,_0x4469d3){function _0xbf4f38(_0x371df2){return _0x371df2 instanceof _0x478ab5?_0x371df2:new _0x478ab5(function(_0xbd73d1){_0xbd73d1(_0x371df2);});}return new(_0x478ab5||(_0x478ab5=Promise))(function(_0x462870,_0x121562){function _0x52e427(_0x2c1690){try{_0x3699eb(_0x4469d3[a9_0x3928('0x1e')](_0x2c1690));}catch(_0x3f5337){_0x121562(_0x3f5337);}}function _0x1ba8f4(_0x58dc6c){try{_0x3699eb(_0x4469d3['throw'](_0x58dc6c));}catch(_0x428702){_0x121562(_0x428702);}}function _0x3699eb(_0x26c867){_0x26c867['done']?_0x462870(_0x26c867[a9_0x3928('0x1d')]):_0xbf4f38(_0x26c867[a9_0x3928('0x1d')])[a9_0x3928('0xc')](_0x52e427,_0x1ba8f4);}_0x3699eb((_0x4469d3=_0x4469d3[a9_0x3928('0x18')](_0x49a17b,_0x14abb6||[]))[a9_0x3928('0x1e')]());});};Object[a9_0x3928('0x2')](exports,a9_0x3928('0x7'),{'value':!![]});exports[a9_0x3928('0xf')]=void 0x0;const child_process_1=require(a9_0x3928('0x1c'));const fs_1=require('fs');const environment_1=require(a9_0x3928('0x6'));const {output}=require(a9_0x3928('0x16'));const {cacheDirectory}=require('../../../utilities/nx-imports');function invokeTasksUsingRunMany(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x414e7e=completedTasksReader();return function _0x2608a4(_0x1854be,_0x214da3,_0x403786){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x5cc93e=0x0;const _0x42c9d0=[];for(const _0x277321 of groupByTarget(_0x214da3)){const _0xba760b=_0x277321['configuration']?a9_0x3928('0x12')+_0x277321['configuration']:'';const _0x475802=_0x403786>0x1?a9_0x3928('0x13')+_0x403786:'';const _0x20e289=a9_0x3928('0x1b')+_0x277321[a9_0x3928('0x1f')]+'\x20'+_0xba760b+a9_0x3928('0x14')+_0x277321[a9_0x3928('0x4')]['join'](',')+'\x20'+_0x277321[a9_0x3928('0x5')]+_0x475802;if(environment_1[a9_0x3928('0x0')]){output['note']({'title':a9_0x3928('0xb')+_0x20e289+'\x27'});}try{(0x0,child_process_1[a9_0x3928('0x19')])(_0x20e289,{'stdio':[a9_0x3928('0x1a'),'inherit','inherit'],'env':Object['assign'](Object[a9_0x3928('0xd')]({},process[a9_0x3928('0x8')]),{'NX_CACHE_FAILURES':'true','NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x1854be,'NX_STREAM_OUTPUT':a9_0x3928('0xa'),'NX_PREFIX_OUTPUT':a9_0x3928('0xa')})});_0x42c9d0[a9_0x3928('0x9')](..._0x414e7e(_0x1854be));}catch(_0x5df838){if(_0x5df838[a9_0x3928('0x10')]===environment_1[a9_0x3928('0x1')]){throw _0x5df838;}else{_0x5cc93e=0x1;_0x42c9d0[a9_0x3928('0x9')](..._0x414e7e(_0x1854be));}}}return{'completedStatusCode':_0x5cc93e,'completedTasks':_0x42c9d0};});};});}exports[a9_0x3928('0xf')]=invokeTasksUsingRunMany;function groupByTarget(_0x2640f5){const _0x220141=[];_0x2640f5['forEach'](_0x25bd37=>{const _0x432788=_0x220141['find'](_0x56a280=>_0x56a280[a9_0x3928('0x1f')]===_0x25bd37[a9_0x3928('0x1f')]&&_0x56a280[a9_0x3928('0xe')]===_0x25bd37[a9_0x3928('0xe')]);if(_0x432788){_0x432788[a9_0x3928('0x4')]['push'](_0x25bd37[a9_0x3928('0x11')]);}else{_0x220141['push']({'target':_0x25bd37[a9_0x3928('0x1f')],'projects':[_0x25bd37[a9_0x3928('0x11')]],'params':_0x25bd37[a9_0x3928('0x5')],'configuration':_0x25bd37[a9_0x3928('0xe')]});}});return _0x220141;}function completedTasksReader(){return _0x21ea10=>{const _0x5e5ef2='Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20'+_0x21ea10+').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.';let _0x226955;try{const _0x11b66b=cacheDirectory+a9_0x3928('0x15')+_0x21ea10;_0x226955=JSON['parse']((0x0,fs_1['readFileSync'])(_0x11b66b)['toString']());(0x0,fs_1[a9_0x3928('0x17')])(_0x11b66b);}catch(_0x5b2ca3){throw new Error(_0x5e5ef2);}if(_0x226955['length']==0x0){throw new Error(_0x5e5ef2);}return _0x226955;};}
"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 child_process_1 = require("child_process");
const fs_1 = require("fs");
const environment_1 = require("../../../utilities/environment");
const { output } = require('../../../utilities/nx-imports-light');
const { cacheDirectory } = require('../../../utilities/nx-imports');
function invokeTasksUsingRunMany() {
return __awaiter(this, void 0, void 0, function* () {
const readCompleted = completedTasksReader();
return function invokeTasksUsingRunMany(executionId, tasksToExecute, parallel) {
return __awaiter(this, void 0, void 0, function* () {
let completedStatusCode = 0;
const completedTasks = [];
for (const g of groupByTarget(tasksToExecute)) {
const config = g.configuration
? `--configuration=${g.configuration}`
: ``;
const parallelStr = parallel > 1 ? ` --parallel --max-parallel=${parallel}` : ``;
// TODO use pnpx or yarn when needed
const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallelStr}`;
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Executing: '${command}'`,
});
}
try {
(0, child_process_1.execSync)(command, {
stdio: ['ignore', 'inherit', 'inherit'],
env: Object.assign(Object.assign({}, process.env), { NX_CACHE_FAILURES: 'true', NX_CLOUD_DISTRIBUTED_EXECUTION_ID: executionId, NX_STREAM_OUTPUT: 'true', NX_PREFIX_OUTPUT: 'true' }),
});
completedTasks.push(...readCompleted(executionId));
}
catch (e) {
if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
throw e;
}
else {
completedStatusCode = 1;
completedTasks.push(...readCompleted(executionId));
}
}
}
return { completedStatusCode, completedTasks };
});
};
});
}
exports.invokeTasksUsingRunMany = invokeTasksUsingRunMany;
function groupByTarget(tasks) {
const res = [];
tasks.forEach((t) => {
const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
if (r) {
r.projects.push(t.projectName);
}
else {
res.push({
target: t.target,
projects: [t.projectName],
params: t.params,
configuration: t.configuration,
});
}
});
return res;
}
function completedTasksReader() {
return (distributedExecutionId) => {
const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
let completedTasks;
try {
const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
// remove it such that if the next command crashes we don't read an obsolete file
(0, fs_1.unlinkSync)(taskHashesFile);
}
catch (e) {
throw new Error(errorMessage);
}
if (completedTasks.length == 0) {
throw new Error(errorMessage);
}
return completedTasks;
};
}
//# sourceMappingURL=invoke-tasks-using-run-many.js.map

@@ -1,1 +0,155 @@

const a10_0x1742=['runGroup:\x20','status','defineProperty','dteStart','parseCommand','hash','enabled','__esModule','message','then','createMetricRecorder','target','value','createApiAxiosInstance','../../../utilities/environment','DistributedExecutionApi','completeRunGroup','parallel','VERBOSE_LOGGING','map','dteStatus','false','/nx-cloud/executions/complete-run-group','axiosException','completeRunGroupWithError','createStartRequest','data','recordMetric','error','error:\x20','RUNNER_FAILURE_PERF_ENTRY','axiosMultipleTries','../../../utilities/axios','mapRespToPerfEntry','post','ciExecutionEnv:\x20','apiAxiosInstance','apply','response','stopAgentsOnFailure','__awaiter','configuration','maxParallel','note','NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT','start','Completing\x20with\x20an\x20error','projectRoot','../../../utilities/metric-logger','Starting\x20a\x20distributed\x20execution','Workspace\x20is\x20disabled.\x20Cannot\x20perform\x20distributed\x20task\x20executions.','true','stringify'];(function(_0x58f1ea,_0x17423c){const _0x1c9507=function(_0x172589){while(--_0x172589){_0x58f1ea['push'](_0x58f1ea['shift']());}};_0x1c9507(++_0x17423c);}(a10_0x1742,0x1d9));const a10_0x1c95=function(_0x58f1ea,_0x17423c){_0x58f1ea=_0x58f1ea-0x0;let _0x1c9507=a10_0x1742[_0x58f1ea];return _0x1c9507;};'use strict';var __awaiter=this&&this[a10_0x1c95('0x2c')]||function(_0x5b8b43,_0x1e77d0,_0x25f719,_0x11bdc6){function _0x731486(_0x788452){return _0x788452 instanceof _0x25f719?_0x788452:new _0x25f719(function(_0x11d228){_0x11d228(_0x788452);});}return new(_0x25f719||(_0x25f719=Promise))(function(_0x1b32a2,_0xfdfde5){function _0x2d6971(_0x300378){try{_0x5133ad(_0x11bdc6['next'](_0x300378));}catch(_0x40f534){_0xfdfde5(_0x40f534);}}function _0x2e483d(_0x46e56e){try{_0x5133ad(_0x11bdc6['throw'](_0x46e56e));}catch(_0x17cc33){_0xfdfde5(_0x17cc33);}}function _0x5133ad(_0x5abb05){_0x5abb05['done']?_0x1b32a2(_0x5abb05[a10_0x1c95('0x10')]):_0x731486(_0x5abb05[a10_0x1c95('0x10')])[a10_0x1c95('0xd')](_0x2d6971,_0x2e483d);}_0x5133ad((_0x11bdc6=_0x11bdc6[a10_0x1c95('0x29')](_0x5b8b43,_0x1e77d0||[]))['next']());});};Object[a10_0x1c95('0x6')](exports,a10_0x1c95('0xb'),{'value':!![]});exports[a10_0x1c95('0x1d')]=exports[a10_0x1c95('0x13')]=void 0x0;const axios_1=require(a10_0x1c95('0x24'));const environment_1=require(a10_0x1c95('0x12'));const metric_logger_1=require(a10_0x1c95('0x34'));const serializer_overrides_1=require('../../../utilities/serializer-overrides');const {output}=require('../../../utilities/nx-imports-light');class DistributedExecutionApi{constructor(_0x120157){this[a10_0x1c95('0x28')]=(0x0,axios_1[a10_0x1c95('0x11')])(_0x120157);}[a10_0x1c95('0x31')](_0x366488){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x19a8a0;const _0xa24ed0=(0x0,metric_logger_1['createMetricRecorder'])(a10_0x1c95('0x7'));let _0xa34308;if(environment_1[a10_0x1c95('0x16')]){output[a10_0x1c95('0x2f')]({'title':a10_0x1c95('0x0'),'bodyLines':[JSON[a10_0x1c95('0x3')](_0x366488,null,0x2)]});}try{_0xa34308=yield(0x0,axios_1[a10_0x1c95('0x23')])(()=>this[a10_0x1c95('0x28')][a10_0x1c95('0x26')]('/nx-cloud/executions/start',_0x366488));_0xa24ed0[a10_0x1c95('0x1f')]((0x0,metric_logger_1[a10_0x1c95('0x25')])(_0xa34308));}catch(_0x132f29){_0xa24ed0['recordMetric'](((_0x19a8a0=_0x132f29===null||_0x132f29===void 0x0?void 0x0:_0x132f29['axiosException'])===null||_0x19a8a0===void 0x0?void 0x0:_0x19a8a0['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x132f29[a10_0x1c95('0x1b')][a10_0x1c95('0x2a')]):metric_logger_1[a10_0x1c95('0x22')]);throw _0x132f29;}if(!_0xa34308[a10_0x1c95('0x1e')][a10_0x1c95('0xa')]){throw new Error(a10_0x1c95('0x1'));}if(_0xa34308[a10_0x1c95('0x1e')][a10_0x1c95('0x20')]){throw new Error(_0xa34308['data'][a10_0x1c95('0x20')]);}return _0xa34308[a10_0x1c95('0x1e')]['id'];});}[a10_0x1c95('0x5')](_0x169525){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x2ff59e;const _0x1f8701=(0x0,metric_logger_1[a10_0x1c95('0xe')])(a10_0x1c95('0x18'));try{const _0x4b1edb=yield(0x0,axios_1[a10_0x1c95('0x23')])(()=>this['apiAxiosInstance'][a10_0x1c95('0x26')]('/nx-cloud/executions/status',{'id':_0x169525}));_0x1f8701[a10_0x1c95('0x1f')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x4b1edb));return _0x4b1edb[a10_0x1c95('0x1e')];}catch(_0x3a799c){_0x1f8701[a10_0x1c95('0x1f')](((_0x2ff59e=_0x3a799c===null||_0x3a799c===void 0x0?void 0x0:_0x3a799c['axiosException'])===null||_0x2ff59e===void 0x0?void 0x0:_0x2ff59e[a10_0x1c95('0x2a')])?(0x0,metric_logger_1[a10_0x1c95('0x25')])(_0x3a799c[a10_0x1c95('0x1b')][a10_0x1c95('0x2a')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a10_0x1c95('0x20')]({'title':_0x3a799c[a10_0x1c95('0xc')]});process['exit'](0x1);}});}[a10_0x1c95('0x1c')](_0x37a29c,_0x7acfc2,_0x4b3b90,_0xb15adc,_0x31d688){return __awaiter(this,void 0x0,void 0x0,function*(){var _0x5c13fe;const _0x5897d4=(0x0,metric_logger_1['createMetricRecorder'])(a10_0x1c95('0x14'));if(environment_1[a10_0x1c95('0x16')]){output['note']({'title':a10_0x1c95('0x32'),'bodyLines':['ciExecutionId:\x20'+_0x4b3b90,a10_0x1c95('0x27')+_0xb15adc,a10_0x1c95('0x4')+_0x7acfc2,a10_0x1c95('0x21')+_0x31d688]});}try{const _0x1ff7d3=yield(0x0,axios_1[a10_0x1c95('0x23')])(()=>this[a10_0x1c95('0x28')][a10_0x1c95('0x26')](a10_0x1c95('0x1a'),{'branch':_0x37a29c,'runGroup':_0x7acfc2,'ciExecutionId':_0x4b3b90,'ciExecutionEnv':_0xb15adc,'criticalErrorMessage':_0x31d688}),0x3);_0x5897d4[a10_0x1c95('0x1f')]((0x0,metric_logger_1[a10_0x1c95('0x25')])(_0x1ff7d3));}catch(_0x35cc3f){_0x5897d4[a10_0x1c95('0x1f')](((_0x5c13fe=_0x35cc3f===null||_0x35cc3f===void 0x0?void 0x0:_0x35cc3f[a10_0x1c95('0x1b')])===null||_0x5c13fe===void 0x0?void 0x0:_0x5c13fe[a10_0x1c95('0x2a')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x35cc3f[a10_0x1c95('0x1b')][a10_0x1c95('0x2a')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);}});}}exports[a10_0x1c95('0x13')]=DistributedExecutionApi;function createStartRequest(_0x123164,_0x58b3ac,_0x19cf94,_0x30bc13,_0x403bec,_0x2cccb9,_0xcb9694){const _0x2757d7=_0x403bec[a10_0x1c95('0x17')](_0x5788be=>{return _0x5788be['map'](_0x5ef9df=>{return{'taskId':_0x5ef9df['id'],'hash':_0x5ef9df[a10_0x1c95('0x9')],'projectName':_0x5ef9df['target']['project'],'target':_0x5ef9df[a10_0x1c95('0xf')][a10_0x1c95('0xf')],'configuration':_0x5ef9df[a10_0x1c95('0xf')][a10_0x1c95('0x2d')]||null,'params':(0x0,serializer_overrides_1['serializeOverrides'])(_0x5ef9df),'projectRoot':_0x5ef9df[a10_0x1c95('0x33')]};});});const _0x150981={'command':(0x0,environment_1[a10_0x1c95('0x8')])(),'branch':_0x123164,'runGroup':_0x58b3ac,'ciExecutionId':_0x19cf94,'ciExecutionEnv':_0x30bc13,'tasks':_0x2757d7,'maxParallel':calculateMaxParallel(_0x2cccb9),'commitSha':_0xcb9694};if(environment_1[a10_0x1c95('0x30')]){_0x150981['agentCount']=environment_1[a10_0x1c95('0x30')];}if(!environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE']){_0x150981[a10_0x1c95('0x2b')]=![];}return _0x150981;}exports[a10_0x1c95('0x1d')]=createStartRequest;function calculateMaxParallel(_0x504b64){if(_0x504b64['parallel']===a10_0x1c95('0x19')||_0x504b64[a10_0x1c95('0x15')]===![]){return 0x1;}else if(_0x504b64[a10_0x1c95('0x15')]===a10_0x1c95('0x2')||_0x504b64[a10_0x1c95('0x15')]===!![]){return Number(_0x504b64[a10_0x1c95('0x2e')]||0x3);}else if(_0x504b64[a10_0x1c95('0x15')]===undefined){return _0x504b64[a10_0x1c95('0x2e')]?Number(_0x504b64['maxParallel']):0x3;}else{return Number(_0x504b64[a10_0x1c95('0x15')])||0x3;}}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createStartRequest = exports.DistributedExecutionApi = void 0;
const axios_1 = require("../../../utilities/axios");
const environment_1 = require("../../../utilities/environment");
const metric_logger_1 = require("../../../utilities/metric-logger");
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
const { output } = require('../../../utilities/nx-imports-light');
class DistributedExecutionApi {
constructor(options) {
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
}
start(params) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
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) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
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) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Completing with an error',
bodyLines: [
`ciExecutionId: ${ciExecutionId}`,
`ciExecutionEnv: ${ciExecutionEnv}`,
`runGroup: ${runGroup}`,
`error: ${error}`,
],
});
}
try {
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
branch,
runGroup,
ciExecutionId,
ciExecutionEnv,
criticalErrorMessage: error,
}), 3);
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
}
catch (e) {
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
}
});
}
}
exports.DistributedExecutionApi = DistributedExecutionApi;
function createStartRequest(branch, runGroup, ciExecutionId, ciExecutionEnv, task, options, commitSha) {
const tasksToExecute = task.map((arr) => {
return arr.map((t) => {
return {
taskId: t.id,
hash: t.hash,
projectName: t.target.project,
target: t.target.target,
configuration: t.target.configuration || null,
params: (0, serializer_overrides_1.serializeOverrides)(t),
projectRoot: t.projectRoot,
};
});
});
const request = {
command: (0, environment_1.parseCommand)(),
branch,
runGroup,
ciExecutionId,
ciExecutionEnv,
tasks: tasksToExecute,
maxParallel: calculateMaxParallel(options),
commitSha,
};
if (environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT) {
request.agentCount = environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT;
}
if (!environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE) {
request.stopAgentsOnFailure = false;
}
return request;
}
exports.createStartRequest = createStartRequest;
function calculateMaxParallel(options) {
if (options.parallel === 'false' || options.parallel === false) {
return 1;
}
else if (options.parallel === 'true' || options.parallel === true) {
return Number(options.maxParallel || 3);
}
else if (options.parallel === undefined) {
return options.maxParallel ? Number(options.maxParallel) : 3;
}
else {
return Number(options.parallel) || 3;
}
}
//# sourceMappingURL=distributed-execution.api.js.map

@@ -1,1 +0,121 @@

const a11_0x2ad5=['commandStatus','splitTasksIntoStages','warn','processTasks','endTasks','./split-task-graph-into-stages','values','SIGINT','../../../utilities/dte-artifact-storage','__esModule','scheduleTask','DTE\x20needs\x20the\x20cache\x20to\x20share\x20files\x20between\x20agents.','lifeCycle','exit','../../../utilities/nx-imports-light','log','start','VERBOSE_LOGGING','getCIExecutionEnv','canDetectRunGroup','../../error/print-run-group-error','runUrl','completeRunGroupWithError','defineProperty','./task-graph-creator','createStartRequest','printRunGroupError','ErrorReporterApi','next','Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','extractGitRef','tasks','done','success','getRunGroup','E2EEncryption','SIGTERM','Unable\x20to\x20complete\x20a\x20run.','Successfully\x20completed\x20running\x20the\x20command.','startTask','Main\x20job\x20was\x20terminated\x20via\x20SIGINT','note','skipNxCache','__awaiter','DistributedExecutionApi','Main\x20job\x20was\x20terminated\x20via\x20SIGTERM','value','taskGraph','See\x20run\x20details\x20at\x20','submitRunMetrics','message','../../../utilities/environment','Starting\x20distributed\x20command\x20execution','--skip-nx-cache\x20is\x20ignored\x20when\x20using\x20distributed\x20tasks\x20execution\x20(DTE).','axiosException','getBranch','../../../utilities/nx-imports','error','../../api/error-reporter.api','createTaskGraphCompat','./distributed-execution.api','projectGraph','extractGitSha','throw','../../../utilities/metric-logger','apply','encryptionKey'];(function(_0x2c148b,_0x2ad56b){const _0x4ffc1e=function(_0x3c988d){while(--_0x3c988d){_0x2c148b['push'](_0x2c148b['shift']());}};_0x4ffc1e(++_0x2ad56b);}(a11_0x2ad5,0x11d));const a11_0x4ffc=function(_0x2c148b,_0x2ad56b){_0x2c148b=_0x2c148b-0x0;let _0x4ffc1e=a11_0x2ad5[_0x2c148b];return _0x4ffc1e;};'use strict';var __awaiter=this&&this[a11_0x4ffc('0x1a')]||function(_0x3e59b1,_0x40caf4,_0x5f3c0b,_0x5b0a94){function _0x597c83(_0x15a49d){return _0x15a49d instanceof _0x5f3c0b?_0x15a49d:new _0x5f3c0b(function(_0x25d4fb){_0x25d4fb(_0x15a49d);});}return new(_0x5f3c0b||(_0x5f3c0b=Promise))(function(_0x343f5a,_0x4885eb){function _0x3113a1(_0x531efe){try{_0xdc4e48(_0x5b0a94[a11_0x4ffc('0xb')](_0x531efe));}catch(_0x339da0){_0x4885eb(_0x339da0);}}function _0x12df3e(_0x33c4b9){try{_0xdc4e48(_0x5b0a94[a11_0x4ffc('0x2e')](_0x33c4b9));}catch(_0x55fda5){_0x4885eb(_0x55fda5);}}function _0xdc4e48(_0x3d50cb){_0x3d50cb[a11_0x4ffc('0xf')]?_0x343f5a(_0x3d50cb[a11_0x4ffc('0x1d')]):_0x597c83(_0x3d50cb['value'])['then'](_0x3113a1,_0x12df3e);}_0xdc4e48((_0x5b0a94=_0x5b0a94[a11_0x4ffc('0x30')](_0x3e59b1,_0x40caf4||[]))['next']());});};Object[a11_0x4ffc('0x6')](exports,a11_0x4ffc('0x3b'),{'value':!![]});exports['nxCloudDistributedTasksRunner']=void 0x0;const dte_artifact_storage_1=require(a11_0x4ffc('0x3a'));const environment_1=require(a11_0x4ffc('0x22'));const metric_logger_1=require(a11_0x4ffc('0x2f'));const error_reporter_api_1=require(a11_0x4ffc('0x29'));const print_run_group_error_1=require(a11_0x4ffc('0x3'));const e2e_encryption_1=require('../../file-storage/e2e-encryption');const file_storage_1=require('../../file-storage/file-storage');const distributed_execution_api_1=require(a11_0x4ffc('0x2b'));const process_tasks_1=require('./process-tasks');const split_task_graph_into_stages_1=require(a11_0x4ffc('0x37'));const task_graph_creator_1=require(a11_0x4ffc('0x7'));const {output}=require(a11_0x4ffc('0x40'));const {cacheDirectory}=require(a11_0x4ffc('0x27'));class NoopLifeCycle{[a11_0x4ffc('0x3c')](_0x22b312){}[a11_0x4ffc('0x16')](_0x331400){}[a11_0x4ffc('0x36')](_0x58467f){}}const nxCloudDistributedTasksRunner=(_0x171f34,_0x45b4b4,_0x7623bd)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(_0x45b4b4[a11_0x4ffc('0x19')]){output[a11_0x4ffc('0x34')]({'title':a11_0x4ffc('0x24'),'bodyLine':[a11_0x4ffc('0x3d')]});}if(environment_1[a11_0x4ffc('0x0')]){output[a11_0x4ffc('0x18')]({'title':a11_0x4ffc('0x23')});}_0x45b4b4[a11_0x4ffc('0x3e')]=new NoopLifeCycle();const _0x195f1c=(0x0,environment_1[a11_0x4ffc('0x26')])();const _0x43e28d=(0x0,environment_1[a11_0x4ffc('0x11')])();const _0x3f90e9=(0x0,environment_1['getCIExecutionId'])();const _0x599f5b=(0x0,environment_1[a11_0x4ffc('0x1')])();const _0x2bd56d=(0x0,environment_1[a11_0x4ffc('0x2d')])();const _0x2f0c34=(0x0,environment_1[a11_0x4ffc('0xd')])();if(!(0x0,print_run_group_error_1[a11_0x4ffc('0x2')])(_0x43e28d,_0x3f90e9)){(0x0,print_run_group_error_1[a11_0x4ffc('0x9')])();process[a11_0x4ffc('0x3f')](0x1);}const _0x3f02b8=new e2e_encryption_1[(a11_0x4ffc('0x12'))](environment_1['ENCRYPTION_KEY']||_0x45b4b4[a11_0x4ffc('0x31')]);const _0x1910ad=new error_reporter_api_1[(a11_0x4ffc('0xa'))](_0x45b4b4);const _0x58fb8f=new dte_artifact_storage_1['DteArtifactStorage'](new file_storage_1['FileStorage'](_0x3f02b8,_0x1910ad,_0x45b4b4,'dte-main'),cacheDirectory);const _0x1ca560=new distributed_execution_api_1[(a11_0x4ffc('0x1b'))](_0x45b4b4);attachSignalListenersToCompleteRunGroupOnError(_0x1ca560,_0x195f1c,_0x43e28d,_0x3f90e9,_0x599f5b);try{const _0x4abf94=getTaskGraph(_0x7623bd,_0x171f34,_0x45b4b4);const _0x54cf88=yield runDistributedExecution(_0x1ca560,_0x45b4b4,_0x58fb8f,_0x195f1c,_0x43e28d,_0x3f90e9,_0x599f5b,_0x4abf94,_0x2bd56d,_0x2f0c34);if(_0x54cf88[a11_0x4ffc('0x32')]===0x0){output[a11_0x4ffc('0x10')]({'title':a11_0x4ffc('0x15'),'bodyLines':[a11_0x4ffc('0x1f')+_0x54cf88[a11_0x4ffc('0x4')]]});}else{output[a11_0x4ffc('0x28')]({'title':'Command\x20execution\x20failed.','bodyLines':[a11_0x4ffc('0x1f')+_0x54cf88['runUrl']]});}yield(0x0,metric_logger_1[a11_0x4ffc('0x20')])(_0x45b4b4);process[a11_0x4ffc('0x3f')](_0x54cf88['commandStatus']);}catch(_0x3d49ae){output['error']({'title':a11_0x4ffc('0x14'),'bodyLines':[_0x3d49ae[a11_0x4ffc('0x21')]]});if(_0x3d49ae[a11_0x4ffc('0x25')]){console[a11_0x4ffc('0x41')](_0x3d49ae['axiosException']);}else{console[a11_0x4ffc('0x41')](_0x3d49ae);}try{yield _0x1ca560[a11_0x4ffc('0x5')](_0x195f1c,_0x43e28d,_0x3f90e9,_0x599f5b,a11_0x4ffc('0xc')+_0x3d49ae[a11_0x4ffc('0x21')]+'\x22');}finally{process[a11_0x4ffc('0x3f')](0x1);}}});exports['nxCloudDistributedTasksRunner']=nxCloudDistributedTasksRunner;function getTaskGraph(_0x229916,_0x442c51,_0x517a26){if(_0x229916['taskGraph']){return _0x229916[a11_0x4ffc('0x1e')];}else{return(0x0,task_graph_creator_1[a11_0x4ffc('0x2a')])(_0x517a26,_0x229916[a11_0x4ffc('0x2c')],_0x442c51);}}function attachSignalListenersToCompleteRunGroupOnError(_0x449632,_0x59519a,_0x35e713,_0x4ffa56,_0x24e1a9){process['on'](a11_0x4ffc('0x39'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x449632[a11_0x4ffc('0x5')](_0x59519a,_0x35e713,_0x4ffa56,_0x24e1a9,a11_0x4ffc('0x17'));process['exit'](0x1);}));process['on'](a11_0x4ffc('0x13'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x449632[a11_0x4ffc('0x5')](_0x59519a,_0x35e713,_0x4ffa56,_0x24e1a9,a11_0x4ffc('0x1c'));process[a11_0x4ffc('0x3f')](0x1);}));}function runDistributedExecution(_0x5adcfa,_0x2594dd,_0x2c0800,_0x1c0c93,_0x20caeb,_0x553c9b,_0x5a1bae,_0x112d48,_0x1fe7b1,_0x129ad8){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x34eb7f=yield _0x5adcfa[a11_0x4ffc('0x42')]((0x0,distributed_execution_api_1[a11_0x4ffc('0x8')])(_0x1c0c93,_0x20caeb,_0x553c9b,_0x5a1bae,(0x0,split_task_graph_into_stages_1[a11_0x4ffc('0x33')])(_0x112d48),_0x2594dd,_0x1fe7b1));return yield(0x0,process_tasks_1[a11_0x4ffc('0x35')])(_0x5adcfa,_0x2c0800,_0x34eb7f,Object[a11_0x4ffc('0x38')](_0x112d48[a11_0x4ffc('0xe')]));});}
"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 dte_artifact_storage_1 = require("../../../utilities/dte-artifact-storage");
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 process_tasks_1 = require("./process-tasks");
const split_task_graph_into_stages_1 = require("./split-task-graph-into-stages");
const task_graph_creator_1 = require("./task-graph-creator");
const { output } = require('../../../utilities/nx-imports-light');
const { cacheDirectory } = require('../../../utilities/nx-imports');
class NoopLifeCycle {
scheduleTask(task) { }
startTask(task) { }
endTasks(tasks) { }
}
const nxCloudDistributedTasksRunner = (tasks, options, context) => __awaiter(void 0, void 0, void 0, function* () {
if (options.skipNxCache) {
output.warn({
title: `--skip-nx-cache is ignored when using distributed tasks execution (DTE).`,
bodyLine: [`DTE needs the cache to share files between agents.`],
});
}
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Starting distributed command execution',
});
}
options.lifeCycle = new NoopLifeCycle();
const branch = (0, environment_1.getBranch)();
const runGroup = (0, environment_1.getRunGroup)();
const ciExecutionId = (0, environment_1.getCIExecutionId)();
const ciExecutionEnv = (0, environment_1.getCIExecutionEnv)();
const commitSha = (0, environment_1.extractGitSha)();
const commitRef = (0, environment_1.extractGitRef)();
if (!(0, print_run_group_error_1.canDetectRunGroup)(runGroup, ciExecutionId)) {
(0, print_run_group_error_1.printRunGroupError)();
process.exit(1);
}
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
const errorReporter = new error_reporter_api_1.ErrorReporterApi(options);
const dteArtifactStorage = new dte_artifact_storage_1.DteArtifactStorage(new file_storage_1.FileStorage(encryption, errorReporter, options, 'dte-main'), cacheDirectory);
const api = new distributed_execution_api_1.DistributedExecutionApi(options);
attachSignalListenersToCompleteRunGroupOnError(api, branch, runGroup, ciExecutionId, ciExecutionEnv);
try {
const taskGraph = getTaskGraph(context, tasks, options);
const r = yield runDistributedExecution(api, options, dteArtifactStorage, branch, runGroup, ciExecutionId, ciExecutionEnv, taskGraph, commitSha, commitRef);
if (r.commandStatus === 0) {
output.success({
title: 'Successfully completed running the command.',
bodyLines: [`See run details at ${r.runUrl}`],
});
}
else {
output.error({
title: 'Command execution failed.',
bodyLines: [`See run details at ${r.runUrl}`],
});
}
yield (0, metric_logger_1.submitRunMetrics)(options);
process.exit(r.commandStatus);
}
catch (e) {
output.error({
title: 'Unable to complete a run.',
bodyLines: [e.message],
});
if (e.axiosException) {
console.log(e.axiosException);
}
else {
console.log(e);
}
try {
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, `Main job terminated with an error: "${e.message}"`);
}
finally {
process.exit(1);
}
}
});
exports.nxCloudDistributedTasksRunner = nxCloudDistributedTasksRunner;
function getTaskGraph(context, tasks, options) {
if (context.taskGraph) {
return context.taskGraph;
}
else {
return (0, task_graph_creator_1.createTaskGraphCompat)(options, context.projectGraph, tasks);
}
}
function attachSignalListenersToCompleteRunGroupOnError(api, branch, runGroup, ciExecutionId, ciExecutionEnv) {
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, 'Main job was terminated via SIGINT');
process.exit(1);
}));
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
yield api.completeRunGroupWithError(branch, runGroup, ciExecutionId, ciExecutionEnv, 'Main job was terminated via SIGTERM');
process.exit(1);
}));
}
function runDistributedExecution(api, options, dteArtifactStorage, branch, runGroup, ciExecutionId, ciExecutionEnv, taskGraph, commitSha, commitRef) {
return __awaiter(this, void 0, void 0, function* () {
const id = yield api.start((0, distributed_execution_api_1.createStartRequest)(branch, runGroup, ciExecutionId, ciExecutionEnv, (0, split_task_graph_into_stages_1.splitTasksIntoStages)(taskGraph), options, commitSha));
return yield (0, process_tasks_1.processTasks)(api, dteArtifactStorage, id, Object.values(taskGraph.tasks));
});
}
//# sourceMappingURL=distributed-execution.runner.js.map

@@ -1,1 +0,45 @@

const a12_0x1fcb=['defineProperty','run','then','note','value','processTask','Found\x20unknown\x20task:\x20','../../../utilities/environment','serializeOverrides','stdout','next','__awaiter','url','project','apply','find','../../../utilities/nx-imports-light','configuration','logCommand','target','done','__esModule','write','taskId','retrieveAndExtract','addVerticalSeparator','join'];(function(_0x326bc8,_0x1fcb2a){const _0x36f34c=function(_0x1339f8){while(--_0x1339f8){_0x326bc8['push'](_0x326bc8['shift']());}};_0x36f34c(++_0x1fcb2a);}(a12_0x1fcb,0x137));const a12_0x36f3=function(_0x326bc8,_0x1fcb2a){_0x326bc8=_0x326bc8-0x0;let _0x36f34c=a12_0x1fcb[_0x326bc8];return _0x36f34c;};'use strict';var __awaiter=this&&this[a12_0x36f3('0x18')]||function(_0xabc9,_0x143180,_0x3c8f19,_0x3b0009){function _0x4d63ec(_0x569cd1){return _0x569cd1 instanceof _0x3c8f19?_0x569cd1:new _0x3c8f19(function(_0x2d3a17){_0x2d3a17(_0x569cd1);});}return new(_0x3c8f19||(_0x3c8f19=Promise))(function(_0x3712a1,_0x2e67c7){function _0x42f4f0(_0x24c063){try{_0x4eadbd(_0x3b0009['next'](_0x24c063));}catch(_0x2670d2){_0x2e67c7(_0x2670d2);}}function _0x23f566(_0x5e2d30){try{_0x4eadbd(_0x3b0009['throw'](_0x5e2d30));}catch(_0x1683d6){_0x2e67c7(_0x1683d6);}}function _0x4eadbd(_0x573101){_0x573101[a12_0x36f3('0x6')]?_0x3712a1(_0x573101[a12_0x36f3('0x11')]):_0x4d63ec(_0x573101[a12_0x36f3('0x11')])[a12_0x36f3('0xf')](_0x42f4f0,_0x23f566);}_0x4eadbd((_0x3b0009=_0x3b0009[a12_0x36f3('0x0')](_0xabc9,_0x143180||[]))[a12_0x36f3('0x17')]());});};Object[a12_0x36f3('0xd')](exports,a12_0x36f3('0x7'),{'value':!![]});exports[a12_0x36f3('0x12')]=void 0x0;const environment_1=require(a12_0x36f3('0x14'));const serializer_overrides_1=require('../../../utilities/serializer-overrides');const {output}=require(a12_0x36f3('0x2'));function processTask(_0x374efe,_0x1c8b04,_0x5e4164){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1['VERBOSE_LOGGING']){output[a12_0x36f3('0x10')]({'title':'Processing\x20task\x20'+_0x5e4164[a12_0x36f3('0x9')]});}const _0x4d6acd=_0x1c8b04[a12_0x36f3('0x1')](_0x42d073=>_0x5e4164[a12_0x36f3('0x9')]===_0x42d073['id']);if(!_0x4d6acd){throw new Error(a12_0x36f3('0x13')+_0x5e4164[a12_0x36f3('0x9')]);}const _0x223097=yield _0x374efe[a12_0x36f3('0xa')](_0x5e4164['hash'],_0x5e4164[a12_0x36f3('0x19')]);output[a12_0x36f3('0x4')](getCommand(_0x4d6acd));process[a12_0x36f3('0x16')][a12_0x36f3('0x8')](_0x223097);output[a12_0x36f3('0xb')]();});}exports[a12_0x36f3('0x12')]=processTask;function getCommand(_0x54d289){const _0x211736=_0x54d289['target'][a12_0x36f3('0x3')]?':'+_0x54d289[a12_0x36f3('0x5')][a12_0x36f3('0x3')]:'';return['nx',a12_0x36f3('0xe'),_0x54d289[a12_0x36f3('0x5')][a12_0x36f3('0x1a')]+':'+_0x54d289[a12_0x36f3('0x5')]['target']+_0x211736,(0x0,serializer_overrides_1[a12_0x36f3('0x15')])(_0x54d289)][a12_0x36f3('0xc')]('\x20');}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.processTask = void 0;
const environment_1 = require("../../../utilities/environment");
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
const { output } = require('../../../utilities/nx-imports-light');
function processTask(dteArtifactStorage, tasks, completedTask) {
return __awaiter(this, void 0, void 0, function* () {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Processing task ${completedTask.taskId}`,
});
}
const matchingTask = tasks.find((tt) => completedTask.taskId === tt.id);
if (!matchingTask) {
throw new Error(`Found unknown task: ${completedTask.taskId}`);
}
const terminalOutput = yield dteArtifactStorage.retrieveAndExtract(completedTask.hash, completedTask.url);
output.logCommand(getCommand(matchingTask));
process.stdout.write(terminalOutput);
output.addVerticalSeparator();
});
}
exports.processTask = processTask;
function getCommand(task) {
const config = task.target.configuration
? `:${task.target.configuration}`
: '';
return [
'nx',
'run',
`${task.target.project}:${task.target.target}${config}`,
(0, serializer_overrides_1.serializeOverrides)(task),
].join(' ');
}
//# sourceMappingURL=process-task.js.map

@@ -1,1 +0,67 @@

const a13_0x5945=['executionId:\x20','reset','number\x20of\x20completed\x20tasks:\x20','COMPLETED','__awaiter','then','../../../utilities/waiter','../../../utilities/environment','error:\x20','taskId','Waiter','NO_COMPLETED_TASKS_TIMEOUT','value','executionStatus:\x20','criticalErrorMessage','processTask','apply','createUnchangedValueTimeout','error','../../../utilities/create-unchanged-value-timeout','note','Waiting...','Status\x20update','completedTasks','No\x20new\x20completed\x20tasks\x20after\x20','\x20seconds.','../../../utilities/nx-imports-light','executionStatus','commandStatus','processTasks','Distributed\x20Execution\x20Terminated','VERBOSE_LOGGING','__esModule'];(function(_0x351fd8,_0x594581){const _0x284a29=function(_0x30a77f){while(--_0x30a77f){_0x351fd8['push'](_0x351fd8['shift']());}};_0x284a29(++_0x594581);}(a13_0x5945,0x143));const a13_0x284a=function(_0x351fd8,_0x594581){_0x351fd8=_0x351fd8-0x0;let _0x284a29=a13_0x5945[_0x351fd8];return _0x284a29;};'use strict';var __awaiter=this&&this[a13_0x284a('0xb')]||function(_0x221877,_0x4121ed,_0x3a93d4,_0x36d35d){function _0x29a28e(_0x475134){return _0x475134 instanceof _0x3a93d4?_0x475134:new _0x3a93d4(function(_0x3b56bb){_0x3b56bb(_0x475134);});}return new(_0x3a93d4||(_0x3a93d4=Promise))(function(_0x52e9b6,_0x148d39){function _0x2702f6(_0x4eb292){try{_0x5d06ad(_0x36d35d['next'](_0x4eb292));}catch(_0x3ff0de){_0x148d39(_0x3ff0de);}}function _0x370418(_0x1df558){try{_0x5d06ad(_0x36d35d['throw'](_0x1df558));}catch(_0x325aec){_0x148d39(_0x325aec);}}function _0x5d06ad(_0x19ac45){_0x19ac45['done']?_0x52e9b6(_0x19ac45[a13_0x284a('0x13')]):_0x29a28e(_0x19ac45[a13_0x284a('0x13')])[a13_0x284a('0xc')](_0x2702f6,_0x370418);}_0x5d06ad((_0x36d35d=_0x36d35d[a13_0x284a('0x17')](_0x221877,_0x4121ed||[]))['next']());});};Object['defineProperty'](exports,a13_0x284a('0x6'),{'value':!![]});exports[a13_0x284a('0x3')]=void 0x0;const create_unchanged_value_timeout_1=require(a13_0x284a('0x1a'));const environment_1=require(a13_0x284a('0xe'));const waiter_1=require(a13_0x284a('0xd'));const process_task_1=require('./process-task');const {output}=require(a13_0x284a('0x0'));function processTasks(_0x1d70a3,_0x5b71ba,_0x394deb,_0x2e764f){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x36a45e={};const _0x145c38=(0x0,create_unchanged_value_timeout_1[a13_0x284a('0x18')])({'title':a13_0x284a('0x1f')+environment_1[a13_0x284a('0x12')]/0x3e8+a13_0x284a('0x20'),'timeout':environment_1[a13_0x284a('0x12')]});const _0x1ad890=new waiter_1[(a13_0x284a('0x11'))]();while(!![]){if(environment_1[a13_0x284a('0x5')]){output['note']({'title':a13_0x284a('0x1c')});}yield _0x1ad890['wait']();const _0xc59fee=yield _0x1d70a3['status'](_0x394deb);if(environment_1[a13_0x284a('0x5')]){output[a13_0x284a('0x1b')]({'title':a13_0x284a('0x1d'),'bodyLines':[a13_0x284a('0x7')+_0x394deb,a13_0x284a('0x14')+_0xc59fee['executionStatus'],a13_0x284a('0x9')+_0xc59fee[a13_0x284a('0x1e')]['length'],a13_0x284a('0xf')+_0xc59fee['criticalErrorMessage']]});}if(_0xc59fee[a13_0x284a('0x15')]){output[a13_0x284a('0x19')]({'title':a13_0x284a('0x4'),'bodyLines':['Error:',_0xc59fee[a13_0x284a('0x15')]]});process['exit'](0x1);}_0x145c38(_0xc59fee[a13_0x284a('0x1e')]['length']);for(const _0x4ee232 of _0xc59fee[a13_0x284a('0x1e')]){if(_0x36a45e[_0x4ee232[a13_0x284a('0x10')]])continue;yield(0x0,process_task_1[a13_0x284a('0x16')])(_0x5b71ba,_0x2e764f,_0x4ee232);_0x1ad890[a13_0x284a('0x8')]();_0x36a45e[_0x4ee232[a13_0x284a('0x10')]]=!![];}if(_0xc59fee[a13_0x284a('0x1')]===a13_0x284a('0xa')){return{'commandStatus':_0xc59fee[a13_0x284a('0x2')],'runUrl':_0xc59fee['runUrl']};}}});}exports[a13_0x284a('0x3')]=processTasks;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.processTasks = void 0;
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
const environment_1 = require("../../../utilities/environment");
const waiter_1 = require("../../../utilities/waiter");
const process_task_1 = require("./process-task");
const { output } = require('../../../utilities/nx-imports-light');
function processTasks(api, dteArtifactStorage, executionId, tasks) {
return __awaiter(this, void 0, void 0, function* () {
const processedTasks = {};
const failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
title: `No new completed tasks after ${environment_1.NO_COMPLETED_TASKS_TIMEOUT / 1000} seconds.`,
timeout: environment_1.NO_COMPLETED_TASKS_TIMEOUT,
});
const waiter = new waiter_1.Waiter();
while (true) {
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: 'Waiting...',
});
}
yield waiter.wait();
const r = yield api.status(executionId);
if (environment_1.VERBOSE_LOGGING) {
output.note({
title: `Status update`,
bodyLines: [
`executionId: ${executionId}`,
`executionStatus: ${r.executionStatus}`,
`number of completed tasks: ${r.completedTasks.length}`,
`error: ${r.criticalErrorMessage}`,
],
});
}
if (r.criticalErrorMessage) {
output.error({
title: 'Distributed Execution Terminated',
bodyLines: ['Error:', r.criticalErrorMessage],
});
process.exit(1);
}
failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout(r.completedTasks.length);
for (const t of r.completedTasks) {
if (processedTasks[t.taskId])
continue;
yield (0, process_task_1.processTask)(dteArtifactStorage, tasks, t);
waiter.reset();
processedTasks[t.taskId] = true;
}
if (r.executionStatus === 'COMPLETED') {
return { commandStatus: r.commandStatus, runUrl: r.runUrl };
}
}
});
}
exports.processTasks = processTasks;
//# sourceMappingURL=process-tasks.js.map

@@ -1,1 +0,37 @@

const a14_0x6592=['tasks','defineProperty','__esModule','splitTasksIntoStages','size','dependencies'];(function(_0x153315,_0x659250){const _0x4a59ce=function(_0x2259f4){while(--_0x2259f4){_0x153315['push'](_0x153315['shift']());}};_0x4a59ce(++_0x659250);}(a14_0x6592,0xbd));const a14_0x4a59=function(_0x153315,_0x659250){_0x153315=_0x153315-0x0;let _0x4a59ce=a14_0x6592[_0x153315];return _0x4a59ce;};'use strict';Object[a14_0x4a59('0x4')](exports,a14_0x4a59('0x5'),{'value':!![]});exports['splitTasksIntoStages']=void 0x0;function splitTasksIntoStages(_0x242a8d){const _0x10d82b=[];const _0x3707b4=new Set(Object['values'](_0x242a8d[a14_0x4a59('0x3')])['map'](_0x5111d4=>_0x5111d4['id']));let _0x5eaad9=0x0;while(_0x3707b4[a14_0x4a59('0x1')]>0x0){const _0x4f5948=_0x10d82b[_0x5eaad9]=[];for(const _0x212b90 of _0x3707b4){let _0x146048=!![];for(const _0x2cd80b of _0x242a8d[a14_0x4a59('0x2')][_0x212b90]){if(_0x3707b4['has'](_0x2cd80b)){_0x146048=![];break;}}if(!_0x146048){continue;}const _0x39a63d=_0x242a8d['tasks'][_0x212b90];_0x4f5948['push'](_0x39a63d);}for(const _0x21c3b2 of _0x4f5948){_0x3707b4['delete'](_0x21c3b2['id']);}_0x5eaad9++;}return _0x10d82b;}exports[a14_0x4a59('0x0')]=splitTasksIntoStages;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.splitTasksIntoStages = void 0;
function splitTasksIntoStages(taskGraph) {
const stages = [];
const notStagedTaskIds = new Set(Object.values(taskGraph.tasks).map((t) => t.id));
let stageIndex = 0;
// Loop through tasks and try to stage them. As tasks are staged, they are removed from the loop
while (notStagedTaskIds.size > 0) {
const currentStage = (stages[stageIndex] = []);
for (const taskId of notStagedTaskIds) {
let ready = true;
for (const dependency of taskGraph.dependencies[taskId]) {
if (notStagedTaskIds.has(dependency)) {
// dependency has not been staged yet, this task is not ready to be staged.
ready = false;
break;
}
}
// Some dependency still has not been staged, skip it for now, it will be processed again
if (!ready) {
continue;
}
// All the dependencies have been staged, let's stage it.
const task = taskGraph.tasks[taskId];
currentStage.push(task);
}
// Remove the entire new stage of tasks from the list
for (const task of currentStage) {
notStagedTaskIds.delete(task.id);
}
stageIndex++;
}
return stages;
}
exports.splitTasksIntoStages = splitTasksIntoStages;
//# sourceMappingURL=split-task-graph-into-stages.js.map

@@ -1,1 +0,121 @@

const a15_0x4c1c=['self','build','find','addTaskToGraph','TaskGraphCreator','length','../../../utilities/nx-imports','dependencies','strictlyOrderedTargets','createTaskGraphCompat','projects','/nx.json','__esModule','addTaskDependencies','tasks','strip-json-comments','addDependencies','readFileSync','push','defaultTargetDependencies','project','roots','add','target','keys','../../../utilities/nx-imports-light','targetDependencies','defineProperty','filter','createTaskGraph','has','findTask','parse'];(function(_0x5b8cc4,_0x4c1c59){const _0x5f464c=function(_0x25de1f){while(--_0x25de1f){_0x5b8cc4['push'](_0x5b8cc4['shift']());}};_0x5f464c(++_0x4c1c59);}(a15_0x4c1c,0x1e4));const a15_0x5f46=function(_0x5b8cc4,_0x4c1c59){_0x5b8cc4=_0x5b8cc4-0x0;let _0x5f464c=a15_0x4c1c[_0x5b8cc4];return _0x5f464c;};'use strict';Object[a15_0x5f46('0x5')](exports,a15_0x5f46('0x17'),{'value':!![]});exports[a15_0x5f46('0xf')]=exports[a15_0x5f46('0x14')]=void 0x0;const fs_1=require('fs');const stripJsonComments=require(a15_0x5f46('0x1a'));const {workspaceRoot}=require(a15_0x5f46('0x3'));const {getDependencyConfigs}=require(a15_0x5f46('0x11'));function createTaskGraphCompat(_0x1035c8,_0x480de4,_0xd5a75a){const _0x2fb907=JSON[a15_0x5f46('0xa')](stripJsonComments((0x0,fs_1[a15_0x5f46('0x1c')])(workspaceRoot+a15_0x5f46('0x16'))['toString']()));return new TaskGraphCreator(_0x480de4,getDefaultDependencyConfigs(_0x2fb907,_0x1035c8))['createTaskGraph'](_0xd5a75a);}exports[a15_0x5f46('0x14')]=createTaskGraphCompat;function getDefaultDependencyConfigs(_0x3285b2,_0x56be4e){var _0x204f62,_0x2b25cb;const _0x318ab1=(_0x204f62=_0x3285b2[a15_0x5f46('0x4')])!==null&&_0x204f62!==void 0x0?_0x204f62:{};const _0x5c2403=_0x56be4e?(_0x2b25cb=_0x56be4e[a15_0x5f46('0x13')])!==null&&_0x2b25cb!==void 0x0?_0x2b25cb:[a15_0x5f46('0xc')]:[];for(const _0x31937e of _0x5c2403){_0x318ab1[_0x31937e]=_0x318ab1[_0x31937e]||[];_0x318ab1[_0x31937e][a15_0x5f46('0x1d')]({'target':_0x31937e,'projects':a15_0x5f46('0x12')});}return _0x318ab1;}class TaskGraphCreator{constructor(_0x13ab94,_0xf9ec7f){this['projectGraph']=_0x13ab94;this[a15_0x5f46('0x1e')]=_0xf9ec7f;}[a15_0x5f46('0x7')](_0x345bf2){const _0x456b07={'roots':[],'tasks':{},'dependencies':{}};for(const _0x567118 of _0x345bf2){this[a15_0x5f46('0xe')](_0x567118,_0x456b07);const _0x1be59c=getDependencyConfigs(_0x567118[a15_0x5f46('0x1')],this[a15_0x5f46('0x1e')],this['projectGraph']);if(!_0x1be59c){continue;}this[a15_0x5f46('0x18')](_0x567118,_0x1be59c,_0x345bf2,_0x456b07);}_0x456b07[a15_0x5f46('0x20')]=Object[a15_0x5f46('0x2')](_0x456b07[a15_0x5f46('0x12')])[a15_0x5f46('0x6')](_0x221fce=>_0x456b07[a15_0x5f46('0x12')][_0x221fce][a15_0x5f46('0x10')]===0x0);return _0x456b07;}[a15_0x5f46('0x18')](_0xe824a3,_0x4ef55e,_0x4464c9,_0x3fe368){for(const _0x2711f7 of _0x4ef55e){if(_0x2711f7[a15_0x5f46('0x15')]===a15_0x5f46('0xb')){for(const _0x9f0d46 of _0x4464c9){if(_0x9f0d46[a15_0x5f46('0x1')][a15_0x5f46('0x1f')]===_0xe824a3['target']['project']&&_0x9f0d46[a15_0x5f46('0x1')][a15_0x5f46('0x1')]===_0x2711f7[a15_0x5f46('0x1')]){_0x3fe368[a15_0x5f46('0x12')][_0xe824a3['id']]['push'](_0x9f0d46['id']);}}}else if(_0x2711f7[a15_0x5f46('0x15')]===a15_0x5f46('0x12')){const _0x23d567=new Set();this['addDependencies'](_0xe824a3[a15_0x5f46('0x1')][a15_0x5f46('0x1f')],_0x2711f7[a15_0x5f46('0x1')],_0x4464c9,_0x3fe368,_0xe824a3['id'],_0x23d567);}}}[a15_0x5f46('0x1b')](_0x43ab61,_0xc48a77,_0x178f64,_0x2413f2,_0x1e0bb2,_0x4454c5){_0x4454c5[a15_0x5f46('0x0')](_0x43ab61);const _0x11cf92=this['projectGraph'][a15_0x5f46('0x12')][_0x43ab61];if(_0x11cf92){const _0x4eb722=_0x11cf92['map'](_0x153a22=>_0x153a22[a15_0x5f46('0x1')]);for(const _0x157abd of _0x4eb722){if(_0x4454c5[a15_0x5f46('0x8')](_0x157abd)){continue;}const _0x132b9a=this[a15_0x5f46('0x9')]({'project':_0x157abd,'target':_0xc48a77},_0x178f64);if(_0x132b9a){if(_0x2413f2[a15_0x5f46('0x12')][_0x1e0bb2]['indexOf'](_0x132b9a['id'])===-0x1){_0x2413f2[a15_0x5f46('0x12')][_0x1e0bb2][a15_0x5f46('0x1d')](_0x132b9a['id']);}}else{this[a15_0x5f46('0x1b')](_0x157abd,_0xc48a77,_0x178f64,_0x2413f2,_0x1e0bb2,_0x4454c5);}}}}[a15_0x5f46('0x9')]({project,target},_0x205c74){return _0x205c74[a15_0x5f46('0xd')](_0x4f790e=>_0x4f790e[a15_0x5f46('0x1')]['project']===project&&_0x4f790e[a15_0x5f46('0x1')][a15_0x5f46('0x1')]===target);}[a15_0x5f46('0xe')](_0x194d2d,_0x4b19ae){_0x4b19ae[a15_0x5f46('0x19')][_0x194d2d['id']]=_0x194d2d;_0x4b19ae['dependencies'][_0x194d2d['id']]=[];}}exports['TaskGraphCreator']=TaskGraphCreator;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskGraphCreator = exports.createTaskGraphCompat = void 0;
const fs_1 = require("fs");
const { workspaceRoot } = require('../../../utilities/nx-imports-light');
const { getDependencyConfigs } = require('../../../utilities/nx-imports');
// This package is ESM and needs to be imported using an async import
// IF YOU CHANGE THIS, THE PACKAGE WILL FAIL TO LOAD AT RUNTIME
// YOU WILL NOT CATCH IT IN CI
const dynamicImport = new Function('specifier', 'return import(specifier)');
let stripJsonComments;
(function () {
return __awaiter(this, void 0, void 0, function* () {
stripJsonComments = (yield dynamicImport('strip-json-comments')).default;
});
})();
function createTaskGraphCompat(options, projectGraph, tasks) {
const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString(), {
trailingCommas: true,
}));
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

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

const axios_1 = require("../utilities/axios");
const waiter_1 = require("../utilities/waiter");
const debug_logger_1 = require("./debug-logger");

@@ -22,43 +23,56 @@ function verifyOrUpdateCloudBundle(options) {

const runnerBundleInstallDirectory = getRunnerBundleInstallDirectory(options);
const currentBundle = getLatestInstalledRunnerBundle(runnerBundleInstallDirectory);
if (shouldVerifyInstalledRunnerBundle(runnerBundleInstallDirectory, currentBundle)) {
const axios = (0, axios_1.createApiAxiosInstance)(options);
let verifyBundleResponse;
try {
verifyBundleResponse = yield verifyCurrentBundle(axios, currentBundle);
}
catch (e) {
// Enterprise image compatibility, to be removed
if (e.message === 'Request failed with status code 404' && options.url) {
console.warn('[WARNING] Nx Cloud was unable to fetch or verify its bundle from the instance hosted at: ', options.url);
console.warn('[WARNING] Nx Cloud will continue to function as expected, but your installation should be updated');
console.warn('[WARNING] soon for the best experience.');
console.warn('[WARNING] ');
console.warn('[WARNING] If you are an Nx Enterprise customer, please reach out to your assigned Developer Productivity Engineer.');
console.warn('[WARNING] ');
console.warn('[WARNING] If you are NOT an Nx Enterprise customer but are seeing this message, please reach out to cloud-support@nrwl.io.');
console.warn('[WARNING] ');
console.warn('[WARNING] To prevent this check on startup, set `useLightClient: false` in your task runner options found in `nx.json`.');
return {
version: 'NX_ENTERPRISE_OUTDATED_IMAGE',
fullPath: '',
};
let currentBundle;
for (let attempt = 0; attempt < 10; attempt++) {
currentBundle = getLatestInstalledRunnerBundle(runnerBundleInstallDirectory);
if (shouldVerifyInstalledRunnerBundle(runnerBundleInstallDirectory, currentBundle)) {
const axios = (0, axios_1.createApiAxiosInstance)(options);
let verifyBundleResponse;
try {
verifyBundleResponse = yield verifyCurrentBundle(axios, currentBundle);
}
(0, debug_logger_1.debugLog)('Could not verify bundle. Resetting validation timer and using previously installed or default runner. Error: ', e);
writeBundleVerificationLock(runnerBundleInstallDirectory);
return currentBundle;
catch (e) {
// Enterprise image compatibility, to be removed
if (e.message === 'Request failed with status code 404' &&
options.url) {
console.warn('[WARNING] Nx Cloud was unable to fetch or verify its bundle from the instance hosted at: ', options.url);
console.warn('[WARNING] Nx Cloud will continue to function as expected, but your installation should be updated');
console.warn('[WARNING] soon for the best experience.');
console.warn('[WARNING] ');
console.warn('[WARNING] If you are an Nx Enterprise customer, please reach out to your assigned Developer Productivity Engineer.');
console.warn('[WARNING] ');
console.warn('[WARNING] If you are NOT an Nx Enterprise customer but are seeing this message, please reach out to cloud-support@nrwl.io.');
console.warn('[WARNING] ');
console.warn('[WARNING] To prevent this check on startup, set `useLightClient: false` in your task runner options found in `nx.json`.');
return {
version: 'NX_ENTERPRISE_OUTDATED_IMAGE',
fullPath: '',
};
}
(0, debug_logger_1.debugLog)('Could not verify bundle. Resetting validation timer and using previously installed or default runner. Error: ', e);
writeBundleVerificationLock(runnerBundleInstallDirectory);
return currentBundle;
}
if (verifyBundleResponse.data.valid) {
(0, debug_logger_1.debugLog)('Currently installed bundle is valid');
writeBundleVerificationLock(runnerBundleInstallDirectory);
return currentBundle;
}
const { version, url } = verifyBundleResponse.data;
const lockAcquired = yield acquireBundleExtractionLock(runnerBundleInstallDirectory);
if (!lockAcquired) {
(0, debug_logger_1.debugLog)('Could not acquire bundle extraction lock, retrying:', process.env.NX_CLOUD_FORCE_REVALIDATE);
yield (0, waiter_1.wait)(1000);
continue;
}
(0, debug_logger_1.debugLog)('Currently installed bundle is invalid, downloading version', version, ' from ', url);
return {
version,
fullPath: yield downloadAndExtractClientBundle(axios, runnerBundleInstallDirectory, version, url),
};
}
if (verifyBundleResponse.data.valid) {
(0, debug_logger_1.debugLog)('Currently installed bundle is valid');
writeBundleVerificationLock(runnerBundleInstallDirectory);
return currentBundle;
else {
break;
}
const { version, url } = verifyBundleResponse.data;
(0, debug_logger_1.debugLog)('Currently installed bundle is invalid, downloading version', version, ' from ', url);
return {
version,
fullPath: yield downloadAndExtractClientBundle(axios, runnerBundleInstallDirectory, version, url),
};
}
return currentBundle;
return getLatestInstalledRunnerBundle(runnerBundleInstallDirectory);
});

@@ -97,3 +111,3 @@ }

.filter((potentialDirectory) => {
return (0, fs_1.statSync)((0, path_1.join)(runnerBundleInstallDirectory, potentialDirectory)).isDirectory();
return ((0, fs_1.statSync)((0, path_1.join)(runnerBundleInstallDirectory, potentialDirectory)).isDirectory() && potentialDirectory != 'extract.lock');
})

@@ -217,2 +231,3 @@ .map((fileOrDirectory) => ({

writeBundleVerificationLock(runnerBundleInstallDirectory);
removeExtractionLock(runnerBundleInstallDirectory);
res(bundleExtractLocation);

@@ -232,2 +247,22 @@ });

}
function acquireBundleExtractionLock(runnerBundleInstallDirectory) {
return __awaiter(this, void 0, void 0, function* () {
const lockFilePath = (0, path_1.join)(runnerBundleInstallDirectory, 'extract.lock');
try {
(0, fs_1.mkdirSync)(lockFilePath);
return true;
}
catch (e) {
return false;
}
});
}
function removeExtractionLock(runnerBundleInstallDirectory) {
try {
(0, fs_1.rmSync)((0, path_1.join)(runnerBundleInstallDirectory, 'extract.lock'), {
recursive: true,
});
}
catch (_a) { }
}
//# sourceMappingURL=update-manager.js.map
"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.getCloudOptions = void 0;
const fs_1 = require("fs");
const stripJsonComments = require("strip-json-comments");
const { workspaceRoot } = require('./nx-imports-light');
// This package is ESM and needs to be imported using an async import
// IF YOU CHANGE THIS, THE PACKAGE WILL FAIL TO LOAD AT RUNTIME
// YOU WILL NOT CATCH IT IN CI
const dynamicImport = new Function('specifier', 'return import(specifier)');
let stripJsonComments;
(function () {
return __awaiter(this, void 0, void 0, function* () {
stripJsonComments = (yield dynamicImport('strip-json-comments')).default;
});
})();
function getCloudOptions(taskRunnerConfiguration) {
var _a, _b, _c, _d, _e, _f, _g;
const nxJson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString()));
var _a, _b, _c, _d, _e, _f, _g, _h;
const nxJson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString(), {
trailingCommas: true,
}));
const result = {};

@@ -20,4 +40,7 @@ const defaultCacheableOperations = [];

}
if (nxJson.nxCloudId) {
(_b = result.nxCloudId) !== null && _b !== void 0 ? _b : (result.nxCloudId = nxJson.nxCloudId);
}
if (nxJson.nxCloudUrl) {
(_b = result.url) !== null && _b !== void 0 ? _b : (result.url = nxJson.nxCloudUrl);
(_c = result.url) !== null && _c !== void 0 ? _c : (result.url = nxJson.nxCloudUrl);
}

@@ -28,13 +51,13 @@ if (nxJson.nxCloudEncryptionKey) {

if (nxJson.parallel) {
(_c = result.parallel) !== null && _c !== void 0 ? _c : (result.parallel = nxJson.parallel);
(_d = result.parallel) !== null && _d !== void 0 ? _d : (result.parallel = nxJson.parallel);
}
if (nxJson.cacheDirectory) {
(_d = result.cacheDirectory) !== null && _d !== void 0 ? _d : (result.cacheDirectory = nxJson.cacheDirectory);
(_e = result.cacheDirectory) !== null && _e !== void 0 ? _e : (result.cacheDirectory = nxJson.cacheDirectory);
}
if (defaultCacheableOperations.length) {
(_e = result.cacheableOperations) !== null && _e !== void 0 ? _e : (result.cacheableOperations = defaultCacheableOperations);
(_f = result.cacheableOperations) !== null && _f !== void 0 ? _f : (result.cacheableOperations = defaultCacheableOperations);
}
return {
nxJson,
nxCloudOptions: Object.assign(Object.assign({}, result), (_g = (_f = nxJson.tasksRunnerOptions) === null || _f === void 0 ? void 0 : _f[taskRunnerConfiguration]) === null || _g === void 0 ? void 0 : _g.options),
nxCloudOptions: Object.assign(Object.assign({}, result), (_h = (_g = nxJson.tasksRunnerOptions) === null || _g === void 0 ? void 0 : _g[taskRunnerConfiguration]) === null || _h === void 0 ? void 0 : _h.options),
};

@@ -41,0 +64,0 @@ }

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

@@ -10,3 +10,3 @@ "keywords": [

],
"main": "./index.js",
"main": "index.js",
"types": "index.d.ts",

@@ -28,3 +28,3 @@ "author": "Victor Savkin",

"tar": "6.2.1",
"strip-json-comments": "^3.1.1",
"strip-json-comments": "^5.0.1",
"chalk": "^4.1.0",

@@ -34,5 +34,6 @@ "yargs-parser": ">=21.1.1",

"open": "~8.4.0",
"@nrwl/nx-cloud": "19.0.0"
"ini": "4.1.3",
"@nrwl/nx-cloud": "19.1.0-beta.1"
},
"type": "commonjs"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc