@nrwl/nx-cloud 14.6.2 → 14.7.0-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_0x100f=['../../../utilities/environment','note','__esModule','Nx\x20Cloud:\x20Cache\x20miss\x20','__awaiter','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','response','hash','scheduledTasks','VERBOSE_LOGGING','store','statuses','resolve','done','hashUrls','get','.\x20Read\x20only\x20token\x20is\x20used.','value','filter','remote-cache-hit','push','next','map','throw','api','messages','then','requests','status','axiosException','cache-miss','waitForStoreRequestsToComplete','CloudRemoteCache','runContext','cacheError','retrieve','storeRequests','../../../utilities/nx-imports','put','extractErrorMessage','fileStorage','storage'];(function(_0x13fb89,_0x100f14){const _0x5166ae=function(_0x27cef6){while(--_0x27cef6){_0x13fb89['push'](_0x13fb89['shift']());}};_0x5166ae(++_0x100f14);}(a2_0x100f,0xb7));const a2_0x5166=function(_0x13fb89,_0x100f14){_0x13fb89=_0x13fb89-0x0;let _0x5166ae=a2_0x100f[_0x13fb89];return _0x5166ae;};'use strict';var __awaiter=this&&this[a2_0x5166('0x1f')]||function(_0x2abcbe,_0x413121,_0x3ab90d,_0x13cc50){function _0x1ecbc2(_0x32d615){return _0x32d615 instanceof _0x3ab90d?_0x32d615:new _0x3ab90d(function(_0x5901ef){_0x5901ef(_0x32d615);});}return new(_0x3ab90d||(_0x3ab90d=Promise))(function(_0x24ac78,_0x223d01){function _0x4addd5(_0x596222){try{_0x45468c(_0x13cc50[a2_0x5166('0x6')](_0x596222));}catch(_0x48701b){_0x223d01(_0x48701b);}}function _0x2542a5(_0x28f504){try{_0x45468c(_0x13cc50[a2_0x5166('0x8')](_0x28f504));}catch(_0x4da8d7){_0x223d01(_0x4da8d7);}}function _0x45468c(_0x13b369){_0x13b369[a2_0x5166('0x28')]?_0x24ac78(_0x13b369[a2_0x5166('0x2')]):_0x1ecbc2(_0x13b369[a2_0x5166('0x2')])['then'](_0x4addd5,_0x2542a5);}_0x45468c((_0x13cc50=_0x13cc50['apply'](_0x2abcbe,_0x413121||[]))[a2_0x5166('0x6')]());});};Object['defineProperty'](exports,a2_0x5166('0x1d'),{'value':!![]});exports[a2_0x5166('0x11')]=void 0x0;const environment_1=require(a2_0x5166('0x1b'));const {output}=require(a2_0x5166('0x16'));class CloudRemoteCache{constructor(_0x510520,_0x3a5a8a,_0x438f12,_0x52fda8){this[a2_0x5166('0xa')]=_0x510520;this[a2_0x5166('0x9')]=_0x3a5a8a;this[a2_0x5166('0x12')]=_0x438f12;this[a2_0x5166('0x19')]=_0x52fda8;this[a2_0x5166('0x15')]=[];}[a2_0x5166('0x14')](_0x521765,_0x2d894f){var _0x500cda;return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a2_0x5166('0x13')])return![];const _0x28043b=yield this[a2_0x5166('0x29')](_0x521765);if(!_0x28043b||!_0x28043b[a2_0x5166('0x0')]){if(environment_1[a2_0x5166('0x24')]){output[a2_0x5166('0x1c')]({'title':'Nx\x20Cloud:\x20Cache\x20miss\x20'+_0x521765+'.'});}this[a2_0x5166('0x12')][a2_0x5166('0x26')][_0x521765]=a2_0x5166('0xf');return![];}try{yield this['fileStorage'][a2_0x5166('0x14')](_0x521765,_0x28043b[a2_0x5166('0x0')],_0x2d894f);this[a2_0x5166('0x12')][a2_0x5166('0x26')][_0x521765]=a2_0x5166('0x4');return!![];}catch(_0x415c2b){const _0x242398=(_0x500cda=_0x415c2b['axiosException'])!==null&&_0x500cda!==void 0x0?_0x500cda:_0x415c2b;if(_0x242398[a2_0x5166('0x21')]&&_0x242398['response'][a2_0x5166('0xd')]===0x194){if(environment_1[a2_0x5166('0x24')]){output[a2_0x5166('0x1c')]({'title':a2_0x5166('0x1e')+_0x521765+'.\x20Status\x20404.'});}}else{this[a2_0x5166('0xa')][a2_0x5166('0x13')]=this[a2_0x5166('0xa')][a2_0x5166('0x18')](_0x242398,a2_0x5166('0x1a'));}this[a2_0x5166('0x12')][a2_0x5166('0x26')][_0x521765]='cache-miss';return![];}});}[a2_0x5166('0x25')](_0x3ba8fa,_0x35baff){return __awaiter(this,void 0x0,void 0x0,function*(){if(this['messages'][a2_0x5166('0x13')])return![];const _0x2baadc=Promise[a2_0x5166('0x27')]()[a2_0x5166('0xb')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x306cd2;const _0x34fbfb=yield this[a2_0x5166('0x29')](_0x3ba8fa);if(!_0x34fbfb)return![];if(!_0x34fbfb[a2_0x5166('0x17')]){if(environment_1[a2_0x5166('0x24')]){output[a2_0x5166('0x1c')]({'title':'Nx\x20Cloud:\x20Skipping\x20storing\x20'+_0x3ba8fa+a2_0x5166('0x1')});}return!![];}try{yield this['fileStorage'][a2_0x5166('0x25')](_0x3ba8fa,_0x34fbfb[a2_0x5166('0x17')],_0x35baff);return!![];}catch(_0x4e6e71){const _0x27d21e=(_0x306cd2=_0x4e6e71[a2_0x5166('0xe')])!==null&&_0x306cd2!==void 0x0?_0x306cd2:_0x4e6e71;this[a2_0x5166('0xa')][a2_0x5166('0x13')]=this[a2_0x5166('0xa')][a2_0x5166('0x18')](_0x27d21e,a2_0x5166('0x1a'));return![];}}));this[a2_0x5166('0x15')][a2_0x5166('0x5')](_0x2baadc);return _0x2baadc;});}[a2_0x5166('0x29')](_0x40b37e){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x40b37e in this['runContext'][a2_0x5166('0xc')]){return(yield this['runContext']['requests'][_0x40b37e])[_0x40b37e];}else{const _0x1497f7=this[a2_0x5166('0x12')][a2_0x5166('0x23')][a2_0x5166('0x3')](_0x5fd848=>!this[a2_0x5166('0x12')][a2_0x5166('0xc')][_0x5fd848[a2_0x5166('0x22')]])[a2_0x5166('0x7')](_0x182ff7=>_0x182ff7[a2_0x5166('0x22')]);if(_0x1497f7['indexOf'](_0x40b37e)===-0x1){_0x1497f7[a2_0x5166('0x5')](_0x40b37e);}const _0x4798a7=this[a2_0x5166('0x9')]['startRun'](environment_1[a2_0x5166('0x20')],_0x1497f7);_0x1497f7['forEach'](_0x28d3d9=>{this[a2_0x5166('0x12')][a2_0x5166('0xc')][_0x28d3d9]=_0x4798a7;});return(yield _0x4798a7)[_0x40b37e];}});}[a2_0x5166('0x10')](){return Promise['all'](this['storeRequests'])[a2_0x5166('0xb')](_0x1e1bc3=>_0x1e1bc3['reduce']((_0x25fbe9,_0x39a93d)=>_0x25fbe9&&_0x39a93d,!![]));}}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_0x4304=['response','startRun','post','stack','apiAxiosInstance','package.json','parse','data','createMetricRecorder','messages','value','urls','then','RUNNER_FAILURE_PERF_ENTRY','zlib','RunStart\x20duration','createApiAxiosInstance','length','createReqBody','getBranch','runUrl','defineProperty','RunStart','printDuration','throw','...','toString','@nrwl/nx-cloud','devDependencies','Invalid\x20end\x20run\x20response','Stack\x20Trace:','axiosException','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','/nx-cloud/runs/start','RunEnd.\x20Completed\x20tasks','mapRespToPerfEntry','map','error','axiosMultipleTries','gzip','from','CloudRunApi','../../../utilities/environment','Run\x20Details:','__awaiter','VERBOSE_LOGGING','message','Invalid\x20Nx\x20Cloud\x20response:\x20','promisify','assign','endRun','__esModule','api','Invalid\x20end\x20run\x20response:\x20','nxCloudVersion','../../../utilities/axios','runContext','note','extractErrorMessage','../../../utilities/metric-logger','unknown','recordMetric','readFileSync','slice','machineInfo','success','apiError','headers','apply','next','application/octet-stream','status','stringify','RunEnd\x20duration'];(function(_0x4dc884,_0x43049c){const _0xe6f493=function(_0x3bf753){while(--_0x3bf753){_0x4dc884['push'](_0x4dc884['shift']());}};_0xe6f493(++_0x43049c);}(a3_0x4304,0x1ab));const a3_0xe6f4=function(_0x4dc884,_0x43049c){_0x4dc884=_0x4dc884-0x0;let _0xe6f493=a3_0x4304[_0x4dc884];return _0xe6f493;};'use strict';var __awaiter=this&&this[a3_0xe6f4('0x3d')]||function(_0x4391bf,_0x261ef2,_0x3d8c97,_0x3d9ade){function _0x423017(_0x422cd2){return _0x422cd2 instanceof _0x3d8c97?_0x422cd2:new _0x3d8c97(function(_0x3309a9){_0x3309a9(_0x422cd2);});}return new(_0x3d8c97||(_0x3d8c97=Promise))(function(_0x129a18,_0x41d0aa){function _0x4c0718(_0x4dcaba){try{_0x324999(_0x3d9ade[a3_0xe6f4('0xc')](_0x4dcaba));}catch(_0x349b5f){_0x41d0aa(_0x349b5f);}}function _0x153b2a(_0x227ec9){try{_0x324999(_0x3d9ade[a3_0xe6f4('0x29')](_0x227ec9));}catch(_0x20b0db){_0x41d0aa(_0x20b0db);}}function _0x324999(_0x4a9c34){_0x4a9c34['done']?_0x129a18(_0x4a9c34[a3_0xe6f4('0x1b')]):_0x423017(_0x4a9c34['value'])[a3_0xe6f4('0x1d')](_0x4c0718,_0x153b2a);}_0x324999((_0x3d9ade=_0x3d9ade[a3_0xe6f4('0xb')](_0x4391bf,_0x261ef2||[]))['next']());});};Object[a3_0xe6f4('0x26')](exports,a3_0xe6f4('0x44'),{'value':!![]});exports[a3_0xe6f4('0x3a')]=void 0x0;const axios_1=require(a3_0xe6f4('0x48'));const environment_1=require(a3_0xe6f4('0x3b'));const fs_1=require('fs');const zlib_1=require(a3_0xe6f4('0x1f'));const util_1=require('util');const metric_logger_1=require(a3_0xe6f4('0x2'));const {output}=require('../../../utilities/nx-imports');class CloudRunApi{constructor(_0x8887e7,_0x1ff789,_0x4f05cd,_0xc5cc14){this['messages']=_0x8887e7;this[a3_0xe6f4('0x49')]=_0x1ff789;this[a3_0xe6f4('0x7')]=_0xc5cc14;this[a3_0xe6f4('0x15')]=(0x0,axios_1[a3_0xe6f4('0x21')])(_0x4f05cd);}[a3_0xe6f4('0x12')](_0x497bb1,_0x12eaf9){var _0x8376e3;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x28916f=(0x0,metric_logger_1[a3_0xe6f4('0x19')])(a3_0xe6f4('0x12'));try{const _0x295682={'meta':{'nxCloudVersion':this['nxCloudVersion']()},'branch':(0x0,environment_1[a3_0xe6f4('0x24')])(),'runGroup':(0x0,environment_1['getRunGroup'])(),'distributedExecutionId':_0x497bb1,'hashes':_0x12eaf9};if(environment_1[a3_0xe6f4('0x3e')]){output['note']({'title':a3_0xe6f4('0x27'),'bodyLines':['\x0a'+JSON[a3_0xe6f4('0xf')](_0x295682,null,0x2)]});}const _0x3e5607=yield(0x0,axios_1['printDuration'])(a3_0xe6f4('0x20'),()=>(0x0,axios_1['axiosMultipleTries'])(()=>this['apiAxiosInstance'][a3_0xe6f4('0x13')](a3_0xe6f4('0x32'),_0x295682)));_0x28916f[a3_0xe6f4('0x4')]((0x0,metric_logger_1[a3_0xe6f4('0x34')])(_0x3e5607));if(_0x3e5607['data']&&_0x3e5607[a3_0xe6f4('0x18')][a3_0xe6f4('0x3f')]){this[a3_0xe6f4('0x1a')][a3_0xe6f4('0x3f')]=_0x3e5607[a3_0xe6f4('0x18')][a3_0xe6f4('0x3f')];}if(!_0x3e5607[a3_0xe6f4('0x18')]||!_0x3e5607[a3_0xe6f4('0x18')][a3_0xe6f4('0x1c')]){this['messages'][a3_0xe6f4('0x9')]=a3_0xe6f4('0x40')+JSON[a3_0xe6f4('0xf')](_0x3e5607['data']);return{};}return _0x3e5607['data'][a3_0xe6f4('0x1c')];}catch(_0x30d617){_0x28916f['recordMetric'](((_0x8376e3=_0x30d617===null||_0x30d617===void 0x0?void 0x0:_0x30d617[a3_0xe6f4('0x30')])===null||_0x8376e3===void 0x0?void 0x0:_0x8376e3[a3_0xe6f4('0x11')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x30d617[a3_0xe6f4('0x30')]['response']):metric_logger_1[a3_0xe6f4('0x1e')]);this[a3_0xe6f4('0x1a')][a3_0xe6f4('0x9')]=this[a3_0xe6f4('0x1a')][a3_0xe6f4('0x1')](_0x30d617,a3_0xe6f4('0x45'));return{};}});}[a3_0xe6f4('0x23')](_0x977838,_0x49431b,_0x1bf0d8){const _0x57e9ab={'meta':{'nxCloudVersion':this[a3_0xe6f4('0x47')]()},'tasks':_0x49431b,'run':_0x977838,'linkId':_0x1bf0d8,'machineInfo':this[a3_0xe6f4('0x7')]};return JSON['stringify'](_0x57e9ab);}[a3_0xe6f4('0x43')](_0x4fefc3,_0x21226c,_0x4d7cd1){var _0x4cdde6,_0x11930c;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0xe6f4('0x1a')][a3_0xe6f4('0x9')])return![];let _0x480c7d=this['createReqBody'](_0x4fefc3,_0x21226c,_0x4d7cd1);if(_0x480c7d[a3_0xe6f4('0x22')]>0x14*0x3e8*0x3e8){_0x480c7d=this[a3_0xe6f4('0x23')](_0x4fefc3,_0x21226c['map'](_0x4a5809=>Object[a3_0xe6f4('0x42')](Object['assign']({},_0x4a5809),{'hashDetails':undefined})));}const _0x2ac8fd=Buffer[a3_0xe6f4('0x39')](_0x480c7d);const _0x29200d=yield(0x0,util_1[a3_0xe6f4('0x41')])(zlib_1[a3_0xe6f4('0x38')])(_0x2ac8fd);const _0x1f8f5e=(0x0,metric_logger_1['createMetricRecorder'])('endRun');try{if(environment_1[a3_0xe6f4('0x3e')]){const _0x5b1527=_0x21226c[a3_0xe6f4('0x35')](_0x2b5a40=>{return Object[a3_0xe6f4('0x42')](Object['assign']({},_0x2b5a40),{'terminalOutput':_0x2b5a40['terminalOutput']?_0x2b5a40['terminalOutput'][a3_0xe6f4('0x6')](0x0,0x14)+a3_0xe6f4('0x2a'):undefined});});output[a3_0xe6f4('0x0')]({'title':a3_0xe6f4('0x33'),'bodyLines':['\x0a'+JSON[a3_0xe6f4('0xf')](_0x5b1527,null,0x2)]});}const _0xfc28b0=yield(0x0,axios_1[a3_0xe6f4('0x28')])(a3_0xe6f4('0x10'),()=>(0x0,axios_1[a3_0xe6f4('0x37')])(()=>this[a3_0xe6f4('0x15')][a3_0xe6f4('0x13')]('/nx-cloud/runs/end',_0x29200d,{'headers':Object[a3_0xe6f4('0x42')](Object[a3_0xe6f4('0x42')]({},this[a3_0xe6f4('0x15')]['defaults'][a3_0xe6f4('0xa')]),{'Content-Encoding':'gzip','Content-Type':a3_0xe6f4('0xd')})})));if(_0xfc28b0){_0x1f8f5e[a3_0xe6f4('0x4')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0xfc28b0));if(_0xfc28b0[a3_0xe6f4('0x18')]&&_0xfc28b0[a3_0xe6f4('0x18')][a3_0xe6f4('0x25')]&&_0xfc28b0[a3_0xe6f4('0x18')][a3_0xe6f4('0xe')]===a3_0xe6f4('0x8')){this[a3_0xe6f4('0x49')]['runUrl']=_0xfc28b0['data'][a3_0xe6f4('0x25')];return!![];}if(_0xfc28b0[a3_0xe6f4('0x18')]&&_0xfc28b0[a3_0xe6f4('0x18')][a3_0xe6f4('0xe')]){this[a3_0xe6f4('0x1a')][a3_0xe6f4('0x9')]='Invalid\x20end\x20run\x20response:\x20'+JSON[a3_0xe6f4('0xf')](_0xfc28b0[a3_0xe6f4('0x18')][a3_0xe6f4('0x3f')]);}else if(_0xfc28b0['data']&&typeof _0xfc28b0[a3_0xe6f4('0x18')]==='string'){if(_0xfc28b0[a3_0xe6f4('0x18')]!==a3_0xe6f4('0x8')){this['messages'][a3_0xe6f4('0x9')]=a3_0xe6f4('0x46')+JSON['stringify'](_0xfc28b0['data']);}}else{this[a3_0xe6f4('0x1a')][a3_0xe6f4('0x9')]=a3_0xe6f4('0x46')+JSON[a3_0xe6f4('0xf')](_0xfc28b0[a3_0xe6f4('0x18')]);}if(environment_1['VERBOSE_LOGGING']){output['note']({'title':a3_0xe6f4('0x2e'),'bodyLines':[JSON[a3_0xe6f4('0xf')](_0xfc28b0[a3_0xe6f4('0x18')],null,0x2)]});}}else{output[a3_0xe6f4('0x36')]({'title':a3_0xe6f4('0x31'),'bodyLines':['Run\x20completion\x20responded\x20with\x20`undefined`.',a3_0xe6f4('0x3c'),JSON['stringify'](_0x4fefc3,null,0x2),a3_0xe6f4('0x2f'),JSON[a3_0xe6f4('0xf')](new Error()[a3_0xe6f4('0x14')],null,0x2)]});}return![];}catch(_0x387de3){_0x1f8f5e[a3_0xe6f4('0x4')](((_0x4cdde6=_0x387de3===null||_0x387de3===void 0x0?void 0x0:_0x387de3[a3_0xe6f4('0x30')])===null||_0x4cdde6===void 0x0?void 0x0:_0x4cdde6[a3_0xe6f4('0x11')])?(0x0,metric_logger_1[a3_0xe6f4('0x34')])(_0x387de3[a3_0xe6f4('0x30')][a3_0xe6f4('0x11')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);const _0x5ebc57=(_0x11930c=_0x387de3[a3_0xe6f4('0x30')])!==null&&_0x11930c!==void 0x0?_0x11930c:_0x387de3;this[a3_0xe6f4('0x1a')][a3_0xe6f4('0x9')]=this[a3_0xe6f4('0x1a')][a3_0xe6f4('0x1')](_0x5ebc57,a3_0xe6f4('0x45'));return![];}});}[a3_0xe6f4('0x47')](){try{const _0xa60c39=JSON[a3_0xe6f4('0x17')]((0x0,fs_1[a3_0xe6f4('0x5')])(a3_0xe6f4('0x16'))[a3_0xe6f4('0x2b')]());return _0xa60c39[a3_0xe6f4('0x2d')][a3_0xe6f4('0x2c')];}catch(_0x2884e6){return a3_0xe6f4('0x3');}}}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_0x19e6=['floor','0123456789','__esModule','toLowerCase','length','defineProperty','random','ABCDEFGHIJKLMNOPQRSTUVWXYZ'];(function(_0x40a3ef,_0x19e6a8){const _0x43110c=function(_0x2f6701){while(--_0x2f6701){_0x40a3ef['push'](_0x40a3ef['shift']());}};_0x43110c(++_0x19e6a8);}(a4_0x19e6,0x173));const a4_0x4311=function(_0x40a3ef,_0x19e6a8){_0x40a3ef=_0x40a3ef-0x0;let _0x43110c=a4_0x19e6[_0x40a3ef];return _0x43110c;};'use strict';Object[a4_0x4311('0x2')](exports,a4_0x4311('0x7'),{'value':!![]});exports['generateUniqueLinkId']=void 0x0;const upper=a4_0x4311('0x4');const digits=a4_0x4311('0x6');const lower=upper[a4_0x4311('0x0')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x3a29fe='';for(let _0x36464c=0x0;_0x36464c<0xa;++_0x36464c){_0x3a29fe+=alphanum[Math[a4_0x4311('0x5')](Math[a4_0x4311('0x3')]()*alphanum[a4_0x4311('0x1')])];}return _0x3a29fe;}exports['generateUniqueLinkId']=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_0xb8c9=['/nx-cloud/executions/tasks','createApiAxiosInstance','__awaiter','/nx-cloud/executions/complete-run-group','tasks','completeRunGroupWithError','../../../utilities/metric-logger','post','dtePollTasks','throw','runGroup','completeRunGroup','error:\x20','data','response','createMetricRecorder','../../../utilities/nx-imports','note','../../../utilities/axios','agentName','apply','axiosException','__esModule','apiAxiosInstance','value','mapRespToPerfEntry','then','Completing\x20run\x20group\x20with\x20an\x20error','next','VERBOSE_LOGGING','axiosMultipleTries','done','recordMetric','DistributedAgentApi','RUNNER_FAILURE_PERF_ENTRY'];(function(_0x26d9eb,_0xb8c901){const _0x30da06=function(_0x416bd2){while(--_0x416bd2){_0x26d9eb['push'](_0x26d9eb['shift']());}};_0x30da06(++_0xb8c901);}(a5_0xb8c9,0x107));const a5_0x30da=function(_0x26d9eb,_0xb8c901){_0x26d9eb=_0x26d9eb-0x0;let _0x30da06=a5_0xb8c9[_0x26d9eb];return _0x30da06;};'use strict';var __awaiter=this&&this[a5_0x30da('0x13')]||function(_0x4de3a3,_0x36501c,_0x59eefe,_0x3529f2){function _0x3af494(_0x569460){return _0x569460 instanceof _0x59eefe?_0x569460:new _0x59eefe(function(_0x347eab){_0x347eab(_0x569460);});}return new(_0x59eefe||(_0x59eefe=Promise))(function(_0x80e93e,_0x174626){function _0xbe0a84(_0x4e6965){try{_0x53a0d6(_0x3529f2[a5_0x30da('0xa')](_0x4e6965));}catch(_0xfa649){_0x174626(_0xfa649);}}function _0x26b564(_0x469e33){try{_0x53a0d6(_0x3529f2[a5_0x30da('0x1a')](_0x469e33));}catch(_0x35ae57){_0x174626(_0x35ae57);}}function _0x53a0d6(_0x47dc08){_0x47dc08[a5_0x30da('0xd')]?_0x80e93e(_0x47dc08['value']):_0x3af494(_0x47dc08[a5_0x30da('0x6')])[a5_0x30da('0x8')](_0xbe0a84,_0x26b564);}_0x53a0d6((_0x3529f2=_0x3529f2[a5_0x30da('0x2')](_0x4de3a3,_0x36501c||[]))['next']());});};Object['defineProperty'](exports,a5_0x30da('0x4'),{'value':!![]});exports['DistributedAgentApi']=void 0x0;const axios_1=require(a5_0x30da('0x0'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a5_0x30da('0x17'));const {output}=require(a5_0x30da('0x21'));class DistributedAgentApi{constructor(_0x222917,_0x20527d,_0x542d1e){this['runGroup']=_0x20527d;this[a5_0x30da('0x1')]=_0x542d1e;this[a5_0x30da('0x5')]=(0x0,axios_1[a5_0x30da('0x12')])(_0x222917);}[a5_0x30da('0x15')](_0x38de42,_0x5db3af,_0x577bd1){var _0x27f56c;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x8a07b3=(0x0,metric_logger_1[a5_0x30da('0x20')])(a5_0x30da('0x19'));try{const _0x3baf00=yield(0x0,axios_1[a5_0x30da('0xc')])(()=>this[a5_0x30da('0x5')]['post'](a5_0x30da('0x11'),{'runGroup':this[a5_0x30da('0x1b')],'agentName':this[a5_0x30da('0x1')],'executionId':_0x38de42,'statusCode':_0x5db3af,'completedTasks':_0x577bd1}));_0x8a07b3[a5_0x30da('0xe')]((0x0,metric_logger_1[a5_0x30da('0x7')])(_0x3baf00));return _0x3baf00[a5_0x30da('0x1e')];}catch(_0x4c2159){_0x8a07b3[a5_0x30da('0xe')](((_0x27f56c=_0x4c2159===null||_0x4c2159===void 0x0?void 0x0:_0x4c2159[a5_0x30da('0x3')])===null||_0x27f56c===void 0x0?void 0x0:_0x27f56c[a5_0x30da('0x1f')])?(0x0,metric_logger_1[a5_0x30da('0x7')])(_0x4c2159[a5_0x30da('0x3')][a5_0x30da('0x1f')]):metric_logger_1[a5_0x30da('0x10')]);throw _0x4c2159;}});}[a5_0x30da('0x16')](_0xe33985){var _0x5ba5ab;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1['VERBOSE_LOGGING']){output[a5_0x30da('0x22')]({'title':a5_0x30da('0x9'),'bodyLines':['runGroup:\x20'+this[a5_0x30da('0x1b')],a5_0x30da('0x1d')+_0xe33985]});}const _0xc6733d=(0x0,metric_logger_1['createMetricRecorder'])(a5_0x30da('0x1c'));try{const _0x21ae33=yield(0x0,axios_1[a5_0x30da('0xc')])(()=>this[a5_0x30da('0x5')][a5_0x30da('0x18')](a5_0x30da('0x14'),{'runGroup':this[a5_0x30da('0x1b')],'agentName':this[a5_0x30da('0x1')],'criticalErrorMessage':_0xe33985}));if(environment_1[a5_0x30da('0xb')]){output[a5_0x30da('0x22')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0xc6733d[a5_0x30da('0xe')]((0x0,metric_logger_1[a5_0x30da('0x7')])(_0x21ae33));}catch(_0x59eec1){_0xc6733d[a5_0x30da('0xe')](((_0x5ba5ab=_0x59eec1===null||_0x59eec1===void 0x0?void 0x0:_0x59eec1['axiosException'])===null||_0x5ba5ab===void 0x0?void 0x0:_0x5ba5ab[a5_0x30da('0x1f')])?(0x0,metric_logger_1[a5_0x30da('0x7')])(_0x59eec1[a5_0x30da('0x3')][a5_0x30da('0x1f')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);console['error'](_0x59eec1);}});}}exports[a5_0x30da('0xf')]=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