@nrwl/nx-cloud 15.3.2 → 15.3.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/lib/core/api/error-reporter.api.js +36 -1
  2. package/lib/core/api/run-group.api.js +73 -1
  3. package/lib/core/commands/upload-and-show-run-details.js +2 -1
  4. package/lib/core/commands/upload-and-show-run-details.js.map +1 -1
  5. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +93 -1
  6. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +320 -1
  7. package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +133 -1
  8. package/lib/core/runners/cloud-enabled/cloud-run.api.js +168 -1
  9. package/lib/core/runners/cloud-enabled/id-generator.js +16 -1
  10. package/lib/core/runners/distributed-agent/distributed-agent.api.js +93 -1
  11. package/lib/core/runners/distributed-agent/distributed-agent.impl.js +157 -1
  12. package/lib/core/runners/distributed-agent/execute-tasks.js +114 -1
  13. package/lib/core/runners/distributed-agent/invoke-tasks-using-nx-imperative-api.js +58 -1
  14. package/lib/core/runners/distributed-agent/invoke-tasks-using-run-many.js +97 -1
  15. package/lib/core/runners/distributed-execution/distributed-execution.api.js +152 -1
  16. package/lib/core/runners/distributed-execution/distributed-execution.runner.js +118 -1
  17. package/lib/core/runners/distributed-execution/process-task.js +45 -1
  18. package/lib/core/runners/distributed-execution/process-tasks.js +67 -1
  19. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -1
  20. package/lib/core/runners/distributed-execution/task-graph-creator.js +100 -1
  21. package/lib/utilities/environment.js +8 -2
  22. package/lib/utilities/environment.js.map +1 -1
  23. package/lib/utilities/is-private-cloud.d.ts +1 -0
  24. package/lib/utilities/is-private-cloud.js +30 -0
  25. package/lib/utilities/is-private-cloud.js.map +1 -0
  26. package/package.json +1 -1
