@nrwl/nx-cloud 13.0.1-beta.2 → 13.0.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/run-group.api.js +1 -59
- package/lib/core/file-storage/file-storage.js +12 -4
- package/lib/core/file-storage/file-storage.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -120
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -167
- 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-run.api.js +1 -153
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -73
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -239
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -122
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -270
- package/lib/utilities/environment.d.ts +2 -0
- package/lib/utilities/environment.js +3 -1
- package/lib/utilities/environment.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,153 +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 output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
14
|
-
const axios_1 = require("../../../utilities/axios");
|
|
15
|
-
const environment_1 = require("../../../utilities/environment");
|
|
16
|
-
const fs_1 = require("fs");
|
|
17
|
-
const zlib_1 = require("zlib");
|
|
18
|
-
const util_1 = require("util");
|
|
19
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
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
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
|
|
30
|
-
try {
|
|
31
|
-
const request = {
|
|
32
|
-
meta: {
|
|
33
|
-
nxCloudVersion: this.nxCloudVersion(),
|
|
34
|
-
},
|
|
35
|
-
branch: (0, environment_1.getBranch)(),
|
|
36
|
-
runGroup: (0, environment_1.getRunGroup)(),
|
|
37
|
-
distributedExecutionId,
|
|
38
|
-
hashes,
|
|
39
|
-
};
|
|
40
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
41
|
-
output_1.output.note({
|
|
42
|
-
title: 'RunStart',
|
|
43
|
-
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request), environment_1.NUMBER_OF_TRIES);
|
|
47
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
48
|
-
if (resp.data && resp.data.message) {
|
|
49
|
-
this.messages.message = resp.data.message;
|
|
50
|
-
}
|
|
51
|
-
if (!resp.data || !resp.data.urls) {
|
|
52
|
-
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
return resp.data.urls;
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
59
|
-
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
endRun(run, tasks) {
|
|
65
|
-
var _a;
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
// API is not working, don't make the end request
|
|
68
|
-
if (this.messages.apiError)
|
|
69
|
-
return false;
|
|
70
|
-
const uncompressedReqBody = {
|
|
71
|
-
meta: {
|
|
72
|
-
nxCloudVersion: this.nxCloudVersion(),
|
|
73
|
-
},
|
|
74
|
-
tasks,
|
|
75
|
-
run: run,
|
|
76
|
-
machineInfo: this.machineInfo,
|
|
77
|
-
};
|
|
78
|
-
const uncompressedBuffer = Buffer.from(JSON.stringify(uncompressedReqBody));
|
|
79
|
-
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
|
|
80
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
|
|
81
|
-
try {
|
|
82
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
83
|
-
const t = tasks.map((tt) => {
|
|
84
|
-
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
|
|
85
|
-
? `${tt.terminalOutput.slice(0, 20)}...`
|
|
86
|
-
: undefined });
|
|
87
|
-
});
|
|
88
|
-
output_1.output.note({
|
|
89
|
-
title: 'RunEnd. Completed tasks',
|
|
90
|
-
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
|
|
94
|
-
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
|
|
95
|
-
}), environment_1.NUMBER_OF_TRIES);
|
|
96
|
-
if (resp) {
|
|
97
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
98
|
-
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
|
|
99
|
-
this.runContext.runUrl = resp.data.runUrl;
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
if (resp.data && resp.data.status) {
|
|
103
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
|
|
104
|
-
}
|
|
105
|
-
else if (resp.data && typeof resp.data === 'string') {
|
|
106
|
-
if (resp.data !== 'success') {
|
|
107
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
112
|
-
}
|
|
113
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
114
|
-
output_1.output.note({
|
|
115
|
-
title: 'Invalid end run response',
|
|
116
|
-
bodyLines: [JSON.stringify(resp.data, null, 2)],
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
output_1.output.error({
|
|
122
|
-
title: 'Nx Cloud: Unknown Error Occurred',
|
|
123
|
-
bodyLines: [
|
|
124
|
-
'Run completion responded with `undefined`.',
|
|
125
|
-
'Run Details:',
|
|
126
|
-
JSON.stringify(run, null, 2),
|
|
127
|
-
'Stack Trace:',
|
|
128
|
-
JSON.stringify(new Error().stack, null, 2),
|
|
129
|
-
],
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
catch (ee) {
|
|
135
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
136
|
-
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
137
|
-
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
nxCloudVersion() {
|
|
143
|
-
try {
|
|
144
|
-
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
|
|
145
|
-
return v.devDependencies['@nrwl/nx-cloud'];
|
|
146
|
-
}
|
|
147
|
-
catch (e) {
|
|
148
|
-
return 'unknown';
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
exports.CloudRunApi = CloudRunApi;
|
|
153
|
-
//# sourceMappingURL=cloud-run.api.js.map
|
|
1
|
+
const a3_0x145b=['axiosMultipleTries','note','parse','Invalid\x20Nx\x20Cloud\x20response:\x20','value','status','success','apiError','devDependencies','NUMBER_OF_TRIES','apiAxiosInstance','nxCloudVersion','endRun','slice','@nrwl/nx-cloud','message','from','headers','throw','gzip','../../../utilities/metric-logger','...','stringify','urls','createMetricRecorder','VERBOSE_LOGGING','Run\x20Details:','mapRespToPerfEntry','assign','application/octet-stream','post','apply','data','../../../utilities/axios','/nx-cloud/runs/end','RunStart','terminalOutput','string','runContext','readFileSync','Invalid\x20end\x20run\x20response:\x20','map','RUNNER_FAILURE_PERF_ENTRY','runUrl','next','messages','startRun','defaults','unknown','CloudRunApi','RunEnd.\x20Completed\x20tasks','promisify','done','../../../utilities/environment','recordMetric','util','extractErrorMessage','output','api','getRunGroup'];(function(_0x240c60,_0x145b25){const _0x27618e=function(_0x593673){while(--_0x593673){_0x240c60['push'](_0x240c60['shift']());}};_0x27618e(++_0x145b25);}(a3_0x145b,0xfb));const a3_0x2761=function(_0x240c60,_0x145b25){_0x240c60=_0x240c60-0x0;let _0x27618e=a3_0x145b[_0x240c60];return _0x27618e;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x2be6bd,_0x45925b,_0x8763ea,_0xe158e){function _0xe6c2c5(_0x4ef1c0){return _0x4ef1c0 instanceof _0x8763ea?_0x4ef1c0:new _0x8763ea(function(_0x2e03d5){_0x2e03d5(_0x4ef1c0);});}return new(_0x8763ea||(_0x8763ea=Promise))(function(_0x4781de,_0xc41b8){function _0x5d6747(_0x479e3f){try{_0x6ff5f5(_0xe158e[a3_0x2761('0x21')](_0x479e3f));}catch(_0x53a0fd){_0xc41b8(_0x53a0fd);}}function _0x4252fc(_0x49ebee){try{_0x6ff5f5(_0xe158e[a3_0x2761('0x7')](_0x49ebee));}catch(_0x175c36){_0xc41b8(_0x175c36);}}function _0x6ff5f5(_0x109d92){_0x109d92[a3_0x2761('0x29')]?_0x4781de(_0x109d92['value']):_0xe6c2c5(_0x109d92[a3_0x2761('0x35')])['then'](_0x5d6747,_0x4252fc);}_0x6ff5f5((_0xe158e=_0xe158e[a3_0x2761('0x14')](_0x2be6bd,_0x45925b||[]))[a3_0x2761('0x21')]());});};Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a3_0x2761('0x26')]=void 0x0;const output_1=require('@nrwl/workspace/src/utilities/output');const axios_1=require(a3_0x2761('0x16'));const environment_1=require(a3_0x2761('0x2a'));const fs_1=require('fs');const zlib_1=require('zlib');const util_1=require(a3_0x2761('0x2c'));const metric_logger_1=require(a3_0x2761('0x9'));class CloudRunApi{constructor(_0x329c26,_0x249946,_0x1743be,_0x2ea27f){this[a3_0x2761('0x22')]=_0x329c26;this[a3_0x2761('0x1b')]=_0x249946;this['machineInfo']=_0x2ea27f;this[a3_0x2761('0x3b')]=(0x0,axios_1['createApiAxiosInstance'])(_0x1743be);}[a3_0x2761('0x23')](_0x2e421a,_0x33e929){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x135539=(0x0,metric_logger_1[a3_0x2761('0xd')])(a3_0x2761('0x23'));try{const _0x33af8f={'meta':{'nxCloudVersion':this[a3_0x2761('0x0')]()},'branch':(0x0,environment_1['getBranch'])(),'runGroup':(0x0,environment_1[a3_0x2761('0x30')])(),'distributedExecutionId':_0x2e421a,'hashes':_0x33e929};if(environment_1[a3_0x2761('0xe')]){output_1[a3_0x2761('0x2e')][a3_0x2761('0x32')]({'title':a3_0x2761('0x18'),'bodyLines':['\x0a'+JSON[a3_0x2761('0xb')](_0x33af8f,null,0x2)]});}const _0x1a7ea7=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a3_0x2761('0x3b')]['post']('/nx-cloud/runs/start',_0x33af8f),environment_1[a3_0x2761('0x3a')]);_0x135539[a3_0x2761('0x2b')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x1a7ea7));if(_0x1a7ea7[a3_0x2761('0x15')]&&_0x1a7ea7[a3_0x2761('0x15')][a3_0x2761('0x4')]){this[a3_0x2761('0x22')][a3_0x2761('0x4')]=_0x1a7ea7[a3_0x2761('0x15')][a3_0x2761('0x4')];}if(!_0x1a7ea7[a3_0x2761('0x15')]||!_0x1a7ea7[a3_0x2761('0x15')]['urls']){this[a3_0x2761('0x22')][a3_0x2761('0x38')]=a3_0x2761('0x34')+JSON[a3_0x2761('0xb')](_0x1a7ea7[a3_0x2761('0x15')]);return{};}return _0x1a7ea7[a3_0x2761('0x15')][a3_0x2761('0xc')];}catch(_0x1d65bc){_0x135539['recordMetric'](metric_logger_1[a3_0x2761('0x1f')]);this[a3_0x2761('0x22')]['apiError']=this['messages'][a3_0x2761('0x2d')](_0x1d65bc,a3_0x2761('0x2f'));return{};}});}[a3_0x2761('0x1')](_0xb82444,_0xebacea){var _0x4f429b;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x2761('0x22')]['apiError'])return![];const _0x5f43ed={'meta':{'nxCloudVersion':this['nxCloudVersion']()},'tasks':_0xebacea,'run':_0xb82444,'machineInfo':this['machineInfo']};const _0x5c9e42=Buffer[a3_0x2761('0x5')](JSON['stringify'](_0x5f43ed));const _0x53c306=yield(0x0,util_1[a3_0x2761('0x28')])(zlib_1[a3_0x2761('0x8')])(_0x5c9e42);const _0x4a74f4=(0x0,metric_logger_1['createMetricRecorder'])('endRun');try{if(environment_1[a3_0x2761('0xe')]){const _0x40dd92=_0xebacea[a3_0x2761('0x1e')](_0x58767a=>{return Object[a3_0x2761('0x11')](Object[a3_0x2761('0x11')]({},_0x58767a),{'terminalOutput':_0x58767a[a3_0x2761('0x19')]?_0x58767a[a3_0x2761('0x19')][a3_0x2761('0x2')](0x0,0x14)+a3_0x2761('0xa'):undefined});});output_1[a3_0x2761('0x2e')]['note']({'title':a3_0x2761('0x27'),'bodyLines':['\x0a'+JSON[a3_0x2761('0xb')](_0x40dd92,null,0x2)]});}const _0x2f86aa=yield(0x0,axios_1[a3_0x2761('0x31')])(()=>this['apiAxiosInstance'][a3_0x2761('0x13')](a3_0x2761('0x17'),_0x53c306,{'headers':Object[a3_0x2761('0x11')](Object[a3_0x2761('0x11')]({},this['apiAxiosInstance'][a3_0x2761('0x24')][a3_0x2761('0x6')]),{'Content-Encoding':a3_0x2761('0x8'),'Content-Type':a3_0x2761('0x12')})}),environment_1[a3_0x2761('0x3a')]);if(_0x2f86aa){_0x4a74f4[a3_0x2761('0x2b')]((0x0,metric_logger_1[a3_0x2761('0x10')])(_0x2f86aa));if(_0x2f86aa['data']&&_0x2f86aa[a3_0x2761('0x15')][a3_0x2761('0x20')]&&_0x2f86aa['data'][a3_0x2761('0x36')]===a3_0x2761('0x37')){this[a3_0x2761('0x1b')][a3_0x2761('0x20')]=_0x2f86aa[a3_0x2761('0x15')][a3_0x2761('0x20')];return!![];}if(_0x2f86aa[a3_0x2761('0x15')]&&_0x2f86aa[a3_0x2761('0x15')][a3_0x2761('0x36')]){this[a3_0x2761('0x22')][a3_0x2761('0x38')]='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0x2761('0xb')](_0x2f86aa[a3_0x2761('0x15')]['message']);}else if(_0x2f86aa['data']&&typeof _0x2f86aa[a3_0x2761('0x15')]===a3_0x2761('0x1a')){if(_0x2f86aa[a3_0x2761('0x15')]!==a3_0x2761('0x37')){this[a3_0x2761('0x22')][a3_0x2761('0x38')]=a3_0x2761('0x1d')+JSON[a3_0x2761('0xb')](_0x2f86aa[a3_0x2761('0x15')]);}}else{this[a3_0x2761('0x22')]['apiError']=a3_0x2761('0x1d')+JSON['stringify'](_0x2f86aa['data']);}if(environment_1[a3_0x2761('0xe')]){output_1['output'][a3_0x2761('0x32')]({'title':'Invalid\x20end\x20run\x20response','bodyLines':[JSON[a3_0x2761('0xb')](_0x2f86aa['data'],null,0x2)]});}}else{output_1['output']['error']({'title':'Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','bodyLines':['Run\x20completion\x20responded\x20with\x20`undefined`.',a3_0x2761('0xf'),JSON[a3_0x2761('0xb')](_0xb82444,null,0x2),'Stack\x20Trace:',JSON[a3_0x2761('0xb')](new Error()['stack'],null,0x2)]});}return![];}catch(_0x20cc2f){_0x4a74f4['recordMetric'](metric_logger_1[a3_0x2761('0x1f')]);const _0x38cc72=(_0x4f429b=_0x20cc2f['axiosException'])!==null&&_0x4f429b!==void 0x0?_0x4f429b:_0x20cc2f;this[a3_0x2761('0x22')][a3_0x2761('0x38')]=this['messages'][a3_0x2761('0x2d')](_0x38cc72,'api');return![];}});}['nxCloudVersion'](){try{const _0x522c18=JSON[a3_0x2761('0x33')]((0x0,fs_1[a3_0x2761('0x1c')])('package.json')['toString']());return _0x522c18[a3_0x2761('0x39')][a3_0x2761('0x3')];}catch(_0xd0c3a){return a3_0x2761('0x25');}}}exports['CloudRunApi']=CloudRunApi;
|
|
@@ -1,73 +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 output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
14
|
-
const axios_1 = require("../../../utilities/axios");
|
|
15
|
-
const environment_1 = require("../../../utilities/environment");
|
|
16
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
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
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
|
|
26
|
-
try {
|
|
27
|
-
const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
|
|
28
|
-
runGroup: this.runGroup,
|
|
29
|
-
agentName: this.agentName,
|
|
30
|
-
executionId,
|
|
31
|
-
statusCode,
|
|
32
|
-
completedTasks,
|
|
33
|
-
}), 30);
|
|
34
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
|
|
35
|
-
return res.data;
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
39
|
-
throw e;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
completeRunGroupWithError(error) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
46
|
-
output_1.output.note({
|
|
47
|
-
title: 'Completing run group with an error',
|
|
48
|
-
bodyLines: [`runGroup: ${this.runGroup}`, `error: ${error}`],
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
|
|
52
|
-
try {
|
|
53
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
54
|
-
runGroup: this.runGroup,
|
|
55
|
-
agentName: this.agentName,
|
|
56
|
-
criticalErrorMessage: error,
|
|
57
|
-
}), 3);
|
|
58
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
59
|
-
output_1.output.note({
|
|
60
|
-
title: 'Completed run group with an error',
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
67
|
-
console.error(e);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.DistributedAgentApi = DistributedAgentApi;
|
|
73
|
-
//# sourceMappingURL=distributed-agent.api.js.map
|
|
1
|
+
const a4_0x2694=['mapRespToPerfEntry','error','/nx-cloud/executions/complete-run-group','post','dtePollTasks','agentName','__awaiter','next','done','then','axiosMultipleTries','runGroup','Completed\x20run\x20group\x20with\x20an\x20error','throw','Completing\x20run\x20group\x20with\x20an\x20error','tasks','../../../utilities/metric-logger','completeRunGroup','__esModule','recordMetric','../../../utilities/environment','@nrwl/workspace/src/utilities/output','value','apiAxiosInstance','RUNNER_FAILURE_PERF_ENTRY','error:\x20','note','output','data','createMetricRecorder','apply','../../../utilities/axios','DistributedAgentApi'];(function(_0x3c4ece,_0x2694db){const _0xf1333b=function(_0x53226){while(--_0x53226){_0x3c4ece['push'](_0x3c4ece['shift']());}};_0xf1333b(++_0x2694db);}(a4_0x2694,0x161));const a4_0xf133=function(_0x3c4ece,_0x2694db){_0x3c4ece=_0x3c4ece-0x0;let _0xf1333b=a4_0x2694[_0x3c4ece];return _0xf1333b;};'use strict';var __awaiter=this&&this[a4_0xf133('0x10')]||function(_0x53bb56,_0x427bfa,_0x5a8ef0,_0x1552fa){function _0x1959ff(_0x458831){return _0x458831 instanceof _0x5a8ef0?_0x458831:new _0x5a8ef0(function(_0x70da96){_0x70da96(_0x458831);});}return new(_0x5a8ef0||(_0x5a8ef0=Promise))(function(_0x77e82d,_0x4ed07c){function _0x11d616(_0x38d337){try{_0x338cdb(_0x1552fa['next'](_0x38d337));}catch(_0x56c18b){_0x4ed07c(_0x56c18b);}}function _0x31b383(_0x41753e){try{_0x338cdb(_0x1552fa[a4_0xf133('0x17')](_0x41753e));}catch(_0x16b98f){_0x4ed07c(_0x16b98f);}}function _0x338cdb(_0x33c168){_0x33c168[a4_0xf133('0x12')]?_0x77e82d(_0x33c168[a4_0xf133('0x20')]):_0x1959ff(_0x33c168[a4_0xf133('0x20')])[a4_0xf133('0x13')](_0x11d616,_0x31b383);}_0x338cdb((_0x1552fa=_0x1552fa[a4_0xf133('0x7')](_0x53bb56,_0x427bfa||[]))[a4_0xf133('0x11')]());});};Object['defineProperty'](exports,a4_0xf133('0x1c'),{'value':!![]});exports[a4_0xf133('0x9')]=void 0x0;const output_1=require(a4_0xf133('0x1f'));const axios_1=require(a4_0xf133('0x8'));const environment_1=require(a4_0xf133('0x1e'));const metric_logger_1=require(a4_0xf133('0x1a'));class DistributedAgentApi{constructor(_0x4e7b88,_0x42b69b,_0x2bb428){this['runGroup']=_0x42b69b;this[a4_0xf133('0xf')]=_0x2bb428;this[a4_0xf133('0x0')]=(0x0,axios_1['createApiAxiosInstance'])(_0x4e7b88);}[a4_0xf133('0x19')](_0x4d12fd,_0x1beb30,_0x5ad277){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x437577=(0x0,metric_logger_1[a4_0xf133('0x6')])(a4_0xf133('0xe'));try{const _0x16cfb4=yield(0x0,axios_1['axiosMultipleTries'])(()=>this['apiAxiosInstance'][a4_0xf133('0xd')]('/nx-cloud/executions/tasks',{'runGroup':this[a4_0xf133('0x15')],'agentName':this[a4_0xf133('0xf')],'executionId':_0x4d12fd,'statusCode':_0x1beb30,'completedTasks':_0x5ad277}),0x1e);_0x437577[a4_0xf133('0x1d')]((0x0,metric_logger_1[a4_0xf133('0xa')])(_0x16cfb4));return _0x16cfb4[a4_0xf133('0x5')];}catch(_0x124125){_0x437577[a4_0xf133('0x1d')](metric_logger_1[a4_0xf133('0x1')]);throw _0x124125;}});}['completeRunGroupWithError'](_0x2c09df){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1['VERBOSE_LOGGING']){output_1['output'][a4_0xf133('0x3')]({'title':a4_0xf133('0x18'),'bodyLines':['runGroup:\x20'+this[a4_0xf133('0x15')],a4_0xf133('0x2')+_0x2c09df]});}const _0x3f8118=(0x0,metric_logger_1[a4_0xf133('0x6')])(a4_0xf133('0x1b'));try{const _0xb03117=yield(0x0,axios_1[a4_0xf133('0x14')])(()=>this['apiAxiosInstance']['post'](a4_0xf133('0xc'),{'runGroup':this['runGroup'],'agentName':this[a4_0xf133('0xf')],'criticalErrorMessage':_0x2c09df}),0x3);if(environment_1['VERBOSE_LOGGING']){output_1[a4_0xf133('0x4')][a4_0xf133('0x3')]({'title':a4_0xf133('0x16')});}_0x3f8118[a4_0xf133('0x1d')]((0x0,metric_logger_1[a4_0xf133('0xa')])(_0xb03117));}catch(_0x27aa40){_0x3f8118[a4_0xf133('0x1d')](metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);console[a4_0xf133('0xb')](_0x27aa40);}});}}exports['DistributedAgentApi']=DistributedAgentApi;
|
|
@@ -1,239 +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 output_1 = require("@nrwl/workspace/src/utilities/output");
|
|
14
|
-
const child_process_1 = require("child_process");
|
|
15
|
-
const stripJsonComments = require("strip-json-comments");
|
|
16
|
-
const distributed_agent_api_1 = require("./distributed-agent.api");
|
|
17
|
-
const waiter_1 = require("../../../utilities/waiter");
|
|
18
|
-
const environment_1 = require("../../../utilities/environment");
|
|
19
|
-
const print_run_group_error_1 = require("../../error/print-run-group-error");
|
|
20
|
-
const create_no_new_messages_timeout_1 = require("../../../utilities/create-no-new-messages-timeout");
|
|
21
|
-
const fs_1 = require("fs");
|
|
22
|
-
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
23
|
-
function executeTasks(options, api) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
let completedStatusCode = 0;
|
|
26
|
-
let apiResponse = null;
|
|
27
|
-
const failIfSameTasksIn30Mins = (0, create_no_new_messages_timeout_1.createNoNewMessagesTimeout)();
|
|
28
|
-
const waiter = new waiter_1.Waiter();
|
|
29
|
-
let completedTasks = [];
|
|
30
|
-
const startTime = new Date();
|
|
31
|
-
let executedAnyTasks = false;
|
|
32
|
-
while (true) {
|
|
33
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
34
|
-
output_1.output.note({
|
|
35
|
-
title: 'Fetching tasks...',
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks);
|
|
39
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
40
|
-
output_1.output.note({
|
|
41
|
-
title: 'API Response',
|
|
42
|
-
bodyLines: [
|
|
43
|
-
`completed: ${apiResponse.completed}`,
|
|
44
|
-
`retryDuring: ${apiResponse.retryDuring}`,
|
|
45
|
-
`executionId: ${apiResponse.executionId}`,
|
|
46
|
-
`number of tasks: ${apiResponse.tasks.length}`,
|
|
47
|
-
`error: ${apiResponse.criticalErrorMessage}`,
|
|
48
|
-
`maxParallel: ${apiResponse.maxParallel}`,
|
|
49
|
-
],
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (apiResponse.criticalErrorMessage) {
|
|
53
|
-
output_1.output.error({
|
|
54
|
-
title: 'Distributed Execution Terminated',
|
|
55
|
-
bodyLines: ['Error:', apiResponse.criticalErrorMessage],
|
|
56
|
-
});
|
|
57
|
-
process.exit(0);
|
|
58
|
-
}
|
|
59
|
-
// run group is completed but it might be a rerun
|
|
60
|
-
// we will try several times before going further and
|
|
61
|
-
// completed the response
|
|
62
|
-
// we only do it if we haven't executed any tasks
|
|
63
|
-
if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
|
|
64
|
-
(apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
|
|
65
|
-
!executedAnyTasks &&
|
|
66
|
-
new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
|
|
67
|
-
yield waiter.wait();
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (apiResponse.completed)
|
|
71
|
-
return;
|
|
72
|
-
failIfSameTasksIn30Mins(apiResponse.tasks.map((t) => t.taskId).join(''));
|
|
73
|
-
if (!apiResponse.executionId) {
|
|
74
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
75
|
-
output_1.output.note({
|
|
76
|
-
title: 'Waiting...',
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
yield waiter.wait();
|
|
80
|
-
completedStatusCode = 0;
|
|
81
|
-
completedTasks = [];
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
waiter.reset();
|
|
85
|
-
executedAnyTasks = true;
|
|
86
|
-
const r = invokeTasksUsingRunMany(options, apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
|
|
87
|
-
completedStatusCode = r.completedStatusCode;
|
|
88
|
-
completedTasks = r.completedTasks;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
function readCompletedTasks(options, distributedExecutionId) {
|
|
93
|
-
const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
|
|
94
|
-
let completedTasks;
|
|
95
|
-
try {
|
|
96
|
-
const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
|
|
97
|
-
const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
|
|
98
|
-
completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
|
|
99
|
-
// remove it such that if the next command crashes we don't read an obsolete file
|
|
100
|
-
(0, fs_1.unlinkSync)(taskHashesFile);
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
throw new Error(errorMessage);
|
|
104
|
-
}
|
|
105
|
-
if (completedTasks.length == 0) {
|
|
106
|
-
throw new Error(errorMessage);
|
|
107
|
-
}
|
|
108
|
-
return completedTasks;
|
|
109
|
-
}
|
|
110
|
-
function invokeTasksUsingRunMany(options, executionId, tasks, maxParallel) {
|
|
111
|
-
let completedStatusCode = 0;
|
|
112
|
-
const completedTasks = [];
|
|
113
|
-
for (const g of groupByTarget(tasks)) {
|
|
114
|
-
const config = g.configuration ? `--configuration=${g.configuration}` : ``;
|
|
115
|
-
const parallel = maxParallel > 1 ? ` --parallel --max-parallel=${maxParallel}` : ``;
|
|
116
|
-
// TODO use pnpx or yarn when needed
|
|
117
|
-
const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallel}`;
|
|
118
|
-
if (environment_1.VERBOSE_LOGGING) {
|
|
119
|
-
output_1.output.note({
|
|
120
|
-
title: `Executing: '${command}'`,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
(0, child_process_1.execSync)(command, {
|
|
125
|
-
stdio: ['inherit', 'inherit', 'inherit'],
|
|
126
|
-
env: Object.assign(Object.assign({}, process.env), { NX_CACHE_FAILURES: 'true', NX_CLOUD_DISTRIBUTED_EXECUTION_ID: executionId }),
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
catch (e) {
|
|
130
|
-
if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
|
|
131
|
-
throw e;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
completedStatusCode = 1;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
finally {
|
|
138
|
-
completedTasks.push(...readCompletedTasks(options, executionId));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return { completedStatusCode, completedTasks };
|
|
142
|
-
}
|
|
143
|
-
function groupByTarget(tasks) {
|
|
144
|
-
const res = [];
|
|
145
|
-
tasks.forEach((t) => {
|
|
146
|
-
const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
|
|
147
|
-
if (r) {
|
|
148
|
-
r.projects.push(t.projectName);
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
res.push({
|
|
152
|
-
target: t.target,
|
|
153
|
-
projects: [t.projectName],
|
|
154
|
-
params: t.params,
|
|
155
|
-
configuration: t.configuration,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return res;
|
|
160
|
-
}
|
|
161
|
-
function getAgentName() {
|
|
162
|
-
if (process.env.NX_AGENT_NAME !== undefined) {
|
|
163
|
-
return process.env.NX_AGENT_NAME;
|
|
164
|
-
}
|
|
165
|
-
else if (process.env.CIRCLECI !== undefined) {
|
|
166
|
-
return process.env.CIRCLE_STAGE;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
return `Agent ${Math.floor(Math.random() * 100000)}`;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function createAgentLockfile(options, agentName) {
|
|
173
|
-
const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
|
|
174
|
-
const lockFileDirectory = `${cacheDirectory}/lockfiles`;
|
|
175
|
-
const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
|
|
176
|
-
if (!(0, fs_1.existsSync)(lockFileDirectory)) {
|
|
177
|
-
(0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
|
|
178
|
-
}
|
|
179
|
-
// Check for other agents' lockfiles and warn if exist
|
|
180
|
-
const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
|
|
181
|
-
if (lockFiles.length) {
|
|
182
|
-
// Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
|
|
183
|
-
if (lockFiles.includes(`${agentName}.lock`)) {
|
|
184
|
-
output_1.output.error({
|
|
185
|
-
title: 'Duplicate Agent ID Detected',
|
|
186
|
-
bodyLines: [
|
|
187
|
-
'We have detected another agent with this ID running in this workspace. This should not happen.',
|
|
188
|
-
'',
|
|
189
|
-
'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
|
|
190
|
-
],
|
|
191
|
-
});
|
|
192
|
-
process.exit(1);
|
|
193
|
-
}
|
|
194
|
-
output_1.output.warn({
|
|
195
|
-
title: 'Other Nx Cloud Agents Detected',
|
|
196
|
-
bodyLines: [
|
|
197
|
-
'We have detected other agents running in this workspace. This can cause unexpected behavior.',
|
|
198
|
-
'',
|
|
199
|
-
'This can also be a false positive caused by agents that did not shut down correctly.',
|
|
200
|
-
'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
|
|
201
|
-
],
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
(0, fs_1.writeFileSync)(lockFilePath, '');
|
|
205
|
-
process.on('exit', () => cleanupAgentLockfile(lockFilePath));
|
|
206
|
-
process.on('SIGINT', () => cleanupAgentLockfile(lockFilePath));
|
|
207
|
-
}
|
|
208
|
-
function cleanupAgentLockfile(lockFilePath) {
|
|
209
|
-
if ((0, fs_1.existsSync)(lockFilePath)) {
|
|
210
|
-
(0, fs_1.unlinkSync)(lockFilePath);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function startAgent() {
|
|
214
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
-
const runGroup = (0, environment_1.getRunGroup)();
|
|
216
|
-
if (!runGroup) {
|
|
217
|
-
(0, print_run_group_error_1.printRunGroupError)();
|
|
218
|
-
return process.exit(1);
|
|
219
|
-
}
|
|
220
|
-
output_1.output.note({
|
|
221
|
-
title: 'Starting an agent for running Nx tasks',
|
|
222
|
-
});
|
|
223
|
-
const options = JSON.parse(stripJsonComments((0, fs_1.readFileSync)('nx.json').toString())).tasksRunnerOptions.default.options;
|
|
224
|
-
const agentName = getAgentName();
|
|
225
|
-
createAgentLockfile(options, agentName);
|
|
226
|
-
const api = new distributed_agent_api_1.DistributedAgentApi(options, runGroup, agentName);
|
|
227
|
-
return executeTasks(options, api)
|
|
228
|
-
.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
229
|
-
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
230
|
-
return res;
|
|
231
|
-
}))
|
|
232
|
-
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
233
|
-
yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
|
|
234
|
-
throw e;
|
|
235
|
-
}));
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
exports.startAgent = startAgent;
|
|
239
|
-
//# sourceMappingURL=distributed-agent.impl.js.map
|
|
1
|
+
const a5_0x1b52=['error','includes','tasksRunnerOptions','completed','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','NX_AGENT_NAME','push','CIRCLE_STAGE','/lockfiles','projectName','value','retryDuring:\x20','inherit','forEach','params','nx.json','Error:','--configuration=','startAgent','CIRCLECI','parse','completedStatusCode','target','throw','getTime','env','unlinkSync','maxParallel:\x20','exit','../../error/print-run-group-error','@nrwl/workspace/src/utilities/output','toString','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','done','createNoNewMessagesTimeout','completed:\x20','getRunGroup','readFileSync','catch',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','projects','__awaiter','Fetching\x20tasks...','Distributed\x20Execution\x20Terminated','note','find','default','Critical\x20Error\x20in\x20Agent:\x20\x22','executionId:\x20','criticalErrorMessage','../../../utilities/waiter','next','./node_modules/.cache/nx','error:\x20','message','existsSync','configuration','status','\x20--parallel\x20--max-parallel=','wait','completedTasks','length','warn','execSync','maxParallel','VERBOSE_LOGGING','../../../utilities/environment','number\x20of\x20tasks:\x20','SIGINT','completeRunGroupWithError','child_process','executionId','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','defineProperty','../../../utilities/metric-logger','retryDuring','floor','mkdirSync','then','assign','join','Executing:\x20\x27','output','../../../utilities/create-no-new-messages-timeout','submitRunMetrics','true','apply','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','Agent\x20','printRunGroupError','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','cacheDirectory','map','Other\x20Nx\x20Cloud\x20Agents\x20Detected'];(function(_0x4b1a92,_0x1b5232){const _0x1f87a9=function(_0x476dbe){while(--_0x476dbe){_0x4b1a92['push'](_0x4b1a92['shift']());}};_0x1f87a9(++_0x1b5232);}(a5_0x1b52,0x19f));const a5_0x1f87=function(_0x4b1a92,_0x1b5232){_0x4b1a92=_0x4b1a92-0x0;let _0x1f87a9=a5_0x1b52[_0x4b1a92];return _0x1f87a9;};'use strict';var __awaiter=this&&this[a5_0x1f87('0x2')]||function(_0x2ca3b8,_0x363d56,_0x28ee4f,_0x1a1645){function _0x40d55c(_0x3cf3b8){return _0x3cf3b8 instanceof _0x28ee4f?_0x3cf3b8:new _0x28ee4f(function(_0x2d32c9){_0x2d32c9(_0x3cf3b8);});}return new(_0x28ee4f||(_0x28ee4f=Promise))(function(_0xa8a929,_0x4b6d97){function _0x4ff810(_0x1ccd17){try{_0x39d64a(_0x1a1645['next'](_0x1ccd17));}catch(_0x5c461f){_0x4b6d97(_0x5c461f);}}function _0x56cd44(_0x1b3193){try{_0x39d64a(_0x1a1645[a5_0x1f87('0x4e')](_0x1b3193));}catch(_0x1956f4){_0x4b6d97(_0x1956f4);}}function _0x39d64a(_0x5b25cf){_0x5b25cf[a5_0x1f87('0x58')]?_0xa8a929(_0x5b25cf[a5_0x1f87('0x41')]):_0x40d55c(_0x5b25cf['value'])[a5_0x1f87('0x27')](_0x4ff810,_0x56cd44);}_0x39d64a((_0x1a1645=_0x1a1645[a5_0x1f87('0x2f')](_0x2ca3b8,_0x363d56||[]))[a5_0x1f87('0xc')]());});};Object[a5_0x1f87('0x22')](exports,'__esModule',{'value':!![]});exports[a5_0x1f87('0x49')]=void 0x0;const output_1=require(a5_0x1f87('0x55'));const child_process_1=require(a5_0x1f87('0x1f'));const stripJsonComments=require('strip-json-comments');const distributed_agent_api_1=require('./distributed-agent.api');const waiter_1=require(a5_0x1f87('0xb'));const environment_1=require(a5_0x1f87('0x1b'));const print_run_group_error_1=require(a5_0x1f87('0x54'));const create_no_new_messages_timeout_1=require(a5_0x1f87('0x2c'));const fs_1=require('fs');const metric_logger_1=require(a5_0x1f87('0x23'));function executeTasks(_0x287015,_0x1cfee8){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x1ffc20=0x0;let _0x212423=null;const _0x29fb58=(0x0,create_no_new_messages_timeout_1[a5_0x1f87('0x59')])();const _0x32103a=new waiter_1['Waiter']();let _0x504246=[];const _0x965647=new Date();let _0x27572c=![];while(!![]){if(environment_1['VERBOSE_LOGGING']){output_1[a5_0x1f87('0x2b')][a5_0x1f87('0x5')]({'title':a5_0x1f87('0x3')});}_0x212423=yield _0x1cfee8['tasks'](_0x212423?_0x212423['executionId']:null,_0x1ffc20,_0x504246);if(environment_1[a5_0x1f87('0x1a')]){output_1[a5_0x1f87('0x2b')][a5_0x1f87('0x5')]({'title':'API\x20Response','bodyLines':[a5_0x1f87('0x5a')+_0x212423[a5_0x1f87('0x3a')],a5_0x1f87('0x42')+_0x212423['retryDuring'],a5_0x1f87('0x9')+_0x212423[a5_0x1f87('0x20')],a5_0x1f87('0x1c')+_0x212423['tasks'][a5_0x1f87('0x16')],a5_0x1f87('0xe')+_0x212423[a5_0x1f87('0xa')],a5_0x1f87('0x52')+_0x212423[a5_0x1f87('0x19')]]});}if(_0x212423[a5_0x1f87('0xa')]){output_1[a5_0x1f87('0x2b')][a5_0x1f87('0x37')]({'title':a5_0x1f87('0x4'),'bodyLines':[a5_0x1f87('0x47'),_0x212423[a5_0x1f87('0xa')]]});process[a5_0x1f87('0x53')](0x0);}if((_0x212423===null||_0x212423===void 0x0?void 0x0:_0x212423[a5_0x1f87('0x24')])&&(_0x212423===null||_0x212423===void 0x0?void 0x0:_0x212423[a5_0x1f87('0x24')])!==0x0&&!_0x27572c&&new Date()[a5_0x1f87('0x4f')]()-_0x965647[a5_0x1f87('0x4f')]()>_0x212423[a5_0x1f87('0x24')]){yield _0x32103a[a5_0x1f87('0x14')]();continue;}if(_0x212423['completed'])return;_0x29fb58(_0x212423['tasks'][a5_0x1f87('0x35')](_0x1b21e3=>_0x1b21e3['taskId'])[a5_0x1f87('0x29')](''));if(!_0x212423[a5_0x1f87('0x20')]){if(environment_1[a5_0x1f87('0x1a')]){output_1[a5_0x1f87('0x2b')]['note']({'title':'Waiting...'});}yield _0x32103a[a5_0x1f87('0x14')]();_0x1ffc20=0x0;_0x504246=[];continue;}_0x32103a['reset']();_0x27572c=!![];const _0x2648ff=invokeTasksUsingRunMany(_0x287015,_0x212423[a5_0x1f87('0x20')],_0x212423['tasks'],_0x212423[a5_0x1f87('0x19')]);_0x1ffc20=_0x2648ff[a5_0x1f87('0x4c')];_0x504246=_0x2648ff[a5_0x1f87('0x15')];}});}function readCompletedTasks(_0x511771,_0x25b542){const _0x51e372='Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20'+_0x25b542+a5_0x1f87('0x0');let _0x10fe66;try{const _0x329391=_0x511771[a5_0x1f87('0x34')]||a5_0x1f87('0xd');const _0x8f52c4=_0x329391+'/tasks-hashes-'+_0x25b542;_0x10fe66=JSON[a5_0x1f87('0x4b')]((0x0,fs_1[a5_0x1f87('0x5c')])(_0x8f52c4)[a5_0x1f87('0x56')]());(0x0,fs_1[a5_0x1f87('0x51')])(_0x8f52c4);}catch(_0x29a284){throw new Error(_0x51e372);}if(_0x10fe66[a5_0x1f87('0x16')]==0x0){throw new Error(_0x51e372);}return _0x10fe66;}function invokeTasksUsingRunMany(_0x24ca49,_0x246d3c,_0x4b2500,_0x54d9db){let _0xe4b430=0x0;const _0x2c5e74=[];for(const _0x20dcfd of groupByTarget(_0x4b2500)){const _0x3534a1=_0x20dcfd['configuration']?a5_0x1f87('0x48')+_0x20dcfd[a5_0x1f87('0x11')]:'';const _0x39dcc2=_0x54d9db>0x1?a5_0x1f87('0x13')+_0x54d9db:'';const _0x55e2d5='npx\x20nx\x20run-many\x20--target='+_0x20dcfd[a5_0x1f87('0x4d')]+'\x20'+_0x3534a1+'\x20--projects='+_0x20dcfd[a5_0x1f87('0x1')][a5_0x1f87('0x29')](',')+'\x20'+_0x20dcfd[a5_0x1f87('0x45')]+_0x39dcc2;if(environment_1['VERBOSE_LOGGING']){output_1[a5_0x1f87('0x2b')][a5_0x1f87('0x5')]({'title':a5_0x1f87('0x2a')+_0x55e2d5+'\x27'});}try{(0x0,child_process_1[a5_0x1f87('0x18')])(_0x55e2d5,{'stdio':[a5_0x1f87('0x43'),a5_0x1f87('0x43'),a5_0x1f87('0x43')],'env':Object[a5_0x1f87('0x28')](Object[a5_0x1f87('0x28')]({},process[a5_0x1f87('0x50')]),{'NX_CACHE_FAILURES':a5_0x1f87('0x2e'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x246d3c})});}catch(_0x5ed13b){if(_0x5ed13b[a5_0x1f87('0x12')]===environment_1[a5_0x1f87('0x57')]){throw _0x5ed13b;}else{_0xe4b430=0x1;}}finally{_0x2c5e74[a5_0x1f87('0x3d')](...readCompletedTasks(_0x24ca49,_0x246d3c));}}return{'completedStatusCode':_0xe4b430,'completedTasks':_0x2c5e74};}function groupByTarget(_0x4e9c38){const _0x2d8f60=[];_0x4e9c38[a5_0x1f87('0x44')](_0x4cf724=>{const _0x5b7277=_0x2d8f60[a5_0x1f87('0x6')](_0x415bd2=>_0x415bd2['target']===_0x4cf724['target']&&_0x415bd2[a5_0x1f87('0x11')]===_0x4cf724['configuration']);if(_0x5b7277){_0x5b7277['projects']['push'](_0x4cf724[a5_0x1f87('0x40')]);}else{_0x2d8f60[a5_0x1f87('0x3d')]({'target':_0x4cf724[a5_0x1f87('0x4d')],'projects':[_0x4cf724[a5_0x1f87('0x40')]],'params':_0x4cf724[a5_0x1f87('0x45')],'configuration':_0x4cf724[a5_0x1f87('0x11')]});}});return _0x2d8f60;}function getAgentName(){if(process[a5_0x1f87('0x50')][a5_0x1f87('0x3c')]!==undefined){return process[a5_0x1f87('0x50')][a5_0x1f87('0x3c')];}else if(process[a5_0x1f87('0x50')][a5_0x1f87('0x4a')]!==undefined){return process[a5_0x1f87('0x50')][a5_0x1f87('0x3e')];}else{return a5_0x1f87('0x31')+Math[a5_0x1f87('0x25')](Math['random']()*0x186a0);}}function createAgentLockfile(_0x4676be,_0x2c86b9){const _0x508f5b=_0x4676be[a5_0x1f87('0x34')]||'./node_modules/.cache/nx';const _0x47d91a=_0x508f5b+a5_0x1f87('0x3f');const _0x54d864=_0x47d91a+'/'+_0x2c86b9+'.lock';if(!(0x0,fs_1[a5_0x1f87('0x10')])(_0x47d91a)){(0x0,fs_1[a5_0x1f87('0x26')])(_0x47d91a,{'recursive':!![]});}const _0x242413=(0x0,fs_1['readdirSync'])(_0x47d91a);if(_0x242413[a5_0x1f87('0x16')]){if(_0x242413[a5_0x1f87('0x38')](_0x2c86b9+'.lock')){output_1[a5_0x1f87('0x2b')][a5_0x1f87('0x37')]({'title':'Duplicate\x20Agent\x20ID\x20Detected','bodyLines':[a5_0x1f87('0x30'),'','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.']});process[a5_0x1f87('0x53')](0x1);}output_1['output'][a5_0x1f87('0x17')]({'title':a5_0x1f87('0x36'),'bodyLines':[a5_0x1f87('0x3b'),'',a5_0x1f87('0x21'),a5_0x1f87('0x33')]});}(0x0,fs_1['writeFileSync'])(_0x54d864,'');process['on']('exit',()=>cleanupAgentLockfile(_0x54d864));process['on'](a5_0x1f87('0x1d'),()=>cleanupAgentLockfile(_0x54d864));}function cleanupAgentLockfile(_0x55c174){if((0x0,fs_1[a5_0x1f87('0x10')])(_0x55c174)){(0x0,fs_1[a5_0x1f87('0x51')])(_0x55c174);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x2438c5=(0x0,environment_1[a5_0x1f87('0x5b')])();if(!_0x2438c5){(0x0,print_run_group_error_1[a5_0x1f87('0x32')])();return process['exit'](0x1);}output_1[a5_0x1f87('0x2b')][a5_0x1f87('0x5')]({'title':'Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks'});const _0x23c9c0=JSON[a5_0x1f87('0x4b')](stripJsonComments((0x0,fs_1[a5_0x1f87('0x5c')])(a5_0x1f87('0x46'))[a5_0x1f87('0x56')]()))[a5_0x1f87('0x39')][a5_0x1f87('0x7')]['options'];const _0x484c64=getAgentName();createAgentLockfile(_0x23c9c0,_0x484c64);const _0x237b15=new distributed_agent_api_1['DistributedAgentApi'](_0x23c9c0,_0x2438c5,_0x484c64);return executeTasks(_0x23c9c0,_0x237b15)['then'](_0x1705db=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a5_0x1f87('0x2d')])(_0x23c9c0);return _0x1705db;}))[a5_0x1f87('0x5d')](_0x29fc11=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x237b15[a5_0x1f87('0x1e')](a5_0x1f87('0x8')+_0x29fc11[a5_0x1f87('0xf')]+'\x22');throw _0x29fc11;}));});}exports[a5_0x1f87('0x49')]=startAgent;
|