@nrwl/nx-cloud 14.1.0 → 14.1.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 (29) hide show
  1. package/lib/core/api/error-reporter.api.js +36 -1
  2. package/lib/core/api/run-group.api.js +65 -1
  3. package/lib/core/models/run-context.model.d.ts +86 -0
  4. package/lib/core/models/run-context.model.js +19 -0
  5. package/lib/core/models/run-context.model.js.map +1 -1
  6. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +138 -1
  7. package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js.map +1 -1
  8. package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +169 -1
  9. package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +113 -1
  10. package/lib/core/runners/cloud-enabled/cloud-run.api.js +166 -1
  11. package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -1
  12. package/lib/core/runners/distributed-agent/distributed-agent.impl.js +240 -1
  13. package/lib/core/runners/distributed-execution/distributed-execution.api.js +131 -1
  14. package/lib/core/runners/distributed-execution/distributed-execution.api.js.map +1 -1
  15. package/lib/core/runners/distributed-execution/distributed-execution.runner.d.ts +0 -11
  16. package/lib/core/runners/distributed-execution/distributed-execution.runner.js +206 -1
  17. package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
  18. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.d.ts +2 -0
  19. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -0
  20. package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js.map +1 -0
  21. package/lib/core/runners/distributed-execution/task-graph-creator.d.ts +15 -0
  22. package/lib/core/runners/distributed-execution/task-graph-creator.js +77 -0
  23. package/lib/core/runners/distributed-execution/task-graph-creator.js.map +1 -0
  24. package/lib/utilities/nx-imports.js +2 -4
  25. package/lib/utilities/nx-imports.js.map +1 -1
  26. package/lib/utilities/serializer-overrides.d.ts +2 -0
  27. package/lib/utilities/serializer-overrides.js +40 -0
  28. package/lib/utilities/serializer-overrides.js.map +1 -0
  29. package/package.json +1 -1
