@nrwl/nx-cloud 14.6.1 → 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.
Files changed (25) hide show
  1. package/lib/core/api/error-reporter.api.js +36 -1
  2. package/lib/core/api/run-group.api.js +68 -1
  3. package/lib/core/commands/start-ci-run.js +7 -2
  4. package/lib/core/commands/start-ci-run.js.map +1 -1
  5. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +156 -1
  6. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +288 -1
  7. package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +113 -1
  8. package/lib/core/runners/cloud-enabled/cloud-run.api.js +167 -1
  9. package/lib/core/runners/cloud-enabled/id-generator.js +16 -1
  10. package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -1
  11. package/lib/core/runners/distributed-agent/distributed-agent.impl.js +263 -1
  12. package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -1
  13. package/lib/core/runners/distributed-execution/distributed-execution.api.js +143 -1
  14. package/lib/core/runners/distributed-execution/distributed-execution.runner.js +220 -1
  15. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -1
  16. package/lib/core/runners/distributed-execution/task-graph-creator.js +77 -1
  17. package/lib/nx-cloud-tasks-runner.js +7 -3
  18. package/lib/nx-cloud-tasks-runner.js.map +1 -1
  19. package/lib/utilities/distributed-task-execution-detection.d.ts +2 -2
  20. package/lib/utilities/distributed-task-execution-detection.js +12 -5
  21. package/lib/utilities/distributed-task-execution-detection.js.map +1 -1
  22. package/lib/utilities/environment.d.ts +0 -1
  23. package/lib/utilities/environment.js +2 -3
  24. package/lib/utilities/environment.js.map +1 -1
  25. package/package.json +4 -4
