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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,113 +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.CloudRemoteCache = void 0;
13
- const environment_1 = require("../../../utilities/environment");
14
- const { output } = require('../../../utilities/nx-imports');
15
- class CloudRemoteCache {
16
- constructor(messages, api, runContext, fileStorage) {
17
- this.messages = messages;
18
- this.api = api;
19
- this.runContext = runContext;
20
- this.fileStorage = fileStorage;
21
- this.storeRequests = [];
22
- }
23
- retrieve(hash, cacheDirectory) {
24
- var _a;
25
- return __awaiter(this, void 0, void 0, function* () {
26
- if (this.messages.cacheError)
27
- return false;
28
- const hashUrls = yield this.hashUrls(hash);
29
- if (!hashUrls || !hashUrls.get) {
30
- if (environment_1.VERBOSE_LOGGING) {
31
- output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
32
- }
33
- this.runContext.statuses[hash] = 'cache-miss';
34
- return false;
35
- }
36
- try {
37
- yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
38
- this.runContext.statuses[hash] = 'remote-cache-hit';
39
- return true;
40
- }
41
- catch (ee) {
42
- const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
43
- if (e.response && e.response.status === 404) {
44
- if (environment_1.VERBOSE_LOGGING) {
45
- output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
46
- }
47
- // cache miss. print nothing
48
- }
49
- else {
50
- this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
51
- }
52
- this.runContext.statuses[hash] = 'cache-miss';
53
- return false;
54
- }
55
- });
56
- }
57
- store(hash, cacheDirectory) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- if (this.messages.cacheError)
60
- return false;
61
- const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
62
- var _a;
63
- const hashUrls = yield this.hashUrls(hash);
64
- if (!hashUrls)
65
- return false;
66
- if (!hashUrls.put) {
67
- if (environment_1.VERBOSE_LOGGING) {
68
- output.note({
69
- title: `Nx Cloud: Skipping storing ${hash}. Read only token is used.`,
70
- });
71
- }
72
- return true;
73
- }
74
- try {
75
- yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
76
- return true;
77
- }
78
- catch (ee) {
79
- const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
80
- this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
81
- return false;
82
- }
83
- }));
84
- this.storeRequests.push(res);
85
- return res;
86
- });
87
- }
88
- hashUrls(hash) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- if (hash in this.runContext.requests) {
91
- return (yield this.runContext.requests[hash])[hash];
92
- }
93
- else {
94
- const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
95
- .filter((t) => !this.runContext.requests[t.hash])
96
- .map((t) => t.hash);
97
- if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
98
- scheduledTaskHashesWithoutRequests.push(hash);
99
- }
100
- const request = this.api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, scheduledTaskHashesWithoutRequests);
101
- scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
102
- this.runContext.requests[taskHash] = request;
103
- });
104
- return (yield request)[hash];
105
- }
106
- });
107
- }
108
- waitForStoreRequestsToComplete() {
109
- return Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
110
- }
111
- }
112
- exports.CloudRemoteCache = CloudRemoteCache;
113
- //# sourceMappingURL=cloud-remote-cache.js.map
1
+ const a2_0x4209=['Nx\x20Cloud:\x20Cache\x20miss\x20','VERBOSE_LOGGING','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','storeRequests','statuses','push','CloudRemoteCache','forEach','get','extractErrorMessage','fileStorage','Nx\x20Cloud:\x20Skipping\x20storing\x20','../../../utilities/environment','.\x20Read\x20only\x20token\x20is\x20used.','runContext','resolve','status','next','then','../../../utilities/nx-imports','retrieve','storage','__esModule','cache-miss','waitForStoreRequestsToComplete','requests','done','map','axiosException','response','reduce','filter','cacheError','put','messages','all','api','hash','startRun','note','hashUrls','__awaiter','defineProperty','.\x20Status\x20404.','value'];(function(_0x1f216f,_0x42098a){const _0x2ed5eb=function(_0x22d74a){while(--_0x22d74a){_0x1f216f['push'](_0x1f216f['shift']());}};_0x2ed5eb(++_0x42098a);}(a2_0x4209,0xe6));const a2_0x2ed5=function(_0x1f216f,_0x42098a){_0x1f216f=_0x1f216f-0x0;let _0x2ed5eb=a2_0x4209[_0x1f216f];return _0x2ed5eb;};'use strict';var __awaiter=this&&this[a2_0x2ed5('0x24')]||function(_0x29b9e0,_0x4ee9ac,_0x3699f4,_0x522f99){function _0x5bbcc9(_0x1910a9){return _0x1910a9 instanceof _0x3699f4?_0x1910a9:new _0x3699f4(function(_0x3d7d45){_0x3d7d45(_0x1910a9);});}return new(_0x3699f4||(_0x3699f4=Promise))(function(_0x16e3c4,_0x4873a5){function _0x4f6f6a(_0x4bfd62){try{_0x6f9c12(_0x522f99['next'](_0x4bfd62));}catch(_0x3ef5e7){_0x4873a5(_0x3ef5e7);}}function _0x11639c(_0x5727ce){try{_0x6f9c12(_0x522f99['throw'](_0x5727ce));}catch(_0x4f6565){_0x4873a5(_0x4f6565);}}function _0x6f9c12(_0x35e17a){_0x35e17a[a2_0x2ed5('0x15')]?_0x16e3c4(_0x35e17a['value']):_0x5bbcc9(_0x35e17a[a2_0x2ed5('0x27')])[a2_0x2ed5('0xd')](_0x4f6f6a,_0x11639c);}_0x6f9c12((_0x522f99=_0x522f99['apply'](_0x29b9e0,_0x4ee9ac||[]))[a2_0x2ed5('0xc')]());});};Object[a2_0x2ed5('0x25')](exports,a2_0x2ed5('0x11'),{'value':!![]});exports[a2_0x2ed5('0x1')]=void 0x0;const environment_1=require(a2_0x2ed5('0x7'));const {output}=require(a2_0x2ed5('0xe'));class CloudRemoteCache{constructor(_0xd17bdb,_0xcd1f20,_0x4f2692,_0x1ee6c9){this[a2_0x2ed5('0x1d')]=_0xd17bdb;this[a2_0x2ed5('0x1f')]=_0xcd1f20;this[a2_0x2ed5('0x9')]=_0x4f2692;this[a2_0x2ed5('0x5')]=_0x1ee6c9;this[a2_0x2ed5('0x2b')]=[];}['retrieve'](_0x5741c0,_0x5116ac){var _0x2f350c;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a2_0x2ed5('0x1b')])return![];const _0x3312d6=yield this[a2_0x2ed5('0x23')](_0x5741c0);if(!_0x3312d6||!_0x3312d6[a2_0x2ed5('0x3')]){if(environment_1['VERBOSE_LOGGING']){output[a2_0x2ed5('0x22')]({'title':a2_0x2ed5('0x28')+_0x5741c0+'.'});}this[a2_0x2ed5('0x9')][a2_0x2ed5('0x2c')][_0x5741c0]=a2_0x2ed5('0x12');return![];}try{yield this[a2_0x2ed5('0x5')][a2_0x2ed5('0xf')](_0x5741c0,_0x3312d6[a2_0x2ed5('0x3')],_0x5116ac);this[a2_0x2ed5('0x9')][a2_0x2ed5('0x2c')][_0x5741c0]='remote-cache-hit';return!![];}catch(_0x36594a){const _0x1bad83=(_0x2f350c=_0x36594a[a2_0x2ed5('0x17')])!==null&&_0x2f350c!==void 0x0?_0x2f350c:_0x36594a;if(_0x1bad83[a2_0x2ed5('0x18')]&&_0x1bad83[a2_0x2ed5('0x18')][a2_0x2ed5('0xb')]===0x194){if(environment_1[a2_0x2ed5('0x29')]){output[a2_0x2ed5('0x22')]({'title':'Nx\x20Cloud:\x20Cache\x20miss\x20'+_0x5741c0+a2_0x2ed5('0x26')});}}else{this[a2_0x2ed5('0x1d')]['cacheError']=this[a2_0x2ed5('0x1d')]['extractErrorMessage'](_0x1bad83,a2_0x2ed5('0x10'));}this[a2_0x2ed5('0x9')][a2_0x2ed5('0x2c')][_0x5741c0]=a2_0x2ed5('0x12');return![];}});}['store'](_0x25c56b,_0x3102e6){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x2ed5('0x1d')][a2_0x2ed5('0x1b')])return![];const _0x277f81=Promise[a2_0x2ed5('0xa')]()[a2_0x2ed5('0xd')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x59ed83;const _0x364537=yield this['hashUrls'](_0x25c56b);if(!_0x364537)return![];if(!_0x364537[a2_0x2ed5('0x1c')]){if(environment_1['VERBOSE_LOGGING']){output[a2_0x2ed5('0x22')]({'title':a2_0x2ed5('0x6')+_0x25c56b+a2_0x2ed5('0x8')});}return!![];}try{yield this[a2_0x2ed5('0x5')]['store'](_0x25c56b,_0x364537['put'],_0x3102e6);return!![];}catch(_0x4abc57){const _0x3c3a27=(_0x59ed83=_0x4abc57[a2_0x2ed5('0x17')])!==null&&_0x59ed83!==void 0x0?_0x59ed83:_0x4abc57;this[a2_0x2ed5('0x1d')][a2_0x2ed5('0x1b')]=this[a2_0x2ed5('0x1d')][a2_0x2ed5('0x4')](_0x3c3a27,'storage');return![];}}));this[a2_0x2ed5('0x2b')][a2_0x2ed5('0x0')](_0x277f81);return _0x277f81;});}[a2_0x2ed5('0x23')](_0x16f2d5){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x16f2d5 in this[a2_0x2ed5('0x9')][a2_0x2ed5('0x14')]){return(yield this[a2_0x2ed5('0x9')][a2_0x2ed5('0x14')][_0x16f2d5])[_0x16f2d5];}else{const _0x2ec69d=this[a2_0x2ed5('0x9')]['scheduledTasks'][a2_0x2ed5('0x1a')](_0x5eebbf=>!this[a2_0x2ed5('0x9')][a2_0x2ed5('0x14')][_0x5eebbf[a2_0x2ed5('0x20')]])[a2_0x2ed5('0x16')](_0x993e9e=>_0x993e9e[a2_0x2ed5('0x20')]);if(_0x2ec69d['indexOf'](_0x16f2d5)===-0x1){_0x2ec69d[a2_0x2ed5('0x0')](_0x16f2d5);}const _0x3a5c1a=this[a2_0x2ed5('0x1f')][a2_0x2ed5('0x21')](environment_1[a2_0x2ed5('0x2a')],_0x2ec69d);_0x2ec69d[a2_0x2ed5('0x2')](_0x143d67=>{this[a2_0x2ed5('0x9')][a2_0x2ed5('0x14')][_0x143d67]=_0x3a5c1a;});return(yield _0x3a5c1a)[_0x16f2d5];}});}[a2_0x2ed5('0x13')](){return Promise[a2_0x2ed5('0x1e')](this[a2_0x2ed5('0x2b')])[a2_0x2ed5('0xd')](_0x1b8cd7=>_0x1b8cd7[a2_0x2ed5('0x19')]((_0x4fc8e2,_0x97a55)=>_0x4fc8e2&&_0x97a55,!![]));}}exports['CloudRemoteCache']=CloudRemoteCache;
@@ -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_0x3813=['done','Run\x20completion\x20responded\x20with\x20`undefined`.','post','apiAxiosInstance','urls','../../../utilities/nx-imports','mapRespToPerfEntry','application/octet-stream','api','createMetricRecorder','getBranch','__awaiter','/nx-cloud/runs/start','apiError','readFileSync','createReqBody','axiosException','throw','status','extractErrorMessage','string','messages','../../../utilities/environment','next','stringify','from','../../../utilities/metric-logger','recordMetric','machineInfo','startRun','value','Invalid\x20end\x20run\x20response','../../../utilities/axios','RUNNER_FAILURE_PERF_ENTRY','Stack\x20Trace:','/nx-cloud/runs/end','CloudRunApi','headers','data','terminalOutput','__esModule','@nrwl/nx-cloud','VERBOSE_LOGGING','success','response','Run\x20Details:','assign','gzip','unknown','message','note','parse','defaults','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','length','map','stack','toString','promisify','axiosMultipleTries','defineProperty','Invalid\x20end\x20run\x20response:\x20','RunStart','runUrl','runContext','endRun','then','nxCloudVersion','getRunGroup','devDependencies','error'];(function(_0x39ecab,_0x38131e){const _0x19cb67=function(_0x2a2bf7){while(--_0x2a2bf7){_0x39ecab['push'](_0x39ecab['shift']());}};_0x19cb67(++_0x38131e);}(a3_0x3813,0x157));const a3_0x19cb=function(_0x39ecab,_0x38131e){_0x39ecab=_0x39ecab-0x0;let _0x19cb67=a3_0x3813[_0x39ecab];return _0x19cb67;};'use strict';var __awaiter=this&&this[a3_0x19cb('0x17')]||function(_0x23034b,_0x4e00e1,_0x58685d,_0x1e126e){function _0x221890(_0x11dca3){return _0x11dca3 instanceof _0x58685d?_0x11dca3:new _0x58685d(function(_0xdff906){_0xdff906(_0x11dca3);});}return new(_0x58685d||(_0x58685d=Promise))(function(_0x431d28,_0x16398d){function _0x475434(_0x1f6389){try{_0x36f11c(_0x1e126e[a3_0x19cb('0x23')](_0x1f6389));}catch(_0x24e61b){_0x16398d(_0x24e61b);}}function _0x292f82(_0x36151a){try{_0x36f11c(_0x1e126e[a3_0x19cb('0x1d')](_0x36151a));}catch(_0x2609ab){_0x16398d(_0x2609ab);}}function _0x36f11c(_0xcaa2ec){_0xcaa2ec[a3_0x19cb('0xc')]?_0x431d28(_0xcaa2ec[a3_0x19cb('0x2a')]):_0x221890(_0xcaa2ec[a3_0x19cb('0x2a')])[a3_0x19cb('0x7')](_0x475434,_0x292f82);}_0x36f11c((_0x1e126e=_0x1e126e['apply'](_0x23034b,_0x4e00e1||[]))[a3_0x19cb('0x23')]());});};Object[a3_0x19cb('0x1')](exports,a3_0x19cb('0x34'),{'value':!![]});exports[a3_0x19cb('0x30')]=void 0x0;const axios_1=require(a3_0x19cb('0x2c'));const environment_1=require(a3_0x19cb('0x22'));const fs_1=require('fs');const zlib_1=require('zlib');const util_1=require('util');const metric_logger_1=require(a3_0x19cb('0x26'));const {output}=require(a3_0x19cb('0x11'));class CloudRunApi{constructor(_0x164411,_0x177598,_0x2eca4b,_0x13b644){this[a3_0x19cb('0x21')]=_0x164411;this[a3_0x19cb('0x5')]=_0x177598;this[a3_0x19cb('0x28')]=_0x13b644;this[a3_0x19cb('0xf')]=(0x0,axios_1['createApiAxiosInstance'])(_0x2eca4b);}[a3_0x19cb('0x29')](_0x4c5499,_0x18cb10){var _0x1a73a1;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1ce524=(0x0,metric_logger_1[a3_0x19cb('0x15')])(a3_0x19cb('0x29'));try{const _0x7534d6={'meta':{'nxCloudVersion':this[a3_0x19cb('0x8')]()},'branch':(0x0,environment_1[a3_0x19cb('0x16')])(),'runGroup':(0x0,environment_1[a3_0x19cb('0x9')])(),'distributedExecutionId':_0x4c5499,'hashes':_0x18cb10};if(environment_1[a3_0x19cb('0x36')]){output[a3_0x19cb('0x3e')]({'title':a3_0x19cb('0x3'),'bodyLines':['\x0a'+JSON[a3_0x19cb('0x24')](_0x7534d6,null,0x2)]});}const _0xd86279=yield(0x0,axios_1[a3_0x19cb('0x0')])(()=>this[a3_0x19cb('0xf')][a3_0x19cb('0xe')](a3_0x19cb('0x18'),_0x7534d6));_0x1ce524['recordMetric']((0x0,metric_logger_1[a3_0x19cb('0x12')])(_0xd86279));if(_0xd86279[a3_0x19cb('0x32')]&&_0xd86279[a3_0x19cb('0x32')][a3_0x19cb('0x3d')]){this[a3_0x19cb('0x21')][a3_0x19cb('0x3d')]=_0xd86279[a3_0x19cb('0x32')][a3_0x19cb('0x3d')];}if(!_0xd86279[a3_0x19cb('0x32')]||!_0xd86279['data'][a3_0x19cb('0x10')]){this[a3_0x19cb('0x21')][a3_0x19cb('0x19')]='Invalid\x20Nx\x20Cloud\x20response:\x20'+JSON[a3_0x19cb('0x24')](_0xd86279[a3_0x19cb('0x32')]);return{};}return _0xd86279[a3_0x19cb('0x32')][a3_0x19cb('0x10')];}catch(_0x41f958){_0x1ce524[a3_0x19cb('0x27')](((_0x1a73a1=_0x41f958===null||_0x41f958===void 0x0?void 0x0:_0x41f958[a3_0x19cb('0x1c')])===null||_0x1a73a1===void 0x0?void 0x0:_0x1a73a1[a3_0x19cb('0x38')])?(0x0,metric_logger_1[a3_0x19cb('0x12')])(_0x41f958['axiosException']['response']):metric_logger_1[a3_0x19cb('0x2d')]);this[a3_0x19cb('0x21')]['apiError']=this[a3_0x19cb('0x21')][a3_0x19cb('0x1f')](_0x41f958,a3_0x19cb('0x14'));return{};}});}[a3_0x19cb('0x1b')](_0x4ec1de,_0x26abee){const _0x4a506c={'meta':{'nxCloudVersion':this[a3_0x19cb('0x8')]()},'tasks':_0x26abee,'run':_0x4ec1de,'machineInfo':this['machineInfo']};return JSON[a3_0x19cb('0x24')](_0x4a506c);}[a3_0x19cb('0x6')](_0x3c5337,_0x2c81b4){var _0x2075f4,_0x9a4120;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a3_0x19cb('0x19')])return![];let _0xe7f66e=this[a3_0x19cb('0x1b')](_0x3c5337,_0x2c81b4);if(_0xe7f66e[a3_0x19cb('0x42')]>0x14*0x3e8*0x3e8){_0xe7f66e=this['createReqBody'](_0x3c5337,_0x2c81b4[a3_0x19cb('0x43')](_0x2b2581=>Object[a3_0x19cb('0x3a')](Object['assign']({},_0x2b2581),{'hashDetails':undefined})));}const _0x1630e8=Buffer[a3_0x19cb('0x25')](_0xe7f66e);const _0x7f2483=yield(0x0,util_1[a3_0x19cb('0x46')])(zlib_1[a3_0x19cb('0x3b')])(_0x1630e8);const _0x410b44=(0x0,metric_logger_1[a3_0x19cb('0x15')])(a3_0x19cb('0x6'));try{if(environment_1['VERBOSE_LOGGING']){const _0x404616=_0x2c81b4[a3_0x19cb('0x43')](_0x184a01=>{return Object[a3_0x19cb('0x3a')](Object[a3_0x19cb('0x3a')]({},_0x184a01),{'terminalOutput':_0x184a01[a3_0x19cb('0x33')]?_0x184a01[a3_0x19cb('0x33')]['slice'](0x0,0x14)+'...':undefined});});output[a3_0x19cb('0x3e')]({'title':'RunEnd.\x20Completed\x20tasks','bodyLines':['\x0a'+JSON[a3_0x19cb('0x24')](_0x404616,null,0x2)]});}const _0x1d7a8d=yield(0x0,axios_1[a3_0x19cb('0x0')])(()=>this[a3_0x19cb('0xf')][a3_0x19cb('0xe')](a3_0x19cb('0x2f'),_0x7f2483,{'headers':Object[a3_0x19cb('0x3a')](Object[a3_0x19cb('0x3a')]({},this['apiAxiosInstance'][a3_0x19cb('0x40')][a3_0x19cb('0x31')]),{'Content-Encoding':'gzip','Content-Type':a3_0x19cb('0x13')})}));if(_0x1d7a8d){_0x410b44[a3_0x19cb('0x27')]((0x0,metric_logger_1[a3_0x19cb('0x12')])(_0x1d7a8d));if(_0x1d7a8d[a3_0x19cb('0x32')]&&_0x1d7a8d[a3_0x19cb('0x32')][a3_0x19cb('0x4')]&&_0x1d7a8d[a3_0x19cb('0x32')][a3_0x19cb('0x1e')]===a3_0x19cb('0x37')){this[a3_0x19cb('0x5')][a3_0x19cb('0x4')]=_0x1d7a8d[a3_0x19cb('0x32')]['runUrl'];return!![];}if(_0x1d7a8d[a3_0x19cb('0x32')]&&_0x1d7a8d[a3_0x19cb('0x32')][a3_0x19cb('0x1e')]){this[a3_0x19cb('0x21')][a3_0x19cb('0x19')]=a3_0x19cb('0x2')+JSON['stringify'](_0x1d7a8d[a3_0x19cb('0x32')]['message']);}else if(_0x1d7a8d[a3_0x19cb('0x32')]&&typeof _0x1d7a8d['data']===a3_0x19cb('0x20')){if(_0x1d7a8d['data']!==a3_0x19cb('0x37')){this[a3_0x19cb('0x21')][a3_0x19cb('0x19')]=a3_0x19cb('0x2')+JSON[a3_0x19cb('0x24')](_0x1d7a8d['data']);}}else{this['messages'][a3_0x19cb('0x19')]=a3_0x19cb('0x2')+JSON['stringify'](_0x1d7a8d[a3_0x19cb('0x32')]);}if(environment_1[a3_0x19cb('0x36')]){output[a3_0x19cb('0x3e')]({'title':a3_0x19cb('0x2b'),'bodyLines':[JSON[a3_0x19cb('0x24')](_0x1d7a8d[a3_0x19cb('0x32')],null,0x2)]});}}else{output[a3_0x19cb('0xb')]({'title':a3_0x19cb('0x41'),'bodyLines':[a3_0x19cb('0xd'),a3_0x19cb('0x39'),JSON[a3_0x19cb('0x24')](_0x3c5337,null,0x2),a3_0x19cb('0x2e'),JSON[a3_0x19cb('0x24')](new Error()[a3_0x19cb('0x44')],null,0x2)]});}return![];}catch(_0x12c27a){_0x410b44['recordMetric'](((_0x2075f4=_0x12c27a===null||_0x12c27a===void 0x0?void 0x0:_0x12c27a[a3_0x19cb('0x1c')])===null||_0x2075f4===void 0x0?void 0x0:_0x2075f4['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x12c27a['axiosException'][a3_0x19cb('0x38')]):metric_logger_1[a3_0x19cb('0x2d')]);const _0x2cb5bd=(_0x9a4120=_0x12c27a[a3_0x19cb('0x1c')])!==null&&_0x9a4120!==void 0x0?_0x9a4120:_0x12c27a;this[a3_0x19cb('0x21')][a3_0x19cb('0x19')]=this[a3_0x19cb('0x21')][a3_0x19cb('0x1f')](_0x2cb5bd,a3_0x19cb('0x14'));return![];}});}[a3_0x19cb('0x8')](){try{const _0x953935=JSON[a3_0x19cb('0x3f')]((0x0,fs_1[a3_0x19cb('0x1a')])('package.json')[a3_0x19cb('0x45')]());return _0x953935[a3_0x19cb('0xa')][a3_0x19cb('0x35')];}catch(_0x41fe09){return a3_0x19cb('0x3c');}}}exports[a3_0x19cb('0x30')]=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_0xfa39=['Completed\x20run\x20group\x20with\x20an\x20error','__esModule','mapRespToPerfEntry','apply','axiosException','axiosMultipleTries','post','DistributedAgentApi','VERBOSE_LOGGING','next','runGroup:\x20','apiAxiosInstance','recordMetric','agentName','RUNNER_FAILURE_PERF_ENTRY','createMetricRecorder','../../../utilities/axios','response','__awaiter','throw','completeRunGroupWithError','note','completeRunGroup','data','value','error:\x20','createApiAxiosInstance','Completing\x20run\x20group\x20with\x20an\x20error','defineProperty','runGroup','../../../utilities/environment'];(function(_0x5c83bb,_0xfa39e7){const _0x38c56c=function(_0x37c50d){while(--_0x37c50d){_0x5c83bb['push'](_0x5c83bb['shift']());}};_0x38c56c(++_0xfa39e7);}(a4_0xfa39,0x1e9));const a4_0x38c5=function(_0x5c83bb,_0xfa39e7){_0x5c83bb=_0x5c83bb-0x0;let _0x38c56c=a4_0xfa39[_0x5c83bb];return _0x38c56c;};'use strict';var __awaiter=this&&this[a4_0x38c5('0x19')]||function(_0x113252,_0xdb240b,_0x3591f1,_0x2e15d3){function _0x400a39(_0xf9ba15){return _0xf9ba15 instanceof _0x3591f1?_0xf9ba15:new _0x3591f1(function(_0x30e7c3){_0x30e7c3(_0xf9ba15);});}return new(_0x3591f1||(_0x3591f1=Promise))(function(_0x4e66fb,_0x4243e3){function _0x452aac(_0x3d0ced){try{_0x1208fb(_0x2e15d3[a4_0x38c5('0x10')](_0x3d0ced));}catch(_0xac0c03){_0x4243e3(_0xac0c03);}}function _0x2d7c1a(_0x13dfb0){try{_0x1208fb(_0x2e15d3[a4_0x38c5('0x1a')](_0x13dfb0));}catch(_0x22cfb7){_0x4243e3(_0x22cfb7);}}function _0x1208fb(_0x4d63d1){_0x4d63d1['done']?_0x4e66fb(_0x4d63d1[a4_0x38c5('0x0')]):_0x400a39(_0x4d63d1[a4_0x38c5('0x0')])['then'](_0x452aac,_0x2d7c1a);}_0x1208fb((_0x2e15d3=_0x2e15d3[a4_0x38c5('0xa')](_0x113252,_0xdb240b||[]))[a4_0x38c5('0x10')]());});};Object[a4_0x38c5('0x4')](exports,a4_0x38c5('0x8'),{'value':!![]});exports['DistributedAgentApi']=void 0x0;const axios_1=require(a4_0x38c5('0x17'));const environment_1=require(a4_0x38c5('0x6'));const metric_logger_1=require('../../../utilities/metric-logger');const {output}=require('../../../utilities/nx-imports');class DistributedAgentApi{constructor(_0x11c564,_0x23c28f,_0x56d4f5){this[a4_0x38c5('0x5')]=_0x23c28f;this['agentName']=_0x56d4f5;this[a4_0x38c5('0x12')]=(0x0,axios_1[a4_0x38c5('0x2')])(_0x11c564);}['tasks'](_0x5a17b2,_0x205782,_0x1e6008){var _0x56caa3;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x8a851c=(0x0,metric_logger_1[a4_0x38c5('0x16')])('dtePollTasks');try{const _0x1172f7=yield(0x0,axios_1[a4_0x38c5('0xc')])(()=>this[a4_0x38c5('0x12')][a4_0x38c5('0xd')]('/nx-cloud/executions/tasks',{'runGroup':this['runGroup'],'agentName':this[a4_0x38c5('0x14')],'executionId':_0x5a17b2,'statusCode':_0x205782,'completedTasks':_0x1e6008}));_0x8a851c['recordMetric']((0x0,metric_logger_1[a4_0x38c5('0x9')])(_0x1172f7));return _0x1172f7[a4_0x38c5('0x1e')];}catch(_0x5da77a){_0x8a851c['recordMetric'](((_0x56caa3=_0x5da77a===null||_0x5da77a===void 0x0?void 0x0:_0x5da77a[a4_0x38c5('0xb')])===null||_0x56caa3===void 0x0?void 0x0:_0x56caa3[a4_0x38c5('0x18')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x5da77a[a4_0x38c5('0xb')][a4_0x38c5('0x18')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);throw _0x5da77a;}});}[a4_0x38c5('0x1b')](_0x2c888d){var _0x1bdf76;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a4_0x38c5('0xf')]){output[a4_0x38c5('0x1c')]({'title':a4_0x38c5('0x3'),'bodyLines':[a4_0x38c5('0x11')+this[a4_0x38c5('0x5')],a4_0x38c5('0x1')+_0x2c888d]});}const _0x5ad6cb=(0x0,metric_logger_1[a4_0x38c5('0x16')])(a4_0x38c5('0x1d'));try{const _0x321254=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a4_0x38c5('0x12')][a4_0x38c5('0xd')]('/nx-cloud/executions/complete-run-group',{'runGroup':this['runGroup'],'agentName':this[a4_0x38c5('0x14')],'criticalErrorMessage':_0x2c888d}));if(environment_1[a4_0x38c5('0xf')]){output['note']({'title':a4_0x38c5('0x7')});}_0x5ad6cb[a4_0x38c5('0x13')]((0x0,metric_logger_1[a4_0x38c5('0x9')])(_0x321254));}catch(_0x5d56c1){_0x5ad6cb[a4_0x38c5('0x13')](((_0x1bdf76=_0x5d56c1===null||_0x5d56c1===void 0x0?void 0x0:_0x5d56c1[a4_0x38c5('0xb')])===null||_0x1bdf76===void 0x0?void 0x0:_0x1bdf76[a4_0x38c5('0x18')])?(0x0,metric_logger_1[a4_0x38c5('0x9')])(_0x5d56c1['axiosException'][a4_0x38c5('0x18')]):metric_logger_1[a4_0x38c5('0x15')]);console['error'](_0x5d56c1);}});}}exports[a4_0x38c5('0xe')]=DistributedAgentApi;