@nrwl/nx-cloud 13.2.2 → 13.3.0-beta.0

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,65 @@
1
- const a0_0x54ff=['mapRespToPerfEntry','../../utilities/axios','axiosException','/nx-cloud/executions/complete-run-group','response','completeRunGroup','exit','then','recordMetric','RUNNER_FAILURE_PERF_ENTRY','apiAxiosInstance','axiosMultipleTries','createRunGroup','apply','post','../../utilities/metric-logger','RunGroupApi','../../utilities/nx-imports','throw','value','__awaiter','error','/nx-cloud/executions/create-run-group','createMetricRecorder','__esModule','message','createApiAxiosInstance','done'];(function(_0x3c3ac2,_0x54ff92){const _0x2b399e=function(_0x127907){while(--_0x127907){_0x3c3ac2['push'](_0x3c3ac2['shift']());}};_0x2b399e(++_0x54ff92);}(a0_0x54ff,0x161));const a0_0x2b39=function(_0x3c3ac2,_0x54ff92){_0x3c3ac2=_0x3c3ac2-0x0;let _0x2b399e=a0_0x54ff[_0x3c3ac2];return _0x2b399e;};'use strict';var __awaiter=this&&this[a0_0x2b39('0x3')]||function(_0xb5bd92,_0x18c675,_0x2817cc,_0x4ba41a){function _0x1b1097(_0x3522bf){return _0x3522bf instanceof _0x2817cc?_0x3522bf:new _0x2817cc(function(_0xfab067){_0xfab067(_0x3522bf);});}return new(_0x2817cc||(_0x2817cc=Promise))(function(_0x131155,_0x22c41e){function _0x580c0e(_0x2de508){try{_0xf20894(_0x4ba41a['next'](_0x2de508));}catch(_0x1c64b8){_0x22c41e(_0x1c64b8);}}function _0x54c0de(_0x28fc2e){try{_0xf20894(_0x4ba41a[a0_0x2b39('0x1')](_0x28fc2e));}catch(_0x3ca1e0){_0x22c41e(_0x3ca1e0);}}function _0xf20894(_0x1791e4){_0x1791e4[a0_0x2b39('0xa')]?_0x131155(_0x1791e4[a0_0x2b39('0x2')]):_0x1b1097(_0x1791e4[a0_0x2b39('0x2')])[a0_0x2b39('0x12')](_0x580c0e,_0x54c0de);}_0xf20894((_0x4ba41a=_0x4ba41a[a0_0x2b39('0x18')](_0xb5bd92,_0x18c675||[]))['next']());});};Object['defineProperty'](exports,a0_0x2b39('0x7'),{'value':!![]});exports[a0_0x2b39('0x1b')]=void 0x0;const axios_1=require(a0_0x2b39('0xc'));const metric_logger_1=require(a0_0x2b39('0x1a'));const {output}=require(a0_0x2b39('0x0'));class RunGroupApi{constructor(_0x187af4){this[a0_0x2b39('0x15')]=(0x0,axios_1[a0_0x2b39('0x9')])(_0x187af4);}[a0_0x2b39('0x17')](_0xe48bae,_0x46a74f){var _0x491041;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x510e3c=(0x0,metric_logger_1[a0_0x2b39('0x6')])(a0_0x2b39('0x17'));try{const _0x47c536=yield(0x0,axios_1[a0_0x2b39('0x16')])(()=>this[a0_0x2b39('0x15')]['post'](a0_0x2b39('0x5'),{'branch':_0xe48bae,'runGroup':_0x46a74f}));_0x510e3c['recordMetric']((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x47c536));}catch(_0x23a636){_0x510e3c[a0_0x2b39('0x13')](((_0x491041=_0x23a636===null||_0x23a636===void 0x0?void 0x0:_0x23a636[a0_0x2b39('0xd')])===null||_0x491041===void 0x0?void 0x0:_0x491041['response'])?(0x0,metric_logger_1[a0_0x2b39('0xb')])(_0x23a636[a0_0x2b39('0xd')][a0_0x2b39('0xf')]):metric_logger_1[a0_0x2b39('0x14')]);output[a0_0x2b39('0x4')]({'title':_0x23a636['message']});process['exit'](0x1);}});}[a0_0x2b39('0x10')](_0x1ef6a5){var _0x10ebb9;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x324370=(0x0,metric_logger_1[a0_0x2b39('0x6')])(a0_0x2b39('0x17'));try{const _0x178905=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a0_0x2b39('0x15')][a0_0x2b39('0x19')](a0_0x2b39('0xe'),{'runGroup':_0x1ef6a5}));_0x324370[a0_0x2b39('0x13')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x178905));}catch(_0xb804bc){_0x324370['recordMetric'](((_0x10ebb9=_0xb804bc===null||_0xb804bc===void 0x0?void 0x0:_0xb804bc[a0_0x2b39('0xd')])===null||_0x10ebb9===void 0x0?void 0x0:_0x10ebb9[a0_0x2b39('0xf')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0xb804bc['axiosException'][a0_0x2b39('0xf')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a0_0x2b39('0x4')]({'title':_0xb804bc[a0_0x2b39('0x8')]});process[a0_0x2b39('0x11')](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_0x3867=['configuration','params','cacheDirectory','startsWith','../../../utilities/nx-imports','local-cache-hit','toISOString','collectTerminalOutput','statuses','indexOf','defineProperty','tasks','join','readTerminalOutputFile','endTask','.cache','readFileSync','getTerminalOutput','outputObfuscator','endCommand','MAX_CHARACTERS_CACHED_TASK','forEach','cleanUpHashDetails','assign','toString','terminalOutputs','slice','nodes','keys','startTask','cacheStatus','hashDetails','scheduledTasks','status','cacheableOperations','MAX_CHARACTERS_FAILED_TASK','terminalOutput','local-cache','task','runContext','push','endTasks','__esModule','remote-cache','obfuscate','project','Cannot\x20find\x20task\x20','hash','skipNxCache','cache-miss','target','endTime','MAX_CHARACTERS_SUCCESSFUL_TASK','length','CloudEnabledLifeCycle','path','remote-cache-hit','local-cache-kept-existing','TRUNCATED\x0a\x0a','overrides','updateStartedTask','find'];(function(_0x1c1fb6,_0x386714){const _0x552254=function(_0x1731ea){while(--_0x1731ea){_0x1c1fb6['push'](_0x1c1fb6['shift']());}};_0x552254(++_0x386714);}(a0_0x3867,0x6b));const a0_0x5522=function(_0x1c1fb6,_0x386714){_0x1c1fb6=_0x1c1fb6-0x0;let _0x552254=a0_0x3867[_0x1c1fb6];return _0x552254;};'use strict';Object[a0_0x5522('0x1b')](exports,a0_0x5522('0x3b'),{'value':!![]});exports['CloudEnabledLifeCycle']=void 0x0;const path=require(a0_0x5522('0xa'));const path_1=require('path');const fs_1=require('fs');const {appRootPath,unparse}=require(a0_0x5522('0x15'));class CloudEnabledLifeCycle{constructor(_0x2ddde3,_0x482a8d,_0x4adb04,_0xae1955,_0x5532ed,_0x240dc9,_0x19c3e4){this[a0_0x5522('0x38')]=_0x2ddde3;this[a0_0x5522('0x13')]=_0x482a8d;this[a0_0x5522('0x3')]=_0x4adb04;this['collectTerminalOutput']=_0xae1955;this[a0_0x5522('0x33')]=_0x5532ed;this[a0_0x5522('0x23')]=_0x240dc9;this[a0_0x5522('0x1c')]=_0x19c3e4;}['scheduleTask'](_0x45123e){this['runContext'][a0_0x5522('0x31')][a0_0x5522('0x39')](_0x45123e);}[a0_0x5522('0x2e')](_0x4e37ce){const _0x3f65e2=Object[a0_0x5522('0x28')]({},_0x4e37ce[a0_0x5522('0xe')]||{});if(_0x4e37ce['target']['configuration']){_0x3f65e2[a0_0x5522('0x11')]=_0x4e37ce[a0_0x5522('0x5')][a0_0x5522('0x11')];}this['tasks'][a0_0x5522('0x39')]({'taskId':_0x4e37ce['id'],'startTime':new Date()[a0_0x5522('0x17')](),'target':_0x4e37ce[a0_0x5522('0x5')][a0_0x5522('0x5')],'projectName':_0x4e37ce[a0_0x5522('0x5')][a0_0x5522('0x0')],'hash':_0x4e37ce['hash'],'hashDetails':this['cleanUpHashDetails'](_0x4e37ce[a0_0x5522('0x30')]),'params':unparse(_0x3f65e2)['join']('\x20')});}[a0_0x5522('0x1f')](_0x3a2d26,_0x573033){let _0x2a93f1;if(this['runContext'][a0_0x5522('0x19')][_0x3a2d26[a0_0x5522('0x2')]]){_0x2a93f1=this['runContext'][a0_0x5522('0x19')][_0x3a2d26[a0_0x5522('0x2')]];}else{if(this[a0_0x5522('0x33')][a0_0x5522('0x1a')](_0x3a2d26[a0_0x5522('0x5')][a0_0x5522('0x5')])>-0x1&&!this[a0_0x5522('0x3')]){_0x2a93f1=a0_0x5522('0x16');}else{_0x2a93f1=a0_0x5522('0x4');}}this[a0_0x5522('0xf')](_0x3a2d26,_0x573033,_0x2a93f1);}[a0_0x5522('0x3a')](_0x471ae4){for(let _0x166858 of _0x471ae4){const _0x5384d9=_0x166858[a0_0x5522('0x32')]===a0_0x5522('0x3c')?a0_0x5522('0xb'):_0x166858[a0_0x5522('0x32')]===a0_0x5522('0x36')||_0x166858['status']===a0_0x5522('0xc')?a0_0x5522('0x16'):'cache-miss';this[a0_0x5522('0xf')](_0x166858[a0_0x5522('0x37')],_0x166858['code'],_0x5384d9);}}[a0_0x5522('0x24')](){}[a0_0x5522('0xf')](_0x3dc606,_0x1e011c,_0x4ecc57){const _0x483003=this[a0_0x5522('0x1c')][a0_0x5522('0x10')](_0x2ca212=>_0x2ca212['taskId']===_0x3dc606['id']);if(!_0x483003){throw new Error(a0_0x5522('0x1')+_0x3dc606['id']);}_0x483003[a0_0x5522('0x6')]=new Date()[a0_0x5522('0x17')]();_0x483003[a0_0x5522('0x32')]=_0x1e011c;_0x483003['params']=this[a0_0x5522('0x23')][a0_0x5522('0x3d')](_0x483003[a0_0x5522('0x12')]);_0x483003[a0_0x5522('0x2f')]=_0x4ecc57;if(this[a0_0x5522('0x18')]){_0x483003[a0_0x5522('0x35')]=this[a0_0x5522('0x22')](_0x3dc606['hash'],_0x483003['cacheStatus'],_0x1e011c);}}[a0_0x5522('0x22')](_0x35e3e1,_0x1d8a18,_0x5477cb){let _0x3853cc;if(this[a0_0x5522('0x13')]){if(this['cacheDirectory'][a0_0x5522('0x14')]('./')){_0x3853cc=(0x0,path_1[a0_0x5522('0x1d')])(appRootPath,this[a0_0x5522('0x13')]);}else{_0x3853cc=this['cacheDirectory'];}}else{_0x3853cc=(0x0,path_1[a0_0x5522('0x1d')])(appRootPath,'node_modules',a0_0x5522('0x20'),'nx');}try{const _0x5bae87=this[a0_0x5522('0x1e')](_0x3853cc,_0x35e3e1);const _0xd4d81d=this[a0_0x5522('0x23')][a0_0x5522('0x3d')](_0x5bae87);const _0x23e950=_0x1d8a18===a0_0x5522('0x4')?_0x5477cb===0x0?CloudEnabledLifeCycle[a0_0x5522('0x7')]:CloudEnabledLifeCycle['MAX_CHARACTERS_FAILED_TASK']:CloudEnabledLifeCycle[a0_0x5522('0x25')];return _0xd4d81d[a0_0x5522('0x8')]>_0x23e950?a0_0x5522('0xd')+_0xd4d81d[a0_0x5522('0x2b')](_0xd4d81d[a0_0x5522('0x8')]-_0x23e950):_0xd4d81d;}catch(_0x1aff01){return'';}}[a0_0x5522('0x27')](_0x1c7cef){const _0x2896fd={};Object[a0_0x5522('0x2d')](_0x1c7cef['nodes'])['filter'](_0x2ac5fc=>!_0x2ac5fc[a0_0x5522('0x14')]('npm:'))[a0_0x5522('0x26')](_0x3bd13a=>{_0x2896fd[_0x3bd13a]=_0x1c7cef[a0_0x5522('0x2c')][_0x3bd13a];});return{'nodes':_0x2896fd,'runtime':_0x1c7cef['runtime'],'implicitDeps':_0x1c7cef['implicitDeps']};}[a0_0x5522('0x1e')](_0x37fa10,_0x8b916b){try{return(0x0,fs_1[a0_0x5522('0x21')])(path[a0_0x5522('0x1d')](_0x37fa10,a0_0x5522('0x2a'),_0x8b916b))['toString']();}catch(_0x279348){try{return(0x0,fs_1[a0_0x5522('0x21')])(path[a0_0x5522('0x1d')](_0x37fa10,_0x8b916b,a0_0x5522('0x35')))[a0_0x5522('0x29')]();}catch(_0x4926bb){return'';}}}}exports[a0_0x5522('0x9')]=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x5522('0x34')]=0x30d40;CloudEnabledLifeCycle[a0_0x5522('0x7')]=0x4e20;CloudEnabledLifeCycle['MAX_CHARACTERS_CACHED_TASK']=0x1388;
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 { appRootPath, unparse } = require('../../../utilities/nx-imports');
8
+ class CloudEnabledLifeCycle {
9
+ constructor(runContext, cacheDirectory, skipNxCache, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
10
+ this.runContext = runContext;
11
+ this.cacheDirectory = cacheDirectory;
12
+ this.skipNxCache = skipNxCache;
13
+ this.collectTerminalOutput = collectTerminalOutput;
14
+ this.cacheableOperations = cacheableOperations;
15
+ this.outputObfuscator = outputObfuscator;
16
+ this.tasks = tasks;
17
+ }
18
+ scheduleTask(task) {
19
+ this.runContext.scheduledTasks.push(task);
20
+ }
21
+ startTask(task) {
22
+ const overrides = Object.assign({}, (task.overrides || {}));
23
+ if (task.target.configuration) {
24
+ overrides['configuration'] = task.target.configuration;
25
+ }
26
+ this.tasks.push({
27
+ taskId: task.id,
28
+ startTime: new Date().toISOString(),
29
+ target: task.target.target,
30
+ projectName: task.target.project,
31
+ hash: task.hash,
32
+ hashDetails: this.cleanUpHashDetails(task.hashDetails),
33
+ params: unparse(overrides).join(' '),
34
+ });
35
+ }
36
+ // Used for older version for Nx. Remove in Dec 2022
37
+ endTask(task, code) {
38
+ let cacheStatus;
39
+ if (this.runContext.statuses[task.hash]) {
40
+ cacheStatus = this.runContext.statuses[task.hash];
41
+ }
42
+ else {
43
+ if (this.cacheableOperations.indexOf(task.target.target) > -1 &&
44
+ !this.skipNxCache) {
45
+ cacheStatus = 'local-cache-hit';
46
+ }
47
+ else {
48
+ cacheStatus = 'cache-miss';
49
+ }
50
+ }
51
+ this.updateStartedTask(task, code, cacheStatus);
52
+ }
53
+ endTasks(tasks) {
54
+ for (let t of tasks) {
55
+ const status = t.status === 'remote-cache'
56
+ ? 'remote-cache-hit'
57
+ : t.status === 'local-cache' ||
58
+ t.status === 'local-cache-kept-existing'
59
+ ? 'local-cache-hit'
60
+ : 'cache-miss';
61
+ this.updateStartedTask(t.task, t.code, status);
62
+ }
63
+ }
64
+ endCommand() { }
65
+ updateStartedTask(task, code, cacheStatus) {
66
+ const startedTask = this.tasks.find((t) => t.taskId === task.id);
67
+ if (!startedTask) {
68
+ throw new Error(`Cannot find task ${task.id}`);
69
+ }
70
+ startedTask.endTime = new Date().toISOString();
71
+ startedTask.status = code;
72
+ startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
73
+ startedTask.cacheStatus = cacheStatus;
74
+ if (this.collectTerminalOutput) {
75
+ startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
76
+ }
77
+ }
78
+ getTerminalOutput(hash, cacheStatus, code) {
79
+ let dir;
80
+ if (this.cacheDirectory) {
81
+ if (this.cacheDirectory.startsWith('./')) {
82
+ dir = (0, path_1.join)(appRootPath, this.cacheDirectory);
83
+ }
84
+ else {
85
+ dir = this.cacheDirectory;
86
+ }
87
+ }
88
+ else {
89
+ dir = (0, path_1.join)(appRootPath, 'node_modules', '.cache', 'nx');
90
+ }
91
+ try {
92
+ const taskOutput = this.readTerminalOutputFile(dir, hash);
93
+ const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
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 = 5000;
138
+ //# sourceMappingURL=cloud-enabled-life-cycle.js.map
@@ -1 +1,166 @@
1
- const a1_0x1a7e=['tasks-hashes-','all','scan','assign','throw','EndOfRunMessage','lifeCycle','../../file-storage/file-storage','subscribe','MessageReporter','extractGitSha','waitForStoreRequestsToComplete','toISOString','encryptionKey','CloudRunApi','exit','CloudEnabledLifeCycle','env','getRunGroup','cacheDirectory','../../terminal-output/end-of-run-message','skipNxCache','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','path','anyErrors','printCacheHitsMessage','./cloud-enabled-life-cycle','then','../../../utilities/nx-imports','printMessages','next','submitRunMetrics','maskedProperties','OutputObfuscator','Subject','getBranch','VERBOSE_LOGGING','error','done','../../terminal-output/message-reporter','__esModule','E2EEncryption','Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts','note','../../../utilities/metric-logger','map','forEach','value','hash','__awaiter','parseCommand','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','cacheableOperations','writeFileSync','Executed\x20tasks\x20with\x20hashes:\x20','Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run','taskId','endRun','./node_modules/.cache/nx','getMachineInfo'];(function(_0x495555,_0x1a7e07){const _0x2e5687=function(_0x89ba06){while(--_0x89ba06){_0x495555['push'](_0x495555['shift']());}};_0x2e5687(++_0x1a7e07);}(a1_0x1a7e,0x198));const a1_0x2e56=function(_0x495555,_0x1a7e07){_0x495555=_0x495555-0x0;let _0x2e5687=a1_0x1a7e[_0x495555];return _0x2e5687;};'use strict';var __awaiter=this&&this[a1_0x2e56('0x8')]||function(_0x39d90a,_0x49a1b5,_0x188742,_0x27317a){function _0xcc899(_0x10956f){return _0x10956f instanceof _0x188742?_0x10956f:new _0x188742(function(_0x1ac0d3){_0x1ac0d3(_0x10956f);});}return new(_0x188742||(_0x188742=Promise))(function(_0x4fc4b0,_0x544bac){function _0x5aca2f(_0xc02672){try{_0x53d4f4(_0x27317a[a1_0x2e56('0x32')](_0xc02672));}catch(_0x4bb9ff){_0x544bac(_0x4bb9ff);}}function _0x3a19de(_0xd8eda6){try{_0x53d4f4(_0x27317a[a1_0x2e56('0x17')](_0xd8eda6));}catch(_0x17eb3a){_0x544bac(_0x17eb3a);}}function _0x53d4f4(_0x34752b){_0x34752b[a1_0x2e56('0x3a')]?_0x4fc4b0(_0x34752b[a1_0x2e56('0x6')]):_0xcc899(_0x34752b[a1_0x2e56('0x6')])[a1_0x2e56('0x2f')](_0x5aca2f,_0x3a19de);}_0x53d4f4((_0x27317a=_0x27317a['apply'](_0x39d90a,_0x49a1b5||[]))[a1_0x2e56('0x32')]());});};Object['defineProperty'](exports,a1_0x2e56('0x3c'),{'value':!![]});exports['cloudEnabledTasksRunner']=void 0x0;const Subject_1=require('rxjs/internal/Subject');const message_reporter_1=require(a1_0x2e56('0x3b'));const end_of_run_message_1=require(a1_0x2e56('0x27'));const output_obfuscator_1=require('../../terminal-output/output-obfuscator');const cloud_enabled_life_cycle_1=require(a1_0x2e56('0x2e'));const file_storage_1=require(a1_0x2e56('0x1a'));const e2e_encryption_1=require('../../file-storage/e2e-encryption');const environment_1=require('../../../utilities/environment');const cloud_remote_cache_1=require('./cloud-remote-cache');const cloud_run_api_1=require('./cloud-run.api');const fs_1=require('fs');const path=require(a1_0x2e56('0x2b'));const metric_logger_1=require(a1_0x2e56('0x3'));const {tasksRunnerV2,output}=require('../../../utilities/nx-imports');function createApi(_0x189fc2,_0x3a7d05,_0x5f4a1a){const _0x5840ed=(0x0,environment_1[a1_0x2e56('0x12')])(_0x3a7d05);return new cloud_run_api_1[(a1_0x2e56('0x21'))](_0x189fc2,_0x5f4a1a,_0x3a7d05,_0x5840ed);}function storeTaskHashes(_0x1f150b,_0x538f8e,_0x81e255){const _0xc3d61f=JSON['stringify'](_0x1f150b['map'](_0x2103aa=>({'taskId':_0x2103aa[a1_0x2e56('0xf')],'hash':_0x2103aa[a1_0x2e56('0x7')]})));if(environment_1[a1_0x2e56('0x38')]){output[a1_0x2e56('0x2')]({'title':a1_0x2e56('0xd')+_0xc3d61f});}(0x0,fs_1[a1_0x2e56('0xc')])(path['join'](_0x538f8e,a1_0x2e56('0x13')+_0x81e255),_0xc3d61f);}function onComplete(_0x370f61,_0x2d3a88,_0x2053e2,_0x41b168,_0x4b44a0,_0x183a08,_0x2cbbea,_0x57fc56,_0x524e3f,_0x58a699){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x531132=new Date()[a1_0x2e56('0x1f')]();if(environment_1[a1_0x2e56('0x2a')]){storeTaskHashes(_0x524e3f,_0x2d3a88[a1_0x2e56('0x26')]||a1_0x2e56('0x11'),environment_1[a1_0x2e56('0x29')]);}const _0x5a6098=(0x0,environment_1[a1_0x2e56('0x37')])();const _0x15f0ad=yield Promise[a1_0x2e56('0x14')]([_0x2053e2[a1_0x2e56('0x1e')](),_0x41b168[a1_0x2e56('0x10')]({'command':_0x4b44a0['obfuscate']((0x0,environment_1[a1_0x2e56('0x9')])()),'startTime':_0x183a08,'endTime':_0x531132,'distributedExecutionId':environment_1[a1_0x2e56('0x29')],'branch':_0x5a6098,'scan':!![],'runGroup':(0x0,environment_1[a1_0x2e56('0x25')])(),'sha':_0x5a6098?(0x0,environment_1[a1_0x2e56('0x1d')])():undefined},_0x524e3f)]);if(_0x58a699){setTimeout(()=>{_0x2cbbea[a1_0x2e56('0x31')]();if(!_0x2cbbea[a1_0x2e56('0x2c')]){_0x57fc56[a1_0x2e56('0x2d')]();}},0x0);}else{_0x2cbbea[a1_0x2e56('0x31')]();if(!_0x2cbbea[a1_0x2e56('0x2c')]){_0x57fc56[a1_0x2e56('0x2d')]();}}if(environment_1['AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION']){if(!_0x15f0ad[0x0]){output[a1_0x2e56('0x39')]({'title':a1_0x2e56('0x1')});_0x2cbbea[a1_0x2e56('0x31')]();process[a1_0x2e56('0x22')](environment_1[a1_0x2e56('0xa')]);}if(!_0x15f0ad[0x1]){output[a1_0x2e56('0x39')]({'title':a1_0x2e56('0xe')});_0x2cbbea[a1_0x2e56('0x31')]();process[a1_0x2e56('0x22')](environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']);}}yield(0x0,metric_logger_1[a1_0x2e56('0x33')])(_0x2d3a88);});}function createLifeCycle(_0x403434,_0x396e69,_0x1a5406,_0x345b58){const _0x5876d0=new cloud_enabled_life_cycle_1[(a1_0x2e56('0x23'))](_0x403434,_0x396e69[a1_0x2e56('0x26')],!!_0x396e69[a1_0x2e56('0x28')],_0x396e69[a1_0x2e56('0x15')]===undefined?!![]:_0x396e69['scan'],_0x396e69[a1_0x2e56('0xb')]||[],_0x1a5406,_0x345b58);try{const {CompositeLifeCycle}=require(a1_0x2e56('0x30'));if(!CompositeLifeCycle)return _0x5876d0;return new CompositeLifeCycle([_0x396e69['lifeCycle'],_0x5876d0]);}catch(_0xf5f066){return _0x5876d0;}}function cloudEnabledTasksRunner(_0x1c7391,_0x55f356,_0x187cc8){const _0x387627={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x1c7391};const _0x391e40=_0x55f356[a1_0x2e56('0x19')]===undefined;const _0x555679=[];const _0x5baef8=new message_reporter_1[(a1_0x2e56('0x1c'))](_0x55f356);const _0x50be99=createApi(_0x5baef8,_0x55f356,_0x387627);const _0x520e74=new end_of_run_message_1[(a1_0x2e56('0x18'))](_0x387627,_0x555679);const _0xb96ded=new output_obfuscator_1[(a1_0x2e56('0x35'))](_0x55f356[a1_0x2e56('0x34')]);const _0x522f47=_0x1c7391[a1_0x2e56('0x4')](_0x218df9=>_0x218df9['hash'])['filter'](_0x35f80c=>!!_0x35f80c);const _0x373a11=_0x50be99['startRun'](environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],_0x522f47);_0x522f47[a1_0x2e56('0x5')](_0x5d3935=>{_0x387627['requests'][_0x5d3935]=_0x373a11;});const _0x4404db=new Date()[a1_0x2e56('0x1f')]();const _0x4ecae9=createLifeCycle(_0x387627,_0x55f356,_0xb96ded,_0x555679);const _0x4b65ac=new e2e_encryption_1[(a1_0x2e56('0x0'))](environment_1['ENCRYPTION_KEY']||_0x55f356[a1_0x2e56('0x20')]);const _0x21dec6=new file_storage_1['FileStorage'](_0x4b65ac);const _0xbc87fa=new cloud_remote_cache_1['CloudRemoteCache'](_0x5baef8,_0x50be99,_0x387627,_0x21dec6);delete process[a1_0x2e56('0x24')][a1_0x2e56('0x29')];const _0x24f702=tasksRunnerV2(_0x1c7391,Object[a1_0x2e56('0x16')](Object['assign']({},_0x55f356),{'remoteCache':_0xbc87fa,'lifeCycle':_0x4ecae9}),_0x187cc8);if(_0x24f702[a1_0x2e56('0x1b')]){const _0x4457ed=new Subject_1[(a1_0x2e56('0x36'))]();_0x24f702[a1_0x2e56('0x1b')]({'next':_0x11d664=>_0x4457ed[a1_0x2e56('0x32')](_0x11d664),'error':_0x115c94=>_0x4457ed['error'](_0x115c94),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x4ecae9,_0x55f356,_0xbc87fa,_0x50be99,_0xb96ded,_0x4404db,_0x5baef8,_0x520e74,_0x555679,_0x391e40);_0x4457ed['complete']();})});return _0x4457ed;}else{return _0x24f702['then'](_0x3265f2=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x4ecae9,_0x55f356,_0xbc87fa,_0x50be99,_0xb96ded,_0x4404db,_0x5baef8,_0x520e74,_0x555679,_0x391e40);return _0x3265f2;}))['catch'](_0x40b459=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x4ecae9,_0x55f356,_0xbc87fa,_0x50be99,_0xb96ded,_0x4404db,_0x5baef8,_0x520e74,_0x555679,_0x391e40);throw _0x40b459;}));}}exports['cloudEnabledTasksRunner']=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 Subject_1 = require("rxjs/internal/Subject");
14
+ const message_reporter_1 = require("../../terminal-output/message-reporter");
15
+ const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
16
+ const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
17
+ const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
18
+ const file_storage_1 = require("../../file-storage/file-storage");
19
+ const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
20
+ const environment_1 = require("../../../utilities/environment");
21
+ const cloud_remote_cache_1 = require("./cloud-remote-cache");
22
+ const cloud_run_api_1 = require("./cloud-run.api");
23
+ const fs_1 = require("fs");
24
+ const path = require("path");
25
+ const metric_logger_1 = require("../../../utilities/metric-logger");
26
+ const { tasksRunnerV2, 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) {
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
+ }, taskExecutions),
64
+ ]);
65
+ // this workaround is required because prior to Nx 13.3 we printed
66
+ // the end message after the runner completes, so we need to wait for the
67
+ // message to appear in the right place
68
+ if (versionOfNxBefore133) {
69
+ setTimeout(() => {
70
+ messages.printMessages();
71
+ if (!messages.anyErrors) {
72
+ endOfRunMessage.printCacheHitsMessage();
73
+ }
74
+ }, 0);
75
+ }
76
+ else {
77
+ messages.printMessages();
78
+ if (!messages.anyErrors) {
79
+ endOfRunMessage.printCacheHitsMessage();
80
+ }
81
+ }
82
+ if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
83
+ if (!endRequest[0]) {
84
+ output.error({
85
+ title: `Agent wasn't able to store artifacts`,
86
+ });
87
+ messages.printMessages();
88
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
89
+ }
90
+ if (!endRequest[1]) {
91
+ output.error({
92
+ title: `Agent wasn't able to record its run`,
93
+ });
94
+ messages.printMessages();
95
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
96
+ }
97
+ }
98
+ yield (0, metric_logger_1.submitRunMetrics)(options);
99
+ });
100
+ }
101
+ function createLifeCycle(runContext, options, outputObfuscator, tasks) {
102
+ const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, options.cacheDirectory, !!options.skipNxCache, options.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
103
+ try {
104
+ const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
105
+ if (!CompositeLifeCycle)
106
+ return cloudEnabledLifeCycle;
107
+ return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
108
+ }
109
+ catch (e) {
110
+ return cloudEnabledLifeCycle;
111
+ }
112
+ }
113
+ function cloudEnabledTasksRunner(tasks, options, context) {
114
+ const runContext = {
115
+ statuses: {},
116
+ scheduledTasks: [],
117
+ requests: {},
118
+ allTasks: tasks,
119
+ };
120
+ const versionOfNxBefore133 = options.lifeCycle === undefined;
121
+ const taskExecutions = [];
122
+ const messages = new message_reporter_1.MessageReporter(options);
123
+ const api = createApi(messages, options, runContext);
124
+ const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions);
125
+ const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
126
+ const hashes = tasks.map((t) => t.hash).filter((h) => !!h);
127
+ const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
128
+ hashes.forEach((hash) => {
129
+ runContext.requests[hash] = startRunRequest;
130
+ });
131
+ const runStartTime = new Date().toISOString();
132
+ const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
133
+ const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
134
+ const fileStorage = new file_storage_1.FileStorage(encryption);
135
+ const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
136
+ // have to reset it so we don't capture inner tasks
137
+ delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
138
+ const res = tasksRunnerV2(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
139
+ // observable -> legacy
140
+ if (res.subscribe) {
141
+ const wrappedRes = new Subject_1.Subject();
142
+ res.subscribe({
143
+ next: (value) => wrappedRes.next(value),
144
+ error: (err) => wrappedRes.error(err),
145
+ complete: () => __awaiter(this, void 0, void 0, function* () {
146
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133);
147
+ wrappedRes.complete();
148
+ }),
149
+ });
150
+ return wrappedRes;
151
+ // promise
152
+ }
153
+ else {
154
+ return res
155
+ .then((r) => __awaiter(this, void 0, void 0, function* () {
156
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133);
157
+ return r;
158
+ }))
159
+ .catch((e) => __awaiter(this, void 0, void 0, function* () {
160
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133);
161
+ throw e;
162
+ }));
163
+ }
164
+ }
165
+ exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
166
+ //# sourceMappingURL=cloud-enabled.runner.js.map
@@ -1 +1,113 @@
1
- const a2_0x495a=['requests','VERBOSE_LOGGING','remote-cache-hit','resolve','value','hashUrls','filter','cache-miss','extractErrorMessage','defineProperty','messages','storeRequests','runContext','retrieve','get','store','axiosException','../../../utilities/environment','statuses','CloudRemoteCache','push','Nx\x20Cloud:\x20Cache\x20miss\x20','api','response','waitForStoreRequestsToComplete','hash','throw','cacheError','put','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','then','.\x20Read\x20only\x20token\x20is\x20used.','../../../utilities/nx-imports','storage','fileStorage','reduce','.\x20Status\x20404.','all','map','startRun','apply','done'];(function(_0x3df1c9,_0x495a09){const _0x135098=function(_0x4ab5cd){while(--_0x4ab5cd){_0x3df1c9['push'](_0x3df1c9['shift']());}};_0x135098(++_0x495a09);}(a2_0x495a,0x168));const a2_0x1350=function(_0x3df1c9,_0x495a09){_0x3df1c9=_0x3df1c9-0x0;let _0x135098=a2_0x495a[_0x3df1c9];return _0x135098;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x4f4422,_0x134dca,_0x3e0c42,_0x17706d){function _0x359e3e(_0x496fc3){return _0x496fc3 instanceof _0x3e0c42?_0x496fc3:new _0x3e0c42(function(_0x173975){_0x173975(_0x496fc3);});}return new(_0x3e0c42||(_0x3e0c42=Promise))(function(_0xdd88c6,_0x777d7c){function _0x36eef3(_0x15cfdf){try{_0x2decca(_0x17706d['next'](_0x15cfdf));}catch(_0x29c030){_0x777d7c(_0x29c030);}}function _0x1f6d42(_0x48fbbf){try{_0x2decca(_0x17706d[a2_0x1350('0x2')](_0x48fbbf));}catch(_0x25fd92){_0x777d7c(_0x25fd92);}}function _0x2decca(_0x140e1c){_0x140e1c[a2_0x1350('0x11')]?_0xdd88c6(_0x140e1c[a2_0x1350('0x16')]):_0x359e3e(_0x140e1c[a2_0x1350('0x16')])[a2_0x1350('0x6')](_0x36eef3,_0x1f6d42);}_0x2decca((_0x17706d=_0x17706d[a2_0x1350('0x10')](_0x4f4422,_0x134dca||[]))['next']());});};Object[a2_0x1350('0x1b')](exports,'__esModule',{'value':!![]});exports[a2_0x1350('0x25')]=void 0x0;const environment_1=require(a2_0x1350('0x23'));const {output}=require(a2_0x1350('0x8'));class CloudRemoteCache{constructor(_0x2aa2d3,_0x417e5a,_0x208a03,_0x232547){this['messages']=_0x2aa2d3;this[a2_0x1350('0x28')]=_0x417e5a;this[a2_0x1350('0x1e')]=_0x208a03;this[a2_0x1350('0xa')]=_0x232547;this[a2_0x1350('0x1d')]=[];}[a2_0x1350('0x1f')](_0x2fb89c,_0x41a874){var _0x2643de;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x1350('0x1c')][a2_0x1350('0x3')])return![];const _0x49feab=yield this[a2_0x1350('0x17')](_0x2fb89c);if(!_0x49feab||!_0x49feab[a2_0x1350('0x20')]){if(environment_1[a2_0x1350('0x13')]){output['note']({'title':a2_0x1350('0x27')+_0x2fb89c+'.'});}this[a2_0x1350('0x1e')][a2_0x1350('0x24')][_0x2fb89c]=a2_0x1350('0x19');return![];}try{yield this[a2_0x1350('0xa')]['retrieve'](_0x2fb89c,_0x49feab[a2_0x1350('0x20')],_0x41a874);this[a2_0x1350('0x1e')][a2_0x1350('0x24')][_0x2fb89c]=a2_0x1350('0x14');return!![];}catch(_0xdfbe53){const _0x2205ca=(_0x2643de=_0xdfbe53['axiosException'])!==null&&_0x2643de!==void 0x0?_0x2643de:_0xdfbe53;if(_0x2205ca[a2_0x1350('0x29')]&&_0x2205ca[a2_0x1350('0x29')]['status']===0x194){if(environment_1[a2_0x1350('0x13')]){output['note']({'title':a2_0x1350('0x27')+_0x2fb89c+a2_0x1350('0xc')});}}else{this[a2_0x1350('0x1c')][a2_0x1350('0x3')]=this[a2_0x1350('0x1c')]['extractErrorMessage'](_0x2205ca,a2_0x1350('0x9'));}this[a2_0x1350('0x1e')][a2_0x1350('0x24')][_0x2fb89c]='cache-miss';return![];}});}[a2_0x1350('0x21')](_0x5ddeea,_0x33eee9){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x1350('0x1c')][a2_0x1350('0x3')])return![];const _0x3bbfca=Promise[a2_0x1350('0x15')]()[a2_0x1350('0x6')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x15975b;const _0x1fcc30=yield this[a2_0x1350('0x17')](_0x5ddeea);if(!_0x1fcc30)return![];if(!_0x1fcc30[a2_0x1350('0x4')]){if(environment_1[a2_0x1350('0x13')]){output['note']({'title':'Nx\x20Cloud:\x20Skipping\x20storing\x20'+_0x5ddeea+a2_0x1350('0x7')});}return!![];}try{yield this[a2_0x1350('0xa')][a2_0x1350('0x21')](_0x5ddeea,_0x1fcc30[a2_0x1350('0x4')],_0x33eee9);return!![];}catch(_0x5921b9){const _0x199941=(_0x15975b=_0x5921b9[a2_0x1350('0x22')])!==null&&_0x15975b!==void 0x0?_0x15975b:_0x5921b9;this['messages']['cacheError']=this[a2_0x1350('0x1c')][a2_0x1350('0x1a')](_0x199941,a2_0x1350('0x9'));return![];}}));this[a2_0x1350('0x1d')][a2_0x1350('0x26')](_0x3bbfca);return _0x3bbfca;});}[a2_0x1350('0x17')](_0x7cfb39){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x7cfb39 in this[a2_0x1350('0x1e')]['requests']){return(yield this[a2_0x1350('0x1e')][a2_0x1350('0x12')][_0x7cfb39])[_0x7cfb39];}else{const _0x4e9843=this[a2_0x1350('0x1e')]['scheduledTasks'][a2_0x1350('0x18')](_0x26c84a=>!this[a2_0x1350('0x1e')]['requests'][_0x26c84a[a2_0x1350('0x1')]])[a2_0x1350('0xe')](_0x37a0a8=>_0x37a0a8[a2_0x1350('0x1')]);if(_0x4e9843['indexOf'](_0x7cfb39)===-0x1){_0x4e9843[a2_0x1350('0x26')](_0x7cfb39);}const _0x35aa74=this[a2_0x1350('0x28')][a2_0x1350('0xf')](environment_1[a2_0x1350('0x5')],_0x4e9843);_0x4e9843['forEach'](_0x45d8ae=>{this[a2_0x1350('0x1e')][a2_0x1350('0x12')][_0x45d8ae]=_0x35aa74;});return(yield _0x35aa74)[_0x7cfb39];}});}[a2_0x1350('0x0')](){return Promise[a2_0x1350('0xd')](this[a2_0x1350('0x1d')])[a2_0x1350('0x6')](_0x333194=>_0x333194[a2_0x1350('0xb')]((_0x48e1a3,_0x4f6e0f)=>_0x48e1a3&&_0x4f6e0f,!![]));}}exports[a2_0x1350('0x25')]=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