@nrwl/nx-cloud 14.4.0 → 14.4.2-beta.2

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 (31) hide show
  1. package/bin/nx-cloud.js +3 -3
  2. package/bin/nx-cloud.js.map +1 -1
  3. package/lib/core/api/error-reporter.api.js +36 -1
  4. package/lib/core/api/run-group.api.d.ts +1 -1
  5. package/lib/core/api/run-group.api.js +68 -1
  6. package/lib/core/api/run-group.api.js.map +1 -1
  7. package/lib/core/commands/start-ci-run.js +7 -1
  8. package/lib/core/commands/start-ci-run.js.map +1 -1
  9. package/lib/core/models/distributed-agent/tasks-api-response.model.d.ts +1 -0
  10. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +156 -1
  11. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +201 -1
  12. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
  13. package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +113 -1
  14. package/lib/core/runners/cloud-enabled/cloud-run.api.js +166 -1
  15. package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -1
  16. package/lib/core/runners/distributed-agent/distributed-agent.impl.js +263 -1
  17. package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -1
  18. package/lib/core/runners/distributed-execution/distributed-execution.api.js +143 -1
  19. package/lib/core/runners/distributed-execution/distributed-execution.runner.js +220 -1
  20. package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
  21. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -1
  22. package/lib/core/runners/distributed-execution/task-graph-creator.js +77 -1
  23. package/lib/utilities/create-unchanged-value-timeout.d.ts +4 -0
  24. package/lib/utilities/{create-no-new-messages-timeout.js → create-unchanged-value-timeout.js} +6 -7
  25. package/lib/utilities/create-unchanged-value-timeout.js.map +1 -0
  26. package/lib/utilities/environment.d.ts +1 -0
  27. package/lib/utilities/environment.js +5 -1
  28. package/lib/utilities/environment.js.map +1 -1
  29. package/package.json +3 -2
  30. package/lib/utilities/create-no-new-messages-timeout.d.ts +0 -1
  31. package/lib/utilities/create-no-new-messages-timeout.js.map +0 -1
package/bin/nx-cloud.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const distributed_agent_impl_1 = require("../lib/core/runners/distributed-agent/distributed-agent.impl");
5
- const start_ci_run_1 = require("../lib/core/commands/start-ci-run");
6
- const stop_all_agents_1 = require("../lib/core/commands/stop-all-agents");
7
4
  const clean_up_agents_1 = require("../lib/core/commands/clean-up-agents");
8
5
  const record_output_1 = require("../lib/core/commands/record-output");
6
+ const start_ci_run_1 = require("../lib/core/commands/start-ci-run");
7
+ const stop_all_agents_1 = require("../lib/core/commands/stop-all-agents");
8
+ const distributed_agent_impl_1 = require("../lib/core/runners/distributed-agent/distributed-agent.impl");
9
9
  const command = process.argv[2];
