@nrwl/nx-cloud 14.1.3-beta.2 → 14.1.3

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.
@@ -1,166 +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.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.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) {
68
- const uncompressedReqBody = {
69
- meta: {
70
- nxCloudVersion: this.nxCloudVersion(),
71
- },
72
- tasks,
73
- run: run,
74
- machineInfo: this.machineInfo,
75
- };
76
- return JSON.stringify(uncompressedReqBody);
77
- }
78
- endRun(run, tasks) {
79
- var _a, _b;
80
- return __awaiter(this, void 0, void 0, function* () {
81
- // API is not working, don't make the end request
82
- if (this.messages.apiError)
83
- return false;
84
- let uncompressedBodyString = this.createReqBody(run, tasks);
85
- // if the req body is > 20mb, remove hashDetails
86
- if (uncompressedBodyString.length > 20 * 1000 * 1000) {
87
- uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))));
88
- }
89
- const uncompressedBuffer = Buffer.from(uncompressedBodyString);
90
- const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
91
- const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
92
- try {
93
- if (environment_1.VERBOSE_LOGGING) {
94
- const t = tasks.map((tt) => {
95
- return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
96
- ? `${tt.terminalOutput.slice(0, 20)}...`
97
- : undefined });
98
- });
99
- output.note({
100
- title: 'RunEnd. Completed tasks',
101
- bodyLines: ['\n' + JSON.stringify(t, null, 2)],
102
- });
103
- }
104
- const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
105
- headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
106
- }));
107
- if (resp) {
108
- recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
109
- if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
110
- this.runContext.runUrl = resp.data.runUrl;
111
- return true;
112
- }
113
- if (resp.data && resp.data.status) {
114
- this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
115
- }
116
- else if (resp.data && typeof resp.data === 'string') {
117
- if (resp.data !== 'success') {
118
- this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
119
- }
120
- }
121
- else {
122
- this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
123
- }
124
- if (environment_1.VERBOSE_LOGGING) {
125
- output.note({
126
- title: 'Invalid end run response',
127
- bodyLines: [JSON.stringify(resp.data, null, 2)],
128
- });
129
- }
130
- }
131
- else {
132
- output.error({
133
- title: 'Nx Cloud: Unknown Error Occurred',
134
- bodyLines: [
135
- 'Run completion responded with `undefined`.',
136
- 'Run Details:',
137
- JSON.stringify(run, null, 2),
138
- 'Stack Trace:',
139
- JSON.stringify(new Error().stack, null, 2),
140
- ],
141
- });
142
- }
143
- return false;
144
- }
145
- catch (ee) {
146
- recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
147
- ? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
148
- : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
149
- const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
150
- this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
151
- return false;
152
- }
153
- });
154
- }
155
- nxCloudVersion() {
156
- try {
157
- const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
158
- return v.devDependencies['@nrwl/nx-cloud'];
159
- }
160
- catch (e) {
161
- return 'unknown';
162
- }
163
- }
164
- }
165
- exports.CloudRunApi = CloudRunApi;
166
- //# sourceMappingURL=cloud-run.api.js.map
1
+ const a3_0x437c=['error','application/octet-stream','note','headers','runContext','gzip','createMetricRecorder','axiosMultipleTries','apiAxiosInstance','RunEnd.\x20Completed\x20tasks','length','zlib','done','machineInfo','messages','message','RunStart','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','../../../utilities/nx-imports','terminalOutput','stack','../../../utilities/environment','recordMetric','apiError','success','VERBOSE_LOGGING','apply','string','post','stringify','api','next','axiosException','Invalid\x20end\x20run\x20response','defaults','urls','map','__awaiter','endRun','parse','unknown','Stack\x20Trace:','mapRespToPerfEntry','data','runUrl','throw','Run\x20completion\x20responded\x20with\x20`undefined`.','Run\x20Details:','response','Invalid\x20end\x20run\x20response:\x20','../../../utilities/axios','value','then','util','extractErrorMessage','defineProperty','CloudRunApi','assign','RUNNER_FAILURE_PERF_ENTRY','...','createReqBody','status','promisify','nxCloudVersion','from','/nx-cloud/runs/end'];(function(_0x1b6ad2,_0x437cb8){const _0x2b7e84=function(_0xb05a69){while(--_0xb05a69){_0x1b6ad2['push'](_0x1b6ad2['shift']());}};_0x2b7e84(++_0x437cb8);}(a3_0x437c,0xd7));const a3_0x2b7e=function(_0x1b6ad2,_0x437cb8){_0x1b6ad2=_0x1b6ad2-0x0;let _0x2b7e84=a3_0x437c[_0x1b6ad2];return _0x2b7e84;};'use strict';var __awaiter=this&&this[a3_0x2b7e('0x14')]||function(_0x1353b8,_0x4ed12a,_0x22b105,_0xa730a7){function _0x1249f9(_0x4b613d){return _0x4b613d instanceof _0x22b105?_0x4b613d:new _0x22b105(function(_0x5d31bd){_0x5d31bd(_0x4b613d);});}return new(_0x22b105||(_0x22b105=Promise))(function(_0x230085,_0x18ec55){function _0x153c80(_0x1fb52a){try{_0x1910d6(_0xa730a7[a3_0x2b7e('0xe')](_0x1fb52a));}catch(_0x4be4cd){_0x18ec55(_0x4be4cd);}}function _0x2331f2(_0x560f27){try{_0x1910d6(_0xa730a7[a3_0x2b7e('0x1c')](_0x560f27));}catch(_0xa3581e){_0x18ec55(_0xa3581e);}}function _0x1910d6(_0x1c650d){_0x1c650d[a3_0x2b7e('0x3d')]?_0x230085(_0x1c650d[a3_0x2b7e('0x22')]):_0x1249f9(_0x1c650d['value'])[a3_0x2b7e('0x23')](_0x153c80,_0x2331f2);}_0x1910d6((_0xa730a7=_0xa730a7[a3_0x2b7e('0x9')](_0x1353b8,_0x4ed12a||[]))[a3_0x2b7e('0xe')]());});};Object[a3_0x2b7e('0x26')](exports,'__esModule',{'value':!![]});exports[a3_0x2b7e('0x27')]=void 0x0;const axios_1=require(a3_0x2b7e('0x21'));const environment_1=require(a3_0x2b7e('0x4'));const fs_1=require('fs');const zlib_1=require(a3_0x2b7e('0x3c'));const util_1=require(a3_0x2b7e('0x24'));const metric_logger_1=require('../../../utilities/metric-logger');const {output}=require(a3_0x2b7e('0x1'));class CloudRunApi{constructor(_0x22e88c,_0x3d6c10,_0x2d4466,_0x51efb9){this[a3_0x2b7e('0x3f')]=_0x22e88c;this[a3_0x2b7e('0x35')]=_0x3d6c10;this[a3_0x2b7e('0x3e')]=_0x51efb9;this[a3_0x2b7e('0x39')]=(0x0,axios_1['createApiAxiosInstance'])(_0x2d4466);}['startRun'](_0xdf19aa,_0x2bc3ec){var _0x273fe9;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x52f9b4=(0x0,metric_logger_1['createMetricRecorder'])('startRun');try{const _0x53ca5c={'meta':{'nxCloudVersion':this[a3_0x2b7e('0x2e')]()},'branch':(0x0,environment_1['getBranch'])(),'runGroup':(0x0,environment_1['getRunGroup'])(),'distributedExecutionId':_0xdf19aa,'hashes':_0x2bc3ec};if(environment_1[a3_0x2b7e('0x8')]){output[a3_0x2b7e('0x33')]({'title':a3_0x2b7e('0x41'),'bodyLines':['\x0a'+JSON['stringify'](_0x53ca5c,null,0x2)]});}const _0x1505f1=yield(0x0,axios_1[a3_0x2b7e('0x38')])(()=>this[a3_0x2b7e('0x39')][a3_0x2b7e('0xb')]('/nx-cloud/runs/start',_0x53ca5c));_0x52f9b4['recordMetric']((0x0,metric_logger_1[a3_0x2b7e('0x19')])(_0x1505f1));if(_0x1505f1[a3_0x2b7e('0x1a')]&&_0x1505f1[a3_0x2b7e('0x1a')][a3_0x2b7e('0x40')]){this['messages'][a3_0x2b7e('0x40')]=_0x1505f1['data'][a3_0x2b7e('0x40')];}if(!_0x1505f1[a3_0x2b7e('0x1a')]||!_0x1505f1['data'][a3_0x2b7e('0x12')]){this['messages'][a3_0x2b7e('0x6')]='Invalid\x20Nx\x20Cloud\x20response:\x20'+JSON[a3_0x2b7e('0xc')](_0x1505f1['data']);return{};}return _0x1505f1[a3_0x2b7e('0x1a')][a3_0x2b7e('0x12')];}catch(_0x1d12c9){_0x52f9b4['recordMetric'](((_0x273fe9=_0x1d12c9===null||_0x1d12c9===void 0x0?void 0x0:_0x1d12c9['axiosException'])===null||_0x273fe9===void 0x0?void 0x0:_0x273fe9[a3_0x2b7e('0x1f')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x1d12c9[a3_0x2b7e('0xf')][a3_0x2b7e('0x1f')]):metric_logger_1[a3_0x2b7e('0x29')]);this[a3_0x2b7e('0x3f')][a3_0x2b7e('0x6')]=this[a3_0x2b7e('0x3f')][a3_0x2b7e('0x25')](_0x1d12c9,'api');return{};}});}['createReqBody'](_0x3a6c4a,_0x19c775){const _0x5af0c0={'meta':{'nxCloudVersion':this[a3_0x2b7e('0x2e')]()},'tasks':_0x19c775,'run':_0x3a6c4a,'machineInfo':this[a3_0x2b7e('0x3e')]};return JSON[a3_0x2b7e('0xc')](_0x5af0c0);}[a3_0x2b7e('0x15')](_0x2972a3,_0x18e541){var _0x14dbad,_0xac0824;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x2b7e('0x3f')]['apiError'])return![];let _0x4c8eea=this[a3_0x2b7e('0x2b')](_0x2972a3,_0x18e541);if(_0x4c8eea[a3_0x2b7e('0x3b')]>0x14*0x3e8*0x3e8){_0x4c8eea=this[a3_0x2b7e('0x2b')](_0x2972a3,_0x18e541['map'](_0x3cffbf=>Object['assign'](Object[a3_0x2b7e('0x28')]({},_0x3cffbf),{'hashDetails':undefined})));}const _0x4ddd40=Buffer[a3_0x2b7e('0x2f')](_0x4c8eea);const _0x587a68=yield(0x0,util_1[a3_0x2b7e('0x2d')])(zlib_1['gzip'])(_0x4ddd40);const _0x5e9728=(0x0,metric_logger_1[a3_0x2b7e('0x37')])('endRun');try{if(environment_1['VERBOSE_LOGGING']){const _0x2c3760=_0x18e541[a3_0x2b7e('0x13')](_0x39318a=>{return Object[a3_0x2b7e('0x28')](Object[a3_0x2b7e('0x28')]({},_0x39318a),{'terminalOutput':_0x39318a[a3_0x2b7e('0x2')]?_0x39318a[a3_0x2b7e('0x2')]['slice'](0x0,0x14)+a3_0x2b7e('0x2a'):undefined});});output[a3_0x2b7e('0x33')]({'title':a3_0x2b7e('0x3a'),'bodyLines':['\x0a'+JSON[a3_0x2b7e('0xc')](_0x2c3760,null,0x2)]});}const _0xb2cac4=yield(0x0,axios_1[a3_0x2b7e('0x38')])(()=>this[a3_0x2b7e('0x39')][a3_0x2b7e('0xb')](a3_0x2b7e('0x30'),_0x587a68,{'headers':Object[a3_0x2b7e('0x28')](Object[a3_0x2b7e('0x28')]({},this[a3_0x2b7e('0x39')][a3_0x2b7e('0x11')][a3_0x2b7e('0x34')]),{'Content-Encoding':a3_0x2b7e('0x36'),'Content-Type':a3_0x2b7e('0x32')})}));if(_0xb2cac4){_0x5e9728[a3_0x2b7e('0x5')]((0x0,metric_logger_1[a3_0x2b7e('0x19')])(_0xb2cac4));if(_0xb2cac4[a3_0x2b7e('0x1a')]&&_0xb2cac4['data'][a3_0x2b7e('0x1b')]&&_0xb2cac4[a3_0x2b7e('0x1a')][a3_0x2b7e('0x2c')]===a3_0x2b7e('0x7')){this['runContext'][a3_0x2b7e('0x1b')]=_0xb2cac4['data'][a3_0x2b7e('0x1b')];return!![];}if(_0xb2cac4['data']&&_0xb2cac4['data']['status']){this[a3_0x2b7e('0x3f')][a3_0x2b7e('0x6')]=a3_0x2b7e('0x20')+JSON[a3_0x2b7e('0xc')](_0xb2cac4[a3_0x2b7e('0x1a')][a3_0x2b7e('0x40')]);}else if(_0xb2cac4[a3_0x2b7e('0x1a')]&&typeof _0xb2cac4[a3_0x2b7e('0x1a')]===a3_0x2b7e('0xa')){if(_0xb2cac4[a3_0x2b7e('0x1a')]!==a3_0x2b7e('0x7')){this[a3_0x2b7e('0x3f')][a3_0x2b7e('0x6')]=a3_0x2b7e('0x20')+JSON[a3_0x2b7e('0xc')](_0xb2cac4[a3_0x2b7e('0x1a')]);}}else{this[a3_0x2b7e('0x3f')][a3_0x2b7e('0x6')]=a3_0x2b7e('0x20')+JSON['stringify'](_0xb2cac4[a3_0x2b7e('0x1a')]);}if(environment_1[a3_0x2b7e('0x8')]){output[a3_0x2b7e('0x33')]({'title':a3_0x2b7e('0x10'),'bodyLines':[JSON[a3_0x2b7e('0xc')](_0xb2cac4['data'],null,0x2)]});}}else{output[a3_0x2b7e('0x31')]({'title':a3_0x2b7e('0x0'),'bodyLines':[a3_0x2b7e('0x1d'),a3_0x2b7e('0x1e'),JSON[a3_0x2b7e('0xc')](_0x2972a3,null,0x2),a3_0x2b7e('0x18'),JSON[a3_0x2b7e('0xc')](new Error()[a3_0x2b7e('0x3')],null,0x2)]});}return![];}catch(_0x20808e){_0x5e9728[a3_0x2b7e('0x5')](((_0x14dbad=_0x20808e===null||_0x20808e===void 0x0?void 0x0:_0x20808e[a3_0x2b7e('0xf')])===null||_0x14dbad===void 0x0?void 0x0:_0x14dbad[a3_0x2b7e('0x1f')])?(0x0,metric_logger_1[a3_0x2b7e('0x19')])(_0x20808e[a3_0x2b7e('0xf')][a3_0x2b7e('0x1f')]):metric_logger_1[a3_0x2b7e('0x29')]);const _0x288585=(_0xac0824=_0x20808e[a3_0x2b7e('0xf')])!==null&&_0xac0824!==void 0x0?_0xac0824:_0x20808e;this[a3_0x2b7e('0x3f')][a3_0x2b7e('0x6')]=this[a3_0x2b7e('0x3f')][a3_0x2b7e('0x25')](_0x288585,a3_0x2b7e('0xd'));return![];}});}[a3_0x2b7e('0x2e')](){try{const _0x428cbf=JSON[a3_0x2b7e('0x16')]((0x0,fs_1['readFileSync'])('package.json')['toString']());return _0x428cbf['devDependencies']['@nrwl/nx-cloud'];}catch(_0x57b1a7){return a3_0x2b7e('0x17');}}}exports[a3_0x2b7e('0x27')]=CloudRunApi;
@@ -1,79 +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.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 a4_0x435d=['defineProperty','axiosException','value','completeRunGroupWithError','../../../utilities/axios','VERBOSE_LOGGING','/nx-cloud/executions/complete-run-group','/nx-cloud/executions/tasks','axiosMultipleTries','recordMetric','__esModule','RUNNER_FAILURE_PERF_ENTRY','mapRespToPerfEntry','response','error','runGroup','createApiAxiosInstance','runGroup:\x20','throw','then','apply','agentName','__awaiter','Completed\x20run\x20group\x20with\x20an\x20error','../../../utilities/environment','next','apiAxiosInstance','Completing\x20run\x20group\x20with\x20an\x20error','error:\x20','post','../../../utilities/metric-logger','createMetricRecorder'];(function(_0x3dfbfb,_0x435d79){const _0x481092=function(_0x32febb){while(--_0x32febb){_0x3dfbfb['push'](_0x3dfbfb['shift']());}};_0x481092(++_0x435d79);}(a4_0x435d,0x168));const a4_0x4810=function(_0x3dfbfb,_0x435d79){_0x3dfbfb=_0x3dfbfb-0x0;let _0x481092=a4_0x435d[_0x3dfbfb];return _0x481092;};'use strict';var __awaiter=this&&this[a4_0x4810('0xe')]||function(_0xf11018,_0x5aece3,_0x4193c0,_0x51488c){function _0x1af1c1(_0x1d39cc){return _0x1d39cc instanceof _0x4193c0?_0x1d39cc:new _0x4193c0(function(_0x56956f){_0x56956f(_0x1d39cc);});}return new(_0x4193c0||(_0x4193c0=Promise))(function(_0x6da967,_0x1c461f){function _0x3d4a8c(_0x2cd96d){try{_0x44a50c(_0x51488c[a4_0x4810('0x11')](_0x2cd96d));}catch(_0x58e60c){_0x1c461f(_0x58e60c);}}function _0x531da2(_0x5069b3){try{_0x44a50c(_0x51488c[a4_0x4810('0xa')](_0x5069b3));}catch(_0x10bbc6){_0x1c461f(_0x10bbc6);}}function _0x44a50c(_0xd3fd55){_0xd3fd55['done']?_0x6da967(_0xd3fd55[a4_0x4810('0x1a')]):_0x1af1c1(_0xd3fd55['value'])[a4_0x4810('0xb')](_0x3d4a8c,_0x531da2);}_0x44a50c((_0x51488c=_0x51488c[a4_0x4810('0xc')](_0xf11018,_0x5aece3||[]))[a4_0x4810('0x11')]());});};Object[a4_0x4810('0x18')](exports,a4_0x4810('0x2'),{'value':!![]});exports['DistributedAgentApi']=void 0x0;const axios_1=require(a4_0x4810('0x1c'));const environment_1=require(a4_0x4810('0x10'));const metric_logger_1=require(a4_0x4810('0x16'));const {output}=require('../../../utilities/nx-imports');class DistributedAgentApi{constructor(_0x53fbec,_0x1f99cf,_0xc1b928){this[a4_0x4810('0x7')]=_0x1f99cf;this[a4_0x4810('0xd')]=_0xc1b928;this[a4_0x4810('0x12')]=(0x0,axios_1[a4_0x4810('0x8')])(_0x53fbec);}['tasks'](_0x797f73,_0x323f6d,_0xf9693a){var _0x318d12;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x38fd82=(0x0,metric_logger_1['createMetricRecorder'])('dtePollTasks');try{const _0x5ba231=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a4_0x4810('0x12')][a4_0x4810('0x15')](a4_0x4810('0x1f'),{'runGroup':this['runGroup'],'agentName':this[a4_0x4810('0xd')],'executionId':_0x797f73,'statusCode':_0x323f6d,'completedTasks':_0xf9693a}));_0x38fd82['recordMetric']((0x0,metric_logger_1[a4_0x4810('0x4')])(_0x5ba231));return _0x5ba231['data'];}catch(_0x36b2b0){_0x38fd82[a4_0x4810('0x1')](((_0x318d12=_0x36b2b0===null||_0x36b2b0===void 0x0?void 0x0:_0x36b2b0[a4_0x4810('0x19')])===null||_0x318d12===void 0x0?void 0x0:_0x318d12[a4_0x4810('0x5')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x36b2b0[a4_0x4810('0x19')][a4_0x4810('0x5')]):metric_logger_1[a4_0x4810('0x3')]);throw _0x36b2b0;}});}[a4_0x4810('0x1b')](_0x10b5e8){var _0x1a4422;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a4_0x4810('0x1d')]){output['note']({'title':a4_0x4810('0x13'),'bodyLines':[a4_0x4810('0x9')+this[a4_0x4810('0x7')],a4_0x4810('0x14')+_0x10b5e8]});}const _0x53b555=(0x0,metric_logger_1[a4_0x4810('0x17')])('completeRunGroup');try{const _0x440966=yield(0x0,axios_1[a4_0x4810('0x0')])(()=>this[a4_0x4810('0x12')][a4_0x4810('0x15')](a4_0x4810('0x1e'),{'runGroup':this[a4_0x4810('0x7')],'agentName':this[a4_0x4810('0xd')],'criticalErrorMessage':_0x10b5e8}));if(environment_1[a4_0x4810('0x1d')]){output['note']({'title':a4_0x4810('0xf')});}_0x53b555[a4_0x4810('0x1')]((0x0,metric_logger_1[a4_0x4810('0x4')])(_0x440966));}catch(_0x37d71a){_0x53b555[a4_0x4810('0x1')](((_0x1a4422=_0x37d71a===null||_0x37d71a===void 0x0?void 0x0:_0x37d71a[a4_0x4810('0x19')])===null||_0x1a4422===void 0x0?void 0x0:_0x1a4422[a4_0x4810('0x5')])?(0x0,metric_logger_1[a4_0x4810('0x4')])(_0x37d71a[a4_0x4810('0x19')][a4_0x4810('0x5')]):metric_logger_1[a4_0x4810('0x3')]);console[a4_0x4810('0x6')](_0x37d71a);}});}}exports['DistributedAgentApi']=DistributedAgentApi;
@@ -1,243 +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 stripJsonComments = require("strip-json-comments");
15
- const distributed_agent_api_1 = require("./distributed-agent.api");
16
- const waiter_1 = require("../../../utilities/waiter");
17
- const environment_1 = require("../../../utilities/environment");
18
- const print_run_group_error_1 = require("../../error/print-run-group-error");
19
- const create_no_new_messages_timeout_1 = require("../../../utilities/create-no-new-messages-timeout");
20
- const fs_1 = require("fs");
21
- const metric_logger_1 = require("../../../utilities/metric-logger");
22
- const { output, workspaceRoot } = require('../../../utilities/nx-imports');
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.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.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.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.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.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 && process.env.CIRCLE_STAGE) {
166
- return process.env.CIRCLE_STAGE;
167
- }
168
- else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_JOB) {
169
- return process.env.CIRCLE_JOB;
170
- }
171
- else {
172
- return `Agent ${Math.floor(Math.random() * 100000)}`;
173
- }
174
- }
175
- function createAgentLockfile(options, agentName) {
176
- const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
177
- const lockFileDirectory = `${cacheDirectory}/lockfiles`;
178
- const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
179
- if (!(0, fs_1.existsSync)(lockFileDirectory)) {
180
- (0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
181
- }
182
- // Check for other agents' lockfiles and warn if exist
183
- const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
184
- if (lockFiles.length) {
185
- // Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
186
- if (lockFiles.includes(`${agentName}.lock`)) {
187
- output.error({
188
- title: 'Duplicate Agent ID Detected',
189
- bodyLines: [
190
- 'We have detected another agent with this ID running in this workspace. This should not happen.',
191
- '',
192
- 'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
193
- ],
194
- });
195
- process.exit(1);
196
- }
197
- output.warn({
198
- title: 'Other Nx Cloud Agents Detected',
199
- bodyLines: [
200
- 'We have detected other agents running in this workspace. This can cause unexpected behavior.',
201
- '',
202
- 'This can also be a false positive caused by agents that did not shut down correctly.',
203
- 'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
204
- ],
205
- });
206
- }
207
- (0, fs_1.writeFileSync)(lockFilePath, '');
208
- process.on('exit', (code) => cleanupAgentLockfile(lockFilePath, code));
209
- process.on('SIGINT', () => cleanupAgentLockfile(lockFilePath, 0));
210
- }
211
- function cleanupAgentLockfile(lockFilePath, code) {
212
- if ((0, fs_1.existsSync)(lockFilePath)) {
213
- (0, fs_1.unlinkSync)(lockFilePath);
214
- process.exit(code);
215
- }
216
- }
217
- function startAgent() {
218
- return __awaiter(this, void 0, void 0, function* () {
219
- const runGroup = (0, environment_1.getRunGroup)();
220
- if (!runGroup) {
221
- (0, print_run_group_error_1.printRunGroupError)();
222
- return process.exit(1);
223
- }
224
- output.note({
225
- title: 'Starting an agent for running Nx tasks',
226
- });
227
- const options = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default.options;
228
- const agentName = getAgentName();
229
- createAgentLockfile(options, agentName);
230
- const api = new distributed_agent_api_1.DistributedAgentApi(options, runGroup, agentName);
231
- return executeTasks(options, api)
232
- .then((res) => __awaiter(this, void 0, void 0, function* () {
233
- yield (0, metric_logger_1.submitRunMetrics)(options);
234
- return res;
235
- }))
236
- .catch((e) => __awaiter(this, void 0, void 0, function* () {
237
- yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
238
- throw e;
239
- }));
240
- });
241
- }
242
- exports.startAgent = startAgent;
243
- //# sourceMappingURL=distributed-agent.impl.js.map
1
+ const a5_0x129c=['true','./node_modules/.cache/nx','maxParallel','reset','CIRCLE_JOB','execSync','status','floor','join','options','createNoNewMessagesTimeout','printRunGroupError','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','warn','catch','NX_AGENT_NAME','../../../utilities/metric-logger','cacheDirectory','Duplicate\x20Agent\x20ID\x20Detected','submitRunMetrics','DistributedAgentApi','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','map','default','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','VERBOSE_LOGGING','unlinkSync','__esModule','defineProperty','throw','Other\x20Nx\x20Cloud\x20Agents\x20Detected','toString','/nx.json','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','configuration','apply','assign','retryDuring','parse','child_process','error','tasks','env','mkdirSync','If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.','./distributed-agent.api','completedStatusCode','executionId','/lockfiles','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','next','SIGINT','\x20--projects=','length','completed:\x20','../../error/print-run-group-error','\x20--parallel\x20--max-parallel=','includes','Distributed\x20Execution\x20Terminated','value','target','projects','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','Agent\x20','Waiting...','forEach','retryDuring:\x20','startAgent','CIRCLECI','../../../utilities/environment','push','note','getTime','completed','../../../utilities/waiter','completeRunGroupWithError','projectName','CIRCLE_STAGE','wait',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','Waiter','executionId:\x20','inherit','../../../utilities/create-no-new-messages-timeout','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','API\x20Response','then','criticalErrorMessage','message','tasksRunnerOptions','getRunGroup','exit','npx\x20nx\x20run-many\x20--target=','Critical\x20Error\x20in\x20Agent:\x20\x22','params','taskId'];(function(_0x4382b3,_0x129cfa){const _0x33e5f7=function(_0x5b4125){while(--_0x5b4125){_0x4382b3['push'](_0x4382b3['shift']());}};_0x33e5f7(++_0x129cfa);}(a5_0x129c,0x17f));const a5_0x33e5=function(_0x4382b3,_0x129cfa){_0x4382b3=_0x4382b3-0x0;let _0x33e5f7=a5_0x129c[_0x4382b3];return _0x33e5f7;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x45e6e2,_0x12cd8f,_0x2dfff5,_0x2b6c52){function _0xa3d469(_0x4c6857){return _0x4c6857 instanceof _0x2dfff5?_0x4c6857:new _0x2dfff5(function(_0x4ab378){_0x4ab378(_0x4c6857);});}return new(_0x2dfff5||(_0x2dfff5=Promise))(function(_0x501b1c,_0x51d88c){function _0x16a0a9(_0x59e95a){try{_0x1fbaf5(_0x2b6c52[a5_0x33e5('0x33')](_0x59e95a));}catch(_0xa00579){_0x51d88c(_0xa00579);}}function _0xa51b8b(_0x22c06e){try{_0x1fbaf5(_0x2b6c52[a5_0x33e5('0x1e')](_0x22c06e));}catch(_0x58b8eb){_0x51d88c(_0x58b8eb);}}function _0x1fbaf5(_0xdb4ab4){_0xdb4ab4['done']?_0x501b1c(_0xdb4ab4[a5_0x33e5('0x3c')]):_0xa3d469(_0xdb4ab4[a5_0x33e5('0x3c')])[a5_0x33e5('0x57')](_0x16a0a9,_0xa51b8b);}_0x1fbaf5((_0x2b6c52=_0x2b6c52[a5_0x33e5('0x24')](_0x45e6e2,_0x12cd8f||[]))[a5_0x33e5('0x33')]());});};Object[a5_0x33e5('0x1d')](exports,a5_0x33e5('0x1c'),{'value':!![]});exports[a5_0x33e5('0x44')]=void 0x0;const child_process_1=require(a5_0x33e5('0x28'));const stripJsonComments=require('strip-json-comments');const distributed_agent_api_1=require(a5_0x33e5('0x2e'));const waiter_1=require(a5_0x33e5('0x4b'));const environment_1=require(a5_0x33e5('0x46'));const print_run_group_error_1=require(a5_0x33e5('0x38'));const create_no_new_messages_timeout_1=require(a5_0x33e5('0x54'));const fs_1=require('fs');const metric_logger_1=require(a5_0x33e5('0x11'));const {output,workspaceRoot}=require('../../../utilities/nx-imports');function executeTasks(_0x35bc57,_0x54ad5d){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x4448d7=0x0;let _0x4241fa=null;const _0x7d0c2a=(0x0,create_no_new_messages_timeout_1[a5_0x33e5('0xb')])();const _0x4f46ea=new waiter_1[(a5_0x33e5('0x51'))]();let _0x4afed6=[];const _0x10dcae=new Date();let _0x27c720=![];while(!![]){if(environment_1[a5_0x33e5('0x1a')]){output['note']({'title':'Fetching\x20tasks...'});}_0x4241fa=yield _0x54ad5d[a5_0x33e5('0x2a')](_0x4241fa?_0x4241fa['executionId']:null,_0x4448d7,_0x4afed6);if(environment_1[a5_0x33e5('0x1a')]){output[a5_0x33e5('0x48')]({'title':a5_0x33e5('0x56'),'bodyLines':[a5_0x33e5('0x37')+_0x4241fa[a5_0x33e5('0x4a')],a5_0x33e5('0x43')+_0x4241fa[a5_0x33e5('0x26')],a5_0x33e5('0x52')+_0x4241fa[a5_0x33e5('0x30')],'number\x20of\x20tasks:\x20'+_0x4241fa['tasks']['length'],'error:\x20'+_0x4241fa['criticalErrorMessage'],'maxParallel:\x20'+_0x4241fa['maxParallel']]});}if(_0x4241fa['criticalErrorMessage']){output[a5_0x33e5('0x29')]({'title':a5_0x33e5('0x3b'),'bodyLines':['Error:',_0x4241fa[a5_0x33e5('0x58')]]});process[a5_0x33e5('0x5c')](0x0);}if((_0x4241fa===null||_0x4241fa===void 0x0?void 0x0:_0x4241fa[a5_0x33e5('0x26')])&&(_0x4241fa===null||_0x4241fa===void 0x0?void 0x0:_0x4241fa[a5_0x33e5('0x26')])!==0x0&&!_0x27c720&&new Date()[a5_0x33e5('0x49')]()-_0x10dcae[a5_0x33e5('0x49')]()>_0x4241fa['retryDuring']){yield _0x4f46ea[a5_0x33e5('0x4f')]();continue;}if(_0x4241fa[a5_0x33e5('0x4a')])return;_0x7d0c2a(_0x4241fa['tasks'][a5_0x33e5('0x17')](_0x45a57c=>_0x45a57c[a5_0x33e5('0x0')])[a5_0x33e5('0x9')](''));if(!_0x4241fa[a5_0x33e5('0x30')]){if(environment_1[a5_0x33e5('0x1a')]){output[a5_0x33e5('0x48')]({'title':a5_0x33e5('0x41')});}yield _0x4f46ea[a5_0x33e5('0x4f')]();_0x4448d7=0x0;_0x4afed6=[];continue;}_0x4f46ea[a5_0x33e5('0x4')]();_0x27c720=!![];const _0x5b1ff8=invokeTasksUsingRunMany(_0x35bc57,_0x4241fa['executionId'],_0x4241fa[a5_0x33e5('0x2a')],_0x4241fa[a5_0x33e5('0x3')]);_0x4448d7=_0x5b1ff8[a5_0x33e5('0x2f')];_0x4afed6=_0x5b1ff8['completedTasks'];}});}function readCompletedTasks(_0x2cc162,_0x3e81bf){const _0x2f8977=a5_0x33e5('0x55')+_0x3e81bf+a5_0x33e5('0x50');let _0x155cef;try{const _0x19afcf=_0x2cc162['cacheDirectory']||'./node_modules/.cache/nx';const _0x3bd77f=_0x19afcf+'/tasks-hashes-'+_0x3e81bf;_0x155cef=JSON[a5_0x33e5('0x27')]((0x0,fs_1['readFileSync'])(_0x3bd77f)[a5_0x33e5('0x20')]());(0x0,fs_1[a5_0x33e5('0x1b')])(_0x3bd77f);}catch(_0x16ed15){throw new Error(_0x2f8977);}if(_0x155cef[a5_0x33e5('0x36')]==0x0){throw new Error(_0x2f8977);}return _0x155cef;}function invokeTasksUsingRunMany(_0x2953f3,_0x135a53,_0x33bb07,_0x58e9bb){let _0x168801=0x0;const _0x37caeb=[];for(const _0x4d846d of groupByTarget(_0x33bb07)){const _0x3f0127=_0x4d846d[a5_0x33e5('0x23')]?'--configuration='+_0x4d846d[a5_0x33e5('0x23')]:'';const _0x29c974=_0x58e9bb>0x1?a5_0x33e5('0x39')+_0x58e9bb:'';const _0x109699=a5_0x33e5('0x5d')+_0x4d846d['target']+'\x20'+_0x3f0127+a5_0x33e5('0x35')+_0x4d846d[a5_0x33e5('0x3e')][a5_0x33e5('0x9')](',')+'\x20'+_0x4d846d['params']+_0x29c974;if(environment_1[a5_0x33e5('0x1a')]){output[a5_0x33e5('0x48')]({'title':'Executing:\x20\x27'+_0x109699+'\x27'});}try{(0x0,child_process_1[a5_0x33e5('0x6')])(_0x109699,{'stdio':['inherit','inherit',a5_0x33e5('0x53')],'env':Object[a5_0x33e5('0x25')](Object['assign']({},process[a5_0x33e5('0x2b')]),{'NX_CACHE_FAILURES':a5_0x33e5('0x1'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x135a53})});}catch(_0x12ea9a){if(_0x12ea9a[a5_0x33e5('0x7')]===environment_1[a5_0x33e5('0x22')]){throw _0x12ea9a;}else{_0x168801=0x1;}}finally{_0x37caeb['push'](...readCompletedTasks(_0x2953f3,_0x135a53));}}return{'completedStatusCode':_0x168801,'completedTasks':_0x37caeb};}function groupByTarget(_0x3235c1){const _0x2b896d=[];_0x3235c1[a5_0x33e5('0x42')](_0x30000e=>{const _0x52a624=_0x2b896d['find'](_0x24d708=>_0x24d708[a5_0x33e5('0x3d')]===_0x30000e[a5_0x33e5('0x3d')]&&_0x24d708[a5_0x33e5('0x23')]===_0x30000e['configuration']);if(_0x52a624){_0x52a624[a5_0x33e5('0x3e')][a5_0x33e5('0x47')](_0x30000e[a5_0x33e5('0x4d')]);}else{_0x2b896d[a5_0x33e5('0x47')]({'target':_0x30000e[a5_0x33e5('0x3d')],'projects':[_0x30000e[a5_0x33e5('0x4d')]],'params':_0x30000e[a5_0x33e5('0x5f')],'configuration':_0x30000e[a5_0x33e5('0x23')]});}});return _0x2b896d;}function getAgentName(){if(process[a5_0x33e5('0x2b')][a5_0x33e5('0x10')]!==undefined){return process[a5_0x33e5('0x2b')][a5_0x33e5('0x10')];}else if(process[a5_0x33e5('0x2b')]['CIRCLECI']!==undefined&&process[a5_0x33e5('0x2b')][a5_0x33e5('0x4e')]){return process[a5_0x33e5('0x2b')][a5_0x33e5('0x4e')];}else if(process['env'][a5_0x33e5('0x45')]!==undefined&&process[a5_0x33e5('0x2b')][a5_0x33e5('0x5')]){return process[a5_0x33e5('0x2b')][a5_0x33e5('0x5')];}else{return a5_0x33e5('0x40')+Math[a5_0x33e5('0x8')](Math['random']()*0x186a0);}}function createAgentLockfile(_0x4fa83d,_0x45dae9){const _0x11f243=_0x4fa83d[a5_0x33e5('0x12')]||a5_0x33e5('0x2');const _0x4d8a18=_0x11f243+a5_0x33e5('0x31');const _0x428f07=_0x4d8a18+'/'+_0x45dae9+'.lock';if(!(0x0,fs_1['existsSync'])(_0x4d8a18)){(0x0,fs_1[a5_0x33e5('0x2c')])(_0x4d8a18,{'recursive':!![]});}const _0x4a1293=(0x0,fs_1['readdirSync'])(_0x4d8a18);if(_0x4a1293[a5_0x33e5('0x36')]){if(_0x4a1293[a5_0x33e5('0x3a')](_0x45dae9+'.lock')){output[a5_0x33e5('0x29')]({'title':a5_0x33e5('0x13'),'bodyLines':[a5_0x33e5('0x32'),'',a5_0x33e5('0x3f')]});process[a5_0x33e5('0x5c')](0x1);}output[a5_0x33e5('0xe')]({'title':a5_0x33e5('0x1f'),'bodyLines':[a5_0x33e5('0x19'),'',a5_0x33e5('0x16'),a5_0x33e5('0x2d')]});}(0x0,fs_1['writeFileSync'])(_0x428f07,'');process['on'](a5_0x33e5('0x5c'),_0x4a14aa=>cleanupAgentLockfile(_0x428f07,_0x4a14aa));process['on'](a5_0x33e5('0x34'),()=>cleanupAgentLockfile(_0x428f07,0x0));}function cleanupAgentLockfile(_0x52f149,_0x5e5a29){if((0x0,fs_1['existsSync'])(_0x52f149)){(0x0,fs_1[a5_0x33e5('0x1b')])(_0x52f149);process[a5_0x33e5('0x5c')](_0x5e5a29);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x39c692=(0x0,environment_1[a5_0x33e5('0x5b')])();if(!_0x39c692){(0x0,print_run_group_error_1[a5_0x33e5('0xc')])();return process[a5_0x33e5('0x5c')](0x1);}output[a5_0x33e5('0x48')]({'title':a5_0x33e5('0xd')});const _0x484455=JSON[a5_0x33e5('0x27')](stripJsonComments((0x0,fs_1['readFileSync'])(workspaceRoot+a5_0x33e5('0x21'))['toString']()))[a5_0x33e5('0x5a')][a5_0x33e5('0x18')][a5_0x33e5('0xa')];const _0x15a7f8=getAgentName();createAgentLockfile(_0x484455,_0x15a7f8);const _0x30b081=new distributed_agent_api_1[(a5_0x33e5('0x15'))](_0x484455,_0x39c692,_0x15a7f8);return executeTasks(_0x484455,_0x30b081)[a5_0x33e5('0x57')](_0x3fee07=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a5_0x33e5('0x14')])(_0x484455);return _0x3fee07;}))[a5_0x33e5('0xf')](_0x4852e2=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x30b081[a5_0x33e5('0x4c')](a5_0x33e5('0x5e')+_0x4852e2[a5_0x33e5('0x59')]+'\x22');throw _0x4852e2;}));});}exports[a5_0x33e5('0x44')]=startAgent;