@@ -1 +1,36 @@
1
- const a0_0xed75=['__awaiter','apiAxiosInstance','createApiAxiosInstance','ErrorReporterApi','__esModule','/nx-cloud/report-client-error','../../utilities/nx-imports','throw','apply','next','reportError','../../utilities/axios','warn','defineProperty','value','post','Unable\x20to\x20record\x20the\x20following\x20error:\x20\x27'];(function(_0x522690,_0xed75f7){const _0x296647=function(_0x22cccd){while(--_0x22cccd){_0x522690['push'](_0x522690['shift']());}};_0x296647(++_0xed75f7);}(a0_0xed75,0x1bd));const a0_0x2966=function(_0x522690,_0xed75f7){_0x522690=_0x522690-0x0;let _0x296647=a0_0xed75[_0x522690];return _0x296647;};'use strict';var __awaiter=this&&this[a0_0x2966('0xe')]||function(_0x59aa37,_0x5eede8,_0x42a115,_0xb6e052){function _0x4bd1d8(_0x3a5ae2){return _0x3a5ae2 instanceof _0x42a115?_0x3a5ae2:new _0x42a115(function(_0x2a3901){_0x2a3901(_0x3a5ae2);});}return new(_0x42a115||(_0x42a115=Promise))(function(_0x4fc9c6,_0x47b09a){function _0x1d835a(_0x46790c){try{_0x359676(_0xb6e052[a0_0x2966('0x6')](_0x46790c));}catch(_0x341cc1){_0x47b09a(_0x341cc1);}}function _0x33990a(_0x1a6dc7){try{_0x359676(_0xb6e052[a0_0x2966('0x4')](_0x1a6dc7));}catch(_0x383ea2){_0x47b09a(_0x383ea2);}}function _0x359676(_0x5e5592){_0x5e5592['done']?_0x4fc9c6(_0x5e5592[a0_0x2966('0xb')]):_0x4bd1d8(_0x5e5592['value'])['then'](_0x1d835a,_0x33990a);}_0x359676((_0xb6e052=_0xb6e052[a0_0x2966('0x5')](_0x59aa37,_0x5eede8||[]))['next']());});};Object[a0_0x2966('0xa')](exports,a0_0x2966('0x1'),{'value':!![]});exports[a0_0x2966('0x0')]=void 0x0;const axios_1=require(a0_0x2966('0x8'));const {output}=require(a0_0x2966('0x3'));class ErrorReporterApi{constructor(_0x479afc){this['apiAxiosInstance']=(0x0,axios_1[a0_0x2966('0x10')])(_0x479afc);}[a0_0x2966('0x7')](_0x26dfd7){return __awaiter(this,void 0x0,void 0x0,function*(){try{yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a0_0x2966('0xf')][a0_0x2966('0xc')](a0_0x2966('0x2'),{'message':_0x26dfd7}));}catch(_0x4a390b){output[a0_0x2966('0x9')]({'title':a0_0x2966('0xd')+_0x26dfd7+'\x27','bodyLines':[_0x4a390b['message']]});}});}}exports[a0_0x2966('0x0')]=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,65 @@
1
- const a1_0x18b3=['RUNNER_FAILURE_PERF_ENTRY','response','/nx-cloud/executions/complete-run-group','next','recordMetric','apiAxiosInstance','axiosException','message','mapRespToPerfEntry','apply','value','throw','axiosMultipleTries','__esModule','createApiAxiosInstance','error','../../utilities/nx-imports','createRunGroup','createMetricRecorder','post','RunGroupApi'];(function(_0x11f2ab,_0x18b3d6){const _0x40c8a9=function(_0x5cd14f){while(--_0x5cd14f){_0x11f2ab['push'](_0x11f2ab['shift']());}};_0x40c8a9(++_0x18b3d6);}(a1_0x18b3,0xaf));const a1_0x40c8=function(_0x11f2ab,_0x18b3d6){_0x11f2ab=_0x11f2ab-0x0;let _0x40c8a9=a1_0x18b3[_0x11f2ab];return _0x40c8a9;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x407e42,_0x5538c7,_0xe635cf,_0x1a14ae){function _0x1cdbbf(_0x519ba4){return _0x519ba4 instanceof _0xe635cf?_0x519ba4:new _0xe635cf(function(_0x27fa6a){_0x27fa6a(_0x519ba4);});}return new(_0xe635cf||(_0xe635cf=Promise))(function(_0x47b689,_0x2fbf24){function _0x17f9f1(_0x3d2610){try{_0x1d57a3(_0x1a14ae[a1_0x40c8('0x11')](_0x3d2610));}catch(_0x13c284){_0x2fbf24(_0x13c284);}}function _0x4179ae(_0x3185d6){try{_0x1d57a3(_0x1a14ae[a1_0x40c8('0x4')](_0x3185d6));}catch(_0x17273a){_0x2fbf24(_0x17273a);}}function _0x1d57a3(_0x198f5e){_0x198f5e['done']?_0x47b689(_0x198f5e[a1_0x40c8('0x3')]):_0x1cdbbf(_0x198f5e[a1_0x40c8('0x3')])['then'](_0x17f9f1,_0x4179ae);}_0x1d57a3((_0x1a14ae=_0x1a14ae[a1_0x40c8('0x2')](_0x407e42,_0x5538c7||[]))[a1_0x40c8('0x11')]());});};Object['defineProperty'](exports,a1_0x40c8('0x6'),{'value':!![]});exports['RunGroupApi']=void 0x0;const axios_1=require('../../utilities/axios');const metric_logger_1=require('../../utilities/metric-logger');const {output}=require(a1_0x40c8('0x9'));class RunGroupApi{constructor(_0x410b34){this[a1_0x40c8('0x13')]=(0x0,axios_1[a1_0x40c8('0x7')])(_0x410b34);}[a1_0x40c8('0xa')](_0xb1cf30,_0xd15ba4){var _0x49ccb5;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x286f48=(0x0,metric_logger_1['createMetricRecorder'])(a1_0x40c8('0xa'));try{const _0x362aa4=yield(0x0,axios_1[a1_0x40c8('0x5')])(()=>this['apiAxiosInstance'][a1_0x40c8('0xc')]('/nx-cloud/executions/create-run-group',{'branch':_0xb1cf30,'runGroup':_0xd15ba4}));_0x286f48[a1_0x40c8('0x12')]((0x0,metric_logger_1[a1_0x40c8('0x1')])(_0x362aa4));}catch(_0x154e4a){_0x286f48['recordMetric'](((_0x49ccb5=_0x154e4a===null||_0x154e4a===void 0x0?void 0x0:_0x154e4a['axiosException'])===null||_0x49ccb5===void 0x0?void 0x0:_0x49ccb5[a1_0x40c8('0xf')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x154e4a[a1_0x40c8('0x14')][a1_0x40c8('0xf')]):metric_logger_1[a1_0x40c8('0xe')]);output[a1_0x40c8('0x8')]({'title':_0x154e4a['message']});process['exit'](0x1);}});}['completeRunGroup'](_0x451265){var _0x348922;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x76a795=(0x0,metric_logger_1[a1_0x40c8('0xb')])(a1_0x40c8('0xa'));try{const _0x4d1766=yield(0x0,axios_1[a1_0x40c8('0x5')])(()=>this['apiAxiosInstance'][a1_0x40c8('0xc')](a1_0x40c8('0x10'),{'runGroup':_0x451265}));_0x76a795[a1_0x40c8('0x12')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x4d1766));}catch(_0x17222b){_0x76a795[a1_0x40c8('0x12')](((_0x348922=_0x17222b===null||_0x17222b===void 0x0?void 0x0:_0x17222b[a1_0x40c8('0x14')])===null||_0x348922===void 0x0?void 0x0:_0x348922['response'])?(0x0,metric_logger_1[a1_0x40c8('0x1')])(_0x17222b[a1_0x40c8('0x14')][a1_0x40c8('0xf')]):metric_logger_1[a1_0x40c8('0xe')]);output[a1_0x40c8('0x8')]({'title':_0x17222b[a1_0x40c8('0x0')]});process['exit'](0x1);}});}}exports[a1_0x40c8('0xd')]=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) {
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: branch,
27
+ runGroup: runGroup,
28
+ }));
29
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
30
+ }
31
+ catch (e) {
32
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
33
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
34
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
35
+ output.error({
36
+ title: e.message,
37
+ });
38
+ process.exit(1);
39
+ }
40
+ });
41
+ }
42
+ completeRunGroup(runGroup) {
43
+ var _a;
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
46
+ try {
47
+ const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
48
+ runGroup: runGroup,
49
+ }));
50
+ recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
51
+ }
52
+ catch (e) {
53
+ recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
54
+ ? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
55
+ : metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
56
+ output.error({
57
+ title: e.message,
58
+ });
59
+ process.exit(1);
60
+ }
61
+ });
62
+ }
63
+ }
64
+ exports.RunGroupApi = RunGroupApi;
65
+ //# sourceMappingURL=run-group.api.js.map
@@ -6,6 +6,92 @@ export interface TaskResult {
6
6
  code: number;
7
7
  terminalOutput?: string;
8
8
  }