10
10
  if (command === 'start-agent') {
11
11
  (0, distributed_agent_impl_1.startAgent)().catch((e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"nx-cloud.js","sourceRoot":"","sources":["../../../../../libs/nx-packages/nx-cloud/bin/nx-cloud.ts"],"names":[],"mappings":";;;AAEA,yGAA0F;AAC1F,oEAA+D;AAC/D,0EAAqE;AACrE,0EAAqE;AACrE,sEAA+E;AAE/E,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEhC,IAAI,OAAO,KAAK,aAAa,EAAE;IAC7B,IAAA,mCAAU,GAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;CACJ;KAAM,IAAI,OAAO,KAAK,iBAAiB,EAAE;IACxC,IAAA,+BAAa,GAAE,CAAC,K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ance','apply','reportError','post','done','__awaiter','../../utilities/nx-imports','next','axiosMultipleTries','createApiAxiosInstance','ErrorReporterApi','throw','../../utilities/axios'];(function(_0x55dcd9,_0x37a7fc){const _0x34e4d5=function(_0x2ee2fd){while(--_0x2ee2fd){_0x55dcd9['push'](_0x55dcd9['shift']());}};_0x34e4d5(++_0x37a7fc);}(a0_0x37a7,0x7a));const a0_0x34e4=function(_0x55dcd9,_0x37a7fc){_0x55dcd9=_0x55dcd9-0x0;let _0x34e4d5=a0_0x37a7[_0x55dcd9];return _0x34e4d5;};'use strict';var __awaiter=this&&this[a0_0x34e4('0x6')]||function(_0x3af607,_0x1f7a3a,_0x56750e,_0x46e509){function _0x443d94(_0x513175){return _0x513175 instanceof _0x56750e?_0x513175:new _0x56750e(function(_0x1bddec){_0x1bddec(_0x513175);});}return new(_0x56750e||(_0x56750e=Promise))(function(_0x3b5aad,_0x59962f){function _0x4a984a(_0x439a8f){try{_0x3df56f(_0x46e509[a0_0x34e4('0x8')](_0x439a8f));}catch(_0x3f04c1){_0x59962f(_0x3f04c1);}}function _0x3b0f2e(_0x3ba5e6){try{_0x3df56f(_0x46e509[a0_0x34e4('0xc')](_0x3ba5e6));}catch(_0x1a259d){_0x59962f(_0x1a259d);}}function _0x3df56f(_0x101a75){_0x101a75[a0_0x34e4('0x5')]?_0x3b5aad(_0x101a75[a0_0x34e4('0xe')]):_0x443d94(_0x101a75[a0_0x34e4('0xe')])['then'](_0x4a984a,_0x3b0f2e);}_0x3df56f((_0x46e509=_0x46e509[a0_0x34e4('0x2')](_0x3af607,_0x1f7a3a||[]))[a0_0x34e4('0x8')]());});};Object[a0_0x34e4('0x10')](exports,'__esModule',{'value':!![]});exports[a0_0x34e4('0xb')]=void 0x0;const axios_1=require(a0_0x34e4('0xd'));const {output}=require(a0_0x34e4('0x7'));class ErrorReporterApi{constructor(_0x5f2229){this[a0_0x34e4('0x1')]=(0x0,axios_1[a0_0x34e4('0xa')])(_0x5f2229);}[a0_0x34e4('0x3')](_0x56ed22){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1[a0_0x34e4('0x9')])(()=>this[a0_0x34e4('0x1')][a0_0x34e4('0x4')](a0_0x34e4('0x0'),{'message':_0x56ed22}));}catch(_0xf1a76a){output['warn']({'title':'Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27'+_0x56ed22+'\x27','bodyLines':[_0xf1a76a[a0_0x34e4('0xf')]]});}});}}exports[a0_0x34e4('0xb')]=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
@@ -2,6 +2,6 @@ import { CloudTaskRunnerOptions } from '../models/cloud-task-runner-options';
2
2
  export declare class RunGroupApi {
3
3
  private apiAxiosInstance;
4
4
  constructor(options: CloudTaskRunnerOptions);
5
- createRunGroup(branch: string | null, runGroup: string): Promise<void>;
5
+ createRunGroup(branch: string | null, runGroup: string, stopAgentsOnFailure?: boolean, agentCount?: number, commandCount?: number): Promise<void>;
6
6
  completeRunGroup(runGroup: string): Promise<void>;
7
7
  }
@@ -1 +1,68 @@
1
- const a1_0x39ae=['__esModule','apply','RunGroupApi','recordMetric','mapRespToPerfEntry','next','../../utilities/metric-logger','createRunGroup','../../utilities/axios','then','response','/nx-cloud/executions/create-run-group','message','RUNNER_FAILURE_PERF_ENTRY','axiosMultipleTries','defineProperty','value','post','throw','error','createApiAxiosInstance','done','exit','__awaiter','axiosException','apiAxiosInstance','createMetricRecorder'];(function(_0x2b7a18,_0x39ae8d){const _0x28a0a3=function(_0x9b1555){while(--_0x9b1555){_0x2b7a18['push'](_0x2b7a18['shift']());}};_0x28a0a3(++_0x39ae8d);}(a1_0x39ae,0x11a));const a1_0x28a0=function(_0x2b7a18,_0x39ae8d){_0x2b7a18=_0x2b7a18-0x0;let _0x28a0a3=a1_0x39ae[_0x2b7a18];return _0x28a0a3;};'use strict';var __awaiter=this&&this[a1_0x28a0('0xb')]||function(_0x5a175d,_0x50e4a1,_0x460ea7,_0x9bae3c){function _0x46e298(_0x434fe4){return _0x434fe4 instanceof _0x460ea7?_0x434fe4:new _0x460ea7(function(_0x3902f0){_0x3902f0(_0x434fe4);});}return new(_0x460ea7||(_0x460ea7=Promise))(function(_0x17b8b7,_0x141ef7){function _0x5c4ec8(_0x33dfc6){try{_0x4c8c45(_0x9bae3c['next'](_0x33dfc6));}catch(_0x1afe9e){_0x141ef7(_0x1afe9e);}}function _0x263924(_0x794413){try{_0x4c8c45(_0x9bae3c[a1_0x28a0('0x6')](_0x794413));}catch(_0x293d3f){_0x141ef7(_0x293d3f);}}function _0x4c8c45(_0x5c4146){_0x5c4146[a1_0x28a0('0x9')]?_0x17b8b7(_0x5c4146[a1_0x28a0('0x4')]):_0x46e298(_0x5c4146['value'])[a1_0x28a0('0x18')](_0x5c4ec8,_0x263924);}_0x4c8c45((_0x9bae3c=_0x9bae3c[a1_0x28a0('0x10')](_0x5a175d,_0x50e4a1||[]))[a1_0x28a0('0x14')]());});};Object[a1_0x28a0('0x3')](exports,a1_0x28a0('0xf'),{'value':!![]});exports[a1_0x28a0('0x11')]=void 0x0;const axios_1=require(a1_0x28a0('0x17'));const metric_logger_1=require(a1_0x28a0('0x15'));const {output}=require('../../utilities/nx-imports');class RunGroupApi{constructor(_0x13dbec){this[a1_0x28a0('0xd')]=(0x0,axios_1[a1_0x28a0('0x8')])(_0x13dbec);}['createRunGroup'](_0x5bdd93,_0x194245){var _0x21c379;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x1a5f72=(0x0,metric_logger_1[a1_0x28a0('0xe')])(a1_0x28a0('0x16'));try{const _0x1c2827=yield(0x0,axios_1[a1_0x28a0('0x2')])(()=>this['apiAxiosInstance'][a1_0x28a0('0x5')](a1_0x28a0('0x1a'),{'branch':_0x5bdd93,'runGroup':_0x194245}));_0x1a5f72[a1_0x28a0('0x12')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x1c2827));}catch(_0x37d1c1){_0x1a5f72[a1_0x28a0('0x12')](((_0x21c379=_0x37d1c1===null||_0x37d1c1===void 0x0?void 0x0:_0x37d1c1[a1_0x28a0('0xc')])===null||_0x21c379===void 0x0?void 0x0:_0x21c379[a1_0x28a0('0x19')])?(0x0,metric_logger_1[a1_0x28a0('0x13')])(_0x37d1c1[a1_0x28a0('0xc')][a1_0x28a0('0x19')]):metric_logger_1[a1_0x28a0('0x1')]);output['error']({'title':_0x37d1c1['message']});process['exit'](0x1);}});}['completeRunGroup'](_0x16c318){var _0x4af3ea;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x5daf2e=(0x0,metric_logger_1[a1_0x28a0('0xe')])(a1_0x28a0('0x16'));try{const _0x578072=yield(0x0,axios_1[a1_0x28a0('0x2')])(()=>this[a1_0x28a0('0xd')]['post']('/nx-cloud/executions/complete-run-group',{'runGroup':_0x16c318}));_0x5daf2e[a1_0x28a0('0x12')]((0x0,metric_logger_1[a1_0x28a0('0x13')])(_0x578072));}catch(_0x29a8e4){_0x5daf2e[a1_0x28a0('0x12')](((_0x4af3ea=_0x29a8e4===null||_0x29a8e4===void 0x0?void 0x0:_0x29a8e4[a1_0x28a0('0xc')])===null||_0x4af3ea===void 0x0?void 0x0:_0x4af3ea[a1_0x28a0('0x19')])?(0x0,metric_logger_1[a1_0x28a0('0x13')])(_0x29a8e4['axiosException'][a1_0x28a0('0x19')]):metric_logger_1[a1_0x28a0('0x1')]);output[a1_0x28a0('0x7')]({'title':_0x29a8e4[a1_0x28a0('0x0')]});process[a1_0x28a0('0xa')](0x1);}});}}exports[a1_0x28a0('0x11')]=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, stopAgentsOnFailure, agentCount, commandCount) {
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
+ stopAgentsOnFailure,
29
+ agentCount,
30
+ commandCount,
31
+ }));
32
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
33
+ }
34
+ catch (e) {
35
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
36
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
37
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
38
+ output.error({
39
+ title: e.message,
40
+ });
41
+ process.exit(1);
42
+ }
43
+ });
44
+ }
45
+ completeRunGroup(runGroup) {
46
+ var _a;
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
49
+ try {
50
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
51
+ runGroup: runGroup,
52
+ }));
53
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
54
+ }
55
+ catch (e) {
56
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
57
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
58
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
59
+ output.error({
60
+ title: e.message,
61
+ });
62
+ process.exit(1);
63
+ }
64
+ });
65
+ }
66
+ }
67
+ exports.RunGroupApi = RunGroupApi;
68
+ //# sourceMappingURL=run-group.api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-group.api.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/api/run-group.api.ts"],"names":[],"mappings":";;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I,CAAC,yCAAyC,EAAE;oBACpE,QAAQ,EAAE,QAAQ;iBACnB,CAAC,CACH,CAAC;gBACF,QAAQ,CAAC,YAAY,CAAC,IAAA,kCAAkB,EAAC,IAAI,CAAC,CAAC,CAAC;aACjD;YAAC,OAAO,CAAM,EAAE;gBACf,QAAQ,CAAC,YAAY,CACnB,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,cAAc,0CAAE,QAAQ;oBACzB,CAAC,CAAC,IAAA,kCAAkB,EAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC;oBAC/C,CAAC,CAAC,yCAAyB,CAC9B,CAAC;gBAEF,MAAM,CAAC,KAAK,CAAC;oBACX,KAAK,EAAE,CAAC,CAAC,OAAO;iBACjB,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;;KACF;CACF;AAtDD,kCAsDC"}
1
+ {"version":3,"file":"run-group.api.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/api/run-group.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAG+B;AAC/B,iEAIuC;AAGvC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAEzD,MAAa,WAAW;IAGtB,YAAY,OAA+B;QACzC,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEK,cAAc,CAClB,MAAqB,EACrB,QAAgB,EAChB,mBAA6B,EAC7B,UAAmB,EACnB,YAAqB;;;YAErB,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,gBAAgB,CAAC,CAAC;YACxD,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAA,0BAAkB,EAAC,GAAG,EAAE,CACzC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,uCAAuC,EAAE;oBAClE,MAAM;oBACN,QAAQ;oBACR,mBAAm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AC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;;KACF;CACF;AA/DD,kCA+DC"}
@@ -15,7 +15,12 @@ const environment_1 = require("../../utilities/environment");
15
15
  const print_run_group_error_1 = require("../error/print-run-group-error");