@@ -1 +1,113 @@
1
- const a2_0x17d6=['hash','cacheError','storeRequests','__awaiter','apply','scheduledTasks','put','resolve','filter','cache-miss','VERBOSE_LOGGING','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','Nx\x20Cloud:\x20Skipping\x20storing\x20','throw','waitForStoreRequestsToComplete','fileStorage','../../../utilities/nx-imports','push','done','runContext','reduce','.\x20Status\x20404.','__esModule','axiosException','store','storage','defineProperty','retrieve','then','all','get','requests','response','messages','note','next','statuses','.\x20Read\x20only\x20token\x20is\x20used.','remote-cache-hit','api','CloudRemoteCache','extractErrorMessage','hashUrls','status','value'];(function(_0x109814,_0x17d68a){const _0x4a3e2e=function(_0x22a28d){while(--_0x22a28d){_0x109814['push'](_0x109814['shift']());}};_0x4a3e2e(++_0x17d68a);}(a2_0x17d6,0xa9));const a2_0x4a3e=function(_0x109814,_0x17d68a){_0x109814=_0x109814-0x0;let _0x4a3e2e=a2_0x17d6[_0x109814];return _0x4a3e2e;};'use strict';var __awaiter=this&&this[a2_0x4a3e('0xe')]||function(_0x5916bd,_0x4527b5,_0x124f03,_0x22bf37){function _0x3521c7(_0x521e51){return _0x521e51 instanceof _0x124f03?_0x521e51:new _0x124f03(function(_0x17d05e){_0x17d05e(_0x521e51);});}return new(_0x124f03||(_0x124f03=Promise))(function(_0x1f3895,_0xd996f5){function _0x5ef8ab(_0x1f6169){try{_0x5b824b(_0x22bf37[a2_0x4a3e('0x1')](_0x1f6169));}catch(_0x1878db){_0xd996f5(_0x1878db);}}function _0x5559f5(_0x154137){try{_0x5b824b(_0x22bf37[a2_0x4a3e('0x18')](_0x154137));}catch(_0x493c67){_0xd996f5(_0x493c67);}}function _0x5b824b(_0x5c5b7d){_0x5c5b7d[a2_0x4a3e('0x1d')]?_0x1f3895(_0x5c5b7d[a2_0x4a3e('0xa')]):_0x3521c7(_0x5c5b7d[a2_0x4a3e('0xa')])['then'](_0x5ef8ab,_0x5559f5);}_0x5b824b((_0x22bf37=_0x22bf37[a2_0x4a3e('0xf')](_0x5916bd,_0x4527b5||[]))[a2_0x4a3e('0x1')]());});};Object[a2_0x4a3e('0x25')](exports,a2_0x4a3e('0x21'),{'value':!![]});exports[a2_0x4a3e('0x6')]=void 0x0;const environment_1=require('../../../utilities/environment');const {output}=require(a2_0x4a3e('0x1b'));class CloudRemoteCache{constructor(_0x21dfcb,_0x258fc5,_0x519583,_0x531032){this['messages']=_0x21dfcb;this[a2_0x4a3e('0x5')]=_0x258fc5;this['runContext']=_0x519583;this[a2_0x4a3e('0x1a')]=_0x531032;this[a2_0x4a3e('0xd')]=[];}['retrieve'](_0xb1c7b4,_0x2fd4b2){var _0x335838;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x4a3e('0x2c')][a2_0x4a3e('0xc')])return![];const _0x2e39c6=yield this['hashUrls'](_0xb1c7b4);if(!_0x2e39c6||!_0x2e39c6[a2_0x4a3e('0x29')]){if(environment_1[a2_0x4a3e('0x15')]){output[a2_0x4a3e('0x0')]({'title':'Nx\x20Cloud:\x20Cache\x20miss\x20'+_0xb1c7b4+'.'});}this[a2_0x4a3e('0x1e')][a2_0x4a3e('0x2')][_0xb1c7b4]=a2_0x4a3e('0x14');return![];}try{yield this[a2_0x4a3e('0x1a')][a2_0x4a3e('0x26')](_0xb1c7b4,_0x2e39c6['get'],_0x2fd4b2);this[a2_0x4a3e('0x1e')][a2_0x4a3e('0x2')][_0xb1c7b4]=a2_0x4a3e('0x4');return!![];}catch(_0x5a0fd6){const _0x201ad1=(_0x335838=_0x5a0fd6[a2_0x4a3e('0x22')])!==null&&_0x335838!==void 0x0?_0x335838:_0x5a0fd6;if(_0x201ad1[a2_0x4a3e('0x2b')]&&_0x201ad1[a2_0x4a3e('0x2b')][a2_0x4a3e('0x9')]===0x194){if(environment_1[a2_0x4a3e('0x15')]){output[a2_0x4a3e('0x0')]({'title':'Nx\x20Cloud:\x20Cache\x20miss\x20'+_0xb1c7b4+a2_0x4a3e('0x20')});}}else{this['messages'][a2_0x4a3e('0xc')]=this['messages'][a2_0x4a3e('0x7')](_0x201ad1,a2_0x4a3e('0x24'));}this[a2_0x4a3e('0x1e')]['statuses'][_0xb1c7b4]='cache-miss';return![];}});}[a2_0x4a3e('0x23')](_0x36ac91,_0xeaeae8){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x4a3e('0x2c')][a2_0x4a3e('0xc')])return![];const _0x2d1e0a=Promise[a2_0x4a3e('0x12')]()[a2_0x4a3e('0x27')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x2bd9e2;const _0x98105e=yield this[a2_0x4a3e('0x8')](_0x36ac91);if(!_0x98105e)return![];if(!_0x98105e[a2_0x4a3e('0x11')]){if(environment_1[a2_0x4a3e('0x15')]){output['note']({'title':a2_0x4a3e('0x17')+_0x36ac91+a2_0x4a3e('0x3')});}return!![];}try{yield this[a2_0x4a3e('0x1a')][a2_0x4a3e('0x23')](_0x36ac91,_0x98105e[a2_0x4a3e('0x11')],_0xeaeae8);return!![];}catch(_0x43ed3d){const _0x26e74f=(_0x2bd9e2=_0x43ed3d[a2_0x4a3e('0x22')])!==null&&_0x2bd9e2!==void 0x0?_0x2bd9e2:_0x43ed3d;this[a2_0x4a3e('0x2c')][a2_0x4a3e('0xc')]=this[a2_0x4a3e('0x2c')]['extractErrorMessage'](_0x26e74f,a2_0x4a3e('0x24'));return![];}}));this[a2_0x4a3e('0xd')][a2_0x4a3e('0x1c')](_0x2d1e0a);return _0x2d1e0a;});}[a2_0x4a3e('0x8')](_0x1e9dc1){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x1e9dc1 in this['runContext'][a2_0x4a3e('0x2a')]){return(yield this[a2_0x4a3e('0x1e')][a2_0x4a3e('0x2a')][_0x1e9dc1])[_0x1e9dc1];}else{const _0x2e62a9=this[a2_0x4a3e('0x1e')][a2_0x4a3e('0x10')][a2_0x4a3e('0x13')](_0x27f740=>!this[a2_0x4a3e('0x1e')][a2_0x4a3e('0x2a')][_0x27f740[a2_0x4a3e('0xb')]])['map'](_0x52aabc=>_0x52aabc[a2_0x4a3e('0xb')]);if(_0x2e62a9['indexOf'](_0x1e9dc1)===-0x1){_0x2e62a9[a2_0x4a3e('0x1c')](_0x1e9dc1);}const _0x4d06a8=this[a2_0x4a3e('0x5')]['startRun'](environment_1[a2_0x4a3e('0x16')],_0x2e62a9);_0x2e62a9['forEach'](_0x5e58e4=>{this[a2_0x4a3e('0x1e')][a2_0x4a3e('0x2a')][_0x5e58e4]=_0x4d06a8;});return(yield _0x4d06a8)[_0x1e9dc1];}});}[a2_0x4a3e('0x19')](){return Promise[a2_0x4a3e('0x28')](this[a2_0x4a3e('0xd')])[a2_0x4a3e('0x27')](_0x70b97f=>_0x70b97f[a2_0x4a3e('0x1f')]((_0x1afaab,_0x160da1)=>_0x1afaab&&_0x160da1,!![]));}}exports[a2_0x4a3e('0x6')]=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_0x409b=['apiAxiosInstance','apiError','message','length','headers','string','throw','assign','toString','post','../../../utilities/nx-imports','terminalOutput','status','RunEnd\x20duration','createMetricRecorder','promisify','axiosException','endRun','value','createApiAxiosInstance','RunEnd.\x20Completed\x20tasks','slice','success','axiosMultipleTries','error','Run\x20completion\x20responded\x20with\x20`undefined`.','defaults','/nx-cloud/runs/end','RunStart\x20duration','Run\x20Details:','@nrwl/nx-cloud','runContext','api','/nx-cloud/runs/start','Stack\x20Trace:','../../../utilities/metric-logger','done','RUNNER_FAILURE_PERF_ENTRY','gzip','printDuration','startRun','extractErrorMessage','readFileSync','__esModule','note','VERBOSE_LOGGING','stack','recordMetric','runUrl','Invalid\x20end\x20run\x20response:\x20','Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','...','parse','getRunGroup','unknown','urls','createReqBody','defineProperty','map','nxCloudVersion','messages','from','data','Invalid\x20Nx\x20Cloud\x20response:\x20','CloudRunApi','package.json','stringify','mapRespToPerfEntry','next'];(function(_0x278ef2,_0x409b8a){const _0x2578c8=function(_0x591ee8){while(--_0x591ee8){_0x278ef2['push'](_0x278ef2['shift']());}};_0x2578c8(++_0x409b8a);}(a3_0x409b,0x10a));const a3_0x2578=function(_0x278ef2,_0x409b8a){_0x278ef2=_0x278ef2-0x0;let _0x2578c8=a3_0x409b[_0x278ef2];return _0x2578c8;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x3d49d5,_0x417fc9,_0x2303da,_0x4508e6){function _0x1be03b(_0x4ba446){return _0x4ba446 instanceof _0x2303da?_0x4ba446:new _0x2303da(function(_0x4fa2f1){_0x4fa2f1(_0x4ba446);});}return new(_0x2303da||(_0x2303da=Promise))(function(_0x48e9f6,_0x262a76){function _0x900137(_0xc791cd){try{_0x4d59f5(_0x4508e6[a3_0x2578('0x9')](_0xc791cd));}catch(_0x1508df){_0x262a76(_0x1508df);}}function _0x50b85e(_0x41dcf0){try{_0x4d59f5(_0x4508e6[a3_0x2578('0x10')](_0x41dcf0));}catch(_0x545c22){_0x262a76(_0x545c22);}}function _0x4d59f5(_0x39e98e){_0x39e98e[a3_0x2578('0x2e')]?_0x48e9f6(_0x39e98e[a3_0x2578('0x1c')]):_0x1be03b(_0x39e98e[a3_0x2578('0x1c')])['then'](_0x900137,_0x50b85e);}_0x4d59f5((_0x4508e6=_0x4508e6['apply'](_0x3d49d5,_0x417fc9||[]))['next']());});};Object[a3_0x2578('0x43')](exports,a3_0x2578('0x35'),{'value':!![]});exports[a3_0x2578('0x5')]=void 0x0;const axios_1=require('../../../utilities/axios');const environment_1=require('../../../utilities/environment');const fs_1=require('fs');const zlib_1=require('zlib');const util_1=require('util');const metric_logger_1=require(a3_0x2578('0x2d'));const {output}=require(a3_0x2578('0x14'));class CloudRunApi{constructor(_0x52d6d5,_0x2fc9ce,_0x131a4a,_0x2d0b02){this[a3_0x2578('0x1')]=_0x52d6d5;this[a3_0x2578('0x29')]=_0x2fc9ce;this['machineInfo']=_0x2d0b02;this['apiAxiosInstance']=(0x0,axios_1[a3_0x2578('0x1d')])(_0x131a4a);}[a3_0x2578('0x32')](_0x364135,_0x4b1cc3){var _0x5854fb;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x213594=(0x0,metric_logger_1['createMetricRecorder'])(a3_0x2578('0x32'));try{const _0x362307={'meta':{'nxCloudVersion':this['nxCloudVersion']()},'branch':(0x0,environment_1['getBranch'])(),'runGroup':(0x0,environment_1[a3_0x2578('0x3f')])(),'distributedExecutionId':_0x364135,'hashes':_0x4b1cc3};if(environment_1['VERBOSE_LOGGING']){output[a3_0x2578('0x36')]({'title':'RunStart','bodyLines':['\x0a'+JSON[a3_0x2578('0x7')](_0x362307,null,0x2)]});}const _0x2ecc5e=yield(0x0,axios_1[a3_0x2578('0x31')])(a3_0x2578('0x26'),()=>(0x0,axios_1[a3_0x2578('0x21')])(()=>this['apiAxiosInstance'][a3_0x2578('0x13')](a3_0x2578('0x2b'),_0x362307)));_0x213594['recordMetric']((0x0,metric_logger_1[a3_0x2578('0x8')])(_0x2ecc5e));if(_0x2ecc5e[a3_0x2578('0x3')]&&_0x2ecc5e[a3_0x2578('0x3')][a3_0x2578('0xc')]){this[a3_0x2578('0x1')][a3_0x2578('0xc')]=_0x2ecc5e[a3_0x2578('0x3')][a3_0x2578('0xc')];}if(!_0x2ecc5e['data']||!_0x2ecc5e[a3_0x2578('0x3')][a3_0x2578('0x41')]){this['messages']['apiError']=a3_0x2578('0x4')+JSON['stringify'](_0x2ecc5e[a3_0x2578('0x3')]);return{};}return _0x2ecc5e['data']['urls'];}catch(_0x555dcf){_0x213594[a3_0x2578('0x39')](((_0x5854fb=_0x555dcf===null||_0x555dcf===void 0x0?void 0x0:_0x555dcf[a3_0x2578('0x1a')])===null||_0x5854fb===void 0x0?void 0x0:_0x5854fb['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x555dcf[a3_0x2578('0x1a')]['response']):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);this[a3_0x2578('0x1')]['apiError']=this[a3_0x2578('0x1')][a3_0x2578('0x33')](_0x555dcf,'api');return{};}});}[a3_0x2578('0x42')](_0x3d84da,_0x501863,_0x1d1fcb){const _0x21ed52={'meta':{'nxCloudVersion':this[a3_0x2578('0x0')]()},'tasks':_0x501863,'run':_0x3d84da,'linkId':_0x1d1fcb,'machineInfo':this['machineInfo']};return JSON[a3_0x2578('0x7')](_0x21ed52);}['endRun'](_0x59d52e,_0x4fca4a,_0x9398ed){var _0x2bd655,_0x292b96;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x2578('0x1')][a3_0x2578('0xb')])return![];let _0x181330=this[a3_0x2578('0x42')](_0x59d52e,_0x4fca4a,_0x9398ed);if(_0x181330[a3_0x2578('0xd')]>0x14*0x3e8*0x3e8){_0x181330=this[a3_0x2578('0x42')](_0x59d52e,_0x4fca4a[a3_0x2578('0x44')](_0x360365=>Object['assign'](Object[a3_0x2578('0x11')]({},_0x360365),{'hashDetails':undefined})));}const _0x1e3694=Buffer[a3_0x2578('0x2')](_0x181330);const _0x292811=yield(0x0,util_1[a3_0x2578('0x19')])(zlib_1['gzip'])(_0x1e3694);const _0x248c42=(0x0,metric_logger_1[a3_0x2578('0x18')])(a3_0x2578('0x1b'));try{if(environment_1[a3_0x2578('0x37')]){const _0x6313d5=_0x4fca4a['map'](_0x5a0ff5=>{return Object[a3_0x2578('0x11')](Object[a3_0x2578('0x11')]({},_0x5a0ff5),{'terminalOutput':_0x5a0ff5[a3_0x2578('0x15')]?_0x5a0ff5[a3_0x2578('0x15')][a3_0x2578('0x1f')](0x0,0x14)+a3_0x2578('0x3d'):undefined});});output[a3_0x2578('0x36')]({'title':a3_0x2578('0x1e'),'bodyLines':['\x0a'+JSON[a3_0x2578('0x7')](_0x6313d5,null,0x2)]});}const _0x281bd8=yield(0x0,axios_1['printDuration'])(a3_0x2578('0x17'),()=>(0x0,axios_1['axiosMultipleTries'])(()=>this['apiAxiosInstance']['post'](a3_0x2578('0x25'),_0x292811,{'headers':Object[a3_0x2578('0x11')](Object[a3_0x2578('0x11')]({},this[a3_0x2578('0xa')][a3_0x2578('0x24')][a3_0x2578('0xe')]),{'Content-Encoding':a3_0x2578('0x30'),'Content-Type':'application/octet-stream'})})));if(_0x281bd8){_0x248c42[a3_0x2578('0x39')]((0x0,metric_logger_1[a3_0x2578('0x8')])(_0x281bd8));if(_0x281bd8[a3_0x2578('0x3')]&&_0x281bd8[a3_0x2578('0x3')][a3_0x2578('0x3a')]&&_0x281bd8[a3_0x2578('0x3')][a3_0x2578('0x16')]==='success'){this[a3_0x2578('0x29')][a3_0x2578('0x3a')]=_0x281bd8[a3_0x2578('0x3')][a3_0x2578('0x3a')];return!![];}if(_0x281bd8[a3_0x2578('0x3')]&&_0x281bd8[a3_0x2578('0x3')]['status']){this[a3_0x2578('0x1')][a3_0x2578('0xb')]=a3_0x2578('0x3b')+JSON[a3_0x2578('0x7')](_0x281bd8['data'][a3_0x2578('0xc')]);}else if(_0x281bd8[a3_0x2578('0x3')]&&typeof _0x281bd8[a3_0x2578('0x3')]===a3_0x2578('0xf')){if(_0x281bd8[a3_0x2578('0x3')]!==a3_0x2578('0x20')){this['messages']['apiError']=a3_0x2578('0x3b')+JSON[a3_0x2578('0x7')](_0x281bd8['data']);}}else{this['messages'][a3_0x2578('0xb')]=a3_0x2578('0x3b')+JSON[a3_0x2578('0x7')](_0x281bd8[a3_0x2578('0x3')]);}if(environment_1[a3_0x2578('0x37')]){output[a3_0x2578('0x36')]({'title':'Invalid\x20end\x20run\x20response','bodyLines':[JSON[a3_0x2578('0x7')](_0x281bd8[a3_0x2578('0x3')],null,0x2)]});}}else{output[a3_0x2578('0x22')]({'title':a3_0x2578('0x3c'),'bodyLines':[a3_0x2578('0x23'),a3_0x2578('0x27'),JSON['stringify'](_0x59d52e,null,0x2),a3_0x2578('0x2c'),JSON[a3_0x2578('0x7')](new Error()[a3_0x2578('0x38')],null,0x2)]});}return![];}catch(_0x37d835){_0x248c42['recordMetric'](((_0x2bd655=_0x37d835===null||_0x37d835===void 0x0?void 0x0:_0x37d835[a3_0x2578('0x1a')])===null||_0x2bd655===void 0x0?void 0x0:_0x2bd655['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x37d835[a3_0x2578('0x1a')]['response']):metric_logger_1[a3_0x2578('0x2f')]);const _0x4dc930=(_0x292b96=_0x37d835[a3_0x2578('0x1a')])!==null&&_0x292b96!==void 0x0?_0x292b96:_0x37d835;this['messages'][a3_0x2578('0xb')]=this['messages'][a3_0x2578('0x33')](_0x4dc930,a3_0x2578('0x2a'));return![];}});}['nxCloudVersion'](){try{const _0x5eb3f8=JSON[a3_0x2578('0x3e')]((0x0,fs_1[a3_0x2578('0x34')])(a3_0x2578('0x6'))[a3_0x2578('0x12')]());return _0x5eb3f8['devDependencies'][a3_0x2578('0x28')];}catch(_0xc8f6b8){return a3_0x2578('0x40');}}}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_0x22e7=['defineProperty','0123456789','generateUniqueLinkId','random','length','floor','ABCDEFGHIJKLMNOPQRSTUVWXYZ','toLowerCase'];(function(_0x116d8d,_0x22e7e6){const _0x472ae0=function(_0x17303c){while(--_0x17303c){_0x116d8d['push'](_0x116d8d['shift']());}};_0x472ae0(++_0x22e7e6);}(a4_0x22e7,0xad));const a4_0x472a=function(_0x116d8d,_0x22e7e6){_0x116d8d=_0x116d8d-0x0;let _0x472ae0=a4_0x22e7[_0x116d8d];return _0x472ae0;};'use strict';Object[a4_0x472a('0x3')](exports,'__esModule',{'value':!![]});exports['generateUniqueLinkId']=void 0x0;const upper=a4_0x472a('0x1');const digits=a4_0x472a('0x4');const lower=upper[a4_0x472a('0x2')]();const alphanum=upper+lower+digits;function generateUniqueLinkId(){let _0x33d8f5='';for(let _0x3b53d4=0x0;_0x3b53d4<0xa;++_0x3b53d4){_0x33d8f5+=alphanum[Math[a4_0x472a('0x0')](Math[a4_0x472a('0x6')]()*alphanum[a4_0x472a('0x7')])];}return _0x33d8f5;}exports[a4_0x472a('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_0x13b2=['response','Completed\x20run\x20group\x20with\x20an\x20error','/nx-cloud/executions/complete-run-group','data','../../../utilities/metric-logger','recordMetric','VERBOSE_LOGGING','createMetricRecorder','completeRunGroup','../../../utilities/axios','__awaiter','done','RUNNER_FAILURE_PERF_ENTRY','throw','apiAxiosInstance','agentName','error:\x20','axiosMultipleTries','../../../utilities/nx-imports','axiosException','mapRespToPerfEntry','tasks','DistributedAgentApi','__esModule','dtePollTasks','value','/nx-cloud/executions/tasks','post','next','apply','defineProperty','note','runGroup'];(function(_0x1b8aac,_0x13b26b){const _0x34a203=function(_0x18aca9){while(--_0x18aca9){_0x1b8aac['push'](_0x1b8aac['shift']());}};_0x34a203(++_0x13b26b);}(a5_0x13b2,0xd7));const a5_0x34a2=function(_0x1b8aac,_0x13b26b){_0x1b8aac=_0x1b8aac-0x0;let _0x34a203=a5_0x13b2[_0x1b8aac];return _0x34a203;};'use strict';var __awaiter=this&&this[a5_0x34a2('0x1a')]||function(_0x241a99,_0x5c75b4,_0x59b324,_0x409eeb){function _0x230be3(_0x15a62d){return _0x15a62d instanceof _0x59b324?_0x15a62d:new _0x59b324(function(_0x2c3272){_0x2c3272(_0x15a62d);});}return new(_0x59b324||(_0x59b324=Promise))(function(_0x21370e,_0x2cb83e){function _0x458dcf(_0x4876a4){try{_0x4061f8(_0x409eeb[a5_0x34a2('0xb')](_0x4876a4));}catch(_0x222271){_0x2cb83e(_0x222271);}}function _0x20cc71(_0x3b353d){try{_0x4061f8(_0x409eeb[a5_0x34a2('0x1d')](_0x3b353d));}catch(_0x570971){_0x2cb83e(_0x570971);}}function _0x4061f8(_0x122a6b){_0x122a6b[a5_0x34a2('0x1b')]?_0x21370e(_0x122a6b[a5_0x34a2('0x8')]):_0x230be3(_0x122a6b[a5_0x34a2('0x8')])['then'](_0x458dcf,_0x20cc71);}_0x4061f8((_0x409eeb=_0x409eeb[a5_0x34a2('0xc')](_0x241a99,_0x5c75b4||[]))[a5_0x34a2('0xb')]());});};Object[a5_0x34a2('0xd')](exports,a5_0x34a2('0x6'),{'value':!![]});exports[a5_0x34a2('0x5')]=void 0x0;const axios_1=require(a5_0x34a2('0x19'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a5_0x34a2('0x14'));const {output}=require(a5_0x34a2('0x1'));class DistributedAgentApi{constructor(_0x485319,_0x1f8f2d,_0x56e39f){this[a5_0x34a2('0xf')]=_0x1f8f2d;this[a5_0x34a2('0x1f')]=_0x56e39f;this[a5_0x34a2('0x1e')]=(0x0,axios_1['createApiAxiosInstance'])(_0x485319);}[a5_0x34a2('0x4')](_0x2ab015,_0x40ac1a,_0xff1e50){var _0x402c23;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4d3361=(0x0,metric_logger_1[a5_0x34a2('0x17')])(a5_0x34a2('0x7'));try{const _0x58eb65=yield(0x0,axios_1['axiosMultipleTries'])(()=>this['apiAxiosInstance'][a5_0x34a2('0xa')](a5_0x34a2('0x9'),{'runGroup':this['runGroup'],'agentName':this['agentName'],'executionId':_0x2ab015,'statusCode':_0x40ac1a,'completedTasks':_0xff1e50}));_0x4d3361[a5_0x34a2('0x15')]((0x0,metric_logger_1[a5_0x34a2('0x3')])(_0x58eb65));return _0x58eb65[a5_0x34a2('0x13')];}catch(_0x2e7a82){_0x4d3361[a5_0x34a2('0x15')](((_0x402c23=_0x2e7a82===null||_0x2e7a82===void 0x0?void 0x0:_0x2e7a82[a5_0x34a2('0x2')])===null||_0x402c23===void 0x0?void 0x0:_0x402c23[a5_0x34a2('0x10')])?(0x0,metric_logger_1[a5_0x34a2('0x3')])(_0x2e7a82[a5_0x34a2('0x2')][a5_0x34a2('0x10')]):metric_logger_1[a5_0x34a2('0x1c')]);throw _0x2e7a82;}});}['completeRunGroupWithError'](_0x4baa96){var _0x41b68d;return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a5_0x34a2('0x16')]){output['note']({'title':'Completing\x20run\x20group\x20with\x20an\x20error','bodyLines':['runGroup:\x20'+this[a5_0x34a2('0xf')],a5_0x34a2('0x20')+_0x4baa96]});}const _0x74d496=(0x0,metric_logger_1[a5_0x34a2('0x17')])(a5_0x34a2('0x18'));try{const _0x90a79d=yield(0x0,axios_1[a5_0x34a2('0x0')])(()=>this[a5_0x34a2('0x1e')][a5_0x34a2('0xa')](a5_0x34a2('0x12'),{'runGroup':this[a5_0x34a2('0xf')],'agentName':this[a5_0x34a2('0x1f')],'criticalErrorMessage':_0x4baa96}));if(environment_1[a5_0x34a2('0x16')]){output[a5_0x34a2('0xe')]({'title':a5_0x34a2('0x11')});}_0x74d496['recordMetric']((0x0,metric_logger_1[a5_0x34a2('0x3')])(_0x90a79d));}catch(_0x30e30a){_0x74d496[a5_0x34a2('0x15')](((_0x41b68d=_0x30e30a===null||_0x30e30a===void 0x0?void 0x0:_0x30e30a['axiosException'])===null||_0x41b68d===void 0x0?void 0x0:_0x41b68d[a5_0x34a2('0x10')])?(0x0,metric_logger_1[a5_0x34a2('0x3')])(_0x30e30a[a5_0x34a2('0x2')][a5_0x34a2('0x10')]):metric_logger_1[a5_0x34a2('0x1c')]);console['error'](_0x30e30a);}});}}exports[a5_0x34a2('0x5')]=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