@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,36 @@
1
- const a0_0x3bc5=['reportError','/nx-cloud/report-client-error','warn','post','next','apply','ErrorReporterApi','apiAxiosInstance','then','value','__esModule','throw','../../utilities/nx-imports','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27','__awaiter','done','message'];(function(_0x513d31,_0x3bc5aa){const _0x552a42=function(_0x2d337e){while(--_0x2d337e){_0x513d31['push'](_0x513d31['shift']());}};_0x552a42(++_0x3bc5aa);}(a0_0x3bc5,0x1b9));const a0_0x552a=function(_0x513d31,_0x3bc5aa){_0x513d31=_0x513d31-0x0;let _0x552a42=a0_0x3bc5[_0x513d31];return _0x552a42;};'use strict';var __awaiter=this&&this[a0_0x552a('0xf')]||function(_0xc595c1,_0x354b93,_0x400468,_0x52f92c){function _0x5306ea(_0x246f14){return _0x246f14 instanceof _0x400468?_0x246f14:new _0x400468(function(_0x240d26){_0x240d26(_0x246f14);});}return new(_0x400468||(_0x400468=Promise))(function(_0x10d184,_0x3732b1){function _0x371727(_0x93254d){try{_0x6732c8(_0x52f92c[a0_0x552a('0x5')](_0x93254d));}catch(_0x31da6b){_0x3732b1(_0x31da6b);}}function _0x12b9c9(_0x2f67b0){try{_0x6732c8(_0x52f92c[a0_0x552a('0xc')](_0x2f67b0));}catch(_0x2fb1c7){_0x3732b1(_0x2fb1c7);}}function _0x6732c8(_0x484d63){_0x484d63[a0_0x552a('0x10')]?_0x10d184(_0x484d63[a0_0x552a('0xa')]):_0x5306ea(_0x484d63[a0_0x552a('0xa')])[a0_0x552a('0x9')](_0x371727,_0x12b9c9);}_0x6732c8((_0x52f92c=_0x52f92c[a0_0x552a('0x6')](_0xc595c1,_0x354b93||[]))[a0_0x552a('0x5')]());});};Object['defineProperty'](exports,a0_0x552a('0xb'),{'value':!![]});exports[a0_0x552a('0x7')]=void 0x0;const axios_1=require('../../utilities/axios');const {output}=require(a0_0x552a('0xd'));class ErrorReporterApi{constructor(_0x4de023){this[a0_0x552a('0x8')]=(0x0,axios_1['createApiAxiosInstance'])(_0x4de023);}[a0_0x552a('0x1')](_0x51bdc1){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a0_0x552a('0x8')][a0_0x552a('0x4')](a0_0x552a('0x2'),{'message':_0x51bdc1}));}catch(_0x533613){output[a0_0x552a('0x3')]({'title':a0_0x552a('0xe')+_0x51bdc1+'\x27','bodyLines':[_0x533613[a0_0x552a('0x0')]]});}});}}exports[a0_0x552a('0x7')]=ErrorReporterApi;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ErrorReporterApi = void 0;
13
+ const axios_1 = require("../../utilities/axios");
14
+ const { output } = require('../../utilities/nx-imports');
15
+ class ErrorReporterApi {
16
+ constructor(options) {
17
+ this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
18
+ }
19
+ reportError(message) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ try {
22
+ yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', {
23
+ message,
24
+ }));
25
+ }
26
+ catch (e) {
27
+ output.warn({
28
+ title: `Unable to record the following error: '${message}'`,
29
+ bodyLines: [e.message],
30
+ });
31
+ }
32
+ });
33
+ }
34
+ }
35
+ exports.ErrorReporterApi = ErrorReporterApi;
36
+ //# sourceMappingURL=error-reporter.api.js.map
@@ -1 +1,73 @@
1
- const a1_0x4bfa=['RUNNER_FAILURE_PERF_ENTRY','next','then','createRunGroup','message','mapRespToPerfEntry','post','__awaiter','__esModule','/nx-cloud/executions/create-run-group','apiAxiosInstance','axiosMultipleTries','completeRunGroup','throw','value','exit','apply','../../utilities/nx-imports','../../utilities/metric-logger','createMetricRecorder','axiosException','response','error','defineProperty','/nx-cloud/executions/complete-run-group','RunGroupApi','recordMetric'];(function(_0x1b561e,_0x4bfa86){const _0x4d739a=function(_0x3b5b80){while(--_0x3b5b80){_0x1b561e['push'](_0x1b561e['shift']());}};_0x4d739a(++_0x4bfa86);}(a1_0x4bfa,0xd6));const a1_0x4d73=function(_0x1b561e,_0x4bfa86){_0x1b561e=_0x1b561e-0x0;let _0x4d739a=a1_0x4bfa[_0x1b561e];return _0x4d739a;};'use strict';var __awaiter=this&&this[a1_0x4d73('0x9')]||function(_0x57382b,_0x395369,_0x51d28d,_0x5ed3a5){function _0x4adb5f(_0x4db1c3){return _0x4db1c3 instanceof _0x51d28d?_0x4db1c3:new _0x51d28d(function(_0x80deaa){_0x80deaa(_0x4db1c3);});}return new(_0x51d28d||(_0x51d28d=Promise))(function(_0x41be57,_0x4ed754){function _0x2689c9(_0x48066e){try{_0x8b82bf(_0x5ed3a5[a1_0x4d73('0x3')](_0x48066e));}catch(_0x20a428){_0x4ed754(_0x20a428);}}function _0x15acdd(_0xa17567){try{_0x8b82bf(_0x5ed3a5[a1_0x4d73('0xf')](_0xa17567));}catch(_0xd744c4){_0x4ed754(_0xd744c4);}}function _0x8b82bf(_0x2918c9){_0x2918c9['done']?_0x41be57(_0x2918c9[a1_0x4d73('0x10')]):_0x4adb5f(_0x2918c9[a1_0x4d73('0x10')])[a1_0x4d73('0x4')](_0x2689c9,_0x15acdd);}_0x8b82bf((_0x5ed3a5=_0x5ed3a5[a1_0x4d73('0x12')](_0x57382b,_0x395369||[]))[a1_0x4d73('0x3')]());});};Object[a1_0x4d73('0x19')](exports,a1_0x4d73('0xa'),{'value':!![]});exports[a1_0x4d73('0x0')]=void 0x0;const axios_1=require('../../utilities/axios');const metric_logger_1=require(a1_0x4d73('0x14'));const {output}=require(a1_0x4d73('0x13'));class RunGroupApi{constructor(_0x1922df){this[a1_0x4d73('0xc')]=(0x0,axios_1['createApiAxiosInstance'])(_0x1922df);}[a1_0x4d73('0x5')](_0x59203e,_0x4d1972,_0x4d67f5,_0x45a483,_0x1ebab5,_0x116702,_0x29dde1){var _0x4f0dc2;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1bf7a6=(0x0,metric_logger_1['createMetricRecorder'])(a1_0x4d73('0x5'));try{const _0x42106e=yield(0x0,axios_1[a1_0x4d73('0xd')])(()=>this['apiAxiosInstance'][a1_0x4d73('0x8')](a1_0x4d73('0xb'),{'branch':_0x59203e,'runGroup':_0x4d1972,'ciExecutionId':_0x4d67f5,'ciExecutionEnv':_0x45a483,'stopAgentsOnFailure':_0x1ebab5,'agentCount':_0x116702,'stopAgentsAfter':_0x29dde1}));_0x1bf7a6['recordMetric']((0x0,metric_logger_1[a1_0x4d73('0x7')])(_0x42106e));}catch(_0x934f29){_0x1bf7a6['recordMetric'](((_0x4f0dc2=_0x934f29===null||_0x934f29===void 0x0?void 0x0:_0x934f29['axiosException'])===null||_0x4f0dc2===void 0x0?void 0x0:_0x4f0dc2['response'])?(0x0,metric_logger_1[a1_0x4d73('0x7')])(_0x934f29['axiosException']['response']):metric_logger_1[a1_0x4d73('0x2')]);output['error']({'title':_0x934f29['message']});process[a1_0x4d73('0x11')](0x1);}});}[a1_0x4d73('0xe')](_0x219f48,_0x1ee707,_0x3ae4d4,_0x2903c4){var _0x261a00;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x59cf3e=(0x0,metric_logger_1[a1_0x4d73('0x15')])(a1_0x4d73('0xe'));try{const _0x29ccf3=yield(0x0,axios_1[a1_0x4d73('0xd')])(()=>this[a1_0x4d73('0xc')]['post'](a1_0x4d73('0x1a'),{'branch':_0x219f48,'runGroup':_0x1ee707,'ciExecutionId':_0x3ae4d4,'ciExecutionEnv':_0x2903c4}));_0x59cf3e[a1_0x4d73('0x1')]((0x0,metric_logger_1[a1_0x4d73('0x7')])(_0x29ccf3));}catch(_0x213167){_0x59cf3e[a1_0x4d73('0x1')](((_0x261a00=_0x213167===null||_0x213167===void 0x0?void 0x0:_0x213167['axiosException'])===null||_0x261a00===void 0x0?void 0x0:_0x261a00[a1_0x4d73('0x17')])?(0x0,metric_logger_1[a1_0x4d73('0x7')])(_0x213167[a1_0x4d73('0x16')][a1_0x4d73('0x17')]):metric_logger_1[a1_0x4d73('0x2')]);output[a1_0x4d73('0x18')]({'title':_0x213167[a1_0x4d73('0x6')]});process['exit'](0x1);}});}}exports['RunGroupApi']=RunGroupApi;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RunGroupApi = void 0;
13
+ const axios_1 = require("../../utilities/axios");
14
+ const metric_logger_1 = require("../../utilities/metric-logger");
15
+ const { output } = require('../../utilities/nx-imports');
16
+ class RunGroupApi {
17
+ constructor(options) {
18
+ this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
19
+ }
20
+ createRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv, stopAgentsOnFailure, agentCount, stopAgentsAfter) {
21
+ var _a;
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
24
+ try {
25
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
26
+ branch,
27
+ runGroup,
28
+ ciExecutionId,
29
+ ciExecutionEnv,
30
+ stopAgentsOnFailure,
31
+ agentCount,
32
+ stopAgentsAfter,
33
+ }));
34
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
35
+ }
36
+ catch (e) {
37
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
38
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
39
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
40
+ output.error({
41
+ title: e.message,
42
+ });
43
+ process.exit(1);
44
+ }
45
+ });
46
+ }
47
+ completeRunGroup(branch, runGroup, ciExecutionId, ciExecutionEnv) {
48
+ var _a;
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
51
+ try {
52
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
53
+ branch,
54
+ runGroup,
55
+ ciExecutionId,
56
+ ciExecutionEnv,
57
+ }));
58
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
59
+ }
60
+ catch (e) {
61
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
62
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
63
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
64
+ output.error({
65
+ title: e.message,
66
+ });
67
+ process.exit(1);
68
+ }
69
+ });
70
+ }
71
+ }
72
+ exports.RunGroupApi = RunGroupApi;
73
+ //# sourceMappingURL=run-group.api.js.map
@@ -19,6 +19,7 @@ const id_generator_1 = require("../runners/cloud-enabled/id-generator");
19
19
  const message_reporter_1 = require("../terminal-output/message-reporter");
