@nrwl/nx-cloud 15.0.4-beta.2 → 15.0.4-beta.3
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.d.ts +2 -0
- package/bin/nx-cloud.js +50 -0
- package/bin/nx-cloud.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +5 -0
- package/index.js.map +1 -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 +7 -0
- package/lib/core/api/run-group.api.js +68 -0
- package/lib/core/api/run-group.api.js.map +1 -0
- package/lib/core/commands/clean-up-agents.d.ts +1 -0
- package/lib/core/commands/clean-up-agents.js +34 -0
- package/lib/core/commands/clean-up-agents.js.map +1 -0
- package/lib/core/commands/record-output.d.ts +1 -0
- package/lib/core/commands/record-output.js +177 -0
- package/lib/core/commands/record-output.js.map +1 -0
- package/lib/core/commands/start-ci-run.d.ts +1 -0
- package/lib/core/commands/start-ci-run.js +61 -0
- package/lib/core/commands/start-ci-run.js.map +1 -0
- package/lib/core/commands/stop-all-agents.d.ts +1 -0
- package/lib/core/commands/stop-all-agents.js +37 -0
- package/lib/core/commands/stop-all-agents.js.map +1 -0
- package/lib/core/commands/upload-and-show-run-details.d.ts +1 -0
- package/lib/core/commands/upload-and-show-run-details.js +60 -0
- package/lib/core/commands/upload-and-show-run-details.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 +16 -0
- package/lib/core/error/print-run-group-error.js.map +1 -0
- package/lib/core/file-storage/e2e-encryption.d.ts +9 -0
- package/lib/core/file-storage/e2e-encryption.js +46 -0
- package/lib/core/file-storage/e2e-encryption.js.map +1 -0
- package/lib/core/file-storage/file-storage.d.ts +24 -0
- package/lib/core/file-storage/file-storage.js +262 -0
- package/lib/core/file-storage/file-storage.js.map +1 -0
- package/lib/core/models/cache-urls.model.d.ts +6 -0
- package/lib/core/models/cache-urls.model.js +3 -0
- package/lib/core/models/cache-urls.model.js.map +1 -0
- package/lib/core/models/cloud-task-runner-options.d.ts +20 -0
- package/lib/core/models/cloud-task-runner-options.js +3 -0
- package/lib/core/models/cloud-task-runner-options.js.map +1 -0
- package/lib/core/models/distributed-agent/grouped-tasks.model.d.ts +6 -0
- package/lib/core/models/distributed-agent/grouped-tasks.model.js +3 -0
- package/lib/core/models/distributed-agent/grouped-tasks.model.js.map +1 -0
- package/lib/core/models/distributed-agent/index.d.ts +3 -0
- package/lib/core/models/distributed-agent/index.js +20 -0
- package/lib/core/models/distributed-agent/index.js.map +1 -0
- package/lib/core/models/distributed-agent/task-to-execute.model.d.ts +7 -0
- package/lib/core/models/distributed-agent/task-to-execute.model.js +3 -0
- package/lib/core/models/distributed-agent/task-to-execute.model.js.map +1 -0
- package/lib/core/models/distributed-agent/tasks-api-response.model.d.ts +10 -0
- package/lib/core/models/distributed-agent/tasks-api-response.model.js +3 -0
- package/lib/core/models/distributed-agent/tasks-api-response.model.js.map +1 -0
- package/lib/core/models/machine-info.model.d.ts +6 -0
- package/lib/core/models/machine-info.model.js +3 -0
- package/lib/core/models/machine-info.model.js.map +1 -0
- package/lib/core/models/run-context.model.d.ts +128 -0
- package/lib/core/models/run-context.model.js +22 -0
- package/lib/core/models/run-context.model.js.map +1 -0
- package/lib/core/models/run-data.model.d.ts +11 -0
- package/lib/core/models/run-data.model.js +3 -0
- package/lib/core/models/run-data.model.js.map +1 -0
- package/lib/core/models/task-execution.model.d.ts +13 -0
- package/lib/core/models/task-execution.model.js +3 -0
- package/lib/core/models/task-execution.model.js.map +1 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.d.ts +19 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +84 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js.map +1 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.d.ts +3 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +288 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -0
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.d.ts +16 -0
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +117 -0
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js.map +1 -0
- package/lib/core/runners/cloud-enabled/cloud-run.api.d.ts +18 -0
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +167 -0
- package/lib/core/runners/cloud-enabled/cloud-run.api.js.map +1 -0
- 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 +13 -0
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -0
- package/lib/core/runners/distributed-agent/distributed-agent.api.js.map +1 -0
- package/lib/core/runners/distributed-agent/distributed-agent.impl.d.ts +1 -0
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +269 -0
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -0
- package/lib/core/runners/distributed-execution/distributed-execution.api.d.ts +10 -0
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +143 -0
- package/lib/core/runners/distributed-execution/distributed-execution.api.js.map +1 -0
- package/lib/core/runners/distributed-execution/distributed-execution.runner.d.ts +1 -0
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +241 -0
- package/lib/core/runners/distributed-execution/distributed-execution.runner.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 +15 -0
- package/lib/core/runners/distributed-execution/task-graph-creator.js +77 -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 +8 -0
- package/lib/core/terminal-output/end-of-run-message.js +44 -0
- package/lib/core/terminal-output/end-of-run-message.js.map +1 -0
- package/lib/core/terminal-output/message-reporter.d.ts +11 -0
- package/lib/core/terminal-output/message-reporter.js +71 -0
- package/lib/core/terminal-output/message-reporter.js.map +1 -0
- package/lib/core/terminal-output/output-obfuscator.d.ts +6 -0
- package/lib/core/terminal-output/output-obfuscator.js +48 -0
- package/lib/core/terminal-output/output-obfuscator.js.map +1 -0
- 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 +60 -0
- package/lib/daemon/process-run-end.js.map +1 -0
- package/lib/generators/init/init.d.ts +1 -0
- package/lib/generators/init/init.js +96 -0
- package/lib/generators/init/init.js.map +1 -0
- package/lib/nx-cloud-tasks-runner.d.ts +2 -0
- package/lib/nx-cloud-tasks-runner.js +146 -0
- package/lib/nx-cloud-tasks-runner.js.map +1 -0
- package/lib/utilities/axios.d.ts +10 -0
- package/lib/utilities/axios.js +87 -0
- package/lib/utilities/axios.js.map +1 -0
- package/lib/utilities/create-unchanged-value-timeout.d.ts +4 -0
- package/lib/utilities/create-unchanged-value-timeout.js +24 -0
- 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/environment.d.ts +27 -0
- package/lib/utilities/environment.js +200 -0
- package/lib/utilities/environment.js.map +1 -0
- 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.d.ts +22 -0
- package/lib/utilities/metric-logger.js +70 -0
- package/lib/utilities/metric-logger.js.map +1 -0
- package/lib/utilities/nx-imports.d.ts +0 -0
- package/lib/utilities/nx-imports.js +59 -0
- package/lib/utilities/nx-imports.js.map +1 -0
- package/lib/utilities/print-message.d.ts +1 -0
- package/lib/utilities/print-message.js +64 -0
- package/lib/utilities/print-message.js.map +1 -0
- package/lib/utilities/serializer-overrides.d.ts +2 -0
- package/lib/utilities/serializer-overrides.js +40 -0
- package/lib/utilities/serializer-overrides.js.map +1 -0
- package/lib/utilities/waiter.d.ts +6 -0
- package/lib/utilities/waiter.js +36 -0
- package/lib/utilities/waiter.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,241 @@
|
|
|
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.nxCloudDistributedTasksRunner = void 0;
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const stripJsonComments = require("strip-json-comments");
|
|
15
|
+
const create_unchanged_value_timeout_1 = require("../../../utilities/create-unchanged-value-timeout");
|
|
16
|
+
const environment_1 = require("../../../utilities/environment");
|
|
17
|
+
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
18
|
+
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
19
|
+
const waiter_1 = require("../../../utilities/waiter");
|
|
20
|
+
const error_reporter_api_1 = require("../../api/error-reporter.api");
|
|
21
|
+
const print_run_group_error_1 = require("../../error/print-run-group-error");
|
|
22
|
+
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
|
|
23
|
+
const file_storage_1 = require("../../file-storage/file-storage");
|
|
24
|
+
const distributed_execution_api_1 = require("./distributed-execution.api");
|
|
25
|
+
const split_task_graph_into_stages_1 = require("./split-task-graph-into-stages");
|
|
26
|
+
const task_graph_creator_1 = require("./task-graph-creator");
|
|
27
|
+
const { output, workspaceRoot, getOutputs, Cache, } = require('../../../utilities/nx-imports');
|
|
28
|
+
class NoopLifeCycle {
|
|
29
|
+
scheduleTask(task) { }
|
|
30
|
+
startTask(task) { }
|
|
31
|
+
endTasks(tasks) { }
|
|
32
|
+
}
|
|
33
|
+
function runDistributedExecution(api, options, context, fileStorage, cache, runGroup, taskGraph) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const id = yield api.start((0, distributed_execution_api_1.createStartRequest)(runGroup, (0, split_task_graph_into_stages_1.splitTasksIntoStages)(taskGraph), options));
|
|
36
|
+
return yield processTasks(api, fileStorage, cache, options, id, Object.values(taskGraph.tasks), context);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function processTasks(api, fileStorage, cache, options, executionId, tasks, context) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const processedTasks = {};
|
|
42
|
+
const failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout = (0, create_unchanged_value_timeout_1.createUnchangedValueTimeout)({
|
|
43
|
+
title: `No new completed tasks after ${environment_1.NO_COMPLETED_TASKS_TIMEOUT / 1000} seconds.`,
|
|
44
|
+
timeout: environment_1.NO_COMPLETED_TASKS_TIMEOUT,
|
|
45
|
+
});
|
|
46
|
+
const waiter = new waiter_1.Waiter();
|
|
47
|
+
while (true) {
|
|
48
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
49
|
+
output.note({
|
|
50
|
+
title: 'Waiting...',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
yield waiter.wait();
|
|
54
|
+
const r = yield api.status(executionId);
|
|
55
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
56
|
+
output.note({
|
|
57
|
+
title: `Status update`,
|
|
58
|
+
bodyLines: [
|
|
59
|
+
`executionId: ${executionId}`,
|
|
60
|
+
`executionStatus: ${r.executionStatus}`,
|
|
61
|
+
`number of completed tasks: ${r.completedTasks.length}`,
|
|
62
|
+
`error: ${r.criticalErrorMessage}`,
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (r.criticalErrorMessage) {
|
|
67
|
+
output.error({
|
|
68
|
+
title: 'Distributed Execution Terminated',
|
|
69
|
+
bodyLines: ['Error:', r.criticalErrorMessage],
|
|
70
|
+
});
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
failIfNumberOfCompletedTasksDoesNotChangeAfterTimeout(r.completedTasks.length);
|
|
74
|
+
for (const t of r.completedTasks) {
|
|
75
|
+
if (processedTasks[t.taskId])
|
|
76
|
+
continue;
|
|
77
|
+
yield processTask(fileStorage, cache, context, options, tasks, t);
|
|
78
|
+
waiter.reset();
|
|
79
|
+
processedTasks[t.taskId] = true;
|
|
80
|
+
}
|
|
81
|
+
if (r.executionStatus === 'COMPLETED') {
|
|
82
|
+
return { commandStatus: r.commandStatus, runUrl: r.runUrl };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function processTask(fileStorage, cache, context, options, tasks, completedTask) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
90
|
+
output.note({
|
|
91
|
+
title: `Processing task ${completedTask.taskId}`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const matchingTask = tasks.find((tt) => completedTask.taskId === tt.id);
|
|
95
|
+
if (!matchingTask) {
|
|
96
|
+
throw new Error(`Found unknown task: ${completedTask.taskId}`);
|
|
97
|
+
}
|
|
98
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
99
|
+
output.note({
|
|
100
|
+
title: `Retrieving artifacts from ${completedTask.url}`,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const outputs = getOutputs(context.projectGraph.nodes, matchingTask);
|
|
104
|
+
try {
|
|
105
|
+
yield fileStorage.retrieve(completedTask.hash, completedTask.url, (0, environment_1.getNxCacheDirectory)(options));
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
if (outputs.length > 0 && !outputs.find((output) => (0, fs_1.existsSync)(output))) {
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
output.warn({
|
|
113
|
+
title: `Unable to download ${completedTask.url}. Hash: ${completedTask.hash}`,
|
|
114
|
+
bodyLines: [
|
|
115
|
+
'The files have been extracted from a previous command invocation.',
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const cachedResult = yield cache.get(Object.assign(Object.assign({}, matchingTask), { hash: completedTask.hash }));
|
|
121
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
122
|
+
output.note({
|
|
123
|
+
title: `Extracting artifacts`,
|
|
124
|
+
bodyLines: outputs,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
yield cache.copyFilesFromCache(completedTask.hash, cachedResult, outputs);
|
|
128
|
+
output.logCommand(getCommand(matchingTask));
|
|
129
|
+
process.stdout.write(cachedResult.terminalOutput);
|
|
130
|
+
output.addVerticalSeparator();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function getCommand(task) {
|
|
134
|
+
const config = task.target.configuration
|
|
135
|
+
? `:${task.target.configuration}`
|
|
136
|
+
: '';
|
|
137
|
+
return [
|
|
138
|
+
'nx',
|
|
139
|
+
'run',
|
|
140
|
+
`${task.target.project}:${task.target.target}${config}`,
|
|
141
|
+
(0, serializer_overrides_1.serializeOverrides)(task),
|
|
142
|
+
].join(' ');
|
|
143
|
+
}
|
|
144
|
+
function attachSignalListenersToCompleteRunGroupOnError(api, runGroup) {
|
|
145
|
+
process.on('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
yield api.completeRunGroupWithError(runGroup, 'Main job was terminated via SIGINT');
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}));
|
|
149
|
+
process.on('SIGTERM', () => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
yield api.completeRunGroupWithError(runGroup, 'Main job was terminated via SIGTERM');
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
const nxCloudDistributedTasksRunner = (tasks, options, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
if (options.skipNxCache) {
|
|
156
|
+
output.warn({
|
|
157
|
+
title: `--skip-nx-cache is ignored when using distributed tasks execution (DTE).`,
|
|
158
|
+
bodyLine: [`DTE needs the cache to share files between agents.`],
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
162
|
+
output.note({
|
|
163
|
+
title: 'Starting distributed command execution',
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
options.lifeCycle = new NoopLifeCycle();
|
|
167
|
+
const runGroup = (0, environment_1.getRunGroup)();
|
|
168
|
+
if (!runGroup) {
|
|
169
|
+
(0, print_run_group_error_1.printRunGroupError)();
|
|
170
|
+
return process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
|
|
173
|
+
const errorReporter = new error_reporter_api_1.ErrorReporterApi(options);
|
|
174
|
+
const fileStorage = new file_storage_1.FileStorage(encryption, errorReporter, true, false);
|
|
175
|
+
const cache = new Cache(options);
|
|
176
|
+
const api = new distributed_execution_api_1.DistributedExecutionApi(options);
|
|
177
|
+
attachSignalListenersToCompleteRunGroupOnError(api, runGroup);
|
|
178
|
+
try {
|
|
179
|
+
const taskGraph = getTaskGraph(context, tasks, options);
|
|
180
|
+
const r = yield runDistributedExecution(api, options, context, fileStorage, cache, runGroup, taskGraph);
|
|
181
|
+
if (r.commandStatus === 0) {
|
|
182
|
+
output.success({
|
|
183
|
+
title: 'Successfully completed running the command.',
|
|
184
|
+
bodyLines: [`See run details at ${r.runUrl}`],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
output.error({
|
|
189
|
+
title: 'Command execution failed.',
|
|
190
|
+
bodyLines: [`See run details at ${r.runUrl}`],
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
194
|
+
process.exit(r.commandStatus);
|
|
195
|
+
}
|
|
196
|
+
catch (e) {
|
|
197
|
+
output.error({
|
|
198
|
+
title: 'Unable to complete a run.',
|
|
199
|
+
bodyLines: [e.message],
|
|
200
|
+
});
|
|
201
|
+
if (e.axiosException) {
|
|
202
|
+
console.log(e.axiosException);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
console.log(e);
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
yield api.completeRunGroupWithError(runGroup, `Main job terminated with an error: "${e.message}"`);
|
|
209
|
+
}
|
|
210
|
+
finally {
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
exports.nxCloudDistributedTasksRunner = nxCloudDistributedTasksRunner;
|
|
216
|
+
function getTaskGraph(context, tasks, options) {
|
|
217
|
+
if (context.taskGraph) {
|
|
218
|
+
return context.taskGraph;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)(`${workspaceRoot}/nx.json`).toString()));
|
|
222
|
+
return new task_graph_creator_1.TaskGraphCreator(context.projectGraph, getDefaultDependencyConfigs(nxjson, options)).createTaskGraph(tasks);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function getDefaultDependencyConfigs(nxJson, runnerOptions) {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
const defaults = (_a = nxJson.targetDependencies) !== null && _a !== void 0 ? _a : {};
|
|
228
|
+
const strictlyOrderedTargets = runnerOptions
|
|
229
|
+
? (_b = runnerOptions.strictlyOrderedTargets) !== null && _b !== void 0 ? _b : ['build']
|
|
230
|
+
: [];
|
|
231
|
+
// Strictly Ordered Targets depend on their dependencies
|
|
232
|
+
for (const target of strictlyOrderedTargets) {
|
|
233
|
+
defaults[target] = defaults[target] || [];
|
|
234
|
+
defaults[target].push({
|
|
235
|
+
target,
|
|
236
|
+
projects: 'dependencies',
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return defaults;
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=distributed-execution.runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distributed-execution.runner.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/distributed-execution/distributed-execution.runner.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAA8C;AAC9C,yDAAyD;AACzD,sGAAgG;AAChG,gEAMwC;AACxC,oEAAoE;AACpE,kFAA6E;AAC7E,sDAAmD;AACnD,qEAAgE;AAChE,6EAAuE;AACvE,sEAAkE;AAClE,kEAA8D;AAG9D,2EAGqC;AACrC,iFAAsE;AACtE,6DAAwD;AAExD,MAAM,EACJ,MAAM,EACN,aAAa,EACb,UAAU,EACV,KAAK,GACN,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAY7C,MAAM,aAAa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OAAc,CAAC,CACpD,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;KAC1B;AACH,CAAC;AAED,SAAS,2BAA2B,CAClC,MAAW,EACX,aAEC;;IAED,MAAM,QAAQ,GAA0B,MAAA,MAAM,CAAC,kBAAkB,mCAAI,EAAE,CAAC;IACxE,MAAM,sBAAsB,GAAG,aAAa;QAC1C,CAAC,CAAC,MAAA,aAAa,CAAC,sBAAsB,mCAAI,CAAC,OAAO,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC;IACP,wDAAwD;IACxD,KAAK,MAAM,MAAM,IAAI,sBAAsB,EAAE;QAC3C,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC1C,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YACpB,MAAM;YACN,QAAQ,EAAE,cAAc;SACzB,CAAC,CAAC;KACJ;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitTasksIntoStages = void 0;
|
|
4
|
+
function splitTasksIntoStages(taskGraph) {
|
|
5
|
+
const stages = [];
|
|
6
|
+
const notStagedTaskIds = new Set(Object.values(taskGraph.tasks).map((t) => t.id));
|
|
7
|
+
let stageIndex = 0;
|
|
8
|
+
// Loop through tasks and try to stage them. As tasks are staged, they are removed from the loop
|
|
9
|
+
while (notStagedTaskIds.size > 0) {
|
|
10
|
+
const currentStage = (stages[stageIndex] = []);
|
|
11
|
+
for (const taskId of notStagedTaskIds) {
|
|
12
|
+
let ready = true;
|
|
13
|
+
for (const dependency of taskGraph.dependencies[taskId]) {
|
|
14
|
+
if (notStagedTaskIds.has(dependency)) {
|
|
15
|
+
// dependency has not been staged yet, this task is not ready to be staged.
|
|
16
|
+
ready = false;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Some dependency still has not been staged, skip it for now, it will be processed again
|
|
21
|
+
if (!ready) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
// All the dependencies have been staged, let's stage it.
|
|
25
|
+
const task = taskGraph.tasks[taskId];
|
|
26
|
+
currentStage.push(task);
|
|
27
|
+
}
|
|
28
|
+
// Remove the entire new stage of tasks from the list
|
|
29
|
+
for (const task of currentStage) {
|
|
30
|
+
notStagedTaskIds.delete(task.id);
|
|
31
|
+
}
|
|
32
|
+
stageIndex++;
|
|
33
|
+
}
|
|
34
|
+
return stages;
|
|
35
|
+
}
|
|
36
|
+
exports.splitTasksIntoStages = splitTasksIntoStages;
|
|
37
|
+
//# sourceMappingURL=split-task-graph-into-stages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-task-graph-into-stages.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/distributed-execution/split-task-graph-into-stages.ts"],"names":[],"mappings":";;;AAEA,SAAgB,oBAAoB,CAAC,SAAoB;IACvD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAChD,CAAC;IACF,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,gGAAgG;IAChG,OAAO,gBAAgB,CAAC,IAAI,GAAG,CAAC,EAAE;QAChC,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAQ,CAAC;QACtD,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE;YACrC,IAAI,KAAK,GAAG,IAAI,CAAC;YACjB,KAAK,MAAM,UAAU,IAAI,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;gBACvD,IAAI,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;oBACpC,2EAA2E;oBAC3E,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;iBACP;aACF;YAED,yFAAyF;YACzF,IAAI,CAAC,KAAK,EAAE;gBACV,SAAS;aACV;YAED,yDAAyD;YACzD,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACrC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACzB;QAED,qDAAqD;QACrD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE;YAC/B,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAClC;QACD,UAAU,EAAE,CAAC;KACd;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AArCD,oDAqCC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProjectGraph, Task, TaskGraph } from '../../models/run-context.model';
|
|
2
|
+
/**
|
|
3
|
+
* This is only used for versions of Nx prior to 14 where the task graph
|
|
4
|
+
* wasn't part of the context so we have to recreate it
|
|
5
|
+
*/
|
|
6
|
+
export declare class TaskGraphCreator {
|
|
7
|
+
private readonly projectGraph;
|
|
8
|
+
private readonly defaultTargetDependencies;
|
|
9
|
+
constructor(projectGraph: ProjectGraph, defaultTargetDependencies: Record<string, any[]>);
|
|
10
|
+
createTaskGraph(tasks: Task[]): TaskGraph;
|
|
11
|
+
private addTaskDependencies;
|
|
12
|
+
private addDependencies;
|
|
13
|
+
private findTask;
|
|
14
|
+
private addTaskToGraph;
|
|
15
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskGraphCreator = void 0;
|
|
4
|
+
const { getDependencyConfigs } = require('../../../utilities/nx-imports');
|
|
5
|
+
/**
|
|
6
|
+
* This is only used for versions of Nx prior to 14 where the task graph
|
|
7
|
+
* wasn't part of the context so we have to recreate it
|
|
8
|
+
*/
|
|
9
|
+
class TaskGraphCreator {
|
|
10
|
+
constructor(projectGraph, defaultTargetDependencies) {
|
|
11
|
+
this.projectGraph = projectGraph;
|
|
12
|
+
this.defaultTargetDependencies = defaultTargetDependencies;
|
|
13
|
+
}
|
|
14
|
+
createTaskGraph(tasks) {
|
|
15
|
+
const graph = {
|
|
16
|
+
roots: [],
|
|
17
|
+
tasks: {},
|
|
18
|
+
dependencies: {},
|
|
19
|
+
};
|
|
20
|
+
for (const task of tasks) {
|
|
21
|
+
this.addTaskToGraph(task, graph);
|
|
22
|
+
const dependencyConfigs = getDependencyConfigs(task.target, this.defaultTargetDependencies, this.projectGraph);
|
|
23
|
+
if (!dependencyConfigs) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
this.addTaskDependencies(task, dependencyConfigs, tasks, graph);
|
|
27
|
+
}
|
|
28
|
+
graph.roots = Object.keys(graph.dependencies).filter((k) => graph.dependencies[k].length === 0);
|
|
29
|
+
return graph;
|
|
30
|
+
}
|
|
31
|
+
addTaskDependencies(task, dependencyConfigs, tasks, graph) {
|
|
32
|
+
for (const dependencyConfig of dependencyConfigs) {
|
|
33
|
+
if (dependencyConfig.projects === 'self') {
|
|
34
|
+
for (const t of tasks) {
|
|
35
|
+
if (t.target.project === task.target.project &&
|
|
36
|
+
t.target.target === dependencyConfig.target) {
|
|
37
|
+
graph.dependencies[task.id].push(t.id);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if (dependencyConfig.projects === 'dependencies') {
|
|
42
|
+
const seen = new Set();
|
|
43
|
+
this.addDependencies(task.target.project, dependencyConfig.target, tasks, graph, task.id, seen);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
addDependencies(project, target, tasks, graph, taskId, seen) {
|
|
48
|
+
seen.add(project);
|
|
49
|
+
const dependencies = this.projectGraph.dependencies[project];
|
|
50
|
+
if (dependencies) {
|
|
51
|
+
const projectDependencies = dependencies.map((dependency) => dependency.target);
|
|
52
|
+
for (const projectDependency of projectDependencies) {
|
|
53
|
+
if (seen.has(projectDependency)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const dependency = this.findTask({ project: projectDependency, target }, tasks);
|
|
57
|
+
if (dependency) {
|
|
58
|
+
if (graph.dependencies[taskId].indexOf(dependency.id) === -1) {
|
|
59
|
+
graph.dependencies[taskId].push(dependency.id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.addDependencies(projectDependency, target, tasks, graph, taskId, seen);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
findTask({ project, target }, tasks) {
|
|
69
|
+
return tasks.find((t) => t.target.project === project && t.target.target === target);
|
|
70
|
+
}
|
|
71
|
+
addTaskToGraph(task, graph) {
|
|
72
|
+
graph.tasks[task.id] = task;
|
|
73
|
+
graph.dependencies[task.id] = [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.TaskGraphCreator = TaskGraphCreator;
|
|
77
|
+
//# 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":";;;AAEA,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAa,gBAAgB;IAC3B,YACmB,YAA0B,EAC1B,yBAAgD;QADhD,iBAAY,GAAZ,YAAY,CAAc;QAC1B,8BAAyB,GAAzB,yBAAyB,CAAuB;IAChE,CAAC;IAEJ,eAAe,CAAC,KAAa;QAC3B,MAAM,KAAK,GAAQ;YACjB,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,EAAE;YACT,YAAY,EAAE,EA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C,CAAC,CAAC,MAAM,CAAC,OAAO,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAC3D,CAAC;IACX,CAAC;IAEO,cAAc,CAAC,IAAU,EAAE,KAAU;QAC3C,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;QAC5B,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AAvHD,4CAuHC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RunContext } from '../models/run-context.model';
|
|
2
|
+
import { TaskExecution } from '../models/task-execution.model';
|
|
3
|
+
export declare class EndOfRunMessage {
|
|
4
|
+
private readonly runContext;
|
|
5
|
+
private readonly taskExecutions;
|
|
6
|
+
constructor(runContext: RunContext, taskExecutions: TaskExecution[]);
|
|
7
|
+
printCacheHitsMessage(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EndOfRunMessage = void 0;
|
|
4
|
+
const environment_1 = require("../../utilities/environment");
|
|
5
|
+
const print_message_1 = require("../../utilities/print-message");
|
|
6
|
+
class EndOfRunMessage {
|
|
7
|
+
constructor(runContext, taskExecutions) {
|
|
8
|
+
this.runContext = runContext;
|
|
9
|
+
this.taskExecutions = taskExecutions;
|
|
10
|
+
}
|
|
11
|
+
printCacheHitsMessage() {
|
|
12
|
+
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION)
|
|
13
|
+
return;
|
|
14
|
+
if (!this.runContext.runUrl) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const anyErrors = !!this.taskExecutions.find((te) => te.status !== 0);
|
|
18
|
+
const anyCacheMisses = !!this.taskExecutions.find((te) => te.cacheStatus === 'cache-miss');
|
|
19
|
+
const hits = this.taskExecutions
|
|
20
|
+
.filter((t) => this.runContext.statuses[t.hash] === 'remote-cache-hit')
|
|
21
|
+
.map((t) => t.projectName);
|
|
22
|
+
const message = [];
|
|
23
|
+
if (anyErrors) {
|
|
24
|
+
message.push(`View structured, searchable error logs at ${this.runContext.runUrl}`);
|
|
25
|
+
}
|
|
26
|
+
else if (anyCacheMisses) {
|
|
27
|
+
message.push(`View logs and investigate cache misses at ${this.runContext.runUrl}`);
|
|
28
|
+
}
|
|
29
|
+
else if (hits.length > 0) {
|
|
30
|
+
const tasks = hits.length === 1 ? hits[0] : `${hits.length} tasks`;
|
|
31
|
+
message.push(`Nx Cloud made it possible to reuse ${tasks}: ${this.runContext.runUrl}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (this.runContext.runUrl) {
|
|
35
|
+
message.push(`View logs and run details at ${this.runContext.runUrl}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (message.length > 0) {
|
|
39
|
+
(0, print_message_1.printMessage)(message.join(' '));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.EndOfRunMessage = EndOfRunMessage;
|
|
44
|
+
//# sourceMappingURL=end-of-run-message.js.map
|
|
@@ -0,0 +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,6DAAqF;AACrF,iEAA6D;AAE7D,MAAa,eAAe;IAC1B,YACmB,UAAsB,EACtB,cAA+B;QAD/B,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAiB;IAC/C,CAAC;IAEJ,qBAAqB;QACnB,IAAI,oDAAsC;YAAE,OAAO;QAEnD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAC3B,OAAO;SACR;QAED,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,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CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,IAAA,4BAAY,EAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SACjC;IACH,CAAC;CACF;AA7CD,0CA6CC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CloudTaskRunnerOptions } from '../models/cloud-task-runner-options';
|
|
2
|
+
export declare class MessageReporter {
|
|
3
|
+
private readonly options;
|
|
4
|
+
cacheError: string | null;
|
|
5
|
+
apiError: string | null;
|
|
6
|
+
message: string | null;
|
|
7
|
+
constructor(options: CloudTaskRunnerOptions);
|
|
8
|
+
get anyErrors(): string | null;
|
|
9
|
+
printMessages(): void;
|
|
10
|
+
extractErrorMessage(e: any, scope: string): string | null;
|
|
11
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageReporter = void 0;
|
|
4
|
+
const print_message_1 = require("../../utilities/print-message");
|
|
5
|
+
const { output } = require('../../utilities/nx-imports');
|
|
6
|
+
class MessageReporter {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.cacheError = null;
|
|
10
|
+
this.apiError = null;
|
|
11
|
+
this.message = null;
|
|
12
|
+
}
|
|
13
|
+
get anyErrors() {
|
|
14
|
+
return this.cacheError || this.apiError;
|
|
15
|
+
}
|
|
16
|
+
printMessages() {
|
|
17
|
+
if (this.anyErrors) {
|
|
18
|
+
const bodyLines = [];
|
|
19
|
+
if (this.cacheError) {
|
|
20
|
+
bodyLines.push(`- ${this.cacheError}`);
|
|
21
|
+
}
|
|
22
|
+
if (this.apiError && this.apiError !== this.cacheError) {
|
|
23
|
+
bodyLines.push(`- ${this.apiError}`);
|
|
24
|
+
}
|
|
25
|
+
output.warn({
|
|
26
|
+
title: `Nx Cloud Problems`,
|
|
27
|
+
bodyLines,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (this.message) {
|
|
31
|
+
(0, print_message_1.printMessage)(this.message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
extractErrorMessage(e, scope) {
|
|
35
|
+
if (e.code === 'ECONNABORTED') {
|
|
36
|
+
return `Cannot connect to Nx Cloud (scope: ${scope}, code: ${e.code}). Try invoking the command with the NX_CLOUD_NO_TIMEOUTS env variable set to 'true'.`;
|
|
37
|
+
}
|
|
38
|
+
else if (e.code === 'ECONNREFUSED' ||
|
|
39
|
+
e.code === 'EAI_AGAIN' ||
|
|
40
|
+
e.code === 'ENOTFOUND' ||
|
|
41
|
+
e.code === 'EPROTO') {
|
|
42
|
+
return `Cannot connect to Nx Cloud (scope: ${scope}, code: ${e.code}).`;
|
|
43
|
+
}
|
|
44
|
+
else if (e.response && e.response.status === 401) {
|
|
45
|
+
return e.response.data.message
|
|
46
|
+
? e.response.data.message
|
|
47
|
+
: e.response.data;
|
|
48
|
+
}
|
|
49
|
+
else if (e.response && e.response.status === 402) {
|
|
50
|
+
if (this.options.showUsageWarnings === false ||
|
|
51
|
+
this.options.showUsageWarnings === undefined)
|
|
52
|
+
return null;
|
|
53
|
+
return e.response.data.message
|
|
54
|
+
? e.response.data.message
|
|
55
|
+
: e.response.data;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
let details = '';
|
|
59
|
+
if (e.response && e.response.data && e.response.data.message) {
|
|
60
|
+
details = `. ${e.response.data.message}`;
|
|
61
|
+
}
|
|
62
|
+
else if (e.response && e.response.data) {
|
|
63
|
+
details = `. ${e.response.data}`;
|
|
64
|
+
}
|
|
65
|
+
const code = e.code ? ` (code: ${e.code})` : ``;
|
|
66
|
+
return `${e.message}${details}${code}`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.MessageReporter = MessageReporter;
|
|
71
|
+
//# sourceMappingURL=message-reporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-reporter.js","source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ACD,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,OAAO,GAAG,CAAC,CAAC,OAAO,GAAG,OAAO,GAAG,IAAI,EAAE,CAAC;SACxC;IACH,CAAC;CACF;AAhED,0CAgEC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OutputObfuscator = void 0;
|
|
4
|
+
class OutputObfuscator {
|
|
5
|
+
constructor(maskedProperties = []) {
|
|
6
|
+
this.normalizedMaskedProperties = [];
|
|
7
|
+
// Remove possible duplicates from config
|
|
8
|
+
this.normalizedMaskedProperties = Array.from(new Set(maskedProperties)).map(this.toCamelCase);
|
|
9
|
+
}
|
|
10
|
+
obfuscate(terminalOutput) {
|
|
11
|
+
if (!this.normalizedMaskedProperties.length) {
|
|
12
|
+
return terminalOutput;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Replace instances of a secret key being used as a command flag
|
|
16
|
+
* --secret-key=somekey => --secret-key=********
|
|
17
|
+
* or
|
|
18
|
+
* --secretKey=somekey => --secretKey=********
|
|
19
|
+
*/
|
|
20
|
+
this.normalizedMaskedProperties.forEach((secretKey) => {
|
|
21
|
+
const commandFlagPattern = new RegExp(`(--${secretKey}=)[\\S]*`);
|
|
22
|
+
terminalOutput = terminalOutput.replace(commandFlagPattern, '$1********');
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Replace instances of a secret key's value that exists in process.env
|
|
26
|
+
* by reverse lookup
|
|
27
|
+
*/
|
|
28
|
+
const secretValues = this.normalizedMaskedProperties
|
|
29
|
+
.filter((secretKey) => secretKey in process.env)
|
|
30
|
+
.map((secretKey) => process.env[secretKey]);
|
|
31
|
+
secretValues.forEach((secretValue) => {
|
|
32
|
+
terminalOutput = terminalOutput.replace(secretValue, '********');
|
|
33
|
+
});
|
|
34
|
+
return terminalOutput;
|
|
35
|
+
}
|
|
36
|
+
toCamelCase(input) {
|
|
37
|
+
if (input.indexOf('-') > 1) {
|
|
38
|
+
return input
|
|
39
|
+
.toLowerCase()
|
|
40
|
+
.replace(/-(.)/g, (match, group1) => group1.toUpperCase());
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return input;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.OutputObfuscator = OutputObfuscator;
|
|
48
|
+
//# sourceMappingURL=output-obfuscator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-obfuscator.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/terminal-output/output-obfuscator.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;IAG3B,YAAY,mBAA6B,EAAE;QAFnC,+BAA0B,GAAa,EAAE,CAAC;QAGhD,yCAAyC;QACzC,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CACzE,IAAI,CAAC,WAAW,CACjB,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,cAAsB;QAC9B,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE;YAC3C,OAAO,cAAc,CAAC;SACvB;QAED;;;;;WAKG;QACH,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YACpD,MAAM,kBAAkB,GAAG,IAAI,MAAM,CAAC,MAAM,SAAS,UAAU,CAAC,CAAC;YACjE,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;QAEH;;;WAGG;QACH,MAAM,YAAY,GAAa,IAAI,CAAC,0BAA0B;aAC3D,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC;aAC/C,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,CAAC;QAC/C,YAAY,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YACnC,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,WAAW,CAAC,KAAa;QACvB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAC1B,OAAO,KAAK;iBACT,WAAW,EAAE;iBACb,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;aAAM;YACL,OAAO,KAAK,CAAC;SACd;IACH,CAAC;CACF;AAjDD,4CAiDC"}
|
|
@@ -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;
|