@nrwl/nx-cloud 15.0.3 → 15.0.4-beta.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.
@@ -1 +1,113 @@
1
- const a2_0xdd61=['runContext','axiosException','statuses','Nx\x20Cloud:\x20Cache\x20miss\x20','cacheError','get','remote-cache-hit','map','.\x20Status\x20404.','apply','startRun','done','waitForStoreRequestsToComplete','fileStorage','then','messages','extractErrorMessage','__esModule','api','Nx\x20Cloud:\x20Skipping\x20storing\x20','storeRequests','note','retrieve','../../../utilities/nx-imports','CloudRemoteCache','VERBOSE_LOGGING','cache-miss','storage','hash','next','forEach','../../../utilities/environment','throw','store','value','indexOf','requests','status','put','push','filter','hashUrls','__awaiter','reduce','response','scheduledTasks','defineProperty','NX_CLOUD_DISTRIBUTED_EXECUTION_ID'];(function(_0x165983,_0xdd6125){const _0x4ecbb8=function(_0x2474e7){while(--_0x2474e7){_0x165983['push'](_0x165983['shift']());}};_0x4ecbb8(++_0xdd6125);}(a2_0xdd61,0xc1));const a2_0x4ecb=function(_0x165983,_0xdd6125){_0x165983=_0x165983-0x0;let _0x4ecbb8=a2_0xdd61[_0x165983];return _0x4ecbb8;};'use strict';var __awaiter=this&&this[a2_0x4ecb('0x29')]||function(_0xff29f8,_0x113e21,_0x622f0c,_0x211b11){function _0x51648d(_0x111fb2){return _0x111fb2 instanceof _0x622f0c?_0x111fb2:new _0x622f0c(function(_0x4c2340){_0x4c2340(_0x111fb2);});}return new(_0x622f0c||(_0x622f0c=Promise))(function(_0x5d71b1,_0x557909){function _0x18cfb0(_0x5cd6be){try{_0x42fbed(_0x211b11[a2_0x4ecb('0x1c')](_0x5cd6be));}catch(_0x339872){_0x557909(_0x339872);}}function _0x4b0526(_0x20da7f){try{_0x42fbed(_0x211b11[a2_0x4ecb('0x1f')](_0x20da7f));}catch(_0x2f02c1){_0x557909(_0x2f02c1);}}function _0x42fbed(_0x505ec4){_0x505ec4[a2_0x4ecb('0xa')]?_0x5d71b1(_0x505ec4[a2_0x4ecb('0x21')]):_0x51648d(_0x505ec4[a2_0x4ecb('0x21')])[a2_0x4ecb('0xd')](_0x18cfb0,_0x4b0526);}_0x42fbed((_0x211b11=_0x211b11[a2_0x4ecb('0x8')](_0xff29f8,_0x113e21||[]))[a2_0x4ecb('0x1c')]());});};Object[a2_0x4ecb('0x2d')](exports,a2_0x4ecb('0x10'),{'value':!![]});exports['CloudRemoteCache']=void 0x0;const environment_1=require(a2_0x4ecb('0x1e'));const {output}=require(a2_0x4ecb('0x16'));class CloudRemoteCache{constructor(_0x58b2b9,_0x156e74,_0x596dfd,_0x5d37e0){this[a2_0x4ecb('0xe')]=_0x58b2b9;this[a2_0x4ecb('0x11')]=_0x156e74;this[a2_0x4ecb('0x2f')]=_0x596dfd;this[a2_0x4ecb('0xc')]=_0x5d37e0;this[a2_0x4ecb('0x13')]=[];}[a2_0x4ecb('0x15')](_0x42e82a,_0x3b75fe){var _0x2d57c7;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x4ecb('0xe')][a2_0x4ecb('0x3')])return![];const _0x9c1393=yield this[a2_0x4ecb('0x28')](_0x42e82a);if(!_0x9c1393||!_0x9c1393['get']){if(environment_1[a2_0x4ecb('0x18')]){output[a2_0x4ecb('0x14')]({'title':a2_0x4ecb('0x2')+_0x42e82a+'.'});}this['runContext'][a2_0x4ecb('0x1')][_0x42e82a]='cache-miss';return![];}try{yield this[a2_0x4ecb('0xc')][a2_0x4ecb('0x15')](_0x42e82a,_0x9c1393[a2_0x4ecb('0x4')],_0x3b75fe);this[a2_0x4ecb('0x2f')][a2_0x4ecb('0x1')][_0x42e82a]=a2_0x4ecb('0x5');return!![];}catch(_0x1d42d5){const _0x39c2a2=(_0x2d57c7=_0x1d42d5[a2_0x4ecb('0x0')])!==null&&_0x2d57c7!==void 0x0?_0x2d57c7:_0x1d42d5;if(_0x39c2a2[a2_0x4ecb('0x2b')]&&_0x39c2a2['response'][a2_0x4ecb('0x24')]===0x194){if(environment_1[a2_0x4ecb('0x18')]){output['note']({'title':a2_0x4ecb('0x2')+_0x42e82a+a2_0x4ecb('0x7')});}}else{this['messages'][a2_0x4ecb('0x3')]=this[a2_0x4ecb('0xe')][a2_0x4ecb('0xf')](_0x39c2a2,a2_0x4ecb('0x1a'));}this[a2_0x4ecb('0x2f')]['statuses'][_0x42e82a]=a2_0x4ecb('0x19');return![];}});}['store'](_0x27bb34,_0x10788f){return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a2_0x4ecb('0x3')])return![];const _0xa2a3d7=Promise['resolve']()[a2_0x4ecb('0xd')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x489101;const _0x45b06a=yield this[a2_0x4ecb('0x28')](_0x27bb34);if(!_0x45b06a)return![];if(!_0x45b06a[a2_0x4ecb('0x25')]){if(environment_1[a2_0x4ecb('0x18')]){output[a2_0x4ecb('0x14')]({'title':a2_0x4ecb('0x12')+_0x27bb34+'.\x20Read\x20only\x20token\x20is\x20used.'});}return!![];}try{yield this[a2_0x4ecb('0xc')][a2_0x4ecb('0x20')](_0x27bb34,_0x45b06a['put'],_0x10788f);return!![];}catch(_0x42431e){const _0x3877bf=(_0x489101=_0x42431e[a2_0x4ecb('0x0')])!==null&&_0x489101!==void 0x0?_0x489101:_0x42431e;this[a2_0x4ecb('0xe')][a2_0x4ecb('0x3')]=this[a2_0x4ecb('0xe')][a2_0x4ecb('0xf')](_0x3877bf,'storage');return![];}}));this[a2_0x4ecb('0x13')][a2_0x4ecb('0x26')](_0xa2a3d7);return _0xa2a3d7;});}['hashUrls'](_0xb3fbe6){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0xb3fbe6 in this['runContext']['requests']){return(yield this[a2_0x4ecb('0x2f')][a2_0x4ecb('0x23')][_0xb3fbe6])[_0xb3fbe6];}else{const _0x79d8f6=this[a2_0x4ecb('0x2f')][a2_0x4ecb('0x2c')][a2_0x4ecb('0x27')](_0x361e52=>!this[a2_0x4ecb('0x2f')][a2_0x4ecb('0x23')][_0x361e52[a2_0x4ecb('0x1b')]])[a2_0x4ecb('0x6')](_0x2ab371=>_0x2ab371['hash']);if(_0x79d8f6[a2_0x4ecb('0x22')](_0xb3fbe6)===-0x1){_0x79d8f6[a2_0x4ecb('0x26')](_0xb3fbe6);}const _0x468198=this['api'][a2_0x4ecb('0x9')](environment_1[a2_0x4ecb('0x2e')],_0x79d8f6);_0x79d8f6[a2_0x4ecb('0x1d')](_0x31f45e=>{this[a2_0x4ecb('0x2f')][a2_0x4ecb('0x23')][_0x31f45e]=_0x468198;});return(yield _0x468198)[_0xb3fbe6];}});}[a2_0x4ecb('0xb')](){return Promise['all'](this[a2_0x4ecb('0x13')])['then'](_0x16a48b=>_0x16a48b[a2_0x4ecb('0x2a')]((_0x317206,_0x3489c4)=>_0x317206&&_0x3489c4,!![]));}}exports[a2_0x4ecb('0x17')]=CloudRemoteCache;
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 +1,167 @@
1
- const a3_0x3640=['headers','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','mapRespToPerfEntry','data','response','createMetricRecorder','stack','Invalid\x20end\x20run\x20response','devDependencies','Run\x20completion\x20responded\x20with\x20`undefined`.','success','length','apply','status','map','terminalOutput','api','@nrwl/nx-cloud','/nx-cloud/runs/end','apiError','recordMetric','nxCloudVersion','createReqBody','axiosException','util','parse','machineInfo','defineProperty','Invalid\x20Nx\x20Cloud\x20response:\x20','note','../../../utilities/environment','promisify','CloudRunApi','axiosMultipleTries','runContext','../../../utilities/metric-logger','__esModule','urls','toString','then','Stack\x20Trace:','...','messages','endRun','post','slice','extractErrorMessage','throw','zlib','Run\x20Details:','getRunGroup','done','from','defaults','gzip','RunStart','stringify','startRun','runUrl','error','RUNNER_FAILURE_PERF_ENTRY','unknown','printDuration','Invalid\x20end\x20run\x20response:\x20','/nx-cloud/runs/start','next','message','__awaiter','RunEnd.\x20Completed\x20tasks','assign','value','VERBOSE_LOGGING'];(function(_0x3efe6d,_0x3640a7){const _0x5d8ca5=function(_0x2f9e70){while(--_0x2f9e70){_0x3efe6d['push'](_0x3efe6d['shift']());}};_0x5d8ca5(++_0x3640a7);}(a3_0x3640,0x16c));const a3_0x5d8c=function(_0x3efe6d,_0x3640a7){_0x3efe6d=_0x3efe6d-0x0;let _0x5d8ca5=a3_0x3640[_0x3efe6d];return _0x5d8ca5;};'use strict';var __awaiter=this&&this[a3_0x5d8c('0x3f')]||function(_0x22c294,_0x241545,_0x1e881d,_0x384180){function _0xee1280(_0x37469f){return _0x37469f instanceof _0x1e881d?_0x37469f:new _0x1e881d(function(_0x280762){_0x280762(_0x37469f);});}return new(_0x1e881d||(_0x1e881d=Promise))(function(_0x3034c1,_0x28857e){function _0x3a1e1c(_0xccc244){try{_0x4d6711(_0x384180[a3_0x5d8c('0x3d')](_0xccc244));}catch(_0xc4d39f){_0x28857e(_0xc4d39f);}}function _0x188966(_0x202629){try{_0x4d6711(_0x384180[a3_0x5d8c('0x2b')](_0x202629));}catch(_0x4e1e29){_0x28857e(_0x4e1e29);}}function _0x4d6711(_0x53eec1){_0x53eec1[a3_0x5d8c('0x2f')]?_0x3034c1(_0x53eec1[a3_0x5d8c('0x42')]):_0xee1280(_0x53eec1['value'])[a3_0x5d8c('0x23')](_0x3a1e1c,_0x188966);}_0x4d6711((_0x384180=_0x384180[a3_0x5d8c('0x8')](_0x22c294,_0x241545||[]))[a3_0x5d8c('0x3d')]());});};Object[a3_0x5d8c('0x17')](exports,a3_0x5d8c('0x20'),{'value':!![]});exports[a3_0x5d8c('0x1c')]=void 0x0;const axios_1=require('../../../utilities/axios');const environment_1=require(a3_0x5d8c('0x1a'));const fs_1=require('fs');const zlib_1=require(a3_0x5d8c('0x2c'));const util_1=require(a3_0x5d8c('0x14'));const metric_logger_1=require(a3_0x5d8c('0x1f'));const {output}=require('../../../utilities/nx-imports');class CloudRunApi{constructor(_0x2266cc,_0x4157ff,_0x2393e4,_0x369a7a){this[a3_0x5d8c('0x26')]=_0x2266cc;this[a3_0x5d8c('0x1e')]=_0x4157ff;this[a3_0x5d8c('0x16')]=_0x369a7a;this['apiAxiosInstance']=(0x0,axios_1['createApiAxiosInstance'])(_0x2393e4);}['startRun'](_0x257dc3,_0x41db9){var _0x4e8344;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x3af6e1=(0x0,metric_logger_1[a3_0x5d8c('0x1')])(a3_0x5d8c('0x35'));try{const _0xa3d902={'meta':{'nxCloudVersion':this[a3_0x5d8c('0x11')]()},'branch':(0x0,environment_1['getBranch'])(),'runGroup':(0x0,environment_1[a3_0x5d8c('0x2e')])(),'distributedExecutionId':_0x257dc3,'hashes':_0x41db9};if(environment_1[a3_0x5d8c('0x43')]){output[a3_0x5d8c('0x19')]({'title':a3_0x5d8c('0x33'),'bodyLines':['\x0a'+JSON[a3_0x5d8c('0x34')](_0xa3d902,null,0x2)]});}const _0x32d84c=yield(0x0,axios_1[a3_0x5d8c('0x3a')])('RunStart\x20duration',()=>(0x0,axios_1[a3_0x5d8c('0x1d')])(()=>this['apiAxiosInstance'][a3_0x5d8c('0x28')](a3_0x5d8c('0x3c'),_0xa3d902)));_0x3af6e1['recordMetric']((0x0,metric_logger_1[a3_0x5d8c('0x46')])(_0x32d84c));if(_0x32d84c[a3_0x5d8c('0x47')]&&_0x32d84c[a3_0x5d8c('0x47')]['message']){this[a3_0x5d8c('0x26')][a3_0x5d8c('0x3e')]=_0x32d84c['data'][a3_0x5d8c('0x3e')];}if(!_0x32d84c[a3_0x5d8c('0x47')]||!_0x32d84c[a3_0x5d8c('0x47')]['urls']){this[a3_0x5d8c('0x26')][a3_0x5d8c('0xf')]=a3_0x5d8c('0x18')+JSON[a3_0x5d8c('0x34')](_0x32d84c[a3_0x5d8c('0x47')]);return{};}return _0x32d84c['data'][a3_0x5d8c('0x21')];}catch(_0x538087){_0x3af6e1[a3_0x5d8c('0x10')](((_0x4e8344=_0x538087===null||_0x538087===void 0x0?void 0x0:_0x538087['axiosException'])===null||_0x4e8344===void 0x0?void 0x0:_0x4e8344[a3_0x5d8c('0x0')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x538087[a3_0x5d8c('0x13')][a3_0x5d8c('0x0')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);this[a3_0x5d8c('0x26')][a3_0x5d8c('0xf')]=this['messages'][a3_0x5d8c('0x2a')](_0x538087,a3_0x5d8c('0xc'));return{};}});}[a3_0x5d8c('0x12')](_0xbb228d,_0x2cd71a,_0x5a04a7){const _0xa28803={'meta':{'nxCloudVersion':this[a3_0x5d8c('0x11')]()},'tasks':_0x2cd71a,'run':_0xbb228d,'linkId':_0x5a04a7,'machineInfo':this[a3_0x5d8c('0x16')]};return JSON[a3_0x5d8c('0x34')](_0xa28803);}[a3_0x5d8c('0x27')](_0x27c18a,_0x5aedb3,_0x657f0b){var _0x23cffa,_0x3c9f5d;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x5d8c('0x26')]['apiError'])return![];let _0x3ce2ef=this[a3_0x5d8c('0x12')](_0x27c18a,_0x5aedb3,_0x657f0b);if(_0x3ce2ef[a3_0x5d8c('0x7')]>0x14*0x3e8*0x3e8){_0x3ce2ef=this[a3_0x5d8c('0x12')](_0x27c18a,_0x5aedb3[a3_0x5d8c('0xa')](_0x32eee1=>Object[a3_0x5d8c('0x41')](Object[a3_0x5d8c('0x41')]({},_0x32eee1),{'hashDetails':undefined})));}const _0x227f4a=Buffer[a3_0x5d8c('0x30')](_0x3ce2ef);const _0x1fc532=yield(0x0,util_1[a3_0x5d8c('0x1b')])(zlib_1['gzip'])(_0x227f4a);const _0xe3ea49=(0x0,metric_logger_1['createMetricRecorder'])('endRun');try{if(environment_1[a3_0x5d8c('0x43')]){const _0x3551fd=_0x5aedb3['map'](_0x23d575=>{return Object[a3_0x5d8c('0x41')](Object[a3_0x5d8c('0x41')]({},_0x23d575),{'terminalOutput':_0x23d575['terminalOutput']?_0x23d575[a3_0x5d8c('0xb')][a3_0x5d8c('0x29')](0x0,0x14)+a3_0x5d8c('0x25'):undefined});});output[a3_0x5d8c('0x19')]({'title':a3_0x5d8c('0x40'),'bodyLines':['\x0a'+JSON[a3_0x5d8c('0x34')](_0x3551fd,null,0x2)]});}const _0x5bc412=yield(0x0,axios_1['printDuration'])('RunEnd\x20duration',()=>(0x0,axios_1[a3_0x5d8c('0x1d')])(()=>this['apiAxiosInstance'][a3_0x5d8c('0x28')](a3_0x5d8c('0xe'),_0x1fc532,{'headers':Object['assign'](Object[a3_0x5d8c('0x41')]({},this['apiAxiosInstance'][a3_0x5d8c('0x31')][a3_0x5d8c('0x44')]),{'Content-Encoding':a3_0x5d8c('0x32'),'Content-Type':'application/octet-stream'})})));if(_0x5bc412){_0xe3ea49[a3_0x5d8c('0x10')]((0x0,metric_logger_1[a3_0x5d8c('0x46')])(_0x5bc412));if(_0x5bc412[a3_0x5d8c('0x47')]&&_0x5bc412['data'][a3_0x5d8c('0x36')]&&_0x5bc412['data'][a3_0x5d8c('0x9')]===a3_0x5d8c('0x6')){this[a3_0x5d8c('0x1e')][a3_0x5d8c('0x36')]=_0x5bc412[a3_0x5d8c('0x47')][a3_0x5d8c('0x36')];return!![];}if(_0x5bc412[a3_0x5d8c('0x47')]&&_0x5bc412['data'][a3_0x5d8c('0x9')]){this[a3_0x5d8c('0x26')]['apiError']='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0x5d8c('0x34')](_0x5bc412[a3_0x5d8c('0x47')][a3_0x5d8c('0x3e')]);}else if(_0x5bc412['data']&&typeof _0x5bc412[a3_0x5d8c('0x47')]==='string'){if(_0x5bc412[a3_0x5d8c('0x47')]!==a3_0x5d8c('0x6')){this['messages'][a3_0x5d8c('0xf')]=a3_0x5d8c('0x3b')+JSON['stringify'](_0x5bc412[a3_0x5d8c('0x47')]);}}else{this[a3_0x5d8c('0x26')][a3_0x5d8c('0xf')]=a3_0x5d8c('0x3b')+JSON[a3_0x5d8c('0x34')](_0x5bc412['data']);}if(environment_1['VERBOSE_LOGGING']){output[a3_0x5d8c('0x19')]({'title':a3_0x5d8c('0x3'),'bodyLines':[JSON[a3_0x5d8c('0x34')](_0x5bc412['data'],null,0x2)]});}}else{output[a3_0x5d8c('0x37')]({'title':a3_0x5d8c('0x45'),'bodyLines':[a3_0x5d8c('0x5'),a3_0x5d8c('0x2d'),JSON[a3_0x5d8c('0x34')](_0x27c18a,null,0x2),a3_0x5d8c('0x24'),JSON['stringify'](new Error()[a3_0x5d8c('0x2')],null,0x2)]});}return![];}catch(_0x279df5){_0xe3ea49[a3_0x5d8c('0x10')](((_0x23cffa=_0x279df5===null||_0x279df5===void 0x0?void 0x0:_0x279df5[a3_0x5d8c('0x13')])===null||_0x23cffa===void 0x0?void 0x0:_0x23cffa[a3_0x5d8c('0x0')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x279df5[a3_0x5d8c('0x13')][a3_0x5d8c('0x0')]):metric_logger_1[a3_0x5d8c('0x38')]);const _0x474850=(_0x3c9f5d=_0x279df5[a3_0x5d8c('0x13')])!==null&&_0x3c9f5d!==void 0x0?_0x3c9f5d:_0x279df5;this[a3_0x5d8c('0x26')][a3_0x5d8c('0xf')]=this[a3_0x5d8c('0x26')][a3_0x5d8c('0x2a')](_0x474850,a3_0x5d8c('0xc'));return![];}});}[a3_0x5d8c('0x11')](){try{const _0x142bb1=JSON[a3_0x5d8c('0x15')]((0x0,fs_1['readFileSync'])('package.json')[a3_0x5d8c('0x22')]());return _0x142bb1[a3_0x5d8c('0x4')][a3_0x5d8c('0xd')];}catch(_0x5b82c1){return a3_0x5d8c('0x39');}}}exports['CloudRunApi']=CloudRunApi;
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.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request)));
48
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
49
+ if (resp.data && resp.data.message) {
50
+ this.messages.message = resp.data.message;
51
+ }
52
+ if (!resp.data || !resp.data.urls) {
53
+ this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
54
+ return {};
55
+ }
56
+ return resp.data.urls;
57
+ }
58
+ catch (e) {
59
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
60
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
61
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
62
+ this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
63
+ return {};
64
+ }
65
+ });
66
+ }
67
+ createReqBody(run, tasks, linkId) {
68
+ const uncompressedReqBody = {
69
+ meta: {
70
+ nxCloudVersion: this.nxCloudVersion(),
71
+ },
72
+ tasks,
73
+ run,
74
+ linkId,
75
+ machineInfo: this.machineInfo,
76
+ };
77
+ return JSON.stringify(uncompressedReqBody);
78
+ }
79
+ endRun(run, tasks, linkId) {
80
+ var _a, _b;
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ // API is not working, don't make the end request
83
+ if (this.messages.apiError)
84
+ return false;
85
+ let uncompressedBodyString = this.createReqBody(run, tasks, linkId);
86
+ // if the req body is > 20mb, remove hashDetails
87
+ if (uncompressedBodyString.length > 20 * 1000 * 1000) {
88
+ uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))));
89
+ }
90
+ const uncompressedBuffer = Buffer.from(uncompressedBodyString);
91
+ const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
92
+ const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
93
+ try {
94
+ if (environment_1.VERBOSE_LOGGING) {
95
+ const t = tasks.map((tt) => {
96
+ return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
97
+ ? `${tt.terminalOutput.slice(0, 20)}...`
98
+ : undefined });
99
+ });
100
+ output.note({
101
+ title: 'RunEnd. Completed tasks',
102
+ bodyLines: ['\n' + JSON.stringify(t, null, 2)],
103
+ });
104
+ }
105
+ const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
106
+ headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
107
+ })));
108
+ if (resp) {
109
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
110
+ if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
111
+ this.runContext.runUrl = resp.data.runUrl;
112
+ return true;
113
+ }
114
+ if (resp.data && resp.data.status) {
115
+ this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
116
+ }
117
+ else if (resp.data && typeof resp.data === 'string') {
118
+ if (resp.data !== 'success') {
119
+ this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
120
+ }
121
+ }
122
+ else {
123
+ this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
124
+ }
125
+ if (environment_1.VERBOSE_LOGGING) {
126
+ output.note({
127
+ title: 'Invalid end run response',
128
+ bodyLines: [JSON.stringify(resp.data, null, 2)],
129
+ });
130
+ }
131
+ }
132
+ else {
133
+ output.error({
134
+ title: 'Nx Cloud: Unknown Error Occurred',
135
+ bodyLines: [
136
+ 'Run completion responded with `undefined`.',
137
+ 'Run Details:',
138
+ JSON.stringify(run, null, 2),
139
+ 'Stack Trace:',
140
+ JSON.stringify(new Error().stack, null, 2),
141
+ ],
142
+ });
143
+ }
144
+ return false;
145
+ }
146
+ catch (ee) {
147
+ recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
148
+ ? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
149
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
150
+ const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
151
+ this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
152
+ return false;
153
+ }
154
+ });
155
+ }
156
+ nxCloudVersion() {
157
+ try {
158
+ const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
159
+ return v.devDependencies['@nrwl/nx-cloud'];
160
+ }
161
+ catch (e) {
162
+ return 'unknown';
163
+ }
164
+ }
165
+ }
166
+ exports.CloudRunApi = CloudRunApi;
167
+ //# sourceMappingURL=cloud-run.api.js.map
@@ -1 +1,16 @@
1
- const a4_0x26ff=['__esModule','0123456789','generateUniqueLinkId','random','length','floor','toLowerCase','ABCDEFGHIJKLMNOPQRSTUVWXYZ','defineProperty'];(function(_0x10cea5,_0x26ff8a){const _0x1c5d1a=function(_0x138740){while(--_0x138740){_0x10cea5['push'](_0x10cea5['shift']());}};_0x1c5d1a(++_0x26ff8a);}(a4_0x26ff,0xaa));const a4_0x1c5d=function(_0x10cea5,_0x26ff8a){_0x10cea5=_0x10cea5-0x0;let _0x1c5d1a=a4_0x26ff[_0x10cea5];return _0x1c5d1a;};'use strict';Object[a4_0x1c5d('0x0')](exports,a4_0x1c5d('0x1'),{'value':!![]});exports[a4_0x1c5d('0x3')]=void 0x0;const upper=a4_0x1c5d('0x8');const digits=a4_0x1c5d('0x2');const lower=upper[a4_0x1c5d('0x7')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x42cde2='';for(let _0x4eb0ca=0x0;_0x4eb0ca<0xa;++_0x4eb0ca){_0x42cde2+=alphanum[Math[a4_0x1c5d('0x6')](Math[a4_0x1c5d('0x4')]()*alphanum[a4_0x1c5d('0x5')])];}return _0x42cde2;}exports[a4_0x1c5d('0x3')]=generateUniqueLinkId;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateUniqueLinkId = void 0;
4
+ const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
5
+ const digits = '0123456789';
6
+ const lower = upper.toLowerCase();
7
+ const alphanum = upper + lower + digits;
8
+ function generateUniqueLinkId() {
9
+ let res = '';
10
+ for (let i = 0; i < 10; ++i) {
11
+ res += alphanum[Math.floor(Math.random() * alphanum.length)];
12
+ }
13
+ return res;
14
+ }
15
+ exports.generateUniqueLinkId = generateUniqueLinkId;
16
+ //# sourceMappingURL=id-generator.js.map
@@ -1 +1,79 @@
1
- const a5_0x1738=['runGroup:\x20','/nx-cloud/executions/tasks','tasks','note','axiosException','dtePollTasks','value','data','DistributedAgentApi','createMetricRecorder','done','response','../../../utilities/axios','../../../utilities/nx-imports','throw','../../../utilities/metric-logger','then','runGroup','__awaiter','RUNNER_FAILURE_PERF_ENTRY','mapRespToPerfEntry','error:\x20','VERBOSE_LOGGING','next','axiosMultipleTries','post','/nx-cloud/executions/complete-run-group','../../../utilities/environment','Completing\x20run\x20group\x20with\x20an\x20error','apply','apiAxiosInstance','recordMetric','agentName'];(function(_0x454c87,_0x1738f){const _0x450b1f=function(_0xe3687f){while(--_0xe3687f){_0x454c87['push'](_0x454c87['shift']());}};_0x450b1f(++_0x1738f);}(a5_0x1738,0x187));const a5_0x450b=function(_0x454c87,_0x1738f){_0x454c87=_0x454c87-0x0;let _0x450b1f=a5_0x1738[_0x454c87];return _0x450b1f;};'use strict';var __awaiter=this&&this[a5_0x450b('0x17')]||function(_0x53d8aa,_0x535621,_0x3c885c,_0x201606){function _0x315225(_0x5f29d5){return _0x5f29d5 instanceof _0x3c885c?_0x5f29d5:new _0x3c885c(function(_0x263b61){_0x263b61(_0x5f29d5);});}return new(_0x3c885c||(_0x3c885c=Promise))(function(_0xbb1019,_0x29031d){function _0x166198(_0x15779c){try{_0x4546d2(_0x201606[a5_0x450b('0x1c')](_0x15779c));}catch(_0x333a23){_0x29031d(_0x333a23);}}function _0x439bfc(_0x436cf4){try{_0x4546d2(_0x201606[a5_0x450b('0x13')](_0x436cf4));}catch(_0x28954c){_0x29031d(_0x28954c);}}function _0x4546d2(_0x4d7045){_0x4d7045[a5_0x450b('0xf')]?_0xbb1019(_0x4d7045[a5_0x450b('0xb')]):_0x315225(_0x4d7045[a5_0x450b('0xb')])[a5_0x450b('0x15')](_0x166198,_0x439bfc);}_0x4546d2((_0x201606=_0x201606[a5_0x450b('0x1')](_0x53d8aa,_0x535621||[]))['next']());});};Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a5_0x450b('0xd')]=void 0x0;const axios_1=require(a5_0x450b('0x11'));const environment_1=require(a5_0x450b('0x20'));const metric_logger_1=require(a5_0x450b('0x14'));const {output}=require(a5_0x450b('0x12'));class DistributedAgentApi{constructor(_0x43deba,_0x48ea25,_0x302baa){this[a5_0x450b('0x16')]=_0x48ea25;this['agentName']=_0x302baa;this[a5_0x450b('0x2')]=(0x0,axios_1['createApiAxiosInstance'])(_0x43deba);}[a5_0x450b('0x7')](_0x3f6ee2,_0x5b69f0,_0x27eec3){var _0x39dd5c;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x57bd73=(0x0,metric_logger_1[a5_0x450b('0xe')])(a5_0x450b('0xa'));try{const _0x166d3b=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a5_0x450b('0x2')][a5_0x450b('0x1e')](a5_0x450b('0x6'),{'runGroup':this['runGroup'],'agentName':this['agentName'],'executionId':_0x3f6ee2,'statusCode':_0x5b69f0,'completedTasks':_0x27eec3}));_0x57bd73['recordMetric']((0x0,metric_logger_1[a5_0x450b('0x19')])(_0x166d3b));return _0x166d3b[a5_0x450b('0xc')];}catch(_0x4cd0e6){_0x57bd73[a5_0x450b('0x3')](((_0x39dd5c=_0x4cd0e6===null||_0x4cd0e6===void 0x0?void 0x0:_0x4cd0e6[a5_0x450b('0x9')])===null||_0x39dd5c===void 0x0?void 0x0:_0x39dd5c[a5_0x450b('0x10')])?(0x0,metric_logger_1[a5_0x450b('0x19')])(_0x4cd0e6[a5_0x450b('0x9')]['response']):metric_logger_1[a5_0x450b('0x18')]);throw _0x4cd0e6;}});}['completeRunGroupWithError'](_0x1f6b72){var _0x2c5259;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a5_0x450b('0x1b')]){output[a5_0x450b('0x8')]({'title':a5_0x450b('0x0'),'bodyLines':[a5_0x450b('0x5')+this[a5_0x450b('0x16')],a5_0x450b('0x1a')+_0x1f6b72]});}const _0x589332=(0x0,metric_logger_1[a5_0x450b('0xe')])('completeRunGroup');try{const _0x52e6a7=yield(0x0,axios_1[a5_0x450b('0x1d')])(()=>this['apiAxiosInstance'][a5_0x450b('0x1e')](a5_0x450b('0x1f'),{'runGroup':this['runGroup'],'agentName':this[a5_0x450b('0x4')],'criticalErrorMessage':_0x1f6b72}));if(environment_1[a5_0x450b('0x1b')]){output[a5_0x450b('0x8')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0x589332[a5_0x450b('0x3')]((0x0,metric_logger_1[a5_0x450b('0x19')])(_0x52e6a7));}catch(_0x5c73df){_0x589332[a5_0x450b('0x3')](((_0x2c5259=_0x5c73df===null||_0x5c73df===void 0x0?void 0x0:_0x5c73df[a5_0x450b('0x9')])===null||_0x2c5259===void 0x0?void 0x0:_0x2c5259['response'])?(0x0,metric_logger_1[a5_0x450b('0x19')])(_0x5c73df['axiosException'][a5_0x450b('0x10')]):metric_logger_1[a5_0x450b('0x18')]);console['error'](_0x5c73df);}});}}exports['DistributedAgentApi']=DistributedAgentApi;
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