@nrwl/nx-cloud 15.0.0 → 15.0.1-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_0x2ded=['value','extractErrorMessage','storage','cache-miss','retrieve','__esModule','resolve','messages','then','apply','api','Nx\x20Cloud:\x20Skipping\x20storing\x20','store','startRun','requests','scheduledTasks','cacheError','fileStorage','CloudRemoteCache','statuses','indexOf','get','__awaiter','.\x20Read\x20only\x20token\x20is\x20used.','status','done','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','hashUrls','response','Nx\x20Cloud:\x20Cache\x20miss\x20','forEach','push','runContext','put','reduce','VERBOSE_LOGGING','storeRequests','note','.\x20Status\x20404.','waitForStoreRequestsToComplete','hash','all','throw','../../../utilities/nx-imports','next'];(function(_0xc01854,_0x2ded75){const _0x19da88=function(_0x434d2e){while(--_0x434d2e){_0xc01854['push'](_0xc01854['shift']());}};_0x19da88(++_0x2ded75);}(a2_0x2ded,0x96));const a2_0x19da=function(_0xc01854,_0x2ded75){_0xc01854=_0xc01854-0x0;let _0x19da88=a2_0x2ded[_0xc01854];return _0x19da88;};'use strict';var __awaiter=this&&this[a2_0x19da('0x7')]||function(_0x53158b,_0x2cf92c,_0x271c84,_0x21c7c5){function _0x142b9e(_0x5c04e7){return _0x5c04e7 instanceof _0x271c84?_0x5c04e7:new _0x271c84(function(_0x5464a4){_0x5464a4(_0x5c04e7);});}return new(_0x271c84||(_0x271c84=Promise))(function(_0x5eb689,_0x1f5eef){function _0x19e8db(_0x3368e9){try{_0x15e176(_0x21c7c5['next'](_0x3368e9));}catch(_0x1570bd){_0x1f5eef(_0x1570bd);}}function _0x223b39(_0x24b6f7){try{_0x15e176(_0x21c7c5[a2_0x19da('0x1b')](_0x24b6f7));}catch(_0x270f15){_0x1f5eef(_0x270f15);}}function _0x15e176(_0x2425f6){_0x2425f6[a2_0x19da('0xa')]?_0x5eb689(_0x2425f6['value']):_0x142b9e(_0x2425f6[a2_0x19da('0x1e')])[a2_0x19da('0x26')](_0x19e8db,_0x223b39);}_0x15e176((_0x21c7c5=_0x21c7c5[a2_0x19da('0x27')](_0x53158b,_0x2cf92c||[]))[a2_0x19da('0x1d')]());});};Object['defineProperty'](exports,a2_0x19da('0x23'),{'value':!![]});exports[a2_0x19da('0x3')]=void 0x0;const environment_1=require('../../../utilities/environment');const {output}=require(a2_0x19da('0x1c'));class CloudRemoteCache{constructor(_0x3ba44c,_0x5de079,_0x514401,_0x6fa4e7){this[a2_0x19da('0x25')]=_0x3ba44c;this[a2_0x19da('0x28')]=_0x5de079;this['runContext']=_0x514401;this[a2_0x19da('0x2')]=_0x6fa4e7;this[a2_0x19da('0x15')]=[];}[a2_0x19da('0x22')](_0xa4c55a,_0x39384e){var _0xe155cf;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x19da('0x25')]['cacheError'])return![];const _0x4b80d5=yield this['hashUrls'](_0xa4c55a);if(!_0x4b80d5||!_0x4b80d5[a2_0x19da('0x6')]){if(environment_1[a2_0x19da('0x14')]){output[a2_0x19da('0x16')]({'title':a2_0x19da('0xe')+_0xa4c55a+'.'});}this[a2_0x19da('0x11')][a2_0x19da('0x4')][_0xa4c55a]=a2_0x19da('0x21');return![];}try{yield this[a2_0x19da('0x2')]['retrieve'](_0xa4c55a,_0x4b80d5[a2_0x19da('0x6')],_0x39384e);this[a2_0x19da('0x11')][a2_0x19da('0x4')][_0xa4c55a]='remote-cache-hit';return!![];}catch(_0x88027b){const _0x353fa0=(_0xe155cf=_0x88027b['axiosException'])!==null&&_0xe155cf!==void 0x0?_0xe155cf:_0x88027b;if(_0x353fa0[a2_0x19da('0xd')]&&_0x353fa0[a2_0x19da('0xd')][a2_0x19da('0x9')]===0x194){if(environment_1[a2_0x19da('0x14')]){output['note']({'title':'Nx\x20Cloud:\x20Cache\x20miss\x20'+_0xa4c55a+a2_0x19da('0x17')});}}else{this[a2_0x19da('0x25')][a2_0x19da('0x1')]=this[a2_0x19da('0x25')][a2_0x19da('0x1f')](_0x353fa0,a2_0x19da('0x20'));}this[a2_0x19da('0x11')]['statuses'][_0xa4c55a]=a2_0x19da('0x21');return![];}});}[a2_0x19da('0x2a')](_0x288240,_0x76e0f6){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x19da('0x25')][a2_0x19da('0x1')])return![];const _0x32c21d=Promise[a2_0x19da('0x24')]()[a2_0x19da('0x26')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x47d403;const _0x47045b=yield this[a2_0x19da('0xc')](_0x288240);if(!_0x47045b)return![];if(!_0x47045b[a2_0x19da('0x12')]){if(environment_1[a2_0x19da('0x14')]){output[a2_0x19da('0x16')]({'title':a2_0x19da('0x29')+_0x288240+a2_0x19da('0x8')});}return!![];}try{yield this[a2_0x19da('0x2')][a2_0x19da('0x2a')](_0x288240,_0x47045b[a2_0x19da('0x12')],_0x76e0f6);return!![];}catch(_0x12cd5d){const _0x129520=(_0x47d403=_0x12cd5d['axiosException'])!==null&&_0x47d403!==void 0x0?_0x47d403:_0x12cd5d;this[a2_0x19da('0x25')][a2_0x19da('0x1')]=this[a2_0x19da('0x25')]['extractErrorMessage'](_0x129520,a2_0x19da('0x20'));return![];}}));this[a2_0x19da('0x15')][a2_0x19da('0x10')](_0x32c21d);return _0x32c21d;});}[a2_0x19da('0xc')](_0x2ddb45){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x2ddb45 in this[a2_0x19da('0x11')]['requests']){return(yield this[a2_0x19da('0x11')][a2_0x19da('0x2c')][_0x2ddb45])[_0x2ddb45];}else{const _0x403234=this[a2_0x19da('0x11')][a2_0x19da('0x0')]['filter'](_0x25a46e=>!this[a2_0x19da('0x11')][a2_0x19da('0x2c')][_0x25a46e[a2_0x19da('0x19')]])['map'](_0x15f72b=>_0x15f72b[a2_0x19da('0x19')]);if(_0x403234[a2_0x19da('0x5')](_0x2ddb45)===-0x1){_0x403234[a2_0x19da('0x10')](_0x2ddb45);}const _0xa7b7e=this['api'][a2_0x19da('0x2b')](environment_1[a2_0x19da('0xb')],_0x403234);_0x403234[a2_0x19da('0xf')](_0x34b3c9=>{this['runContext'][a2_0x19da('0x2c')][_0x34b3c9]=_0xa7b7e;});return(yield _0xa7b7e)[_0x2ddb45];}});}[a2_0x19da('0x18')](){return Promise[a2_0x19da('0x1a')](this[a2_0x19da('0x15')])['then'](_0x35c638=>_0x35c638[a2_0x19da('0x13')]((_0x46e105,_0x5311c6)=>_0x46e105&&_0x5311c6,!![]));}}exports['CloudRemoteCache']=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_0x5ea5=['../../../utilities/metric-logger','RunEnd.\x20Completed\x20tasks','runUrl','message','Stack\x20Trace:','Invalid\x20end\x20run\x20response:\x20','Invalid\x20Nx\x20Cloud\x20response:\x20','zlib','response','success','assign','util','apply','endRun','RunStart\x20duration','apiError','gzip','urls','done','axiosException','Run\x20completion\x20responded\x20with\x20`undefined`.','string','map','getRunGroup','Invalid\x20end\x20run\x20response','unknown','stringify','createReqBody','printDuration','mapRespToPerfEntry','data','...','axiosMultipleTries','parse','then','api','toString','nxCloudVersion','RunEnd\x20duration','stack','../../../utilities/axios','readFileSync','next','CloudRunApi','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','slice','post','__awaiter','apiAxiosInstance','devDependencies','getBranch','application/octet-stream','status','Run\x20Details:','note','promisify','throw','value','terminalOutput','createMetricRecorder','extractErrorMessage','messages','package.json','../../../utilities/nx-imports','recordMetric','VERBOSE_LOGGING','RUNNER_FAILURE_PERF_ENTRY','startRun','/nx-cloud/runs/start'];(function(_0x4179fa,_0x5ea55d){const _0x50a0b6=function(_0x238603){while(--_0x238603){_0x4179fa['push'](_0x4179fa['shift']());}};_0x50a0b6(++_0x5ea55d);}(a3_0x5ea5,0x177));const a3_0x50a0=function(_0x4179fa,_0x5ea55d){_0x4179fa=_0x4179fa-0x0;let _0x50a0b6=a3_0x5ea5[_0x4179fa];return _0x50a0b6;};'use strict';var __awaiter=this&&this[a3_0x50a0('0x11')]||function(_0x3a4ffb,_0x1746f1,_0x4c4c85,_0x189821){function _0x55a7c4(_0x34972e){return _0x34972e instanceof _0x4c4c85?_0x34972e:new _0x4c4c85(function(_0x1b075f){_0x1b075f(_0x34972e);});}return new(_0x4c4c85||(_0x4c4c85=Promise))(function(_0x32a886,_0x5c6f6e){function _0x385018(_0x11a4e1){try{_0x25a9a3(_0x189821[a3_0x50a0('0xc')](_0x11a4e1));}catch(_0x30c0e7){_0x5c6f6e(_0x30c0e7);}}function _0x164a38(_0x3c5417){try{_0x25a9a3(_0x189821[a3_0x50a0('0x1a')](_0x3c5417));}catch(_0x23b4b6){_0x5c6f6e(_0x23b4b6);}}function _0x25a9a3(_0x391c60){_0x391c60[a3_0x50a0('0x39')]?_0x32a886(_0x391c60[a3_0x50a0('0x1b')]):_0x55a7c4(_0x391c60[a3_0x50a0('0x1b')])[a3_0x50a0('0x4')](_0x385018,_0x164a38);}_0x25a9a3((_0x189821=_0x189821[a3_0x50a0('0x33')](_0x3a4ffb,_0x1746f1||[]))['next']());});};Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a3_0x50a0('0xd')]=void 0x0;const axios_1=require(a3_0x50a0('0xa'));const environment_1=require('../../../utilities/environment');const fs_1=require('fs');const zlib_1=require(a3_0x50a0('0x2e'));const util_1=require(a3_0x50a0('0x32'));const metric_logger_1=require(a3_0x50a0('0x27'));const {output}=require(a3_0x50a0('0x21'));class CloudRunApi{constructor(_0x2bbf85,_0x4d0603,_0x3b1198,_0x766918){this[a3_0x50a0('0x1f')]=_0x2bbf85;this['runContext']=_0x4d0603;this['machineInfo']=_0x766918;this[a3_0x50a0('0x12')]=(0x0,axios_1['createApiAxiosInstance'])(_0x3b1198);}['startRun'](_0x2ae607,_0x3d6b0c){var _0x157f73;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5a0725=(0x0,metric_logger_1['createMetricRecorder'])(a3_0x50a0('0x25'));try{const _0x109431={'meta':{'nxCloudVersion':this[a3_0x50a0('0x7')]()},'branch':(0x0,environment_1[a3_0x50a0('0x14')])(),'runGroup':(0x0,environment_1[a3_0x50a0('0x3e')])(),'distributedExecutionId':_0x2ae607,'hashes':_0x3d6b0c};if(environment_1['VERBOSE_LOGGING']){output[a3_0x50a0('0x18')]({'title':'RunStart','bodyLines':['\x0a'+JSON[a3_0x50a0('0x41')](_0x109431,null,0x2)]});}const _0xd1e45c=yield(0x0,axios_1['printDuration'])(a3_0x50a0('0x35'),()=>(0x0,axios_1[a3_0x50a0('0x2')])(()=>this[a3_0x50a0('0x12')][a3_0x50a0('0x10')](a3_0x50a0('0x26'),_0x109431)));_0x5a0725[a3_0x50a0('0x22')]((0x0,metric_logger_1[a3_0x50a0('0x44')])(_0xd1e45c));if(_0xd1e45c[a3_0x50a0('0x0')]&&_0xd1e45c[a3_0x50a0('0x0')][a3_0x50a0('0x2a')]){this[a3_0x50a0('0x1f')][a3_0x50a0('0x2a')]=_0xd1e45c['data'][a3_0x50a0('0x2a')];}if(!_0xd1e45c['data']||!_0xd1e45c[a3_0x50a0('0x0')][a3_0x50a0('0x38')]){this[a3_0x50a0('0x1f')][a3_0x50a0('0x36')]=a3_0x50a0('0x2d')+JSON[a3_0x50a0('0x41')](_0xd1e45c[a3_0x50a0('0x0')]);return{};}return _0xd1e45c[a3_0x50a0('0x0')]['urls'];}catch(_0x1a3976){_0x5a0725[a3_0x50a0('0x22')](((_0x157f73=_0x1a3976===null||_0x1a3976===void 0x0?void 0x0:_0x1a3976['axiosException'])===null||_0x157f73===void 0x0?void 0x0:_0x157f73[a3_0x50a0('0x2f')])?(0x0,metric_logger_1[a3_0x50a0('0x44')])(_0x1a3976[a3_0x50a0('0x3a')]['response']):metric_logger_1[a3_0x50a0('0x24')]);this[a3_0x50a0('0x1f')][a3_0x50a0('0x36')]=this['messages'][a3_0x50a0('0x1e')](_0x1a3976,'api');return{};}});}[a3_0x50a0('0x42')](_0x181fb8,_0x2dc12d,_0x3becda){const _0x5f47d4={'meta':{'nxCloudVersion':this[a3_0x50a0('0x7')]()},'tasks':_0x2dc12d,'run':_0x181fb8,'linkId':_0x3becda,'machineInfo':this['machineInfo']};return JSON['stringify'](_0x5f47d4);}[a3_0x50a0('0x34')](_0xee2d35,_0x1599d2,_0x5190c4){var _0x481ab0,_0xa21a19;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x50a0('0x1f')][a3_0x50a0('0x36')])return![];let _0x236ff3=this[a3_0x50a0('0x42')](_0xee2d35,_0x1599d2,_0x5190c4);if(_0x236ff3['length']>0x14*0x3e8*0x3e8){_0x236ff3=this[a3_0x50a0('0x42')](_0xee2d35,_0x1599d2[a3_0x50a0('0x3d')](_0x43af01=>Object[a3_0x50a0('0x31')](Object[a3_0x50a0('0x31')]({},_0x43af01),{'hashDetails':undefined})));}const _0x42207b=Buffer['from'](_0x236ff3);const _0x55340b=yield(0x0,util_1[a3_0x50a0('0x19')])(zlib_1['gzip'])(_0x42207b);const _0x1d42f4=(0x0,metric_logger_1[a3_0x50a0('0x1d')])(a3_0x50a0('0x34'));try{if(environment_1['VERBOSE_LOGGING']){const _0x3be0db=_0x1599d2[a3_0x50a0('0x3d')](_0x39ac10=>{return Object['assign'](Object[a3_0x50a0('0x31')]({},_0x39ac10),{'terminalOutput':_0x39ac10[a3_0x50a0('0x1c')]?_0x39ac10[a3_0x50a0('0x1c')][a3_0x50a0('0xf')](0x0,0x14)+a3_0x50a0('0x1'):undefined});});output[a3_0x50a0('0x18')]({'title':a3_0x50a0('0x28'),'bodyLines':['\x0a'+JSON[a3_0x50a0('0x41')](_0x3be0db,null,0x2)]});}const _0x3e5ff3=yield(0x0,axios_1[a3_0x50a0('0x43')])(a3_0x50a0('0x8'),()=>(0x0,axios_1['axiosMultipleTries'])(()=>this[a3_0x50a0('0x12')][a3_0x50a0('0x10')]('/nx-cloud/runs/end',_0x55340b,{'headers':Object[a3_0x50a0('0x31')](Object[a3_0x50a0('0x31')]({},this[a3_0x50a0('0x12')]['defaults']['headers']),{'Content-Encoding':a3_0x50a0('0x37'),'Content-Type':a3_0x50a0('0x15')})})));if(_0x3e5ff3){_0x1d42f4[a3_0x50a0('0x22')]((0x0,metric_logger_1[a3_0x50a0('0x44')])(_0x3e5ff3));if(_0x3e5ff3[a3_0x50a0('0x0')]&&_0x3e5ff3[a3_0x50a0('0x0')][a3_0x50a0('0x29')]&&_0x3e5ff3[a3_0x50a0('0x0')]['status']==='success'){this['runContext'][a3_0x50a0('0x29')]=_0x3e5ff3['data'][a3_0x50a0('0x29')];return!![];}if(_0x3e5ff3[a3_0x50a0('0x0')]&&_0x3e5ff3[a3_0x50a0('0x0')][a3_0x50a0('0x16')]){this[a3_0x50a0('0x1f')][a3_0x50a0('0x36')]=a3_0x50a0('0x2c')+JSON[a3_0x50a0('0x41')](_0x3e5ff3[a3_0x50a0('0x0')][a3_0x50a0('0x2a')]);}else if(_0x3e5ff3[a3_0x50a0('0x0')]&&typeof _0x3e5ff3['data']===a3_0x50a0('0x3c')){if(_0x3e5ff3['data']!==a3_0x50a0('0x30')){this[a3_0x50a0('0x1f')]['apiError']='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0x50a0('0x41')](_0x3e5ff3[a3_0x50a0('0x0')]);}}else{this[a3_0x50a0('0x1f')][a3_0x50a0('0x36')]=a3_0x50a0('0x2c')+JSON[a3_0x50a0('0x41')](_0x3e5ff3[a3_0x50a0('0x0')]);}if(environment_1[a3_0x50a0('0x23')]){output['note']({'title':a3_0x50a0('0x3f'),'bodyLines':[JSON[a3_0x50a0('0x41')](_0x3e5ff3['data'],null,0x2)]});}}else{output['error']({'title':a3_0x50a0('0xe'),'bodyLines':[a3_0x50a0('0x3b'),a3_0x50a0('0x17'),JSON[a3_0x50a0('0x41')](_0xee2d35,null,0x2),a3_0x50a0('0x2b'),JSON['stringify'](new Error()[a3_0x50a0('0x9')],null,0x2)]});}return![];}catch(_0x831a8e){_0x1d42f4[a3_0x50a0('0x22')](((_0x481ab0=_0x831a8e===null||_0x831a8e===void 0x0?void 0x0:_0x831a8e[a3_0x50a0('0x3a')])===null||_0x481ab0===void 0x0?void 0x0:_0x481ab0[a3_0x50a0('0x2f')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x831a8e[a3_0x50a0('0x3a')]['response']):metric_logger_1[a3_0x50a0('0x24')]);const _0x4126af=(_0xa21a19=_0x831a8e[a3_0x50a0('0x3a')])!==null&&_0xa21a19!==void 0x0?_0xa21a19:_0x831a8e;this[a3_0x50a0('0x1f')][a3_0x50a0('0x36')]=this[a3_0x50a0('0x1f')][a3_0x50a0('0x1e')](_0x4126af,a3_0x50a0('0x5'));return![];}});}[a3_0x50a0('0x7')](){try{const _0x353aca=JSON[a3_0x50a0('0x3')]((0x0,fs_1[a3_0x50a0('0xb')])(a3_0x50a0('0x20'))[a3_0x50a0('0x6')]());return _0x353aca[a3_0x50a0('0x13')]['@nrwl/nx-cloud'];}catch(_0x2b8719){return a3_0x50a0('0x40');}}}exports[a3_0x50a0('0xd')]=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_0x1a92=['random','generateUniqueLinkId','toLowerCase','0123456789','length','ABCDEFGHIJKLMNOPQRSTUVWXYZ'];(function(_0x44185b,_0x1a9273){const _0x38f1f1=function(_0x5b3971){while(--_0x5b3971){_0x44185b['push'](_0x44185b['shift']());}};_0x38f1f1(++_0x1a9273);}(a4_0x1a92,0x182));const a4_0x38f1=function(_0x44185b,_0x1a9273){_0x44185b=_0x44185b-0x0;let _0x38f1f1=a4_0x1a92[_0x44185b];return _0x38f1f1;};'use strict';Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a4_0x38f1('0x5')]=void 0x0;const upper=a4_0x38f1('0x3');const digits=a4_0x38f1('0x1');const lower=upper[a4_0x38f1('0x0')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0xf1004='';for(let _0x3400ed=0x0;_0x3400ed<0xa;++_0x3400ed){_0xf1004+=alphanum[Math['floor'](Math[a4_0x38f1('0x4')]()*alphanum[a4_0x38f1('0x2')])];}return _0xf1004;}exports[a4_0x38f1('0x5')]=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_0xc242=['throw','/nx-cloud/executions/tasks','createMetricRecorder','DistributedAgentApi','value','next','/nx-cloud/executions/complete-run-group','../../../utilities/metric-logger','recordMetric','completeRunGroup','apply','done','note','createApiAxiosInstance','axiosException','error:\x20','__awaiter','error','__esModule','../../../utilities/axios','tasks','axiosMultipleTries','post','../../../utilities/nx-imports','apiAxiosInstance','RUNNER_FAILURE_PERF_ENTRY','completeRunGroupWithError','agentName','mapRespToPerfEntry','defineProperty','runGroup','data','response','VERBOSE_LOGGING'];(function(_0x3816a7,_0xc242){const _0x9c18d9=function(_0x2d6916){while(--_0x2d6916){_0x3816a7['push'](_0x3816a7['shift']());}};_0x9c18d9(++_0xc242);}(a5_0xc242,0x14f));const a5_0x9c18=function(_0x3816a7,_0xc242){_0x3816a7=_0x3816a7-0x0;let _0x9c18d9=a5_0xc242[_0x3816a7];return _0x9c18d9;};'use strict';var __awaiter=this&&this[a5_0x9c18('0x15')]||function(_0x28e485,_0xdb94e0,_0x2674c4,_0x5879d6){function _0x2fcdb1(_0x56a31){return _0x56a31 instanceof _0x2674c4?_0x56a31:new _0x2674c4(function(_0x2e79e3){_0x2e79e3(_0x56a31);});}return new(_0x2674c4||(_0x2674c4=Promise))(function(_0x159ef1,_0x1f728d){function _0x37c80b(_0x181833){try{_0x44cabd(_0x5879d6[a5_0x9c18('0xa')](_0x181833));}catch(_0x11c35d){_0x1f728d(_0x11c35d);}}function _0x2f2e2c(_0x1c7682){try{_0x44cabd(_0x5879d6[a5_0x9c18('0x5')](_0x1c7682));}catch(_0x13044e){_0x1f728d(_0x13044e);}}function _0x44cabd(_0x10f5d1){_0x10f5d1[a5_0x9c18('0x10')]?_0x159ef1(_0x10f5d1[a5_0x9c18('0x9')]):_0x2fcdb1(_0x10f5d1[a5_0x9c18('0x9')])['then'](_0x37c80b,_0x2f2e2c);}_0x44cabd((_0x5879d6=_0x5879d6[a5_0x9c18('0xf')](_0x28e485,_0xdb94e0||[]))[a5_0x9c18('0xa')]());});};Object[a5_0x9c18('0x0')](exports,a5_0x9c18('0x17'),{'value':!![]});exports[a5_0x9c18('0x8')]=void 0x0;const axios_1=require(a5_0x9c18('0x18'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a5_0x9c18('0xc'));const {output}=require(a5_0x9c18('0x1c'));class DistributedAgentApi{constructor(_0x520b13,_0x65df10,_0x57c977){this['runGroup']=_0x65df10;this[a5_0x9c18('0x20')]=_0x57c977;this[a5_0x9c18('0x1d')]=(0x0,axios_1[a5_0x9c18('0x12')])(_0x520b13);}[a5_0x9c18('0x19')](_0x41bc91,_0x2c26c2,_0x457e0d){var _0x5436f0;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x117b30=(0x0,metric_logger_1[a5_0x9c18('0x7')])('dtePollTasks');try{const _0x14ac36=yield(0x0,axios_1[a5_0x9c18('0x1a')])(()=>this[a5_0x9c18('0x1d')][a5_0x9c18('0x1b')](a5_0x9c18('0x6'),{'runGroup':this[a5_0x9c18('0x1')],'agentName':this[a5_0x9c18('0x20')],'executionId':_0x41bc91,'statusCode':_0x2c26c2,'completedTasks':_0x457e0d}));_0x117b30[a5_0x9c18('0xd')]((0x0,metric_logger_1[a5_0x9c18('0x21')])(_0x14ac36));return _0x14ac36[a5_0x9c18('0x2')];}catch(_0x2564e4){_0x117b30['recordMetric'](((_0x5436f0=_0x2564e4===null||_0x2564e4===void 0x0?void 0x0:_0x2564e4[a5_0x9c18('0x13')])===null||_0x5436f0===void 0x0?void 0x0:_0x5436f0['response'])?(0x0,metric_logger_1[a5_0x9c18('0x21')])(_0x2564e4[a5_0x9c18('0x13')][a5_0x9c18('0x3')]):metric_logger_1[a5_0x9c18('0x1e')]);throw _0x2564e4;}});}[a5_0x9c18('0x1f')](_0x2afb5b){var _0x3b7eff;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a5_0x9c18('0x4')]){output[a5_0x9c18('0x11')]({'title':'Completing\x20run\x20group\x20with\x20an\x20error','bodyLines':['runGroup:\x20'+this[a5_0x9c18('0x1')],a5_0x9c18('0x14')+_0x2afb5b]});}const _0x4948a0=(0x0,metric_logger_1[a5_0x9c18('0x7')])(a5_0x9c18('0xe'));try{const _0x112932=yield(0x0,axios_1[a5_0x9c18('0x1a')])(()=>this[a5_0x9c18('0x1d')][a5_0x9c18('0x1b')](a5_0x9c18('0xb'),{'runGroup':this['runGroup'],'agentName':this[a5_0x9c18('0x20')],'criticalErrorMessage':_0x2afb5b}));if(environment_1[a5_0x9c18('0x4')]){output[a5_0x9c18('0x11')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0x4948a0[a5_0x9c18('0xd')]((0x0,metric_logger_1[a5_0x9c18('0x21')])(_0x112932));}catch(_0x2b9ee9){_0x4948a0[a5_0x9c18('0xd')](((_0x3b7eff=_0x2b9ee9===null||_0x2b9ee9===void 0x0?void 0x0:_0x2b9ee9[a5_0x9c18('0x13')])===null||_0x3b7eff===void 0x0?void 0x0:_0x3b7eff[a5_0x9c18('0x3')])?(0x0,metric_logger_1[a5_0x9c18('0x21')])(_0x2b9ee9['axiosException']['response']):metric_logger_1[a5_0x9c18('0x1e')]);console[a5_0x9c18('0x16')](_0x2b9ee9);}});}}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