@nrwl/nx-cloud 15.0.2 → 15.0.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/api/error-reporter.api.js +36 -1
- package/lib/core/api/run-group.api.js +68 -1
- package/lib/core/commands/clean-up-agents.js +1 -1
- package/lib/core/commands/clean-up-agents.js.map +1 -1
- package/lib/core/commands/upload-and-show-run-details.js +1 -1
- package/lib/core/commands/upload-and-show-run-details.js.map +1 -1
- package/lib/core/error/print-invalid-runner-error.d.ts +1 -0
- package/lib/core/error/print-invalid-runner-error.js +17 -0
- package/lib/core/error/print-invalid-runner-error.js.map +1 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.d.ts +1 -3
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +84 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +288 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +113 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +167 -1
- package/lib/core/runners/cloud-enabled/id-generator.js +16 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +269 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +143 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +241 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -1
- package/lib/core/runners/distributed-execution/task-graph-creator.js +77 -1
- package/lib/utilities/distributed-task-execution-detection.js +1 -1
- package/lib/utilities/distributed-task-execution-detection.js.map +1 -1
- package/lib/utilities/environment.d.ts +2 -0
- package/lib/utilities/environment.js +18 -10
- package/lib/utilities/environment.js.map +1 -1
- package/package.json +1 -1
- package/project.json +2 -1
|
@@ -1 +1,36 @@
|
|
|
1
|
-
|
|
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,68 @@
|
|
|
1
|
-
|
|
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, stopAgentsAfter) {
|
|
21
|
+
var _a;
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
24
|
+
try {
|
|
25
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
|
|
26
|
+
branch,
|
|
27
|
+
runGroup,
|
|
28
|
+
stopAgentsOnFailure,
|
|
29
|
+
agentCount,
|
|
30
|
+
stopAgentsAfter,
|
|
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
|
|
@@ -17,7 +17,7 @@ const { output, workspaceRoot } = require('../../utilities/nx-imports');
|
|
|
17
17
|
function cleanUpAgents() {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
const options = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString())).tasksRunnerOptions.default.options;
|
|
20
|
-
const cacheDirectory = options
|
|
20
|
+
const cacheDirectory = (0, environment_1.getNxCacheDirectory)(options);
|
|
21
21
|
const lockFileDirectory = `${cacheDirectory}/lockfiles`;
|
|
22
22
|
if (environment_1.VERBOSE_LOGGING) {
|
|
23
23
|
output.note({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean-up-agents.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/commands/clean-up-agents.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyD;AACzD,
|
|
1
|
+
{"version":3,"file":"clean-up-agents.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/commands/clean-up-agents.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyD;AACzD,6DAGqC;AACrC,2BAAsC;AAEtC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAExE,SAAsB,aAAa;;QACjC,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;QACrC,MAAM,cAAc,GAAG,IAAA,iCAAmB,EAAC,OAAO,CAAC,CAAC;QACpD,MAAM,iBAAiB,GAAG,GAAG,cAAc,YAAY,CAAC;QAExD,IAAI,6BAAe,EAAE;YACnB,MAAM,CAAC,IAAI,CAAC;gBACV,KAAK,EAAE,gDAAgD;aACxD,CAAC,CAAC;SACJ;QAED,OAAO,IAAA,OAAE,EAAC,iBAAiB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;YACrE,IAAI,GAAG;gBAAE,MAAM,GAAG,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAhBD,sCAgBC"}
|
|
@@ -26,7 +26,7 @@ function uploadRunDetails(options) {
|
|
|
26
26
|
const runContext = {};
|
|
27
27
|
const machineInfo = (0, environment_1.getMachineInfo)(options);
|
|
28
28
|
const api = new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
|
|
29
|
-
const directory = options
|
|
29
|
+
const directory = (0, environment_1.getNxCacheDirectory)(options);
|
|
30
30
|
const outputObfusactor = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
|
|
31
31
|
const runInfo = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(directory, 'run.json')).toString());
|
|
32
32
|
// we need to connect to cloud if not connected yet
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-and-show-run-details.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/commands/upload-and-show-run-details.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"upload-and-show-run-details.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/commands/upload-and-show-run-details.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAGqC;AACrC,0EAAqE;AACrE,0EAAsE;AACtE,2BAAkC;AAClC,+BAA4B;AAC5B,wEAA6E;AAC7E,6BAA6B;AAC7B,4FAAsF;AACtF,4EAAwE;AAExE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAExE,SAAe,gBAAgB,CAAC,OAAY;;QAC1C,MAAM,MAAM,GAAG,IAAI,kCAAe,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,EAAS,CAAC;QAC7B,MAAM,WAAW,GAAG,IAAA,4BAAc,EAAC,OAAO,CAAC,CAA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W;;IAClB,IAAI;QACF,OAAO,MAAA,MAAA,MAAA,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,0CACtE,kBAAkB,0CAAE,OAAO,0CAAE,OAAO,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,EAAE,CAAC;KACX;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printInvalidRunnerError(): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printInvalidRunnerError = void 0;
|
|
4
|
+
const { output } = require('../../utilities/nx-imports');
|
|
5
|
+
function printInvalidRunnerError() {
|
|
6
|
+
output.error({
|
|
7
|
+
title: `Invalid Task Runner Configuration`,
|
|
8
|
+
bodyLines: [
|
|
9
|
+
'To use Distributed Task Execution, your default task runner configuration must',
|
|
10
|
+
'use the "@nrwl/nx-cloud" task runner.',
|
|
11
|
+
'',
|
|
12
|
+
'This can be adjusted in "nx.json".',
|
|
13
|
+
],
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.printInvalidRunnerError = printInvalidRunnerError;
|
|
17
|
+
//# sourceMappingURL=print-invalid-runner-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-invalid-runner-error.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/error/print-invalid-runner-error.ts"],"names":[],"mappings":";;;AAAA,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAEzD,SAAgB,uBAAuB;IACrC,MAAM,CAAC,KAAK,CAAC;QACX,KAAK,EAAE,mCAAmC;QAC1C,SAAS,EAAE;YACT,gFAAgF;YAChF,uCAAuC;YACvC,EAAE;YACF,oCAAoC;SACrC;KACF,CAAC,CAAC;AACL,CAAC;AAVD,0DAUC"}
|
|
@@ -4,15 +4,13 @@ import { OutputObfuscator } from '../../terminal-output/output-obfuscator';
|
|
|
4
4
|
export declare class CloudEnabledLifeCycle {
|
|
5
5
|
private readonly runContext;
|
|
6
6
|
private readonly cacheDirectory;
|
|
7
|
-
private readonly skipNxCache;
|
|
8
7
|
private readonly collectTerminalOutput;
|
|
9
8
|
private readonly cacheableOperations;
|
|
10
9
|
private readonly outputObfuscator;
|
|
11
10
|
private readonly tasks;
|
|
12
|
-
constructor(runContext: RunContext, cacheDirectory: string | undefined,
|
|
11
|
+
constructor(runContext: RunContext, cacheDirectory: string | undefined, collectTerminalOutput: boolean, cacheableOperations: string[], outputObfuscator: OutputObfuscator, tasks: TaskExecution[]);
|
|
13
12
|
scheduleTask(task: Task): void;
|
|
14
13
|
startTask(task: Task): void;
|
|
15
|
-
endTask(task: Task, code: number): void;
|
|
16
14
|
endTasks(tasks: TaskResult[]): void;
|
|
17
15
|
endCommand(): void;
|
|
18
16
|
private updateStartedTask;
|
|
@@ -1 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudEnabledLifeCycle = void 0;
|
|
4
|
+
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
5
|
+
const read_task_terminal_output_1 = require("../../terminal-output/read-task-terminal-output");
|
|
6
|
+
class CloudEnabledLifeCycle {
|
|
7
|
+
constructor(runContext, cacheDirectory, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
|
|
8
|
+
this.runContext = runContext;
|
|
9
|
+
this.cacheDirectory = cacheDirectory;
|
|
10
|
+
this.collectTerminalOutput = collectTerminalOutput;
|
|
11
|
+
this.cacheableOperations = cacheableOperations;
|
|
12
|
+
this.outputObfuscator = outputObfuscator;
|
|
13
|
+
this.tasks = tasks;
|
|
14
|
+
}
|
|
15
|
+
scheduleTask(task) {
|
|
16
|
+
this.runContext.scheduledTasks.push(task);
|
|
17
|
+
}
|
|
18
|
+
startTask(task) {
|
|
19
|
+
this.tasks.push({
|
|
20
|
+
taskId: task.id,
|
|
21
|
+
startTime: new Date().toISOString(),
|
|
22
|
+
target: task.target.target,
|
|
23
|
+
projectName: task.target.project,
|
|
24
|
+
hash: task.hash,
|
|
25
|
+
hashDetails: this.cleanUpHashDetails(task.hashDetails),
|
|
26
|
+
params: (0, serializer_overrides_1.serializeOverrides)(task),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
endTasks(tasks) {
|
|
30
|
+
for (let t of tasks) {
|
|
31
|
+
let cacheStatus;
|
|
32
|
+
const taskIsRemoteCacheHit = t.status === 'remote-cache';
|
|
33
|
+
const taskIsLocalCacheHitPreNx135 = t.status === 'cache';
|
|
34
|
+
const taskIsLocalCacheHit = t.status === 'local-cache' ||
|
|
35
|
+
t.status === 'local-cache-kept-existing' ||
|
|
36
|
+
taskIsLocalCacheHitPreNx135;
|
|
37
|
+
if (this.runContext.statuses[t.task.hash]) {
|
|
38
|
+
cacheStatus = this.runContext.statuses[t.task.hash];
|
|
39
|
+
}
|
|
40
|
+
else if (taskIsRemoteCacheHit) {
|
|
41
|
+
cacheStatus = 'remote-cache-hit';
|
|
42
|
+
}
|
|
43
|
+
else if (taskIsLocalCacheHit) {
|
|
44
|
+
cacheStatus = 'local-cache-hit';
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
cacheStatus = 'cache-miss';
|
|
48
|
+
}
|
|
49
|
+
this.updateStartedTask(t.task, t.code, cacheStatus);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
endCommand() { }
|
|
53
|
+
updateStartedTask(task, code, cacheStatus) {
|
|
54
|
+
const startedTask = this.tasks.find((t) => t.taskId === task.id);
|
|
55
|
+
if (!startedTask) {
|
|
56
|
+
throw new Error(`Cannot find task ${task.id}`);
|
|
57
|
+
}
|
|
58
|
+
startedTask.endTime = new Date().toISOString();
|
|
59
|
+
startedTask.status = code;
|
|
60
|
+
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
|
|
61
|
+
startedTask.cacheStatus = cacheStatus;
|
|
62
|
+
if (this.collectTerminalOutput) {
|
|
63
|
+
startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
getTerminalOutput(hash, cacheStatus, code) {
|
|
67
|
+
return (0, read_task_terminal_output_1.readTaskTerminalOutput)(this.cacheDirectory, this.outputObfuscator, hash, cacheStatus, code);
|
|
68
|
+
}
|
|
69
|
+
cleanUpHashDetails(hashDetails) {
|
|
70
|
+
const nodes = {};
|
|
71
|
+
Object.keys(hashDetails.nodes)
|
|
72
|
+
.filter((k) => !k.startsWith('npm:'))
|
|
73
|
+
.forEach((k) => {
|
|
74
|
+
nodes[k] = hashDetails.nodes[k];
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
nodes,
|
|
78
|
+
runtime: hashDetails.runtime,
|
|
79
|
+
implicitDeps: hashDetails.implicitDeps,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
|
|
84
|
+
//# 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":";;;
|
|
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":";;;AAGA,kFAA6E;AAC7E,+FAAyF;AAEzF,MAAa,qBAAqB;IAChC,YACmB,UAAsB,EACtB,cAAkC,EAClC,qBAA8B,EAC9B,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AA,kDAAsB,EAC3B,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,gBAAgB,EACrB,IAAI,EACJ,WAAW,EACX,IAAI,CACL,CAAC;IACJ,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;CACF;AAvGD,sDAuGC"}
|
|
@@ -1 +1,288 @@
|
|
|
1
|
-
const a1_0x52d8=['lifeCycle','AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION','../../../utilities/nx-imports','cachePath','uploads','enabled','__awaiter','OutputObfuscator','getBranch','processInBackground','api.nrwl.io','pathExists','taskId','runUrl','getMachineInfo','/runs/','VERBOSE_LOGGING','generateUniqueLinkId','encryptionKey','endsWith','ErrorReporterApi','EndOfRunMessage','env','cloudEnabledTasksRunner','done','../../terminal-output/output-obfuscator','../../../utilities/environment','value','FileStorage','requests','toISOString','note','__esModule','CloudRunApi','rxjs/internal/Subject','skipNxCache','assign','toString','waitForStoreRequestsToComplete','anyErrors','./cloud-remote-cache','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','indexOf','parseCommand','writeFileSync','printCacheHitsMessage','ACCESS_TOKEN','../../api/error-reporter.api','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20store\x20artifacts.','hash','then','tasks-hashes-','E2EEncryption','catch','subscribe','exit','printMessages','next','map','./cloud-run.api','url','https://nx.app','accessToken','cacheDirectory','endRun','message','path','startRun','Nx\x20Cloud\x20wasn\x27t\x20able\x20to\x20record\x20its\x20run.','error','daemon','.nx.app','length','stringify','../../terminal-output/end-of-run-message','join','NX_CLOUD_DISTRIBUTED_EXECUTION_ID','throw','scan','Nx\x20Cloud\x20Problems','getRunGroup'];(function(_0x4fbe33,_0x52d894){const _0x14a2d3=function(_0x8d08b5){while(--_0x8d08b5){_0x4fbe33['push'](_0x4fbe33['shift']());}};_0x14a2d3(++_0x52d894);}(a1_0x52d8,0x1b3));const a1_0x14a2=function(_0x4fbe33,_0x52d894){_0x4fbe33=_0x4fbe33-0x0;let _0x14a2d3=a1_0x52d8[_0x4fbe33];return _0x14a2d3;};'use strict';var __awaiter=this&&this[a1_0x14a2('0x39')]||function(_0x574f3d,_0x169e45,_0x35e293,_0x31dbe4){function _0x2bfd26(_0x410bb3){return _0x410bb3 instanceof _0x35e293?_0x410bb3:new _0x35e293(function(_0x4fdf31){_0x4fdf31(_0x410bb3);});}return new(_0x35e293||(_0x35e293=Promise))(function(_0x1b756e,_0x33ee99){function _0x1f4ec8(_0x248a10){try{_0x3e6460(_0x31dbe4[a1_0x14a2('0x1b')](_0x248a10));}catch(_0x4f2bd3){_0x33ee99(_0x4f2bd3);}}function _0x39e07c(_0x3cb38f){try{_0x3e6460(_0x31dbe4[a1_0x14a2('0x2f')](_0x3cb38f));}catch(_0x2699bc){_0x33ee99(_0x2699bc);}}function _0x3e6460(_0x58aa37){_0x58aa37[a1_0x14a2('0x4b')]?_0x1b756e(_0x58aa37[a1_0x14a2('0x4e')]):_0x2bfd26(_0x58aa37[a1_0x14a2('0x4e')])[a1_0x14a2('0x14')](_0x1f4ec8,_0x39e07c);}_0x3e6460((_0x31dbe4=_0x31dbe4['apply'](_0x574f3d,_0x169e45||[]))['next']());});};Object['defineProperty'](exports,a1_0x14a2('0x2'),{'value':!![]});exports[a1_0x14a2('0x4a')]=void 0x0;const message_reporter_1=require('../../terminal-output/message-reporter');const end_of_run_message_1=require(a1_0x14a2('0x2c'));const output_obfuscator_1=require(a1_0x14a2('0x4c'));const cloud_enabled_life_cycle_1=require('./cloud-enabled-life-cycle');const file_storage_1=require('../../file-storage/file-storage');const e2e_encryption_1=require('../../file-storage/e2e-encryption');const environment_1=require(a1_0x14a2('0x4d'));const cloud_remote_cache_1=require(a1_0x14a2('0xa'));const cloud_run_api_1=require(a1_0x14a2('0x1d'));const fs_1=require('fs');const path=require(a1_0x14a2('0x24'));const metric_logger_1=require('../../../utilities/metric-logger');const error_reporter_api_1=require(a1_0x14a2('0x11'));const path_1=require(a1_0x14a2('0x24'));const fs_extra_1=require('fs-extra');const id_generator_1=require('./id-generator');const {tasksRunner,output,Cache}=require(a1_0x14a2('0x35'));function createApi(_0x46c245,_0x100982,_0x50d874){const _0x43dc04=(0x0,environment_1[a1_0x14a2('0x41')])(_0x100982);return new cloud_run_api_1[(a1_0x14a2('0x3'))](_0x46c245,_0x50d874,_0x100982,_0x43dc04);}function storeTaskHashes(_0x388dc2,_0x432900,_0xafbeda){const _0x487fff=JSON[a1_0x14a2('0x2b')](_0x388dc2[a1_0x14a2('0x1c')](_0x5115b2=>({'taskId':_0x5115b2[a1_0x14a2('0x3f')],'hash':_0x5115b2[a1_0x14a2('0x13')]})));if(environment_1[a1_0x14a2('0x43')]){output[a1_0x14a2('0x1')]({'title':'Executed\x20tasks\x20with\x20hashes:\x20'+_0x487fff});}(0x0,fs_1[a1_0x14a2('0xe')])(path['join'](_0x432900,a1_0x14a2('0x15')+_0xafbeda),_0x487fff);}function onComplete({daemon,lifeCycle,options,remoteCache,api,outputObfuscator,runStartTime,messages,endOfRunMessage,taskExecutions,versionOfNxBefore133,inner,encryptionKey,fileStorage,uploadInCurrentProcess,runContext}){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x199144=new Date()[a1_0x14a2('0x0')]();const _0x41b63b=(0x0,environment_1[a1_0x14a2('0x3b')])();const _0x431e7e={'command':outputObfuscator['obfuscate']((0x0,environment_1[a1_0x14a2('0xd')])()),'startTime':runStartTime,'endTime':_0x199144,'distributedExecutionId':environment_1[a1_0x14a2('0x2e')],'branch':_0x41b63b,'scan':!![],'runGroup':(0x0,environment_1[a1_0x14a2('0x32')])(),'sha':_0x41b63b?(0x0,environment_1['extractGitSha'])():undefined,'inner':inner};if(uploadInCurrentProcess){if(environment_1[a1_0x14a2('0x34')]){storeTaskHashes(taskExecutions,options[a1_0x14a2('0x21')]||'./node_modules/.cache/nx',environment_1['NX_CLOUD_DISTRIBUTED_EXECUTION_ID']);}try{yield remoteCache[a1_0x14a2('0x8')]();}catch(_0x296dbf){output[a1_0x14a2('0x27')]({'title':a1_0x14a2('0x12')});messages[a1_0x14a2('0x1a')]();process['exit'](environment_1[a1_0x14a2('0xb')]);}try{yield api[a1_0x14a2('0x22')](_0x431e7e,taskExecutions);}catch(_0x5bca09){output[a1_0x14a2('0x27')]({'title':a1_0x14a2('0x26')});messages[a1_0x14a2('0x1a')]();process[a1_0x14a2('0x19')](environment_1['DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE']);}yield(0x0,metric_logger_1['submitRunMetrics'])(options);}else{try{const _0x15c1a6=environment_1[a1_0x14a2('0x10')]?environment_1['ACCESS_TOKEN']:options[a1_0x14a2('0x20')];const _0x33d147=(0x0,id_generator_1[a1_0x14a2('0x44')])();yield daemon[a1_0x14a2('0x3c')]('@nrwl/nx-cloud/lib/daemon/process-run-end',{'encryptionKey':encryptionKey,'runnerOptions':Object[a1_0x14a2('0x6')](Object[a1_0x14a2('0x6')]({},options),{'accessToken':_0x15c1a6}),'uploads':fileStorage[a1_0x14a2('0x37')],'runEnd':{'runData':_0x431e7e,'taskExecutions':taskExecutions,'linkId':_0x33d147}});runContext[a1_0x14a2('0x40')]=(options['url']||a1_0x14a2('0x1f'))+a1_0x14a2('0x42')+_0x33d147;}catch(_0x58f278){output['warn']({'title':a1_0x14a2('0x31'),'bodyLines':[_0x58f278[a1_0x14a2('0x23')]||_0x58f278[a1_0x14a2('0x7')]()]});}}if(versionOfNxBefore133){setTimeout(()=>{messages['printMessages']();if(!messages[a1_0x14a2('0x9')]&&!inner){endOfRunMessage[a1_0x14a2('0xf')]();}},0x0);}else{messages['printMessages']();if(!messages[a1_0x14a2('0x9')]&&!inner){endOfRunMessage[a1_0x14a2('0xf')]();}}});}function createLifeCycle(_0x25f71b,_0x1ff057,_0x23bd93,_0x1848d9){const _0x2b87f1=new cloud_enabled_life_cycle_1['CloudEnabledLifeCycle'](_0x25f71b,_0x1ff057['cacheDirectory'],!!_0x1ff057[a1_0x14a2('0x5')],_0x1ff057[a1_0x14a2('0x30')]===undefined?!![]:_0x1ff057[a1_0x14a2('0x30')],_0x1ff057['cacheableOperations']||[],_0x23bd93,_0x1848d9);try{const {CompositeLifeCycle}=require(a1_0x14a2('0x35'));if(!CompositeLifeCycle)return _0x2b87f1;return new CompositeLifeCycle([_0x1ff057[a1_0x14a2('0x33')],_0x2b87f1]);}catch(_0x313ad0){return _0x2b87f1;}}function fetchUrlsForKnownHashesUpfront(_0x4352d3,_0x92659d,_0x5d0df5,_0x35f3ee){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x5dfdc=_0x5d0df5[a1_0x14a2('0x1c')](_0x3ac38c=>_0x3ac38c[a1_0x14a2('0x13')])['filter'](_0x4c5d69=>!!_0x4c5d69);const _0x32342f=new Cache(_0x35f3ee);if(!_0x35f3ee[a1_0x14a2('0x5')]){const _0x6ab78b=yield Promise['all'](_0x5dfdc[a1_0x14a2('0x1c')](_0x52499f=>{const _0x2e3bd5=(0x0,path_1[a1_0x14a2('0x2d')])(_0x32342f[a1_0x14a2('0x36')],_0x52499f+'.commit');return(0x0,fs_extra_1[a1_0x14a2('0x3e')])(_0x2e3bd5);}));const _0x38aaeb=[];for(let _0x4e47eb=0x0;_0x4e47eb<_0x6ab78b[a1_0x14a2('0x2a')];++_0x4e47eb){if(_0x6ab78b[_0x4e47eb]){_0x38aaeb['push'](_0x5dfdc[_0x4e47eb]);}}_0x5dfdc=_0x38aaeb;}if(_0x5dfdc[a1_0x14a2('0x2a')]>0x0){const _0x660b64=_0x4352d3[a1_0x14a2('0x25')](environment_1[a1_0x14a2('0x2e')],_0x5dfdc);for(const _0x199785 of _0x5dfdc){_0x92659d[a1_0x14a2('0x50')][_0x199785]=_0x660b64;}}});}function isConnectedToPrivateCloud(_0x4cfb09){if(!_0x4cfb09[a1_0x14a2('0x1e')])return![];if(_0x4cfb09['url'][a1_0x14a2('0x46')](a1_0x14a2('0x3d')))return![];if(_0x4cfb09[a1_0x14a2('0x1e')][a1_0x14a2('0x46')](a1_0x14a2('0x29')))return![];if(_0x4cfb09[a1_0x14a2('0x1e')][a1_0x14a2('0xc')]('localhost')>-0x1)return![];return!![];}function cloudEnabledTasksRunner(_0x4babb4,_0x406e98,_0x3f39af,_0x4cb693=![]){var _0x33f889;const _0x2850d4={'statuses':{},'scheduledTasks':[],'requests':{},'allTasks':_0x4babb4};const _0x9a5db=_0x406e98[a1_0x14a2('0x33')]===undefined;const _0x3e5646=[];const _0x24254f=new message_reporter_1['MessageReporter'](_0x406e98);const _0x493e4a=createApi(_0x24254f,_0x406e98,_0x2850d4);const _0x265377=new end_of_run_message_1[(a1_0x14a2('0x48'))](_0x2850d4,_0x3e5646);const _0x527a06=new output_obfuscator_1[(a1_0x14a2('0x3a'))](_0x406e98['maskedProperties']);const _0x34463a=new Date()[a1_0x14a2('0x0')]();const _0x136819=createLifeCycle(_0x2850d4,_0x406e98,_0x527a06,_0x3e5646);const _0x9beea9=environment_1['ENCRYPTION_KEY']||_0x406e98[a1_0x14a2('0x45')];const _0x5b7a5f=new e2e_encryption_1[(a1_0x14a2('0x16'))](_0x9beea9);const _0x511040=new error_reporter_api_1[(a1_0x14a2('0x47'))](_0x406e98);const _0x132270=!!environment_1[a1_0x14a2('0x34')]||!((_0x33f889=_0x3f39af[a1_0x14a2('0x28')])===null||_0x33f889===void 0x0?void 0x0:_0x33f889[a1_0x14a2('0x38')]())||isConnectedToPrivateCloud(_0x406e98);const _0x26b28a=new file_storage_1[(a1_0x14a2('0x4f'))](_0x5b7a5f,_0x511040,![],_0x132270);const _0x5ae23c=new cloud_remote_cache_1['CloudRemoteCache'](_0x24254f,_0x493e4a,_0x2850d4,_0x26b28a);fetchUrlsForKnownHashesUpfront(_0x493e4a,_0x2850d4,_0x4babb4,_0x406e98);delete process[a1_0x14a2('0x49')][a1_0x14a2('0x2e')];const _0x26dc91=tasksRunner(_0x4babb4,Object['assign'](Object[a1_0x14a2('0x6')]({},_0x406e98),{'remoteCache':_0x5ae23c,'lifeCycle':_0x136819}),_0x3f39af);if(_0x26dc91[a1_0x14a2('0x18')]){const {Subject}=require(a1_0x14a2('0x4'));const _0x248577=new Subject();_0x26dc91[a1_0x14a2('0x18')]({'next':_0x50085d=>_0x248577['next'](_0x50085d),'error':_0x56829a=>_0x248577['error'](_0x56829a),'complete':()=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0x3f39af['daemon'],'lifeCycle':_0x136819,'options':_0x406e98,'remoteCache':_0x5ae23c,'api':_0x493e4a,'outputObfuscator':_0x527a06,'runStartTime':_0x34463a,'messages':_0x24254f,'endOfRunMessage':_0x265377,'taskExecutions':_0x3e5646,'versionOfNxBefore133':_0x9a5db,'inner':_0x4cb693,'encryptionKey':_0x9beea9,'fileStorage':_0x26b28a,'uploadInCurrentProcess':_0x132270,'runContext':_0x2850d4});_0x248577['complete']();})});return _0x248577;}else{return _0x26dc91[a1_0x14a2('0x14')](_0x47f754=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0x3f39af[a1_0x14a2('0x28')],'lifeCycle':_0x136819,'options':_0x406e98,'remoteCache':_0x5ae23c,'api':_0x493e4a,'outputObfuscator':_0x527a06,'runStartTime':_0x34463a,'messages':_0x24254f,'endOfRunMessage':_0x265377,'taskExecutions':_0x3e5646,'versionOfNxBefore133':_0x9a5db,'inner':_0x4cb693,'encryptionKey':_0x9beea9,'fileStorage':_0x26b28a,'uploadInCurrentProcess':_0x132270,'runContext':_0x2850d4});return _0x47f754;}))[a1_0x14a2('0x17')](_0x15d830=>__awaiter(this,void 0x0,void 0x0,function*(){yield onComplete({'daemon':_0x3f39af['daemon'],'lifeCycle':_0x136819,'options':_0x406e98,'remoteCache':_0x5ae23c,'api':_0x493e4a,'outputObfuscator':_0x527a06,'runStartTime':_0x34463a,'messages':_0x24254f,'endOfRunMessage':_0x265377,'taskExecutions':_0x3e5646,'versionOfNxBefore133':_0x9a5db,'inner':_0x4cb693,'encryptionKey':_0x9beea9,'fileStorage':_0x26b28a,'uploadInCurrentProcess':_0x132270,'runContext':_0x2850d4});throw _0x15d830;}));}}exports['cloudEnabledTasksRunner']=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 id_generator_1 = require("./id-generator");
|
|
29
|
+
const { tasksRunner, output, Cache } = require('../../../utilities/nx-imports');
|
|
30
|
+
function createApi(errors, options, runContext) {
|
|
31
|
+
const machineInfo = (0, environment_1.getMachineInfo)(options);
|
|
32
|
+
return new cloud_run_api_1.CloudRunApi(errors, runContext, options, machineInfo);
|
|
33
|
+
}
|
|
34
|
+
function storeTaskHashes(taskExecutions, directory, distributedExecutionId) {
|
|
35
|
+
const hashes = JSON.stringify(taskExecutions.map((t) => ({
|
|
36
|
+
taskId: t.taskId,
|
|
37
|
+
hash: t.hash,
|
|
38
|
+
})));
|
|
39
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
40
|
+
output.note({
|
|
41
|
+
title: `Executed tasks with hashes: ${hashes}`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
(0, fs_1.writeFileSync)(path.join(directory, `tasks-hashes-${distributedExecutionId}`), hashes);
|
|
45
|
+
}
|
|
46
|
+
function onComplete({ daemon, lifeCycle, options, remoteCache, api, outputObfuscator, runStartTime, messages, endOfRunMessage, taskExecutions, versionOfNxBefore133, inner, encryptionKey, fileStorage, uploadInCurrentProcess, runContext, }) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const runEndTime = new Date().toISOString();
|
|
49
|
+
const branch = (0, environment_1.getBranch)();
|
|
50
|
+
const runData = {
|
|
51
|
+
command: outputObfuscator.obfuscate((0, environment_1.parseCommand)()),
|
|
52
|
+
startTime: runStartTime,
|
|
53
|
+
endTime: runEndTime,
|
|
54
|
+
distributedExecutionId: environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID,
|
|
55
|
+
branch: branch,
|
|
56
|
+
scan: true,
|
|
57
|
+
runGroup: (0, environment_1.getRunGroup)(),
|
|
58
|
+
// only set sha if branch is set because we invoke a separate process,
|
|
59
|
+
// which adds a few millis
|
|
60
|
+
sha: branch ? (0, environment_1.extractGitSha)() : undefined,
|
|
61
|
+
inner: inner,
|
|
62
|
+
};
|
|
63
|
+
if (uploadInCurrentProcess) {
|
|
64
|
+
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION) {
|
|
65
|
+
storeTaskHashes(taskExecutions, (0, environment_1.getNxCacheDirectory)(options), environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID);
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
yield remoteCache.waitForStoreRequestsToComplete();
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
output.error({
|
|
72
|
+
title: `Nx Cloud wasn't able to store artifacts.`,
|
|
73
|
+
});
|
|
74
|
+
messages.printMessages();
|
|
75
|
+
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
yield api.endRun(runData, taskExecutions);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
output.error({
|
|
82
|
+
title: `Nx Cloud wasn't able to record its run.`,
|
|
83
|
+
});
|
|
84
|
+
messages.printMessages();
|
|
85
|
+
process.exit(environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE);
|
|
86
|
+
}
|
|
87
|
+
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
try {
|
|
91
|
+
const accessToken = environment_1.ACCESS_TOKEN ? environment_1.ACCESS_TOKEN : options.accessToken;
|
|
92
|
+
const linkId = (0, id_generator_1.generateUniqueLinkId)();
|
|
93
|
+
yield daemon.processInBackground('@nrwl/nx-cloud/lib/daemon/process-run-end', {
|
|
94
|
+
encryptionKey,
|
|
95
|
+
runnerOptions: Object.assign(Object.assign({}, options), { accessToken }),
|
|
96
|
+
uploads: fileStorage.uploads,
|
|
97
|
+
runEnd: {
|
|
98
|
+
runData,
|
|
99
|
+
taskExecutions,
|
|
100
|
+
linkId,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
runContext.runUrl = `${options.url || 'https://nx.app'}/runs/${linkId}`;
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
output.warn({
|
|
107
|
+
title: `Nx Cloud Problems`,
|
|
108
|
+
bodyLines: [e.message || e.toString()],
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// this workaround is required because prior to Nx 13.3 we printed
|
|
113
|
+
// the end message after the runner completes, so we need to wait for the
|
|
114
|
+
// message to appear in the right place
|
|
115
|
+
if (versionOfNxBefore133) {
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
messages.printMessages();
|
|
118
|
+
if (!messages.anyErrors && !inner) {
|
|
119
|
+
endOfRunMessage.printCacheHitsMessage();
|
|
120
|
+
}
|
|
121
|
+
}, 0);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
messages.printMessages();
|
|
125
|
+
if (!messages.anyErrors && !inner) {
|
|
126
|
+
endOfRunMessage.printCacheHitsMessage();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function createLifeCycle(runContext, options, outputObfuscator, tasks) {
|
|
132
|
+
const cloudEnabledLifeCycle = new cloud_enabled_life_cycle_1.CloudEnabledLifeCycle(runContext, (0, environment_1.getNxCacheDirectory)(options), options.scan === undefined ? true : options.scan, options.cacheableOperations || [], outputObfuscator, tasks);
|
|
133
|
+
try {
|
|
134
|
+
const { CompositeLifeCycle } = require('../../../utilities/nx-imports');
|
|
135
|
+
if (!CompositeLifeCycle)
|
|
136
|
+
return cloudEnabledLifeCycle;
|
|
137
|
+
return new CompositeLifeCycle([options.lifeCycle, cloudEnabledLifeCycle]);
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
return cloudEnabledLifeCycle;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
let hashes = tasks.map((t) => t.hash).filter((h) => !!h);
|
|
146
|
+
const c = new Cache(options);
|
|
147
|
+
if (!options.skipNxCache) {
|
|
148
|
+
// filter out the urls that don't have artifact stored locally
|
|
149
|
+
const promises = yield Promise.all(hashes.map((hash) => {
|
|
150
|
+
const tdCommit = (0, path_1.join)(c.cachePath, `${hash}.commit`);
|
|
151
|
+
return (0, fs_extra_1.pathExists)(tdCommit);
|
|
152
|
+
}));
|
|
153
|
+
const missingHashes = [];
|
|
154
|
+
for (let i = 0; i < promises.length; ++i) {
|
|
155
|
+
if (promises[i]) {
|
|
156
|
+
missingHashes.push(hashes[i]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
hashes = missingHashes;
|
|
160
|
+
}
|
|
161
|
+
if (hashes.length > 0) {
|
|
162
|
+
const startRunRequest = api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, hashes);
|
|
163
|
+
for (const hash of hashes) {
|
|
164
|
+
runContext.requests[hash] = startRunRequest;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function isConnectedToPrivateCloud(options) {
|
|
170
|
+
if (!options.url)
|
|
171
|
+
return false;
|
|
172
|
+
if (options.url.endsWith('api.nrwl.io'))
|
|
173
|
+
return false;
|
|
174
|
+
if (options.url.endsWith('.nx.app'))
|
|
175
|
+
return false;
|
|
176
|
+
if (options.url.indexOf('localhost') > -1)
|
|
177
|
+
return false;
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
function cloudEnabledTasksRunner(tasks, options, context, inner = false) {
|
|
181
|
+
var _a;
|
|
182
|
+
const runContext = {
|
|
183
|
+
statuses: {},
|
|
184
|
+
scheduledTasks: [],
|
|
185
|
+
requests: {},
|
|
186
|
+
allTasks: tasks,
|
|
187
|
+
};
|
|
188
|
+
const versionOfNxBefore133 = options.lifeCycle === undefined;
|
|
189
|
+
const taskExecutions = [];
|
|
190
|
+
const messages = new message_reporter_1.MessageReporter(options);
|
|
191
|
+
const api = createApi(messages, options, runContext);
|
|
192
|
+
const endOfRunMessage = new end_of_run_message_1.EndOfRunMessage(runContext, taskExecutions);
|
|
193
|
+
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(options.maskedProperties);
|
|
194
|
+
const runStartTime = new Date().toISOString();
|
|
195
|
+
const lifeCycle = createLifeCycle(runContext, options, outputObfuscator, taskExecutions);
|
|
196
|
+
const encryptionKey = environment_1.ENCRYPTION_KEY || options.encryptionKey;
|
|
197
|
+
const encryption = new e2e_encryption_1.E2EEncryption(encryptionKey);
|
|
198
|
+
const errorApi = new error_reporter_api_1.ErrorReporterApi(options);
|
|
199
|
+
const uploadInCurrentProcess = !!environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION ||
|
|
200
|
+
!((_a = context.daemon) === null || _a === void 0 ? void 0 : _a.enabled()) ||
|
|
201
|
+
isConnectedToPrivateCloud(options);
|
|
202
|
+
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, false, uploadInCurrentProcess);
|
|
203
|
+
const remoteCache = new cloud_remote_cache_1.CloudRemoteCache(messages, api, runContext, fileStorage);
|
|
204
|
+
// we don't await for it cause this step is optional
|
|
205
|
+
fetchUrlsForKnownHashesUpfront(api, runContext, tasks, options);
|
|
206
|
+
// have to reset it so we don't capture inner tasks
|
|
207
|
+
delete process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID;
|
|
208
|
+
const res = tasksRunner(tasks, Object.assign(Object.assign({}, options), { remoteCache, lifeCycle }), context);
|
|
209
|
+
// observable -> legacy
|
|
210
|
+
if (res.subscribe) {
|
|
211
|
+
const { Subject } = require('rxjs/internal/Subject');
|
|
212
|
+
const wrappedRes = new Subject();
|
|
213
|
+
res.subscribe({
|
|
214
|
+
next: (value) => wrappedRes.next(value),
|
|
215
|
+
error: (err) => wrappedRes.error(err),
|
|
216
|
+
complete: () => __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
yield onComplete({
|
|
218
|
+
daemon: context.daemon,
|
|
219
|
+
lifeCycle,
|
|
220
|
+
options,
|
|
221
|
+
remoteCache,
|
|
222
|
+
api,
|
|
223
|
+
outputObfuscator,
|
|
224
|
+
runStartTime,
|
|
225
|
+
messages,
|
|
226
|
+
endOfRunMessage,
|
|
227
|
+
taskExecutions,
|
|
228
|
+
versionOfNxBefore133,
|
|
229
|
+
inner,
|
|
230
|
+
encryptionKey,
|
|
231
|
+
fileStorage,
|
|
232
|
+
uploadInCurrentProcess,
|
|
233
|
+
runContext,
|
|
234
|
+
});
|
|
235
|
+
wrappedRes.complete();
|
|
236
|
+
}),
|
|
237
|
+
});
|
|
238
|
+
return wrappedRes;
|
|
239
|
+
// promise
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
return res
|
|
243
|
+
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
yield onComplete({
|
|
245
|
+
daemon: context.daemon,
|
|
246
|
+
lifeCycle,
|
|
247
|
+
options,
|
|
248
|
+
remoteCache,
|
|
249
|
+
api,
|
|
250
|
+
outputObfuscator,
|
|
251
|
+
runStartTime,
|
|
252
|
+
messages,
|
|
253
|
+
endOfRunMessage,
|
|
254
|
+
taskExecutions,
|
|
255
|
+
versionOfNxBefore133,
|
|
256
|
+
inner,
|
|
257
|
+
encryptionKey,
|
|
258
|
+
fileStorage,
|
|
259
|
+
uploadInCurrentProcess,
|
|
260
|
+
runContext,
|
|
261
|
+
});
|
|
262
|
+
return r;
|
|
263
|
+
}))
|
|
264
|
+
.catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
265
|
+
yield onComplete({
|
|
266
|
+
daemon: context.daemon,
|
|
267
|
+
lifeCycle,
|
|
268
|
+
options,
|
|
269
|
+
remoteCache,
|
|
270
|
+
api,
|
|
271
|
+
outputObfuscator,
|
|
272
|
+
runStartTime,
|
|
273
|
+
messages,
|
|
274
|
+
endOfRunMessage,
|
|
275
|
+
taskExecutions,
|
|
276
|
+
versionOfNxBefore133,
|
|
277
|
+
inner,
|
|
278
|
+
encryptionKey,
|
|
279
|
+
fileStorage,
|
|
280
|
+
uploadInCurrentProcess,
|
|
281
|
+
runContext,
|
|
282
|
+
});
|
|
283
|
+
throw e;
|
|
284
|
+
}));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
exports.cloudEnabledTasksRunner = cloudEnabledTasksRunner;
|
|
288
|
+
//# sourceMappingURL=cloud-enabled.runner.js.map
|