@nrwl/nx-cloud 13.3.1 → 13.5.1-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/bin/nx-cloud.js +10 -3
- package/bin/nx-cloud.js.map +1 -1
- package/generators.json +12 -0
- package/lib/core/api/error-reporter.api.d.ts +6 -0
- package/lib/core/api/error-reporter.api.js +36 -0
- package/lib/core/api/error-reporter.api.js.map +1 -0
- package/lib/core/api/run-group.api.d.ts +2 -2
- package/lib/core/api/run-group.api.js +73 -1
- package/lib/core/api/run-group.api.js.map +1 -1
- package/lib/core/commands/clean-up-agents.js +3 -3
- package/lib/core/commands/clean-up-agents.js.map +1 -1
- package/lib/core/commands/record-output.d.ts +0 -15
- package/lib/core/commands/record-output.js +36 -57
- package/lib/core/commands/record-output.js.map +1 -1
- package/lib/core/commands/start-ci-run.js +27 -5
- package/lib/core/commands/start-ci-run.js.map +1 -1
- package/lib/core/commands/stop-all-agents.js +6 -3
- package/lib/core/commands/stop-all-agents.js.map +1 -1
- package/lib/core/commands/upload-and-show-run-details.d.ts +1 -0
- package/lib/core/commands/upload-and-show-run-details.js +65 -0
- package/lib/core/commands/upload-and-show-run-details.js.map +1 -0
- package/lib/core/error/print-cacheable-targets-error.d.ts +1 -0
- package/lib/core/error/print-cacheable-targets-error.js +15 -0
- package/lib/core/error/print-cacheable-targets-error.js.map +1 -0
- 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/error/print-run-group-error.d.ts +1 -0
- package/lib/core/error/print-run-group-error.js +9 -5
- package/lib/core/error/print-run-group-error.js.map +1 -1
- package/lib/core/file-storage/file-storage.d.ts +11 -1
- package/lib/core/file-storage/file-storage.js +103 -21
- package/lib/core/file-storage/file-storage.js.map +1 -1
- package/lib/core/models/cloud-task-runner-options.d.ts +1 -1
- package/lib/core/models/distributed-agent/tasks-api-response.model.d.ts +6 -0
- package/lib/core/models/run-context.model.d.ts +89 -1
- package/lib/core/models/run-context.model.js +19 -0
- package/lib/core/models/run-context.model.js.map +1 -1
- package/lib/core/models/run-data.model.d.ts +1 -1
- package/lib/core/models/task-execution.model.d.ts +1 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.d.ts +1 -7
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +93 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.d.ts +1 -2
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +320 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.d.ts +8 -2
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +133 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.d.ts +7 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +168 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js.map +1 -1
- package/lib/core/runners/cloud-enabled/id-generator.d.ts +1 -0
- package/lib/core/runners/cloud-enabled/id-generator.js +16 -0
- package/lib/core/runners/cloud-enabled/id-generator.js.map +1 -0
- package/lib/core/runners/distributed-agent/distributed-agent.api.d.ts +6 -3
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +93 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js.map +1 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +157 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -1
- package/lib/core/runners/distributed-agent/execute-tasks.d.ts +10 -0
- package/lib/core/runners/distributed-agent/execute-tasks.js +114 -0
- package/lib/core/runners/distributed-agent/execute-tasks.js.map +1 -0
- package/lib/core/runners/distributed-agent/invoke-tasks-using-nx-imperative-api.d.ts +9 -0
- package/lib/core/runners/distributed-agent/invoke-tasks-using-nx-imperative-api.js +58 -0
- package/lib/core/runners/distributed-agent/invoke-tasks-using-nx-imperative-api.js.map +1 -0
- package/lib/core/runners/distributed-agent/invoke-tasks-using-run-many.d.ts +9 -0
- package/lib/core/runners/distributed-agent/invoke-tasks-using-run-many.js +97 -0
- package/lib/core/runners/distributed-agent/invoke-tasks-using-run-many.js.map +1 -0
- package/lib/core/runners/distributed-execution/distributed-execution.api.d.ts +2 -2
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +152 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js.map +1 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.d.ts +0 -11
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +118 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
- package/lib/core/runners/distributed-execution/process-task.d.ts +7 -0
- package/lib/core/runners/distributed-execution/process-task.js +45 -0
- package/lib/core/runners/distributed-execution/process-task.js.map +1 -0
- package/lib/core/runners/distributed-execution/process-tasks.d.ts +7 -0
- package/lib/core/runners/distributed-execution/process-tasks.js +67 -0
- package/lib/core/runners/distributed-execution/process-tasks.js.map +1 -0
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.d.ts +2 -0
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -0
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js.map +1 -0
- package/lib/core/runners/distributed-execution/task-graph-creator.d.ts +17 -0
- package/lib/core/runners/distributed-execution/task-graph-creator.js +100 -0
- package/lib/core/runners/distributed-execution/task-graph-creator.js.map +1 -0
- package/lib/core/terminal-output/end-of-run-message.d.ts +2 -1
- package/lib/core/terminal-output/end-of-run-message.js +18 -10
- package/lib/core/terminal-output/end-of-run-message.js.map +1 -1
- package/lib/core/terminal-output/read-task-terminal-output.d.ts +2 -0
- package/lib/core/terminal-output/read-task-terminal-output.js +60 -0
- package/lib/core/terminal-output/read-task-terminal-output.js.map +1 -0
- package/lib/daemon/process-run-end.d.ts +3 -0
- package/lib/daemon/process-run-end.js +66 -0
- package/lib/daemon/process-run-end.js.map +1 -0
- package/lib/generators/init/init.d.ts +1 -2
- package/lib/generators/init/init.js +33 -56
- package/lib/generators/init/init.js.map +1 -1
- package/lib/generators/init/schema.json +5 -0
- package/lib/nx-cloud-tasks-runner.js +83 -25
- package/lib/nx-cloud-tasks-runner.js.map +1 -1
- package/lib/utilities/axios.d.ts +2 -1
- package/lib/utilities/axios.js +26 -12
- package/lib/utilities/axios.js.map +1 -1
- package/lib/utilities/create-unchanged-value-timeout.d.ts +4 -0
- package/lib/utilities/{create-no-new-messages-timeout.js → create-unchanged-value-timeout.js} +6 -7
- package/lib/utilities/create-unchanged-value-timeout.js.map +1 -0
- package/lib/utilities/distributed-task-execution-detection.d.ts +2 -0
- package/lib/utilities/distributed-task-execution-detection.js +36 -0
- package/lib/utilities/distributed-task-execution-detection.js.map +1 -0
- package/lib/utilities/dte-artifact-storage.d.ts +7 -0
- package/lib/utilities/dte-artifact-storage.js +43 -0
- package/lib/utilities/dte-artifact-storage.js.map +1 -0
- package/lib/utilities/environment.d.ts +11 -7
- package/lib/utilities/environment.js +97 -33
- package/lib/utilities/environment.js.map +1 -1
- package/lib/utilities/is-ci.d.ts +1 -0
- package/lib/utilities/is-ci.js +21 -0
- package/lib/utilities/is-ci.js.map +1 -0
- package/lib/utilities/metric-logger.js +2 -2
- package/lib/utilities/metric-logger.js.map +1 -1
- package/lib/utilities/nx-imports.js +54 -33
- package/lib/utilities/nx-imports.js.map +1 -1
- package/lib/utilities/print-message.js +40 -11
- package/lib/utilities/print-message.js.map +1 -1
- package/lib/utilities/serializer-overrides.d.ts +3 -0
- package/lib/utilities/serializer-overrides.js +44 -0
- package/lib/utilities/serializer-overrides.js.map +1 -0
- package/package.json +7 -6
- package/project.json +37 -0
- package/tsconfig.lib.json +1 -1
- package/tsconfig.spec.json +2 -1
- package/collection.json +0 -22
- package/lib/utilities/create-no-new-messages-timeout.d.ts +0 -1
- package/lib/utilities/create-no-new-messages-timeout.js.map +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskGraphCreator = exports.createTaskGraphCompat = void 0;
|
|
4
|
+
const stripJsonComments = require("strip-json-comments");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const { getDependencyConfigs, workspaceRoot, } = require('../../../utilities/nx-imports');
|
|
7
|
+
function createTaskGraphCompat(options, projectGraph, tasks) {
|
|
8
|
+
const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString()));
|
|
9
|
+
return new TaskGraphCreator(projectGraph, getDefaultDependencyConfigs(nxjson, options)).createTaskGraph(tasks);
|
|
10
|
+
}
|
|
11
|
+
exports.createTaskGraphCompat = createTaskGraphCompat;
|
|
12
|
+
function getDefaultDependencyConfigs(nxJson, runnerOptions) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const defaults = (_a = nxJson.targetDependencies) !== null && _a !== void 0 ? _a : {};
|
|
15
|
+
const strictlyOrderedTargets = runnerOptions
|
|
16
|
+
? (_b = runnerOptions.strictlyOrderedTargets) !== null && _b !== void 0 ? _b : ['build']
|
|
17
|
+
: [];
|
|
18
|
+
// Strictly Ordered Targets depend on their dependencies
|
|
19
|
+
for (const target of strictlyOrderedTargets) {
|
|
20
|
+
defaults[target] = defaults[target] || [];
|
|
21
|
+
defaults[target].push({
|
|
22
|
+
target,
|
|
23
|
+
projects: 'dependencies',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return defaults;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* This is only used for versions of Nx prior to 14 where the task graph
|
|
30
|
+
* wasn't part of the context so we have to recreate it
|
|
31
|
+
*/
|
|
32
|
+
class TaskGraphCreator {
|
|
33
|
+
constructor(projectGraph, defaultTargetDependencies) {
|
|
34
|
+
this.projectGraph = projectGraph;
|
|
35
|
+
this.defaultTargetDependencies = defaultTargetDependencies;
|
|
36
|
+
}
|
|
37
|
+
createTaskGraph(tasks) {
|
|
38
|
+
const graph = {
|
|
39
|
+
roots: [],
|
|
40
|
+
tasks: {},
|
|
41
|
+
dependencies: {},
|
|
42
|
+
};
|
|
43
|
+
for (const task of tasks) {
|
|
44
|
+
this.addTaskToGraph(task, graph);
|
|
45
|
+
const dependencyConfigs = getDependencyConfigs(task.target, this.defaultTargetDependencies, this.projectGraph);
|
|
46
|
+
if (!dependencyConfigs) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
this.addTaskDependencies(task, dependencyConfigs, tasks, graph);
|
|
50
|
+
}
|
|
51
|
+
graph.roots = Object.keys(graph.dependencies).filter((k) => graph.dependencies[k].length === 0);
|
|
52
|
+
return graph;
|
|
53
|
+
}
|
|
54
|
+
addTaskDependencies(task, dependencyConfigs, tasks, graph) {
|
|
55
|
+
for (const dependencyConfig of dependencyConfigs) {
|
|
56
|
+
if (dependencyConfig.projects === 'self') {
|
|
57
|
+
for (const t of tasks) {
|
|
58
|
+
if (t.target.project === task.target.project &&
|
|
59
|
+
t.target.target === dependencyConfig.target) {
|
|
60
|
+
graph.dependencies[task.id].push(t.id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (dependencyConfig.projects === 'dependencies') {
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
this.addDependencies(task.target.project, dependencyConfig.target, tasks, graph, task.id, seen);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
addDependencies(project, target, tasks, graph, taskId, seen) {
|
|
71
|
+
seen.add(project);
|
|
72
|
+
const dependencies = this.projectGraph.dependencies[project];
|
|
73
|
+
if (dependencies) {
|
|
74
|
+
const projectDependencies = dependencies.map((dependency) => dependency.target);
|
|
75
|
+
for (const projectDependency of projectDependencies) {
|
|
76
|
+
if (seen.has(projectDependency)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const dependency = this.findTask({ project: projectDependency, target }, tasks);
|
|
80
|
+
if (dependency) {
|
|
81
|
+
if (graph.dependencies[taskId].indexOf(dependency.id) === -1) {
|
|
82
|
+
graph.dependencies[taskId].push(dependency.id);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.addDependencies(projectDependency, target, tasks, graph, taskId, seen);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
findTask({ project, target }, tasks) {
|
|
92
|
+
return tasks.find((t) => t.target.project === project && t.target.target === target);
|
|
93
|
+
}
|
|
94
|
+
addTaskToGraph(task, graph) {
|
|
95
|
+
graph.tasks[task.id] = task;
|
|
96
|
+
graph.dependencies[task.id] = [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.TaskGraphCreator = TaskGraphCreator;
|
|
100
|
+
//# sourceMappingURL=task-graph-creator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-graph-creator.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/distributed-execution/task-graph-creator.ts"],"names":[],"mappings":";;;AACA,yDAAyD;AACzD,2BAAkC;AAGlC,MAAM,EACJ,oBAAoB,EACpB,aAAa,GACd,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE7C,SAAgB,qBAAqB,CACnC,OAA+B,EAC/B,YAA0B,EAC1B,KAAa;IAEb,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACvB,iBAAiB,CAAC,IAAA,iBAAY,EAAC,GAAG,aAAa,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,CACvE,CAAC;IACF,OAAO,IAAI,gBAAgB,CACzB,YAAY,EACZ,2BAA2B,CAAC,MAAM,EAAE,OAAc,CAAC,CACpD,CAAC,eAAe,CAAC,KAAK,CAAC,CA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
export declare class EndOfRunMessage {
|
|
4
4
|
private readonly runContext;
|
|
5
5
|
private readonly taskExecutions;
|
|
6
|
-
|
|
6
|
+
private readonly distributedExecutionId;
|
|
7
|
+
constructor(runContext: RunContext, taskExecutions: TaskExecution[], distributedExecutionId: string | undefined);
|
|
7
8
|
printCacheHitsMessage(): void;
|
|
8
9
|
}
|
|
@@ -3,29 +3,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EndOfRunMessage = void 0;
|
|
4
4
|
const environment_1 = require("../../utilities/environment");
|
|
5
5
|
const print_message_1 = require("../../utilities/print-message");
|
|
6
|
-
const chalk = require('chalk');
|
|
7
6
|
class EndOfRunMessage {
|
|
8
|
-
constructor(runContext, taskExecutions) {
|
|
7
|
+
constructor(runContext, taskExecutions, distributedExecutionId) {
|
|
9
8
|
this.runContext = runContext;
|
|
10
9
|
this.taskExecutions = taskExecutions;
|
|
10
|
+
this.distributedExecutionId = distributedExecutionId;
|
|
11
11
|
}
|
|
12
12
|
printCacheHitsMessage() {
|
|
13
|
-
if (environment_1.
|
|
13
|
+
if ((0, environment_1.agentRunningInDistributedExecution)(this.distributedExecutionId))
|
|
14
14
|
return;
|
|
15
|
+
if (!this.runContext.runUrl) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const anyErrors = !!this.taskExecutions.find((te) => te.status !== 0);
|
|
19
|
+
const anyCacheMisses = !!this.taskExecutions.find((te) => te.cacheStatus === 'cache-miss');
|
|
15
20
|
const hits = this.taskExecutions
|
|
16
21
|
.filter((t) => this.runContext.statuses[t.hash] === 'remote-cache-hit')
|
|
17
22
|
.map((t) => t.projectName);
|
|
18
|
-
if (hits.length === 0 && !this.runContext.runUrl) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const tasks = hits.length === 1 ? hits[0] : `${hits.length} tasks`;
|
|
22
23
|
const message = [];
|
|
23
|
-
if (
|
|
24
|
-
message.push(`
|
|
24
|
+
if (anyErrors) {
|
|
25
|
+
message.push(`View structured, searchable error logs at ${this.runContext.runUrl}`);
|
|
26
|
+
}
|
|
27
|
+
else if (anyCacheMisses) {
|
|
28
|
+
message.push(`View logs and investigate cache misses at ${this.runContext.runUrl}`);
|
|
29
|
+
}
|
|
30
|
+
else if (hits.length > 0) {
|
|
31
|
+
const tasks = hits.length === 1 ? hits[0] : `${hits.length} tasks`;
|
|
32
|
+
message.push(`Nx Cloud made it possible to reuse ${tasks}: ${this.runContext.runUrl}`);
|
|
25
33
|
}
|
|
26
34
|
else {
|
|
27
35
|
if (this.runContext.runUrl) {
|
|
28
|
-
message.push(`
|
|
36
|
+
message.push(`View logs and run details at ${this.runContext.runUrl}`);
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
if (message.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"end-of-run-message.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/terminal-output/end-of-run-message.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"end-of-run-message.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/terminal-output/end-of-run-message.ts"],"names":[],"mappings":";;;AAEA,6DAAiF;AACjF,iEAA6D;AAE7D,MAAa,eAAe;IAC1B,YACmB,UAAsB,EACtB,cAA+B,EAC/B,sBAA0C;QAF1C,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAiB;QAC/B,2BAAsB,GAAtB,sBAAsB,CAAoB;IAC1D,CAAC;IAEJ,qBAAqB;QACnB,IAAI,IAAA,gDAAkC,EAAC,IAAI,CAAC,sBAAsB,CAAC;YAAE,OAAO;QAE5E,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAC3B,OAAO;SACR;QAED,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EA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AAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SACjC;IACH,CAAC;CACF;AA9CD,0CA8CC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { OutputObfuscator } from './output-obfuscator';
|
|
2
|
+
export declare function readTaskTerminalOutput(cacheDirectory: string | undefined, outputObfuscator: OutputObfuscator, hash: string, cacheStatus: 'remote-cache-hit' | 'local-cache-hit' | 'cache-miss', code: number): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readTaskTerminalOutput = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const { workspaceRoot } = require('../../utilities/nx-imports');
|
|
6
|
+
const environment_1 = require("../../utilities/environment");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const MAX_CHARACTERS_FAILED_TASK = 200000;
|
|
10
|
+
const MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
|
|
11
|
+
const MAX_CHARACTERS_CACHED_TASK = 20000;
|
|
12
|
+
function readTaskTerminalOutput(cacheDirectory, outputObfuscator, hash, cacheStatus, code) {
|
|
13
|
+
let dir;
|
|
14
|
+
if (cacheDirectory) {
|
|
15
|
+
if (cacheDirectory.startsWith('./')) {
|
|
16
|
+
dir = (0, path_1.join)(workspaceRoot, cacheDirectory);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
dir = cacheDirectory;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
dir = (0, path_1.join)(workspaceRoot, 'node_modules', '.cache', 'nx');
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const taskOutput = readTerminalOutputFile(dir, hash);
|
|
27
|
+
const taskOutputSanitized = outputObfuscator.obfuscate(taskOutput);
|
|
28
|
+
if (environment_1.NX_CLOUD_UNLIMITED_OUTPUT)
|
|
29
|
+
return taskOutputSanitized;
|
|
30
|
+
const maxCharacters = cacheStatus === 'cache-miss'
|
|
31
|
+
? code === 0
|
|
32
|
+
? MAX_CHARACTERS_SUCCESSFUL_TASK
|
|
33
|
+
: MAX_CHARACTERS_FAILED_TASK
|
|
34
|
+
: MAX_CHARACTERS_CACHED_TASK;
|
|
35
|
+
return taskOutputSanitized.length > maxCharacters
|
|
36
|
+
? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
|
|
37
|
+
: taskOutputSanitized;
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
41
|
+
console.error(e);
|
|
42
|
+
}
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.readTaskTerminalOutput = readTaskTerminalOutput;
|
|
47
|
+
function readTerminalOutputFile(dir, hash) {
|
|
48
|
+
try {
|
|
49
|
+
return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
|
|
50
|
+
}
|
|
51
|
+
catch (_a) {
|
|
52
|
+
try {
|
|
53
|
+
return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
|
|
54
|
+
}
|
|
55
|
+
catch (_b) {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=read-task-terminal-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-task-terminal-output.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/terminal-output/read-task-terminal-output.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAE5B,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAChE,6DAAwE;AACxE,2BAAkC;AAClC,6BAA6B;AAG7B,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAC1C,MAA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,sBAAsB,CAAC,GAAW,EAAE,IAAY;IACvD,IAAI;QACF,OAAO,IAAA,iBAAY,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;KACzE;IAAC,WAAM;QACN,IAAI;YACF,OAAO,IAAA,iBAAY,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SACxE;QAAC,WAAM;YACN,OAAO,EAAE,CAAC;SACX;KACF;AACH,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
const file_storage_1 = require("../core/file-storage/file-storage");
|
|
13
|
+
const cloud_run_api_1 = require("../core/runners/cloud-enabled/cloud-run.api");
|
|
14
|
+
const error_reporter_api_1 = require("../core/api/error-reporter.api");
|
|
15
|
+
const e2e_encryption_1 = require("../core/file-storage/e2e-encryption");
|
|
16
|
+
const environment_1 = require("../utilities/environment");
|
|
17
|
+
const message_reporter_1 = require("../core/terminal-output/message-reporter");
|
|
18
|
+
const metric_logger_1 = require("../utilities/metric-logger");
|
|
19
|
+
function processRunEnd(data, logger) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const encryption = new e2e_encryption_1.E2EEncryption(data.encryptionKey);
|
|
22
|
+
const errorApi = new error_reporter_api_1.ErrorReporterApi(data.runnerOptions);
|
|
23
|
+
const fileStorage = new file_storage_1.FileStorage(encryption, errorApi, data.runnerOptions, 'daemon');
|
|
24
|
+
const cachePath = (0, environment_1.getNxCacheDirectory)(data.runnerOptions);
|
|
25
|
+
const reporter = new message_reporter_1.MessageReporter(data.runnerOptions);
|
|
26
|
+
const runContext = {};
|
|
27
|
+
const machineInfo = (0, environment_1.getMachineInfo)(data.runnerOptions);
|
|
28
|
+
const api = new cloud_run_api_1.CloudRunApi(reporter, runContext, data.runnerOptions, machineInfo);
|
|
29
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
logger.log('Uploading file artifacts');
|
|
31
|
+
try {
|
|
32
|
+
yield Promise.all(data.delayedStoreRequests.map((t) => fileStorage.store(t.hash, t.url, cachePath)));
|
|
33
|
+
logger.log('Done uploading file artifacts');
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
logger.log('Error when uploading file artifacts');
|
|
37
|
+
console.log(e);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
for (const hash of fileStorage.storedHashes) {
|
|
41
|
+
const matchingTask = data.runEnd.taskExecutions.find((t) => t.hash === hash);
|
|
42
|
+
if (!matchingTask) {
|
|
43
|
+
throw new Error(`Task with hash ${hash} isn't recorded`);
|
|
44
|
+
}
|
|
45
|
+
matchingTask.uploadedToStorage = true;
|
|
46
|
+
}
|
|
47
|
+
logger.log('Sending EndRun request');
|
|
48
|
+
// check the return value
|
|
49
|
+
try {
|
|
50
|
+
const res = yield api.endRun(data.runEnd.runData, data.runEnd.taskExecutions, data.ciExecutionContext, data.runEnd.linkId);
|
|
51
|
+
if (!res) {
|
|
52
|
+
throw new Error(reporter.apiError);
|
|
53
|
+
}
|
|
54
|
+
logger.log('Done sending EndRun request');
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
logger.log('Error when sending EndRun');
|
|
58
|
+
console.log(e);
|
|
59
|
+
}
|
|
60
|
+
yield (0, metric_logger_1.submitRunMetrics)(data.runOptions);
|
|
61
|
+
}), 0);
|
|
62
|
+
return '{}';
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.default = processRunEnd;
|
|
66
|
+
//# sourceMappingURL=process-run-end.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-run-end.js","sourceRoot":"","sources":["../../../../../../libs/nx-packages/nx-cloud/lib/daemon/process-run-end.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oEAAgE;AAChE,+EAA0E;AAC1E,uEAAkE;AAClE,wEAAoE;AACpE,0DAA+E;AAC/E,+EAA2E;AAC3E,8DAA8D;AAE9D,SAA8B,aAAa,CACzC,IAAS,EACT,MAAsC;;QAEtC,MAAM,UAAU,GAAG,IAAI,8BAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzD,MAAM,QAAQ,GAAG,IAAI,qCAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,IAAI,0BAAW,CACjC,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,aAAa,EAClB,QAAQ,CACT,CAAC;QAEF,MAAM,SAAS,GAAG,IAAA,iCAAmB,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,IAAI,kCAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzD,MAAM,UAAU,GAAG,EAAS,CAAC;QAC7B,MAAM,WAAW,GAAG,IAAA,4BAAc,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACvD,MAAM,GAAG,GAAG,IAAI,2BAAW,CACzB,QAAQ,EACR,UAAU,EACV,IAAI,CAAC,aAAa,EAClB,WAAW,CACZ,CAAC;QAEF,UAAU,CAAC,GAA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6BAA6B,CAAC,CAAC;aAC3C;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;gBACxC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aAChB;YACD,MAAM,IAAA,gCAAgB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1C,CAAC,CAAA,EAAE,CAAC,CAAC,CAAC;QAEN,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAtED,gCAsEC"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function generator(host: any): Promise<() => void>;
|
|
2
|
-
export declare function schematic(): () => Promise<(host: any, context: any) => void>;
|
|
1
|
+
export declare function generator(host: any, schema: any): Promise<() => void>;
|
|
@@ -9,17 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.generator = void 0;
|
|
13
13
|
const fs_1 = require("fs");
|
|
14
|
-
const rxjs_1 = require("rxjs");
|
|
15
14
|
function updateNxJson(json, token) {
|
|
16
15
|
var _a, _b, _c;
|
|
17
16
|
const alreadySetOptions = (_c = (_b = (_a = json.tasksRunnerOptions) === null || _a === void 0 ? void 0 : _a.default) === null || _b === void 0 ? void 0 : _b.options) !== null && _c !== void 0 ? _c : {};
|
|
18
17
|
const options = Object.assign(Object.assign({}, alreadySetOptions), { accessToken: token });
|
|
19
|
-
// TODO: remove after Nx 13 is out
|
|
20
|
-
if (process.env.NRWL_API) {
|
|
21
|
-
options.url = process.env.NRWL_API;
|
|
22
|
-
}
|
|
23
18
|
if (process.env.NX_CLOUD_API) {
|
|
24
19
|
options.url = process.env.NX_CLOUD_API;
|
|
25
20
|
}
|
|
@@ -30,32 +25,39 @@ function updateNxJson(json, token) {
|
|
|
30
25
|
},
|
|
31
26
|
};
|
|
32
27
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
28
|
+
function updateNxJsonUsingNx(host, token) {
|
|
29
|
+
try {
|
|
30
|
+
const jsonUtils = require('nx/src/utils/json');
|
|
31
|
+
const json = jsonUtils.parseJson(host.read('nx.json', 'utf-8'));
|
|
35
32
|
updateNxJson(json, token);
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return require('@nrwl/workspace').updateJsonInTree('nx.json', (json) => {
|
|
33
|
+
host.write('nx.json', jsonUtils.serializeJson(json));
|
|
34
|
+
}
|
|
35
|
+
catch (ee) {
|
|
36
|
+
const json = JSON.parse(host.read('nx.json', 'utf-8'));
|
|
41
37
|
updateNxJson(json, token);
|
|
42
|
-
|
|
43
|
-
}
|
|
38
|
+
host.write('nx.json', JSON.stringify(json, null, 2));
|
|
39
|
+
}
|
|
44
40
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
function getRootPackageName() {
|
|
42
|
+
var _a;
|
|
43
|
+
let packageJson;
|
|
44
|
+
try {
|
|
45
|
+
packageJson = JSON.parse((0, fs_1.readFileSync)('package.json').toString());
|
|
46
|
+
}
|
|
47
|
+
catch (e) { }
|
|
48
|
+
return (_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.name) !== null && _a !== void 0 ? _a : 'my-workspace';
|
|
48
49
|
}
|
|
49
50
|
function removeTrailingSlash(apiUrl) {
|
|
50
51
|
return apiUrl[apiUrl.length - 1] === '/'
|
|
51
52
|
? apiUrl.substr(0, apiUrl.length - 1)
|
|
52
53
|
: apiUrl;
|
|
53
54
|
}
|
|
54
|
-
function createNxCloudWorkspace(workspaceName) {
|
|
55
|
+
function createNxCloudWorkspace(workspaceName, installationSource) {
|
|
55
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://
|
|
57
|
+
const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
|
|
57
58
|
const response = yield require('axios').post(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
|
|
58
59
|
workspaceName,
|
|
60
|
+
installationSource,
|
|
59
61
|
});
|
|
60
62
|
if (response.data.message) {
|
|
61
63
|
throw new Error(response.data.message);
|
|
@@ -71,49 +73,24 @@ function printMessage(url) {
|
|
|
71
73
|
}
|
|
72
74
|
catch (e) { }
|
|
73
75
|
output.note({
|
|
74
|
-
title: `Nx Cloud has been enabled`,
|
|
76
|
+
title: `Distributed caching via Nx Cloud has been enabled`,
|
|
75
77
|
bodyLines: [
|
|
76
|
-
`
|
|
77
|
-
`
|
|
78
|
+
`In addition to the caching, Nx Cloud provides config-free distributed execution,`,
|
|
79
|
+
`UI for viewing complex runs and GitHub integration. Learn more at https://nx.app`,
|
|
80
|
+
``,
|
|
81
|
+
`Your workspace is currently unclaimed. Run details from unclaimed workspaces can be viewed on ${host} by anyone`,
|
|
82
|
+
`with the link. Claim your workspace at the following link to restrict access.`,
|
|
83
|
+
``,
|
|
84
|
+
`${url}`,
|
|
78
85
|
],
|
|
79
86
|
});
|
|
80
87
|
}
|
|
81
|
-
function
|
|
82
|
-
return {
|
|
83
|
-
name: 'NxCloudPrintMessage',
|
|
84
|
-
create: () => {
|
|
85
|
-
return Promise.resolve(() => {
|
|
86
|
-
return new rxjs_1.Observable((obs) => {
|
|
87
|
-
printMessage(url);
|
|
88
|
-
obs.next();
|
|
89
|
-
obs.complete();
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function generator(host) {
|
|
88
|
+
function generator(host, schema) {
|
|
96
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
const r = yield createNxCloudWorkspace(
|
|
98
|
-
|
|
90
|
+
const r = yield createNxCloudWorkspace(getRootPackageName(), schema.installationSource);
|
|
91
|
+
updateNxJsonUsingNx(host, r.token);
|
|
99
92
|
return () => printMessage(r.url);
|
|
100
93
|
});
|
|
101
94
|
}
|
|
102
95
|
exports.generator = generator;
|
|
103
|
-
function schematic() {
|
|
104
|
-
return () => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
const r = yield createNxCloudWorkspace(readNpmScope());
|
|
106
|
-
return (host, context) => {
|
|
107
|
-
const engineHost = context.engine.workflow.engineHost;
|
|
108
|
-
engineHost.registerTaskExecutor(printMessageTaskExecutor(r.url));
|
|
109
|
-
context.addTask({
|
|
110
|
-
toConfiguration() {
|
|
111
|
-
return { name: 'NxCloudPrintMessage' };
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
updateNxJsonUsingNrwlWorkspace(r.token)(host, context);
|
|
115
|
-
};
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
exports.schematic = schematic;
|
|
119
96
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/generators/init/init.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAAkC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/generators/init/init.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAAkC;AAElC,SAAS,YAAY,CAAC,IAAI,EAAE,KAAa;;IACvC,MAAM,iBAAiB,GAAG,MAAA,MAAA,MAAA,IAAI,CAAC,kBAAkB,0CAAE,OAAO,0CAAE,OAAO,mCAAI,EAAE,CAAC;IAE1E,MAAM,OAAO,mCACR,iBAAiB,KACpB,WAAW,EAAE,KAAK,GACnB,CAAC;IAEF,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;QAC5B,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;KACxC;IAED,IAAI,CAAC,kBAAkB,GAAG;QACxB,OAAO,EAAE;YACP,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,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;CAAA;AAPD,8BAOC"}
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
"type": "boolean",
|
|
10
10
|
"description": "Anonymously store hashed machine ID for task runs",
|
|
11
11
|
"default": false
|
|
12
|
+
},
|
|
13
|
+
"installationSource": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Name of Nx Cloud installation invoker (ex. user, add-nx-to-monorepo, create-nx-workspace, nx-upgrade",
|
|
16
|
+
"default": "user"
|
|
12
17
|
}
|
|
13
18
|
},
|
|
14
19
|
"additionalProperties": false,
|