@@ -1 +1,157 @@
1
- const a6_0x56b9=['E2EEncryption','writeFileSync','ENCRYPTION_KEY','includes','exit','tasksRunnerOptions','../../../utilities/environment','trim','strip-json-comments','Other\x20Nx\x20Cloud\x20Agents\x20Detected','./execute-tasks','readFileSync','default','CIRCLE_JOB','catch','@nrwl/nx-cloud','executeTasks','targets','filter','unlinkSync','floor','DteArtifactStorage','./invoke-tasks-using-nx-imperative-api','random','then','ErrorReporterApi','env','getRunGroup','readdirSync','CIRCLE_STAGE','cacheableOperations','./distributed-agent.api','length','options','getBranch','value','/nx.json','invokeTasksUsingRunMany','printRunGroupError','toString','completeRunGroupWithError','__awaiter','../../file-storage/file-storage','../../api/error-reporter.api','SIGINT','../../error/print-invalid-runner-error','note','../../error/print-cacheable-targets-error','canDetectRunGroup','Agent\x20was\x20terminated\x20via\x20SIGINT','runner','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.','getCIExecutionEnv','some','.lock','join','../../../utilities/nx-imports','map','throw','Agent\x20','defineProperty','warn','next','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','CIRCLECI','/lockfiles','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','FileStorage','startAgent','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','Critical\x20Error\x20in\x20Agent:\x20\x22','parse','encryptionKey','Agent\x20was\x20terminated\x20via\x20SIGTERM','printCacheableTargetsError','message','__esModule','apply','../../../utilities/dte-artifact-storage','../../file-storage/e2e-encryption','NX_AGENT_NAME','done','error','SIGTERM'];(function(_0x3805cf,_0x56b971){const _0x567c82=function(_0x9aad8d){while(--_0x9aad8d){_0x3805cf['push'](_0x3805cf['shift']());}};_0x567c82(++_0x56b971);}(a6_0x56b9,0x14f));const a6_0x567c=function(_0x3805cf,_0x56b971){_0x3805cf=_0x3805cf-0x0;let _0x567c82=a6_0x56b9[_0x3805cf];return _0x567c82;};'use strict';var __awaiter=this&&this[a6_0x567c('0x2a')]||function(_0x288362,_0x5363fc,_0x49c8ba,_0x12fdf2){function _0x551be3(_0x4cedff){return _0x4cedff instanceof _0x49c8ba?_0x4cedff:new _0x49c8ba(function(_0x4462fb){_0x4462fb(_0x4cedff);});}return new(_0x49c8ba||(_0x49c8ba=Promise))(function(_0x3c2d19,_0x342183){function _0x51e0fc(_0xca2c4d){try{_0x4e8fa7(_0x12fdf2[a6_0x567c('0x3f')](_0xca2c4d));}catch(_0x3b2455){_0x342183(_0x3b2455);}}function _0x3723ad(_0x191ce0){try{_0x4e8fa7(_0x12fdf2[a6_0x567c('0x3b')](_0x191ce0));}catch(_0x123c75){_0x342183(_0x123c75);}}function _0x4e8fa7(_0x283b1f){_0x283b1f[a6_0x567c('0x52')]?_0x3c2d19(_0x283b1f[a6_0x567c('0x24')]):_0x551be3(_0x283b1f['value'])[a6_0x567c('0x19')](_0x51e0fc,_0x3723ad);}_0x4e8fa7((_0x12fdf2=_0x12fdf2[a6_0x567c('0x4e')](_0x288362,_0x5363fc||[]))[a6_0x567c('0x3f')]());});};Object[a6_0x567c('0x3d')](exports,a6_0x567c('0x4d'),{'value':!![]});exports[a6_0x567c('0x45')]=void 0x0;const fs_1=require('fs');const stripJsonComments=require(a6_0x567c('0x9'));const yargsParser=require('yargs-parser');const environment_1=require(a6_0x567c('0x7'));const metric_logger_1=require('../../../utilities/metric-logger');const print_cacheable_targets_error_1=require(a6_0x567c('0x30'));const print_invalid_runner_error_1=require(a6_0x567c('0x2e'));const print_run_group_error_1=require('../../error/print-run-group-error');const distributed_agent_api_1=require(a6_0x567c('0x20'));const execute_tasks_1=require(a6_0x567c('0xb'));const dte_artifact_storage_1=require(a6_0x567c('0x4f'));const file_storage_1=require(a6_0x567c('0x2b'));const e2e_encryption_1=require(a6_0x567c('0x50'));const error_reporter_api_1=require(a6_0x567c('0x2c'));const invoke_tasks_using_run_many_1=require('./invoke-tasks-using-run-many');const invoke_tasks_using_nx_imperative_api_1=require(a6_0x567c('0x17'));const {output,initTasksRunner,workspaceRoot}=require(a6_0x567c('0x39'));const args=yargsParser(process['argv'],{'array':[a6_0x567c('0x12')],'default':{}});if(args['targets']&&args[a6_0x567c('0x12')]['length']===0x1){args[a6_0x567c('0x12')]=args['targets'][0x0]['split'](',')[a6_0x567c('0x3a')](_0x3db1e5=>_0x3db1e5[a6_0x567c('0x8')]());}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5e5493=(0x0,environment_1[a6_0x567c('0x23')])();const _0x3b141f=(0x0,environment_1[a6_0x567c('0x1c')])();const _0x34ad5b=(0x0,environment_1['getCIExecutionId'])();const _0x735a0d=(0x0,environment_1[a6_0x567c('0x35')])();if(!(0x0,print_run_group_error_1[a6_0x567c('0x31')])(_0x3b141f,_0x34ad5b)){(0x0,print_run_group_error_1[a6_0x567c('0x27')])();process[a6_0x567c('0x5')](0x1);}if(args['targets']&&args[a6_0x567c('0x12')][a6_0x567c('0x21')]){output[a6_0x567c('0x2f')]({'title':'Starting\x20an\x20agent\x20for\x20running\x20Nx\x20target(s)\x20['+args[a6_0x567c('0x12')][a6_0x567c('0x38')](',\x20')+']'});}else{output[a6_0x567c('0x2f')]({'title':'Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks'});}const _0x338cef=JSON[a6_0x567c('0x48')](stripJsonComments((0x0,fs_1[a6_0x567c('0xc')])(workspaceRoot+a6_0x567c('0x25'))[a6_0x567c('0x28')]()))[a6_0x567c('0x6')][a6_0x567c('0xd')];if(_0x338cef[a6_0x567c('0x33')]!==a6_0x567c('0x10')){(0x0,print_invalid_runner_error_1['printInvalidRunnerError'])();return process[a6_0x567c('0x5')](0x1);}const _0x5248b9=_0x338cef[a6_0x567c('0x22')];if(args[a6_0x567c('0x12')]&&args[a6_0x567c('0x12')][a6_0x567c('0x36')](_0x2060f4=>{var _0x773da9;return!((_0x773da9=_0x5248b9[a6_0x567c('0x1f')])===null||_0x773da9===void 0x0?void 0x0:_0x773da9[a6_0x567c('0x4')](_0x2060f4));})){const _0x1cea94=args[a6_0x567c('0x12')][a6_0x567c('0x13')](_0x417fd0=>{var _0x19483d;return!((_0x19483d=_0x5248b9[a6_0x567c('0x1f')])===null||_0x19483d===void 0x0?void 0x0:_0x19483d[a6_0x567c('0x4')](_0x417fd0));});(0x0,print_cacheable_targets_error_1[a6_0x567c('0x4b')])(_0x1cea94);return process[a6_0x567c('0x5')](0x1);}const _0xabc4eb=getAgentName();const _0x63286f=new distributed_agent_api_1['DistributedAgentApi'](_0x5248b9,_0x5e5493,_0x3b141f,_0x34ad5b,_0x735a0d,_0xabc4eb);createAgentLockfileAndSetUpListeners(_0x63286f,_0x5248b9,_0xabc4eb);const _0x4df9a9=new e2e_encryption_1[(a6_0x567c('0x1'))](environment_1[a6_0x567c('0x3')]||_0x5248b9[a6_0x567c('0x49')]);const _0x415de7=new error_reporter_api_1[(a6_0x567c('0x1a'))](_0x5248b9);const _0x588e5c=new dte_artifact_storage_1[(a6_0x567c('0x16'))](new file_storage_1[(a6_0x567c('0x44'))](_0x4df9a9,_0x415de7,_0x5248b9,'dte-agent'),(0x0,environment_1['getNxCacheDirectory'])(_0x5248b9));const _0x54aa9c=initTasksRunner?yield(0x0,invoke_tasks_using_nx_imperative_api_1['invokeTasksUsingNxImperativeApi'])(_0x5248b9):yield(0x0,invoke_tasks_using_run_many_1[a6_0x567c('0x26')])(_0x5248b9);return(0x0,execute_tasks_1[a6_0x567c('0x11')])(_0xabc4eb,_0x63286f,_0x588e5c,_0x54aa9c,args[a6_0x567c('0x12')])[a6_0x567c('0x19')](_0x4826d3=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1['submitRunMetrics'])(_0x5248b9);return _0x4826d3;}))[a6_0x567c('0xf')](_0x492951=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x63286f[a6_0x567c('0x29')](a6_0x567c('0x47')+_0x492951[a6_0x567c('0x4c')]+'\x22');throw _0x492951;}));});}exports['startAgent']=startAgent;function getAgentName(){if(process['env'][a6_0x567c('0x51')]!==undefined){return process[a6_0x567c('0x1b')]['NX_AGENT_NAME'];}else if(process[a6_0x567c('0x1b')]['CIRCLECI']!==undefined&&process[a6_0x567c('0x1b')][a6_0x567c('0x1e')]){return process[a6_0x567c('0x1b')][a6_0x567c('0x1e')];}else if(process[a6_0x567c('0x1b')][a6_0x567c('0x41')]!==undefined&&process[a6_0x567c('0x1b')][a6_0x567c('0xe')]){return process[a6_0x567c('0x1b')]['CIRCLE_JOB'];}else{return a6_0x567c('0x3c')+Math[a6_0x567c('0x15')](Math[a6_0x567c('0x18')]()*0x186a0);}}function createAgentLockfileAndSetUpListeners(_0x7ed862,_0x16aff6,_0x10fbf0){const _0x7dd589=(0x0,environment_1['getNxCacheDirectory'])(_0x16aff6);const _0x37b227=_0x7dd589+a6_0x567c('0x42');const _0x4e006d=_0x37b227+'/'+_0x10fbf0+'.lock';if(!(0x0,fs_1['existsSync'])(_0x37b227)){(0x0,fs_1['mkdirSync'])(_0x37b227,{'recursive':!![]});}const _0x54b44a=(0x0,fs_1[a6_0x567c('0x1d')])(_0x37b227);if(_0x54b44a['length']){if(_0x54b44a[a6_0x567c('0x4')](_0x10fbf0+a6_0x567c('0x37'))){output[a6_0x567c('0x53')]({'title':'Duplicate\x20Agent\x20ID\x20Detected','bodyLines':[a6_0x567c('0x46'),'',a6_0x567c('0x34')]});process[a6_0x567c('0x5')](0x1);}output[a6_0x567c('0x3e')]({'title':a6_0x567c('0xa'),'bodyLines':[a6_0x567c('0x43'),'',a6_0x567c('0x40'),'If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.']});}(0x0,fs_1[a6_0x567c('0x2')])(_0x4e006d,'');process['on']('exit',_0x26fc31=>{cleanupAgentLockfile(_0x4e006d,_0x26fc31);});process['on'](a6_0x567c('0x0'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x7ed862[a6_0x567c('0x29')](a6_0x567c('0x4a'));cleanupAgentLockfile(_0x4e006d,0x1);}));process['on'](a6_0x567c('0x2d'),()=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x7ed862['completeRunGroupWithError'](a6_0x567c('0x32'));cleanupAgentLockfile(_0x4e006d,0x1);}));}function cleanupAgentLockfile(_0x91bc20,_0x1b053e){if((0x0,fs_1['existsSync'])(_0x91bc20)){(0x0,fs_1[a6_0x567c('0x14')])(_0x91bc20);process[a6_0x567c('0x5')](_0x1b053e);}}
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.startAgent = void 0;
13
+ const fs_1 = require("fs");
14
+ const stripJsonComments = require("strip-json-comments");
15
+ const yargsParser = require("yargs-parser");
16
+ const environment_1 = require("../../../utilities/environment");
17
+ const metric_logger_1 = require("../../../utilities/metric-logger");
18
+ const print_cacheable_targets_error_1 = require("../../error/print-cacheable-targets-error");
19
+ const print_invalid_runner_error_1 = require("../../error/print-invalid-runner-error");
20
+ const print_run_group_error_1 = require("../../error/print-run-group-error");
21
+ const distributed_agent_api_1 = require("./distributed-agent.api");
22
+ const execute_tasks_1 = require("./execute-tasks");
23
+ const dte_artifact_storage_1 = require("../../../utilities/dte-artifact-storage");
24
+ const file_storage_1 = require("../../file-storage/file-storage");
25
+ const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
26
+ const error_reporter_api_1 = require("../../api/error-reporter.api");
27
+ const invoke_tasks_using_run_many_1 = require("./invoke-tasks-using-run-many");
28
+ const invoke_tasks_using_nx_imperative_api_1 = require("./invoke-tasks-using-nx-imperative-api");
29
+ const { output, initTasksRunner, workspaceRoot, } = require('../../../utilities/nx-imports');
30
+ const args = yargsParser(process.argv, {
31
+ array: ['targets'],
32
+ default: {},
33
+ });
34
+ // just in case someone passes the args with commas
35
+ // cf. https://github.com/yargs/yargs/issues/846
36
+ if (args.targets && args.targets.length === 1) {
37
+ args.targets = args.targets[0].split(',').map((x) => x.trim());
38
+ }
39
+ function startAgent() {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const branch = (0, environment_1.getBranch)();
42
+ const runGroup = (0, environment_1.getRunGroup)();
43
+ const ciExecutionId = (0, environment_1.getCIExecutionId)();
44
+ const ciExecutionEnv = (0, environment_1.getCIExecutionEnv)();
45
+ if (!(0, print_run_group_error_1.canDetectRunGroup)(runGroup, ciExecutionId)) {
46
+ (0, print_run_group_error_1.printRunGroupError)();
47
+ process.exit(1);
48
+ }
49
+ if (args.targets && args.targets.length) {
50
+ output.note({
51
+ title: `Starting an agent for running Nx target(s) [${args.targets.join(', ')}]`,
52
+ });
53
+ }
54
+ else {
55
+ output.note({
56
+ title: 'Starting an agent for running Nx tasks',
57
+ });
58
+ }
59
+ const defaultRunnerConfig = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default;
60
+ if (defaultRunnerConfig.runner !== '@nrwl/nx-cloud') {
61
+ (0, print_invalid_runner_error_1.printInvalidRunnerError)();
62
+ return process.exit(1);
63
+ }
64
+ const options = defaultRunnerConfig.options;
65
+ if (args.targets &&
66
+ args.targets.some((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); })) {
67
+ const wrongTargets = args.targets.filter((target) => { var _a; return !((_a = options.cacheableOperations) === null || _a === void 0 ? void 0 : _a.includes(target)); });
68
+ (0, print_cacheable_targets_error_1.printCacheableTargetsError)(wrongTargets);
69
+ return process.exit(1);
70
+ }
71
+ const agentName = getAgentName();
72
+ const api = new distributed_agent_api_1.DistributedAgentApi(options, branch, runGroup, ciExecutionId, ciExecutionEnv, agentName);
73
+ createAgentLockfileAndSetUpListeners(api, options, agentName);
74
+ const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
75
+ const errorReporter = new error_reporter_api_1.ErrorReporterApi(options);
76
+ const dteArtifactStorage = new dte_artifact_storage_1.DteArtifactStorage(new file_storage_1.FileStorage(encryption, errorReporter, options, 'dte-agent'), (0, environment_1.getNxCacheDirectory)(options));
77
+ const invokeTasks = initTasksRunner
78
+ ? yield (0, invoke_tasks_using_nx_imperative_api_1.invokeTasksUsingNxImperativeApi)(options)
79
+ : yield (0, invoke_tasks_using_run_many_1.invokeTasksUsingRunMany)(options);
80
+ return (0, execute_tasks_1.executeTasks)(agentName, api, dteArtifactStorage, invokeTasks, args.targets)
81
+ .then((res) => __awaiter(this, void 0, void 0, function* () {
82
+ yield (0, metric_logger_1.submitRunMetrics)(options);
83
+ return res;
84
+ }))
85
+ .catch((e) => __awaiter(this, void 0, void 0, function* () {
86
+ yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
87
+ throw e;
88
+ }));
89
+ });
90
+ }
91
+ exports.startAgent = startAgent;
92
+ function getAgentName() {
93
+ if (process.env.NX_AGENT_NAME !== undefined) {
94
+ return process.env.NX_AGENT_NAME;
95
+ }
96
+ else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_STAGE) {
97
+ return process.env.CIRCLE_STAGE;
98
+ }
99
+ else if (process.env.CIRCLECI !== undefined && process.env.CIRCLE_JOB) {
100
+ return process.env.CIRCLE_JOB;
101
+ }
102
+ else {
103
+ return `Agent ${Math.floor(Math.random() * 100000)}`;
104
+ }
105
+ }
106
+ function createAgentLockfileAndSetUpListeners(api, options, agentName) {
107
+ const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
108
+ const lockFileDirectory = `${cacheDirectory}/lockfiles`;
109
+ const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
110
+ if (!(0, fs_1.existsSync)(lockFileDirectory)) {
111
+ (0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
112
+ }
113
+ // Check for other agents' lockfiles and warn if exist
114
+ const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
115
+ if (lockFiles.length) {
116
+ // Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
117
+ if (lockFiles.includes(`${agentName}.lock`)) {
118
+ output.error({
119
+ title: 'Duplicate Agent ID Detected',
120
+ bodyLines: [
121
+ 'We have detected another agent with this ID running in this workspace. This should not happen.',
122
+ '',
123
+ 'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
124
+ ],
125
+ });
126
+ process.exit(1);
127
+ }
128
+ output.warn({
129
+ title: 'Other Nx Cloud Agents Detected',
130
+ bodyLines: [
131
+ 'We have detected other agents running in this workspace. This can cause unexpected behavior.',
132
+ '',
133
+ 'This can also be a false positive caused by agents that did not shut down correctly.',
134
+ 'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
135
+ ],
136
+ });
137
+ }
138
+ (0, fs_1.writeFileSync)(lockFilePath, '');
139
+ process.on('exit', (code) => {
140
+ cleanupAgentLockfile(lockFilePath, code);
141
+ });
142
+ process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
143
+ yield api.completeRunGroupWithError('Agent was terminated via SIGTERM');
144
+ cleanupAgentLockfile(lockFilePath, 1);
145
+ }));
146
+ process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
147
+ yield api.completeRunGroupWithError('Agent was terminated via SIGINT');
148
+ cleanupAgentLockfile(lockFilePath, 1);
149
+ }));
150
+ }
151
+ function cleanupAgentLockfile(lockFilePath, code) {
152
+ if ((0, fs_1.existsSync)(lockFilePath)) {
153
+ (0, fs_1.unlinkSync)(lockFilePath);
154
+ process.exit(code);
155
+ }
156
+ }
157
+ //# sourceMappingURL=distributed-agent.impl.js.map
@@ -1 +1,114 @@
1
- const a7_0x2237=['done','NO_FURTHER_TASKS_TO_RUN','hash','reset','NO_MESSAGES_TIMEOUT','maxParallel:\x20','completedTasks','url','value','wait','taskId','then','retryDuring:\x20','VERBOSE_LOGGING','RUN_GROUP_COMPLETED','note','executionId:\x20','Distributed\x20Execution\x20Terminated','../../../utilities/waiter','retrieveAndExtract','error','status','executionId','length','next','retryDuring','createUnchangedValueTimeout','error:\x20','completedStatusCode','map','\x20Hash:\x20','\x20fetching\x20tasks...','number\x20of\x20tasks:\x20','completed:\x20','apply','No\x20new\x20messages\x20received\x20after\x20','__awaiter','getTime','tasks','maxParallel','\x20seconds','__esModule','completed','Error:','\x20received\x20an\x20API\x20Response','criticalErrorMessage'];(function(_0x11cc8b,_0x2237de){const _0xb05736=function(_0x212b68){while(--_0x212b68){_0x11cc8b['push'](_0x11cc8b['shift']());}};_0xb05736(++_0x2237de);}(a7_0x2237,0xae));const a7_0xb057=function(_0x11cc8b,_0x2237de){_0x11cc8b=_0x11cc8b-0x0;let _0xb05736=a7_0x2237[_0x11cc8b];return _0xb05736;};'use strict';var __awaiter=this&&this[a7_0xb057('0x0')]||function(_0x5a3c7a,_0x541477,_0x1602af,_0x3ac9d4){function _0xac607e(_0x1a0138){return _0x1a0138 instanceof _0x1602af?_0x1a0138:new _0x1602af(function(_0x8debc){_0x8debc(_0x1a0138);});}return new(_0x1602af||(_0x1602af=Promise))(function(_0x39d542,_0xe4f586){function _0x21d0f5(_0x5eca92){try{_0x36a1b9(_0x3ac9d4[a7_0xb057('0x22')](_0x5eca92));}catch(_0x365cb4){_0xe4f586(_0x365cb4);}}function _0x189e9e(_0x134c73){try{_0x36a1b9(_0x3ac9d4['throw'](_0x134c73));}catch(_0x168453){_0xe4f586(_0x168453);}}function _0x36a1b9(_0x2cc7b9){_0x2cc7b9[a7_0xb057('0xa')]?_0x39d542(_0x2cc7b9[a7_0xb057('0x12')]):_0xac607e(_0x2cc7b9[a7_0xb057('0x12')])[a7_0xb057('0x15')](_0x21d0f5,_0x189e9e);}_0x36a1b9((_0x3ac9d4=_0x3ac9d4[a7_0xb057('0x2c')](_0x5a3c7a,_0x541477||[]))[a7_0xb057('0x22')]());});};Object['defineProperty'](exports,a7_0xb057('0x5'),{'value':!![]});exports['executeTasks']=void 0x0;const create_unchanged_value_timeout_1=require('../../../utilities/create-unchanged-value-timeout');const environment_1=require('../../../utilities/environment');const waiter_1=require(a7_0xb057('0x1c'));const {output}=require('../../../utilities/nx-imports');function executeTasks(_0x47846b,_0x535a98,_0x26d507,_0x1f46e3,_0x98344f){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x406446=0x0;let _0x5e5ec7=null;const _0x4c4f37=(0x0,create_unchanged_value_timeout_1[a7_0xb057('0x24')])({'title':a7_0xb057('0x2d')+environment_1['NO_MESSAGES_TIMEOUT']/0x3e8+a7_0xb057('0x4'),'timeout':environment_1[a7_0xb057('0xe')]});const _0x2441e8=new waiter_1['Waiter']();let _0x5ed0ae=[];const _0x1e0fa8=new Date();let _0x373707=![];const _0x5e22dd={};while(!![]){if(environment_1['VERBOSE_LOGGING']){output['note']({'title':_0x47846b+a7_0xb057('0x29')});}_0x5e5ec7=yield _0x535a98['tasks'](_0x5e5ec7?_0x5e5ec7[a7_0xb057('0x20')]:null,_0x406446,_0x5ed0ae,_0x98344f);if(environment_1[a7_0xb057('0x17')]){output[a7_0xb057('0x19')]({'title':_0x47846b+a7_0xb057('0x8'),'bodyLines':[a7_0xb057('0x2b')+_0x5e5ec7['completed'],'status:\x20'+_0x5e5ec7[a7_0xb057('0x1f')],a7_0xb057('0x16')+_0x5e5ec7['retryDuring'],a7_0xb057('0x1a')+_0x5e5ec7[a7_0xb057('0x20')],a7_0xb057('0x2a')+_0x5e5ec7[a7_0xb057('0x2')][a7_0xb057('0x21')],a7_0xb057('0x25')+_0x5e5ec7[a7_0xb057('0x9')],a7_0xb057('0xf')+_0x5e5ec7[a7_0xb057('0x3')]]});}if(_0x5e5ec7[a7_0xb057('0x9')]){output[a7_0xb057('0x1e')]({'title':a7_0xb057('0x1b'),'bodyLines':[a7_0xb057('0x7'),_0x5e5ec7['criticalErrorMessage']]});process['exit'](0x0);}if((_0x5e5ec7===null||_0x5e5ec7===void 0x0?void 0x0:_0x5e5ec7[a7_0xb057('0x23')])&&(_0x5e5ec7===null||_0x5e5ec7===void 0x0?void 0x0:_0x5e5ec7['retryDuring'])!==0x0&&!_0x373707&&new Date()[a7_0xb057('0x1')]()-_0x1e0fa8[a7_0xb057('0x1')]()>_0x5e5ec7['retryDuring']){yield _0x2441e8['wait']();continue;}if((_0x5e5ec7===null||_0x5e5ec7===void 0x0?void 0x0:_0x5e5ec7['status'])!==undefined){if(_0x5e5ec7[a7_0xb057('0x1f')]===a7_0xb057('0x18')||_0x5e5ec7['status']===a7_0xb057('0xb')){return;}}else if(_0x5e5ec7[a7_0xb057('0x6')]){return;}_0x4c4f37(_0x5e5ec7[a7_0xb057('0x2')][a7_0xb057('0x27')](_0x48ae2d=>_0x48ae2d[a7_0xb057('0x14')])['join'](''));if(!_0x5e5ec7[a7_0xb057('0x20')]){if(environment_1['VERBOSE_LOGGING']){output[a7_0xb057('0x19')]({'title':_0x47846b+'\x20waiting...'});}yield _0x2441e8[a7_0xb057('0x13')]();_0x406446=0x0;_0x5ed0ae=[];continue;}_0x2441e8[a7_0xb057('0xd')]();_0x373707=!![];if(_0x5e5ec7[a7_0xb057('0x10')]){for(const _0x14aef4 of _0x5e5ec7[a7_0xb057('0x10')]){if(_0x5e22dd[_0x14aef4[a7_0xb057('0x14')]])continue;output['note']({'title':_0x47846b+'\x20downloading\x20artifacts\x20for\x20'+_0x14aef4['taskId']+a7_0xb057('0x28')+_0x14aef4[a7_0xb057('0xc')]+'\x20Url:\x20'+_0x14aef4[a7_0xb057('0x11')]});yield _0x26d507[a7_0xb057('0x1d')](_0x14aef4['hash'],_0x14aef4['url']);_0x5e22dd[_0x14aef4[a7_0xb057('0x14')]]=!![];}}const _0x5866d0=yield _0x1f46e3(_0x5e5ec7[a7_0xb057('0x20')],_0x5e5ec7[a7_0xb057('0x2')],_0x5e5ec7[a7_0xb057('0x3')]);for(const _0x8fc709 of _0x5866d0['completedTasks']){_0x5e22dd[_0x8fc709['taskId']]=!![];}_0x406446=_0x5866d0[a7_0xb057('0x26')];_0x5ed0ae=_0x5866d0['completedTasks'];}});}exports['executeTasks']=executeTasks;
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.executeTasks = void 0;
13
+ const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
14
+ const environment_1 = require("../../../utilities/environment");
15
+ const waiter_1 = require("../../../utilities/waiter");
16
+ const { output } = require('../../../utilities/nx-imports');
17
+ function executeTasks(agentName, api, dteArtifactStorage, invokeTasks, targets) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ let completedStatusCode = 0;
20
+ let apiResponse = null;
21
+ const failIfSameTasksAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
22
+ title: `No new messages received after ${environment_1.NO_MESSAGES_TIMEOUT / 1000} seconds`,
23
+ timeout: environment_1.NO_MESSAGES_TIMEOUT,
24
+ });
25
+ const waiter = new waiter_1.Waiter();
26
+ let completedTasks = [];
27
+ const startTime = new Date();
28
+ let executedAnyTasks = false;
29
+ const processedTasks = {};
30
+ while (true) {
31
+ if (environment_1.VERBOSE_LOGGING) {
32
+ output.note({
33
+ title: `${agentName} fetching tasks...`,
34
+ });
35
+ }
36
+ apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks, targets);
37
+ if (environment_1.VERBOSE_LOGGING) {
38
+ output.note({
39
+ title: `${agentName} received an API Response`,
40
+ bodyLines: [
41
+ `completed: ${apiResponse.completed}`,
42
+ `status: ${apiResponse.status}`,
43
+ `retryDuring: ${apiResponse.retryDuring}`,
44
+ `executionId: ${apiResponse.executionId}`,
45
+ `number of tasks: ${apiResponse.tasks.length}`,
46
+ `error: ${apiResponse.criticalErrorMessage}`,
47
+ `maxParallel: ${apiResponse.maxParallel}`,
48
+ ],
49
+ });
50
+ }
51
+ if (apiResponse.criticalErrorMessage) {
52
+ output.error({
53
+ title: 'Distributed Execution Terminated',
54
+ bodyLines: ['Error:', apiResponse.criticalErrorMessage],
55
+ });
56
+ process.exit(0);
57
+ }
58
+ // run group is completed but it might be a rerun
59
+ // we will try several times before going further and
60
+ // completed the response
61
+ // we only do it if we haven't executed any tasks
62
+ if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
63
+ (apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
64
+ !executedAnyTasks &&
65
+ new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
66
+ yield waiter.wait();
67
+ continue;
68
+ }
69
+ if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.status) !== undefined) {
70
+ if (apiResponse.status === 'RUN_GROUP_COMPLETED' ||
71
+ apiResponse.status === 'NO_FURTHER_TASKS_TO_RUN') {
72
+ return;
73
+ }
74
+ }
75
+ else if (apiResponse.completed) {
76
+ return;
77
+ }
78
+ // if status is present that use the status instead of completed, otherwise use completed
79
+ failIfSameTasksAfterTimeout(apiResponse.tasks.map((t) => t.taskId).join(''));
80
+ if (!apiResponse.executionId) {
81
+ if (environment_1.VERBOSE_LOGGING) {
82
+ output.note({
83
+ title: `${agentName} waiting...`,
84
+ });
85
+ }
86
+ yield waiter.wait();
87
+ completedStatusCode = 0;
88
+ completedTasks = [];
89
+ continue;
90
+ }
91
+ waiter.reset();
92
+ executedAnyTasks = true;
93
+ if (apiResponse.completedTasks) {
94
+ for (const t of apiResponse.completedTasks) {
95
+ if (processedTasks[t.taskId])
96
+ continue;
97
+ output.note({
98
+ title: `${agentName} downloading artifacts for ${t.taskId} Hash: ${t.hash} Url: ${t.url}`,
99
+ });
100
+ yield dteArtifactStorage.retrieveAndExtract(t.hash, t.url);
101
+ processedTasks[t.taskId] = true;
102
+ }
103
+ }
104
+ const r = yield invokeTasks(apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
105
+ for (const t of r.completedTasks) {
106
+ processedTasks[t.taskId] = true;
107
+ }
108
+ completedStatusCode = r.completedStatusCode;
109
+ completedTasks = r.completedTasks;
110
+ }
111
+ });
112
+ }
113
+ exports.executeTasks = executeTasks;
114
+ //# sourceMappingURL=execute-tasks.js.map
@@ -1 +1,58 @@
1
- const a8_0x57aa=['unparse','__esModule','configuration','value','defineProperty','map','assign','apply','length','next','NX_PREFIX_OUTPUT','__awaiter','hash','../../../utilities/serializer-overrides','env','../../../utilities/nx-imports','taskId','projectName','true','status','NX_STREAM_OUTPUT','invoke','invokeTasksUsingNxImperativeApi','then','NX_CACHE_FAILURES','NX_CLOUD_DISTRIBUTED_EXECUTION_ID'];(function(_0x29a9dd,_0x57aa55){const _0x15cc0e=function(_0x1f87aa){while(--_0x1f87aa){_0x29a9dd['push'](_0x29a9dd['shift']());}};_0x15cc0e(++_0x57aa55);}(a8_0x57aa,0x113));const a8_0x15cc=function(_0x29a9dd,_0x57aa55){_0x29a9dd=_0x29a9dd-0x0;let _0x15cc0e=a8_0x57aa[_0x29a9dd];return _0x15cc0e;};'use strict';var __awaiter=this&&this[a8_0x15cc('0x16')]||function(_0x144d00,_0x3f09cf,_0x2d7914,_0x401b98){function _0x1d3ff1(_0x280d4c){return _0x280d4c instanceof _0x2d7914?_0x280d4c:new _0x2d7914(function(_0x5ae730){_0x5ae730(_0x280d4c);});}return new(_0x2d7914||(_0x2d7914=Promise))(function(_0x11aac7,_0x1bb581){function _0x33b05b(_0x45be6e){try{_0x58c16c(_0x401b98[a8_0x15cc('0x14')](_0x45be6e));}catch(_0x2d37fb){_0x1bb581(_0x2d37fb);}}function _0x4fea6e(_0x50608f){try{_0x58c16c(_0x401b98['throw'](_0x50608f));}catch(_0x4d65b6){_0x1bb581(_0x4d65b6);}}function _0x58c16c(_0x2c51f7){_0x2c51f7['done']?_0x11aac7(_0x2c51f7[a8_0x15cc('0xe')]):_0x1d3ff1(_0x2c51f7[a8_0x15cc('0xe')])[a8_0x15cc('0x8')](_0x33b05b,_0x4fea6e);}_0x58c16c((_0x401b98=_0x401b98[a8_0x15cc('0x12')](_0x144d00,_0x3f09cf||[]))[a8_0x15cc('0x14')]());});};Object[a8_0x15cc('0xf')](exports,a8_0x15cc('0xc'),{'value':!![]});exports[a8_0x15cc('0x7')]=void 0x0;const {initTasksRunner}=require(a8_0x15cc('0x0'));const parser=require('yargs-parser');const serializer_overrides_1=require(a8_0x15cc('0x18'));function invokeTasksUsingNxImperativeApi(_0x19c2c6){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5b8e5a=yield initTasksRunner(_0x19c2c6);return(_0x13aded,_0x3efc01,_0x376339)=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x5aed07=_0x3efc01[a8_0x15cc('0x10')](_0x2d5a42=>{const _0x46eae8=parser(_0x2d5a42['params'],{'configuration':{'camel-case-expansion':![],'dot-notation':!![]}});const _0x2849c9=(0x0,serializer_overrides_1[a8_0x15cc('0xb')])(_0x46eae8);if(_0x46eae8['_'][a8_0x15cc('0x13')]==0x0){delete _0x46eae8['_'];}return{'id':_0x2d5a42[a8_0x15cc('0x1')],'target':{'project':_0x2d5a42[a8_0x15cc('0x2')],'target':_0x2d5a42['target'],'configuration':_0x2d5a42[a8_0x15cc('0xd')]},'overrides':Object[a8_0x15cc('0x11')](Object['assign']({},_0x46eae8),{'__overrides_unparsed__':_0x2849c9})};});process[a8_0x15cc('0x19')][a8_0x15cc('0x9')]=a8_0x15cc('0x3');process[a8_0x15cc('0x19')][a8_0x15cc('0xa')]=_0x13aded;process[a8_0x15cc('0x19')][a8_0x15cc('0x5')]=a8_0x15cc('0x3');process['env'][a8_0x15cc('0x15')]=a8_0x15cc('0x3');const _0x5e9889=yield _0x5b8e5a[a8_0x15cc('0x6')]({'tasks':_0x5aed07,'parallel':_0x376339});const _0x5d2543=Object['values'](_0x5e9889['taskGraph']['tasks']);return{'completedTasks':_0x5d2543[a8_0x15cc('0x10')](_0x4f2c29=>({'taskId':_0x4f2c29['id'],'hash':_0x4f2c29[a8_0x15cc('0x17')]})),'completedStatusCode':_0x5e9889[a8_0x15cc('0x4')]};});});}exports['invokeTasksUsingNxImperativeApi']=invokeTasksUsingNxImperativeApi;
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.invokeTasksUsingNxImperativeApi = void 0;
13
+ const { initTasksRunner } = require('../../../utilities/nx-imports');
14
+ const parser = require("yargs-parser");
15
+ const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
16
+ function invokeTasksUsingNxImperativeApi(options) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const tasksRunner = yield initTasksRunner(options);
19
+ return (executionId, tasksToExecute, parallel) => __awaiter(this, void 0, void 0, function* () {
20
+ const tasks = tasksToExecute.map((t) => {
21
+ const params = parser(t.params, {
22
+ configuration: {
23
+ 'camel-case-expansion': false,
24
+ 'dot-notation': true,
25
+ },
26
+ });
27
+ const unparsed = (0, serializer_overrides_1.unparse)(params);
28
+ if (params._.length == 0) {
29
+ delete params._;
30
+ }
31
+ return {
32
+ id: t.taskId,
33
+ target: {
34
+ project: t.projectName,
35
+ target: t.target,
36
+ configuration: t.configuration,
37
+ },
38
+ overrides: Object.assign(Object.assign({}, params), { __overrides_unparsed__: unparsed }),
39
+ };
40
+ });
41
+ process.env.NX_CACHE_FAILURES = 'true'; // this is only requires because of how we do uploads
42
+ process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID = executionId;
43
+ process.env.NX_STREAM_OUTPUT = 'true';
44
+ process.env.NX_PREFIX_OUTPUT = 'true';
45
+ const r = yield tasksRunner.invoke({ tasks, parallel });
46
+ const completedTasks = Object.values(r.taskGraph.tasks);
47
+ return {
48
+ completedTasks: completedTasks.map((t) => ({
49
+ taskId: t.id,
50
+ hash: t.hash,
51
+ })),
52
+ completedStatusCode: r.status,
53
+ };
54
+ });
55
+ });
56
+ }
57
+ exports.invokeTasksUsingNxImperativeApi = invokeTasksUsingNxImperativeApi;
58
+ //# sourceMappingURL=invoke-tasks-using-nx-imperative-api.js.map
@@ -1 +1,97 @@
1
- const a9_0x3652=['\x20--projects=','readFileSync','projectName','done','getNxCacheDirectory','projects','toString','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','Executing:\x20\x27','status','\x20--parallel\x20--max-parallel=','execSync','/tasks-hashes-','child_process','params','target','apply','next',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','--configuration=','true','configuration','defineProperty','__awaiter','push','VERBOSE_LOGGING','parse','forEach','then','value','npx\x20nx\x20run-many\x20--target=','unlinkSync','__esModule'];(function(_0x7bfba3,_0x3652ae){const _0x5f3b71=function(_0x168c50){while(--_0x168c50){_0x7bfba3['push'](_0x7bfba3['shift']());}};_0x5f3b71(++_0x3652ae);}(a9_0x3652,0x84));const a9_0x5f3b=function(_0x7bfba3,_0x3652ae){_0x7bfba3=_0x7bfba3-0x0;let _0x5f3b71=a9_0x3652[_0x7bfba3];return _0x5f3b71;};'use strict';var __awaiter=this&&this[a9_0x5f3b('0x17')]||function(_0x3e53ba,_0x285ec7,_0x160320,_0x566ecb){function _0x3724b6(_0x53e1a7){return _0x53e1a7 instanceof _0x160320?_0x53e1a7:new _0x160320(function(_0x5606cc){_0x5606cc(_0x53e1a7);});}return new(_0x160320||(_0x160320=Promise))(function(_0xe7f517,_0x1bb210){function _0x1d67ee(_0x2d8970){try{_0x1ab121(_0x566ecb[a9_0x5f3b('0x11')](_0x2d8970));}catch(_0x5df228){_0x1bb210(_0x5df228);}}function _0x5f409a(_0x148204){try{_0x1ab121(_0x566ecb['throw'](_0x148204));}catch(_0x211c7f){_0x1bb210(_0x211c7f);}}function _0x1ab121(_0x1b6396){_0x1b6396[a9_0x5f3b('0x3')]?_0xe7f517(_0x1b6396[a9_0x5f3b('0x1d')]):_0x3724b6(_0x1b6396[a9_0x5f3b('0x1d')])[a9_0x5f3b('0x1c')](_0x1d67ee,_0x5f409a);}_0x1ab121((_0x566ecb=_0x566ecb[a9_0x5f3b('0x10')](_0x3e53ba,_0x285ec7||[]))['next']());});};Object[a9_0x5f3b('0x16')](exports,a9_0x5f3b('0x20'),{'value':!![]});exports['invokeTasksUsingRunMany']=void 0x0;const environment_1=require('../../../utilities/environment');const child_process_1=require(a9_0x5f3b('0xd'));const fs_1=require('fs');const {output}=require('../../../utilities/nx-imports');function invokeTasksUsingRunMany(_0x5a7c58){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x4aedfa=completedTasksReader(_0x5a7c58);return function _0x1645eb(_0x140169,_0x500b2c,_0x59a9c){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x4228c7=0x0;const _0x52583c=[];for(const _0x59d123 of groupByTarget(_0x500b2c)){const _0x5558d5=_0x59d123[a9_0x5f3b('0x15')]?a9_0x5f3b('0x13')+_0x59d123[a9_0x5f3b('0x15')]:'';const _0x32a850=_0x59a9c>0x1?a9_0x5f3b('0xa')+_0x59a9c:'';const _0x1a7026=a9_0x5f3b('0x1e')+_0x59d123[a9_0x5f3b('0xf')]+'\x20'+_0x5558d5+a9_0x5f3b('0x0')+_0x59d123[a9_0x5f3b('0x5')]['join'](',')+'\x20'+_0x59d123['params']+_0x32a850;if(environment_1[a9_0x5f3b('0x19')]){output['note']({'title':a9_0x5f3b('0x8')+_0x1a7026+'\x27'});}try{(0x0,child_process_1[a9_0x5f3b('0xb')])(_0x1a7026,{'stdio':['ignore','inherit','inherit'],'env':Object['assign'](Object['assign']({},process['env']),{'NX_CACHE_FAILURES':a9_0x5f3b('0x14'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x140169,'NX_STREAM_OUTPUT':a9_0x5f3b('0x14'),'NX_PREFIX_OUTPUT':a9_0x5f3b('0x14')})});_0x52583c['push'](..._0x4aedfa(_0x140169));}catch(_0x2cc078){if(_0x2cc078[a9_0x5f3b('0x9')]===environment_1[a9_0x5f3b('0x7')]){throw _0x2cc078;}else{_0x4228c7=0x1;_0x52583c[a9_0x5f3b('0x18')](..._0x4aedfa(_0x140169));}}}return{'completedStatusCode':_0x4228c7,'completedTasks':_0x52583c};});};});}exports['invokeTasksUsingRunMany']=invokeTasksUsingRunMany;function groupByTarget(_0x50e879){const _0x37ae80=[];_0x50e879[a9_0x5f3b('0x1b')](_0x2c4c46=>{const _0x531180=_0x37ae80['find'](_0x4db829=>_0x4db829[a9_0x5f3b('0xf')]===_0x2c4c46[a9_0x5f3b('0xf')]&&_0x4db829[a9_0x5f3b('0x15')]===_0x2c4c46['configuration']);if(_0x531180){_0x531180['projects'][a9_0x5f3b('0x18')](_0x2c4c46[a9_0x5f3b('0x2')]);}else{_0x37ae80['push']({'target':_0x2c4c46[a9_0x5f3b('0xf')],'projects':[_0x2c4c46[a9_0x5f3b('0x2')]],'params':_0x2c4c46[a9_0x5f3b('0xe')],'configuration':_0x2c4c46[a9_0x5f3b('0x15')]});}});return _0x37ae80;}function completedTasksReader(_0x169c97){const _0x8b7670=(0x0,environment_1[a9_0x5f3b('0x4')])(_0x169c97);return _0x5481ae=>{const _0x4ac61e='Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20'+_0x5481ae+a9_0x5f3b('0x12');let _0x44afb7;try{const _0x46a4e9=_0x8b7670+a9_0x5f3b('0xc')+_0x5481ae;_0x44afb7=JSON[a9_0x5f3b('0x1a')]((0x0,fs_1[a9_0x5f3b('0x1')])(_0x46a4e9)[a9_0x5f3b('0x6')]());(0x0,fs_1[a9_0x5f3b('0x1f')])(_0x46a4e9);}catch(_0x2f6440){throw new Error(_0x4ac61e);}if(_0x44afb7['length']==0x0){throw new Error(_0x4ac61e);}return _0x44afb7;};}
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.invokeTasksUsingRunMany = void 0;
13
+ const environment_1 = require("../../../utilities/environment");
14
+ const child_process_1 = require("child_process");
15
+ const fs_1 = require("fs");
16
+ const { output } = require('../../../utilities/nx-imports');
17
+ function invokeTasksUsingRunMany(options) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const readCompleted = completedTasksReader(options);
20
+ return function invokeTasksUsingRunMany(executionId, tasksToExecute, parallel) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ let completedStatusCode = 0;
23
+ const completedTasks = [];
24
+ for (const g of groupByTarget(tasksToExecute)) {
25
+ const config = g.configuration
26
+ ? `--configuration=${g.configuration}`
27
+ : ``;
28
+ const parallelStr = parallel > 1 ? ` --parallel --max-parallel=${parallel}` : ``;
29
+ // TODO use pnpx or yarn when needed
30
+ const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallelStr}`;
31
+ if (environment_1.VERBOSE_LOGGING) {
32
+ output.note({
33
+ title: `Executing: '${command}'`,
34
+ });
35
+ }
36
+ try {
37
+ (0, child_process_1.execSync)(command, {
38
+ stdio: ['ignore', 'inherit', 'inherit'],
39
+ env: Object.assign(Object.assign({}, process.env), { NX_CACHE_FAILURES: 'true', NX_CLOUD_DISTRIBUTED_EXECUTION_ID: executionId, NX_STREAM_OUTPUT: 'true', NX_PREFIX_OUTPUT: 'true' }),
40
+ });
41
+ completedTasks.push(...readCompleted(executionId));
42
+ }
43
+ catch (e) {
44
+ if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
45
+ throw e;
46
+ }
47
+ else {
48
+ completedStatusCode = 1;
49
+ completedTasks.push(...readCompleted(executionId));
50
+ }
51
+ }
52
+ }
53
+ return { completedStatusCode, completedTasks };
54
+ });
55
+ };
56
+ });
57
+ }
58
+ exports.invokeTasksUsingRunMany = invokeTasksUsingRunMany;
59
+ function groupByTarget(tasks) {
60
+ const res = [];
61
+ tasks.forEach((t) => {
62
+ const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
63
+ if (r) {
64
+ r.projects.push(t.projectName);
65
+ }
66
+ else {
67
+ res.push({
68
+ target: t.target,
69
+ projects: [t.projectName],
70
+ params: t.params,
71
+ configuration: t.configuration,
72
+ });
73
+ }
74
+ });
75
+ return res;
76
+ }
77
+ function completedTasksReader(options) {
78
+ const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
79
+ return (distributedExecutionId) => {
80
+ const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
81
+ let completedTasks;
82
+ try {
83
+ const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
84
+ completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
85
+ // remove it such that if the next command crashes we don't read an obsolete file
86
+ (0, fs_1.unlinkSync)(taskHashesFile);
87
+ }
88
+ catch (e) {
89
+ throw new Error(errorMessage);
90
+ }
91
+ if (completedTasks.length == 0) {
92
+ throw new Error(errorMessage);
93
+ }
94
+ return completedTasks;
95
+ };
96
+ }
97
+ //# sourceMappingURL=invoke-tasks-using-run-many.js.map