20
20
  const output_obfuscator_1 = require("../terminal-output/output-obfuscator");
21
21
  const read_task_terminal_output_1 = require("../terminal-output/read-task-terminal-output");
22
+ const stripJsonComments = require("strip-json-comments");
22
23
  const { workspaceRoot, output } = require('../../utilities/nx-imports');
23
24
  function uploadRunDetails(options) {
24
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -56,7 +57,7 @@ exports.uploadAndShowRunDetails = uploadAndShowRunDetails;
56
57
  function readOptions() {
57
58
  var _a, _b, _c;
58
59
  try {
59
- return (_c = (_b = (_a = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(workspaceRoot, 'nx.json')).toString())) === null || _a === void 0 ? void 0 : _a.tasksRunnerOptions) === null || _b === void 0 ? void 0 : _b.default) === null || _c === void 0 ? void 0 : _c.options;
60
+ return (_c = (_b = (_a = JSON.parse(stripJsonComments((0, fs_1.readFileSync)((0, path_1.join)(workspaceRoot, 'nx.json')).toString()))) === null || _a === void 0 ? void 0 : _a.tasksRunnerOptions) === null || _b === void 0 ? void 0 : _b.default) === null || _c === void 0 ? void 0 : _c.options;
60
61
  }
61
62
  catch (e) {
62
63
  return {};
@@ -1 +1 @@
1
- {"version":3,"file":"upload-and-show-run-details.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/commands/upload-and-show-run-details.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAAkC;AAClC,6BAA6B;AAC7B,+BAA4B;AAC5B,6DAGqC;AAErC,0EAAqE;AACrE,wEAA6E;AAC7E,0EAAsE;AACtE,4EAAwE;AACxE,4FAAsF;AAEtF,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAExE,SAAe,gBAAgB,CAAC,OAA+B;;QAC7D,MAAM,MAAM,GAAG,IAAI,kCAAe,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,EAAS,CAAC;QAC7B,MAAM,WAAW,GAAG,IAAA,4BAAc,EAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,IAAI,2BAAW,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAEtE,MAAM,SAAS,GAAG,IAAA,iCAAmB,EAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,gBAAgB,GAAG,IAAI,oCAAgB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAExE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CACxB,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,CACrD,CAAC;QAEF,mDAAmD;QACnD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCAClC,CAAC,KACJ,cAAc,EAAE,IAAA,kDAAsB,EACpC,SAAS,EACT,gBAAgB,EAChB,CAAC,CAAC,IAAI,EACN,CAAC,CAAC,WAAW,EACb,CAAC,CAAC,MAAM,CACT,IACD,CAAC,CAAC;QAEJ,MAAM,MAAM,GAAG,IAAA,mCAAoB,GAAE,CAAC;QACtC,MAAM,GAAG,CAAC,MAAM,CACd,OAAO,CAAC,GAAG,EACX,KAAK,EACL;YACE,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,IAAI;YACd,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE,IAAI;SACrB,EACD,MAAM,CACP,CAAC;QACF,OAAO,GAAG,OAAO,CAAC,GAAG,IAAI,gBAAgB,SAAS,MAAM,EAAE,CAAC;IAC7D,CAAC;CAAA;AAED,SAAsB,uBAAuB;;QAC3C,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC;YACb,KAAK,EAAE,uCAAuC;YAC9C,SAAS,EAAE,CAAC,uBAAuB,GAAG,EAAE,CAAC;SAC1C,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,CAAC;CAAA;AARD,0DAQC;AAED,SAAS,WAAW;;IAClB,IAAI;QACF,OAAO,MAAA,MAAA,MAAA,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,0CACtE,kBAAkB,0CAAE,OAAO,0CAAE,OAAO,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,EAA4B,CAAC;KACrC;AACH,CAAC"}
1
+ {"version":3,"file":"upload-and-show-run-details.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/commands/upload-and-show-run-details.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAAgC;AAChC,6BAA6B;AAC7B,+BAA0B;AAC1B,6DAGqC;AAErC,0EAAmE;AACnE,wEAA2E;AAC3E,0EAAoE;AACpE,4EAAsE;AACtE,4FAAoF;AACpF,yDAAyD;AAEzD,MAAM,EAAC,aAAa,EAAE,MAAM,EAAC,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAEtE,SAAe,gBAAgB,CAAC,OAA+B;;QAC7D,MAAM,MAAM,GAAG,IAAI,kCAAe,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,EAAS,CAAC;QAC7B,MAAM,WAAW,GAAG,IAAA,4BAAc,EAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,IAAI,2BAAW,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAEtE,MAAM,SAAS,GAAG,IAAA,iCAAmB,EAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,gBAAgB,GAAG,IAAI,oCAAgB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAExE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CACxB,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,CACrD,CAAC;QAEF,mDAAmD;QACnD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCAClC,CAAC,KACJ,cAAc,EAAE,IAAA,kDAAsB,EACpC,SAAS,EACT,gBAAgB,EAChB,CAAC,CAAC,IAAI,EACN,CAAC,CAAC,WAAW,EACb,CAAC,CAAC,MAAM,CACT,IACD,CAAC,CAAC;QAEJ,MAAM,MAAM,GAAG,IAAA,mCAAoB,GAAE,CAAC;QACtC,MAAM,GAAG,CAAC,MAAM,CACd,OAAO,CAAC,GAAG,EACX,KAAK,EACL;YACE,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,IAAI;YACd,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE,IAAI;SACrB,EACD,MAAM,CACP,CAAC;QACF,OAAO,GAAG,OAAO,CAAC,GAAG,IAAI,gBAAgB,SAAS,MAAM,EAAE,CAAC;IAC7D,CAAC;CAAA;AAED,SAAsB,uBAAuB;;QAC3C,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC;YACb,KAAK,EAAE,uCAAuC;YAC9C,SAAS,EAAE,CAAC,uBAAuB,GAAG,EAAE,CAAC;SAC1C,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,CAAC;CAAA;AARD,0DAQC;AAED,SAAS,WAAW;;IAClB,IAAI;QACF,OAAO,MAAA,MAAA,MAAA,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,0CACzF,kBAAkB,0CAAE,OAAO,0CAAE,OAAO,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,EAA4B,CAAC;KACrC;AACH,CAAC"}
@@ -1 +1,93 @@
1
- const a0_0x3327=['statuses','startTask','cacheStatus','runtime','push','npm:','serializeOverrides','taskId','obfuscate','defineProperty','CloudEnabledLifeCycle','tasks','forEach','code','find','startsWith','collectTerminalOutput','remote-cache','cacheDirectory','runContext','endTime','../../terminal-output/read-task-terminal-output','local-cache','hash','scheduledTasks','nodes','status','terminalOutput','Cannot\x20find\x20task\x20','endTasks','readTaskTerminalOutput','toISOString','cleanUpHashDetails','local-cache-hit','outputObfuscator','startTime','params','updateStartedTask','cache','cache-miss','task','local-cache-kept-existing','scheduleTask','__esModule','target','endCommand','remote-cache-hit','hashDetails'];(function(_0x1319c0,_0x332773){const _0x414463=function(_0x7ac01f){while(--_0x7ac01f){_0x1319c0['push'](_0x1319c0['shift']());}};_0x414463(++_0x332773);}(a0_0x3327,0xb4));const a0_0x4144=function(_0x1319c0,_0x332773){_0x1319c0=_0x1319c0-0x0;let _0x414463=a0_0x3327[_0x1319c0];return _0x414463;};'use strict';Object[a0_0x4144('0x15')](exports,a0_0x4144('0x7'),{'value':!![]});exports[a0_0x4144('0x16')]=void 0x0;const serializer_overrides_1=require('../../../utilities/serializer-overrides');const read_task_terminal_output_1=require(a0_0x4144('0x21'));class CloudEnabledLifeCycle{constructor(_0x2c1ffa,_0x595ef1,_0x16e654,_0x19bd53,_0x164b8f,_0x977fc0){this[a0_0x4144('0x1f')]=_0x2c1ffa;this[a0_0x4144('0x1e')]=_0x595ef1;this[a0_0x4144('0x1c')]=_0x16e654;this['cacheableOperations']=_0x19bd53;this[a0_0x4144('0x2e')]=_0x164b8f;this[a0_0x4144('0x17')]=_0x977fc0;}[a0_0x4144('0x6')](_0x3ae31f){this[a0_0x4144('0x1f')][a0_0x4144('0x24')][a0_0x4144('0x10')](_0x3ae31f);}[a0_0x4144('0xd')](_0x45c227){this[a0_0x4144('0x17')][a0_0x4144('0x10')]({'taskId':_0x45c227['id'],'startTime':new Date()['toISOString'](),'target':_0x45c227[a0_0x4144('0x8')]['target'],'projectName':_0x45c227[a0_0x4144('0x8')]['project'],'hash':_0x45c227['hash'],'hashDetails':this['cleanUpHashDetails'](_0x45c227[a0_0x4144('0xb')]),'params':(0x0,serializer_overrides_1[a0_0x4144('0x12')])(_0x45c227),'uploadedToStorage':![]});}[a0_0x4144('0x29')](_0x42e770){for(let _0x4b02b3 of _0x42e770){let _0x53e460;const _0x54e89=_0x4b02b3[a0_0x4144('0x26')]===a0_0x4144('0x1d');const _0x371b26=_0x4b02b3[a0_0x4144('0x26')]===a0_0x4144('0x2');const _0x194460=_0x4b02b3[a0_0x4144('0x26')]===a0_0x4144('0x22')||_0x4b02b3[a0_0x4144('0x26')]===a0_0x4144('0x5')||_0x371b26;if(this[a0_0x4144('0x1f')]['statuses'][_0x4b02b3[a0_0x4144('0x4')][a0_0x4144('0x23')]]){_0x53e460=this['runContext'][a0_0x4144('0xc')][_0x4b02b3[a0_0x4144('0x4')][a0_0x4144('0x23')]];}else if(_0x54e89){_0x53e460=a0_0x4144('0xa');}else if(_0x194460){_0x53e460=a0_0x4144('0x2d');}else{_0x53e460=a0_0x4144('0x3');}this[a0_0x4144('0x1')](_0x4b02b3,_0x53e460);}}[a0_0x4144('0x9')](){}['updateStartedTask'](_0x235373,_0x319a99){const _0x202eea=this[a0_0x4144('0x17')][a0_0x4144('0x1a')](_0x2e88c6=>_0x2e88c6[a0_0x4144('0x13')]===_0x235373['task']['id']);if(!_0x202eea){throw new Error(a0_0x4144('0x28')+_0x235373[a0_0x4144('0x4')]['id']);}if((_0x235373===null||_0x235373===void 0x0?void 0x0:_0x235373[a0_0x4144('0x2f')])&&(_0x235373===null||_0x235373===void 0x0?void 0x0:_0x235373[a0_0x4144('0x20')])){_0x202eea[a0_0x4144('0x2f')]=new Date(_0x235373[a0_0x4144('0x2f')])[a0_0x4144('0x2b')]();_0x202eea[a0_0x4144('0x20')]=new Date(_0x235373['endTime'])['toISOString']();}else{_0x202eea['endTime']=new Date()['toISOString']();}_0x202eea['status']=_0x235373[a0_0x4144('0x19')];_0x202eea[a0_0x4144('0x0')]=this['outputObfuscator'][a0_0x4144('0x14')](_0x202eea['params']);_0x202eea[a0_0x4144('0xe')]=_0x319a99;if(this[a0_0x4144('0x1c')]){_0x202eea[a0_0x4144('0x27')]=this['getTerminalOutput'](_0x235373[a0_0x4144('0x4')][a0_0x4144('0x23')],_0x202eea[a0_0x4144('0xe')],_0x235373['code']);}}['getTerminalOutput'](_0x16485c,_0x44d0aa,_0x4bbc76){return(0x0,read_task_terminal_output_1[a0_0x4144('0x2a')])(this['cacheDirectory'],this[a0_0x4144('0x2e')],_0x16485c,_0x44d0aa,_0x4bbc76);}[a0_0x4144('0x2c')](_0xb360af){const _0x4a46ef={};Object['keys'](_0xb360af[a0_0x4144('0x25')])['filter'](_0x4845b0=>!_0x4845b0[a0_0x4144('0x1b')](a0_0x4144('0x11')))[a0_0x4144('0x18')](_0x24bef8=>{_0x4a46ef[_0x24bef8]=_0xb360af[a0_0x4144('0x25')][_0x24bef8];});return{'nodes':_0x4a46ef,'runtime':_0xb360af[a0_0x4144('0xf')],'implicitDeps':_0xb360af['implicitDeps']};}}exports[a0_0x4144('0x16')]=CloudEnabledLifeCycle;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudEnabledLifeCycle = void 0;
4
+ const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
5
+ const read_task_terminal_output_1 = require("../../terminal-output/read-task-terminal-output");
6
+ class CloudEnabledLifeCycle {
7
+ constructor(runContext, cacheDirectory, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
8
+ this.runContext = runContext;
9
+ this.cacheDirectory = cacheDirectory;
10
+ this.collectTerminalOutput = collectTerminalOutput;
11
+ this.cacheableOperations = cacheableOperations;
12
+ this.outputObfuscator = outputObfuscator;
13
+ this.tasks = tasks;
14
+ }
15
+ scheduleTask(task) {
16
+ this.runContext.scheduledTasks.push(task);
17
+ }
18
+ // this gets called for every tasks that starts.
19
+ startTask(task) {
20
+ this.tasks.push({
21
+ taskId: task.id,
22
+ startTime: new Date().toISOString(),
23
+ target: task.target.target,
24
+ projectName: task.target.project,
25
+ hash: task.hash,
26
+ hashDetails: this.cleanUpHashDetails(task.hashDetails),
27
+ params: (0, serializer_overrides_1.serializeOverrides)(task),
28
+ uploadedToStorage: false,
29
+ });
30
+ }
31
+ endTasks(tasks) {
32
+ // this can be called multiple times changing this time.
33
+ for (let t of tasks) {
34
+ let cacheStatus;
35
+ const taskIsRemoteCacheHit = t.status === 'remote-cache';
36
+ const taskIsLocalCacheHitPreNx135 = t.status === 'cache';
37
+ const taskIsLocalCacheHit = t.status === 'local-cache' ||
38
+ t.status === 'local-cache-kept-existing' ||
39
+ taskIsLocalCacheHitPreNx135;
40
+ if (this.runContext.statuses[t.task.hash]) {
41
+ cacheStatus = this.runContext.statuses[t.task.hash];
42
+ }
43
+ else if (taskIsRemoteCacheHit) {
44
+ cacheStatus = 'remote-cache-hit';
45
+ }
46
+ else if (taskIsLocalCacheHit) {
47
+ cacheStatus = 'local-cache-hit';
48
+ }
49
+ else {
50
+ cacheStatus = 'cache-miss';
51
+ }
52
+ this.updateStartedTask(t, cacheStatus);
53
+ }
54
+ }
55
+ endCommand() { }
56
+ updateStartedTask(result, cacheStatus) {
57
+ const startedTask = this.tasks.find((t) => t.taskId === result.task.id);
58
+ if (!startedTask) {
59
+ throw new Error(`Cannot find task ${result.task.id}`);
60
+ }
61
+ if ((result === null || result === void 0 ? void 0 : result.startTime) && (result === null || result === void 0 ? void 0 : result.endTime)) {
62
+ startedTask.startTime = new Date(result.startTime).toISOString();
63
+ startedTask.endTime = new Date(result.endTime).toISOString();
64
+ }
65
+ else {
66
+ startedTask.endTime = new Date().toISOString();
67
+ }
68
+ startedTask.status = result.code;
69
+ startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
70
+ startedTask.cacheStatus = cacheStatus;
71
+ if (this.collectTerminalOutput) {
72
+ startedTask.terminalOutput = this.getTerminalOutput(result.task.hash, startedTask.cacheStatus, result.code);
73
+ }
74
+ }
75
+ getTerminalOutput(hash, cacheStatus, code) {
76
+ return (0, read_task_terminal_output_1.readTaskTerminalOutput)(this.cacheDirectory, this.outputObfuscator, hash, cacheStatus, code);
77
+ }
78
+ cleanUpHashDetails(hashDetails) {
79
+ const nodes = {};
80
+ Object.keys(hashDetails.nodes)
81
+ .filter((k) => !k.startsWith('npm:'))
82
+ .forEach((k) => {
83
+ nodes[k] = hashDetails.nodes[k];
84
+ });
85
+ return {
86
+ nodes,
87
+ runtime: hashDetails.runtime,
88
+ implicitDeps: hashDetails.implicitDeps,
89
+ };
90
+ }
91
+ }
92
+ exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
93
+ //# sourceMappingURL=cloud-enabled-life-cycle.js.map
@@ -1 +1,320 @@
1
- const a1_0xc253=['catch','printCacheHitsMessage','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','forEach','waitForStoreRequestsToComplete','uploadedToStorage','path','../../terminal-output/message-reporter','local-cache-hit','processInBackground','../../api/error-reporter.api','__awaiter','../../file-storage/e2e-encryption','./cloud-enabled-life-cycle','../../../utilities/environment','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','toString','assign','.commit','MessageReporter','anyErrors','warn','subscribe','join','all','/runs/','startRun','E2EEncryption','CloudRunApi','ACCESS_TOKEN','length','store','../../terminal-output/end-of-run-message','FileStorage','runUrl','toISOString','agentRunningInDistributedExecution','enabled','value','storedHashes','generateUniqueLinkId','Task\x20with\x20hash\x20','Nx\x20Cloud\x20Problems','Executed\x20tasks\x20with\x20hashes:\x20','./cloud-run.api','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','push','OutputObfuscator','getRunGroup','ENCRYPTION_KEY','error','\x20isn\x27t\x20recorded','next','getNxCacheDirectory','daemon','apply','../../../utilities/nx-imports','defineProperty','printMessages','maskedProperties','extractGitSha','exit','parseCommand','writeFileSync','then','hash','encryptionKey','obfuscate','url','submitRunMetrics','skipNxCache','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','note','endRun','cacheStatus','getMachineInfo','delayedStoreRequests','https://nx.app','ErrorReporterApi','map','cacheableOperations','cloud-enabled-runner','../../../utilities/metric-logger','lifeCycle','fs-extra','env','filter','cloudEnabledTasksRunner','./id-generator','pathExists','CloudEnabledLifeCycle','throw','message'];(function(_0x2b2dcb,_0xc2534a){const _0x5d87e9=function(_0x23c0fa){while(--_0x23c0fa){_0x2b2dcb['push'](_0x2b2dcb['shift']());}};_0x5d87e9(++_0xc2534a);}(a1_0xc253,0x119));const a1_0x5d87=function(_0x2b2dcb,_0xc2534a){_0x2b2dcb=_0x2b2dcb-0x0;let _0x5d87e9=a1_0xc253[_0x2b2dcb];return _0x5d87e9;};'use strict';var __awaiter=this&&this[a1_0x5d87('0x9')]||function(_0x94cdbd,_0x45b061,_0xefae78,_0x4153cf){function _0x137ae9(_0x2bd1d8){return _0x2bd1d8 instanceof _0xefae78?_0x2bd1d8:new _0xefae78(function(_0x4ed6a1){_0x4ed6a1(_0x2bd1d8);});}return new(_0xefae78||(_0xefae78=Promise))(function(_0x396bb3,_0x359d0b){function _0x23a414(_0x4a79e7){try{_0x5e8bbb(_0x4153cf['next'](_0x4a79e7));}catch(_0x1a53da){_0x359d0b(_0x1a53da);}}function _0x5870c1(_0x43f339){try{_0x5e8bbb(_0x4153cf[a1_0x5d87('0x59')](_0x43f339));}catch(_0x3a3899){_0x359d0b(_0x3a3899);}}function _0x5e8bbb(_0x3e3a96){_0x3e3a96['done']?_0x396bb3(_0x3e3a96[a1_0x5d87('0x24')]):_0x137ae9(_0x3e3a96[a1_0x5d87('0x24')])[a1_0x5d87('0x3e')](_0x23a414,_0x5870c1);}_0x5e8bbb((_0x4153cf=_0x4153cf[a1_0x5d87('0x35')](_0x94cdbd,_0x45b061||[]))['next']());});};Object[a1_0x5d87('0x37')](exports,'__esModule',{'value':!![]});exports[a1_0x5d87('0x55')]=void 0x0;const message_reporter_1=require(a1_0x5d87('0x5'));const end_of_run_message_1=require(a1_0x5d87('0x1e'));const output_obfuscator_1=require('../../terminal-output/output-obfuscator');const cloud_enabled_life_cycle_1=require(a1_0x5d87('0xb'));const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require(a1_0x5d87('0xa'));const environment_1=require(a1_0x5d87('0xc'));const cloud_remote_cache_1=require('./cloud-remote-cache');const cloud_run_api_1=require(a1_0x5d87('0x2a'));const fs_1=require('fs');const path=require(a1_0x5d87('0x4'));const path_1=require(a1_0x5d87('0x4'));const metric_logger_1=require(a1_0x5d87('0x50'));const error_reporter_api_1=require(a1_0x5d87('0x8'));const fs_extra_1=require(a1_0x5d87('0x52'));const id_generator_1=require(a1_0x5d87('0x56'));const {tasksRunner,output}=require('../../../utilities/nx-imports');function createApi(_0x1ce2d6,_0x7d5b72,_0x2408cb){const _0x9c1303=(0x0,environment_1[a1_0x5d87('0x49')])(_0x7d5b72);return new cloud_run_api_1[(a1_0x5d87('0x1a'))](_0x1ce2d6,_0x2408cb,_0x7d5b72,_0x9c1303);}function storeTaskHashes(_0x580314,_0x20219d,_0x222e36){const _0x2ddb4f=JSON['stringify'](_0x580314[a1_0x5d87('0x4d')](_0x3c7665=>({'taskId':_0x3c7665['taskId'],'hash':_0x3c7665['hash']})));if(environment_1['VERBOSE_LOGGING']){output[a1_0x5d87('0x46')]({'title':a1_0x5d87('0x29')+_0x2ddb4f});}(0x0,fs_1[a1_0x5d87('0x3d')])(path[a1_0x5d87('0x15')](_0x20219d,'tasks-hashes-'+_0x222e36),_0x2ddb4f);}function storeLocalCacheHits(_0x5977a8,_0x37dde6,_0x10d448){const _0x36b3e9=_0x5977a8['filter'](_0x15f265=>_0x15f265[a1_0x5d87('0x48')]===a1_0x5d87('0x6'))['map'](_0xfea422=>_0xfea422['hash']);_0x36b3e9[a1_0x5d87('0x1')](_0x18efaa=>_0x37dde6[a1_0x5d87('0x1d')](_0x18efaa,_0x10d448));}function onComplete({daemon,options,fileStorage,remoteCache,api,outputObfuscator,runStartTime,messages,endOfRunMessage,taskExecutions,versionOfNxBefore133,inner,encryptionKey,storeInCurrentProcess,distributedExecutionId,runContext}){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x584b9=new Date()[a1_0x5d87('0x21')]();const _0x4060e2=(0x0,environment_1['getBranch'])();const _0x208e54={'command':outputObfuscator[a1_0x5d87('0x41')]((0x0,environment_1[a1_0x5d87('0x3c')])()),'startTime':runStartTime,'endTime':_0x584b9,'distributedExecutionId':distributedExecutionId,'branch':_0x4060e2,'runGroup':(0x0,environment_1[a1_0x5d87('0x2e')])(),'sha':_0x4060e2?(0x0,environment_1[a1_0x5d87('0x3a')])():undefined,'inner':inner};const _0x2af393={'branch':_0x4060e2,'runGroup':(0x0,environment_1[a1_0x5d87('0x2e')])(),'ciExecutionId':(0x0,environment_1['getCIExecutionId'])(),'ciExecutionEnv':(0x0,environment_1['getCIExecutionEnv'])()};if(storeInCurrentProcess){if((0x0,environment_1['agentRunningInDistributedExecution'])(distributedExecutionId)){const _0x192670=(0x0,environment_1[a1_0x5d87('0x33')])(options);storeTaskHashes(taskExecutions,_0x192670,distributedExecutionId);storeLocalCacheHits(taskExecutions,remoteCache,_0x192670);}try{yield remoteCache[a1_0x5d87('0x2')]();}catch(_0x122c61){output['error']({'title':a1_0x5d87('0x45')});messages[a1_0x5d87('0x38')]();return![];}for(const _0x1421f2 of fileStorage[a1_0x5d87('0x25')]){const _0x795843=taskExecutions['find'](_0x4b51f8=>_0x4b51f8[a1_0x5d87('0x3f')]===_0x1421f2);if(!_0x795843){throw new Error(a1_0x5d87('0x27')+_0x1421f2+a1_0x5d87('0x31'));}_0x795843[a1_0x5d87('0x3')]=!![];}try{yield api[a1_0x5d87('0x47')](_0x208e54,taskExecutions,_0x2af393);}catch(_0x99c057){output[a1_0x5d87('0x30')]({'title':a1_0x5d87('0x0')});messages[a1_0x5d87('0x38')]();return![];}yield(0x0,metric_logger_1[a1_0x5d87('0x43')])(options);}else{try{const _0x4c8b71=environment_1['ACCESS_TOKEN']?environment_1[a1_0x5d87('0x1b')]:options['accessToken'];const _0x7d39ca=(0x0,id_generator_1[a1_0x5d87('0x26')])();yield daemon[a1_0x5d87('0x7')]('@nrwl/nx-cloud/lib/daemon/process-run-end',{'encryptionKey':encryptionKey,'runnerOptions':Object['assign'](Object['assign']({},options),{'accessToken':_0x4c8b71}),'delayedStoreRequests':remoteCache[a1_0x5d87('0x4a')],'ciExecutionContext':_0x2af393,'runEnd':{'runData':_0x208e54,'taskExecutions':taskExecutions,'linkId':_0x7d39ca}});runContext[a1_0x5d87('0x20')]=(options[a1_0x5d87('0x42')]||a1_0x5d87('0x4b'))+a1_0x5d87('0x17')+_0x7d39ca;}catch(_0x154eb7){output[a1_0x5d87('0x13')]({'title':a1_0x5d87('0x28'),'bodyLines':[_0x154eb7[a1_0x5d87('0x5a')]||_0x154eb7[a1_0x5d87('0xe')]()]});return![];}}if(versionOfNxBefore133){setTimeout(()=>{messages[a1_0x5d87('0x38')]();if(!messages['anyErrors']&&!inner){endOfRunMessage[a1_0x5d87('0x5c')]();}},0x0);}else{messages[a1_0x5d87('0x38')]();if(!messages[a1_0x5d87('0x12')]&&!inner){endOfRunMessage[a1_0x5d87('0x5c')]();}}return!![];});}function createLifeCycle(_0x1f4052,_0x20a383,_0x131a53,_0x2f3848){const _0x232f80=new cloud_enabled_life_cycle_1[(a1_0x5d87('0x58'))](_0x1f4052,(0x0,environment_1[a1_0x5d87('0x33')])(_0x20a383),!![],_0x20a383[a1_0x5d87('0x4e')]||[],_0x131a53,_0x2f3848);try{const {CompositeLifeCycle}=require(a1_0x5d87('0x36'));if(!CompositeLifeCycle)return _0x232f80;return new CompositeLifeCycle([_0x20a383[a1_0x5d87('0x51')],_0x232f80]);}catch(_0x5762a7){return _0x232f80;}}function fetchUrlsForKnownHashesUpfront(_0x1df3f4,_0x17c20a,_0x333997,_0x4df216,_0x98ca5b){return __awaiter(this,void 0x0,void 0x0,function*(){if(_0x4df216[a1_0x5d87('0x44')])return;let _0x5515d7=_0x333997['map'](_0x318d01=>_0x318d01[a1_0x5d87('0x3f')])[a1_0x5d87('0x54')](_0x537bbd=>!!_0x537bbd);const _0x1f7e02=(0x0,environment_1[a1_0x5d87('0x33')])(_0x4df216);const _0x44064a=yield Promise[a1_0x5d87('0x16')](_0x5515d7[a1_0x5d87('0x4d')](_0x1eb3a1=>{const _0x47f44f=(0x0,path_1[a1_0x5d87('0x15')])(_0x1f7e02,_0x1eb3a1+a1_0x5d87('0x10'));return(0x0,fs_extra_1[a1_0x5d87('0x57')])(_0x47f44f);}));const _0x3628e4=[];for(let _0x5b68ac=0x0;_0x5b68ac<_0x44064a['length'];++_0x5b68ac){if(!_0x44064a[_0x5b68ac]){_0x3628e4[a1_0x5d87('0x2c')](_0x5515d7[_0x5b68ac]);}}if(_0x3628e4[a1_0x5d87('0x1c')]>0x0){const _0x18a2c4=_0x1df3f4[a1_0x5d87('0x18')](_0x98ca5b,_0x3628e4);for(const _0x5790e0 of _0x3628e4){_0x17c20a['requests'][_0x5790e0]=_0x18a2c4;}}});}function cloudEnabledTasksRunner(_0xf4755a,_0x3bcc87,_0x1a4110,_0x584ec8=![]){var _0x13699f;const _0xea4caa=process[a1_0x5d87('0x53')]['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'];const _0xb145c6={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0xf4755a};const _0x41cfde=_0x3bcc87[a1_0x5d87('0x51')]===undefined;const _0x18b9d2=[];const _0x1a28b1=new message_reporter_1[(a1_0x5d87('0x11'))](_0x3bcc87);const _0x50eb71=createApi(_0x1a28b1,_0x3bcc87,_0xb145c6);const _0x2f53e1=new end_of_run_message_1['EndOfRunMessage'](_0xb145c6,_0x18b9d2,_0xea4caa);const _0x2ba217=new output_obfuscator_1[(a1_0x5d87('0x2d'))](_0x3bcc87[a1_0x5d87('0x39')]);const _0x25359b=new Date()[a1_0x5d87('0x21')]();const _0x4420c5=createLifeCycle(_0xb145c6,_0x3bcc87,_0x2ba217,_0x18b9d2);const _0x309c71=environment_1[a1_0x5d87('0x2f')]||_0x3bcc87[a1_0x5d87('0x40')];const _0x22947a=new e2e_encryption_1[(a1_0x5d87('0x19'))](_0x309c71);const _0x2f6db4=new error_reporter_api_1[(a1_0x5d87('0x4c'))](_0x3bcc87);const _0x3adc6f=(0x0,environment_1[a1_0x5d87('0x22')])(_0xea4caa)||!((_0x13699f=_0x1a4110[a1_0x5d87('0x34')])===null||_0x13699f===void 0x0?void 0x0:_0x13699f[a1_0x5d87('0x23')]());const _0x361666=new file_storage_1[(a1_0x5d87('0x1f'))](_0x22947a,_0x2f6db4,_0x3bcc87,a1_0x5d87('0x4f'));const _0xdc725a=new cloud_remote_cache_1['CloudRemoteCache'](_0x1a28b1,_0x50eb71,_0xb145c6,_0x361666,_0xea4caa,_0x3adc6f);fetchUrlsForKnownHashesUpfront(_0x50eb71,_0xb145c6,_0xf4755a,_0x3bcc87,_0xea4caa);delete process[a1_0x5d87('0x53')][a1_0x5d87('0xd')];const _0x2ffd0f=tasksRunner(_0xf4755a,Object[a1_0x5d87('0xf')](Object['assign']({},_0x3bcc87),{'remoteCache':_0xdc725a,'lifeCycle':_0x4420c5}),_0x1a4110);if(_0x2ffd0f[a1_0x5d87('0x14')]){const {Subject}=require('rxjs/internal/Subject');const _0x593bd4=new Subject();_0x2ffd0f['subscribe']({'next':_0x2455b2=>_0x593bd4[a1_0x5d87('0x32')](_0x2455b2),'error':_0x514698=>_0x593bd4[a1_0x5d87('0x30')](_0x514698),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x3b0a21=yield onComplete({'daemon':_0x1a4110[a1_0x5d87('0x34')],'options':_0x3bcc87,'fileStorage':_0x361666,'remoteCache':_0xdc725a,'api':_0x50eb71,'outputObfuscator':_0x2ba217,'runStartTime':_0x25359b,'messages':_0x1a28b1,'endOfRunMessage':_0x2f53e1,'taskExecutions':_0x18b9d2,'versionOfNxBefore133':_0x41cfde,'inner':_0x584ec8,'encryptionKey':_0x309c71,'storeInCurrentProcess':_0x3adc6f,'runContext':_0xb145c6,'distributedExecutionId':_0xea4caa});if(!_0x3b0a21&&(0x0,environment_1['agentRunningInDistributedExecution'])(_0xea4caa)){process[a1_0x5d87('0x3b')](environment_1[a1_0x5d87('0x2b')]);}_0x593bd4['complete']();})});return _0x593bd4;}else{return _0x2ffd0f[a1_0x5d87('0x3e')](_0x479f3a=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x5ee2ad=yield onComplete({'daemon':_0x1a4110[a1_0x5d87('0x34')],'options':_0x3bcc87,'fileStorage':_0x361666,'remoteCache':_0xdc725a,'api':_0x50eb71,'outputObfuscator':_0x2ba217,'runStartTime':_0x25359b,'messages':_0x1a28b1,'endOfRunMessage':_0x2f53e1,'taskExecutions':_0x18b9d2,'versionOfNxBefore133':_0x41cfde,'inner':_0x584ec8,'encryptionKey':_0x309c71,'storeInCurrentProcess':_0x3adc6f,'runContext':_0xb145c6,'distributedExecutionId':_0xea4caa});if(!_0x5ee2ad&&(0x0,environment_1[a1_0x5d87('0x22')])(_0xea4caa)){process[a1_0x5d87('0x3b')](environment_1[a1_0x5d87('0x2b')]);}return _0x479f3a;}))[a1_0x5d87('0x5b')](_0x257d5e=>__awaiter(this,void 0x0,void 0x0,function*(){const _0x34feaf=yield onComplete({'daemon':_0x1a4110['daemon'],'options':_0x3bcc87,'fileStorage':_0x361666,'remoteCache':_0xdc725a,'api':_0x50eb71,'outputObfuscator':_0x2ba217,'runStartTime':_0x25359b,'messages':_0x1a28b1,'endOfRunMessage':_0x2f53e1,'taskExecutions':_0x18b9d2,'versionOfNxBefore133':_0x41cfde,'inner':_0x584ec8,'encryptionKey':_0x309c71,'storeInCurrentProcess':_0x3adc6f,'runContext':_0xb145c6,'distributedExecutionId':_0xea4caa});if(!_0x34feaf&&(0x0,environment_1['agentRunningInDistributedExecution'])(_0xea4caa)){process[a1_0x5d87('0x3b')](environment_1[a1_0x5d87('0x2b')]);}throw _0x257d5e;}));}}exports[a1_0x5d87('0x55')]=cloudEnabledTasksRunner;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.cloudEnabledTasksRunner = void 0;
13
+ const message_reporter_1 = require("../../terminal-output/message-reporter");
14
+ const end_of_run_message_1 = require("../../terminal-output/end-of-run-message");
15
+ const output_obfuscator_1 = require("../../terminal-output/output-obfuscator");
16
+ const cloud_enabled_life_cycle_1 = require("./cloud-enabled-life-cycle");
17
+ const file_storage_1 = require("../../file-storage/file-storage");
18
+ const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
19
+ const environment_1 = require("../../../utilities/environment");
20
+ const cloud_remote_cache_1 = require("./cloud-remote-cache");
21
+ const cloud_run_api_1 = require("./cloud-run.api");
22
+ const fs_1 = require("fs");
23
+ const path = require("path");
24
+ const path_1 = require("path");
25
+ const metric_logger_1 = require("../../../utilities/metric-logger");
26
+ const error_reporter_api_1 = require("../../api/error-reporter.api");
27
+ const fs_extra_1 = require("fs-extra");
28
+ const id_generator_1 = require("./id-generator");
29
+ const { tasksRunner, output } = require('../../../utilities/nx-imports');
30
+ function createApi(errors, options, runContext) {
31
+ const machineInfo = (0, environment_1.getMachineInfo)(options);
32
+ return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
33
+ }
34
+ function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
35
+ const hashes = JSON.stringify(taskExecutions.map((t) => ({
36
+ taskId: t.taskId,
37
+ hash: t.hash,
38
+ })));
39
+ if (environment_1.VERBOSE_LOGGING) {
40
+ output.note({
41
+ title: `Executed tasks with hashes: ${hashes}`,
42
+ });
43
+ }
44
+ (0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
45
+ }
46
+ /*
47
+ * It can happen that a task is executed multiple times on an agent, say for DTE1 and DTE2.
48
+ * When it runs for DTE2, it will be a local cache hit, so it will be marked as completed.
49
+ * However, Nx won't upload an artifact to S3 in this case. Usually this isn't a problem,
50
+ * cause the first DTE would have uploaded it. But if you are using a DTE, with a read-only token,
51
+ * the uploaded artifact will have a different scoped hash.
52
+ *
53
+ * To address this: we are finding all local cache hits, and upload everything that has a put url.
54
+ */
55
+ function storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory) {
56
+ const hashes = taskExecutions
57
+ .filter((t) => t.cacheStatus === 'local-cache-hit')
58
+ .map((t) => t.hash);
59
+ hashes.forEach((hash) => remoteCache.store(hash, nxCacheDirectory));
60
+ }
61
+ function onComplete({ daemon, options, fileStorage, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner, encryptionKey, storeInCurrentProcess, distributedExecutionId, runContext, }) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const runEndTime = new Date().toISOString();
64
+ const branch = (0, environment_1.getBranch)();
65
+ const runData = {
66
+ command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
67
+ startTime: runStartTime,
68
+ endTime: runEndTime,
69
+ distributedExecutionId,
70
+ branch: branch,
71
+ runGroup: (0, environment_1.getRunGroup)(),
72
+ // only set sha if branch is set because we invoke a separate process,
73
+ // which adds a few millis
74
+ sha: branch ? (0, environment_1.extractGitSha)() : undefined,
75
+ inner: inner,
76
+ };
77
+ const ciExecutionContext = {
78
+ branch: branch,
79
+ runGroup: (0, environment_1.getRunGroup)(),
80
+ ciExecutionId: (0, environment_1.getCIExecutionId)(),
81
+ ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
82
+ };
83
+ if (storeInCurrentProcess) {
84
+ if ((0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
85
+ const nxCacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
86
+ storeTaskHashes(taskExecutions, nxCacheDirectory, distributedExecutionId);
87
+ storeLocalCacheHits(taskExecutions, remoteCache, nxCacheDirectory);
88
+ }
89
+ try {
90
+ yield remoteCache.waitForStoreRequestsToComplete();
91
+ }
92
+ catch (e) {
93
+ output.error({
94
+ title: `Nx Cloud wasn't able to store artifacts.`,
95
+ });
96
+ messages.printMessages();
97
+ return false;
98
+ }
99
+ for (const hash of fileStorage.storedHashes) {
100
+ const matchingTask = taskExecutions.find((t) => t.hash === hash);
101
+ if (!matchingTask) {
102
+ throw new Error(`Task with hash ${hash} isn't recorded`);
103
+ }
104
+ matchingTask.uploadedToStorage = true;
105
+ }
106
+ try {
107
+ yield api.endRun(runData, taskExecutions, ciExecutionContext);
108
+ }
109
+ catch (e) {
110
+ output.error({
111
+ title: `Nx Cloud wasn't able to record its run.`,
112
+ });
113
+ messages.printMessages();
114
+ return false;
115
+ }
116
+ yield (0, metric_logger_1.submitRunMetrics)(options);
117
+ }
118
+ else {
119
+ try {
120
+ const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken;
121
+ const linkId = (0, id_generator_1.generateUniqueLinkId)();
122
+ yield daemon.processInBackground('@nrwl/nx-cloud/lib/daemon/process-run-end', {
123
+ encryptionKey,
124
+ runnerOptions: Object.assign(Object.assign({}, options), { accessToken }),
125
+ delayedStoreRequests: remoteCache.delayedStoreRequests,
126
+ ciExecutionContext,
127
+ runEnd: {
128
+ runData,
129
+ taskExecutions,
130
+ linkId,
131
+ },
132
+ });
133
+ runContext.runUrl = `${options.url || 'https://nx.app'}/runs/${linkId}`;
134
+ }
135
+ catch (e) {
136
+ output.warn({
137
+ title: `Nx Cloud Problems`,
138
+ bodyLines: [e.message || e.toString()],
139
+ });
140
+ return false;
141
+ }
142
+ }
143
+ // this workaround is required because prior to Nx 13.3 we printed
144
+ // the end message after the runner completes, so we need to wait for the
145
+ // message to appear in the right place
146
+ if (versionOfNxBefore133) {
147
+ setTimeout(() => {
148
+ messages.printMessages();
149
+ if (!messages.anyErrors && !inner) {
150
+ endOfRunMessage.printCacheHitsMessage();
151
+ }
152
+ }, 0);
153
+ }
154
+ else {
155
+ messages.printMessages();
156
+ if (!messages.anyErrors && !inner) {
157
+ endOfRunMessage.printCacheHitsMessage();
158
+ }
159
+ }
160
+ return true;
161
+ });
162
+ }
163
+ function createLifeCycle(runContext, options, outputObfuscator, tasks) {
164
+ const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, (0, environment_1.getNxCacheDirectory)(options), true, options.cacheableOperations || [], outputObfuscator, tasks);
165
+ try {
166
+ const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
167
+ if (!CompositeLifeCycle)
168
+ return cloudEnabledLifeCycle;
169
+ return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
170
+ }
171
+ catch (e) {
172
+ return cloudEnabledLifeCycle;
173
+ }
174
+ }
175
+ function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId) {
176
+ return __awaiter(this, void 0, void 0, function* () {
177
+ if (options.skipNxCache)
178
+ return;
179
+ let hashes = tasks.map((t) => t.hash).filter((h) => !!h);
180
+ const cachePath = (0, environment_1.getNxCacheDirectory)(options);
181
+ // filter out the urls that don't have artifact stored locally
182
+ const exists = yield Promise.all(hashes.map((hash) => {
183
+ const tdCommit = (0, path_1.join)(cachePath, `${hash}.commit`);
184
+ return (0, fs_extra_1.pathExists)(tdCommit);
185
+ }));
186
+ const missingHashes = [];
187
+ for (let i = 0; i < exists.length; ++i) {
188
+ if (!exists[i]) {
189
+ missingHashes.push(hashes[i]);
190
+ }
191
+ }
192
+ if (missingHashes.length > 0) {
193
+ const startRunRequest = api.startRun(distributedExecutionId, missingHashes);
194
+ for (const hash of missingHashes) {
195
+ runContext.requests[hash] = startRunRequest;
196
+ }
197
+ }
198
+ });
199
+ }
200
+ function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
201
+ var _a;
202
+ const distributedExecutionId = process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
203
+ const runContext = {
204
+ statuses: {},
205
+ scheduledTasks: [],
206
+ requests: {},
207
+ allTasks: tasks,
208
+ };
209
+ const versionOfNxBefore133 = options.lifeCycle === undefined;
210
+ const taskExecutions = [];
211
+ const messages = new message_reporter_1.MessageReporter(options);
212
+ const api = createApi(messages, options, runContext);
213
+ const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions, distributedExecutionId);
214
+ const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
215
+ const runStartTime = new Date().toISOString();
216
+ const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
217
+ const encryptionKey = environment_1.ENCRYPTION_KEY || options.encryptionKey;
218
+ const encryption = new e2e_encryption_1.E2EEncryption(encryptionKey);
219
+ const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
220
+ const storeInCurrentProcess = (0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId) ||
221
+ !((_a = context.daemon) === null || _a === void 0 ? void 0 : _a.enabled());
222
+ const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, options, 'cloud-enabled-runner');
223
+ const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess);
224
+ // we don't await for it cause this step is optional
225
+ fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options, distributedExecutionId);
226
+ // have to reset it so we don't capture inner tasks
227
+ delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
228
+ const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
229
+ // observable -> legacy
230
+ if (res.subscribe) {
231
+ const { Subject } = require('rxjs/internal/Subject');
232
+ const wrappedRes = new Subject();
233
+ res.subscribe({
234
+ next: (value) => wrappedRes.next(value),
235
+ error: (err) => wrappedRes.error(err),
236
+ complete: () => __awaiter(this, void 0, void 0, function* () {
237
+ const success = yield onComplete({
238
+ daemon: context.daemon,
239
+ options,
240
+ fileStorage,
241
+ remoteCache,
242
+ api,
243
+ outputObfuscator,
244
+ runStartTime,
245
+ messages,
246
+ endOfRunMessage,
247
+ taskExecutions,
248
+ versionOfNxBefore133,
249
+ inner,
250
+ encryptionKey,
251
+ storeInCurrentProcess,
252
+ runContext,
253
+ distributedExecutionId,
254
+ });
255
+ if (!success &&
256
+ (0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
257
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
258
+ }
259
+ wrappedRes.complete();
260
+ }),
261
+ });
262
+ return wrappedRes;
263
+ // promise
264
+ }
265
+ else {
266
+ return res
267
+ .then((r) => __awaiter(this, void 0, void 0, function* () {
268
+ const success = yield onComplete({
269
+ daemon: context.daemon,
270
+ options,
271
+ fileStorage,
272
+ remoteCache,
273
+ api,
274
+ outputObfuscator,
275
+ runStartTime,
276
+ messages,
277
+ endOfRunMessage,
278
+ taskExecutions,
279
+ versionOfNxBefore133,
280
+ inner,
281
+ encryptionKey,
282
+ storeInCurrentProcess,
283
+ runContext,
284
+ distributedExecutionId,
285
+ });
286
+ if (!success &&
287
+ (0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
288
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
289
+ }
290
+ return r;
291
+ }))
292
+ .catch((e) => __awaiter(this, void 0, void 0, function* () {
293
+ const success = yield onComplete({
294
+ daemon: context.daemon,
295
+ options,
296
+ fileStorage,
297
+ remoteCache,
298
+ api,
299
+ outputObfuscator,
300
+ runStartTime,
301
+ messages,
302
+ endOfRunMessage,
303
+ taskExecutions,
304
+ versionOfNxBefore133,
305
+ inner,
306
+ encryptionKey,
307
+ storeInCurrentProcess,
308
+ runContext,
309
+ distributedExecutionId,
310
+ });
311
+ if (!success &&
312
+ (0, environment_1.agentRunningInDistributedExecution)(distributedExecutionId)) {
313
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
314
+ }
315
+ throw e;
316
+ }));
317
+ }
318
+ }
319
+ exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
320
+ //# sourceMappingURL=cloud-enabled.runner.js.map