9
+ export interface TaskGraph {
10
+ roots: string[];
11
+ tasks: Record<string, Task>;
12
+ dependencies: Record<string, string[]>;
13
+ }
14
+ export interface ProjectGraph<T = any> {
15
+ nodes: Record<string, ProjectGraphProjectNode<T>>;
16
+ dependencies: Record<string, ProjectGraphDependency[]>;
17
+ }
18
+ /**
19
+ * Type of dependency between projects
20
+ */
21
+ export declare enum DependencyType {
22
+ /**
23
+ * Static dependencies are tied to the loading of the module
24
+ */
25
+ static = "static",
26
+ /**
27
+ * Dynamic dependencies are brought in by the module at run time
28
+ */
29
+ dynamic = "dynamic",
30
+ /**
31
+ * Implicit dependencies are inferred
32
+ */
33
+ implicit = "implicit"
34
+ }
35
+ /**
36
+ * A node describing a project in a workspace
37
+ */
38
+ export interface ProjectGraphProjectNode<T = any> {
39
+ type: 'app' | 'e2e' | 'lib';
40
+ name: string;
41
+ /**
42
+ * Additional metadata about a project
43
+ */
44
+ data: T & {
45
+ /**
46
+ * The project's root directory
47
+ */
48
+ root: string;
49
+ sourceRoot?: string;
50
+ /**
51
+ * Targets associated to the project
52
+ */
53
+ targets?: {
54
+ [targetName: string]: any;
55
+ };
56
+ /**
57
+ * Project's tags used for enforcing module boundaries
58
+ */
59
+ tags?: string[];
60
+ /**
61
+ * Projects on which this node implicitly depends on
62
+ */
63
+ implicitDependencies?: string[];
64
+ /**
65
+ * Files associated to the project
66
+ */
67
+ files: any[];
68
+ };
69
+ }
70
+ /**
71
+ * A node describing an external dependency
72
+ */
73
+ export interface ProjectGraphExternalNode {
74
+ type: 'npm';
75
+ name: `npm:${string}`;
76
+ data: {
77
+ version: string;
78
+ packageName: string;
79
+ };
80
+ }
81
+ /**
82
+ * A dependency between two projects
83
+ */
84
+ export interface ProjectGraphDependency {
85
+ type: DependencyType | string;
86
+ /**
87
+ * The project being imported by the other
88
+ */
89
+ target: string;
90
+ /**
91
+ * The project importing the other
92
+ */
93
+ source: string;
94
+ }
9
95
  export interface Task {
10
96
  id: string;
11
97
  target: {
@@ -1,3 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DependencyType = void 0;
4
+ /**
5
+ * Type of dependency between projects
6
+ */
7
+ var DependencyType;
8
+ (function (DependencyType) {
9
+ /**
10
+ * Static dependencies are tied to the loading of the module
11
+ */
12
+ DependencyType["static"] = "static";
13
+ /**
14
+ * Dynamic dependencies are brought in by the module at run time
15
+ */
16
+ DependencyType["dynamic"] = "dynamic";
17
+ /**
18
+ * Implicit dependencies are inferred
19
+ */
20
+ DependencyType["implicit"] = "implicit";
21
+ })(DependencyType = exports.DependencyType || (exports.DependencyType = {}));
3
22
  //# sourceMappingURL=run-context.model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-context.model.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/models/run-context.model.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"run-context.model.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/models/run-context.model.ts"],"names":[],"mappings":";;;AA4BA;;GAEG;AACH,IAAY,cAaX;AAbD,WAAY,cAAc;IACxB;;OAEG;IACH,mCAAiB,CAAA;IACjB;;OAEG;IACH,qCAAmB,CAAA;IACnB;;OAEG;IACH,uCAAqB,CAAA;AACvB,CAAC,EAbW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAazB"}
@@ -1 +1,138 @@
1
- const a0_0xa2d1=['cacheStatus','skipNxCache','getTerminalOutput','runContext','local-cache','node_modules','statuses','startsWith','local-cache-kept-existing','cleanUpHashDetails','remote-cache-hit','nodes','implicitDeps','path','hashDetails','obfuscate','endTask','outputObfuscator','readTerminalOutputFile','cache-miss','TRUNCATED\x0a\x0a','updateStartedTask','indexOf','terminalOutput','startTask','readFileSync','__esModule','taskId','code','collectTerminalOutput','project','forEach','endCommand','.cache','Cannot\x20find\x20task\x20','scheduledTasks','push','filter','toISOString','runtime','configuration','endTime','hash','find','local-cache-hit','overrides','cacheDirectory','tasks','terminalOutputs','target','endTasks','task','status','MAX_CHARACTERS_FAILED_TASK','../../../utilities/environment','params','join','scheduleTask','toString','CloudEnabledLifeCycle','defineProperty','MAX_CHARACTERS_SUCCESSFUL_TASK','MAX_CHARACTERS_CACHED_TASK','assign','slice'];(function(_0x22fac8,_0xa2d17f){const _0x52fa2c=function(_0x324f77){while(--_0x324f77){_0x22fac8['push'](_0x22fac8['shift']());}};_0x52fa2c(++_0xa2d17f);}(a0_0xa2d1,0xf7));const a0_0x52fa=function(_0x22fac8,_0xa2d17f){_0x22fac8=_0x22fac8-0x0;let _0x52fa2c=a0_0xa2d1[_0x22fac8];return _0x52fa2c;};'use strict';Object[a0_0x52fa('0x8')](exports,a0_0x52fa('0x27'),{'value':!![]});exports[a0_0x52fa('0x7')]=void 0x0;const path=require(a0_0x52fa('0x1a'));const path_1=require(a0_0x52fa('0x1a'));const fs_1=require('fs');const environment_1=require(a0_0x52fa('0x2'));const {workspaceRoot,unparse}=require('../../../utilities/nx-imports');class CloudEnabledLifeCycle{constructor(_0x303fd7,_0x52971c,_0x568961,_0x486354,_0x5befa8,_0x20afca,_0x59fa43){this[a0_0x52fa('0x10')]=_0x303fd7;this[a0_0x52fa('0x3b')]=_0x52971c;this[a0_0x52fa('0xe')]=_0x568961;this[a0_0x52fa('0x2a')]=_0x486354;this['cacheableOperations']=_0x5befa8;this['outputObfuscator']=_0x20afca;this[a0_0x52fa('0x3c')]=_0x59fa43;}[a0_0x52fa('0x5')](_0x324020){this[a0_0x52fa('0x10')][a0_0x52fa('0x30')]['push'](_0x324020);}[a0_0x52fa('0x25')](_0x38de6e){const _0x1d97f4=Object[a0_0x52fa('0xb')]({},_0x38de6e[a0_0x52fa('0x3a')]||{});if(_0x38de6e['target'][a0_0x52fa('0x35')]){_0x1d97f4[a0_0x52fa('0x35')]=_0x38de6e[a0_0x52fa('0x3e')][a0_0x52fa('0x35')];}this[a0_0x52fa('0x3c')][a0_0x52fa('0x31')]({'taskId':_0x38de6e['id'],'startTime':new Date()['toISOString'](),'target':_0x38de6e[a0_0x52fa('0x3e')]['target'],'projectName':_0x38de6e[a0_0x52fa('0x3e')][a0_0x52fa('0x2b')],'hash':_0x38de6e[a0_0x52fa('0x37')],'hashDetails':this[a0_0x52fa('0x16')](_0x38de6e[a0_0x52fa('0x1b')]),'params':unparse(_0x1d97f4)[a0_0x52fa('0x4')]('\x20')});}[a0_0x52fa('0x1d')](_0x1f0445,_0x38e50b){let _0x588b19;if(this[a0_0x52fa('0x10')][a0_0x52fa('0x13')][_0x1f0445['hash']]){_0x588b19=this[a0_0x52fa('0x10')][a0_0x52fa('0x13')][_0x1f0445[a0_0x52fa('0x37')]];}else{if(this['cacheableOperations'][a0_0x52fa('0x23')](_0x1f0445[a0_0x52fa('0x3e')][a0_0x52fa('0x3e')])>-0x1&&!this[a0_0x52fa('0xe')]){_0x588b19=a0_0x52fa('0x39');}else{_0x588b19=a0_0x52fa('0x20');}}this[a0_0x52fa('0x22')](_0x1f0445,_0x38e50b,_0x588b19);}[a0_0x52fa('0x3f')](_0x55df58){for(let _0x224b5a of _0x55df58){const _0x4f4b81=_0x224b5a[a0_0x52fa('0x0')]==='remote-cache'?a0_0x52fa('0x17'):_0x224b5a[a0_0x52fa('0x0')]===a0_0x52fa('0x11')||_0x224b5a['status']===a0_0x52fa('0x15')?'local-cache-hit':'cache-miss';this['updateStartedTask'](_0x224b5a[a0_0x52fa('0x40')],_0x224b5a[a0_0x52fa('0x29')],_0x4f4b81);}}[a0_0x52fa('0x2d')](){}['updateStartedTask'](_0x198821,_0x4944f1,_0xb61326){const _0x30b317=this[a0_0x52fa('0x3c')][a0_0x52fa('0x38')](_0x2207ae=>_0x2207ae[a0_0x52fa('0x28')]===_0x198821['id']);if(!_0x30b317){throw new Error(a0_0x52fa('0x2f')+_0x198821['id']);}_0x30b317[a0_0x52fa('0x36')]=new Date()[a0_0x52fa('0x33')]();_0x30b317[a0_0x52fa('0x0')]=_0x4944f1;_0x30b317['params']=this[a0_0x52fa('0x1e')][a0_0x52fa('0x1c')](_0x30b317[a0_0x52fa('0x3')]);_0x30b317[a0_0x52fa('0xd')]=_0xb61326;if(this[a0_0x52fa('0x2a')]){_0x30b317['terminalOutput']=this['getTerminalOutput'](_0x198821[a0_0x52fa('0x37')],_0x30b317[a0_0x52fa('0xd')],_0x4944f1);}}[a0_0x52fa('0xf')](_0x2a58c2,_0xf918ea,_0x24ceef){let _0x11259b;if(this[a0_0x52fa('0x3b')]){if(this['cacheDirectory'][a0_0x52fa('0x14')]('./')){_0x11259b=(0x0,path_1[a0_0x52fa('0x4')])(workspaceRoot,this[a0_0x52fa('0x3b')]);}else{_0x11259b=this[a0_0x52fa('0x3b')];}}else{_0x11259b=(0x0,path_1[a0_0x52fa('0x4')])(workspaceRoot,a0_0x52fa('0x12'),a0_0x52fa('0x2e'),'nx');}try{const _0x3f80be=this[a0_0x52fa('0x1f')](_0x11259b,_0x2a58c2);const _0x5a78d4=this[a0_0x52fa('0x1e')]['obfuscate'](_0x3f80be);if(environment_1['NX_CLOUD_UNLIMITED_OUTPUT'])return _0x5a78d4;const _0x16ff85=_0xf918ea==='cache-miss'?_0x24ceef===0x0?CloudEnabledLifeCycle[a0_0x52fa('0x9')]:CloudEnabledLifeCycle['MAX_CHARACTERS_FAILED_TASK']:CloudEnabledLifeCycle[a0_0x52fa('0xa')];return _0x5a78d4['length']>_0x16ff85?a0_0x52fa('0x21')+_0x5a78d4[a0_0x52fa('0xc')](_0x5a78d4['length']-_0x16ff85):_0x5a78d4;}catch(_0x44f016){return'';}}['cleanUpHashDetails'](_0xa80726){const _0x5e111f={};Object['keys'](_0xa80726[a0_0x52fa('0x18')])[a0_0x52fa('0x32')](_0x2b345e=>!_0x2b345e[a0_0x52fa('0x14')]('npm:'))[a0_0x52fa('0x2c')](_0x2c406d=>{_0x5e111f[_0x2c406d]=_0xa80726[a0_0x52fa('0x18')][_0x2c406d];});return{'nodes':_0x5e111f,'runtime':_0xa80726[a0_0x52fa('0x34')],'implicitDeps':_0xa80726[a0_0x52fa('0x19')]};}[a0_0x52fa('0x1f')](_0x42cc28,_0x39d415){try{return(0x0,fs_1[a0_0x52fa('0x26')])(path[a0_0x52fa('0x4')](_0x42cc28,a0_0x52fa('0x3d'),_0x39d415))[a0_0x52fa('0x6')]();}catch(_0x2b799d){try{return(0x0,fs_1[a0_0x52fa('0x26')])(path[a0_0x52fa('0x4')](_0x42cc28,_0x39d415,a0_0x52fa('0x24')))['toString']();}catch(_0x4f3efd){return'';}}}}exports[a0_0x52fa('0x7')]=CloudEnabledLifeCycle;CloudEnabledLifeCycle[a0_0x52fa('0x1')]=0x30d40;CloudEnabledLifeCycle['MAX_CHARACTERS_SUCCESSFUL_TASK']=0x4e20;CloudEnabledLifeCycle[a0_0x52fa('0xa')]=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
+ const status = t.status === 'remote-cache'
54
+ ? 'remote-cache-hit'
55
+ : t.status === 'local-cache' ||
56
+ t.status === 'local-cache-kept-existing'
57
+ ? 'local-cache-hit'
58
+ : 'cache-miss';
59
+ this.updateStartedTask(t.task, t.code, status);
60
+ }
61
+ }
62
+ endCommand() { }
63
+ updateStartedTask(task, code, cacheStatus) {
64
+ const startedTask = this.tasks.find((t) => t.taskId === task.id);
65
+ if (!startedTask) {
66
+ throw new Error(`Cannot find task ${task.id}`);
67
+ }
68
+ startedTask.endTime = new Date().toISOString();
69
+ startedTask.status = code;
70
+ startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
71
+ startedTask.cacheStatus = cacheStatus;
72
+ if (this.collectTerminalOutput) {
73
+ startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
74
+ }
75
+ }
76
+ getTerminalOutput(hash, cacheStatus, code) {
77
+ let dir;
78
+ if (this.cacheDirectory) {
79
+ if (this.cacheDirectory.startsWith('./')) {
80
+ dir = (0, path_1.join)(workspaceRoot, this.cacheDirectory);
81
+ }
82
+ else {
83
+ dir = this.cacheDirectory;
84
+ }
85
+ }
86
+ else {
87
+ dir = (0, path_1.join)(workspaceRoot, 'node_modules', '.cache', 'nx');
88
+ }
89
+ try {
90
+ const taskOutput = this.readTerminalOutputFile(dir, hash);
91
+ const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
92
+ if (environment_1.NX_CLOUD_UNLIMITED_OUTPUT)
93
+ return taskOutputSanitized;
94
+ const maxCharacters = cacheStatus === 'cache-miss'
95
+ ? code === 0
96
+ ? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
97
+ : CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
98
+ : CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
99
+ return taskOutputSanitized.length > maxCharacters
100
+ ? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
101
+ : taskOutputSanitized;
102
+ }
103
+ catch (e) {
104
+ return '';
105
+ }
106
+ }
107
+ cleanUpHashDetails(hashDetails) {
108
+ const nodes = {};
109
+ Object.keys(hashDetails.nodes)
110
+ .filter((k) => !k.startsWith('npm:'))
111
+ .forEach((k) => {
112
+ nodes[k] = hashDetails.nodes[k];
113
+ });
114
+ return {
115
+ nodes,
116
+ runtime: hashDetails.runtime,
117
+ implicitDeps: hashDetails.implicitDeps,
118
+ };
119
+ }
120
+ readTerminalOutputFile(dir, hash) {
121
+ try {
122
+ return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
123
+ }
124
+ catch (_a) {
125
+ try {
126
+ return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
127
+ }
128
+ catch (_b) {
129
+ return '';
130
+ }
131
+ }
132
+ }
133
+ }
134
+ exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
135
+ CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
136
+ CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
137
+ CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 20000;
138
+ //# sourceMappingURL=cloud-enabled-life-cycle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloud-enabled-life-cycle.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,+BAA4B;AAC5B,2BAAkC;AAIlC,gEAA2E;AAE3E,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE5E,MAAa,qBAAqB;IAKhC,YACmB,UAAsB,EACtB,cAAkC,EAClC,WAAoB,EACpB,qBAA8B,EAC9B,mBAA6B,EAC7B,gBAAkC,EAClC,KAAsB;QANtB,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAoB;QAClC,gBAAW,GAAX,WAAW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L,CAAC,CAAC,mBAAmB,CAAC;SACzB;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,EAAE,CAAC;SACX;IACH,CAAC;IAEO,kBAAkB,CAAC,WAAgB;QACzC,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;aAC3B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aACpC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACb,KAAK,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACL,OAAO;YACL,KAAK;YACL,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,YAAY,EAAE,WAAW,CAAC,YAAY;SACvC,CAAC;IACJ,CAAC;IAEO,sBAAsB,CAAC,GAAW,EAAE,IAAY;QACtD,IAAI;YACF,OAAO,IAAA,iBAAY,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SACzE;QAAC,WAAM;YACN,IAAI;gBACF,OAAO,IAAA,iBAAY,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;aACxE;YAAC,WAAM;gBACN,OAAO,EAAE,CAAC;aACX;SACF;IACH,CAAC;;AArJH,sDAsJC;AArJgB,gDAA0B,GAAG,MAAM,CAAC;AACpC,oDAA8B,GAAG,KAAK,CAAC;AACvC,gDAA0B,GAAG,KAAK,CAAC"}
1
+ {"version":3,"file":"cloud-enabled-life-cycle.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.ts"],"names":[],"mappings":";;;AAAA,6BAA6B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../terminal-output/message-reporter','obfuscate','../../file-storage/file-storage','anyErrors','__esModule','apply','MessageReporter','filter','all','../../../utilities/metric-logger','value','env','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','CloudRunApi','getMachineInfo','tasks-hashes-','./cloud-enabled-life-cycle','extractGitSha','ErrorReporterApi','throw','ENCRYPTION_KEY','then','printMessages','scan','toISOString','Agent\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run','cacheDirectory','skipNxCache','map','note','cacheableOperations','complete','endRun','../../api/error-reporter.api','../../../utilities/nx-imports','../../terminal-output/output-obfuscator','CloudRemoteCache','defineProperty','done','submitRunMetrics','getBranch','catch','error','cloudEnabledTasksRunner','path','maskedProperties','writeFileSync','rxjs/internal/Subject','E2EEncryption','getRunGroup','startRun','exit','printCacheHitsMessage','lifeCycle','forEach','../../file-storage/e2e-encryption','./cloud-run.api','taskId','waitForStoreRequestsToComplete','../../../utilities/environment','Agent\x20wasn\x27t\x20able\x20to\x20store\x20artifacts','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','assign','OutputObfuscator','encryptionKey','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','parseCommand','../../terminal-output/end-of-run-message'];(function(_0x3b45e6,_0xe26396){const _0x55fb3a=function(_0x5e3326){while(--_0x5e3326){_0x3b45e6['push'](_0x3b45e6['shift']());}};_0x55fb3a(++_0xe26396);}(a1_0xe263,0x15d));const a1_0x55fb=function(_0x3b45e6,_0xe26396){_0x3b45e6=_0x3b45e6-0x0;let _0x55fb3a=a1_0xe263[_0x3b45e6];return _0x55fb3a;};'use strict';var __awaiter=this&&this['__awaiter']||function(_0x51509b,_0x26c95e,_0x916854,_0x2541ed){function _0x28c901(_0xfe613c){return _0xfe613c instanceof _0x916854?_0xfe613c:new _0x916854(function(_0x385324){_0x385324(_0xfe613c);});}return new(_0x916854||(_0x916854=Promise))(function(_0x139dd9,_0xae5554){function _0x59d393(_0x10d01f){try{_0x113092(_0x2541ed['next'](_0x10d01f));}catch(_0x55637b){_0xae5554(_0x55637b);}}function _0x18961a(_0x128189){try{_0x113092(_0x2541ed[a1_0x55fb('0xa')](_0x128189));}catch(_0x1efb2f){_0xae5554(_0x1efb2f);}}function _0x113092(_0x1db71c){_0x1db71c[a1_0x55fb('0x1d')]?_0x139dd9(_0x1db71c[a1_0x55fb('0x1')]):_0x28c901(_0x1db71c[a1_0x55fb('0x1')])[a1_0x55fb('0xc')](_0x59d393,_0x18961a);}_0x113092((_0x2541ed=_0x2541ed[a1_0x55fb('0x40')](_0x51509b,_0x26c95e||[]))['next']());});};Object[a1_0x55fb('0x1c')](exports,a1_0x55fb('0x3f'),{'value':!![]});exports[a1_0x55fb('0x22')]=void 0x0;const message_reporter_1=require(a1_0x55fb('0x3b'));const end_of_run_message_1=require(a1_0x55fb('0x3a'));const output_obfuscator_1=require(a1_0x55fb('0x1a'));const cloud_enabled_life_cycle_1=require(a1_0x55fb('0x7'));const file_storage_1=require(a1_0x55fb('0x3d'));const e2e_encryption_1=require(a1_0x55fb('0x2e'));const environment_1=require(a1_0x55fb('0x32'));const cloud_remote_cache_1=require('./cloud-remote-cache');const cloud_run_api_1=require(a1_0x55fb('0x2f'));const fs_1=require('fs');const path=require(a1_0x55fb('0x23'));const metric_logger_1=require(a1_0x55fb('0x0'));const error_reporter_api_1=require(a1_0x55fb('0x18'));const {tasksRunner,output}=require(a1_0x55fb('0x19'));function createApi(_0x57d0fa,_0x49f40e,_0xb0272e){const _0x172a30=(0x0,environment_1[a1_0x55fb('0x5')])(_0x49f40e);return new cloud_run_api_1[(a1_0x55fb('0x4'))](_0x57d0fa,_0xb0272e,_0x49f40e,_0x172a30);}function storeTaskHashes(_0x25ec1a,_0x5db20e,_0x58637c){const _0x36486a=JSON['stringify'](_0x25ec1a[a1_0x55fb('0x13')](_0x30fee3=>({'taskId':_0x30fee3[a1_0x55fb('0x30')],'hash':_0x30fee3['hash']})));if(environment_1['VERBOSE_LOGGING']){output[a1_0x55fb('0x14')]({'title':'Executed\x20tasks\x20with\x20hashes:\x20'+_0x36486a});}(0x0,fs_1[a1_0x55fb('0x25')])(path['join'](_0x5db20e,a1_0x55fb('0x6')+_0x58637c),_0x36486a);}function onComplete(_0x1129d8,_0x2d8a6a,_0x177a38,_0x110023,_0xbfdd24,_0x217256,_0x3d2f26,_0x3ecf04,_0x3e76ff,_0x11fbd4,_0x1ab87f){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x93ff98=new Date()['toISOString']();if(environment_1[a1_0x55fb('0x38')]){storeTaskHashes(_0x3e76ff,_0x2d8a6a['cacheDirectory']||'./node_modules/.cache/nx',environment_1[a1_0x55fb('0x34')]);}const _0x46b7d1=(0x0,environment_1[a1_0x55fb('0x1f')])();const _0x4d5c5b=yield Promise[a1_0x55fb('0x43')]([_0x177a38[a1_0x55fb('0x31')](),_0x110023[a1_0x55fb('0x17')]({'command':_0xbfdd24[a1_0x55fb('0x3c')]((0x0,environment_1[a1_0x55fb('0x39')])()),'startTime':_0x217256,'endTime':_0x93ff98,'distributedExecutionId':environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'],'branch':_0x46b7d1,'scan':!![],'runGroup':(0x0,environment_1[a1_0x55fb('0x28')])(),'sha':_0x46b7d1?(0x0,environment_1[a1_0x55fb('0x8')])():undefined,'inner':_0x1ab87f},_0x3e76ff)]);if(_0x11fbd4){setTimeout(()=>{_0x3d2f26[a1_0x55fb('0xd')]();if(!_0x3d2f26[a1_0x55fb('0x3e')]&&!_0x1ab87f){_0x3ecf04[a1_0x55fb('0x2b')]();}},0x0);}else{_0x3d2f26[a1_0x55fb('0xd')]();if(!_0x3d2f26['anyErrors']&&!_0x1ab87f){_0x3ecf04[a1_0x55fb('0x2b')]();}}if(environment_1[a1_0x55fb('0x38')]){if(!_0x4d5c5b[0x0]){output['error']({'title':a1_0x55fb('0x33')});_0x3d2f26['printMessages']();process['exit'](environment_1[a1_0x55fb('0x3')]);}if(!_0x4d5c5b[0x1]){output[a1_0x55fb('0x21')]({'title':a1_0x55fb('0x10')});_0x3d2f26[a1_0x55fb('0xd')]();process[a1_0x55fb('0x2a')](environment_1[a1_0x55fb('0x3')]);}}yield(0x0,metric_logger_1[a1_0x55fb('0x1e')])(_0x2d8a6a);});}function createLifeCycle(_0x2e8d9b,_0x489541,_0x1a4862,_0x4d6ed7){const _0x8d1dcb=new cloud_enabled_life_cycle_1['CloudEnabledLifeCycle'](_0x2e8d9b,_0x489541[a1_0x55fb('0x11')],!!_0x489541[a1_0x55fb('0x12')],_0x489541[a1_0x55fb('0xe')]===undefined?!![]:_0x489541[a1_0x55fb('0xe')],_0x489541[a1_0x55fb('0x15')]||[],_0x1a4862,_0x4d6ed7);try{const {CompositeLifeCycle}=require(a1_0x55fb('0x19'));if(!CompositeLifeCycle)return _0x8d1dcb;return new CompositeLifeCycle([_0x489541[a1_0x55fb('0x2c')],_0x8d1dcb]);}catch(_0x4dd4ae){return _0x8d1dcb;}}function cloudEnabledTasksRunner(_0x3c1a94,_0x38c1c6,_0x32f3be,_0x4a7d89=![]){const _0x4625ac={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x3c1a94};const _0x5051c4=_0x38c1c6[a1_0x55fb('0x2c')]===undefined;const _0x533ae6=[];const _0x9b7720=new message_reporter_1[(a1_0x55fb('0x41'))](_0x38c1c6);const _0x5e09d6=createApi(_0x9b7720,_0x38c1c6,_0x4625ac);const _0x1a7837=new end_of_run_message_1['EndOfRunMessage'](_0x4625ac,_0x533ae6);const _0x42b4d5=new output_obfuscator_1[(a1_0x55fb('0x36'))](_0x38c1c6[a1_0x55fb('0x24')]);const _0x3e5269=_0x3c1a94[a1_0x55fb('0x13')](_0x5957cb=>_0x5957cb['hash'])[a1_0x55fb('0x42')](_0x441516=>!!_0x441516);const _0x1160aa=_0x5e09d6[a1_0x55fb('0x29')](environment_1[a1_0x55fb('0x34')],_0x3e5269);_0x3e5269[a1_0x55fb('0x2d')](_0xc4a93a=>{_0x4625ac['requests'][_0xc4a93a]=_0x1160aa;});const _0x2b47f9=new Date()[a1_0x55fb('0xf')]();const _0x134314=createLifeCycle(_0x4625ac,_0x38c1c6,_0x42b4d5,_0x533ae6);const _0x1845d9=new e2e_encryption_1[(a1_0x55fb('0x27'))](environment_1[a1_0x55fb('0xb')]||_0x38c1c6[a1_0x55fb('0x37')]);const _0x29aed1=new error_reporter_api_1[(a1_0x55fb('0x9'))](_0x38c1c6);const _0x4257e8=new file_storage_1['FileStorage'](_0x1845d9,_0x29aed1,![]);const _0x4e95a2=new cloud_remote_cache_1[(a1_0x55fb('0x1b'))](_0x9b7720,_0x5e09d6,_0x4625ac,_0x4257e8);delete process[a1_0x55fb('0x2')][a1_0x55fb('0x34')];const _0xe0f0f3=tasksRunner(_0x3c1a94,Object['assign'](Object[a1_0x55fb('0x35')]({},_0x38c1c6),{'remoteCache':_0x4e95a2,'lifeCycle':_0x134314}),_0x32f3be);if(_0xe0f0f3['subscribe']){const {Subject}=require(a1_0x55fb('0x26'));const _0x2af276=new Subject();_0xe0f0f3['subscribe']({'next':_0x4db47f=>_0x2af276['next'](_0x4db47f),'error':_0x1bd4ca=>_0x2af276[a1_0x55fb('0x21')](_0x1bd4ca),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x134314,_0x38c1c6,_0x4e95a2,_0x5e09d6,_0x42b4d5,_0x2b47f9,_0x9b7720,_0x1a7837,_0x533ae6,_0x5051c4,_0x4a7d89);_0x2af276[a1_0x55fb('0x16')]();})});return _0x2af276;}else{return _0xe0f0f3[a1_0x55fb('0xc')](_0x56c672=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x134314,_0x38c1c6,_0x4e95a2,_0x5e09d6,_0x42b4d5,_0x2b47f9,_0x9b7720,_0x1a7837,_0x533ae6,_0x5051c4,_0x4a7d89);return _0x56c672;}))[a1_0x55fb('0x20')](_0x2b9f60=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete(_0x134314,_0x38c1c6,_0x4e95a2,_0x5e09d6,_0x42b4d5,_0x2b47f9,_0x9b7720,_0x1a7837,_0x533ae6,_0x5051c4,_0x4a7d89);throw _0x2b9f60;}));}}exports[a1_0x55fb('0x22')]=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 { tasksRunner, output } = require('../../../utilities/nx-imports');
27
+ function createApi(errors, options, runContext) {
28
+ const machineInfo = (0, environment_1.getMachineInfo)(options);
29
+ return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
30
+ }
31
+ function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
32
+ const hashes = JSON.stringify(taskExecutions.map((t) => ({
33
+ taskId: t.taskId,
34
+ hash: t.hash,
35
+ })));
36
+ if (environment_1.VERBOSE_LOGGING) {
37
+ output.note({
38
+ title: `Executed tasks with hashes: ${hashes}`,
39
+ });
40
+ }
41
+ (0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
42
+ }
43
+ function onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const runEndTime = new Date().toISOString();
46
+ if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
47
+ storeTaskHashes(taskExecutions, options.cacheDirectory || './node_modules/.cache/nx', environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
48
+ }
49
+ const branch = (0, environment_1.getBranch)();
50
+ const endRequest = yield Promise.all([
51
+ remoteCache.waitForStoreRequestsToComplete(),
52
+ api.endRun({
53
+ command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
54
+ startTime: runStartTime,
55
+ endTime: runEndTime,
56
+ distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
57
+ branch: branch,
58
+ scan: true,
59
+ runGroup: (0, environment_1.getRunGroup)(),
60
+ // only set sha if branch is set because we invoke a separate process,
61
+ // which adds a few millis
62
+ sha: branch ? (0, environment_1.extractGitSha)() : undefined,
63
+ inner: inner,
64
+ }, taskExecutions),
65
+ ]);
66
+ // this workaround is required because prior to Nx 13.3 we printed
67
+ // the end message after the runner completes, so we need to wait for the
68
+ // message to appear in the right place
69
+ if (versionOfNxBefore133) {
70
+ setTimeout(() => {
71
+ messages.printMessages();
72
+ if (!messages.anyErrors && !inner) {
73
+ endOfRunMessage.printCacheHitsMessage();
74
+ }
75
+ }, 0);
76
+ }
77
+ else {
78
+ messages.printMessages();
79
+ if (!messages.anyErrors && !inner) {
80
+ endOfRunMessage.printCacheHitsMessage();
81
+ }
82
+ }
83
+ if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
84
+ if (!endRequest[0]) {
85
+ output.error({
86
+ title: `Agent wasn't able to store artifacts`,
87
+ });
88
+ messages.printMessages();
89
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
90
+ }
91
+ if (!endRequest[1]) {
92
+ output.error({
93
+ title: `Agent wasn't able to record its run`,
94
+ });
95
+ messages.printMessages();
96
+ process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
97
+ }
98
+ }
99
+ yield (0, metric_logger_1.submitRunMetrics)(options);
100
+ });
101
+ }
102
+ function createLifeCycle(runContext, options, outputObfuscator, tasks) {
103
+ const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, options.cacheDirectory, !!options.skipNxCache, options.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
104
+ try {
105
+ const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
106
+ if (!CompositeLifeCycle)
107
+ return cloudEnabledLifeCycle;
108
+ return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
109
+ }
110
+ catch (e) {
111
+ return cloudEnabledLifeCycle;
112
+ }
113
+ }
114
+ function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
115
+ const runContext = {
116
+ statuses: {},
117
+ scheduledTasks: [],
118
+ requests: {},
119
+ allTasks: tasks,
120
+ };
121
+ const versionOfNxBefore133 = options.lifeCycle === undefined;
122
+ const taskExecutions = [];
123
+ const messages = new message_reporter_1.MessageReporter(options);
124
+ const api = createApi(messages, options, runContext);
125
+ const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions);
126
+ const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
127
+ const hashes = tasks.map((t) => t.hash).filter((h) => !!h);
128
+ const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
129
+ hashes.forEach((hash) => {
130
+ runContext.requests[hash] = startRunRequest;
131
+ });
132
+ const runStartTime = new Date().toISOString();
133
+ const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
134
+ const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
135
+ const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
136
+ const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, false);
137
+ const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
138
+ // have to reset it so we don't capture inner tasks
139
+ delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
140
+ const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
141
+ // observable -> legacy
142
+ if (res.subscribe) {
143
+ const { Subject } = require('rxjs/internal/Subject');
144
+ const wrappedRes = new Subject();
145
+ res.subscribe({
146
+ next: (value) => wrappedRes.next(value),
147
+ error: (err) => wrappedRes.error(err),
148
+ complete: () => __awaiter(this, void 0, void 0, function* () {
149
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
150
+ wrappedRes.complete();
151
+ }),
152
+ });
153
+ return wrappedRes;
154
+ // promise
155
+ }
156
+ else {
157
+ return res
158
+ .then((r) => __awaiter(this, void 0, void 0, function* () {
159
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
160
+ return r;
161
+ }))
162
+ .catch((e) => __awaiter(this, void 0, void 0, function* () {
163
+ yield onComplete(lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner);
164
+ throw e;
165
+ }));
166
+ }
167
+ }
168
+ exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
169
+ //# sourceMappingURL=cloud-enabled.runner.js.map