@nrwl/nx-cloud 13.0.3 → 13.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,59 @@
1
- const a0_0xcf84=['message','createMetricRecorder','RUNNER_FAILURE_PERF_ENTRY','/nx-cloud/executions/create-run-group','defineProperty','next','@nrwl/workspace/src/utilities/output','error','createRunGroup','apply','value','axiosMultipleTries','createApiAxiosInstance','done','mapRespToPerfEntry','completeRunGroup','__esModule','apiAxiosInstance','output','exit','../../utilities/metric-logger','post','recordMetric','then','../../utilities/axios','RunGroupApi','throw'];(function(_0x2cc596,_0xcf8417){const _0x57938e=function(_0x48af5a){while(--_0x48af5a){_0x2cc596['push'](_0x2cc596['shift']());}};_0x57938e(++_0xcf8417);}(a0_0xcf84,0x120));const a0_0x5793=function(_0x2cc596,_0xcf8417){_0x2cc596=_0x2cc596-0x0;let _0x57938e=a0_0xcf84[_0x2cc596];return _0x57938e;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x27e5c0,_0x534b7f,_0x320f07,_0x4d1e0d){function _0x6770af(_0x42a991){return _0x42a991 instanceof _0x320f07?_0x42a991:new _0x320f07(function(_0x266ec7){_0x266ec7(_0x42a991);});}return new(_0x320f07||(_0x320f07=Promise))(function(_0xc76474,_0x25c288){function _0xaa18bc(_0x4fc2c1){try{_0x22cf7a(_0x4d1e0d['next'](_0x4fc2c1));}catch(_0x586d17){_0x25c288(_0x586d17);}}function _0x13db97(_0x3231ba){try{_0x22cf7a(_0x4d1e0d[a0_0x5793('0x8')](_0x3231ba));}catch(_0x3a7790){_0x25c288(_0x3a7790);}}function _0x22cf7a(_0x399c71){_0x399c71[a0_0x5793('0x16')]?_0xc76474(_0x399c71[a0_0x5793('0x13')]):_0x6770af(_0x399c71[a0_0x5793('0x13')])[a0_0x5793('0x5')](_0xaa18bc,_0x13db97);}_0x22cf7a((_0x4d1e0d=_0x4d1e0d[a0_0x5793('0x12')](_0x27e5c0,_0x534b7f||[]))[a0_0x5793('0xe')]());});};Object[a0_0x5793('0xd')](exports,a0_0x5793('0x19'),{'value':!![]});exports['RunGroupApi']=void 0x0;const output_1=require(a0_0x5793('0xf'));const axios_1=require(a0_0x5793('0x6'));const metric_logger_1=require(a0_0x5793('0x2'));class RunGroupApi{constructor(_0x40e576){this['apiAxiosInstance']=(0x0,axios_1[a0_0x5793('0x15')])(_0x40e576);}[a0_0x5793('0x11')](_0x1ff1f1,_0x3cd0e8){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x313f6a=(0x0,metric_logger_1['createMetricRecorder'])(a0_0x5793('0x11'));try{const _0xa13000=yield(0x0,axios_1[a0_0x5793('0x14')])(()=>this[a0_0x5793('0x1a')][a0_0x5793('0x3')](a0_0x5793('0xc'),{'branch':_0x1ff1f1,'runGroup':_0x3cd0e8}),0x3);_0x313f6a['recordMetric']((0x0,metric_logger_1[a0_0x5793('0x17')])(_0xa13000));}catch(_0x1fd4a2){_0x313f6a[a0_0x5793('0x4')](metric_logger_1[a0_0x5793('0xb')]);output_1['output'][a0_0x5793('0x10')]({'title':_0x1fd4a2[a0_0x5793('0x9')]});process[a0_0x5793('0x1')](0x1);}});}[a0_0x5793('0x18')](_0x5638a3){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x12aa07=(0x0,metric_logger_1[a0_0x5793('0xa')])(a0_0x5793('0x11'));try{const _0x2571a3=yield(0x0,axios_1[a0_0x5793('0x14')])(()=>this[a0_0x5793('0x1a')][a0_0x5793('0x3')]('/nx-cloud/executions/complete-run-group',{'runGroup':_0x5638a3}),0x3);_0x12aa07['recordMetric']((0x0,metric_logger_1[a0_0x5793('0x17')])(_0x2571a3));}catch(_0x40a751){_0x12aa07[a0_0x5793('0x4')](metric_logger_1[a0_0x5793('0xb')]);output_1[a0_0x5793('0x0')][a0_0x5793('0x10')]({'title':_0x40a751[a0_0x5793('0x9')]});process[a0_0x5793('0x1')](0x1);}});}}exports[a0_0x5793('0x7')]=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 output_1 = require("@nrwl/workspace/src/utilities/output");
14
+ const axios_1 = require("../../utilities/axios");
15
+ const metric_logger_1 = require("../../utilities/metric-logger");
16
+ class RunGroupApi {
17
+ constructor(options) {
18
+ this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
19
+ }
20
+ createRunGroup(branch, runGroup) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
23
+ try {
24
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
25
+ branch: branch,
26
+ runGroup: runGroup,
27
+ }), 3);
28
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
29
+ }
30
+ catch (e) {
31
+ recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
32
+ output_1.output.error({
33
+ title: e.message,
34
+ });
35
+ process.exit(1);
36
+ }
37
+ });
38
+ }
39
+ completeRunGroup(runGroup) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
42
+ try {
43
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
44
+ runGroup: runGroup,
45
+ }), 3);
46
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
47
+ }
48
+ catch (e) {
49
+ recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
50
+ output_1.output.error({
51
+ title: e.message,
52
+ });
53
+ process.exit(1);
54
+ }
55
+ });
56
+ }
57
+ }
58
+ exports.RunGroupApi = RunGroupApi;
59
+ //# sourceMappingURL=run-group.api.js.map
@@ -1 +1,120 @@
1
- const a0_0x441e=['endTask','cacheDirectory','obfuscate','implicitDeps','toISOString','overrides','cache-miss','defineProperty','filter','runContext','startsWith','MAX_CHARACTERS_CACHED_TASK','MAX_CHARACTERS_SUCCESSFUL_TASK','readTerminalOutputFile','scheduleTask','unparse','local-cache-hit','cacheStatus','toString','keys','node_modules','push','CloudEnabledLifeCycle','@nrwl/workspace/src/utils/app-root','tasks','terminalOutputs','hash','indexOf','cacheableOperations','getTerminalOutput','MAX_CHARACTERS_FAILED_TASK','runtime','assign','cleanUpHashDetails','endTime','endCommand','outputObfuscator','find','nodes','forEach','target','length','Cannot\x20find\x20task\x20','params','terminalOutput','TRUNCATED\x0a\x0a','readFileSync','appRootPath','configuration','project','collectTerminalOutput','scheduledTasks','join','__esModule','path'];(function(_0x33c691,_0x441edd){const _0x308544=function(_0x408551){while(--_0x408551){_0x33c691['push'](_0x33c691['shift']());}};_0x308544(++_0x441edd);}(a0_0x441e,0x13d));const a0_0x3085=function(_0x33c691,_0x441edd){_0x33c691=_0x33c691-0x0;let _0x308544=a0_0x441e[_0x33c691];return _0x308544;};'use strict';Object[a0_0x3085('0x14')](exports,a0_0x3085('0xb'),{'value':!![]});exports[a0_0x3085('0x23')]=void 0x0;const utils_1=require('@nrwl/workspace/src/tasks-runner/utils');const path_1=require(a0_0x3085('0xc'));const app_root_1=require(a0_0x3085('0x24'));const fs_1=require('fs');const path=require(a0_0x3085('0xc'));class CloudEnabledLifeCycle{constructor(_0x1e314e,_0x2b75ff,_0x2030a5,_0x1d0bb1,_0x510e1f,_0x1df8c6){this['runContext']=_0x1e314e;this[a0_0x3085('0xe')]=_0x2b75ff;this['collectTerminalOutput']=_0x2030a5;this[a0_0x3085('0x29')]=_0x1d0bb1;this[a0_0x3085('0x31')]=_0x510e1f;this['tasks']=_0x1df8c6;}[a0_0x3085('0x1b')](_0x215c7f){this['runContext'][a0_0x3085('0x9')]['push'](_0x215c7f);}['startTask'](_0x35625a){const _0x4bd31b=Object[a0_0x3085('0x2d')]({},_0x35625a[a0_0x3085('0x12')]||{});if(_0x35625a[a0_0x3085('0x35')][a0_0x3085('0x6')]){_0x4bd31b[a0_0x3085('0x6')]=_0x35625a[a0_0x3085('0x35')][a0_0x3085('0x6')];}this[a0_0x3085('0x25')][a0_0x3085('0x22')]({'taskId':_0x35625a['id'],'startTime':new Date()[a0_0x3085('0x11')](),'target':_0x35625a['target'][a0_0x3085('0x35')],'projectName':_0x35625a[a0_0x3085('0x35')][a0_0x3085('0x7')],'hash':_0x35625a['hash'],'hashDetails':this[a0_0x3085('0x2e')](_0x35625a['hashDetails']),'params':(0x0,utils_1[a0_0x3085('0x1c')])(_0x4bd31b)[a0_0x3085('0xa')]('\x20')});}[a0_0x3085('0xd')](_0x20c7c4,_0x589959){const _0x577575=this['tasks'][a0_0x3085('0x32')](_0x4027fb=>_0x4027fb['taskId']===_0x20c7c4['id']);if(!_0x577575){throw new Error(a0_0x3085('0x0')+_0x20c7c4['id']);}_0x577575[a0_0x3085('0x2f')]=new Date()[a0_0x3085('0x11')]();_0x577575['status']=_0x589959;_0x577575['params']=this[a0_0x3085('0x31')][a0_0x3085('0xf')](_0x577575[a0_0x3085('0x1')]);if(this[a0_0x3085('0x16')]['statuses'][_0x20c7c4[a0_0x3085('0x27')]]){_0x577575['cacheStatus']=this[a0_0x3085('0x16')]['statuses'][_0x20c7c4[a0_0x3085('0x27')]];}else{if(this[a0_0x3085('0x29')][a0_0x3085('0x28')](_0x20c7c4[a0_0x3085('0x35')]['target'])>-0x1){_0x577575['cacheStatus']=a0_0x3085('0x1d');}else{_0x577575['cacheStatus']=a0_0x3085('0x13');}}if(this[a0_0x3085('0x8')]){_0x577575[a0_0x3085('0x2')]=this[a0_0x3085('0x2a')](_0x20c7c4[a0_0x3085('0x27')],_0x577575[a0_0x3085('0x1e')],_0x589959);}}[a0_0x3085('0x30')](){}[a0_0x3085('0x2a')](_0x8713f2,_0x344047,_0x47eaa8){let _0x15829f;if(this[a0_0x3085('0xe')]){if(this['cacheDirectory']['startsWith']('./')){_0x15829f=(0x0,path_1[a0_0x3085('0xa')])(app_root_1[a0_0x3085('0x5')],this[a0_0x3085('0xe')]);}else{_0x15829f=this[a0_0x3085('0xe')];}}else{_0x15829f=(0x0,path_1[a0_0x3085('0xa')])(app_root_1[a0_0x3085('0x5')],a0_0x3085('0x21'),'.cache','nx');}try{const _0x2ecdd0=this[a0_0x3085('0x1a')](_0x15829f,_0x8713f2);const _0x48d7f9=this['outputObfuscator'][a0_0x3085('0xf')](_0x2ecdd0);const _0x47cc77=_0x344047==='cache-miss'?_0x47eaa8===0x0?CloudEnabledLifeCycle['MAX_CHARACTERS_SUCCESSFUL_TASK']:CloudEnabledLifeCycle[a0_0x3085('0x2b')]:CloudEnabledLifeCycle[a0_0x3085('0x18')];return _0x48d7f9['length']>_0x47cc77?a0_0x3085('0x3')+_0x48d7f9['slice'](_0x48d7f9[a0_0x3085('0x36')]-_0x47cc77):_0x48d7f9;}catch(_0x428a6d){return'';}}[a0_0x3085('0x2e')](_0x372816){const _0x41372a={};Object[a0_0x3085('0x20')](_0x372816['nodes'])[a0_0x3085('0x15')](_0x59ba1e=>!_0x59ba1e[a0_0x3085('0x17')]('npm:'))[a0_0x3085('0x34')](_0x12c518=>{_0x41372a[_0x12c518]=_0x372816[a0_0x3085('0x33')][_0x12c518];});return{'nodes':_0x41372a,'runtime':_0x372816[a0_0x3085('0x2c')],'implicitDeps':_0x372816[a0_0x3085('0x10')]};}[a0_0x3085('0x1a')](_0x9914d9,_0x21cf37){try{return(0x0,fs_1['readFileSync'])(path[a0_0x3085('0xa')](_0x9914d9,a0_0x3085('0x26'),_0x21cf37))[a0_0x3085('0x1f')]();}catch(_0x1218de){try{return(0x0,fs_1[a0_0x3085('0x4')])(path[a0_0x3085('0xa')](_0x9914d9,_0x21cf37,a0_0x3085('0x2')))['toString']();}catch(_0x46aff8){return'';}}}}exports[a0_0x3085('0x23')]=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x3085('0x2b')]=0x30d40;CloudEnabledLifeCycle[a0_0x3085('0x19')]=0x4e20;CloudEnabledLifeCycle[a0_0x3085('0x18')]=0x1388;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudEnabledLifeCycle = void 0;
4
+ const utils_1 = require("@nrwl/workspace/src/tasks-runner/utils");
5
+ const path_1 = require("path");
6
+ const app_root_1 = require("@nrwl/workspace/src/utils/app-root");
7
+ const fs_1 = require("fs");
8
+ const path = require("path");
9
+ class CloudEnabledLifeCycle {
10
+ constructor(runContext, cacheDirectory, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
11
+ this.runContext = runContext;
12
+ this.cacheDirectory = cacheDirectory;
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: (0, utils_1.unparse)(overrides).join(' '),
34
+ });
35
+ }
36
+ endTask(task, code) {
37
+ const startedTask = this.tasks.find((t) => t.taskId === task.id);
38
+ if (!startedTask) {
39
+ throw new Error(`Cannot find task ${task.id}`);
40
+ }
41
+ startedTask.endTime = new Date().toISOString();
42
+ startedTask.status = code;
43
+ startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
44
+ if (this.runContext.statuses[task.hash]) {
45
+ startedTask.cacheStatus = this.runContext.statuses[task.hash];
46
+ }
47
+ else {
48
+ if (this.cacheableOperations.indexOf(task.target.target) > -1) {
49
+ startedTask.cacheStatus = 'local-cache-hit';
50
+ }
51
+ else {
52
+ startedTask.cacheStatus = 'cache-miss';
53
+ }
54
+ }
55
+ if (this.collectTerminalOutput) {
56
+ startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
57
+ }
58
+ }
59
+ endCommand() { }
60
+ getTerminalOutput(hash, cacheStatus, code) {
61
+ let dir;
62
+ if (this.cacheDirectory) {
63
+ if (this.cacheDirectory.startsWith('./')) {
64
+ dir = (0, path_1.join)(app_root_1.appRootPath, this.cacheDirectory);
65
+ }
66
+ else {
67
+ dir = this.cacheDirectory;
68
+ }
69
+ }
70
+ else {
71
+ dir = (0, path_1.join)(app_root_1.appRootPath, 'node_modules', '.cache', 'nx');
72
+ }
73
+ try {
74
+ const taskOutput = this.readTerminalOutputFile(dir, hash);
75
+ const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
76
+ const maxCharacters = cacheStatus === 'cache-miss'
77
+ ? code === 0
78
+ ? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
79
+ : CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
80
+ : CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
81
+ return taskOutputSanitized.length > maxCharacters
82
+ ? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
83
+ : taskOutputSanitized;
84
+ }
85
+ catch (e) {
86
+ return '';
87
+ }
88
+ }
89
+ cleanUpHashDetails(hashDetails) {
90
+ const nodes = {};
91
+ Object.keys(hashDetails.nodes)
92
+ .filter((k) => !k.startsWith('npm:'))
93
+ .forEach((k) => {
94
+ nodes[k] = hashDetails.nodes[k];
95
+ });
96
+ return {
97
+ nodes,
98
+ runtime: hashDetails.runtime,
99
+ implicitDeps: hashDetails.implicitDeps,
100
+ };
101
+ }
102
+ readTerminalOutputFile(dir, hash) {
103
+ try {
104
+ return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
105
+ }
106
+ catch (_a) {
107
+ try {
108
+ return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
109
+ }
110
+ catch (_b) {
111
+ return '';
112
+ }
113
+ }
114
+ }
115
+ }
116
+ exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
117
+ CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
118
+ CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
119
+ CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 5000;
120
+ //# sourceMappingURL=cloud-enabled-life-cycle.js.map
@@ -1 +1,167 @@
1
- const a1_0x26c5=['E2EEncryption','map','defineProperty','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run','toISOString','scan','lifeCycle','path','forEach','getMachineInfo','output','catch','__esModule','@nrwl/workspace/src/tasks-runner/tasks-runner-v2','encryptionKey','throw','error','MessageReporter','./cloud-remote-cache','stringify','cacheableOperations','then','note','OutputObfuscator','NUMBER_OF_TRIES','CloudRunApi','../../terminal-output/output-obfuscator','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','@nrwl/workspace/src/utilities/output','rxjs/internal/Subject','assign','@nrwl/workspace/src/tasks-runner/life-cycle','subscribe','../../terminal-output/end-of-run-message','hash','../../file-storage/e2e-encryption','Subject','waitForStoreRequestsToComplete','join','anyErrors','Executed\x20tasks\x20with\x20hashes:\x20','env','printCacheHitsMessage','complete','VERBOSE_LOGGING','./cloud-enabled-life-cycle','all','exit','EndOfRunMessage','extractGitSha','cacheDirectory','writeFileSync','endRun','obfuscate','next','submitRunMetrics','printMessages','__awaiter','value','getRunGroup','apply','cloudEnabledTasksRunner','Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts','ENCRYPTION_KEY','done','../../../utilities/metric-logger','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','requests','CloudEnabledLifeCycle'];(function(_0x6a6ba,_0x26c521){const _0x118602=function(_0x2ed481){while(--_0x2ed481){_0x6a6ba['push'](_0x6a6ba['shift']());}};_0x118602(++_0x26c521);}(a1_0x26c5,0x65));const a1_0x1186=function(_0x6a6ba,_0x26c521){_0x6a6ba=_0x6a6ba-0x0;let _0x118602=a1_0x26c5[_0x6a6ba];return _0x118602;};'use strict';var __awaiter=this&&this[a1_0x1186('0x1b')]||function(_0x446a5f,_0x54aa7c,_0x538118,_0x48a8d4){function _0x44a603(_0x14e6c2){return _0x14e6c2 instanceof _0x538118?_0x14e6c2:new _0x538118(function(_0x1b5d2c){_0x1b5d2c(_0x14e6c2);});}return new(_0x538118||(_0x538118=Promise))(function(_0x2daf0b,_0x269fa9){function _0x5d94e7(_0x292143){try{_0x3a1a5a(_0x48a8d4[a1_0x1186('0x18')](_0x292143));}catch(_0x5456f4){_0x269fa9(_0x5456f4);}}function _0x1c5f8b(_0x391af1){try{_0x3a1a5a(_0x48a8d4[a1_0x1186('0x37')](_0x391af1));}catch(_0x5c5093){_0x269fa9(_0x5c5093);}}function _0x3a1a5a(_0x4c6f99){_0x4c6f99[a1_0x1186('0x22')]?_0x2daf0b(_0x4c6f99[a1_0x1186('0x1c')]):_0x44a603(_0x4c6f99[a1_0x1186('0x1c')])[a1_0x1186('0x3d')](_0x5d94e7,_0x1c5f8b);}_0x3a1a5a((_0x48a8d4=_0x48a8d4[a1_0x1186('0x1e')](_0x446a5f,_0x54aa7c||[]))[a1_0x1186('0x18')]());});};Object[a1_0x1186('0x29')](exports,a1_0x1186('0x34'),{'value':!![]});exports['cloudEnabledTasksRunner']=void 0x0;const Subject_1=require(a1_0x1186('0x45'));const message_reporter_1=require('../../terminal-output/message-reporter');const end_of_run_message_1=require(a1_0x1186('0x3'));const output_obfuscator_1=require(a1_0x1186('0x42'));const cloud_enabled_life_cycle_1=require(a1_0x1186('0xf'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a1_0x1186('0x5'));const environment_1=require('../../../utilities/environment');const cloud_remote_cache_1=require(a1_0x1186('0x3a'));const tasks_runner_v2_1=require(a1_0x1186('0x35'));const output_1=require(a1_0x1186('0x44'));const cloud_run_api_1=require('./cloud-run.api');const fs_1=require('fs');const path=require(a1_0x1186('0x2f'));const metric_logger_1=require(a1_0x1186('0x23'));function createApi(_0x2d20ab,_0x4eb2de,_0x14506d){const _0x7ef242=(0x0,environment_1[a1_0x1186('0x31')])(_0x4eb2de);return new cloud_run_api_1[(a1_0x1186('0x41'))](_0x2d20ab,_0x14506d,_0x4eb2de,_0x7ef242);}function storeTaskHashes(_0x392764,_0x3b42b9,_0x182351){const _0x394252=JSON[a1_0x1186('0x3b')](_0x392764[a1_0x1186('0x28')](_0x5e780b=>({'taskId':_0x5e780b['taskId'],'hash':_0x5e780b[a1_0x1186('0x4')]})));if(environment_1[a1_0x1186('0xe')]){output_1['output'][a1_0x1186('0x3e')]({'title':a1_0x1186('0xa')+_0x394252});}(0x0,fs_1[a1_0x1186('0x15')])(path[a1_0x1186('0x8')](_0x3b42b9,'tasks-hashes-'+_0x182351),_0x394252);}function onComplete(_0x5d8213,_0x56cddc,_0x2467ac,_0x522c4e,_0x4c5d38,_0x50845e,_0x2a7ed6,_0x16fdd1,_0x4911c2,_0x22752a){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4d8eb4=new Date()[a1_0x1186('0x2c')]();if(environment_1[a1_0x1186('0x43')]){storeTaskHashes(_0x4911c2,_0x56cddc[a1_0x1186('0x14')]||'./node_modules/.cache/nx',environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID']);}const _0x30df8b=(0x0,environment_1['getBranch'])();const _0x90cdbd=yield Promise[a1_0x1186('0x10')]([_0x2467ac[a1_0x1186('0x7')](),_0x522c4e[a1_0x1186('0x16')]({'command':_0x4c5d38[a1_0x1186('0x17')]((0x0,environment_1['parseCommand'])()),'startTime':_0x50845e,'endTime':_0x4d8eb4,'distributedExecutionId':environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],'branch':_0x30df8b,'scan':!![],'runGroup':(0x0,environment_1[a1_0x1186('0x1d')])(),'sha':_0x30df8b?(0x0,environment_1[a1_0x1186('0x13')])():undefined},_0x4911c2)]);if(_0x22752a){setTimeout(()=>{_0x2a7ed6['printMessages']();if(!_0x2a7ed6[a1_0x1186('0x9')]){_0x16fdd1[a1_0x1186('0xc')]();}},0x0);}else{_0x2a7ed6['printMessages']();if(!_0x2a7ed6[a1_0x1186('0x9')]){_0x16fdd1[a1_0x1186('0xc')]();}}if(environment_1['AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION']){if(!_0x90cdbd[0x0]){output_1[a1_0x1186('0x32')][a1_0x1186('0x38')]({'title':a1_0x1186('0x20')});_0x2a7ed6[a1_0x1186('0x1a')]();process['exit'](environment_1[a1_0x1186('0x2a')]);}if(!_0x90cdbd[0x1]){output_1['output']['error']({'title':a1_0x1186('0x2b')});_0x2a7ed6[a1_0x1186('0x1a')]();process[a1_0x1186('0x11')](environment_1[a1_0x1186('0x2a')]);}}yield(0x0,metric_logger_1[a1_0x1186('0x19')])(_0x56cddc);});}function createLifeCycle(_0x59a73b,_0x3855d9,_0x13d2e4,_0x16ff31){const _0x3ca9d3=new cloud_enabled_life_cycle_1[(a1_0x1186('0x26'))](_0x59a73b,_0x3855d9[a1_0x1186('0x14')],_0x3855d9[a1_0x1186('0x2d')]===undefined?!![]:_0x3855d9[a1_0x1186('0x2d')],_0x3855d9[a1_0x1186('0x3c')]||[],_0x13d2e4,_0x16ff31);try{const {CompositeLifeCycle}=require(a1_0x1186('0x1'));if(!CompositeLifeCycle)return _0x3ca9d3;return new CompositeLifeCycle([_0x3855d9[a1_0x1186('0x2e')],_0x3ca9d3]);}catch(_0x4cd30c){return _0x3ca9d3;}}function cloudEnabledTasksRunner(_0x26a38e,_0x391c38,_0x62d346){const _0x5b4bb2={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x26a38e};const _0x186da1=_0x391c38['lifeCycle']===undefined;const _0x2ed742=[];const _0x7a0323=new message_reporter_1[(a1_0x1186('0x39'))](_0x391c38);const _0x1a09de=createApi(_0x7a0323,_0x391c38,_0x5b4bb2);const _0x4966d6=new end_of_run_message_1[(a1_0x1186('0x12'))](_0x5b4bb2,_0x2ed742);const _0x3f011c=new output_obfuscator_1[(a1_0x1186('0x3f'))]();const _0x22cd5d=_0x26a38e[a1_0x1186('0x28')](_0x3c36bd=>_0x3c36bd[a1_0x1186('0x4')])['filter'](_0x148849=>!!_0x148849);const _0x3075c8=_0x1a09de['startRun'](environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],_0x22cd5d);_0x22cd5d[a1_0x1186('0x30')](_0x1cc97c=>{_0x5b4bb2[a1_0x1186('0x25')][_0x1cc97c]=_0x3075c8;});const _0x1cc781=new Date()[a1_0x1186('0x2c')]();const _0x1c4b91=createLifeCycle(_0x5b4bb2,_0x391c38,_0x3f011c,_0x2ed742);const _0x3f3fdd=new e2e_encryption_1[(a1_0x1186('0x27'))](environment_1[a1_0x1186('0x21')]||_0x391c38[a1_0x1186('0x36')]);const _0x58e9fa=new file_storage_1['FileStorage'](_0x3f3fdd,environment_1[a1_0x1186('0x40')]);const _0x5500f6=new cloud_remote_cache_1['CloudRemoteCache'](_0x7a0323,_0x1a09de,_0x5b4bb2,_0x58e9fa);delete process[a1_0x1186('0xb')][a1_0x1186('0x24')];const _0xa4d99b=(0x0,tasks_runner_v2_1['tasksRunnerV2'])(_0x26a38e,Object['assign'](Object[a1_0x1186('0x0')]({},_0x391c38),{'remoteCache':_0x5500f6,'lifeCycle':_0x1c4b91}),_0x62d346);if(_0xa4d99b['subscribe']){const _0x24bcdd=new Subject_1[(a1_0x1186('0x6'))]();_0xa4d99b[a1_0x1186('0x2')]({'next':_0x2785b4=>_0x24bcdd[a1_0x1186('0x18')](_0x2785b4),'error':_0x9807e5=>_0x24bcdd[a1_0x1186('0x38')](_0x9807e5),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x1c4b91,_0x391c38,_0x5500f6,_0x1a09de,_0x3f011c,_0x1cc781,_0x7a0323,_0x4966d6,_0x2ed742,_0x186da1);_0x24bcdd[a1_0x1186('0xd')]();})});return _0x24bcdd;}else{return _0xa4d99b[a1_0x1186('0x3d')](_0x4e2aef=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x1c4b91,_0x391c38,_0x5500f6,_0x1a09de,_0x3f011c,_0x1cc781,_0x7a0323,_0x4966d6,_0x2ed742,_0x186da1);return _0x4e2aef;}))[a1_0x1186('0x33')](_0x1c3ad5=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x1c4b91,_0x391c38,_0x5500f6,_0x1a09de,_0x3f011c,_0x1cc781,_0x7a0323,_0x4966d6,_0x2ed742,_0x186da1);throw _0x1c3ad5;}));}}exports[a1_0x1186('0x1f')]=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 tasks_runner_v2_1 = require("@nrwl/workspace/src/tasks-runner/tasks-runner-v2");
23
+ const output_1 = require("@nrwl/workspace/src/utilities/output");
24
+ const cloud_run_api_1 = require("./cloud-run.api");
25
+ const fs_1 = require("fs");
26
+ const path = require("path");
27
+ const metric_logger_1 = require("../../../utilities/metric-logger");
28
+ function createApi(errors, options, runContext) {
29
+ const machineInfo = (0, environment_1.getMachineInfo)(options);
30
+ return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
31
+ }
32
+ function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
33
+ const hashes = JSON.stringify(taskExecutions.map((t) => ({
34
+ taskId: t.taskId,
35
+ hash: t.hash,
36
+ })));
37
+ if (environment_1.VERBOSE_LOGGING) {
38
+ output_1.output.note({
39
+ title: `Executed tasks with hashes: ${hashes}`,
40
+ });
41
+ }
42
+ (0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
43
+ }
44
+ function onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const runEndTime = new Date().toISOString();
47
+ if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
48
+ storeTaskHashes(taskExecutions, options.cacheDirectory || './node_modules/.cache/nx', environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
49
+ }
50
+ const branch = (0, environment_1.getBranch)();
51
+ const endRequest = yield Promise.all([
52
+ remoteCache.waitForStoreRequestsToComplete(),
53
+ api.endRun({
54
+ command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
55
+ startTime: runStartTime,
56
+ endTime: runEndTime,
57
+ distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
58
+ branch: branch,
59
+ scan: true,
60
+ runGroup: (0, environment_1.getRunGroup)(),
61
+ // only set sha if branch is set because we invoke a separate process,
62
+ // which adds a few millis
63
+ sha: branch ? (0, environment_1.extractGitSha)() : undefined,
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) {
73
+ endOfRunMessage.printCacheHitsMessage();
74
+ }
75
+ }, 0);
76
+ }
77
+ else {
78
+ messages.printMessages();
79
+ if (!messages.anyErrors) {
80
+ endOfRunMessage.printCacheHitsMessage();
81
+ }
82
+ }
83
+ if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
84
+ if (!endRequest[0]) {
85
+ output_1.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_1.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.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
104
+ try {
105
+ const { CompositeLifeCycle, } = require('@nrwl/workspace/src/tasks-runner/life-cycle');
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) {
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();
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 fileStorage = new file_storage_1.FileStorage(encryption, environment_1.NUMBER_OF_TRIES);
136
+ const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
137
+ // have to reset it so we don't capture inner tasks
138
+ delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
139
+ const res = (0, tasks_runner_v2_1.tasksRunnerV2)(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
140
+ // observable -> legacy
141
+ if (res.subscribe) {
142
+ const wrappedRes = new Subject_1.Subject();
143
+ res.subscribe({
144
+ next: (value) => wrappedRes.next(value),
145
+ error: (err) => wrappedRes.error(err),
146
+ complete: () => __awaiter(this, void 0, void 0, function* () {
147
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133);
148
+ wrappedRes.complete();
149
+ }),
150
+ });
151
+ return wrappedRes;
152
+ // promise
153
+ }
154
+ else {
155
+ return res
156
+ .then((r) => __awaiter(this, void 0, void 0, function* () {
157
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133);
158
+ return r;
159
+ }))
160
+ .catch((e) => __awaiter(this, void 0, void 0, function* () {
161
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133);
162
+ throw e;
163
+ }));
164
+ }
165
+ }
166
+ exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
167
+ //# sourceMappingURL=cloud-enabled.runner.js.map
@@ -1 +1,113 @@
1
- const a2_0x269e=['__awaiter','cacheError','hash','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','extractErrorMessage','scheduledTasks','map','api','requests','note','store','cache-miss','startRun','throw','remote-cache-hit','get','storeRequests','waitForStoreRequestsToComplete','runContext','apply','forEach','all','messages','VERBOSE_LOGGING','value','Nx\x20Cloud:\x20Cache\x20miss\x20','next','axiosException','output','retrieve','put','statuses','Nx\x20Cloud:\x20Skipping\x20storing\x20','reduce','then','.\x20Read\x20only\x20token\x20is\x20used.','hashUrls','CloudRemoteCache','storage','done','fileStorage','filter','response'];(function(_0x18eaa0,_0x269e34){const _0x57ddd6=function(_0x2402b5){while(--_0x2402b5){_0x18eaa0['push'](_0x18eaa0['shift']());}};_0x57ddd6(++_0x269e34);}(a2_0x269e,0xcc));const a2_0x57dd=function(_0x18eaa0,_0x269e34){_0x18eaa0=_0x18eaa0-0x0;let _0x57ddd6=a2_0x269e[_0x18eaa0];return _0x57ddd6;};'use strict';var __awaiter=this&&this[a2_0x57dd('0xb')]||function(_0x41db82,_0x197e3e,_0x4da9fa,_0x50a033){function _0x1b7304(_0x5be5f3){return _0x5be5f3 instanceof _0x4da9fa?_0x5be5f3:new _0x4da9fa(function(_0x45e6c7){_0x45e6c7(_0x5be5f3);});}return new(_0x4da9fa||(_0x4da9fa=Promise))(function(_0x20b632,_0x2e4935){function _0x450680(_0x4d7fa6){try{_0x3d8d9c(_0x50a033[a2_0x57dd('0x25')](_0x4d7fa6));}catch(_0x1d2531){_0x2e4935(_0x1d2531);}}function _0x5bdf04(_0x509617){try{_0x3d8d9c(_0x50a033[a2_0x57dd('0x18')](_0x509617));}catch(_0x1947ee){_0x2e4935(_0x1947ee);}}function _0x3d8d9c(_0x3da922){_0x3da922[a2_0x57dd('0x7')]?_0x20b632(_0x3da922[a2_0x57dd('0x23')]):_0x1b7304(_0x3da922[a2_0x57dd('0x23')])[a2_0x57dd('0x2')](_0x450680,_0x5bdf04);}_0x3d8d9c((_0x50a033=_0x50a033[a2_0x57dd('0x1e')](_0x41db82,_0x197e3e||[]))[a2_0x57dd('0x25')]());});};Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a2_0x57dd('0x5')]=void 0x0;const output_1=require('@nrwl/workspace/src/utilities/output');const environment_1=require('../../../utilities/environment');class CloudRemoteCache{constructor(_0x34ceab,_0x30d0cb,_0x48347b,_0x50dd8e){this[a2_0x57dd('0x21')]=_0x34ceab;this[a2_0x57dd('0x12')]=_0x30d0cb;this[a2_0x57dd('0x1d')]=_0x48347b;this['fileStorage']=_0x50dd8e;this['storeRequests']=[];}[a2_0x57dd('0x28')](_0x54576d,_0x30cde3){var _0x3fd3ce;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x57dd('0x21')][a2_0x57dd('0xc')])return![];const _0x4d9934=yield this['hashUrls'](_0x54576d);if(!_0x4d9934||!_0x4d9934[a2_0x57dd('0x1a')]){if(environment_1['VERBOSE_LOGGING']){output_1[a2_0x57dd('0x27')][a2_0x57dd('0x14')]({'title':a2_0x57dd('0x24')+_0x54576d+'.'});}this['runContext'][a2_0x57dd('0x2a')][_0x54576d]=a2_0x57dd('0x16');return![];}try{yield this['fileStorage'][a2_0x57dd('0x28')](_0x54576d,_0x4d9934[a2_0x57dd('0x1a')],_0x30cde3);this['runContext'][a2_0x57dd('0x2a')][_0x54576d]=a2_0x57dd('0x19');return!![];}catch(_0x528e5d){const _0x3c423b=(_0x3fd3ce=_0x528e5d[a2_0x57dd('0x26')])!==null&&_0x3fd3ce!==void 0x0?_0x3fd3ce:_0x528e5d;if(_0x3c423b[a2_0x57dd('0xa')]&&_0x3c423b[a2_0x57dd('0xa')]['status']===0x194){if(environment_1[a2_0x57dd('0x22')]){output_1[a2_0x57dd('0x27')]['note']({'title':a2_0x57dd('0x24')+_0x54576d+'.\x20Status\x20404.'});}}else{this[a2_0x57dd('0x21')][a2_0x57dd('0xc')]=this[a2_0x57dd('0x21')][a2_0x57dd('0xf')](_0x3c423b,a2_0x57dd('0x6'));}this[a2_0x57dd('0x1d')][a2_0x57dd('0x2a')][_0x54576d]=a2_0x57dd('0x16');return![];}});}['store'](_0xfabb02,_0x363866){return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a2_0x57dd('0x21')][a2_0x57dd('0xc')])return![];const _0xd02316=Promise['resolve']()[a2_0x57dd('0x2')](()=>__awaiter(this,void 0x0,void 0x0,function*(){var _0x10f9e3;const _0xa9adc1=yield this[a2_0x57dd('0x4')](_0xfabb02);if(!_0xa9adc1)return![];if(!_0xa9adc1['put']){if(environment_1[a2_0x57dd('0x22')]){output_1[a2_0x57dd('0x27')][a2_0x57dd('0x14')]({'title':a2_0x57dd('0x0')+_0xfabb02+a2_0x57dd('0x3')});}return!![];}try{yield this[a2_0x57dd('0x8')][a2_0x57dd('0x15')](_0xfabb02,_0xa9adc1[a2_0x57dd('0x29')],_0x363866);return!![];}catch(_0x15d45b){const _0x45f556=(_0x10f9e3=_0x15d45b['axiosException'])!==null&&_0x10f9e3!==void 0x0?_0x10f9e3:_0x15d45b;this[a2_0x57dd('0x21')]['cacheError']=this['messages'][a2_0x57dd('0xf')](_0x45f556,a2_0x57dd('0x6'));return![];}}));this[a2_0x57dd('0x1b')]['push'](_0xd02316);return _0xd02316;});}[a2_0x57dd('0x4')](_0x42d4b7){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x42d4b7 in this['runContext'][a2_0x57dd('0x13')]){return(yield this[a2_0x57dd('0x1d')]['requests'][_0x42d4b7])[_0x42d4b7];}else{const _0x16f0fc=this[a2_0x57dd('0x1d')][a2_0x57dd('0x10')][a2_0x57dd('0x9')](_0x8695c2=>!this[a2_0x57dd('0x1d')]['requests'][_0x8695c2[a2_0x57dd('0xd')]])[a2_0x57dd('0x11')](_0x4ae666=>_0x4ae666['hash']);if(_0x16f0fc['indexOf'](_0x42d4b7)===-0x1){_0x16f0fc['push'](_0x42d4b7);}const _0x1eac3c=this['api'][a2_0x57dd('0x17')](environment_1[a2_0x57dd('0xe')],_0x16f0fc);_0x16f0fc[a2_0x57dd('0x1f')](_0x57e5d0=>{this[a2_0x57dd('0x1d')][a2_0x57dd('0x13')][_0x57e5d0]=_0x1eac3c;});return(yield _0x1eac3c)[_0x42d4b7];}});}[a2_0x57dd('0x1c')](){return Promise[a2_0x57dd('0x20')](this[a2_0x57dd('0x1b')])[a2_0x57dd('0x2')](_0x262ba1=>_0x262ba1[a2_0x57dd('0x1')]((_0x4537d2,_0x4901f1)=>_0x4537d2&&_0x4901f1,!![]));}}exports[a2_0x57dd('0x5')]=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 output_1 = require("@nrwl/workspace/src/utilities/output");
14
+ const environment_1 = require("../../../utilities/environment");
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_1.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_1.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_1.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