16
16
  const run_group_api_1 = require("../api/run-group.api");
17
17
  const fs_1 = require("fs");
18
+ const yargsParser = require("yargs-parser");
18
19
  const { output, workspaceRoot } = require('../../utilities/nx-imports');
20
+ const args = yargsParser(process.argv, {
21
+ boolean: ['stop-agents-on-failure'],
22
+ number: ['agent-count', 'command-count'],
23
+ });
19
24
  function startCiRun() {
20
25
  return __awaiter(this, void 0, void 0, function* () {
21
26
  const branch = (0, environment_1.getBranch)();
@@ -31,7 +36,8 @@ function startCiRun() {
31
36
  }
32
37
  const options = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default.options;
33
38
  const api = new run_group_api_1.RunGroupApi(options);
34
- yield api.createRunGroup(branch, runGroup);
39
+ console.log(args);
40
+ yield api.createRunGroup(branch, runGroup, args.stopAgentsOnFailure, args.agentCount, args.commandCount);
35
41
  });
36
42
  }
37
43
  exports.startCiRun = startCiRun;
@@ -1 +1 @@
1
- {"version":3,"file":"start-ci-run.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/commands/start-ci-run.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyD;AACzD,6DAIqC;AACrC,0EAAoE;AACpE,wDAAmD;AACnD,2BAAkC;AAElC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAExE,SAAsB,UAAU;;QAC9B,MAAM,MAAM,GAAG,IAAA,uBAAS,GAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAC;QAE/B,IAAI,CAAC,QAAQ,EAAE;YACb,IAAA,0CAAkB,GAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,IAAI,6BAAe,EAAE;YACnB,MAAM,CAAC,IAAI,CAAC;gBACV,KAAK,EAAE,sBAAsB,QAAQ,EAAE;aACxC,CAAC,CAAC;SACJ;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CACxB,iBAAiB,CAAC,IAAA,iBAAY,EAAC,GAAG,aAAa,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,CACvE,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC;QAErC,MAAM,GAAG,GAAG,IAAI,2BAAW,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;CAAA;AApBD,gCAoBC"}
1
+ {"version":3,"file":"start-ci-run.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/commands/start-ci-run.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyD;AACzD,6DAIqC;AACrC,0EAAoE;AACpE,wDAAmD;AACnD,2BAAkC;AAClC,4CAA4C;AAE5C,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACxE,MAAM,IAAI,GAAQ,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE;IAC1C,OAAO,EAAE,CAAC,wBAAwB,CAAC;IACnC,MAAM,EAAE,CAAC,aAAa,EAAE,eAAe,CAAC;CACzC,CAAC,CAAC;AAEH,SAAsB,UAAU;;QAC9B,MAAM,MAAM,GAAG,IAAA,uBAAS,GAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAC;QAE/B,IAAI,CAAC,QAAQ,EAAE;YACb,IAAA,0CAAkB,GAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,IAAI,6BAAe,EAAE;YACnB,MAAM,CAAC,IAAI,CAAC;gBACV,KAAK,EAAE,sBAAsB,QAAQ,EAAE;aACxC,CAAC,CAAC;SACJ;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CACxB,iBAAiB,CAAC,IAAA,iBAAY,EAAC,GAAG,aAAa,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,CACvE,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC;QAErC,MAAM,GAAG,GAAG,IAAI,2BAAW,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM,GAAG,CAAC,cAAc,CACtB,MAAM,EACN,QAAQ,EACR,IAAI,CAAC,mBAAmB,EACxB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,YAAY,CAClB,CAAC;IACJ,CAAC;CAAA;AA3BD,gCA2BC"}
@@ -1,6 +1,7 @@
1
1
  import { TaskToExecute } from './task-to-execute.model';
