@nrwl/nx-cloud 14.1.1 → 14.1.2-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,36 @@
1
- const a0_0x500e=['ErrorReporterApi','value','defineProperty','then','throw','done','../../utilities/axios','axiosMultipleTries','/nx-cloud/report-client-error','../../utilities/nx-imports','createApiAxiosInstance','__awaiter','apiAxiosInstance','next'];(function(_0x5987c0,_0x500e2c){const _0xebf148=function(_0x676c8){while(--_0x676c8){_0x5987c0['push'](_0x5987c0['shift']());}};_0xebf148(++_0x500e2c);}(a0_0x500e,0x1dc));const a0_0xebf1=function(_0x5987c0,_0x500e2c){_0x5987c0=_0x5987c0-0x0;let _0xebf148=a0_0x500e[_0x5987c0];return _0xebf148;};'use strict';var __awaiter=this&&this[a0_0xebf1('0xb')]||function(_0x2fd8f8,_0x2957a6,_0x4ffa4c,_0x386a70){function _0x1a5deb(_0x3879bc){return _0x3879bc instanceof _0x4ffa4c?_0x3879bc:new _0x4ffa4c(function(_0x1dc675){_0x1dc675(_0x3879bc);});}return new(_0x4ffa4c||(_0x4ffa4c=Promise))(function(_0x3f476e,_0x3624a8){function _0x6ae019(_0x2cf01e){try{_0x8f1389(_0x386a70[a0_0xebf1('0xd')](_0x2cf01e));}catch(_0x5b5284){_0x3624a8(_0x5b5284);}}function _0x2864b0(_0x4f2e06){try{_0x8f1389(_0x386a70[a0_0xebf1('0x4')](_0x4f2e06));}catch(_0x4cfdc5){_0x3624a8(_0x4cfdc5);}}function _0x8f1389(_0x1652ed){_0x1652ed[a0_0xebf1('0x5')]?_0x3f476e(_0x1652ed[a0_0xebf1('0x1')]):_0x1a5deb(_0x1652ed[a0_0xebf1('0x1')])[a0_0xebf1('0x3')](_0x6ae019,_0x2864b0);}_0x8f1389((_0x386a70=_0x386a70['apply'](_0x2fd8f8,_0x2957a6||[]))[a0_0xebf1('0xd')]());});};Object[a0_0xebf1('0x2')](exports,'__esModule',{'value':!![]});exports[a0_0xebf1('0x0')]=void 0x0;const axios_1=require(a0_0xebf1('0x6'));const {output}=require(a0_0xebf1('0x9'));class ErrorReporterApi{constructor(_0x3bdd90){this[a0_0xebf1('0xc')]=(0x0,axios_1[a0_0xebf1('0xa')])(_0x3bdd90);}['reportError'](_0x118dee){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0xebf1('0x7')])(()=>this[a0_0xebf1('0xc')]['post'](a0_0xebf1('0x8'),{'message':_0x118dee}));}catch(_0x1dedc5){output['warn']({'title':'Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27'+_0x118dee+'\x27','bodyLines':[_0x1dedc5['message']]});}});}}exports[a0_0xebf1('0x0')]=ErrorReporterApi;
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.ErrorReporterApi = void 0;
13
+ const axios_1 = require("../../utilities/axios");
14
+ const { output } = require('../../utilities/nx-imports');
15
+ class ErrorReporterApi {
16
+ constructor(options) {
17
+ this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
18
+ }
19
+ reportError(message) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ try {
22
+ yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', {
23
+ message,
24
+ }));
25
+ }
26
+ catch (e) {
27
+ output.warn({
28
+ title: `Unable to record the following error: '${message}'`,
29
+ bodyLines: [e.message],
30
+ });
31
+ }
32
+ });
33
+ }
34
+ }
35
+ exports.ErrorReporterApi = ErrorReporterApi;
36
+ //# sourceMappingURL=error-reporter.api.js.map
@@ -1 +1,65 @@
1
- const a1_0x4c8a=['../../utilities/nx-imports','__awaiter','recordMetric','axiosMultipleTries','../../utilities/axios','post','defineProperty','done','RUNNER_FAILURE_PERF_ENTRY','next','apiAxiosInstance','message','mapRespToPerfEntry','createApiAxiosInstance','error','axiosException','response','apply','../../utilities/metric-logger','createRunGroup','then','createMetricRecorder','/nx-cloud/executions/complete-run-group'];(function(_0x3e3955,_0x4c8a5d){const _0x4f06f0=function(_0x3faf1b){while(--_0x3faf1b){_0x3e3955['push'](_0x3e3955['shift']());}};_0x4f06f0(++_0x4c8a5d);}(a1_0x4c8a,0x169));const a1_0x4f06=function(_0x3e3955,_0x4c8a5d){_0x3e3955=_0x3e3955-0x0;let _0x4f06f0=a1_0x4c8a[_0x3e3955];return _0x4f06f0;};'use strict';var __awaiter=this&&this[a1_0x4f06('0x8')]||function(_0x15e226,_0x274e94,_0xca54d1,_0x26e01b){function _0x4031e9(_0x5508d7){return _0x5508d7 instanceof _0xca54d1?_0x5508d7:new _0xca54d1(function(_0x36a54f){_0x36a54f(_0x5508d7);});}return new(_0xca54d1||(_0xca54d1=Promise))(function(_0x373fb7,_0x40b329){function _0x68e4eb(_0x24527b){try{_0x3390d7(_0x26e01b[a1_0x4f06('0x10')](_0x24527b));}catch(_0x55c19b){_0x40b329(_0x55c19b);}}function _0x5dac55(_0x5d6c3a){try{_0x3390d7(_0x26e01b['throw'](_0x5d6c3a));}catch(_0x56d494){_0x40b329(_0x56d494);}}function _0x3390d7(_0x26ff9f){_0x26ff9f[a1_0x4f06('0xe')]?_0x373fb7(_0x26ff9f['value']):_0x4031e9(_0x26ff9f['value'])[a1_0x4f06('0x4')](_0x68e4eb,_0x5dac55);}_0x3390d7((_0x26e01b=_0x26e01b[a1_0x4f06('0x1')](_0x15e226,_0x274e94||[]))[a1_0x4f06('0x10')]());});};Object[a1_0x4f06('0xd')](exports,'__esModule',{'value':!![]});exports['RunGroupApi']=void 0x0;const axios_1=require(a1_0x4f06('0xb'));const metric_logger_1=require(a1_0x4f06('0x2'));const {output}=require(a1_0x4f06('0x7'));class RunGroupApi{constructor(_0x3eaf82){this[a1_0x4f06('0x11')]=(0x0,axios_1[a1_0x4f06('0x14')])(_0x3eaf82);}[a1_0x4f06('0x3')](_0x57202d,_0x32d89a){var _0x1845d2;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5a04ba=(0x0,metric_logger_1[a1_0x4f06('0x5')])('createRunGroup');try{const _0x2646bc=yield(0x0,axios_1[a1_0x4f06('0xa')])(()=>this[a1_0x4f06('0x11')][a1_0x4f06('0xc')]('/nx-cloud/executions/create-run-group',{'branch':_0x57202d,'runGroup':_0x32d89a}));_0x5a04ba[a1_0x4f06('0x9')]((0x0,metric_logger_1[a1_0x4f06('0x13')])(_0x2646bc));}catch(_0x3ae622){_0x5a04ba[a1_0x4f06('0x9')](((_0x1845d2=_0x3ae622===null||_0x3ae622===void 0x0?void 0x0:_0x3ae622['axiosException'])===null||_0x1845d2===void 0x0?void 0x0:_0x1845d2['response'])?(0x0,metric_logger_1[a1_0x4f06('0x13')])(_0x3ae622[a1_0x4f06('0x16')][a1_0x4f06('0x0')]):metric_logger_1[a1_0x4f06('0xf')]);output[a1_0x4f06('0x15')]({'title':_0x3ae622[a1_0x4f06('0x12')]});process['exit'](0x1);}});}['completeRunGroup'](_0x5436a5){var _0x3621c7;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x423550=(0x0,metric_logger_1[a1_0x4f06('0x5')])(a1_0x4f06('0x3'));try{const _0x4f73ae=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a1_0x4f06('0x11')][a1_0x4f06('0xc')](a1_0x4f06('0x6'),{'runGroup':_0x5436a5}));_0x423550[a1_0x4f06('0x9')]((0x0,metric_logger_1[a1_0x4f06('0x13')])(_0x4f73ae));}catch(_0x48f9f1){_0x423550['recordMetric'](((_0x3621c7=_0x48f9f1===null||_0x48f9f1===void 0x0?void 0x0:_0x48f9f1[a1_0x4f06('0x16')])===null||_0x3621c7===void 0x0?void 0x0:_0x3621c7[a1_0x4f06('0x0')])?(0x0,metric_logger_1[a1_0x4f06('0x13')])(_0x48f9f1[a1_0x4f06('0x16')]['response']):metric_logger_1[a1_0x4f06('0xf')]);output[a1_0x4f06('0x15')]({'title':_0x48f9f1[a1_0x4f06('0x12')]});process['exit'](0x1);}});}}exports['RunGroupApi']=RunGroupApi;
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.RunGroupApi = void 0;
13
+ const axios_1 = require("../../utilities/axios");
14
+ const metric_logger_1 = require("../../utilities/metric-logger");
15
+ const { output } = require('../../utilities/nx-imports');
16
+ class RunGroupApi {
17
+ constructor(options) {
18
+ this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
19
+ }
20
+ createRunGroup(branch, runGroup) {
21
+ var _a;
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
24
+ try {
25
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
26
+ branch: branch,
27
+ runGroup: runGroup,
28
+ }));
29
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
30
+ }
31
+ catch (e) {
32
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
33
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
34
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
35
+ output.error({
36
+ title: e.message,
37
+ });
38
+ process.exit(1);
39
+ }
40
+ });
41
+ }
42
+ completeRunGroup(runGroup) {
43
+ var _a;
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
46
+ try {
47
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
48
+ runGroup: runGroup,
49
+ }));
50
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
51
+ }
52
+ catch (e) {
53
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
54
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
55
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
56
+ output.error({
57
+ title: e.message,
58
+ });
59
+ process.exit(1);
60
+ }
61
+ });
62
+ }
63
+ }
64
+ exports.RunGroupApi = RunGroupApi;
65
+ //# sourceMappingURL=run-group.api.js.map
@@ -1 +1,138 @@
1
- const a0_0xd445=['terminalOutputs','scheduleTask','implicitDeps','length','updateStartedTask','runtime','../../../utilities/nx-imports','Cannot\x20find\x20task\x20','path','remote-cache','startTask','NX_CLOUD_UNLIMITED_OUTPUT','TRUNCATED\x0a\x0a','node_modules','code','outputObfuscator','remote-cache-hit','skipNxCache','terminalOutput','../../../utilities/serializer-overrides','hashDetails','endTask','target','MAX_CHARACTERS_CACHED_TASK','endCommand','MAX_CHARACTERS_FAILED_TASK','obfuscate','params','status','statuses','push','hash','startsWith','.cache','filter','slice','local-cache-kept-existing','npm:','readTerminalOutputFile','endTasks','find','cacheDirectory','defineProperty','task','cleanUpHashDetails','forEach','CloudEnabledLifeCycle','MAX_CHARACTERS_SUCCESSFUL_TASK','../../../utilities/environment','cache-miss','project','nodes','readFileSync','local-cache-hit','cacheStatus','cacheableOperations','getTerminalOutput','join','serializeOverrides','collectTerminalOutput','keys','toString','toISOString','endTime','tasks','runContext'];(function(_0x23bca8,_0xd4456c){const _0x178eb3=function(_0x25579d){while(--_0x25579d){_0x23bca8['push'](_0x23bca8['shift']());}};_0x178eb3(++_0xd4456c);}(a0_0xd445,0xfa));const a0_0x178e=function(_0x23bca8,_0xd4456c){_0x23bca8=_0x23bca8-0x0;let _0x178eb3=a0_0xd445[_0x23bca8];return _0x178eb3;};'use strict';Object[a0_0x178e('0x38')](exports,'__esModule',{'value':!![]});exports[a0_0x178e('0x3c')]=void 0x0;const path=require(a0_0x178e('0x16'));const path_1=require(a0_0x178e('0x16'));const fs_1=require('fs');const environment_1=require(a0_0x178e('0x3e'));const serializer_overrides_1=require(a0_0x178e('0x21'));const {workspaceRoot}=require(a0_0x178e('0x14'));class CloudEnabledLifeCycle{constructor(_0x148881,_0x12c0da,_0x3ac9c8,_0x5d970f,_0x1ecc4f,_0x5cb00d,_0xeb65f6){this[a0_0x178e('0xd')]=_0x148881;this['cacheDirectory']=_0x12c0da;this[a0_0x178e('0x1f')]=_0x3ac9c8;this[a0_0x178e('0x7')]=_0x5d970f;this[a0_0x178e('0x3')]=_0x1ecc4f;this[a0_0x178e('0x1d')]=_0x5cb00d;this[a0_0x178e('0xc')]=_0xeb65f6;}[a0_0x178e('0xf')](_0x586f4b){this['runContext']['scheduledTasks'][a0_0x178e('0x2c')](_0x586f4b);}[a0_0x178e('0x18')](_0x21769f){this['tasks'][a0_0x178e('0x2c')]({'taskId':_0x21769f['id'],'startTime':new Date()['toISOString'](),'target':_0x21769f[a0_0x178e('0x24')][a0_0x178e('0x24')],'projectName':_0x21769f['target'][a0_0x178e('0x40')],'hash':_0x21769f['hash'],'hashDetails':this[a0_0x178e('0x3a')](_0x21769f[a0_0x178e('0x22')]),'params':(0x0,serializer_overrides_1[a0_0x178e('0x6')])(_0x21769f)});}[a0_0x178e('0x23')](_0x558b24,_0x1d4511){let _0x5621db;if(this['runContext'][a0_0x178e('0x2b')][_0x558b24[a0_0x178e('0x2d')]]){_0x5621db=this[a0_0x178e('0xd')][a0_0x178e('0x2b')][_0x558b24[a0_0x178e('0x2d')]];}else{if(this[a0_0x178e('0x3')]['indexOf'](_0x558b24['target']['target'])>-0x1&&!this[a0_0x178e('0x1f')]){_0x5621db=a0_0x178e('0x1');}else{_0x5621db='cache-miss';}}this[a0_0x178e('0x12')](_0x558b24,_0x1d4511,_0x5621db);}[a0_0x178e('0x35')](_0x321ea6){for(let _0x1e09a6 of _0x321ea6){const _0x12d3dd=_0x1e09a6[a0_0x178e('0x2a')]===a0_0x178e('0x17')?a0_0x178e('0x1e'):_0x1e09a6[a0_0x178e('0x2a')]==='local-cache'||_0x1e09a6['status']===a0_0x178e('0x32')?a0_0x178e('0x1'):'cache-miss';this[a0_0x178e('0x12')](_0x1e09a6[a0_0x178e('0x39')],_0x1e09a6[a0_0x178e('0x1c')],_0x12d3dd);}}[a0_0x178e('0x26')](){}['updateStartedTask'](_0x45d305,_0x45c10c,_0x58baae){const _0x2241fc=this['tasks'][a0_0x178e('0x36')](_0x91e9f2=>_0x91e9f2['taskId']===_0x45d305['id']);if(!_0x2241fc){throw new Error(a0_0x178e('0x15')+_0x45d305['id']);}_0x2241fc[a0_0x178e('0xb')]=new Date()[a0_0x178e('0xa')]();_0x2241fc[a0_0x178e('0x2a')]=_0x45c10c;_0x2241fc[a0_0x178e('0x29')]=this[a0_0x178e('0x1d')][a0_0x178e('0x28')](_0x2241fc['params']);_0x2241fc[a0_0x178e('0x2')]=_0x58baae;if(this[a0_0x178e('0x7')]){_0x2241fc[a0_0x178e('0x20')]=this['getTerminalOutput'](_0x45d305[a0_0x178e('0x2d')],_0x2241fc[a0_0x178e('0x2')],_0x45c10c);}}[a0_0x178e('0x4')](_0x1f2079,_0x185061,_0x57d72c){let _0x3b6a5c;if(this[a0_0x178e('0x37')]){if(this[a0_0x178e('0x37')][a0_0x178e('0x2e')]('./')){_0x3b6a5c=(0x0,path_1['join'])(workspaceRoot,this['cacheDirectory']);}else{_0x3b6a5c=this[a0_0x178e('0x37')];}}else{_0x3b6a5c=(0x0,path_1[a0_0x178e('0x5')])(workspaceRoot,a0_0x178e('0x1b'),a0_0x178e('0x2f'),'nx');}try{const _0xf3ce82=this[a0_0x178e('0x34')](_0x3b6a5c,_0x1f2079);const _0x1c1bb4=this['outputObfuscator'][a0_0x178e('0x28')](_0xf3ce82);if(environment_1[a0_0x178e('0x19')])return _0x1c1bb4;const _0x120880=_0x185061===a0_0x178e('0x3f')?_0x57d72c===0x0?CloudEnabledLifeCycle[a0_0x178e('0x3d')]:CloudEnabledLifeCycle[a0_0x178e('0x27')]:CloudEnabledLifeCycle[a0_0x178e('0x25')];return _0x1c1bb4[a0_0x178e('0x11')]>_0x120880?a0_0x178e('0x1a')+_0x1c1bb4[a0_0x178e('0x31')](_0x1c1bb4[a0_0x178e('0x11')]-_0x120880):_0x1c1bb4;}catch(_0x3d804d){return'';}}[a0_0x178e('0x3a')](_0x166d62){const _0x30447f={};Object[a0_0x178e('0x8')](_0x166d62[a0_0x178e('0x41')])[a0_0x178e('0x30')](_0x373b33=>!_0x373b33['startsWith'](a0_0x178e('0x33')))[a0_0x178e('0x3b')](_0x45e829=>{_0x30447f[_0x45e829]=_0x166d62['nodes'][_0x45e829];});return{'nodes':_0x30447f,'runtime':_0x166d62[a0_0x178e('0x13')],'implicitDeps':_0x166d62[a0_0x178e('0x10')]};}[a0_0x178e('0x34')](_0x123cb3,_0x4f2301){try{return(0x0,fs_1[a0_0x178e('0x0')])(path[a0_0x178e('0x5')](_0x123cb3,a0_0x178e('0xe'),_0x4f2301))['toString']();}catch(_0x43abb7){try{return(0x0,fs_1['readFileSync'])(path['join'](_0x123cb3,_0x4f2301,a0_0x178e('0x20')))[a0_0x178e('0x9')]();}catch(_0x2227d1){return'';}}}}exports['CloudEnabledLifeCycle']=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x178e('0x27')]=0x30d40;CloudEnabledLifeCycle['MAX_CHARACTERS_SUCCESSFUL_TASK']=0x4e20;CloudEnabledLifeCycle[a0_0x178e('0x25')]=0x4e20;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudEnabledLifeCycle = void 0;
4
+ const path = require("path");
5
+ const path_1 = require("path");
6
+ const fs_1 = require("fs");
7
+ const environment_1 = require("../../../utilities/environment");
8
+ const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
9
+ const { workspaceRoot } = require('../../../utilities/nx-imports');
10
+ class CloudEnabledLifeCycle {
11
+ constructor(runContext, cacheDirectory, skipNxCache, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
12
+ this.runContext = runContext;
13
+ this.cacheDirectory = cacheDirectory;
14
+ this.skipNxCache = skipNxCache;
15
+ this.collectTerminalOutput = collectTerminalOutput;
16
+ this.cacheableOperations = cacheableOperations;
17
+ this.outputObfuscator = outputObfuscator;
18
+ this.tasks = tasks;
19
+ }
20
+ scheduleTask(task) {
21
+ this.runContext.scheduledTasks.push(task);
22
+ }
23
+ startTask(task) {
24
+ this.tasks.push({
25
+ taskId: task.id,
26
+ startTime: new Date().toISOString(),
27
+ target: task.target.target,
28
+ projectName: task.target.project,
29
+ hash: task.hash,
30
+ hashDetails: this.cleanUpHashDetails(task.hashDetails),
31
+ params: (0, serializer_overrides_1.serializeOverrides)(task),
32
+ });
33
+ }
34
+ // Used for older version for Nx. Remove in Dec 2022
35
+ endTask(task, code) {
36
+ let cacheStatus;
37
+ if (this.runContext.statuses[task.hash]) {
38
+ cacheStatus = this.runContext.statuses[task.hash];
39
+ }
40
+ else {
41
+ if (this.cacheableOperations.indexOf(task.target.target) > -1 &&
42
+ !this.skipNxCache) {
43
+ cacheStatus = 'local-cache-hit';
44
+ }
45
+ else {
46
+ cacheStatus = 'cache-miss';
47
+ }
48
+ }
49
+ this.updateStartedTask(task, code, cacheStatus);
50
+ }
51
+ endTasks(tasks) {
52
+ for (let t of tasks) {
53
+ const status = t.status === 'remote-cache'
54
+ ? 'remote-cache-hit'
55
+ : t.status === 'local-cache' ||
56
+ t.status === 'local-cache-kept-existing'
57
+ ? 'local-cache-hit'
58
+ : 'cache-miss';
59
+ this.updateStartedTask(t.task, t.code, status);
60
+ }
61
+ }
62
+ endCommand() { }
63
+ updateStartedTask(task, code, cacheStatus) {
64
+ const startedTask = this.tasks.find((t) => t.taskId === task.id);
65
+ if (!startedTask) {
66
+ throw new Error(`Cannot find task ${task.id}`);
67
+ }
68
+ startedTask.endTime = new Date().toISOString();
69
+ startedTask.status = code;
70
+ startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
71
+ startedTask.cacheStatus = cacheStatus;
72
+ if (this.collectTerminalOutput) {
73
+ startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
74
+ }
75
+ }
76
+ getTerminalOutput(hash, cacheStatus, code) {
77
+ let dir;
78
+ if (this.cacheDirectory) {
79
+ if (this.cacheDirectory.startsWith('./')) {
80
+ dir = (0, path_1.join)(workspaceRoot, this.cacheDirectory);
81
+ }
82
+ else {
83
+ dir = this.cacheDirectory;
84
+ }
85
+ }
86
+ else {
87
+ dir = (0, path_1.join)(workspaceRoot, 'node_modules', '.cache', 'nx');
88
+ }
89
+ try {
90
+ const taskOutput = this.readTerminalOutputFile(dir, hash);
91
+ const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
92
+ if (environment_1.NX_CLOUD_UNLIMITED_OUTPUT)
93
+ return taskOutputSanitized;
94
+ const maxCharacters = cacheStatus === 'cache-miss'
95
+ ? code === 0
96
+ ? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
97
+ : CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
98
+ : CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
99
+ return taskOutputSanitized.length > maxCharacters
100
+ ? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
101
+ : taskOutputSanitized;
102
+ }
103
+ catch (e) {
104
+ return '';
105
+ }
106
+ }
107
+ cleanUpHashDetails(hashDetails) {
108
+ const nodes = {};
109
+ Object.keys(hashDetails.nodes)
110
+ .filter((k) => !k.startsWith('npm:'))
111
+ .forEach((k) => {
112
+ nodes[k] = hashDetails.nodes[k];
113
+ });
114
+ return {
115
+ nodes,
116
+ runtime: hashDetails.runtime,
117
+ implicitDeps: hashDetails.implicitDeps,
118
+ };
119
+ }
120
+ readTerminalOutputFile(dir, hash) {
121
+ try {
122
+ return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
123
+ }
124
+ catch (_a) {
125
+ try {
126
+ return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
127
+ }
128
+ catch (_b) {
129
+ return '';
130
+ }
131
+ }
132
+ }
133
+ }
134
+ exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
135
+ CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
136
+ CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
137
+ CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 20000;
138
+ //# sourceMappingURL=cloud-enabled-life-cycle.js.map
@@ -1 +1,169 @@
1
- const a1_0x1a20=['./cloud-run.api','maskedProperties','Executed\x20tasks\x20with\x20hashes:\x20','waitForStoreRequestsToComplete','./cloud-enabled-life-cycle','EndOfRunMessage','map','throw','../../terminal-output/end-of-run-message','then','defineProperty','cacheableOperations','join','subscribe','printMessages','extractGitSha','lifeCycle','ENCRYPTION_KEY','CloudEnabledLifeCycle','printCacheHitsMessage','writeFileSync','done','__awaiter','hash','error','CloudRunApi','../../../utilities/nx-imports','assign','./node_modules/.cache/nx','toISOString','scan','value','../../file-storage/file-storage','next','FileStorage','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','../../terminal-output/message-reporter','note','exit','requests','../../api/error-reporter.api','catch','getMachineInfo','endRun','VERBOSE_LOGGING','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','path','forEach','encryptionKey','parseCommand','../../terminal-output/output-obfuscator','skipNxCache','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','rxjs/internal/Subject','all','filter','cloudEnabledTasksRunner','./cloud-remote-cache','stringify','cacheDirectory','submitRunMetrics','obfuscate','../../file-storage/e2e-encryption','complete'];(function(_0x1e9c66,_0x1a205c){const _0x40abf7=function(_0x338440){while(--_0x338440){_0x1e9c66['push'](_0x1e9c66['shift']());}};_0x40abf7(++_0x1a205c);}(a1_0x1a20,0xe4));const a1_0x40ab=function(_0x1e9c66,_0x1a205c){_0x1e9c66=_0x1e9c66-0x0;let _0x40abf7=a1_0x1a20[_0x1e9c66];return _0x40abf7;};'use strict';var __awaiter=this&&this[a1_0x40ab('0x32')]||function(_0x2f4642,_0x22efcf,_0x254a1c,_0x1b561b){function _0x727bdc(_0x568165){return _0x568165 instanceof _0x254a1c?_0x568165:new _0x254a1c(function(_0x2c67a5){_0x2c67a5(_0x568165);});}return new(_0x254a1c||(_0x254a1c=Promise))(function(_0x52b960,_0x1148ec){function _0xc106c(_0x3dff85){try{_0x469fd(_0x1b561b[a1_0x40ab('0x3d')](_0x3dff85));}catch(_0x382d97){_0x1148ec(_0x382d97);}}function _0x82777a(_0xae8d04){try{_0x469fd(_0x1b561b[a1_0x40ab('0x23')](_0xae8d04));}catch(_0x4f8859){_0x1148ec(_0x4f8859);}}function _0x469fd(_0x5bc22c){_0x5bc22c[a1_0x40ab('0x31')]?_0x52b960(_0x5bc22c[a1_0x40ab('0x3b')]):_0x727bdc(_0x5bc22c[a1_0x40ab('0x3b')])[a1_0x40ab('0x25')](_0xc106c,_0x82777a);}_0x469fd((_0x1b561b=_0x1b561b['apply'](_0x2f4642,_0x22efcf||[]))['next']());});};Object[a1_0x40ab('0x26')](exports,'__esModule',{'value':!![]});exports[a1_0x40ab('0x14')]=void 0x0;const message_reporter_1=require(a1_0x40ab('0x0'));const end_of_run_message_1=require(a1_0x40ab('0x24'));const output_obfuscator_1=require(a1_0x40ab('0xe'));const cloud_enabled_life_cycle_1=require(a1_0x40ab('0x20'));const file_storage_1=require(a1_0x40ab('0x3c'));const e2e_encryption_1=require(a1_0x40ab('0x1a'));const environment_1=require('../../../utilities/environment');const cloud_remote_cache_1=require(a1_0x40ab('0x15'));const cloud_run_api_1=require(a1_0x40ab('0x1c'));const fs_1=require('fs');const path=require(a1_0x40ab('0xa'));const metric_logger_1=require('../../../utilities/metric-logger');const error_reporter_api_1=require(a1_0x40ab('0x4'));const {tasksRunner,output}=require('../../../utilities/nx-imports');function createApi(_0x1e7909,_0x304fdb,_0x372d2e){const _0x27203c=(0x0,environment_1[a1_0x40ab('0x6')])(_0x304fdb);return new cloud_run_api_1[(a1_0x40ab('0x35'))](_0x1e7909,_0x372d2e,_0x304fdb,_0x27203c);}function storeTaskHashes(_0x5c99d9,_0x5c4650,_0x1b3310){const _0x34b32c=JSON[a1_0x40ab('0x16')](_0x5c99d9['map'](_0x4efe84=>({'taskId':_0x4efe84['taskId'],'hash':_0x4efe84[a1_0x40ab('0x33')]})));if(environment_1[a1_0x40ab('0x8')]){output[a1_0x40ab('0x1')]({'title':a1_0x40ab('0x1e')+_0x34b32c});}(0x0,fs_1[a1_0x40ab('0x30')])(path[a1_0x40ab('0x28')](_0x5c4650,'tasks-hashes-'+_0x1b3310),_0x34b32c);}function onComplete(_0x496f9b,_0x117bff,_0x9a73f1,_0xdc7bb0,_0x7a4441,_0x97dee,_0x34364d,_0x57cc0e,_0x2193d3,_0x1ff5d4,_0x383311){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x38009b=new Date()[a1_0x40ab('0x39')]();if(environment_1[a1_0x40ab('0x3f')]){storeTaskHashes(_0x2193d3,_0x117bff[a1_0x40ab('0x17')]||a1_0x40ab('0x38'),environment_1[a1_0x40ab('0x9')]);}const _0x385f5c=(0x0,environment_1['getBranch'])();const _0x306df2=yield Promise[a1_0x40ab('0x12')]([_0x9a73f1[a1_0x40ab('0x1f')](),_0xdc7bb0[a1_0x40ab('0x7')]({'command':_0x7a4441[a1_0x40ab('0x19')]((0x0,environment_1[a1_0x40ab('0xd')])()),'startTime':_0x97dee,'endTime':_0x38009b,'distributedExecutionId':environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],'branch':_0x385f5c,'scan':!![],'runGroup':(0x0,environment_1['getRunGroup'])(),'sha':_0x385f5c?(0x0,environment_1[a1_0x40ab('0x2b')])():undefined,'inner':_0x383311},_0x2193d3)]);if(_0x1ff5d4){setTimeout(()=>{_0x34364d[a1_0x40ab('0x2a')]();if(!_0x34364d['anyErrors']&&!_0x383311){_0x57cc0e[a1_0x40ab('0x2f')]();}},0x0);}else{_0x34364d[a1_0x40ab('0x2a')]();if(!_0x34364d['anyErrors']&&!_0x383311){_0x57cc0e[a1_0x40ab('0x2f')]();}}if(environment_1[a1_0x40ab('0x3f')]){if(!_0x306df2[0x0]){output['error']({'title':'Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts'});_0x34364d[a1_0x40ab('0x2a')]();process[a1_0x40ab('0x2')](environment_1[a1_0x40ab('0x10')]);}if(!_0x306df2[0x1]){output[a1_0x40ab('0x34')]({'title':'Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run'});_0x34364d[a1_0x40ab('0x2a')]();process[a1_0x40ab('0x2')](environment_1[a1_0x40ab('0x10')]);}}yield(0x0,metric_logger_1[a1_0x40ab('0x18')])(_0x117bff);});}function createLifeCycle(_0x364c52,_0x3ae4,_0x15a47e,_0x4a250f){const _0x42b8dc=new cloud_enabled_life_cycle_1[(a1_0x40ab('0x2e'))](_0x364c52,_0x3ae4['cacheDirectory'],!!_0x3ae4[a1_0x40ab('0xf')],_0x3ae4['scan']===undefined?!![]:_0x3ae4[a1_0x40ab('0x3a')],_0x3ae4[a1_0x40ab('0x27')]||[],_0x15a47e,_0x4a250f);try{const {CompositeLifeCycle}=require(a1_0x40ab('0x36'));if(!CompositeLifeCycle)return _0x42b8dc;return new CompositeLifeCycle([_0x3ae4[a1_0x40ab('0x2c')],_0x42b8dc]);}catch(_0x5af33f){return _0x42b8dc;}}function cloudEnabledTasksRunner(_0xf21d70,_0x160720,_0x1b08d6,_0xd570b8=![]){const _0x22688b={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0xf21d70};const _0x5d777a=_0x160720['lifeCycle']===undefined;const _0x3ec35b=[];const _0x27376c=new message_reporter_1['MessageReporter'](_0x160720);const _0x327e72=createApi(_0x27376c,_0x160720,_0x22688b);const _0xfc0e79=new end_of_run_message_1[(a1_0x40ab('0x21'))](_0x22688b,_0x3ec35b);const _0x4176b9=new output_obfuscator_1['OutputObfuscator'](_0x160720[a1_0x40ab('0x1d')]);const _0x2f45fe=_0xf21d70[a1_0x40ab('0x22')](_0x11395b=>_0x11395b[a1_0x40ab('0x33')])[a1_0x40ab('0x13')](_0x3cf7c7=>!!_0x3cf7c7);const _0x31a755=_0x327e72['startRun'](environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],_0x2f45fe);_0x2f45fe[a1_0x40ab('0xb')](_0x1275db=>{_0x22688b[a1_0x40ab('0x3')][_0x1275db]=_0x31a755;});const _0x216722=new Date()[a1_0x40ab('0x39')]();const _0xf7bf72=createLifeCycle(_0x22688b,_0x160720,_0x4176b9,_0x3ec35b);const _0x395002=new e2e_encryption_1['E2EEncryption'](environment_1[a1_0x40ab('0x2d')]||_0x160720[a1_0x40ab('0xc')]);const _0x10d74b=new error_reporter_api_1['ErrorReporterApi'](_0x160720);const _0x516c6b=new file_storage_1[(a1_0x40ab('0x3e'))](_0x395002,_0x10d74b,![]);const _0x20b98d=new cloud_remote_cache_1['CloudRemoteCache'](_0x27376c,_0x327e72,_0x22688b,_0x516c6b);delete process['env'][a1_0x40ab('0x9')];const _0xe6a7b=tasksRunner(_0xf21d70,Object[a1_0x40ab('0x37')](Object[a1_0x40ab('0x37')]({},_0x160720),{'remoteCache':_0x20b98d,'lifeCycle':_0xf7bf72}),_0x1b08d6);if(_0xe6a7b[a1_0x40ab('0x29')]){const {Subject}=require(a1_0x40ab('0x11'));const _0x11ebae=new Subject();_0xe6a7b[a1_0x40ab('0x29')]({'next':_0x34c05b=>_0x11ebae[a1_0x40ab('0x3d')](_0x34c05b),'error':_0x27d594=>_0x11ebae[a1_0x40ab('0x34')](_0x27d594),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0xf7bf72,_0x160720,_0x20b98d,_0x327e72,_0x4176b9,_0x216722,_0x27376c,_0xfc0e79,_0x3ec35b,_0x5d777a,_0xd570b8);_0x11ebae[a1_0x40ab('0x1b')]();})});return _0x11ebae;}else{return _0xe6a7b[a1_0x40ab('0x25')](_0x48991e=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0xf7bf72,_0x160720,_0x20b98d,_0x327e72,_0x4176b9,_0x216722,_0x27376c,_0xfc0e79,_0x3ec35b,_0x5d777a,_0xd570b8);return _0x48991e;}))[a1_0x40ab('0x5')](_0x4b1a5b=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0xf7bf72,_0x160720,_0x20b98d,_0x327e72,_0x4176b9,_0x216722,_0x27376c,_0xfc0e79,_0x3ec35b,_0x5d777a,_0xd570b8);throw _0x4b1a5b;}));}}exports[a1_0x40ab('0x14')]=cloudEnabledTasksRunner;
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.cloudEnabledTasksRunner = void 0;
13
+ const message_reporter_1 = require("../../terminal-output/message-reporter");
14
+ const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
15
+ const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
16
+ const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
17
+ const file_storage_1 = require("../../file-storage/file-storage");
18
+ const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
19
+ const environment_1 = require("../../../utilities/environment");
20
+ const cloud_remote_cache_1 = require("./cloud-remote-cache");
21
+ const cloud_run_api_1 = require("./cloud-run.api");
22
+ const fs_1 = require("fs");
23
+ const path = require("path");
24
+ const metric_logger_1 = require("../../../utilities/metric-logger");
25
+ const error_reporter_api_1 = require("../../api/error-reporter.api");
26
+ const { tasksRunner, output } = require('../../../utilities/nx-imports');
27
+ function createApi(errors, options, runContext) {
28
+ const machineInfo = (0, environment_1.getMachineInfo)(options);
29
+ return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
30
+ }
31
+ function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
32
+ const hashes = JSON.stringify(taskExecutions.map((t) => ({
33
+ taskId: t.taskId,
34
+ hash: t.hash,
35
+ })));
36
+ if (environment_1.VERBOSE_LOGGING) {
37
+ output.note({
38
+ title: `Executed tasks with hashes: ${hashes}`,
39
+ });
40
+ }
41
+ (0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
42
+ }
43
+ function onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const runEndTime = new Date().toISOString();
46
+ if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
47
+ storeTaskHashes(taskExecutions, options.cacheDirectory || './node_modules/.cache/nx', environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
48
+ }
49
+ const branch = (0, environment_1.getBranch)();
50
+ const endRequest = yield Promise.all([
51
+ remoteCache.waitForStoreRequestsToComplete(),
52
+ api.endRun({
53
+ command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
54
+ startTime: runStartTime,
55
+ endTime: runEndTime,
56
+ distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
57
+ branch: branch,
58
+ scan: true,
59
+ runGroup: (0, environment_1.getRunGroup)(),
60
+ // only set sha if branch is set because we invoke a separate process,
61
+ // which adds a few millis
62
+ sha: branch ? (0, environment_1.extractGitSha)() : undefined,
63
+ inner: inner,
64
+ }, taskExecutions),
65
+ ]);
66
+ // this workaround is required because prior to Nx 13.3 we printed
67
+ // the end message after the runner completes, so we need to wait for the
68
+ // message to appear in the right place
69
+ if (versionOfNxBefore133) {
70
+ setTimeout(() => {
71
+ messages.printMessages();
72
+ if (!messages.anyErrors && !inner) {
73
+ endOfRunMessage.printCacheHitsMessage();
74
+ }
75
+ }, 0);
76
+ }
77
+ else {
78
+ messages.printMessages();
79
+ if (!messages.anyErrors && !inner) {
80
+ endOfRunMessage.printCacheHitsMessage();
81
+ }
82
+ }
83
+ if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
84
+ if (!endRequest[0]) {
85
+ output.error({
86
+ title: `Agent wasn't able to store artifacts`,
87
+ });
88
+ messages.printMessages();
89
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
90
+ }
91
+ if (!endRequest[1]) {
92
+ output.error({
93
+ title: `Agent wasn't able to record its run`,
94
+ });
95
+ messages.printMessages();
96
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
97
+ }
98
+ }
99
+ yield (0, metric_logger_1.submitRunMetrics)(options);
100
+ });
101
+ }
102
+ function createLifeCycle(runContext, options, outputObfuscator, tasks) {
103
+ const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, options.cacheDirectory, !!options.skipNxCache, options.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
104
+ try {
105
+ const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
106
+ if (!CompositeLifeCycle)
107
+ return cloudEnabledLifeCycle;
108
+ return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
109
+ }
110
+ catch (e) {
111
+ return cloudEnabledLifeCycle;
112
+ }
113
+ }
114
+ function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
115
+ const runContext = {
116
+ statuses: {},
117
+ scheduledTasks: [],
118
+ requests: {},
119
+ allTasks: tasks,
120
+ };
121
+ const versionOfNxBefore133 = options.lifeCycle === undefined;
122
+ const taskExecutions = [];
123
+ const messages = new message_reporter_1.MessageReporter(options);
124
+ const api = createApi(messages, options, runContext);
125
+ const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions);
126
+ const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
127
+ const hashes = tasks.map((t) => t.hash).filter((h) => !!h);
128
+ const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
129
+ hashes.forEach((hash) => {
130
+ runContext.requests[hash] = startRunRequest;
131
+ });
132
+ const runStartTime = new Date().toISOString();
133
+ const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
134
+ const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
135
+ const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
136
+ const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, false);
137
+ const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
138
+ // have to reset it so we don't capture inner tasks
139
+ delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
140
+ const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
141
+ // observable -> legacy
142
+ if (res.subscribe) {
143
+ const { Subject } = require('rxjs/internal/Subject');
144
+ const wrappedRes = new Subject();
145
+ res.subscribe({
146
+ next: (value) => wrappedRes.next(value),
147
+ error: (err) => wrappedRes.error(err),
148
+ complete: () => __awaiter(this, void 0, void 0, function* () {
149
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
150
+ wrappedRes.complete();
151
+ }),
152
+ });
153
+ return wrappedRes;
154
+ // promise
155
+ }
156
+ else {
157
+ return res
158
+ .then((r) => __awaiter(this, void 0, void 0, function* () {
159
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
160
+ return r;
161
+ }))
162
+ .catch((e) => __awaiter(this, void 0, void 0, function* () {
163
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
164
+ throw e;
165
+ }));
166
+ }
167
+ }
168
+ exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
169
+ //# sourceMappingURL=cloud-enabled.runner.js.map
@@ -1 +1,113 @@
1
- const a2_0x421c=['cacheError','.\x20Read\x20only\x20token\x20is\x20used.','remote-cache-hit','../../../utilities/environment','indexOf','runContext','messages','storage','value','Nx\x20Cloud:\x20Skipping\x20storing\x20','note','retrieve','storeRequests','defineProperty','Nx\x20Cloud:\x20Cache\x20miss\x20','reduce','hashUrls','filter','forEach','response','done','axiosException','statuses','requests','throw','hash','waitForStoreRequestsToComplete','scheduledTasks','.\x20Status\x20404.','VERBOSE_LOGGING','__esModule','cache-miss','put','push','extractErrorMessage','map','apply','all','store','get','../../../utilities/nx-imports','then','api','__awaiter','fileStorage','CloudRemoteCache'];(function(_0x44acd7,_0x421cdc){const _0x2d59e0=function(_0x18a858){while(--_0x18a858){_0x44acd7['push'](_0x44acd7['shift']());}};_0x2d59e0(++_0x421cdc);}(a2_0x421c,0x184));const a2_0x2d59=function(_0x44acd7,_0x421cdc){_0x44acd7=_0x44acd7-0x0;let _0x2d59e0=a2_0x421c[_0x44acd7];return _0x2d59e0;};'use strict';var __awaiter=this&&this[a2_0x2d59('0x17')]||function(_0x4ca075,_0x2485e4,_0x419000,_0x1a5e8c){function _0x44fd4f(_0x184c08){return _0x184c08 instanceof _0x419000?_0x184c08:new _0x419000(function(_0x2feb1c){_0x2feb1c(_0x184c08);});}return new(_0x419000||(_0x419000=Promise))(function(_0x278c6a,_0x2ba408){function _0x5f36e7(_0x2d1c41){try{_0x4d2106(_0x1a5e8c['next'](_0x2d1c41));}catch(_0xbac0c7){_0x2ba408(_0xbac0c7);}}function _0x22a643(_0x52b67d){try{_0x4d2106(_0x1a5e8c[a2_0x2d59('0x4')](_0x52b67d));}catch(_0x3e540d){_0x2ba408(_0x3e540d);}}function _0x4d2106(_0x5f5d7d){_0x5f5d7d[a2_0x2d59('0x0')]?_0x278c6a(_0x5f5d7d[a2_0x2d59('0x22')]):_0x44fd4f(_0x5f5d7d[a2_0x2d59('0x22')])[a2_0x2d59('0x15')](_0x5f36e7,_0x22a643);}_0x4d2106((_0x1a5e8c=_0x1a5e8c[a2_0x2d59('0x10')](_0x4ca075,_0x2485e4||[]))['next']());});};Object[a2_0x2d59('0x27')](exports,a2_0x2d59('0xa'),{'value':!![]});exports[a2_0x2d59('0x19')]=void 0x0;const environment_1=require(a2_0x2d59('0x1d'));const {output}=require(a2_0x2d59('0x14'));class CloudRemoteCache{constructor(_0xa58f5d,_0x5107a9,_0x5e67e2,_0x56fa7c){this[a2_0x2d59('0x20')]=_0xa58f5d;this[a2_0x2d59('0x16')]=_0x5107a9;this[a2_0x2d59('0x1f')]=_0x5e67e2;this['fileStorage']=_0x56fa7c;this[a2_0x2d59('0x26')]=[];}[a2_0x2d59('0x25')](_0x43d141,_0x19dab8){var _0x5081a8;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x2d59('0x20')]['cacheError'])return![];const _0x2430b3=yield this[a2_0x2d59('0x2a')](_0x43d141);if(!_0x2430b3||!_0x2430b3[a2_0x2d59('0x13')]){if(environment_1[a2_0x2d59('0x9')]){output['note']({'title':a2_0x2d59('0x28')+_0x43d141+'.'});}this[a2_0x2d59('0x1f')][a2_0x2d59('0x2')][_0x43d141]=a2_0x2d59('0xb');return![];}try{yield this[a2_0x2d59('0x18')][a2_0x2d59('0x25')](_0x43d141,_0x2430b3[a2_0x2d59('0x13')],_0x19dab8);this[a2_0x2d59('0x1f')][a2_0x2d59('0x2')][_0x43d141]=a2_0x2d59('0x1c');return!![];}catch(_0x5bcaba){const _0x312e9b=(_0x5081a8=_0x5bcaba[a2_0x2d59('0x1')])!==null&&_0x5081a8!==void 0x0?_0x5081a8:_0x5bcaba;if(_0x312e9b['response']&&_0x312e9b[a2_0x2d59('0x2d')]['status']===0x194){if(environment_1[a2_0x2d59('0x9')]){output[a2_0x2d59('0x24')]({'title':a2_0x2d59('0x28')+_0x43d141+a2_0x2d59('0x8')});}}else{this['messages'][a2_0x2d59('0x1a')]=this[a2_0x2d59('0x20')][a2_0x2d59('0xe')](_0x312e9b,a2_0x2d59('0x21'));}this[a2_0x2d59('0x1f')]['statuses'][_0x43d141]=a2_0x2d59('0xb');return![];}});}[a2_0x2d59('0x12')](_0x233ee0,_0x534ffd){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x2d59('0x20')][a2_0x2d59('0x1a')])return![];const _0x44b2e2=Promise['resolve']()['then'](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x548f38;const _0x4d7b86=yield this[a2_0x2d59('0x2a')](_0x233ee0);if(!_0x4d7b86)return![];if(!_0x4d7b86[a2_0x2d59('0xc')]){if(environment_1[a2_0x2d59('0x9')]){output[a2_0x2d59('0x24')]({'title':a2_0x2d59('0x23')+_0x233ee0+a2_0x2d59('0x1b')});}return!![];}try{yield this[a2_0x2d59('0x18')][a2_0x2d59('0x12')](_0x233ee0,_0x4d7b86[a2_0x2d59('0xc')],_0x534ffd);return!![];}catch(_0x2a011b){const _0x167756=(_0x548f38=_0x2a011b[a2_0x2d59('0x1')])!==null&&_0x548f38!==void 0x0?_0x548f38:_0x2a011b;this[a2_0x2d59('0x20')][a2_0x2d59('0x1a')]=this['messages'][a2_0x2d59('0xe')](_0x167756,a2_0x2d59('0x21'));return![];}}));this['storeRequests'][a2_0x2d59('0xd')](_0x44b2e2);return _0x44b2e2;});}[a2_0x2d59('0x2a')](_0x194bb){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x194bb in this[a2_0x2d59('0x1f')][a2_0x2d59('0x3')]){return(yield this[a2_0x2d59('0x1f')][a2_0x2d59('0x3')][_0x194bb])[_0x194bb];}else{const _0x3498e6=this[a2_0x2d59('0x1f')][a2_0x2d59('0x7')][a2_0x2d59('0x2b')](_0x4ea2f3=>!this[a2_0x2d59('0x1f')][a2_0x2d59('0x3')][_0x4ea2f3[a2_0x2d59('0x5')]])[a2_0x2d59('0xf')](_0x34f46e=>_0x34f46e[a2_0x2d59('0x5')]);if(_0x3498e6[a2_0x2d59('0x1e')](_0x194bb)===-0x1){_0x3498e6[a2_0x2d59('0xd')](_0x194bb);}const _0x872ca2=this[a2_0x2d59('0x16')]['startRun'](environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],_0x3498e6);_0x3498e6[a2_0x2d59('0x2c')](_0x3e35b9=>{this[a2_0x2d59('0x1f')]['requests'][_0x3e35b9]=_0x872ca2;});return(yield _0x872ca2)[_0x194bb];}});}[a2_0x2d59('0x6')](){return Promise[a2_0x2d59('0x11')](this[a2_0x2d59('0x26')])['then'](_0x4d8446=>_0x4d8446[a2_0x2d59('0x29')]((_0x22b598,_0x38537d)=>_0x22b598&&_0x38537d,!![]));}}exports[a2_0x2d59('0x19')]=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