@nrwl/nx-cloud 15.1.0-beta0 → 15.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/api/error-reporter.api.js +1 -36
- package/lib/core/api/run-group.api.js +1 -68
- package/lib/core/commands/clean-up-agents.js +1 -1
- package/lib/core/commands/clean-up-agents.js.map +1 -1
- package/lib/core/commands/upload-and-show-run-details.js +6 -6
- package/lib/core/commands/upload-and-show-run-details.js.map +1 -1
- package/lib/core/error/print-cacheable-targets-error.d.ts +1 -0
- package/lib/core/error/print-cacheable-targets-error.js +15 -0
- package/lib/core/error/print-cacheable-targets-error.js.map +1 -0
- package/lib/core/models/run-context.model.d.ts +2 -0
- package/lib/core/models/run-context.model.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.d.ts +1 -3
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -109
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -288
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -113
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -167
- package/lib/core/runners/cloud-enabled/id-generator.js +1 -16
- package/lib/core/runners/distributed-agent/distributed-agent.api.d.ts +2 -2
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -79
- package/lib/core/runners/distributed-agent/distributed-agent.api.js.map +1 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -269
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -143
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -220
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +1 -37
- package/lib/core/runners/distributed-execution/task-graph-creator.js +1 -77
- package/lib/utilities/environment.d.ts +2 -0
- package/lib/utilities/environment.js +21 -10
- package/lib/utilities/environment.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,167 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CloudRunApi = void 0;
|
|
13
|
-
const axios_1 = require("../../../utilities/axios");
|
|
14
|
-
const environment_1 = require("../../../utilities/environment");
|
|
15
|
-
const fs_1 = require("fs");
|
|
16
|
-
const zlib_1 = require("zlib");
|
|
17
|
-
const util_1 = require("util");
|
|
18
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
19
|
-
const { output } = require('../../../utilities/nx-imports');
|
|
20
|
-
class CloudRunApi {
|
|
21
|
-
constructor(messages, runContext, options, machineInfo) {
|
|
22
|
-
this.messages = messages;
|
|
23
|
-
this.runContext = runContext;
|
|
24
|
-
this.machineInfo = machineInfo;
|
|
25
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
26
|
-
}
|
|
27
|
-
startRun(distributedExecutionId, hashes) {
|
|
28
|
-
var _a;
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
|
|
31
|
-
try {
|
|
32
|
-
const request = {
|
|
33
|
-
meta: {
|
|
34
|
-
nxCloudVersion: this.nxCloudVersion(),
|
|
35
|
-
},
|
|
36
|
-
branch: (0, environment_1.getBranch)(),
|
|
37
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
38
|
-
distributedExecutionId,
|
|
39
|
-
hashes,
|
|
40
|
-
};
|
|
41
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
42
|
-
output.note({
|
|
43
|
-
title: 'RunStart',
|
|
44
|
-
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
const resp = yield (0, axios_1.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request)));
|
|
48
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
49
|
-
if (resp.data && resp.data.message) {
|
|
50
|
-
this.messages.message = resp.data.message;
|
|
51
|
-
}
|
|
52
|
-
if (!resp.data || !resp.data.urls) {
|
|
53
|
-
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
|
|
54
|
-
return {};
|
|
55
|
-
}
|
|
56
|
-
return resp.data.urls;
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
60
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
61
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
62
|
-
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
63
|
-
return {};
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
createReqBody(run, tasks, linkId) {
|
|
68
|
-
const uncompressedReqBody = {
|
|
69
|
-
meta: {
|
|
70
|
-
nxCloudVersion: this.nxCloudVersion(),
|
|
71
|
-
},
|
|
72
|
-
tasks,
|
|
73
|
-
run,
|
|
74
|
-
linkId,
|
|
75
|
-
machineInfo: this.machineInfo,
|
|
76
|
-
};
|
|
77
|
-
return JSON.stringify(uncompressedReqBody);
|
|
78
|
-
}
|
|
79
|
-
endRun(run, tasks, linkId) {
|
|
80
|
-
var _a, _b;
|
|
81
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
// API is not working, don't make the end request
|
|
83
|
-
if (this.messages.apiError)
|
|
84
|
-
return false;
|
|
85
|
-
let uncompressedBodyString = this.createReqBody(run, tasks, linkId);
|
|
86
|
-
// if the req body is > 20mb, remove hashDetails
|
|
87
|
-
if (uncompressedBodyString.length > 20 * 1000 * 1000) {
|
|
88
|
-
uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))));
|
|
89
|
-
}
|
|
90
|
-
const uncompressedBuffer = Buffer.from(uncompressedBodyString);
|
|
91
|
-
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
|
|
92
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
|
|
93
|
-
try {
|
|
94
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
95
|
-
const t = tasks.map((tt) => {
|
|
96
|
-
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
|
|
97
|
-
? `${tt.terminalOutput.slice(0, 20)}...`
|
|
98
|
-
: undefined });
|
|
99
|
-
});
|
|
100
|
-
output.note({
|
|
101
|
-
title: 'RunEnd. Completed tasks',
|
|
102
|
-
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
|
|
106
|
-
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
|
|
107
|
-
})));
|
|
108
|
-
if (resp) {
|
|
109
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
110
|
-
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
|
|
111
|
-
this.runContext.runUrl = resp.data.runUrl;
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
if (resp.data && resp.data.status) {
|
|
115
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
|
|
116
|
-
}
|
|
117
|
-
else if (resp.data && typeof resp.data === 'string') {
|
|
118
|
-
if (resp.data !== 'success') {
|
|
119
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
124
|
-
}
|
|
125
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
126
|
-
output.note({
|
|
127
|
-
title: 'Invalid end run response',
|
|
128
|
-
bodyLines: [JSON.stringify(resp.data, null, 2)],
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
output.error({
|
|
134
|
-
title: 'Nx Cloud: Unknown Error Occurred',
|
|
135
|
-
bodyLines: [
|
|
136
|
-
'Run completion responded with `undefined`.',
|
|
137
|
-
'Run Details:',
|
|
138
|
-
JSON.stringify(run, null, 2),
|
|
139
|
-
'Stack Trace:',
|
|
140
|
-
JSON.stringify(new Error().stack, null, 2),
|
|
141
|
-
],
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
catch (ee) {
|
|
147
|
-
recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
148
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
|
|
149
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
150
|
-
const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
|
|
151
|
-
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
nxCloudVersion() {
|
|
157
|
-
try {
|
|
158
|
-
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
|
|
159
|
-
return v.devDependencies['@nrwl/nx-cloud'];
|
|
160
|
-
}
|
|
161
|
-
catch (e) {
|
|
162
|
-
return 'unknown';
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
exports.CloudRunApi = CloudRunApi;
|
|
167
|
-
//# sourceMappingURL=cloud-run.api.js.map
|
|
1
|
+
const a3_0xf81b=['/nx-cloud/runs/end','gzip','terminalOutput','util','printDuration','...','@nrwl/nx-cloud','/nx-cloud/runs/start','endRun','startRun','toString','Run\x20Details:','Run\x20completion\x20responded\x20with\x20`undefined`.','__awaiter','stack','apiError','map','../../../utilities/environment','runUrl','apiAxiosInstance','promisify','string','post','defaults','throw','stringify','status','extractErrorMessage','headers','VERBOSE_LOGGING','createMetricRecorder','from','../../../utilities/metric-logger','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','RunEnd\x20duration','readFileSync','axiosException','api','response','message','success','../../../utilities/axios','Invalid\x20Nx\x20Cloud\x20response:\x20','CloudRunApi','value','mapRespToPerfEntry','RunStart','length','error','devDependencies','recordMetric','messages','machineInfo','getRunGroup','then','Invalid\x20end\x20run\x20response','runContext','parse','unknown','Stack\x20Trace:','Invalid\x20end\x20run\x20response:\x20','data','createReqBody','note','slice','next','nxCloudVersion','assign','axiosMultipleTries','RUNNER_FAILURE_PERF_ENTRY'];(function(_0x4b38a4,_0xf81b2e){const _0x380cba=function(_0x2809b6){while(--_0x2809b6){_0x4b38a4['push'](_0x4b38a4['shift']());}};_0x380cba(++_0xf81b2e);}(a3_0xf81b,0x1a0));const a3_0x380c=function(_0x4b38a4,_0xf81b2e){_0x4b38a4=_0x4b38a4-0x0;let _0x380cba=a3_0xf81b[_0x4b38a4];return _0x380cba;};'use strict';var __awaiter=this&&this[a3_0x380c('0x11')]||function(_0x168fc7,_0x58b57a,_0x24b06a,_0x4b73a7){function _0x52abfb(_0x3dae64){return _0x3dae64 instanceof _0x24b06a?_0x3dae64:new _0x24b06a(function(_0x5cc347){_0x5cc347(_0x3dae64);});}return new(_0x24b06a||(_0x24b06a=Promise))(function(_0x1fbf8b,_0x7d793c){function _0x190767(_0x2280f0){try{_0x29e293(_0x4b73a7[a3_0x380c('0x45')](_0x2280f0));}catch(_0x2ec946){_0x7d793c(_0x2ec946);}}function _0x2b3d36(_0x2bbfa1){try{_0x29e293(_0x4b73a7[a3_0x380c('0x1c')](_0x2bbfa1));}catch(_0x331b43){_0x7d793c(_0x331b43);}}function _0x29e293(_0x43b3ba){_0x43b3ba['done']?_0x1fbf8b(_0x43b3ba[a3_0x380c('0x30')]):_0x52abfb(_0x43b3ba[a3_0x380c('0x30')])[a3_0x380c('0x3a')](_0x190767,_0x2b3d36);}_0x29e293((_0x4b73a7=_0x4b73a7['apply'](_0x168fc7,_0x58b57a||[]))[a3_0x380c('0x45')]());});};Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a3_0x380c('0x2f')]=void 0x0;const axios_1=require(a3_0x380c('0x2d'));const environment_1=require(a3_0x380c('0x15'));const fs_1=require('fs');const zlib_1=require('zlib');const util_1=require(a3_0x380c('0x7'));const metric_logger_1=require(a3_0x380c('0x24'));const {output}=require('../../../utilities/nx-imports');class CloudRunApi{constructor(_0x11e1c6,_0x50f5f5,_0x51c601,_0x322617){this['messages']=_0x11e1c6;this[a3_0x380c('0x3c')]=_0x50f5f5;this[a3_0x380c('0x38')]=_0x322617;this[a3_0x380c('0x17')]=(0x0,axios_1['createApiAxiosInstance'])(_0x51c601);}[a3_0x380c('0xd')](_0x18b8f7,_0x54cc2f){var _0x314826;return __awaiter(this,void 0x0,void 0x0,function*(){const _0xb58312=(0x0,metric_logger_1[a3_0x380c('0x22')])(a3_0x380c('0xd'));try{const _0x5e9c8c={'meta':{'nxCloudVersion':this['nxCloudVersion']()},'branch':(0x0,environment_1['getBranch'])(),'runGroup':(0x0,environment_1[a3_0x380c('0x39')])(),'distributedExecutionId':_0x18b8f7,'hashes':_0x54cc2f};if(environment_1[a3_0x380c('0x21')]){output[a3_0x380c('0x43')]({'title':a3_0x380c('0x32'),'bodyLines':['\x0a'+JSON[a3_0x380c('0x1d')](_0x5e9c8c,null,0x2)]});}const _0x2cae67=yield(0x0,axios_1[a3_0x380c('0x8')])('RunStart\x20duration',()=>(0x0,axios_1['axiosMultipleTries'])(()=>this[a3_0x380c('0x17')][a3_0x380c('0x1a')](a3_0x380c('0xb'),_0x5e9c8c)));_0xb58312[a3_0x380c('0x36')]((0x0,metric_logger_1[a3_0x380c('0x31')])(_0x2cae67));if(_0x2cae67['data']&&_0x2cae67[a3_0x380c('0x41')][a3_0x380c('0x2b')]){this[a3_0x380c('0x37')][a3_0x380c('0x2b')]=_0x2cae67[a3_0x380c('0x41')][a3_0x380c('0x2b')];}if(!_0x2cae67['data']||!_0x2cae67[a3_0x380c('0x41')]['urls']){this[a3_0x380c('0x37')][a3_0x380c('0x13')]=a3_0x380c('0x2e')+JSON[a3_0x380c('0x1d')](_0x2cae67[a3_0x380c('0x41')]);return{};}return _0x2cae67[a3_0x380c('0x41')]['urls'];}catch(_0xc11461){_0xb58312[a3_0x380c('0x36')](((_0x314826=_0xc11461===null||_0xc11461===void 0x0?void 0x0:_0xc11461['axiosException'])===null||_0x314826===void 0x0?void 0x0:_0x314826['response'])?(0x0,metric_logger_1[a3_0x380c('0x31')])(_0xc11461[a3_0x380c('0x28')][a3_0x380c('0x2a')]):metric_logger_1[a3_0x380c('0x3')]);this[a3_0x380c('0x37')][a3_0x380c('0x13')]=this[a3_0x380c('0x37')][a3_0x380c('0x1f')](_0xc11461,a3_0x380c('0x29'));return{};}});}[a3_0x380c('0x42')](_0x276715,_0x1698c1,_0x54e7c3){const _0x3f0a76={'meta':{'nxCloudVersion':this[a3_0x380c('0x0')]()},'tasks':_0x1698c1,'run':_0x276715,'linkId':_0x54e7c3,'machineInfo':this['machineInfo']};return JSON[a3_0x380c('0x1d')](_0x3f0a76);}[a3_0x380c('0xc')](_0x546927,_0x43a4dc,_0x28cd97){var _0x472366,_0x2b1275;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages']['apiError'])return![];let _0xb4b993=this['createReqBody'](_0x546927,_0x43a4dc,_0x28cd97);if(_0xb4b993[a3_0x380c('0x33')]>0x14*0x3e8*0x3e8){_0xb4b993=this[a3_0x380c('0x42')](_0x546927,_0x43a4dc[a3_0x380c('0x14')](_0x24d307=>Object['assign'](Object[a3_0x380c('0x1')]({},_0x24d307),{'hashDetails':undefined})));}const _0x4950b1=Buffer[a3_0x380c('0x23')](_0xb4b993);const _0x263746=yield(0x0,util_1[a3_0x380c('0x18')])(zlib_1[a3_0x380c('0x5')])(_0x4950b1);const _0x3397fc=(0x0,metric_logger_1[a3_0x380c('0x22')])(a3_0x380c('0xc'));try{if(environment_1[a3_0x380c('0x21')]){const _0x24195e=_0x43a4dc[a3_0x380c('0x14')](_0x2692d1=>{return Object[a3_0x380c('0x1')](Object[a3_0x380c('0x1')]({},_0x2692d1),{'terminalOutput':_0x2692d1[a3_0x380c('0x6')]?_0x2692d1[a3_0x380c('0x6')][a3_0x380c('0x44')](0x0,0x14)+a3_0x380c('0x9'):undefined});});output['note']({'title':'RunEnd.\x20Completed\x20tasks','bodyLines':['\x0a'+JSON['stringify'](_0x24195e,null,0x2)]});}const _0x2d8be0=yield(0x0,axios_1[a3_0x380c('0x8')])(a3_0x380c('0x26'),()=>(0x0,axios_1[a3_0x380c('0x2')])(()=>this['apiAxiosInstance'][a3_0x380c('0x1a')](a3_0x380c('0x4'),_0x263746,{'headers':Object[a3_0x380c('0x1')](Object[a3_0x380c('0x1')]({},this[a3_0x380c('0x17')][a3_0x380c('0x1b')][a3_0x380c('0x20')]),{'Content-Encoding':a3_0x380c('0x5'),'Content-Type':'application/octet-stream'})})));if(_0x2d8be0){_0x3397fc[a3_0x380c('0x36')]((0x0,metric_logger_1[a3_0x380c('0x31')])(_0x2d8be0));if(_0x2d8be0[a3_0x380c('0x41')]&&_0x2d8be0['data']['runUrl']&&_0x2d8be0[a3_0x380c('0x41')][a3_0x380c('0x1e')]===a3_0x380c('0x2c')){this[a3_0x380c('0x3c')][a3_0x380c('0x16')]=_0x2d8be0['data'][a3_0x380c('0x16')];return!![];}if(_0x2d8be0[a3_0x380c('0x41')]&&_0x2d8be0[a3_0x380c('0x41')][a3_0x380c('0x1e')]){this['messages'][a3_0x380c('0x13')]=a3_0x380c('0x40')+JSON[a3_0x380c('0x1d')](_0x2d8be0[a3_0x380c('0x41')][a3_0x380c('0x2b')]);}else if(_0x2d8be0[a3_0x380c('0x41')]&&typeof _0x2d8be0[a3_0x380c('0x41')]===a3_0x380c('0x19')){if(_0x2d8be0[a3_0x380c('0x41')]!==a3_0x380c('0x2c')){this[a3_0x380c('0x37')]['apiError']='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0x380c('0x1d')](_0x2d8be0['data']);}}else{this[a3_0x380c('0x37')][a3_0x380c('0x13')]=a3_0x380c('0x40')+JSON['stringify'](_0x2d8be0[a3_0x380c('0x41')]);}if(environment_1[a3_0x380c('0x21')]){output[a3_0x380c('0x43')]({'title':a3_0x380c('0x3b'),'bodyLines':[JSON[a3_0x380c('0x1d')](_0x2d8be0[a3_0x380c('0x41')],null,0x2)]});}}else{output[a3_0x380c('0x34')]({'title':a3_0x380c('0x25'),'bodyLines':[a3_0x380c('0x10'),a3_0x380c('0xf'),JSON['stringify'](_0x546927,null,0x2),a3_0x380c('0x3f'),JSON['stringify'](new Error()[a3_0x380c('0x12')],null,0x2)]});}return![];}catch(_0x2eeb02){_0x3397fc[a3_0x380c('0x36')](((_0x472366=_0x2eeb02===null||_0x2eeb02===void 0x0?void 0x0:_0x2eeb02[a3_0x380c('0x28')])===null||_0x472366===void 0x0?void 0x0:_0x472366['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x2eeb02[a3_0x380c('0x28')]['response']):metric_logger_1[a3_0x380c('0x3')]);const _0x1d8ec6=(_0x2b1275=_0x2eeb02[a3_0x380c('0x28')])!==null&&_0x2b1275!==void 0x0?_0x2b1275:_0x2eeb02;this['messages'][a3_0x380c('0x13')]=this[a3_0x380c('0x37')][a3_0x380c('0x1f')](_0x1d8ec6,'api');return![];}});}['nxCloudVersion'](){try{const _0x4d130a=JSON[a3_0x380c('0x3d')]((0x0,fs_1[a3_0x380c('0x27')])('package.json')[a3_0x380c('0xe')]());return _0x4d130a[a3_0x380c('0x35')][a3_0x380c('0xa')];}catch(_0x12211e){return a3_0x380c('0x3e');}}}exports[a3_0x380c('0x2f')]=CloudRunApi;
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateUniqueLinkId = void 0;
|
|
4
|
-
const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
5
|
-
const digits = '0123456789';
|
|
6
|
-
const lower = upper.toLowerCase();
|
|
7
|
-
const alphanum = upper + lower + digits;
|
|
8
|
-
function generateUniqueLinkId() {
|
|
9
|
-
let res = '';
|
|
10
|
-
for (let i = 0; i < 10; ++i) {
|
|
11
|
-
res += alphanum[Math.floor(Math.random() * alphanum.length)];
|
|
12
|
-
}
|
|
13
|
-
return res;
|
|
14
|
-
}
|
|
15
|
-
exports.generateUniqueLinkId = generateUniqueLinkId;
|
|
16
|
-
//# sourceMappingURL=id-generator.js.map
|
|
1
|
+
const a4_0x4f22=['floor','toLowerCase','ABCDEFGHIJKLMNOPQRSTUVWXYZ','random','__esModule','defineProperty','generateUniqueLinkId'];(function(_0x128200,_0x4f2213){const _0x1d539e=function(_0xff88e5){while(--_0xff88e5){_0x128200['push'](_0x128200['shift']());}};_0x1d539e(++_0x4f2213);}(a4_0x4f22,0x68));const a4_0x1d53=function(_0x128200,_0x4f2213){_0x128200=_0x128200-0x0;let _0x1d539e=a4_0x4f22[_0x128200];return _0x1d539e;};'use strict';Object[a4_0x1d53('0x6')](exports,a4_0x1d53('0x5'),{'value':!![]});exports[a4_0x1d53('0x0')]=void 0x0;const upper=a4_0x1d53('0x3');const digits='0123456789';const lower=upper[a4_0x1d53('0x2')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x2dbb3c='';for(let _0x498041=0x0;_0x498041<0xa;++_0x498041){_0x2dbb3c+=alphanum[Math[a4_0x1d53('0x1')](Math[a4_0x1d53('0x4')]()*alphanum['length'])];}return _0x2dbb3c;}exports[a4_0x1d53('0x0')]=generateUniqueLinkId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CloudTaskRunnerOptions } from '../../models/cloud-task-runner-options';
|
|
2
|
-
import { TasksApiResponse } from '../../models/distributed-agent
|
|
2
|
+
import { TasksApiResponse } from '../../models/distributed-agent';
|
|
3
3
|
export declare class DistributedAgentApi {
|
|
4
4
|
private readonly runGroup;
|
|
5
5
|
private readonly agentName;
|
|
@@ -8,6 +8,6 @@ export declare class DistributedAgentApi {
|
|
|
8
8
|
tasks(executionId: string | null, statusCode: number | null, completedTasks: {
|
|
9
9
|
taskId: string;
|
|
10
10
|
hash: string;
|
|
11
|
-
}[]): Promise<TasksApiResponse>;
|
|
11
|
+
}[], targets?: string[]): Promise<TasksApiResponse>;
|
|
12
12
|
completeRunGroupWithError(error: string): Promise<void>;
|
|
13
13
|
}
|
|
@@ -1,79 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DistributedAgentApi = void 0;
|
|
13
|
-
const axios_1 = require("../../../utilities/axios");
|
|
14
|
-
const environment_1 = require("../../../utilities/environment");
|
|
15
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
16
|
-
const { output } = require('../../../utilities/nx-imports');
|
|
17
|
-
class DistributedAgentApi {
|
|
18
|
-
constructor(options, runGroup, agentName) {
|
|
19
|
-
this.runGroup = runGroup;
|
|
20
|
-
this.agentName = agentName;
|
|
21
|
-
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
22
|
-
}
|
|
23
|
-
tasks(executionId, statusCode, completedTasks) {
|
|
24
|
-
var _a;
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
|
|
27
|
-
try {
|
|
28
|
-
const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
|
|
29
|
-
runGroup: this.runGroup,
|
|
30
|
-
agentName: this.agentName,
|
|
31
|
-
executionId,
|
|
32
|
-
statusCode,
|
|
33
|
-
completedTasks,
|
|
34
|
-
}));
|
|
35
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
|
|
36
|
-
return res.data;
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
40
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
41
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
42
|
-
throw e;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
completeRunGroupWithError(error) {
|
|
47
|
-
var _a;
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
50
|
-
output.note({
|
|
51
|
-
title: 'Completing run group with an error',
|
|
52
|
-
bodyLines: [`runGroup: ${this.runGroup}`, `error: ${error}`],
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
|
|
56
|
-
try {
|
|
57
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
58
|
-
runGroup: this.runGroup,
|
|
59
|
-
agentName: this.agentName,
|
|
60
|
-
criticalErrorMessage: error,
|
|
61
|
-
}));
|
|
62
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
63
|
-
output.note({
|
|
64
|
-
title: 'Completed run group with an error',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
71
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
72
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
73
|
-
console.error(e);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.DistributedAgentApi = DistributedAgentApi;
|
|
79
|
-
//# sourceMappingURL=distributed-agent.api.js.map
|
|
1
|
+
const a5_0x5d60=['post','../../../utilities/axios','done','../../../utilities/metric-logger','recordMetric','note','VERBOSE_LOGGING','__awaiter','/nx-cloud/executions/tasks','DistributedAgentApi','throw','runGroup','error:\x20','createMetricRecorder','next','/nx-cloud/executions/complete-run-group','agentName','__esModule','error','response','apiAxiosInstance','data','completeRunGroupWithError','mapRespToPerfEntry','dtePollTasks','apply','value','Completing\x20run\x20group\x20with\x20an\x20error','RUNNER_FAILURE_PERF_ENTRY','axiosMultipleTries','axiosException','runGroup:\x20'];(function(_0x5995ad,_0x5d6006){const _0x236585=function(_0x4709ae){while(--_0x4709ae){_0x5995ad['push'](_0x5995ad['shift']());}};_0x236585(++_0x5d6006);}(a5_0x5d60,0x1dc));const a5_0x2365=function(_0x5995ad,_0x5d6006){_0x5995ad=_0x5995ad-0x0;let _0x236585=a5_0x5d60[_0x5995ad];return _0x236585;};'use strict';var __awaiter=this&&this[a5_0x2365('0xb')]||function(_0x2455d4,_0x1c8b86,_0x55d712,_0x3d1d46){function _0x57a604(_0x3882ea){return _0x3882ea instanceof _0x55d712?_0x3882ea:new _0x55d712(function(_0x5769a7){_0x5769a7(_0x3882ea);});}return new(_0x55d712||(_0x55d712=Promise))(function(_0x4a2e72,_0x31ad8a){function _0x4d3f95(_0x558a50){try{_0x3b8261(_0x3d1d46[a5_0x2365('0x12')](_0x558a50));}catch(_0x25e6f3){_0x31ad8a(_0x25e6f3);}}function _0x1ac2b0(_0x5e5da2){try{_0x3b8261(_0x3d1d46[a5_0x2365('0xe')](_0x5e5da2));}catch(_0x1bc9d1){_0x31ad8a(_0x1bc9d1);}}function _0x3b8261(_0x2e8f70){_0x2e8f70[a5_0x2365('0x6')]?_0x4a2e72(_0x2e8f70[a5_0x2365('0x1e')]):_0x57a604(_0x2e8f70[a5_0x2365('0x1e')])['then'](_0x4d3f95,_0x1ac2b0);}_0x3b8261((_0x3d1d46=_0x3d1d46[a5_0x2365('0x1d')](_0x2455d4,_0x1c8b86||[]))[a5_0x2365('0x12')]());});};Object['defineProperty'](exports,a5_0x2365('0x15'),{'value':!![]});exports[a5_0x2365('0xd')]=void 0x0;const axios_1=require(a5_0x2365('0x5'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a5_0x2365('0x7'));const {output}=require('../../../utilities/nx-imports');class DistributedAgentApi{constructor(_0x9adca1,_0x2ae946,_0x14d1e8){this[a5_0x2365('0xf')]=_0x2ae946;this[a5_0x2365('0x14')]=_0x14d1e8;this['apiAxiosInstance']=(0x0,axios_1['createApiAxiosInstance'])(_0x9adca1);}['tasks'](_0xdb2ce0,_0x313e86,_0x29bb9a,_0x3e2598){var _0xcdbe59;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2d8b8f=(0x0,metric_logger_1[a5_0x2365('0x11')])(a5_0x2365('0x1c'));try{const _0x4d4572=yield(0x0,axios_1[a5_0x2365('0x1')])(()=>this[a5_0x2365('0x18')][a5_0x2365('0x4')](a5_0x2365('0xc'),{'runGroup':this[a5_0x2365('0xf')],'agentName':this['agentName'],'executionId':_0xdb2ce0,'statusCode':_0x313e86,'completedTasks':_0x29bb9a,'targets':_0x3e2598}));_0x2d8b8f[a5_0x2365('0x8')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x4d4572));return _0x4d4572[a5_0x2365('0x19')];}catch(_0x109d01){_0x2d8b8f['recordMetric'](((_0xcdbe59=_0x109d01===null||_0x109d01===void 0x0?void 0x0:_0x109d01[a5_0x2365('0x2')])===null||_0xcdbe59===void 0x0?void 0x0:_0xcdbe59[a5_0x2365('0x17')])?(0x0,metric_logger_1[a5_0x2365('0x1b')])(_0x109d01[a5_0x2365('0x2')][a5_0x2365('0x17')]):metric_logger_1[a5_0x2365('0x0')]);throw _0x109d01;}});}[a5_0x2365('0x1a')](_0x3cb848){var _0x1e6c6f;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a5_0x2365('0xa')]){output[a5_0x2365('0x9')]({'title':a5_0x2365('0x1f'),'bodyLines':[a5_0x2365('0x3')+this[a5_0x2365('0xf')],a5_0x2365('0x10')+_0x3cb848]});}const _0x488df5=(0x0,metric_logger_1[a5_0x2365('0x11')])('completeRunGroup');try{const _0x5de60b=yield(0x0,axios_1[a5_0x2365('0x1')])(()=>this[a5_0x2365('0x18')][a5_0x2365('0x4')](a5_0x2365('0x13'),{'runGroup':this[a5_0x2365('0xf')],'agentName':this[a5_0x2365('0x14')],'criticalErrorMessage':_0x3cb848}));if(environment_1[a5_0x2365('0xa')]){output[a5_0x2365('0x9')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0x488df5[a5_0x2365('0x8')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x5de60b));}catch(_0x43c5f7){_0x488df5[a5_0x2365('0x8')](((_0x1e6c6f=_0x43c5f7===null||_0x43c5f7===void 0x0?void 0x0:_0x43c5f7[a5_0x2365('0x2')])===null||_0x1e6c6f===void 0x0?void 0x0:_0x1e6c6f['response'])?(0x0,metric_logger_1[a5_0x2365('0x1b')])(_0x43c5f7[a5_0x2365('0x2')]['response']):metric_logger_1[a5_0x2365('0x0')]);console[a5_0x2365('0x16')](_0x43c5f7);}});}}exports[a5_0x2365('0xd')]=DistributedAgentApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distributed-agent.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/distributed-agent/distributed-agent.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oDAGkC;AAElC,gEAAiE;AACjE,oEAI0C;
|
|
1
|
+
{"version":3,"file":"distributed-agent.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/distributed-agent/distributed-agent.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oDAGkC;AAElC,gEAAiE;AACjE,oEAI0C;AAE1C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE5D,MAAa,mBAAmB;IAG9B,YACE,OAA+B,EACd,QAAgB,EAChB,SAAiB;QADjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAQ;QAElC,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEK,KAAK,CACT,WAA0B,EAC1B,UAAyB,EACzB,cAAkD,EAClD,OAAkB;;;YAElB,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,cAAc,CAAC,CAAC;YAEtD,IAAI;gBACF,MAAM,GAAG,GAAG,MAAM,IAAA,0BAAkB,EAAC,GAAG,EAAE,CACxC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,4BAA4B,EAAE;oBACvD,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,WAAW;oBACX,UAAU;oBACV,cAAc;oBACd,OAAO;iBACR,CAAC,CACH,CAAC;gBACF,QAAQ,CAAC,YAAY,CAAC,IAAA,kCAAkB,EAAC,GAAG,CAAC,CAAC,CAAC;gBAC/C,OAAO,GAAG,CAAC,IAAI,CAAC;aACjB;YAAC,OAAO,CAAM,EAAE;gBACf,QAAQ,CAAC,YAAY,CACnB,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,cAAc,0CAAE,QAAQ;oBACzB,CAAC,CAAC,IAAA,kCAAkB,EAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC;oBAC/C,CAAC,CAAC,yCAAyB,CAC9B,CAAC;gBACF,MAAM,CAAC,CAAC;aACT;;KACF;IAEK,yBAAyB,CAAC,KAAa;;;YAC3C,IAAI,6BAAe,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC;oBACV,KAAK,EAAE,oCAAoC;oBAC3C,SAAS,EAAE,CAAC,aAAa,IAAI,CAAC,QAAQ,EAAE,EAAE,UAAU,KAAK,EAAE,CAAC;iBAC7D,CAAC,CAAC;aACJ;YAED,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,kBAAkB,CAAC,CAAC;YAE1D,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAA,0BAAkB,EAAC,GAAG,EAAE,CACzC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,yCAAyC,EAAE;oBACpE,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,oBAAoB,EAAE,KAAK;iBAC5B,CAAC,CACH,CAAC;gBACF,IAAI,6BAAe,EAAE;oBACnB,MAAM,CAAC,IAAI,CAAC;wBACV,KAAK,EAAE,mCAAmC;qBAC3C,CAAC,CAAC;iBACJ;gBACD,QAAQ,CAAC,YAAY,CAAC,IAAA,kCAAkB,EAAC,IAAI,CAAC,CAAC,CAAC;aACjD;YAAC,OAAO,CAAM,EAAE;gBACf,QAAQ,CAAC,YAAY,CACnB,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,cAAc,0CAAE,QAAQ;oBACzB,CAAC,CAAC,IAAA,kCAAkB,EAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC;oBAC/C,CAAC,CAAC,yCAAyB,CAC9B,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aAClB;;KACF;CACF;AA3ED,kDA2EC"}
|
|
@@ -1,269 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.startAgent = void 0;
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
|
-
const fs_1 = require("fs");
|
|
15
|
-
const stripJsonComments = require("strip-json-comments");
|
|
16
|
-
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
|
|
17
|
-
const environment_1 = require("../../../utilities/environment");
|
|
18
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
19
|
-
const waiter_1 = require("../../../utilities/waiter");
|
|
20
|
-
const print_run_group_error_1 = require("../../error/print-run-group-error");
|
|
21
|
-
const distributed_agent_api_1 = require("./distributed-agent.api");
|
|
22
|
-
const print_invalid_runner_error_1 = require("../../error/print-invalid-runner-error");
|
|
23
|
-
const { output, workspaceRoot } = require('../../../utilities/nx-imports');
|
|
24
|
-
function executeTasks(options, api) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
let completedStatusCode = 0;
|
|
27
|
-
let apiResponse = null;
|
|
28
|
-
const failIfSameTasksAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
|
|
29
|
-
title: `No new messages received after ${environment_1.NO_MESSAGES_TIMEOUT / 1000} seconds`,
|
|
30
|
-
timeout: environment_1.NO_MESSAGES_TIMEOUT,
|
|
31
|
-
});
|
|
32
|
-
const waiter = new waiter_1.Waiter();
|
|
33
|
-
let completedTasks = [];
|
|
34
|
-
const startTime = new Date();
|
|
35
|
-
let executedAnyTasks = false;
|
|
36
|
-
while (true) {
|
|
37
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
38
|
-
output.note({
|
|
39
|
-
title: 'Fetching tasks...',
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks);
|
|
43
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
44
|
-
output.note({
|
|
45
|
-
title: 'API Response',
|
|
46
|
-
bodyLines: [
|
|
47
|
-
`completed: ${apiResponse.completed}`,
|
|
48
|
-
`status: ${apiResponse.status}`,
|
|
49
|
-
`retryDuring: ${apiResponse.retryDuring}`,
|
|
50
|
-
`executionId: ${apiResponse.executionId}`,
|
|
51
|
-
`number of tasks: ${apiResponse.tasks.length}`,
|
|
52
|
-
`error: ${apiResponse.criticalErrorMessage}`,
|
|
53
|
-
`maxParallel: ${apiResponse.maxParallel}`,
|
|
54
|
-
],
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
if (apiResponse.criticalErrorMessage) {
|
|
58
|
-
output.error({
|
|
59
|
-
title: 'Distributed Execution Terminated',
|
|
60
|
-
bodyLines: ['Error:', apiResponse.criticalErrorMessage],
|
|
61
|
-
});
|
|
62
|
-
process.exit(0);
|
|
63
|
-
}
|
|
64
|
-
// run group is completed but it might be a rerun
|
|
65
|
-
// we will try several times before going further and
|
|
66
|
-
// completed the response
|
|
67
|
-
// we only do it if we haven't executed any tasks
|
|
68
|
-
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
|
|
69
|
-
(apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
|
|
70
|
-
!executedAnyTasks &&
|
|
71
|
-
new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
|
|
72
|
-
yield waiter.wait();
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.status) !== undefined) {
|
|
76
|
-
if (apiResponse.status === 'RUN_GROUP_COMPLETED' ||
|
|
77
|
-
apiResponse.status === 'NO_FURTHER_TASKS_TO_RUN') {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else if (apiResponse.completed) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
// if status is present that use the status instead of completed, otherwise use completed
|
|
85
|
-
failIfSameTasksAfterTimeout(apiResponse.tasks.map((t) => t.taskId).join(''));
|
|
86
|
-
if (!apiResponse.executionId) {
|
|
87
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
88
|
-
output.note({
|
|
89
|
-
title: 'Waiting...',
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
yield waiter.wait();
|
|
93
|
-
completedStatusCode = 0;
|
|
94
|
-
completedTasks = [];
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
waiter.reset();
|
|
98
|
-
executedAnyTasks = true;
|
|
99
|
-
const r = invokeTasksUsingRunMany(options, apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
|
|
100
|
-
completedStatusCode = r.completedStatusCode;
|
|
101
|
-
completedTasks = r.completedTasks;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function readCompletedTasks(options, distributedExecutionId) {
|
|
106
|
-
const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
|
|
107
|
-
let completedTasks;
|
|
108
|
-
try {
|
|
109
|
-
const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
|
|
110
|
-
const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
|
|
111
|
-
completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
|
|
112
|
-
// remove it such that if the next command crashes we don't read an obsolete file
|
|
113
|
-
(0, fs_1.unlinkSync)(taskHashesFile);
|
|
114
|
-
}
|
|
115
|
-
catch (e) {
|
|
116
|
-
throw new Error(errorMessage);
|
|
117
|
-
}
|
|
118
|
-
if (completedTasks.length == 0) {
|
|
119
|
-
throw new Error(errorMessage);
|
|
120
|
-
}
|
|
121
|
-
return completedTasks;
|
|
122
|
-
}
|
|
123
|
-
function invokeTasksUsingRunMany(options, executionId, tasks, maxParallel) {
|
|
124
|
-
let completedStatusCode = 0;
|
|
125
|
-
const completedTasks = [];
|
|
126
|
-
for (const g of groupByTarget(tasks)) {
|
|
127
|
-
const config = g.configuration ? `--configuration=${g.configuration}` : ``;
|
|
128
|
-
const parallel = maxParallel > 1 ? ` --parallel --max-parallel=${maxParallel}` : ``;
|
|
129
|
-
// TODO use pnpx or yarn when needed
|
|
130
|
-
const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallel}`;
|
|
131
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
132
|
-
output.note({
|
|
133
|
-
title: `Executing: '${command}'`,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
try {
|
|
137
|
-
(0, child_process_1.execSync)(command, {
|
|
138
|
-
stdio: ['ignore', 'inherit', 'inherit'],
|
|
139
|
-
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' }),
|
|
140
|
-
});
|
|
141
|
-
completedTasks.push(...readCompletedTasks(options, executionId));
|
|
142
|
-
}
|
|
143
|
-
catch (e) {
|
|
144
|
-
if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
|
|
145
|
-
throw e;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
completedStatusCode = 1;
|
|
149
|
-
completedTasks.push(...readCompletedTasks(options, executionId));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return { completedStatusCode, completedTasks };
|
|
154
|
-
}
|
|
155
|
-
function groupByTarget(tasks) {
|
|
156
|
-
const res = [];
|
|
157
|
-
tasks.forEach((t) => {
|
|
158
|
-
const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
|
|
159
|
-
if (r) {
|
|
160
|
-
r.projects.push(t.projectName);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
res.push({
|
|
164
|
-
target: t.target,
|
|
165
|
-
projects: [t.projectName],
|
|
166
|
-
params: t.params,
|
|
167
|
-
configuration: t.configuration,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
return res;
|
|
172
|
-
}
|
|
173
|
-
function getAgentName() {
|
|
174
|
-
if (process.env.NX_AGENT_NAME !== undefined) {
|
|
175
|
-
return process.env.NX_AGENT_NAME;
|
|
176
|
-
}
|
|
177
|
-
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_STAGE) {
|
|
178
|
-
return process.env.CIRCLE_STAGE;
|
|
179
|
-
}
|
|
180
|
-
else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_JOB) {
|
|
181
|
-
return process.env.CIRCLE_JOB;
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
return `Agent ${Math.floor(Math.random() * 100000)}`;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
function createAgentLockfileAndSetUpListeners(api, options, agentName) {
|
|
188
|
-
const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
|
|
189
|
-
const lockFileDirectory = `${cacheDirectory}/lockfiles`;
|
|
190
|
-
const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
|
|
191
|
-
if (!(0, fs_1.existsSync)(lockFileDirectory)) {
|
|
192
|
-
(0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
|
|
193
|
-
}
|
|
194
|
-
// Check for other agents' lockfiles and warn if exist
|
|
195
|
-
const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
|
|
196
|
-
if (lockFiles.length) {
|
|
197
|
-
// Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
|
|
198
|
-
if (lockFiles.includes(`${agentName}.lock`)) {
|
|
199
|
-
output.error({
|
|
200
|
-
title: 'Duplicate Agent ID Detected',
|
|
201
|
-
bodyLines: [
|
|
202
|
-
'We have detected another agent with this ID running in this workspace. This should not happen.',
|
|
203
|
-
'',
|
|
204
|
-
'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
|
|
205
|
-
],
|
|
206
|
-
});
|
|
207
|
-
process.exit(1);
|
|
208
|
-
}
|
|
209
|
-
output.warn({
|
|
210
|
-
title: 'Other Nx Cloud Agents Detected',
|
|
211
|
-
bodyLines: [
|
|
212
|
-
'We have detected other agents running in this workspace. This can cause unexpected behavior.',
|
|
213
|
-
'',
|
|
214
|
-
'This can also be a false positive caused by agents that did not shut down correctly.',
|
|
215
|
-
'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
|
|
216
|
-
],
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
(0, fs_1.writeFileSync)(lockFilePath, '');
|
|
220
|
-
process.on('exit', (code) => {
|
|
221
|
-
cleanupAgentLockfile(lockFilePath, code);
|
|
222
|
-
});
|
|
223
|
-
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
|
|
224
|
-
yield api.completeRunGroupWithError('Agent was terminated via SIGTERM');
|
|
225
|
-
cleanupAgentLockfile(lockFilePath, 1);
|
|
226
|
-
}));
|
|
227
|
-
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
|
|
228
|
-
yield api.completeRunGroupWithError('Agent was terminated via SIGINT');
|
|
229
|
-
cleanupAgentLockfile(lockFilePath, 1);
|
|
230
|
-
}));
|
|
231
|
-
}
|
|
232
|
-
function cleanupAgentLockfile(lockFilePath, code) {
|
|
233
|
-
if ((0, fs_1.existsSync)(lockFilePath)) {
|
|
234
|
-
(0, fs_1.unlinkSync)(lockFilePath);
|
|
235
|
-
process.exit(code);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
function startAgent() {
|
|
239
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
-
const runGroup = (0, environment_1.getRunGroup)();
|
|
241
|
-
if (!runGroup) {
|
|
242
|
-
(0, print_run_group_error_1.printRunGroupError)();
|
|
243
|
-
return process.exit(1);
|
|
244
|
-
}
|
|
245
|
-
output.note({
|
|
246
|
-
title: 'Starting an agent for running Nx tasks',
|
|
247
|
-
});
|
|
248
|
-
const defaultRunnerConfig = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default;
|
|
249
|
-
if (defaultRunnerConfig.runner !== '@nrwl/nx-cloud') {
|
|
250
|
-
(0, print_invalid_runner_error_1.printInvalidRunnerError)();
|
|
251
|
-
return process.exit(1);
|
|
252
|
-
}
|
|
253
|
-
const options = defaultRunnerConfig.options;
|
|
254
|
-
const agentName = getAgentName();
|
|
255
|
-
const api = new distributed_agent_api_1.DistributedAgentApi(options, runGroup, agentName);
|
|
256
|
-
createAgentLockfileAndSetUpListeners(api, options, agentName);
|
|
257
|
-
return executeTasks(options, api)
|
|
258
|
-
.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
259
|
-
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
260
|
-
return res;
|
|
261
|
-
}))
|
|
262
|
-
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
263
|
-
yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
|
|
264
|
-
throw e;
|
|
265
|
-
}));
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
exports.startAgent = startAgent;
|
|
269
|
-
//# sourceMappingURL=distributed-agent.impl.js.map
|
|
1
|
+
const a6_0x104a=['reset','status','../../error/print-run-group-error','\x20seconds','CIRCLE_JOB','DistributedAgentApi','executionId','execSync','printRunGroupError','push','SIGINT','join','--configuration=','RUN_GROUP_COMPLETED','criticalErrorMessage','params','runner','cacheableOperations','Agent\x20was\x20terminated\x20via\x20SIGINT','/nx.json','VERBOSE_LOGGING','unlinkSync','../../error/print-cacheable-targets-error','Duplicate\x20Agent\x20ID\x20Detected','map','startAgent','Executing:\x20\x27','done','existsSync','target','NX_AGENT_NAME','forEach','targets','parse','./distributed-agent.api','__awaiter','completeRunGroupWithError','wait','trim','CIRCLE_STAGE','@nrwl/nx-cloud','printCacheableTargetsError','../../error/print-invalid-runner-error','projects','then','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','configuration','next','completedStatusCode','error','retryDuring','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','message','tasksRunnerOptions','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','toString','default','.lock','../../../utilities/nx-imports','../../../utilities/metric-logger','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','No\x20new\x20messages\x20received\x20after\x20','../../../utilities/environment','getTime','getRunGroup','options','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','note','NO_FURTHER_TASKS_TO_RUN','split','random','NO_MESSAGES_TIMEOUT','completed','../../../utilities/create-unchanged-value-timeout','value','readFileSync','defineProperty','number\x20of\x20tasks:\x20','createUnchangedValueTimeout','tasks','API\x20Response','some','executionId:\x20','env','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','true','length','projectName','Distributed\x20Execution\x20Terminated','\x20--projects=','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','includes','inherit','writeFileSync','exit','completed:\x20','readdirSync','getNxCacheDirectory','strip-json-comments','\x20--parallel\x20--max-parallel=','status:\x20','yargs-parser','Agent\x20','ignore','printInvalidRunnerError','taskId','mkdirSync','error:\x20','apply','SIGTERM','CIRCLECI'];(function(_0x12934b,_0x104ad0){const _0x2d1746=function(_0x43d342){while(--_0x43d342){_0x12934b['push'](_0x12934b['shift']());}};_0x2d1746(++_0x104ad0);}(a6_0x104a,0xb2));const a6_0x2d17=function(_0x12934b,_0x104ad0){_0x12934b=_0x12934b-0x0;let _0x2d1746=a6_0x104a[_0x12934b];return _0x2d1746;};'use strict';var __awaiter=this&&this[a6_0x2d17('0x51')]||function(_0x420326,_0x41393f,_0x2e86e3,_0x28e1d3){function _0xaf36b2(_0xdd13e0){return _0xdd13e0 instanceof _0x2e86e3?_0xdd13e0:new _0x2e86e3(function(_0xb2cf29){_0xb2cf29(_0xdd13e0);});}return new(_0x2e86e3||(_0x2e86e3=Promise))(function(_0x44906a,_0x440438){function _0x2f71d2(_0x17147b){try{_0x2b2eae(_0x28e1d3[a6_0x2d17('0x5d')](_0x17147b));}catch(_0x568e8d){_0x440438(_0x568e8d);}}function _0x235a2a(_0x14deee){try{_0x2b2eae(_0x28e1d3['throw'](_0x14deee));}catch(_0x569bf4){_0x440438(_0x569bf4);}}function _0x2b2eae(_0x248dbb){_0x248dbb[a6_0x2d17('0x49')]?_0x44906a(_0x248dbb[a6_0x2d17('0x8')]):_0xaf36b2(_0x248dbb[a6_0x2d17('0x8')])[a6_0x2d17('0x5a')](_0x2f71d2,_0x235a2a);}_0x2b2eae((_0x28e1d3=_0x28e1d3[a6_0x2d17('0x2b')](_0x420326,_0x41393f||[]))['next']());});};Object[a6_0x2d17('0xa')](exports,'__esModule',{'value':!![]});exports[a6_0x2d17('0x47')]=void 0x0;const child_process_1=require('child_process');const fs_1=require('fs');const stripJsonComments=require(a6_0x2d17('0x21'));const yargsParser=require(a6_0x2d17('0x24'));const create_unchanged_value_timeout_1=require(a6_0x2d17('0x7'));const environment_1=require(a6_0x2d17('0x6c'));const metric_logger_1=require(a6_0x2d17('0x69'));const waiter_1=require('../../../utilities/waiter');const print_cacheable_targets_error_1=require(a6_0x2d17('0x44'));const print_invalid_runner_error_1=require(a6_0x2d17('0x58'));const print_run_group_error_1=require(a6_0x2d17('0x30'));const distributed_agent_api_1=require(a6_0x2d17('0x50'));const {output,workspaceRoot}=require(a6_0x2d17('0x68'));const args=yargsParser(process['argv'],{'array':[a6_0x2d17('0x4e')],'default':{}});if(args[a6_0x2d17('0x4e')]&&args[a6_0x2d17('0x4e')][a6_0x2d17('0x14')]===0x1){args[a6_0x2d17('0x4e')]=args[a6_0x2d17('0x4e')][0x0][a6_0x2d17('0x3')](',')[a6_0x2d17('0x46')](_0x5214c0=>_0x5214c0[a6_0x2d17('0x54')]());}function executeTasks(_0x493552,_0x112fed){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x4c3925=0x0;let _0x1f55ef=null;const _0x2a5b85=(0x0,create_unchanged_value_timeout_1[a6_0x2d17('0xc')])({'title':a6_0x2d17('0x6b')+environment_1[a6_0x2d17('0x5')]/0x3e8+a6_0x2d17('0x31'),'timeout':environment_1['NO_MESSAGES_TIMEOUT']});const _0x3efb49=new waiter_1['Waiter']();let _0x100005=[];const _0x5eb32f=new Date();let _0x42734a=![];while(!![]){if(environment_1['VERBOSE_LOGGING']){output[a6_0x2d17('0x1')]({'title':'Fetching\x20tasks...'});}_0x1f55ef=yield _0x112fed[a6_0x2d17('0xd')](_0x1f55ef?_0x1f55ef[a6_0x2d17('0x34')]:null,_0x4c3925,_0x100005,args[a6_0x2d17('0x4e')]);if(environment_1['VERBOSE_LOGGING']){output[a6_0x2d17('0x1')]({'title':a6_0x2d17('0xe'),'bodyLines':[a6_0x2d17('0x1e')+_0x1f55ef[a6_0x2d17('0x6')],a6_0x2d17('0x23')+_0x1f55ef['status'],'retryDuring:\x20'+_0x1f55ef['retryDuring'],a6_0x2d17('0x10')+_0x1f55ef['executionId'],a6_0x2d17('0xb')+_0x1f55ef[a6_0x2d17('0xd')][a6_0x2d17('0x14')],a6_0x2d17('0x2a')+_0x1f55ef['criticalErrorMessage'],'maxParallel:\x20'+_0x1f55ef['maxParallel']]});}if(_0x1f55ef[a6_0x2d17('0x3c')]){output[a6_0x2d17('0x5f')]({'title':a6_0x2d17('0x16'),'bodyLines':['Error:',_0x1f55ef[a6_0x2d17('0x3c')]]});process[a6_0x2d17('0x1d')](0x0);}if((_0x1f55ef===null||_0x1f55ef===void 0x0?void 0x0:_0x1f55ef[a6_0x2d17('0x60')])&&(_0x1f55ef===null||_0x1f55ef===void 0x0?void 0x0:_0x1f55ef[a6_0x2d17('0x60')])!==0x0&&!_0x42734a&&new Date()[a6_0x2d17('0x6d')]()-_0x5eb32f['getTime']()>_0x1f55ef['retryDuring']){yield _0x3efb49[a6_0x2d17('0x53')]();continue;}if((_0x1f55ef===null||_0x1f55ef===void 0x0?void 0x0:_0x1f55ef[a6_0x2d17('0x2f')])!==undefined){if(_0x1f55ef[a6_0x2d17('0x2f')]===a6_0x2d17('0x3b')||_0x1f55ef[a6_0x2d17('0x2f')]===a6_0x2d17('0x2')){return;}}else if(_0x1f55ef['completed']){return;}_0x2a5b85(_0x1f55ef[a6_0x2d17('0xd')][a6_0x2d17('0x46')](_0x56ff40=>_0x56ff40[a6_0x2d17('0x28')])[a6_0x2d17('0x39')](''));if(!_0x1f55ef[a6_0x2d17('0x34')]){if(environment_1['VERBOSE_LOGGING']){output[a6_0x2d17('0x1')]({'title':'Waiting...'});}yield _0x3efb49[a6_0x2d17('0x53')]();_0x4c3925=0x0;_0x100005=[];continue;}_0x3efb49[a6_0x2d17('0x2e')]();_0x42734a=!![];const _0x11f75f=invokeTasksUsingRunMany(_0x493552,_0x1f55ef['executionId'],_0x1f55ef[a6_0x2d17('0xd')],_0x1f55ef['maxParallel']);_0x4c3925=_0x11f75f[a6_0x2d17('0x5e')];_0x100005=_0x11f75f['completedTasks'];}});}function readCompletedTasks(_0x1ada34,_0x51841d){const _0x11b2f7=a6_0x2d17('0x5b')+_0x51841d+a6_0x2d17('0x19');let _0x1ec9ff;try{const _0x7c3a45=(0x0,environment_1[a6_0x2d17('0x20')])(_0x1ada34);const _0x3858ca=_0x7c3a45+'/tasks-hashes-'+_0x51841d;_0x1ec9ff=JSON[a6_0x2d17('0x4f')]((0x0,fs_1[a6_0x2d17('0x9')])(_0x3858ca)[a6_0x2d17('0x65')]());(0x0,fs_1[a6_0x2d17('0x43')])(_0x3858ca);}catch(_0x5181e6){throw new Error(_0x11b2f7);}if(_0x1ec9ff[a6_0x2d17('0x14')]==0x0){throw new Error(_0x11b2f7);}return _0x1ec9ff;}function invokeTasksUsingRunMany(_0x1b2431,_0x586648,_0xaf73c3,_0x341574){let _0x2f49ab=0x0;const _0x534907=[];for(const _0x5e54ca of groupByTarget(_0xaf73c3)){const _0x3daaad=_0x5e54ca[a6_0x2d17('0x5c')]?a6_0x2d17('0x3a')+_0x5e54ca[a6_0x2d17('0x5c')]:'';const _0x592775=_0x341574>0x1?a6_0x2d17('0x22')+_0x341574:'';const _0x5d391e='npx\x20nx\x20run-many\x20--target='+_0x5e54ca[a6_0x2d17('0x4b')]+'\x20'+_0x3daaad+a6_0x2d17('0x17')+_0x5e54ca[a6_0x2d17('0x59')][a6_0x2d17('0x39')](',')+'\x20'+_0x5e54ca[a6_0x2d17('0x3d')]+_0x592775;if(environment_1[a6_0x2d17('0x42')]){output[a6_0x2d17('0x1')]({'title':a6_0x2d17('0x48')+_0x5d391e+'\x27'});}try{(0x0,child_process_1[a6_0x2d17('0x35')])(_0x5d391e,{'stdio':[a6_0x2d17('0x26'),a6_0x2d17('0x1b'),a6_0x2d17('0x1b')],'env':Object['assign'](Object['assign']({},process[a6_0x2d17('0x11')]),{'NX_CACHE_FAILURES':a6_0x2d17('0x13'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x586648,'NX_STREAM_OUTPUT':a6_0x2d17('0x13'),'NX_PREFIX_OUTPUT':a6_0x2d17('0x13')})});_0x534907[a6_0x2d17('0x37')](...readCompletedTasks(_0x1b2431,_0x586648));}catch(_0x56f6c5){if(_0x56f6c5['status']===environment_1[a6_0x2d17('0x18')]){throw _0x56f6c5;}else{_0x2f49ab=0x1;_0x534907[a6_0x2d17('0x37')](...readCompletedTasks(_0x1b2431,_0x586648));}}}return{'completedStatusCode':_0x2f49ab,'completedTasks':_0x534907};}function groupByTarget(_0x53fcee){const _0x52fd27=[];_0x53fcee[a6_0x2d17('0x4d')](_0x53a588=>{const _0x34177b=_0x52fd27['find'](_0x5c7072=>_0x5c7072[a6_0x2d17('0x4b')]===_0x53a588[a6_0x2d17('0x4b')]&&_0x5c7072[a6_0x2d17('0x5c')]===_0x53a588[a6_0x2d17('0x5c')]);if(_0x34177b){_0x34177b[a6_0x2d17('0x59')][a6_0x2d17('0x37')](_0x53a588[a6_0x2d17('0x15')]);}else{_0x52fd27[a6_0x2d17('0x37')]({'target':_0x53a588[a6_0x2d17('0x4b')],'projects':[_0x53a588[a6_0x2d17('0x15')]],'params':_0x53a588[a6_0x2d17('0x3d')],'configuration':_0x53a588['configuration']});}});return _0x52fd27;}function getAgentName(){if(process[a6_0x2d17('0x11')][a6_0x2d17('0x4c')]!==undefined){return process[a6_0x2d17('0x11')][a6_0x2d17('0x4c')];}else if(process[a6_0x2d17('0x11')][a6_0x2d17('0x2d')]!==undefined&&process['env']['CIRCLE_STAGE']){return process[a6_0x2d17('0x11')][a6_0x2d17('0x55')];}else if(process[a6_0x2d17('0x11')][a6_0x2d17('0x2d')]!==undefined&&process[a6_0x2d17('0x11')]['CIRCLE_JOB']){return process[a6_0x2d17('0x11')][a6_0x2d17('0x32')];}else{return a6_0x2d17('0x25')+Math['floor'](Math[a6_0x2d17('0x4')]()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x3b3558,_0x4ebb39,_0x9a58d0){const _0xde00d7=(0x0,environment_1[a6_0x2d17('0x20')])(_0x4ebb39);const _0x2e7cf7=_0xde00d7+'/lockfiles';const _0x3809c7=_0x2e7cf7+'/'+_0x9a58d0+a6_0x2d17('0x67');if(!(0x0,fs_1['existsSync'])(_0x2e7cf7)){(0x0,fs_1[a6_0x2d17('0x29')])(_0x2e7cf7,{'recursive':!![]});}const _0x5f278c=(0x0,fs_1[a6_0x2d17('0x1f')])(_0x2e7cf7);if(_0x5f278c[a6_0x2d17('0x14')]){if(_0x5f278c[a6_0x2d17('0x1a')](_0x9a58d0+a6_0x2d17('0x67'))){output[a6_0x2d17('0x5f')]({'title':a6_0x2d17('0x45'),'bodyLines':['We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','',a6_0x2d17('0x6a')]});process['exit'](0x1);}output['warn']({'title':'Other\x20Nx\x20Cloud\x20Agents\x20Detected','bodyLines':[a6_0x2d17('0x61'),'',a6_0x2d17('0x0'),a6_0x2d17('0x12')]});}(0x0,fs_1[a6_0x2d17('0x1c')])(_0x3809c7,'');process['on']('exit',_0x2c1459=>{cleanupAgentLockfile(_0x3809c7,_0x2c1459);});process['on'](a6_0x2d17('0x2c'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x3b3558['completeRunGroupWithError']('Agent\x20was\x20terminated\x20via\x20SIGTERM');cleanupAgentLockfile(_0x3809c7,0x1);}));process['on'](a6_0x2d17('0x38'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x3b3558['completeRunGroupWithError'](a6_0x2d17('0x40'));cleanupAgentLockfile(_0x3809c7,0x1);}));}function cleanupAgentLockfile(_0x1e5f39,_0xfe9e77){if((0x0,fs_1[a6_0x2d17('0x4a')])(_0x1e5f39)){(0x0,fs_1[a6_0x2d17('0x43')])(_0x1e5f39);process[a6_0x2d17('0x1d')](_0xfe9e77);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x42b4b3=(0x0,environment_1[a6_0x2d17('0x6e')])();if(!_0x42b4b3){(0x0,print_run_group_error_1[a6_0x2d17('0x36')])();return process['exit'](0x1);}if(args[a6_0x2d17('0x4e')]&&args['targets'][a6_0x2d17('0x14')]){output['note']({'title':'Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20['+args['targets'][a6_0x2d17('0x39')](',\x20')+']'});}else{output['note']({'title':a6_0x2d17('0x64')});}const _0xaf2fb=JSON[a6_0x2d17('0x4f')](stripJsonComments((0x0,fs_1['readFileSync'])(workspaceRoot+a6_0x2d17('0x41'))[a6_0x2d17('0x65')]()))[a6_0x2d17('0x63')][a6_0x2d17('0x66')];if(_0xaf2fb[a6_0x2d17('0x3e')]!==a6_0x2d17('0x56')){(0x0,print_invalid_runner_error_1[a6_0x2d17('0x27')])();return process[a6_0x2d17('0x1d')](0x1);}const _0x596158=_0xaf2fb[a6_0x2d17('0x6f')];if(args['targets']&&args[a6_0x2d17('0x4e')][a6_0x2d17('0xf')](_0x15f806=>{var _0x5765a7;return!((_0x5765a7=_0x596158['cacheableOperations'])===null||_0x5765a7===void 0x0?void 0x0:_0x5765a7[a6_0x2d17('0x1a')](_0x15f806));})){const _0x52727a=args[a6_0x2d17('0x4e')]['filter'](_0x1800cf=>{var _0x1b8304;return!((_0x1b8304=_0x596158[a6_0x2d17('0x3f')])===null||_0x1b8304===void 0x0?void 0x0:_0x1b8304[a6_0x2d17('0x1a')](_0x1800cf));});(0x0,print_cacheable_targets_error_1[a6_0x2d17('0x57')])(_0x52727a);return process[a6_0x2d17('0x1d')](0x1);}const _0x465932=getAgentName();const _0x1427e8=new distributed_agent_api_1[(a6_0x2d17('0x33'))](_0x596158,_0x42b4b3,_0x465932);createAgentLockfileAndSetUpListeners(_0x1427e8,_0x596158,_0x465932);return executeTasks(_0x596158,_0x1427e8)[a6_0x2d17('0x5a')](_0x35b515=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1['submitRunMetrics'])(_0x596158);return _0x35b515;}))['catch'](_0x34e09d=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x1427e8[a6_0x2d17('0x52')]('Critical\x20Error\x20in\x20Agent:\x20\x22'+_0x34e09d[a6_0x2d17('0x62')]+'\x22');throw _0x34e09d;}));});}exports[a6_0x2d17('0x47')]=startAgent;
|