2
2
  export interface TasksApiResponse {
3
3
  completed: boolean;
4
+ status?: 'RUN_GROUP_COMPLETED' | 'NO_FURTHER_TASKS_TO_RUN' | 'IN_PROGRESS';
4
5
  retryDuring: number | null;
5
6
  executionId: string | null;
6
7
  tasks: TaskToExecute[];
@@ -1 +1,156 @@
1
- const a0_0x17e9=['tasks','MAX_CHARACTERS_SUCCESSFUL_TASK','node_modules','endCommand','taskId','terminalOutputs','npm:','length','statuses','indexOf','startTask','local-cache-hit','readFileSync','endTime','local-cache','keys','skipNxCache','startsWith','push','join','cache-miss','getTerminalOutput','MAX_CHARACTERS_FAILED_TASK','filter','path','../../../utilities/environment','status','runtime','MAX_CHARACTERS_CACHED_TASK','nodes','cacheableOperations','readTerminalOutputFile','CloudEnabledLifeCycle','remote-cache-hit','task','updateStartedTask','scheduleTask','../../../utilities/serializer-overrides','cacheDirectory','params','Cannot\x20find\x20task\x20','runContext','implicitDeps','.cache','terminalOutput','local-cache-kept-existing','toString','cacheStatus','target','collectTerminalOutput','toISOString','project','cleanUpHashDetails','remote-cache','obfuscate','hash','slice'];(function(_0x4c996f,_0x17e964){const _0xe92cb1=function(_0x4a56ac){while(--_0x4a56ac){_0x4c996f['push'](_0x4c996f['shift']());}};_0xe92cb1(++_0x17e964);}(a0_0x17e9,0x1a6));const a0_0xe92c=function(_0x4c996f,_0x17e964){_0x4c996f=_0x4c996f-0x0;let _0xe92cb1=a0_0x17e9[_0x4c996f];return _0xe92cb1;};'use strict';Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a0_0xe92c('0x9')]=void 0x0;const path=require(a0_0xe92c('0x1'));const path_1=require(a0_0xe92c('0x1'));const fs_1=require('fs');const environment_1=require(a0_0xe92c('0x2'));const serializer_overrides_1=require(a0_0xe92c('0xe'));const {workspaceRoot}=require('../../../utilities/nx-imports');class CloudEnabledLifeCycle{constructor(_0xacd90c,_0x2c1e2a,_0xac956d,_0x555885,_0x17cff0,_0x2d70d0,_0xae4dfb){this['runContext']=_0xacd90c;this[a0_0xe92c('0xf')]=_0x2c1e2a;this[a0_0xe92c('0x32')]=_0xac956d;this[a0_0xe92c('0x1a')]=_0x555885;this[a0_0xe92c('0x7')]=_0x17cff0;this['outputObfuscator']=_0x2d70d0;this[a0_0xe92c('0x22')]=_0xae4dfb;}[a0_0xe92c('0xd')](_0x2cb4fa){this['runContext']['scheduledTasks'][a0_0xe92c('0x34')](_0x2cb4fa);}[a0_0xe92c('0x2c')](_0x522c44){this[a0_0xe92c('0x22')][a0_0xe92c('0x34')]({'taskId':_0x522c44['id'],'startTime':new Date()[a0_0xe92c('0x1b')](),'target':_0x522c44[a0_0xe92c('0x19')][a0_0xe92c('0x19')],'projectName':_0x522c44[a0_0xe92c('0x19')][a0_0xe92c('0x1c')],'hash':_0x522c44['hash'],'hashDetails':this['cleanUpHashDetails'](_0x522c44['hashDetails']),'params':(0x0,serializer_overrides_1['serializeOverrides'])(_0x522c44)});}['endTask'](_0x161fa4,_0x45d562){let _0x2b9352;if(this[a0_0xe92c('0x12')]['statuses'][_0x161fa4['hash']]){_0x2b9352=this[a0_0xe92c('0x12')][a0_0xe92c('0x2a')][_0x161fa4[a0_0xe92c('0x20')]];}else{if(this['cacheableOperations'][a0_0xe92c('0x2b')](_0x161fa4[a0_0xe92c('0x19')][a0_0xe92c('0x19')])>-0x1&&!this[a0_0xe92c('0x32')]){_0x2b9352='local-cache-hit';}else{_0x2b9352=a0_0xe92c('0x36');}}this[a0_0xe92c('0xc')](_0x161fa4,_0x45d562,_0x2b9352);}['endTasks'](_0x2088e0){for(let _0x4775b9 of _0x2088e0){let _0x39bc76;const _0x57b309=_0x4775b9[a0_0xe92c('0x3')]===a0_0xe92c('0x1e');const _0x591fcc=_0x4775b9[a0_0xe92c('0x3')]==='cache';const _0x540db7=_0x4775b9['status']===a0_0xe92c('0x30')||_0x4775b9[a0_0xe92c('0x3')]===a0_0xe92c('0x16')||_0x591fcc;if(this[a0_0xe92c('0x12')][a0_0xe92c('0x2a')][_0x4775b9[a0_0xe92c('0xb')][a0_0xe92c('0x20')]]){_0x39bc76=this[a0_0xe92c('0x12')][a0_0xe92c('0x2a')][_0x4775b9[a0_0xe92c('0xb')][a0_0xe92c('0x20')]];}else if(_0x57b309){_0x39bc76=a0_0xe92c('0xa');}else if(_0x540db7){_0x39bc76=a0_0xe92c('0x2d');}else{if(this[a0_0xe92c('0x7')][a0_0xe92c('0x2b')](_0x4775b9[a0_0xe92c('0xb')]['target'][a0_0xe92c('0x19')])>-0x1&&!this[a0_0xe92c('0x32')]){_0x39bc76='local-cache-hit';}else{_0x39bc76=a0_0xe92c('0x36');}}this[a0_0xe92c('0xc')](_0x4775b9[a0_0xe92c('0xb')],_0x4775b9['code'],_0x39bc76);}}[a0_0xe92c('0x25')](){}[a0_0xe92c('0xc')](_0x31ef11,_0xa653b2,_0x21e2a6){const _0x5a759c=this[a0_0xe92c('0x22')]['find'](_0x5d74b6=>_0x5d74b6[a0_0xe92c('0x26')]===_0x31ef11['id']);if(!_0x5a759c){throw new Error(a0_0xe92c('0x11')+_0x31ef11['id']);}_0x5a759c[a0_0xe92c('0x2f')]=new Date()[a0_0xe92c('0x1b')]();_0x5a759c[a0_0xe92c('0x3')]=_0xa653b2;_0x5a759c[a0_0xe92c('0x10')]=this['outputObfuscator'][a0_0xe92c('0x1f')](_0x5a759c[a0_0xe92c('0x10')]);_0x5a759c[a0_0xe92c('0x18')]=_0x21e2a6;if(this[a0_0xe92c('0x1a')]){_0x5a759c[a0_0xe92c('0x15')]=this[a0_0xe92c('0x37')](_0x31ef11[a0_0xe92c('0x20')],_0x5a759c[a0_0xe92c('0x18')],_0xa653b2);}}['getTerminalOutput'](_0x50c66a,_0x3440c3,_0x183ac8){let _0x2d06a0;if(this[a0_0xe92c('0xf')]){if(this[a0_0xe92c('0xf')][a0_0xe92c('0x33')]('./')){_0x2d06a0=(0x0,path_1['join'])(workspaceRoot,this[a0_0xe92c('0xf')]);}else{_0x2d06a0=this[a0_0xe92c('0xf')];}}else{_0x2d06a0=(0x0,path_1[a0_0xe92c('0x35')])(workspaceRoot,a0_0xe92c('0x24'),a0_0xe92c('0x14'),'nx');}try{const _0x2d0b3d=this[a0_0xe92c('0x8')](_0x2d06a0,_0x50c66a);const _0x181dfe=this['outputObfuscator'][a0_0xe92c('0x1f')](_0x2d0b3d);if(environment_1['NX_CLOUD_UNLIMITED_OUTPUT'])return _0x181dfe;const _0x22bd10=_0x3440c3===a0_0xe92c('0x36')?_0x183ac8===0x0?CloudEnabledLifeCycle[a0_0xe92c('0x23')]:CloudEnabledLifeCycle[a0_0xe92c('0x38')]:CloudEnabledLifeCycle[a0_0xe92c('0x5')];return _0x181dfe[a0_0xe92c('0x29')]>_0x22bd10?'TRUNCATED\x0a\x0a'+_0x181dfe[a0_0xe92c('0x21')](_0x181dfe['length']-_0x22bd10):_0x181dfe;}catch(_0x107b23){return'';}}[a0_0xe92c('0x1d')](_0x18196a){const _0x144798={};Object[a0_0xe92c('0x31')](_0x18196a['nodes'])[a0_0xe92c('0x0')](_0x535bd9=>!_0x535bd9[a0_0xe92c('0x33')](a0_0xe92c('0x28')))['forEach'](_0xc308b5=>{_0x144798[_0xc308b5]=_0x18196a[a0_0xe92c('0x6')][_0xc308b5];});return{'nodes':_0x144798,'runtime':_0x18196a[a0_0xe92c('0x4')],'implicitDeps':_0x18196a[a0_0xe92c('0x13')]};}['readTerminalOutputFile'](_0x4a5f84,_0x37248f){try{return(0x0,fs_1['readFileSync'])(path[a0_0xe92c('0x35')](_0x4a5f84,a0_0xe92c('0x27'),_0x37248f))[a0_0xe92c('0x17')]();}catch(_0x265336){try{return(0x0,fs_1[a0_0xe92c('0x2e')])(path[a0_0xe92c('0x35')](_0x4a5f84,_0x37248f,a0_0xe92c('0x15')))[a0_0xe92c('0x17')]();}catch(_0x5d2dcb){return'';}}}}exports['CloudEnabledLifeCycle']=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0xe92c('0x38')]=0x30d40;CloudEnabledLifeCycle['MAX_CHARACTERS_SUCCESSFUL_TASK']=0x4e20;CloudEnabledLifeCycle['MAX_CHARACTERS_CACHED_TASK']=0x4e20;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudEnabledLifeCycle = void 0;
4
+ const path = require("path");
5
+ const path_1 = require("path");
6
+ const fs_1 = require("fs");
7
+ const environment_1 = require("../../../utilities/environment");
8
+ const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
9
+ const { workspaceRoot } = require('../../../utilities/nx-imports');
10
+ class CloudEnabledLifeCycle {
11
+ constructor(runContext, cacheDirectory, skipNxCache, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
12
+ this.runContext = runContext;
13
+ this.cacheDirectory = cacheDirectory;
14
+ this.skipNxCache = skipNxCache;
15
+ this.collectTerminalOutput = collectTerminalOutput;
16
+ this.cacheableOperations = cacheableOperations;
17
+ this.outputObfuscator = outputObfuscator;
18
+ this.tasks = tasks;
19
+ }
20
+ scheduleTask(task) {
21
+ this.runContext.scheduledTasks.push(task);
22
+ }
23
+ startTask(task) {
24
+ this.tasks.push({
25
+ taskId: task.id,
26
+ startTime: new Date().toISOString(),
27
+ target: task.target.target,
28
+ projectName: task.target.project,
29
+ hash: task.hash,
30
+ hashDetails: this.cleanUpHashDetails(task.hashDetails),
31
+ params: (0, serializer_overrides_1.serializeOverrides)(task),
32
+ });
33
+ }
34
+ // Used for older version for Nx. Remove in Dec 2022
35
+ endTask(task, code) {
36
+ let cacheStatus;
37
+ if (this.runContext.statuses[task.hash]) {
38
+ cacheStatus = this.runContext.statuses[task.hash];
39
+ }
40
+ else {
41
+ if (this.cacheableOperations.indexOf(task.target.target) > -1 &&
42
+ !this.skipNxCache) {
43
+ cacheStatus = 'local-cache-hit';
44
+ }
45
+ else {
46
+ cacheStatus = 'cache-miss';
47
+ }
48
+ }
49
+ this.updateStartedTask(task, code, cacheStatus);
50
+ }
51
+ endTasks(tasks) {
52
+ for (let t of tasks) {
53
+ let cacheStatus;
54
+ const taskIsRemoteCacheHit = t.status === 'remote-cache';
55
+ const taskIsLocalCacheHitPreNx135 = t.status === 'cache';
56
+ const taskIsLocalCacheHit = t.status === 'local-cache' ||
57
+ t.status === 'local-cache-kept-existing' ||
58
+ taskIsLocalCacheHitPreNx135;
59
+ if (this.runContext.statuses[t.task.hash]) {
60
+ cacheStatus = this.runContext.statuses[t.task.hash];
61
+ }
62
+ else if (taskIsRemoteCacheHit) {
63
+ cacheStatus = 'remote-cache-hit';
64
+ }
65
+ else if (taskIsLocalCacheHit) {
66
+ cacheStatus = 'local-cache-hit';
67
+ }
68
+ else {
69
+ if (this.cacheableOperations.indexOf(t.task.target.target) > -1 &&
70
+ !this.skipNxCache) {
71
+ cacheStatus = 'local-cache-hit';
72
+ }
73
+ else {
74
+ cacheStatus = 'cache-miss';
75
+ }
76
+ }
77
+ this.updateStartedTask(t.task, t.code, cacheStatus);
78
+ }
79
+ }
80
+ endCommand() { }
81
+ updateStartedTask(task, code, cacheStatus) {
82
+ const startedTask = this.tasks.find((t) => t.taskId === task.id);
83
+ if (!startedTask) {
84
+ throw new Error(`Cannot find task ${task.id}`);
85
+ }
86
+ startedTask.endTime = new Date().toISOString();
87
+ startedTask.status = code;
88
+ startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
89
+ startedTask.cacheStatus = cacheStatus;
90
+ if (this.collectTerminalOutput) {
91
+ startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
92
+ }
93
+ }
94
+ getTerminalOutput(hash, cacheStatus, code) {
95
+ let dir;
96
+ if (this.cacheDirectory) {
97
+ if (this.cacheDirectory.startsWith('./')) {
98
+ dir = (0, path_1.join)(workspaceRoot, this.cacheDirectory);
99
+ }
100
+ else {
101
+ dir = this.cacheDirectory;
102
+ }
103
+ }
104
+ else {
105
+ dir = (0, path_1.join)(workspaceRoot, 'node_modules', '.cache', 'nx');
106
+ }
107
+ try {
108
+ const taskOutput = this.readTerminalOutputFile(dir, hash);
109
+ const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
110
+ if (environment_1.NX_CLOUD_UNLIMITED_OUTPUT)
111
+ return taskOutputSanitized;
112
+ const maxCharacters = cacheStatus === 'cache-miss'
113
+ ? code === 0
114
+ ? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
115
+ : CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
116
+ : CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
117
+ return taskOutputSanitized.length > maxCharacters
118
+ ? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
119
+ : taskOutputSanitized;
120
+ }
121
+ catch (e) {
122
+ return '';
123
+ }
124
+ }
125
+ cleanUpHashDetails(hashDetails) {
126
+ const nodes = {};
127
+ Object.keys(hashDetails.nodes)
128
+ .filter((k) => !k.startsWith('npm:'))
129
+ .forEach((k) => {
130
+ nodes[k] = hashDetails.nodes[k];
131
+ });
132
+ return {
133
+ nodes,
134
+ runtime: hashDetails.runtime,
135
+ implicitDeps: hashDetails.implicitDeps,
136
+ };
137
+ }
138
+ readTerminalOutputFile(dir, hash) {
139
+ try {
140
+ return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
141
+ }
142
+ catch (_a) {
143
+ try {
144
+ return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
145
+ }
146
+ catch (_b) {
147
+ return '';
148
+ }
149
+ }
150
+ }
151
+ }
152
+ exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
153
+ CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
154
+ CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
155
+ CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 20000;
156
+ //# sourceMappingURL=cloud-enabled-life-cycle.js.map
@@ -1 +1,201 @@
1
- const a1_0x1a87=['filter','requests','../../../utilities/nx-imports','toISOString','Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts','taskId','../../../utilities/environment','MessageReporter','complete','ErrorReporterApi','env','map','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','../../../utilities/metric-logger','rxjs/internal/Subject','forEach','catch','join','../../file-storage/file-storage','OutputObfuscator','skipNxCache','endRun','subscribe','cacheableOperations','assign','./cloud-enabled-life-cycle','printMessages','./node_modules/.cache/nx','cloudEnabledTasksRunner','./cloud-run.api','anyErrors','value','Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run','ENCRYPTION_KEY','tasks-hashes-','printCacheHitsMessage','throw','exit','extractGitSha','path','getRunGroup','error','../../terminal-output/output-obfuscator','hash','writeFileSync','../../terminal-output/message-reporter','CloudEnabledLifeCycle','Executed\x20tasks\x20with\x20hashes:\x20','stringify','apply','next','all','waitForStoreRequestsToComplete','cacheDirectory','getMachineInfo','parseCommand','CloudRunApi','startRun','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','scan','VERBOSE_LOGGING','../../file-storage/e2e-encryption'];(function(_0x486484,_0x1a8758){const _0x1acf29=function(_0x525fb8){while(--_0x525fb8){_0x486484['push'](_0x486484['shift']());}};_0x1acf29(++_0x1a8758);}(a1_0x1a87,0x194));const a1_0x1acf=function(_0x486484,_0x1a8758){_0x486484=_0x486484-0x0;let _0x1acf29=a1_0x1a87[_0x486484];return _0x1acf29;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0xb78e8b,_0x1ec661,_0x43edab,_0x42c9ad){function _0x287895(_0xb468d5){return _0xb468d5 instanceof _0x43edab?_0xb468d5:new _0x43edab(function(_0x1a0677){_0x1a0677(_0xb468d5);});}return new(_0x43edab||(_0x43edab=Promise))(function(_0x3df26a,_0x4905c0){function _0x3795c6(_0x47f439){try{_0x35532b(_0x42c9ad[a1_0x1acf('0x12')](_0x47f439));}catch(_0x329344){_0x4905c0(_0x329344);}}function _0xeba836(_0x4900fd){try{_0x35532b(_0x42c9ad[a1_0x1acf('0x4')](_0x4900fd));}catch(_0x32b347){_0x4905c0(_0x32b347);}}function _0x35532b(_0x16d77b){_0x16d77b['done']?_0x3df26a(_0x16d77b[a1_0x1acf('0x3d')]):_0x287895(_0x16d77b['value'])['then'](_0x3795c6,_0xeba836);}_0x35532b((_0x42c9ad=_0x42c9ad[a1_0x1acf('0x11')](_0xb78e8b,_0x1ec661||[]))[a1_0x1acf('0x12')]());});};Object['defineProperty'](exports,'__esModule',{'value':!![]});exports[a1_0x1acf('0x3a')]=void 0x0;const message_reporter_1=require(a1_0x1acf('0xd'));const end_of_run_message_1=require('../../terminal-output/end-of-run-message');const output_obfuscator_1=require(a1_0x1acf('0xa'));const cloud_enabled_life_cycle_1=require(a1_0x1acf('0x37'));const file_storage_1=require(a1_0x1acf('0x30'));const e2e_encryption_1=require(a1_0x1acf('0x1d'));const environment_1=require(a1_0x1acf('0x24'));const cloud_remote_cache_1=require('./cloud-remote-cache');const cloud_run_api_1=require(a1_0x1acf('0x3b'));const fs_1=require('fs');const path=require(a1_0x1acf('0x7'));const metric_logger_1=require(a1_0x1acf('0x2b'));const error_reporter_api_1=require('../../api/error-reporter.api');const {tasksRunner,output}=require(a1_0x1acf('0x20'));function createApi(_0x15fb12,_0x210f5b,_0xf473fa){const _0x19b013=(0x0,environment_1[a1_0x1acf('0x16')])(_0x210f5b);return new cloud_run_api_1[(a1_0x1acf('0x18'))](_0x15fb12,_0xf473fa,_0x210f5b,_0x19b013);}function storeTaskHashes(_0x18035c,_0x52e437,_0x43d746){const _0x1df351=JSON[a1_0x1acf('0x10')](_0x18035c[a1_0x1acf('0x29')](_0xeeb9b9=>({'taskId':_0xeeb9b9[a1_0x1acf('0x23')],'hash':_0xeeb9b9[a1_0x1acf('0xb')]})));if(environment_1[a1_0x1acf('0x1c')]){output['note']({'title':a1_0x1acf('0xf')+_0x1df351});}(0x0,fs_1[a1_0x1acf('0xc')])(path[a1_0x1acf('0x2f')](_0x52e437,a1_0x1acf('0x2')+_0x43d746),_0x1df351);}function onComplete(_0x28b235,_0xb65a58,_0x58e209,_0x1bb6dd,_0x26dcd0,_0x2f8bc5,_0x31b266,_0x168fd7,_0x2afab8,_0x5e4c26,_0x53f711){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x20bdb4=new Date()['toISOString']();const _0x440bf6=(0x0,environment_1['getBranch'])();const _0xf258cb={'command':_0x26dcd0['obfuscate']((0x0,environment_1[a1_0x1acf('0x17')])()),'startTime':_0x2f8bc5,'endTime':_0x20bdb4,'distributedExecutionId':environment_1[a1_0x1acf('0x1a')],'branch':_0x440bf6,'scan':!![],'runGroup':(0x0,environment_1[a1_0x1acf('0x8')])(),'sha':_0x440bf6?(0x0,environment_1[a1_0x1acf('0x6')])():undefined,'inner':_0x53f711};if(environment_1['AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION']){storeTaskHashes(_0x2afab8,_0xb65a58[a1_0x1acf('0x15')]||a1_0x1acf('0x39'),environment_1[a1_0x1acf('0x1a')]);try{yield _0x58e209[a1_0x1acf('0x14')]();}catch(_0x448c4e){output[a1_0x1acf('0x9')]({'title':a1_0x1acf('0x22')});_0x31b266[a1_0x1acf('0x38')]();process['exit'](environment_1[a1_0x1acf('0x2a')]);}try{yield _0x1bb6dd[a1_0x1acf('0x33')](_0xf258cb,_0x2afab8);}catch(_0x536af0){output[a1_0x1acf('0x9')]({'title':a1_0x1acf('0x0')});_0x31b266[a1_0x1acf('0x38')]();process[a1_0x1acf('0x5')](environment_1[a1_0x1acf('0x2a')]);}}else{yield Promise[a1_0x1acf('0x13')]([_0x58e209[a1_0x1acf('0x14')](),_0x1bb6dd[a1_0x1acf('0x33')](_0xf258cb,_0x2afab8)]);}if(_0x5e4c26){setTimeout(()=>{_0x31b266[a1_0x1acf('0x38')]();if(!_0x31b266[a1_0x1acf('0x3c')]&&!_0x53f711){_0x168fd7['printCacheHitsMessage']();}},0x0);}else{_0x31b266[a1_0x1acf('0x38')]();if(!_0x31b266[a1_0x1acf('0x3c')]&&!_0x53f711){_0x168fd7[a1_0x1acf('0x3')]();}}yield(0x0,metric_logger_1['submitRunMetrics'])(_0xb65a58);});}function createLifeCycle(_0x5ba68c,_0x29c958,_0x54f1e6,_0x4d4c35){const _0x11c793=new cloud_enabled_life_cycle_1[(a1_0x1acf('0xe'))](_0x5ba68c,_0x29c958['cacheDirectory'],!!_0x29c958[a1_0x1acf('0x32')],_0x29c958[a1_0x1acf('0x1b')]===undefined?!![]:_0x29c958['scan'],_0x29c958[a1_0x1acf('0x35')]||[],_0x54f1e6,_0x4d4c35);try{const {CompositeLifeCycle}=require('../../../utilities/nx-imports');if(!CompositeLifeCycle)return _0x11c793;return new CompositeLifeCycle([_0x29c958['lifeCycle'],_0x11c793]);}catch(_0x539e7d){return _0x11c793;}}function cloudEnabledTasksRunner(_0x25e19f,_0x35b812,_0x1397ed,_0xd30fc0=![]){const _0x3d9118={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x25e19f};const _0x29cedd=_0x35b812['lifeCycle']===undefined;const _0x59cbbd=[];const _0x616ede=new message_reporter_1[(a1_0x1acf('0x25'))](_0x35b812);const _0x424883=createApi(_0x616ede,_0x35b812,_0x3d9118);const _0x4ded8a=new end_of_run_message_1['EndOfRunMessage'](_0x3d9118,_0x59cbbd);const _0x234db7=new output_obfuscator_1[(a1_0x1acf('0x31'))](_0x35b812['maskedProperties']);const _0x52fdbb=_0x25e19f[a1_0x1acf('0x29')](_0x4cbaf2=>_0x4cbaf2[a1_0x1acf('0xb')])[a1_0x1acf('0x1e')](_0x513be4=>!!_0x513be4);const _0x5ce5ff=_0x424883[a1_0x1acf('0x19')](environment_1[a1_0x1acf('0x1a')],_0x52fdbb);_0x52fdbb[a1_0x1acf('0x2d')](_0x4bdceb=>{_0x3d9118[a1_0x1acf('0x1f')][_0x4bdceb]=_0x5ce5ff;});const _0x101a9c=new Date()[a1_0x1acf('0x21')]();const _0x39b3b6=createLifeCycle(_0x3d9118,_0x35b812,_0x234db7,_0x59cbbd);const _0x3da444=new e2e_encryption_1['E2EEncryption'](environment_1[a1_0x1acf('0x1')]||_0x35b812['encryptionKey']);const _0x498fcd=new error_reporter_api_1[(a1_0x1acf('0x27'))](_0x35b812);const _0x26c13c=new file_storage_1['FileStorage'](_0x3da444,_0x498fcd,![]);const _0x2daffe=new cloud_remote_cache_1['CloudRemoteCache'](_0x616ede,_0x424883,_0x3d9118,_0x26c13c);delete process[a1_0x1acf('0x28')][a1_0x1acf('0x1a')];const _0x5e3192=tasksRunner(_0x25e19f,Object[a1_0x1acf('0x36')](Object[a1_0x1acf('0x36')]({},_0x35b812),{'remoteCache':_0x2daffe,'lifeCycle':_0x39b3b6}),_0x1397ed);if(_0x5e3192[a1_0x1acf('0x34')]){const {Subject}=require(a1_0x1acf('0x2c'));const _0x441b6d=new Subject();_0x5e3192[a1_0x1acf('0x34')]({'next':_0x2c608c=>_0x441b6d[a1_0x1acf('0x12')](_0x2c608c),'error':_0x23c1e5=>_0x441b6d[a1_0x1acf('0x9')](_0x23c1e5),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x39b3b6,_0x35b812,_0x2daffe,_0x424883,_0x234db7,_0x101a9c,_0x616ede,_0x4ded8a,_0x59cbbd,_0x29cedd,_0xd30fc0);_0x441b6d[a1_0x1acf('0x26')]();})});return _0x441b6d;}else{return _0x5e3192['then'](_0x2c656b=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x39b3b6,_0x35b812,_0x2daffe,_0x424883,_0x234db7,_0x101a9c,_0x616ede,_0x4ded8a,_0x59cbbd,_0x29cedd,_0xd30fc0);return _0x2c656b;}))[a1_0x1acf('0x2e')](_0x23dc9a=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x39b3b6,_0x35b812,_0x2daffe,_0x424883,_0x234db7,_0x101a9c,_0x616ede,_0x4ded8a,_0x59cbbd,_0x29cedd,_0xd30fc0);throw _0x23dc9a;}));}}exports[a1_0x1acf('0x3a')]=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 metric_logger_1 = require("../../../utilities/metric-logger");
25
+ const error_reporter_api_1 = require("../../api/error-reporter.api");
26
+ const path_1 = require("path");
27
+ const fs_extra_1 = require("fs-extra");
28
+ const { tasksRunner, output, Cache } = require('../../../utilities/nx-imports');
29
+ function createApi(errors, options, runContext) {
30
+ const machineInfo = (0, environment_1.getMachineInfo)(options);
31
+ return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
32
+ }
33
+ function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
34
+ const hashes = JSON.stringify(taskExecutions.map((t) => ({
35
+ taskId: t.taskId,
36
+ hash: t.hash,
37
+ })));
38
+ if (environment_1.VERBOSE_LOGGING) {
39
+ output.note({
40
+ title: `Executed tasks with hashes: ${hashes}`,
41
+ });
42
+ }
43
+ (0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
44
+ }
45
+ function onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const runEndTime = new Date().toISOString();
48
+ const branch = (0, environment_1.getBranch)();
49
+ const runData = {
50
+ command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
51
+ startTime: runStartTime,
52
+ endTime: runEndTime,
53
+ distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
54
+ branch: branch,
55
+ scan: true,
56
+ runGroup: (0, environment_1.getRunGroup)(),
57
+ // only set sha if branch is set because we invoke a separate process,
58
+ // which adds a few millis
59
+ sha: branch ? (0, environment_1.extractGitSha)() : undefined,
60
+ inner: inner,
61
+ };
62
+ if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
63
+ storeTaskHashes(taskExecutions, options.cacheDirectory || './node_modules/.cache/nx', environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
64
+ try {
65
+ yield remoteCache.waitForStoreRequestsToComplete();
66
+ }
67
+ catch (e) {
68
+ output.error({
69
+ title: `Agent wasn't able to store artifacts`,
70
+ });
71
+ messages.printMessages();
72
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
73
+ }
74
+ try {
75
+ yield api.endRun(runData, taskExecutions);
76
+ }
77
+ catch (e) {
78
+ output.error({
79
+ title: `Agent wasn't able to record its run`,
80
+ });
81
+ messages.printMessages();
82
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
83
+ }
84
+ }
85
+ else {
86
+ yield Promise.all([
87
+ remoteCache.waitForStoreRequestsToComplete(),
88
+ api.endRun(runData, taskExecutions),
89
+ ]);
90
+ }
91
+ // this workaround is required because prior to Nx 13.3 we printed
92
+ // the end message after the runner completes, so we need to wait for the
93
+ // message to appear in the right place
94
+ if (versionOfNxBefore133) {
95
+ setTimeout(() => {
96
+ messages.printMessages();
97
+ if (!messages.anyErrors && !inner) {
98
+ endOfRunMessage.printCacheHitsMessage();
99
+ }
100
+ }, 0);
101
+ }
102
+ else {
103
+ messages.printMessages();
104
+ if (!messages.anyErrors && !inner) {
105
+ endOfRunMessage.printCacheHitsMessage();
106
+ }
107
+ }
108
+ yield (0, metric_logger_1.submitRunMetrics)(options);
109
+ });
110
+ }
111
+ function createLifeCycle(runContext, options, outputObfuscator, tasks) {
112
+ const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, options.cacheDirectory, !!options.skipNxCache, options.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
113
+ try {
114
+ const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
115
+ if (!CompositeLifeCycle)
116
+ return cloudEnabledLifeCycle;
117
+ return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
118
+ }
119
+ catch (e) {
120
+ return cloudEnabledLifeCycle;
121
+ }
122
+ }
123
+ function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ let hashes = tasks.map((t) => t.hash).filter((h) => !!h);
126
+ const c = new Cache(options);
127
+ if (!options.skipNxCache) {
128
+ // filter out the urls that don't have artifact stored locally
129
+ const promises = yield Promise.all(hashes.map((hash) => {
130
+ const tdCommit = (0, path_1.join)(c.cachePath, `${hash}.commit`);
131
+ return (0, fs_extra_1.pathExists)(tdCommit);
132
+ }));
133
+ const missingHashes = [];
134
+ for (let i = 0; i < promises.length; ++i) {
135
+ if (promises[i]) {
136
+ missingHashes.push(hashes[i]);
137
+ }
138
+ }
139
+ hashes = missingHashes;
140
+ }
141
+ if (hashes.length > 0) {
142
+ const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
143
+ for (const hash of hashes) {
144
+ runContext.requests[hash] = startRunRequest;
145
+ }
146
+ }
147
+ });
148
+ }
149
+ function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
150
+ const runContext = {
151
+ statuses: {},
152
+ scheduledTasks: [],
153
+ requests: {},
154
+ allTasks: tasks,
155
+ };
156
+ const versionOfNxBefore133 = options.lifeCycle === undefined;
157
+ const taskExecutions = [];
158
+ const messages = new message_reporter_1.MessageReporter(options);
159
+ const api = createApi(messages, options, runContext);
160
+ const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions);
161
+ const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
162
+ const runStartTime = new Date().toISOString();
163
+ const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
164
+ const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
165
+ const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
166
+ const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, false);
167
+ const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
168
+ // we don't await for it cause this step is optional
169
+ fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options);
170
+ // have to reset it so we don't capture inner tasks
171
+ delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
172
+ const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
173
+ // observable -> legacy
174
+ if (res.subscribe) {
175
+ const { Subject } = require('rxjs/internal/Subject');
176
+ const wrappedRes = new Subject();
177
+ res.subscribe({
178
+ next: (value) => wrappedRes.next(value),
179
+ error: (err) => wrappedRes.error(err),
180
+ complete: () => __awaiter(this, void 0, void 0, function* () {
181
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
182
+ wrappedRes.complete();
183
+ }),
184
+ });
185
+ return wrappedRes;
186
+ // promise
187
+ }
188
+ else {
189
+ return res
190
+ .then((r) => __awaiter(this, void 0, void 0, function* () {
191
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
192
+ return r;
193
+ }))
194
+ .catch((e) => __awaiter(this, void 0, void 0, function* () {
195
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
196
+ throw e;
197
+ }));
198
+ }
199
+ }
200
+ exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
201
+ //# sourceMappingURL=cloud-enabled.runner.js.map