@nrwl/nx-cloud 15.1.0-beta0 → 15.1.1
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/nx-cloud-tasks-runner.js +7 -1
- package/lib/nx-cloud-tasks-runner.js.map +1 -1
- 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_0x90b6=['devDependencies','axiosException','message','then','recordMetric','status','RunEnd\x20duration','data','value','startRun','throw','unknown','nxCloudVersion','assign','defineProperty','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','apply','messages','package.json','RunStart\x20duration','axiosMultipleTries','stringify','post','api','terminalOutput','apiError','defaults','success','string','../../../utilities/metric-logger','getRunGroup','endRun','mapRespToPerfEntry','../../../utilities/axios','stack','next','Run\x20completion\x20responded\x20with\x20`undefined`.','gzip','apiAxiosInstance','...','createReqBody','from','CloudRunApi','RUNNER_FAILURE_PERF_ENTRY','__awaiter','Invalid\x20end\x20run\x20response','createApiAxiosInstance','../../../utilities/nx-imports','@nrwl/nx-cloud','slice','response','/nx-cloud/runs/start','runUrl','RunEnd.\x20Completed\x20tasks','Stack\x20Trace:','note','zlib','parse','length','map','Run\x20Details:','Invalid\x20end\x20run\x20response:\x20','application/octet-stream','/nx-cloud/runs/end','urls','runContext','Invalid\x20Nx\x20Cloud\x20response:\x20','createMetricRecorder','machineInfo','util','VERBOSE_LOGGING','headers','error'];(function(_0x5ebd3c,_0x90b683){const _0x4266f8=function(_0x2c5836){while(--_0x2c5836){_0x5ebd3c['push'](_0x5ebd3c['shift']());}};_0x4266f8(++_0x90b683);}(a3_0x90b6,0x1f2));const a3_0x4266=function(_0x5ebd3c,_0x90b683){_0x5ebd3c=_0x5ebd3c-0x0;let _0x4266f8=a3_0x90b6[_0x5ebd3c];return _0x4266f8;};'use strict';var __awaiter=this&&this[a3_0x4266('0x39')]||function(_0xbb0b9,_0x2beaf6,_0x27c278,_0x5ec4af){function _0x2d7c5e(_0x1947f1){return _0x1947f1 instanceof _0x27c278?_0x1947f1:new _0x27c278(function(_0x56d7c6){_0x56d7c6(_0x1947f1);});}return new(_0x27c278||(_0x27c278=Promise))(function(_0x30f71e,_0x113088){function _0xe392e1(_0x2c36ef){try{_0xe2d5d5(_0x5ec4af[a3_0x4266('0x30')](_0x2c36ef));}catch(_0x2e1b61){_0x113088(_0x2e1b61);}}function _0x61c7ba(_0x2f5bc2){try{_0xe2d5d5(_0x5ec4af[a3_0x4266('0x17')](_0x2f5bc2));}catch(_0x4f39d8){_0x113088(_0x4f39d8);}}function _0xe2d5d5(_0x2b3eb6){_0x2b3eb6['done']?_0x30f71e(_0x2b3eb6[a3_0x4266('0x15')]):_0x2d7c5e(_0x2b3eb6['value'])[a3_0x4266('0x10')](_0xe392e1,_0x61c7ba);}_0xe2d5d5((_0x5ec4af=_0x5ec4af[a3_0x4266('0x1d')](_0xbb0b9,_0x2beaf6||[]))[a3_0x4266('0x30')]());});};Object[a3_0x4266('0x1b')](exports,'__esModule',{'value':!![]});exports['CloudRunApi']=void 0x0;const axios_1=require(a3_0x4266('0x2e'));const environment_1=require('../../../utilities/environment');const fs_1=require('fs');const zlib_1=require(a3_0x4266('0x45'));const util_1=require(a3_0x4266('0x9'));const metric_logger_1=require(a3_0x4266('0x2a'));const {output}=require(a3_0x4266('0x3c'));class CloudRunApi{constructor(_0xcdee2d,_0x289dd4,_0x2d2ce4,_0x1b9a20){this[a3_0x4266('0x1e')]=_0xcdee2d;this[a3_0x4266('0x5')]=_0x289dd4;this[a3_0x4266('0x8')]=_0x1b9a20;this[a3_0x4266('0x33')]=(0x0,axios_1[a3_0x4266('0x3b')])(_0x2d2ce4);}[a3_0x4266('0x16')](_0x1b0de6,_0x4f5142){var _0x2479d9;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x15d08b=(0x0,metric_logger_1[a3_0x4266('0x7')])(a3_0x4266('0x16'));try{const _0x2c71a6={'meta':{'nxCloudVersion':this[a3_0x4266('0x19')]()},'branch':(0x0,environment_1['getBranch'])(),'runGroup':(0x0,environment_1[a3_0x4266('0x2b')])(),'distributedExecutionId':_0x1b0de6,'hashes':_0x4f5142};if(environment_1['VERBOSE_LOGGING']){output['note']({'title':'RunStart','bodyLines':['\x0a'+JSON[a3_0x4266('0x22')](_0x2c71a6,null,0x2)]});}const _0x1b21e6=yield(0x0,axios_1['printDuration'])(a3_0x4266('0x20'),()=>(0x0,axios_1[a3_0x4266('0x21')])(()=>this[a3_0x4266('0x33')][a3_0x4266('0x23')](a3_0x4266('0x40'),_0x2c71a6)));_0x15d08b[a3_0x4266('0x11')]((0x0,metric_logger_1[a3_0x4266('0x2d')])(_0x1b21e6));if(_0x1b21e6[a3_0x4266('0x14')]&&_0x1b21e6[a3_0x4266('0x14')][a3_0x4266('0xf')]){this['messages'][a3_0x4266('0xf')]=_0x1b21e6[a3_0x4266('0x14')][a3_0x4266('0xf')];}if(!_0x1b21e6['data']||!_0x1b21e6[a3_0x4266('0x14')][a3_0x4266('0x4')]){this[a3_0x4266('0x1e')][a3_0x4266('0x26')]=a3_0x4266('0x6')+JSON[a3_0x4266('0x22')](_0x1b21e6['data']);return{};}return _0x1b21e6[a3_0x4266('0x14')]['urls'];}catch(_0x29ca08){_0x15d08b[a3_0x4266('0x11')](((_0x2479d9=_0x29ca08===null||_0x29ca08===void 0x0?void 0x0:_0x29ca08['axiosException'])===null||_0x2479d9===void 0x0?void 0x0:_0x2479d9[a3_0x4266('0x3f')])?(0x0,metric_logger_1[a3_0x4266('0x2d')])(_0x29ca08[a3_0x4266('0xe')]['response']):metric_logger_1[a3_0x4266('0x38')]);this[a3_0x4266('0x1e')][a3_0x4266('0x26')]=this[a3_0x4266('0x1e')]['extractErrorMessage'](_0x29ca08,a3_0x4266('0x24'));return{};}});}[a3_0x4266('0x35')](_0x1b9218,_0x5ef53b,_0x2dcb2e){const _0x5c5589={'meta':{'nxCloudVersion':this[a3_0x4266('0x19')]()},'tasks':_0x5ef53b,'run':_0x1b9218,'linkId':_0x2dcb2e,'machineInfo':this[a3_0x4266('0x8')]};return JSON[a3_0x4266('0x22')](_0x5c5589);}[a3_0x4266('0x2c')](_0xecded2,_0x4af0cf,_0x28dd4d){var _0x44ee79,_0x6c7fd6;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x4266('0x1e')][a3_0x4266('0x26')])return![];let _0x4e8228=this[a3_0x4266('0x35')](_0xecded2,_0x4af0cf,_0x28dd4d);if(_0x4e8228[a3_0x4266('0x47')]>0x14*0x3e8*0x3e8){_0x4e8228=this['createReqBody'](_0xecded2,_0x4af0cf['map'](_0x1c3d6b=>Object[a3_0x4266('0x1a')](Object[a3_0x4266('0x1a')]({},_0x1c3d6b),{'hashDetails':undefined})));}const _0x1e3a1c=Buffer[a3_0x4266('0x36')](_0x4e8228);const _0x3640cc=yield(0x0,util_1['promisify'])(zlib_1[a3_0x4266('0x32')])(_0x1e3a1c);const _0x2b371f=(0x0,metric_logger_1[a3_0x4266('0x7')])(a3_0x4266('0x2c'));try{if(environment_1[a3_0x4266('0xa')]){const _0x563a8c=_0x4af0cf[a3_0x4266('0x48')](_0x16bb70=>{return Object[a3_0x4266('0x1a')](Object[a3_0x4266('0x1a')]({},_0x16bb70),{'terminalOutput':_0x16bb70[a3_0x4266('0x25')]?_0x16bb70['terminalOutput'][a3_0x4266('0x3e')](0x0,0x14)+a3_0x4266('0x34'):undefined});});output['note']({'title':a3_0x4266('0x42'),'bodyLines':['\x0a'+JSON[a3_0x4266('0x22')](_0x563a8c,null,0x2)]});}const _0x2bb891=yield(0x0,axios_1['printDuration'])(a3_0x4266('0x13'),()=>(0x0,axios_1[a3_0x4266('0x21')])(()=>this['apiAxiosInstance'][a3_0x4266('0x23')](a3_0x4266('0x3'),_0x3640cc,{'headers':Object[a3_0x4266('0x1a')](Object[a3_0x4266('0x1a')]({},this[a3_0x4266('0x33')][a3_0x4266('0x27')][a3_0x4266('0xb')]),{'Content-Encoding':a3_0x4266('0x32'),'Content-Type':a3_0x4266('0x2')})})));if(_0x2bb891){_0x2b371f['recordMetric']((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x2bb891));if(_0x2bb891[a3_0x4266('0x14')]&&_0x2bb891['data'][a3_0x4266('0x41')]&&_0x2bb891[a3_0x4266('0x14')]['status']===a3_0x4266('0x28')){this[a3_0x4266('0x5')][a3_0x4266('0x41')]=_0x2bb891['data'][a3_0x4266('0x41')];return!![];}if(_0x2bb891[a3_0x4266('0x14')]&&_0x2bb891[a3_0x4266('0x14')][a3_0x4266('0x12')]){this[a3_0x4266('0x1e')][a3_0x4266('0x26')]=a3_0x4266('0x1')+JSON[a3_0x4266('0x22')](_0x2bb891[a3_0x4266('0x14')]['message']);}else if(_0x2bb891[a3_0x4266('0x14')]&&typeof _0x2bb891['data']===a3_0x4266('0x29')){if(_0x2bb891['data']!==a3_0x4266('0x28')){this[a3_0x4266('0x1e')][a3_0x4266('0x26')]=a3_0x4266('0x1')+JSON[a3_0x4266('0x22')](_0x2bb891[a3_0x4266('0x14')]);}}else{this[a3_0x4266('0x1e')][a3_0x4266('0x26')]='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0x4266('0x22')](_0x2bb891[a3_0x4266('0x14')]);}if(environment_1['VERBOSE_LOGGING']){output[a3_0x4266('0x44')]({'title':a3_0x4266('0x3a'),'bodyLines':[JSON[a3_0x4266('0x22')](_0x2bb891[a3_0x4266('0x14')],null,0x2)]});}}else{output[a3_0x4266('0xc')]({'title':a3_0x4266('0x1c'),'bodyLines':[a3_0x4266('0x31'),a3_0x4266('0x0'),JSON[a3_0x4266('0x22')](_0xecded2,null,0x2),a3_0x4266('0x43'),JSON[a3_0x4266('0x22')](new Error()[a3_0x4266('0x2f')],null,0x2)]});}return![];}catch(_0x5361ae){_0x2b371f[a3_0x4266('0x11')](((_0x44ee79=_0x5361ae===null||_0x5361ae===void 0x0?void 0x0:_0x5361ae[a3_0x4266('0xe')])===null||_0x44ee79===void 0x0?void 0x0:_0x44ee79[a3_0x4266('0x3f')])?(0x0,metric_logger_1[a3_0x4266('0x2d')])(_0x5361ae[a3_0x4266('0xe')][a3_0x4266('0x3f')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);const _0x2bb394=(_0x6c7fd6=_0x5361ae[a3_0x4266('0xe')])!==null&&_0x6c7fd6!==void 0x0?_0x6c7fd6:_0x5361ae;this[a3_0x4266('0x1e')][a3_0x4266('0x26')]=this[a3_0x4266('0x1e')]['extractErrorMessage'](_0x2bb394,'api');return![];}});}['nxCloudVersion'](){try{const _0x281461=JSON[a3_0x4266('0x46')]((0x0,fs_1['readFileSync'])(a3_0x4266('0x1f'))['toString']());return _0x281461[a3_0x4266('0xd')][a3_0x4266('0x3d')];}catch(_0x4071b4){return a3_0x4266('0x18');}}}exports[a3_0x4266('0x37')]=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_0x10af=['length','generateUniqueLinkId','random','defineProperty','__esModule','toLowerCase','ABCDEFGHIJKLMNOPQRSTUVWXYZ','0123456789','floor'];(function(_0x33cf49,_0x10af8b){const _0x9828bd=function(_0x2e4f09){while(--_0x2e4f09){_0x33cf49['push'](_0x33cf49['shift']());}};_0x9828bd(++_0x10af8b);}(a4_0x10af,0x13d));const a4_0x9828=function(_0x33cf49,_0x10af8b){_0x33cf49=_0x33cf49-0x0;let _0x9828bd=a4_0x10af[_0x33cf49];return _0x9828bd;};'use strict';Object[a4_0x9828('0x1')](exports,a4_0x9828('0x2'),{'value':!![]});exports[a4_0x9828('0x8')]=void 0x0;const upper=a4_0x9828('0x4');const digits=a4_0x9828('0x5');const lower=upper[a4_0x9828('0x3')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x3181a3='';for(let _0x27f379=0x0;_0x27f379<0xa;++_0x27f379){_0x3181a3+=alphanum[Math[a4_0x9828('0x6')](Math[a4_0x9828('0x0')]()*alphanum[a4_0x9828('0x7')])];}return _0x3181a3;}exports[a4_0x9828('0x8')]=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_0x1e05=['runGroup:\x20','createApiAxiosInstance','runGroup','response','completeRunGroup','apply','axiosMultipleTries','error:\x20','agentName','note','__esModule','then','error','recordMetric','VERBOSE_LOGGING','apiAxiosInstance','dtePollTasks','createMetricRecorder','../../../utilities/metric-logger','throw','completeRunGroupWithError','axiosException','Completed\x20run\x20group\x20with\x20an\x20error','/nx-cloud/executions/tasks','value','Completing\x20run\x20group\x20with\x20an\x20error','next','post','tasks','../../../utilities/nx-imports','DistributedAgentApi','RUNNER_FAILURE_PERF_ENTRY','mapRespToPerfEntry','defineProperty'];(function(_0x7d0624,_0x1e0501){const _0x4c4ac8=function(_0x5c2499){while(--_0x5c2499){_0x7d0624['push'](_0x7d0624['shift']());}};_0x4c4ac8(++_0x1e0501);}(a5_0x1e05,0x84));const a5_0x4c4a=function(_0x7d0624,_0x1e0501){_0x7d0624=_0x7d0624-0x0;let _0x4c4ac8=a5_0x1e05[_0x7d0624];return _0x4c4ac8;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x462060,_0x2aa9d8,_0x598f12,_0x45c9f3){function _0xf9db1f(_0x4c1a0d){return _0x4c1a0d instanceof _0x598f12?_0x4c1a0d:new _0x598f12(function(_0x427a35){_0x427a35(_0x4c1a0d);});}return new(_0x598f12||(_0x598f12=Promise))(function(_0x50aa45,_0x406fa9){function _0x1075a5(_0x4db932){try{_0x53aff4(_0x45c9f3[a5_0x4c4a('0x1e')](_0x4db932));}catch(_0x207cfe){_0x406fa9(_0x207cfe);}}function _0x1113aa(_0x5e284d){try{_0x53aff4(_0x45c9f3[a5_0x4c4a('0x17')](_0x5e284d));}catch(_0x70c9a7){_0x406fa9(_0x70c9a7);}}function _0x53aff4(_0x3647e7){_0x3647e7['done']?_0x50aa45(_0x3647e7[a5_0x4c4a('0x1c')]):_0xf9db1f(_0x3647e7[a5_0x4c4a('0x1c')])[a5_0x4c4a('0xf')](_0x1075a5,_0x1113aa);}_0x53aff4((_0x45c9f3=_0x45c9f3[a5_0x4c4a('0x9')](_0x462060,_0x2aa9d8||[]))[a5_0x4c4a('0x1e')]());});};Object[a5_0x4c4a('0x3')](exports,a5_0x4c4a('0xe'),{'value':!![]});exports['DistributedAgentApi']=void 0x0;const axios_1=require('../../../utilities/axios');const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a5_0x4c4a('0x16'));const {output}=require(a5_0x4c4a('0x21'));class DistributedAgentApi{constructor(_0x487178,_0x44973d,_0x2aca11){this['runGroup']=_0x44973d;this['agentName']=_0x2aca11;this['apiAxiosInstance']=(0x0,axios_1[a5_0x4c4a('0x5')])(_0x487178);}[a5_0x4c4a('0x20')](_0x2b0556,_0x1826ac,_0x130426,_0x1f227d){var _0x5c59f8;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1789a5=(0x0,metric_logger_1[a5_0x4c4a('0x15')])(a5_0x4c4a('0x14'));try{const _0xb6ec7=yield(0x0,axios_1[a5_0x4c4a('0xa')])(()=>this['apiAxiosInstance'][a5_0x4c4a('0x1f')](a5_0x4c4a('0x1b'),{'runGroup':this[a5_0x4c4a('0x6')],'agentName':this[a5_0x4c4a('0xc')],'executionId':_0x2b0556,'statusCode':_0x1826ac,'completedTasks':_0x130426,'targets':_0x1f227d}));_0x1789a5[a5_0x4c4a('0x11')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0xb6ec7));return _0xb6ec7['data'];}catch(_0x1eafb9){_0x1789a5[a5_0x4c4a('0x11')](((_0x5c59f8=_0x1eafb9===null||_0x1eafb9===void 0x0?void 0x0:_0x1eafb9[a5_0x4c4a('0x19')])===null||_0x5c59f8===void 0x0?void 0x0:_0x5c59f8['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x1eafb9[a5_0x4c4a('0x19')]['response']):metric_logger_1[a5_0x4c4a('0x1')]);throw _0x1eafb9;}});}[a5_0x4c4a('0x18')](_0x31ffc8){var _0xb1ce6;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a5_0x4c4a('0x12')]){output[a5_0x4c4a('0xd')]({'title':a5_0x4c4a('0x1d'),'bodyLines':[a5_0x4c4a('0x4')+this[a5_0x4c4a('0x6')],a5_0x4c4a('0xb')+_0x31ffc8]});}const _0x452460=(0x0,metric_logger_1[a5_0x4c4a('0x15')])(a5_0x4c4a('0x8'));try{const _0x514d43=yield(0x0,axios_1[a5_0x4c4a('0xa')])(()=>this[a5_0x4c4a('0x13')][a5_0x4c4a('0x1f')]('/nx-cloud/executions/complete-run-group',{'runGroup':this['runGroup'],'agentName':this[a5_0x4c4a('0xc')],'criticalErrorMessage':_0x31ffc8}));if(environment_1[a5_0x4c4a('0x12')]){output[a5_0x4c4a('0xd')]({'title':a5_0x4c4a('0x1a')});}_0x452460[a5_0x4c4a('0x11')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x514d43));}catch(_0x3bc2fe){_0x452460[a5_0x4c4a('0x11')](((_0xb1ce6=_0x3bc2fe===null||_0x3bc2fe===void 0x0?void 0x0:_0x3bc2fe[a5_0x4c4a('0x19')])===null||_0xb1ce6===void 0x0?void 0x0:_0xb1ce6[a5_0x4c4a('0x7')])?(0x0,metric_logger_1[a5_0x4c4a('0x2')])(_0x3bc2fe[a5_0x4c4a('0x19')][a5_0x4c4a('0x7')]):metric_logger_1[a5_0x4c4a('0x1')]);console[a5_0x4c4a('0x10')](_0x3bc2fe);}});}}exports[a5_0x4c4a('0x0')]=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_0x1aa3=['value','../../error/print-run-group-error','completed','NO_MESSAGES_TIMEOUT','Fetching\x20tasks...','strip-json-comments','retryDuring','maxParallel:\x20','printCacheableTargetsError','includes','target','join','status','find','VERBOSE_LOGGING','executionId','RUN_GROUP_COMPLETED','reset','map','CIRCLE_JOB','No\x20new\x20messages\x20received\x20after\x20','../../../utilities/create-unchanged-value-timeout','length','NO_FURTHER_TASKS_TO_RUN','/lockfiles','CIRCLE_STAGE','../../../utilities/environment','printInvalidRunnerError','inherit','__esModule','number\x20of\x20tasks:\x20','options','Critical\x20Error\x20in\x20Agent:\x20\x22','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','Error:','message','note','writeFileSync','API\x20Response','params','tasksRunnerOptions','__awaiter','retryDuring:\x20','forEach','mkdirSync','toString','configuration','then','split','startAgent','../../error/print-invalid-runner-error','getRunGroup','warn','npx\x20nx\x20run-many\x20--target=','tasks','getTime','readFileSync','@nrwl/nx-cloud','getNxCacheDirectory','completeRunGroupWithError','\x20--projects=','SIGTERM','trim','CIRCLECI','Waiter','execSync','taskId','runner','push','ignore','parse','DistributedAgentApi','submitRunMetrics','done','true','Duplicate\x20Agent\x20ID\x20Detected','catch','maxParallel','apply','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','defineProperty','floor',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','exit','Agent\x20','error:\x20','assign','executionId:\x20','existsSync','throw','argv','SIGINT','completedTasks','cacheableOperations','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','criticalErrorMessage','wait','error','env','filter','../../error/print-cacheable-targets-error','Other\x20Nx\x20Cloud\x20Agents\x20Detected','status:\x20','next','Waiting...','./distributed-agent.api','unlinkSync','targets','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','.lock','../../../utilities/waiter','projectName','../../../utilities/nx-imports','NX_AGENT_NAME'];(function(_0x416217,_0x1aa3e9){const _0x365e13=function(_0x171e7a){while(--_0x171e7a){_0x416217['push'](_0x416217['shift']());}};_0x365e13(++_0x1aa3e9);}(a6_0x1aa3,0x176));const a6_0x365e=function(_0x416217,_0x1aa3e9){_0x416217=_0x416217-0x0;let _0x365e13=a6_0x1aa3[_0x416217];return _0x365e13;};'use strict';var __awaiter=this&&this[a6_0x365e('0xc')]||function(_0x23c3b0,_0x229aad,_0x31a380,_0x550722){function _0x9a692(_0x2db42b){return _0x2db42b instanceof _0x31a380?_0x2db42b:new _0x31a380(function(_0x346eee){_0x346eee(_0x2db42b);});}return new(_0x31a380||(_0x31a380=Promise))(function(_0x4d80b6,_0x536e3e){function _0x57d0c9(_0x1b4649){try{_0x3d12da(_0x550722['next'](_0x1b4649));}catch(_0x2d323b){_0x536e3e(_0x2d323b);}}function _0x2d2134(_0x333d12){try{_0x3d12da(_0x550722[a6_0x365e('0x3c')](_0x333d12));}catch(_0x16c77e){_0x536e3e(_0x16c77e);}}function _0x3d12da(_0xf33706){_0xf33706[a6_0x365e('0x2c')]?_0x4d80b6(_0xf33706[a6_0x365e('0x56')]):_0x9a692(_0xf33706[a6_0x365e('0x56')])[a6_0x365e('0x12')](_0x57d0c9,_0x2d2134);}_0x3d12da((_0x550722=_0x550722[a6_0x365e('0x31')](_0x23c3b0,_0x229aad||[]))[a6_0x365e('0x4a')]());});};Object[a6_0x365e('0x33')](exports,a6_0x365e('0x0'),{'value':!![]});exports['startAgent']=void 0x0;const child_process_1=require('child_process');const fs_1=require('fs');const stripJsonComments=require(a6_0x365e('0x5b'));const yargsParser=require('yargs-parser');const create_unchanged_value_timeout_1=require(a6_0x365e('0x6b'));const environment_1=require(a6_0x365e('0x70'));const metric_logger_1=require('../../../utilities/metric-logger');const waiter_1=require(a6_0x365e('0x52'));const print_cacheable_targets_error_1=require(a6_0x365e('0x47'));const print_invalid_runner_error_1=require(a6_0x365e('0x15'));const print_run_group_error_1=require(a6_0x365e('0x57'));const distributed_agent_api_1=require(a6_0x365e('0x4c'));const {output,workspaceRoot}=require(a6_0x365e('0x54'));const args=yargsParser(process[a6_0x365e('0x3d')],{'array':[a6_0x365e('0x4e')],'default':{}});if(args['targets']&&args[a6_0x365e('0x4e')][a6_0x365e('0x6c')]===0x1){args['targets']=args[a6_0x365e('0x4e')][0x0][a6_0x365e('0x13')](',')[a6_0x365e('0x68')](_0x3f29ef=>_0x3f29ef[a6_0x365e('0x21')]());}function executeTasks(_0x47bef3,_0x32b766){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x345e83=0x0;let _0x45cd5e=null;const _0x4d1718=(0x0,create_unchanged_value_timeout_1['createUnchangedValueTimeout'])({'title':a6_0x365e('0x6a')+environment_1[a6_0x365e('0x59')]/0x3e8+'\x20seconds','timeout':environment_1[a6_0x365e('0x59')]});const _0x19172e=new waiter_1[(a6_0x365e('0x23'))]();let _0x6ad5e9=[];const _0x780762=new Date();let _0x1db747=![];while(!![]){if(environment_1['VERBOSE_LOGGING']){output[a6_0x365e('0x7')]({'title':a6_0x365e('0x5a')});}_0x45cd5e=yield _0x32b766['tasks'](_0x45cd5e?_0x45cd5e['executionId']:null,_0x345e83,_0x6ad5e9,args[a6_0x365e('0x4e')]);if(environment_1[a6_0x365e('0x64')]){output['note']({'title':a6_0x365e('0x9'),'bodyLines':['completed:\x20'+_0x45cd5e[a6_0x365e('0x58')],a6_0x365e('0x49')+_0x45cd5e[a6_0x365e('0x62')],a6_0x365e('0xd')+_0x45cd5e['retryDuring'],a6_0x365e('0x3a')+_0x45cd5e[a6_0x365e('0x65')],a6_0x365e('0x1')+_0x45cd5e[a6_0x365e('0x19')][a6_0x365e('0x6c')],a6_0x365e('0x38')+_0x45cd5e['criticalErrorMessage'],a6_0x365e('0x5d')+_0x45cd5e[a6_0x365e('0x30')]]});}if(_0x45cd5e[a6_0x365e('0x42')]){output[a6_0x365e('0x44')]({'title':'Distributed\x20Execution\x20Terminated','bodyLines':[a6_0x365e('0x5'),_0x45cd5e[a6_0x365e('0x42')]]});process[a6_0x365e('0x36')](0x0);}if((_0x45cd5e===null||_0x45cd5e===void 0x0?void 0x0:_0x45cd5e['retryDuring'])&&(_0x45cd5e===null||_0x45cd5e===void 0x0?void 0x0:_0x45cd5e[a6_0x365e('0x5c')])!==0x0&&!_0x1db747&&new Date()[a6_0x365e('0x1a')]()-_0x780762[a6_0x365e('0x1a')]()>_0x45cd5e[a6_0x365e('0x5c')]){yield _0x19172e[a6_0x365e('0x43')]();continue;}if((_0x45cd5e===null||_0x45cd5e===void 0x0?void 0x0:_0x45cd5e['status'])!==undefined){if(_0x45cd5e[a6_0x365e('0x62')]===a6_0x365e('0x66')||_0x45cd5e['status']===a6_0x365e('0x6d')){return;}}else if(_0x45cd5e['completed']){return;}_0x4d1718(_0x45cd5e['tasks'][a6_0x365e('0x68')](_0x4fd68f=>_0x4fd68f[a6_0x365e('0x25')])['join'](''));if(!_0x45cd5e['executionId']){if(environment_1[a6_0x365e('0x64')]){output[a6_0x365e('0x7')]({'title':a6_0x365e('0x4b')});}yield _0x19172e[a6_0x365e('0x43')]();_0x345e83=0x0;_0x6ad5e9=[];continue;}_0x19172e[a6_0x365e('0x67')]();_0x1db747=!![];const _0x2aff9c=invokeTasksUsingRunMany(_0x47bef3,_0x45cd5e[a6_0x365e('0x65')],_0x45cd5e[a6_0x365e('0x19')],_0x45cd5e[a6_0x365e('0x30')]);_0x345e83=_0x2aff9c['completedStatusCode'];_0x6ad5e9=_0x2aff9c[a6_0x365e('0x3f')];}});}function readCompletedTasks(_0x1aef13,_0x536691){const _0x220018=a6_0x365e('0x32')+_0x536691+a6_0x365e('0x35');let _0x16e65e;try{const _0x56dc41=(0x0,environment_1['getNxCacheDirectory'])(_0x1aef13);const _0x412d1d=_0x56dc41+'/tasks-hashes-'+_0x536691;_0x16e65e=JSON[a6_0x365e('0x29')]((0x0,fs_1[a6_0x365e('0x1b')])(_0x412d1d)[a6_0x365e('0x10')]());(0x0,fs_1[a6_0x365e('0x4d')])(_0x412d1d);}catch(_0xd228a9){throw new Error(_0x220018);}if(_0x16e65e[a6_0x365e('0x6c')]==0x0){throw new Error(_0x220018);}return _0x16e65e;}function invokeTasksUsingRunMany(_0x187aad,_0x58c44c,_0x54bdec,_0x1ccc5c){let _0x4975f8=0x0;const _0x1b6de5=[];for(const _0x5588d6 of groupByTarget(_0x54bdec)){const _0x2ff291=_0x5588d6[a6_0x365e('0x11')]?'--configuration='+_0x5588d6['configuration']:'';const _0x5328d5=_0x1ccc5c>0x1?'\x20--parallel\x20--max-parallel='+_0x1ccc5c:'';const _0x4fce29=a6_0x365e('0x18')+_0x5588d6[a6_0x365e('0x60')]+'\x20'+_0x2ff291+a6_0x365e('0x1f')+_0x5588d6['projects'][a6_0x365e('0x61')](',')+'\x20'+_0x5588d6[a6_0x365e('0xa')]+_0x5328d5;if(environment_1['VERBOSE_LOGGING']){output['note']({'title':'Executing:\x20\x27'+_0x4fce29+'\x27'});}try{(0x0,child_process_1[a6_0x365e('0x24')])(_0x4fce29,{'stdio':[a6_0x365e('0x28'),a6_0x365e('0x72'),a6_0x365e('0x72')],'env':Object[a6_0x365e('0x39')](Object[a6_0x365e('0x39')]({},process['env']),{'NX_CACHE_FAILURES':a6_0x365e('0x2d'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x58c44c,'NX_STREAM_OUTPUT':a6_0x365e('0x2d'),'NX_PREFIX_OUTPUT':a6_0x365e('0x2d')})});_0x1b6de5['push'](...readCompletedTasks(_0x187aad,_0x58c44c));}catch(_0x2b66d2){if(_0x2b66d2['status']===environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']){throw _0x2b66d2;}else{_0x4975f8=0x1;_0x1b6de5['push'](...readCompletedTasks(_0x187aad,_0x58c44c));}}}return{'completedStatusCode':_0x4975f8,'completedTasks':_0x1b6de5};}function groupByTarget(_0x3cb56a){const _0xda7bae=[];_0x3cb56a[a6_0x365e('0xe')](_0x3dc6ce=>{const _0x582691=_0xda7bae[a6_0x365e('0x63')](_0x539fc8=>_0x539fc8[a6_0x365e('0x60')]===_0x3dc6ce[a6_0x365e('0x60')]&&_0x539fc8[a6_0x365e('0x11')]===_0x3dc6ce[a6_0x365e('0x11')]);if(_0x582691){_0x582691['projects'][a6_0x365e('0x27')](_0x3dc6ce['projectName']);}else{_0xda7bae[a6_0x365e('0x27')]({'target':_0x3dc6ce['target'],'projects':[_0x3dc6ce[a6_0x365e('0x53')]],'params':_0x3dc6ce['params'],'configuration':_0x3dc6ce[a6_0x365e('0x11')]});}});return _0xda7bae;}function getAgentName(){if(process[a6_0x365e('0x45')][a6_0x365e('0x55')]!==undefined){return process['env'][a6_0x365e('0x55')];}else if(process[a6_0x365e('0x45')][a6_0x365e('0x22')]!==undefined&&process[a6_0x365e('0x45')][a6_0x365e('0x6f')]){return process['env']['CIRCLE_STAGE'];}else if(process[a6_0x365e('0x45')][a6_0x365e('0x22')]!==undefined&&process[a6_0x365e('0x45')]['CIRCLE_JOB']){return process['env'][a6_0x365e('0x69')];}else{return a6_0x365e('0x37')+Math[a6_0x365e('0x34')](Math['random']()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x8f5b,_0x5adaa3,_0x451eba){const _0x5b29b9=(0x0,environment_1[a6_0x365e('0x1d')])(_0x5adaa3);const _0x51a3e4=_0x5b29b9+a6_0x365e('0x6e');const _0x4a6040=_0x51a3e4+'/'+_0x451eba+a6_0x365e('0x51');if(!(0x0,fs_1[a6_0x365e('0x3b')])(_0x51a3e4)){(0x0,fs_1[a6_0x365e('0xf')])(_0x51a3e4,{'recursive':!![]});}const _0x55ac89=(0x0,fs_1['readdirSync'])(_0x51a3e4);if(_0x55ac89[a6_0x365e('0x6c')]){if(_0x55ac89[a6_0x365e('0x5f')](_0x451eba+a6_0x365e('0x51'))){output[a6_0x365e('0x44')]({'title':a6_0x365e('0x2e'),'bodyLines':[a6_0x365e('0x41'),'',a6_0x365e('0x4')]});process['exit'](0x1);}output[a6_0x365e('0x17')]({'title':a6_0x365e('0x48'),'bodyLines':[a6_0x365e('0x4f'),'',a6_0x365e('0x50'),'If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.']});}(0x0,fs_1[a6_0x365e('0x8')])(_0x4a6040,'');process['on']('exit',_0x19dc26=>{cleanupAgentLockfile(_0x4a6040,_0x19dc26);});process['on'](a6_0x365e('0x20'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x8f5b['completeRunGroupWithError']('Agent\x20was\x20terminated\x20via\x20SIGTERM');cleanupAgentLockfile(_0x4a6040,0x1);}));process['on'](a6_0x365e('0x3e'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x8f5b['completeRunGroupWithError']('Agent\x20was\x20terminated\x20via\x20SIGINT');cleanupAgentLockfile(_0x4a6040,0x1);}));}function cleanupAgentLockfile(_0x2ee76c,_0x157954){if((0x0,fs_1[a6_0x365e('0x3b')])(_0x2ee76c)){(0x0,fs_1[a6_0x365e('0x4d')])(_0x2ee76c);process[a6_0x365e('0x36')](_0x157954);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x70d990=(0x0,environment_1[a6_0x365e('0x16')])();if(!_0x70d990){(0x0,print_run_group_error_1['printRunGroupError'])();return process[a6_0x365e('0x36')](0x1);}if(args[a6_0x365e('0x4e')]&&args[a6_0x365e('0x4e')][a6_0x365e('0x6c')]){output[a6_0x365e('0x7')]({'title':'Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20['+args[a6_0x365e('0x4e')][a6_0x365e('0x61')](',\x20')+']'});}else{output['note']({'title':'Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks'});}const _0x53fcbb=JSON[a6_0x365e('0x29')](stripJsonComments((0x0,fs_1[a6_0x365e('0x1b')])(workspaceRoot+'/nx.json')[a6_0x365e('0x10')]()))[a6_0x365e('0xb')]['default'];if(_0x53fcbb[a6_0x365e('0x26')]!==a6_0x365e('0x1c')){(0x0,print_invalid_runner_error_1[a6_0x365e('0x71')])();return process['exit'](0x1);}const _0x57e695=_0x53fcbb[a6_0x365e('0x2')];if(args['targets']&&args[a6_0x365e('0x4e')]['some'](_0x5f45c2=>{var _0x52e453;return!((_0x52e453=_0x57e695[a6_0x365e('0x40')])===null||_0x52e453===void 0x0?void 0x0:_0x52e453[a6_0x365e('0x5f')](_0x5f45c2));})){const _0x4939fc=args[a6_0x365e('0x4e')][a6_0x365e('0x46')](_0x2470de=>{var _0x26e400;return!((_0x26e400=_0x57e695[a6_0x365e('0x40')])===null||_0x26e400===void 0x0?void 0x0:_0x26e400['includes'](_0x2470de));});(0x0,print_cacheable_targets_error_1[a6_0x365e('0x5e')])(_0x4939fc);return process[a6_0x365e('0x36')](0x1);}const _0xad1e7d=getAgentName();const _0x4995b4=new distributed_agent_api_1[(a6_0x365e('0x2a'))](_0x57e695,_0x70d990,_0xad1e7d);createAgentLockfileAndSetUpListeners(_0x4995b4,_0x57e695,_0xad1e7d);return executeTasks(_0x57e695,_0x4995b4)[a6_0x365e('0x12')](_0x26a698=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a6_0x365e('0x2b')])(_0x57e695);return _0x26a698;}))[a6_0x365e('0x2f')](_0x4e2d6e=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x4995b4[a6_0x365e('0x1e')](a6_0x365e('0x3')+_0x4e2d6e[a6_0x365e('0x6')]+'\x22');throw _0x4e2d6e;}));});}exports[a6_0x365e('0x14')]=startAgent;
|