@nrwl/nx-cloud 15.0.0 → 15.0.1-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,220 @@
1
- const a8_0x5e57=['axiosException','completedTasks','VERBOSE_LOGGING','join','startTask','lifeCycle','NO_COMPLETED_TASKS_TIMEOUT','endTask','../../../utilities/create-unchanged-value-timeout','error','strip-json-comments','parse','logCommand','__awaiter','E2EEncryption','SIGINT','projectGraph','start','splitTasksIntoStages','../../../utilities/metric-logger','./node_modules/.cache/nx','taskGraph','number\x20of\x20completed\x20tasks:\x20','configuration','../../error/print-run-group-error','./task-graph-creator','criticalErrorMessage','Error:','nxCloudDistributedTasksRunner','./split-task-graph-into-stages','assign','../../file-storage/file-storage','target','Retrieving\x20artifacts\x20from\x20','log','/nx.json','taskId','submitRunMetrics','Found\x20unknown\x20task:\x20','TaskGraphCreator','Distributed\x20Execution\x20Terminated','../../../utilities/serializer-overrides','executionStatus','DistributedExecutionApi','strictlyOrderedTargets','dependencies','message','next','SIGTERM','cacheDirectory','run','Extracting\x20artifacts','error:\x20','../../api/error-reporter.api','Main\x20job\x20was\x20terminated\x20via\x20SIGINT','Main\x20job\x20terminated\x20with\x20an\x20error:\x20\x22','build','terminalOutput','addVerticalSeparator','Waiting...','tasks','\x20seconds.','serializeOverrides','Main\x20job\x20was\x20terminated\x20via\x20SIGTERM','Status\x20update','executionStatus:\x20','hash','Waiter','length','FileStorage','push','Starting\x20distributed\x20command\x20execution','note','../../file-storage/e2e-encryption','exit','ErrorReporterApi','status','__esModule','url','../../../utilities/nx-imports','completeRunGroupWithError','write','then','runUrl','toString','defineProperty','createUnchangedValueTimeout','targetDependencies','copyFilesFromCache','commandStatus','readFileSync','Unable\x20to\x20complete\x20a\x20run.','values','done','createTaskGraph','value','project','reset','See\x20run\x20details\x20at\x20'];(function(_0x237591,_0x5e5749){const _0x4ed223=function(_0x198487){while(--_0x198487){_0x237591['push'](_0x237591['shift']());}};_0x4ed223(++_0x5e5749);}(a8_0x5e57,0xf9));const a8_0x4ed2=function(_0x237591,_0x5e5749){_0x237591=_0x237591-0x0;let _0x4ed223=a8_0x5e57[_0x237591];return _0x4ed223;};'use strict';var __awaiter=this&&this[a8_0x4ed2('0x3d')]||function(_0x297502,_0x32268d,_0x4e5c4b,_0x4b3c6a){function _0x1ab646(_0x442c76){return _0x442c76 instanceof _0x4e5c4b?_0x442c76:new _0x4e5c4b(function(_0x552549){_0x552549(_0x442c76);});}return new(_0x4e5c4b||(_0x4e5c4b=Promise))(function(_0x545dbe,_0x2d249b){function _0x1f013a(_0x1b3b0e){try{_0x2cca1a(_0x4b3c6a[a8_0x4ed2('0x5f')](_0x1b3b0e));}catch(_0x94c290){_0x2d249b(_0x94c290);}}function _0x3d2048(_0x5660d0){try{_0x2cca1a(_0x4b3c6a['throw'](_0x5660d0));}catch(_0x470705){_0x2d249b(_0x470705);}}function _0x2cca1a(_0x7da951){_0x7da951[a8_0x4ed2('0x2a')]?_0x545dbe(_0x7da951[a8_0x4ed2('0x2c')]):_0x1ab646(_0x7da951[a8_0x4ed2('0x2c')])[a8_0x4ed2('0x1f')](_0x1f013a,_0x3d2048);}_0x2cca1a((_0x4b3c6a=_0x4b3c6a['apply'](_0x297502,_0x32268d||[]))[a8_0x4ed2('0x5f')]());});};Object[a8_0x4ed2('0x22')](exports,a8_0x4ed2('0x1a'),{'value':!![]});exports[a8_0x4ed2('0x4c')]=void 0x0;const fs_1=require('fs');const stripJsonComments=require(a8_0x4ed2('0x3a'));const create_unchanged_value_timeout_1=require(a8_0x4ed2('0x38'));const environment_1=require('../../../utilities/environment');const metric_logger_1=require(a8_0x4ed2('0x43'));const serializer_overrides_1=require(a8_0x4ed2('0x59'));const waiter_1=require('../../../utilities/waiter');const error_reporter_api_1=require(a8_0x4ed2('0x2'));const print_run_group_error_1=require(a8_0x4ed2('0x48'));const e2e_encryption_1=require(a8_0x4ed2('0x16'));const file_storage_1=require(a8_0x4ed2('0x4f'));const distributed_execution_api_1=require('./distributed-execution.api');const split_task_graph_into_stages_1=require(a8_0x4ed2('0x4d'));const task_graph_creator_1=require(a8_0x4ed2('0x49'));const {output,workspaceRoot,getOutputs,Cache}=require(a8_0x4ed2('0x1c'));class NoopLifeCycle{['scheduleTask'](_0x472e94){}[a8_0x4ed2('0x34')](_0x4c0922){}[a8_0x4ed2('0x37')](_0x4983ee,_0x287604){}}function runDistributedExecution(_0x42e452,_0x5f242f,_0x168a49,_0xba81d2,_0x5a2f3a,_0xd55c0d,_0x3fb056){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4fcfcb=yield _0x42e452[a8_0x4ed2('0x41')]((0x0,distributed_execution_api_1['createStartRequest'])(_0xd55c0d,(0x0,split_task_graph_into_stages_1[a8_0x4ed2('0x42')])(_0x3fb056),_0x5f242f));return yield processTasks(_0x42e452,_0xba81d2,_0x5a2f3a,_0x5f242f,_0x4fcfcb,Object[a8_0x4ed2('0x29')](_0x3fb056[a8_0x4ed2('0x9')]),_0x168a49);});}function processTasks(_0xc2c430,_0x100814,_0x23b86b,_0x163afc,_0x5d586b,_0x81601b,_0x1b6633){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x22c463={};const _0xc50002=(0x0,create_unchanged_value_timeout_1[a8_0x4ed2('0x23')])({'title':'No\x20new\x20completed\x20tasks\x20after\x20'+environment_1[a8_0x4ed2('0x36')]/0x3e8+a8_0x4ed2('0xa'),'timeout':environment_1[a8_0x4ed2('0x36')]});const _0x335b5e=new waiter_1[(a8_0x4ed2('0x10'))]();while(!![]){if(environment_1[a8_0x4ed2('0x32')]){output[a8_0x4ed2('0x15')]({'title':a8_0x4ed2('0x8')});}yield _0x335b5e['wait']();const _0x3245e8=yield _0xc2c430[a8_0x4ed2('0x19')](_0x5d586b);if(environment_1['VERBOSE_LOGGING']){output[a8_0x4ed2('0x15')]({'title':a8_0x4ed2('0xd'),'bodyLines':['executionId:\x20'+_0x5d586b,a8_0x4ed2('0xe')+_0x3245e8[a8_0x4ed2('0x5a')],a8_0x4ed2('0x46')+_0x3245e8['completedTasks'][a8_0x4ed2('0x11')],a8_0x4ed2('0x1')+_0x3245e8[a8_0x4ed2('0x4a')]]});}if(_0x3245e8[a8_0x4ed2('0x4a')]){output[a8_0x4ed2('0x39')]({'title':a8_0x4ed2('0x58'),'bodyLines':[a8_0x4ed2('0x4b'),_0x3245e8[a8_0x4ed2('0x4a')]]});process[a8_0x4ed2('0x17')](0x1);}_0xc50002(_0x3245e8[a8_0x4ed2('0x31')][a8_0x4ed2('0x11')]);for(const _0x50d572 of _0x3245e8['completedTasks']){if(_0x22c463[_0x50d572['taskId']])continue;yield processTask(_0x100814,_0x23b86b,_0x1b6633,_0x163afc,_0x81601b,_0x50d572);_0x335b5e[a8_0x4ed2('0x2e')]();_0x22c463[_0x50d572[a8_0x4ed2('0x54')]]=!![];}if(_0x3245e8[a8_0x4ed2('0x5a')]==='COMPLETED'){return{'commandStatus':_0x3245e8[a8_0x4ed2('0x26')],'runUrl':_0x3245e8[a8_0x4ed2('0x20')]};}}});}function processTask(_0x34c3cb,_0x47a1e7,_0x2b3618,_0x4cb9d3,_0x1176f8,_0x4fc6be){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1[a8_0x4ed2('0x32')]){output[a8_0x4ed2('0x15')]({'title':'Processing\x20task\x20'+_0x4fc6be[a8_0x4ed2('0x54')]});}const _0x2f687a=_0x1176f8['find'](_0xd8aab0=>_0x4fc6be[a8_0x4ed2('0x54')]===_0xd8aab0['id']);if(!_0x2f687a){throw new Error(a8_0x4ed2('0x56')+_0x4fc6be[a8_0x4ed2('0x54')]);}if(environment_1[a8_0x4ed2('0x32')]){output[a8_0x4ed2('0x15')]({'title':a8_0x4ed2('0x51')+_0x4fc6be[a8_0x4ed2('0x1b')]});}yield _0x34c3cb['retrieve'](_0x4fc6be[a8_0x4ed2('0xf')],_0x4fc6be[a8_0x4ed2('0x1b')],_0x4cb9d3[a8_0x4ed2('0x61')]||a8_0x4ed2('0x44'));const _0x5d6cab=yield _0x47a1e7['get'](Object['assign'](Object[a8_0x4ed2('0x4e')]({},_0x2f687a),{'hash':_0x4fc6be[a8_0x4ed2('0xf')]}));const _0x115390=getOutputs(_0x2b3618[a8_0x4ed2('0x40')]['nodes'],_0x2f687a);if(environment_1[a8_0x4ed2('0x32')]){output[a8_0x4ed2('0x15')]({'title':a8_0x4ed2('0x0'),'bodyLines':_0x115390});}yield _0x47a1e7[a8_0x4ed2('0x25')](_0x4fc6be['hash'],_0x5d6cab,_0x115390);output[a8_0x4ed2('0x3c')](getCommand(_0x2f687a));process['stdout'][a8_0x4ed2('0x1e')](_0x5d6cab[a8_0x4ed2('0x6')]);output[a8_0x4ed2('0x7')]();});}function getCommand(_0x56889d){const _0x468903=_0x56889d['target'][a8_0x4ed2('0x47')]?':'+_0x56889d[a8_0x4ed2('0x50')][a8_0x4ed2('0x47')]:'';return['nx',a8_0x4ed2('0x62'),_0x56889d[a8_0x4ed2('0x50')][a8_0x4ed2('0x2d')]+':'+_0x56889d[a8_0x4ed2('0x50')][a8_0x4ed2('0x50')]+_0x468903,(0x0,serializer_overrides_1[a8_0x4ed2('0xb')])(_0x56889d)][a8_0x4ed2('0x33')]('\x20');}function attachSignalListenersToCompleteRunGroupOnError(_0x8060d9,_0x19d2ae){process['on'](a8_0x4ed2('0x3f'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x8060d9[a8_0x4ed2('0x1d')](_0x19d2ae,a8_0x4ed2('0x3'));process[a8_0x4ed2('0x17')](0x1);}));process['on'](a8_0x4ed2('0x60'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x8060d9[a8_0x4ed2('0x1d')](_0x19d2ae,a8_0x4ed2('0xc'));process['exit'](0x1);}));}const nxCloudDistributedTasksRunner=(_0x33aac0,_0x45ba22,_0x5a9563)=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){if(environment_1['VERBOSE_LOGGING']){output[a8_0x4ed2('0x15')]({'title':a8_0x4ed2('0x14')});}_0x45ba22[a8_0x4ed2('0x35')]=new NoopLifeCycle();const _0x1b2ba9=(0x0,environment_1['getRunGroup'])();if(!_0x1b2ba9){(0x0,print_run_group_error_1['printRunGroupError'])();return process[a8_0x4ed2('0x17')](0x1);}const _0x4ce73f=new e2e_encryption_1[(a8_0x4ed2('0x3e'))](environment_1['ENCRYPTION_KEY']||_0x45ba22['encryptionKey']);const _0x4b7f4e=new error_reporter_api_1[(a8_0x4ed2('0x18'))](_0x45ba22);const _0x5774b5=new file_storage_1[(a8_0x4ed2('0x12'))](_0x4ce73f,_0x4b7f4e,!![],![]);const _0x1f75e5=new Cache(_0x45ba22);const _0x4f3a96=new distributed_execution_api_1[(a8_0x4ed2('0x5b'))](_0x45ba22);attachSignalListenersToCompleteRunGroupOnError(_0x4f3a96,_0x1b2ba9);try{const _0x566d4d=getTaskGraph(_0x5a9563,_0x33aac0,_0x45ba22);const _0xd8bfed=yield runDistributedExecution(_0x4f3a96,_0x45ba22,_0x5a9563,_0x5774b5,_0x1f75e5,_0x1b2ba9,_0x566d4d);if(_0xd8bfed['commandStatus']===0x0){output['success']({'title':'Successfully\x20completed\x20running\x20the\x20command.','bodyLines':['See\x20run\x20details\x20at\x20'+_0xd8bfed[a8_0x4ed2('0x20')]]});}else{output[a8_0x4ed2('0x39')]({'title':'Command\x20execution\x20failed.','bodyLines':[a8_0x4ed2('0x2f')+_0xd8bfed[a8_0x4ed2('0x20')]]});}yield(0x0,metric_logger_1[a8_0x4ed2('0x55')])(_0x45ba22);process[a8_0x4ed2('0x17')](_0xd8bfed[a8_0x4ed2('0x26')]);}catch(_0x1bb31e){output['error']({'title':a8_0x4ed2('0x28'),'bodyLines':[_0x1bb31e['message']]});if(_0x1bb31e[a8_0x4ed2('0x30')]){console[a8_0x4ed2('0x52')](_0x1bb31e['axiosException']);}else{console[a8_0x4ed2('0x52')](_0x1bb31e);}try{yield _0x4f3a96[a8_0x4ed2('0x1d')](_0x1b2ba9,a8_0x4ed2('0x4')+_0x1bb31e[a8_0x4ed2('0x5e')]+'\x22');}finally{process[a8_0x4ed2('0x17')](0x1);}}});exports['nxCloudDistributedTasksRunner']=nxCloudDistributedTasksRunner;function getTaskGraph(_0x5339a2,_0x30b998,_0x170db1){if(_0x5339a2[a8_0x4ed2('0x45')]){return _0x5339a2[a8_0x4ed2('0x45')];}else{const _0x57fdb1=JSON[a8_0x4ed2('0x3b')](stripJsonComments((0x0,fs_1[a8_0x4ed2('0x27')])(workspaceRoot+a8_0x4ed2('0x53'))[a8_0x4ed2('0x21')]()));return new task_graph_creator_1[(a8_0x4ed2('0x57'))](_0x5339a2['projectGraph'],getDefaultDependencyConfigs(_0x57fdb1,_0x170db1))[a8_0x4ed2('0x2b')](_0x30b998);}}function getDefaultDependencyConfigs(_0x1cd7d6,_0x5ec2a2){var _0x26d7bb,_0x41da28;const _0x2d339f=(_0x26d7bb=_0x1cd7d6[a8_0x4ed2('0x24')])!==null&&_0x26d7bb!==void 0x0?_0x26d7bb:{};const _0x28eac2=_0x5ec2a2?(_0x41da28=_0x5ec2a2[a8_0x4ed2('0x5c')])!==null&&_0x41da28!==void 0x0?_0x41da28:[a8_0x4ed2('0x5')]:[];for(const _0xe321a6 of _0x28eac2){_0x2d339f[_0xe321a6]=_0x2d339f[_0xe321a6]||[];_0x2d339f[_0xe321a6][a8_0x4ed2('0x13')]({'target':_0xe321a6,'projects':a8_0x4ed2('0x5d')});}return _0x2d339f;}
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.nxCloudDistributedTasksRunner = void 0;
13
+ const fs_1 = require("fs");
14
+ const stripJsonComments = require("strip-json-comments");
15
+ const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
16
+ const environment_1 = require("../../../utilities/environment");
17
+ const metric_logger_1 = require("../../../utilities/metric-logger");
18
+ const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
19
+ const waiter_1 = require("../../../utilities/waiter");
20
+ const error_reporter_api_1 = require("../../api/error-reporter.api");
21
+ const print_run_group_error_1 = require("../../error/print-run-group-error");
22
+ const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
23
+ const file_storage_1 = require("../../file-storage/file-storage");
24
+ const distributed_execution_api_1 = require("./distributed-execution.api");
25
+ const split_task_graph_into_stages_1 = require("./split-task-graph-into-stages");
26
+ const task_graph_creator_1 = require("./task-graph-creator");
27
+ const { output, workspaceRoot, getOutputs, Cache, } = require('../../../utilities/nx-imports');
28
+ class NoopLifeCycle {
29
+ scheduleTask(task) { }
30
+ startTask(task) { }
31
+ endTask(task, code) { }
32
+ }
33
+ function runDistributedExecution(api, options, context, fileStorage, cache, runGroup, taskGraph) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const id = yield api.start((0, distributed_execution_api_1.createStartRequest)(runGroup, (0, split_task_graph_into_stages_1.splitTasksIntoStages)(taskGraph), options));
36
+ return yield processTasks(api, fileStorage, cache, options, id, Object.values(taskGraph.tasks), context);
37
+ });
38
+ }
39
+ function processTasks(api, fileStorage, cache, options, executionId, tasks, context) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const processedTasks = {};
42
+ const failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
43
+ title: `No new completed tasks after ${environment_1.NO_COMPLETED_TASKS_TIMEOUT / 1000} seconds.`,
44
+ timeout: environment_1.NO_COMPLETED_TASKS_TIMEOUT,
45
+ });
46
+ const waiter = new waiter_1.Waiter();
47
+ while (true) {
48
+ if (environment_1.VERBOSE_LOGGING) {
49
+ output.note({
50
+ title: 'Waiting...',
51
+ });
52
+ }
53
+ yield waiter.wait();
54
+ const r = yield api.status(executionId);
55
+ if (environment_1.VERBOSE_LOGGING) {
56
+ output.note({
57
+ title: `Status update`,
58
+ bodyLines: [
59
+ `executionId: ${executionId}`,
60
+ `executionStatus: ${r.executionStatus}`,
61
+ `number of completed tasks: ${r.completedTasks.length}`,
62
+ `error: ${r.criticalErrorMessage}`,
63
+ ],
64
+ });
65
+ }
66
+ if (r.criticalErrorMessage) {
67
+ output.error({
68
+ title: 'Distributed Execution Terminated',
69
+ bodyLines: ['Error:', r.criticalErrorMessage],
70
+ });
71
+ process.exit(1);
72
+ }
73
+ failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout(r.completedTasks.length);
74
+ for (const t of r.completedTasks) {
75
+ if (processedTasks[t.taskId])
76
+ continue;
77
+ yield processTask(fileStorage, cache, context, options, tasks, t);
78
+ waiter.reset();
79
+ processedTasks[t.taskId] = true;
80
+ }
81
+ if (r.executionStatus === 'COMPLETED') {
82
+ return { commandStatus: r.commandStatus, runUrl: r.runUrl };
83
+ }
84
+ }
85
+ });
86
+ }
87
+ function processTask(fileStorage, cache, context, options, tasks, completedTask) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ if (environment_1.VERBOSE_LOGGING) {
90
+ output.note({
91
+ title: `Processing task ${completedTask.taskId}`,
92
+ });
93
+ }
94
+ const matchingTask = tasks.find((tt) => completedTask.taskId === tt.id);
95
+ if (!matchingTask) {
96
+ throw new Error(`Found unknown task: ${completedTask.taskId}`);
97
+ }
98
+ if (environment_1.VERBOSE_LOGGING) {
99
+ output.note({
100
+ title: `Retrieving artifacts from ${completedTask.url}`,
101
+ });
102
+ }
103
+ yield fileStorage.retrieve(completedTask.hash, completedTask.url, options.cacheDirectory || './node_modules/.cache/nx');
104
+ const cachedResult = yield cache.get(Object.assign(Object.assign({}, matchingTask), { hash: completedTask.hash }));
105
+ const outputs = getOutputs(context.projectGraph.nodes, matchingTask);
106
+ if (environment_1.VERBOSE_LOGGING) {
107
+ output.note({
108
+ title: `Extracting artifacts`,
109
+ bodyLines: outputs,
110
+ });
111
+ }
112
+ yield cache.copyFilesFromCache(completedTask.hash, cachedResult, outputs);
113
+ output.logCommand(getCommand(matchingTask));
114
+ process.stdout.write(cachedResult.terminalOutput);
115
+ output.addVerticalSeparator();
116
+ });
117
+ }
118
+ function getCommand(task) {
119
+ const config = task.target.configuration
120
+ ? `:${task.target.configuration}`
121
+ : '';
122
+ return [
123
+ 'nx',
124
+ 'run',
125
+ `${task.target.project}:${task.target.target}${config}`,
126
+ (0, serializer_overrides_1.serializeOverrides)(task),
127
+ ].join(' ');
128
+ }
129
+ function attachSignalListenersToCompleteRunGroupOnError(api, runGroup) {
130
+ process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
131
+ yield api.completeRunGroupWithError(runGroup, 'Main job was terminated via SIGINT');
132
+ process.exit(1);
133
+ }));
134
+ process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
135
+ yield api.completeRunGroupWithError(runGroup, 'Main job was terminated via SIGTERM');
136
+ process.exit(1);
137
+ }));
138
+ }
139
+ const nxCloudDistributedTasksRunner = (tasks, options, context) => __awaiter(void 0, void 0, void 0, function* () {
140
+ if (environment_1.VERBOSE_LOGGING) {
141
+ output.note({
142
+ title: 'Starting distributed command execution',
143
+ });
144
+ }
145
+ options.lifeCycle = new NoopLifeCycle();
146
+ const runGroup = (0, environment_1.getRunGroup)();
147
+ if (!runGroup) {
148
+ (0, print_run_group_error_1.printRunGroupError)();
149
+ return process.exit(1);
150
+ }
151
+ const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
152
+ const errorReporter = new error_reporter_api_1.ErrorReporterApi(options);
153
+ const fileStorage = new file_storage_1.FileStorage(encryption, errorReporter, true, false);
154
+ const cache = new Cache(options);
155
+ const api = new distributed_execution_api_1.DistributedExecutionApi(options);
156
+ attachSignalListenersToCompleteRunGroupOnError(api, runGroup);
157
+ try {
158
+ const taskGraph = getTaskGraph(context, tasks, options);
159
+ const r = yield runDistributedExecution(api, options, context, fileStorage, cache, runGroup, taskGraph);
160
+ if (r.commandStatus === 0) {
161
+ output.success({
162
+ title: 'Successfully completed running the command.',
163
+ bodyLines: [`See run details at ${r.runUrl}`],
164
+ });
165
+ }
166
+ else {
167
+ output.error({
168
+ title: 'Command execution failed.',
169
+ bodyLines: [`See run details at ${r.runUrl}`],
170
+ });
171
+ }
172
+ yield (0, metric_logger_1.submitRunMetrics)(options);
173
+ process.exit(r.commandStatus);
174
+ }
175
+ catch (e) {
176
+ output.error({
177
+ title: 'Unable to complete a run.',
178
+ bodyLines: [e.message],
179
+ });
180
+ if (e.axiosException) {
181
+ console.log(e.axiosException);
182
+ }
183
+ else {
184
+ console.log(e);
185
+ }
186
+ try {
187
+ yield api.completeRunGroupWithError(runGroup, `Main job terminated with an error: "${e.message}"`);
188
+ }
189
+ finally {
190
+ process.exit(1);
191
+ }
192
+ }
193
+ });
194
+ exports.nxCloudDistributedTasksRunner = nxCloudDistributedTasksRunner;
195
+ function getTaskGraph(context, tasks, options) {
196
+ if (context.taskGraph) {
197
+ return context.taskGraph;
198
+ }
199
+ else {
200
+ const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString()));
201
+ return new task_graph_creator_1.TaskGraphCreator(context.projectGraph, getDefaultDependencyConfigs(nxjson, options)).createTaskGraph(tasks);
202
+ }
203
+ }
204
+ function getDefaultDependencyConfigs(nxJson, runnerOptions) {
205
+ var _a, _b;
206
+ const defaults = (_a = nxJson.targetDependencies) !== null && _a !== void 0 ? _a : {};
207
+ const strictlyOrderedTargets = runnerOptions
208
+ ? (_b = runnerOptions.strictlyOrderedTargets) !== null && _b !== void 0 ? _b : ['build']
209
+ : [];
210
+ // Strictly Ordered Targets depend on their dependencies
211
+ for (const target of strictlyOrderedTargets) {
212
+ defaults[target] = defaults[target] || [];
213
+ defaults[target].push({
214
+ target,
215
+ projects: 'dependencies',
216
+ });
217
+ }
218
+ return defaults;
219
+ }
220
+ //# sourceMappingURL=distributed-execution.runner.js.map
@@ -1 +1,37 @@
1
- const a9_0x3db2=['defineProperty','push','splitTasksIntoStages','size','__esModule','dependencies','values','map','delete','has','tasks'];(function(_0x518ce1,_0x3db21e){const _0x3416ce=function(_0x3a3575){while(--_0x3a3575){_0x518ce1['push'](_0x518ce1['shift']());}};_0x3416ce(++_0x3db21e);}(a9_0x3db2,0x1ba));const a9_0x3416=function(_0x518ce1,_0x3db21e){_0x518ce1=_0x518ce1-0x0;let _0x3416ce=a9_0x3db2[_0x518ce1];return _0x3416ce;};'use strict';Object[a9_0x3416('0x9')](exports,a9_0x3416('0x2'),{'value':!![]});exports['splitTasksIntoStages']=void 0x0;function splitTasksIntoStages(_0x297ae5){const _0x811e37=[];const _0x415a4e=new Set(Object[a9_0x3416('0x4')](_0x297ae5[a9_0x3416('0x8')])[a9_0x3416('0x5')](_0x5627a2=>_0x5627a2['id']));let _0x466df7=0x0;while(_0x415a4e[a9_0x3416('0x1')]>0x0){const _0x481fe6=_0x811e37[_0x466df7]=[];for(const _0x401d05 of _0x415a4e){let _0x1b10fd=!![];for(const _0x2fbe71 of _0x297ae5[a9_0x3416('0x3')][_0x401d05]){if(_0x415a4e[a9_0x3416('0x7')](_0x2fbe71)){_0x1b10fd=![];break;}}if(!_0x1b10fd){continue;}const _0x349147=_0x297ae5[a9_0x3416('0x8')][_0x401d05];_0x481fe6[a9_0x3416('0xa')](_0x349147);}for(const _0x2e7f2b of _0x481fe6){_0x415a4e[a9_0x3416('0x6')](_0x2e7f2b['id']);}_0x466df7++;}return _0x811e37;}exports[a9_0x3416('0x0')]=splitTasksIntoStages;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitTasksIntoStages = void 0;
4
+ function splitTasksIntoStages(taskGraph) {
5
+ const stages = [];
6
+ const notStagedTaskIds = new Set(Object.values(taskGraph.tasks).map((t) => t.id));
7
+ let stageIndex = 0;
8
+ // Loop through tasks and try to stage them. As tasks are staged, they are removed from the loop
9
+ while (notStagedTaskIds.size > 0) {
10
+ const currentStage = (stages[stageIndex] = []);
11
+ for (const taskId of notStagedTaskIds) {
12
+ let ready = true;
13
+ for (const dependency of taskGraph.dependencies[taskId]) {
14
+ if (notStagedTaskIds.has(dependency)) {
15
+ // dependency has not been staged yet, this task is not ready to be staged.
16
+ ready = false;
17
+ break;
18
+ }
19
+ }
20
+ // Some dependency still has not been staged, skip it for now, it will be processed again
21
+ if (!ready) {
22
+ continue;
23
+ }
24
+ // All the dependencies have been staged, let's stage it.
25
+ const task = taskGraph.tasks[taskId];
26
+ currentStage.push(task);
27
+ }
28
+ // Remove the entire new stage of tasks from the list
29
+ for (const task of currentStage) {
30
+ notStagedTaskIds.delete(task.id);
31
+ }
32
+ stageIndex++;
33
+ }
34
+ return stages;
35
+ }
36
+ exports.splitTasksIntoStages = splitTasksIntoStages;
37
+ //# sourceMappingURL=split-task-graph-into-stages.js.map
@@ -1 +1,77 @@
1
- const a10_0x2ffd=['self','roots','length','project','indexOf','dependencies','TaskGraphCreator','tasks','findTask','target','createTaskGraph','addTaskToGraph','projectGraph','find','add','push','addTaskDependencies','keys','addDependencies','defaultTargetDependencies','filter','map','projects'];(function(_0x3e5cdb,_0x2ffdd9){const _0x23de54=function(_0x512c9b){while(--_0x512c9b){_0x3e5cdb['push'](_0x3e5cdb['shift']());}};_0x23de54(++_0x2ffdd9);}(a10_0x2ffd,0x16a));const a10_0x23de=function(_0x3e5cdb,_0x2ffdd9){_0x3e5cdb=_0x3e5cdb-0x0;let _0x23de54=a10_0x2ffd[_0x3e5cdb];return _0x23de54;};'use strict';Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a10_0x23de('0xc')]=void 0x0;const {getDependencyConfigs}=require('../../../utilities/nx-imports');class TaskGraphCreator{constructor(_0x591b23,_0x4b68e1){this[a10_0x23de('0x12')]=_0x591b23;this[a10_0x23de('0x2')]=_0x4b68e1;}[a10_0x23de('0x10')](_0x192b31){const _0x399f18={'roots':[],'tasks':{},'dependencies':{}};for(const _0x10da18 of _0x192b31){this[a10_0x23de('0x11')](_0x10da18,_0x399f18);const _0x425365=getDependencyConfigs(_0x10da18['target'],this[a10_0x23de('0x2')],this[a10_0x23de('0x12')]);if(!_0x425365){continue;}this[a10_0x23de('0x16')](_0x10da18,_0x425365,_0x192b31,_0x399f18);}_0x399f18[a10_0x23de('0x7')]=Object[a10_0x23de('0x0')](_0x399f18[a10_0x23de('0xb')])[a10_0x23de('0x3')](_0x52df03=>_0x399f18['dependencies'][_0x52df03][a10_0x23de('0x8')]===0x0);return _0x399f18;}[a10_0x23de('0x16')](_0x56c5a9,_0x18ce2a,_0x4df5f9,_0x1d4ce8){for(const _0x62aadd of _0x18ce2a){if(_0x62aadd[a10_0x23de('0x5')]===a10_0x23de('0x6')){for(const _0x13979a of _0x4df5f9){if(_0x13979a[a10_0x23de('0xf')]['project']===_0x56c5a9[a10_0x23de('0xf')][a10_0x23de('0x9')]&&_0x13979a[a10_0x23de('0xf')][a10_0x23de('0xf')]===_0x62aadd[a10_0x23de('0xf')]){_0x1d4ce8[a10_0x23de('0xb')][_0x56c5a9['id']][a10_0x23de('0x15')](_0x13979a['id']);}}}else if(_0x62aadd[a10_0x23de('0x5')]===a10_0x23de('0xb')){const _0x136231=new Set();this[a10_0x23de('0x1')](_0x56c5a9[a10_0x23de('0xf')]['project'],_0x62aadd[a10_0x23de('0xf')],_0x4df5f9,_0x1d4ce8,_0x56c5a9['id'],_0x136231);}}}[a10_0x23de('0x1')](_0x1bfb79,_0x176b96,_0x24b6dd,_0x405441,_0x184f94,_0x19814b){_0x19814b[a10_0x23de('0x14')](_0x1bfb79);const _0xacb887=this[a10_0x23de('0x12')][a10_0x23de('0xb')][_0x1bfb79];if(_0xacb887){const _0x39c2c3=_0xacb887[a10_0x23de('0x4')](_0x5090bc=>_0x5090bc['target']);for(const _0x38c382 of _0x39c2c3){if(_0x19814b['has'](_0x38c382)){continue;}const _0x2e3e18=this['findTask']({'project':_0x38c382,'target':_0x176b96},_0x24b6dd);if(_0x2e3e18){if(_0x405441[a10_0x23de('0xb')][_0x184f94][a10_0x23de('0xa')](_0x2e3e18['id'])===-0x1){_0x405441['dependencies'][_0x184f94][a10_0x23de('0x15')](_0x2e3e18['id']);}}else{this[a10_0x23de('0x1')](_0x38c382,_0x176b96,_0x24b6dd,_0x405441,_0x184f94,_0x19814b);}}}}[a10_0x23de('0xe')]({project,target},_0x4bd4d2){return _0x4bd4d2[a10_0x23de('0x13')](_0x1cef45=>_0x1cef45[a10_0x23de('0xf')][a10_0x23de('0x9')]===project&&_0x1cef45['target'][a10_0x23de('0xf')]===target);}[a10_0x23de('0x11')](_0x492bd6,_0x2c271f){_0x2c271f[a10_0x23de('0xd')][_0x492bd6['id']]=_0x492bd6;_0x2c271f[a10_0x23de('0xb')][_0x492bd6['id']]=[];}}exports[a10_0x23de('0xc')]=TaskGraphCreator;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaskGraphCreator = void 0;
4
+ const { getDependencyConfigs } = require('../../../utilities/nx-imports');
5
+ /**
6
+ * This is only used for versions of Nx prior to 14 where the task graph
7
+ * wasn't part of the context so we have to recreate it
8
+ */
9
+ class TaskGraphCreator {
10
+ constructor(projectGraph, defaultTargetDependencies) {
11
+ this.projectGraph = projectGraph;
12
+ this.defaultTargetDependencies = defaultTargetDependencies;
13
+ }
14
+ createTaskGraph(tasks) {
15
+ const graph = {
16
+ roots: [],
17
+ tasks: {},
18
+ dependencies: {},
19
+ };
20
+ for (const task of tasks) {
21
+ this.addTaskToGraph(task, graph);
22
+ const dependencyConfigs = getDependencyConfigs(task.target, this.defaultTargetDependencies, this.projectGraph);
23
+ if (!dependencyConfigs) {
24
+ continue;
25
+ }
26
+ this.addTaskDependencies(task, dependencyConfigs, tasks, graph);
27
+ }
28
+ graph.roots = Object.keys(graph.dependencies).filter((k) => graph.dependencies[k].length === 0);
29
+ return graph;
30
+ }
31
+ addTaskDependencies(task, dependencyConfigs, tasks, graph) {
32
+ for (const dependencyConfig of dependencyConfigs) {
33
+ if (dependencyConfig.projects === 'self') {
34
+ for (const t of tasks) {
35
+ if (t.target.project === task.target.project &&
36
+ t.target.target === dependencyConfig.target) {
37
+ graph.dependencies[task.id].push(t.id);
38
+ }
39
+ }
40
+ }
41
+ else if (dependencyConfig.projects === 'dependencies') {
42
+ const seen = new Set();
43
+ this.addDependencies(task.target.project, dependencyConfig.target, tasks, graph, task.id, seen);
44
+ }
45
+ }
46
+ }
47
+ addDependencies(project, target, tasks, graph, taskId, seen) {
48
+ seen.add(project);
49
+ const dependencies = this.projectGraph.dependencies[project];
50
+ if (dependencies) {
51
+ const projectDependencies = dependencies.map((dependency) => dependency.target);
52
+ for (const projectDependency of projectDependencies) {
53
+ if (seen.has(projectDependency)) {
54
+ continue;
55
+ }
56
+ const dependency = this.findTask({ project: projectDependency, target }, tasks);
57
+ if (dependency) {
58
+ if (graph.dependencies[taskId].indexOf(dependency.id) === -1) {
59
+ graph.dependencies[taskId].push(dependency.id);
60
+ }
61
+ }
62
+ else {
63
+ this.addDependencies(projectDependency, target, tasks, graph, taskId, seen);
64
+ }
65
+ }
66
+ }
67
+ }
68
+ findTask({ project, target }, tasks) {
69
+ return tasks.find((t) => t.target.project === project && t.target.target === target);
70
+ }
71
+ addTaskToGraph(task, graph) {
72
+ graph.tasks[task.id] = task;
73
+ graph.dependencies[task.id] = [];
74
+ }
75
+ }
76
+ exports.TaskGraphCreator = TaskGraphCreator;
77
+ //# sourceMappingURL=task-graph-creator.js.map
@@ -11,20 +11,28 @@ class EndOfRunMessage {
11
11
  printCacheHitsMessage() {
12
12
  if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION)
13
13
  return;
14
+ if (!this.runContext.runUrl) {
15
+ return;
16
+ }
17
+ const anyErrors = !!this.taskExecutions.find((te) => te.status !== 0);
18
+ const anyCacheMisses = !!this.taskExecutions.find((te) => te.cacheStatus === 'cache-miss');
14
19
  const hits = this.taskExecutions
15
20
  .filter((t) => this.runContext.statuses[t.hash] === 'remote-cache-hit')
16
21
  .map((t) => t.projectName);
17
- if (hits.length === 0 && !this.runContext.runUrl) {
18
- return;
19
- }
20
- const tasks = hits.length === 1 ? hits[0] : `${hits.length} tasks`;
21
22
  const message = [];
22
- if (hits.length > 0) {
23
- message.push(`Nx Cloud made it possible to reuse ${tasks}${this.runContext.runUrl ? `: ${this.runContext.runUrl}` : ''}`);
23
+ if (anyErrors) {
24
+ message.push(`See searchable error logs at ${this.runContext.runUrl}`);
25
+ }
26
+ else if (anyCacheMisses) {
27
+ message.push(`See logs and investigate cache misses at ${this.runContext.runUrl}`);
28
+ }
29
+ else if (hits.length > 0) {
30
+ const tasks = hits.length === 1 ? hits[0] : `${hits.length} tasks`;
31
+ message.push(`Nx Cloud made it possible to reuse ${tasks}: ${this.runContext.runUrl}`);
24
32
  }
25
33
  else {
26
34
  if (this.runContext.runUrl) {
27
- message.push(`See Nx Cloud run details at ${this.runContext.runUrl}`);
35
+ message.push(`See logs and run details at ${this.runContext.runUrl}`);
28
36
  }
29
37
  }
30
38
  if (message.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"end-of-run-message.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/terminal-output/end-of-run-message.ts"],"names":[],"mappings":";;;AAEA,6DAAqF;AACrF,iEAA6D;AAE7D,MAAa,eAAe;IAC1B,YACmB,UAAsB,EACtB,cAA+B;QAD/B,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAiB;IAC/C,CAAC;IAEJ,qBAAqB;QACnB,IAAI,oDAAsC;YAAE,OAAO;QAEnD,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc;aAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,kBAAkB,CAAC;aACtE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAE7B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAChD,OAAO;SACR;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,QAAQ,CAAC;QACnE,MAAM,OAAO,GAAG,EAAW,CAAC;QAC5B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,OAAO,CAAC,IAAI,CACV,sCAAsC,KAAK,GACzC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAC3D,EAAE,CACH,CAAC;SACH;aAAM;YACL,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;gBAC1B,OAAO,CAAC,IAAI,CAAC,+BAA+B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;aACvE;SACF;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,IAAA,4BAAY,EAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SACjC;IACH,CAAC;CACF;AAlCD,0CAkCC"}
1
+ {"version":3,"file":"end-of-run-message.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/terminal-output/end-of-run-message.ts"],"names":[],"mappings":";;;AAEA,6DAAqF;AACrF,iEAA6D;AAE7D,MAAa,eAAe;IAC1B,YACmB,UAAsB,EACtB,cAA+B;QAD/B,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAiB;IAC/C,CAAC;IAEJ,qBAAqB;QACnB,IAAI,oDAAsC;YAAE,OAAO;QAEnD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAC3B,OAAO;SACR;QAED,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;QACtE,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAC/C,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,KAAK,YAAY,CACxC,CAAC;QAEF,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc;aAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,kBAAkB,CAAC;aACtE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAE7B,MAAM,OAAO,GAAG,EAAW,CAAC;QAC5B,IAAI,SAAS,EAAE;YACb,OAAO,CAAC,IAAI,CAAC,gCAAgC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;SACxE;aAAM,IAAI,cAAc,EAAE;YACzB,OAAO,CAAC,IAAI,CACV,4CAA4C,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CACrE,CAAC;SACH;aAAM,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,QAAQ,CAAC;YACnE,OAAO,CAAC,IAAI,CACV,sCAAsC,KAAK,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CACzE,CAAC;SACH;aAAM;YACL,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;gBAC1B,OAAO,CAAC,IAAI,CAAC,+BAA+B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;aACvE;SACF;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,IAAA,4BAAY,EAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SACjC;IACH,CAAC;CACF;AA3CD,0CA2CC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nrwl/nx-cloud",
3
- "version": "15.0.0",
3
+ "version": "15.0.1-beta.1",
4
4
  "description": "Nx Cloud plugin for Nx",
5
5
  "keywords": [
6
6
  "Monorepo",