@nrwl/nx-cloud 14.0.3-beta.1 → 14.0.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/nx-cloud.d.ts +2 -0
- package/bin/nx-cloud.js +43 -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/run-group.api.d.ts +7 -0
- package/lib/core/api/run-group.api.js +65 -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 +16 -0
- package/lib/core/commands/record-output.js +203 -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 +38 -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/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 +13 -0
- package/lib/core/file-storage/file-storage.js +174 -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 +9 -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 +42 -0
- package/lib/core/models/run-context.model.js +3 -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 +25 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +138 -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 +4 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +167 -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 +113 -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 +17 -0
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +158 -0
- package/lib/core/runners/cloud-enabled/cloud-run.api.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 +239 -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 +130 -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 +12 -0
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +306 -0
- package/lib/core/runners/distributed-execution/distributed-execution.runner.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 +37 -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/generators/init/init.d.ts +2 -0
- package/lib/generators/init/init.js +126 -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 +102 -0
- package/lib/nx-cloud-tasks-runner.js.map +1 -0
- package/lib/utilities/axios.d.ts +9 -0
- package/lib/utilities/axios.js +73 -0
- package/lib/utilities/axios.js.map +1 -0
- package/lib/utilities/create-no-new-messages-timeout.d.ts +1 -0
- package/lib/utilities/create-no-new-messages-timeout.js +25 -0
- package/lib/utilities/create-no-new-messages-timeout.js.map +1 -0
- package/lib/utilities/environment.d.ts +24 -0
- package/lib/utilities/environment.js +156 -0
- package/lib/utilities/environment.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 +39 -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 +35 -0
- package/lib/utilities/print-message.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,306 @@
|
|
|
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.TaskGraphCreator = exports.nxCloudDistributedTasksRunner = void 0;
|
|
13
|
+
const Observable_1 = require("rxjs/internal/Observable");
|
|
14
|
+
const stripJsonComments = require("strip-json-comments");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const distributed_execution_api_1 = require("./distributed-execution.api");
|
|
17
|
+
const file_storage_1 = require("../../file-storage/file-storage");
|
|
18
|
+
const e2e_encryption_1 = require("../../file-storage/e2e-encryption");
|
|
19
|
+
const waiter_1 = require("../../../utilities/waiter");
|
|
20
|
+
const environment_1 = require("../../../utilities/environment");
|
|
21
|
+
const print_run_group_error_1 = require("../../error/print-run-group-error");
|
|
22
|
+
const create_no_new_messages_timeout_1 = require("../../../utilities/create-no-new-messages-timeout");
|
|
23
|
+
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
24
|
+
const { output, getDependencyConfigs, getOutputs, unparse, Cache, } = require('../../../utilities/nx-imports');
|
|
25
|
+
class NoopLifeCycle {
|
|
26
|
+
scheduleTask(task) { }
|
|
27
|
+
startTask(task) { }
|
|
28
|
+
endTask(task, code) { }
|
|
29
|
+
}
|
|
30
|
+
function runDistributedExecution(api, options, context, fileStorage, cache, runGroup, tasks) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const nxjson = JSON.parse(stripJsonComments((0, fs_1.readFileSync)('nx.json').toString()));
|
|
33
|
+
const stages = new TaskOrderer(context.projectGraph, getDefaultDependencyConfigs(nxjson, options)).splitTasksIntoStages(tasks);
|
|
34
|
+
const id = yield api.start((0, distributed_execution_api_1.createStartRequest)(runGroup, stages, options));
|
|
35
|
+
return yield processTasks(api, fileStorage, cache, options, id, tasks, context);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function processTasks(api, fileStorage, cache, options, executionId, tasks, context) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const processedTasks = {};
|
|
41
|
+
const failIfNumberOfCompletedTasksDoesNotChangeIn30Mins = (0, create_no_new_messages_timeout_1.createNoNewMessagesTimeout)();
|
|
42
|
+
const waiter = new waiter_1.Waiter();
|
|
43
|
+
while (true) {
|
|
44
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
45
|
+
output.note({
|
|
46
|
+
title: 'Waiting...',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
yield waiter.wait();
|
|
50
|
+
const r = yield api.status(executionId);
|
|
51
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
52
|
+
output.note({
|
|
53
|
+
title: `Status update`,
|
|
54
|
+
bodyLines: [
|
|
55
|
+
`executionId: ${executionId}`,
|
|
56
|
+
`executionStatus: ${r.executionStatus}`,
|
|
57
|
+
`number of completed tasks: ${r.completedTasks.length}`,
|
|
58
|
+
`error: ${r.criticalErrorMessage}`,
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (r.criticalErrorMessage) {
|
|
63
|
+
output.error({
|
|
64
|
+
title: 'Distributed Execution Terminated',
|
|
65
|
+
bodyLines: ['Error:', r.criticalErrorMessage],
|
|
66
|
+
});
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
failIfNumberOfCompletedTasksDoesNotChangeIn30Mins(r.completedTasks.length);
|
|
70
|
+
for (const t of r.completedTasks) {
|
|
71
|
+
if (processedTasks[t.taskId])
|
|
72
|
+
continue;
|
|
73
|
+
yield processTask(fileStorage, cache, context, options, tasks, t);
|
|
74
|
+
waiter.reset();
|
|
75
|
+
processedTasks[t.taskId] = true;
|
|
76
|
+
}
|
|
77
|
+
if (r.executionStatus === 'COMPLETED') {
|
|
78
|
+
return { commandStatus: r.commandStatus, runUrl: r.runUrl };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function processTask(fileStorage, cache, context, options, tasks, completedTask) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
86
|
+
output.note({
|
|
87
|
+
title: `Processing task ${completedTask.taskId}`,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const matchingTask = tasks.find((tt) => completedTask.taskId === tt.id);
|
|
91
|
+
if (!matchingTask) {
|
|
92
|
+
throw new Error(`Found unknown task: ${completedTask.taskId}`);
|
|
93
|
+
}
|
|
94
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
95
|
+
output.note({
|
|
96
|
+
title: `Retrieving artifacts from ${completedTask.url}`,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
yield fileStorage.retrieve(completedTask.hash, completedTask.url, options.cacheDirectory || './node_modules/.cache/nx');
|
|
100
|
+
const cachedResult = yield cache.get(Object.assign(Object.assign({}, matchingTask), { hash: completedTask.hash }));
|
|
101
|
+
const outputs = getOutputs(context.projectGraph.nodes, matchingTask);
|
|
102
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
103
|
+
output.note({
|
|
104
|
+
title: `Extracting artifacts`,
|
|
105
|
+
bodyLines: outputs,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
yield cache.copyFilesFromCache(completedTask.hash, cachedResult, outputs);
|
|
109
|
+
output.logCommand(getCommand(matchingTask));
|
|
110
|
+
process.stdout.write(cachedResult.terminalOutput);
|
|
111
|
+
output.addVerticalSeparator();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function getCommand(task) {
|
|
115
|
+
const args = unparse(task.overrides || {});
|
|
116
|
+
const config = task.target.configuration
|
|
117
|
+
? `:${task.target.configuration}`
|
|
118
|
+
: '';
|
|
119
|
+
return [
|
|
120
|
+
'nx',
|
|
121
|
+
'run',
|
|
122
|
+
`${task.target.project}:${task.target.target}${config}`,
|
|
123
|
+
...args,
|
|
124
|
+
].join(' ');
|
|
125
|
+
}
|
|
126
|
+
const nxCloudDistributedTasksRunner = (tasks, options, context) => {
|
|
127
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
128
|
+
output.note({
|
|
129
|
+
title: 'Starting distributed command execution',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
options.lifeCycle = new NoopLifeCycle();
|
|
133
|
+
const runGroup = (0, environment_1.getRunGroup)();
|
|
134
|
+
if (!runGroup) {
|
|
135
|
+
(0, print_run_group_error_1.printRunGroupError)();
|
|
136
|
+
return process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
const encryption = new e2e_encryption_1.E2EEncryption(environment_1.ENCRYPTION_KEY || options.encryptionKey);
|
|
139
|
+
const fileStorage = new file_storage_1.FileStorage(encryption);
|
|
140
|
+
const cache = new Cache(options);
|
|
141
|
+
const api = new distributed_execution_api_1.DistributedExecutionApi(options);
|
|
142
|
+
runDistributedExecution(api, options, context, fileStorage, cache, runGroup, tasks)
|
|
143
|
+
.then((r) => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
if (r.commandStatus === 0) {
|
|
145
|
+
output.success({
|
|
146
|
+
title: 'Successfully completed running the command.',
|
|
147
|
+
bodyLines: [`See run details at ${r.runUrl}`],
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
output.error({
|
|
152
|
+
title: 'Command execution failed.',
|
|
153
|
+
bodyLines: [`See run details at ${r.runUrl}`],
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
yield (0, metric_logger_1.submitRunMetrics)(options);
|
|
157
|
+
process.exit(r.commandStatus);
|
|
158
|
+
}))
|
|
159
|
+
.catch((e) => {
|
|
160
|
+
output.error({
|
|
161
|
+
title: 'Unable to complete a run.',
|
|
162
|
+
bodyLines: [e.message],
|
|
163
|
+
});
|
|
164
|
+
if (e.axiosException) {
|
|
165
|
+
console.log(e.axiosException);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
console.log(e);
|
|
169
|
+
}
|
|
170
|
+
api
|
|
171
|
+
.completeRunGroupWithError(runGroup, `Main job terminated with an error: "${e.message}"`)
|
|
172
|
+
.finally(() => process.exit(1));
|
|
173
|
+
});
|
|
174
|
+
return new Observable_1.Observable(() => { });
|
|
175
|
+
};
|
|
176
|
+
exports.nxCloudDistributedTasksRunner = nxCloudDistributedTasksRunner;
|
|
177
|
+
class TaskOrderer {
|
|
178
|
+
constructor(projectGraph, defaultTargetDependencies) {
|
|
179
|
+
this.projectGraph = projectGraph;
|
|
180
|
+
this.defaultTargetDependencies = defaultTargetDependencies;
|
|
181
|
+
}
|
|
182
|
+
splitTasksIntoStages(tasks) {
|
|
183
|
+
if (tasks.length === 0)
|
|
184
|
+
return [];
|
|
185
|
+
const stages = [];
|
|
186
|
+
const taskGraph = this.createTaskGraph(tasks);
|
|
187
|
+
const notStagedTaskIds = new Set(tasks.map((t) => t.id));
|
|
188
|
+
let stageIndex = 0;
|
|
189
|
+
// Loop through tasks and try to stage them. As tasks are staged, they are removed from the loop
|
|
190
|
+
while (notStagedTaskIds.size > 0) {
|
|
191
|
+
const currentStage = (stages[stageIndex] = []);
|
|
192
|
+
for (const taskId of notStagedTaskIds) {
|
|
193
|
+
let ready = true;
|
|
194
|
+
for (const dependency of taskGraph.dependencies[taskId]) {
|
|
195
|
+
if (notStagedTaskIds.has(dependency)) {
|
|
196
|
+
// dependency has not been staged yet, this task is not ready to be staged.
|
|
197
|
+
ready = false;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// Some dependency still has not been staged, skip it for now, it will be processed again
|
|
202
|
+
if (!ready) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
// All the dependencies have been staged, let's stage it.
|
|
206
|
+
const task = taskGraph.tasks[taskId];
|
|
207
|
+
currentStage.push(task);
|
|
208
|
+
}
|
|
209
|
+
// Remove the entire new stage of tasks from the list
|
|
210
|
+
for (const task of currentStage) {
|
|
211
|
+
notStagedTaskIds.delete(task.id);
|
|
212
|
+
}
|
|
213
|
+
stageIndex++;
|
|
214
|
+
}
|
|
215
|
+
return stages;
|
|
216
|
+
}
|
|
217
|
+
createTaskGraph(tasks) {
|
|
218
|
+
const t = new TaskGraphCreator(this.projectGraph, this.defaultTargetDependencies);
|
|
219
|
+
return t.createTaskGraph(tasks);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
class TaskGraphCreator {
|
|
223
|
+
constructor(projectGraph, defaultTargetDependencies) {
|
|
224
|
+
this.projectGraph = projectGraph;
|
|
225
|
+
this.defaultTargetDependencies = defaultTargetDependencies;
|
|
226
|
+
}
|
|
227
|
+
createTaskGraph(tasks) {
|
|
228
|
+
const graph = {
|
|
229
|
+
roots: [],
|
|
230
|
+
tasks: {},
|
|
231
|
+
dependencies: {},
|
|
232
|
+
};
|
|
233
|
+
for (const task of tasks) {
|
|
234
|
+
this.addTaskToGraph(task, graph);
|
|
235
|
+
const dependencyConfigs = getDependencyConfigs(task.target, this.defaultTargetDependencies, this.projectGraph);
|
|
236
|
+
if (!dependencyConfigs) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
this.addTaskDependencies(task, dependencyConfigs, tasks, graph);
|
|
240
|
+
}
|
|
241
|
+
graph.roots = Object.keys(graph.dependencies).filter((k) => graph.dependencies[k].length === 0);
|
|
242
|
+
return graph;
|
|
243
|
+
}
|
|
244
|
+
addTaskDependencies(task, dependencyConfigs, tasks, graph) {
|
|
245
|
+
for (const dependencyConfig of dependencyConfigs) {
|
|
246
|
+
if (dependencyConfig.projects === 'self') {
|
|
247
|
+
for (const t of tasks) {
|
|
248
|
+
if (t.target.project === task.target.project &&
|
|
249
|
+
t.target.target === dependencyConfig.target) {
|
|
250
|
+
graph.dependencies[task.id].push(t.id);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else if (dependencyConfig.projects === 'dependencies') {
|
|
255
|
+
const seen = new Set();
|
|
256
|
+
this.addDependencies(task.target.project, dependencyConfig.target, tasks, graph, task.id, seen);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
addDependencies(project, target, tasks, graph, taskId, seen) {
|
|
261
|
+
seen.add(project);
|
|
262
|
+
const dependencies = this.projectGraph.dependencies[project];
|
|
263
|
+
if (dependencies) {
|
|
264
|
+
const projectDependencies = dependencies.map((dependency) => dependency.target);
|
|
265
|
+
for (const projectDependency of projectDependencies) {
|
|
266
|
+
if (seen.has(projectDependency)) {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const dependency = this.findTask({ project: projectDependency, target }, tasks);
|
|
270
|
+
if (dependency) {
|
|
271
|
+
if (graph.dependencies[taskId].indexOf(dependency.id) === -1) {
|
|
272
|
+
graph.dependencies[taskId].push(dependency.id);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
this.addDependencies(projectDependency, target, tasks, graph, taskId, seen);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
findTask({ project, target }, tasks) {
|
|
282
|
+
return tasks.find((t) => t.target.project === project && t.target.target === target);
|
|
283
|
+
}
|
|
284
|
+
addTaskToGraph(task, graph) {
|
|
285
|
+
graph.tasks[task.id] = task;
|
|
286
|
+
graph.dependencies[task.id] = [];
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
exports.TaskGraphCreator = TaskGraphCreator;
|
|
290
|
+
function getDefaultDependencyConfigs(nxJson, runnerOptions) {
|
|
291
|
+
var _a, _b;
|
|
292
|
+
const defaults = (_a = nxJson.targetDependencies) !== null && _a !== void 0 ? _a : {};
|
|
293
|
+
const strictlyOrderedTargets = runnerOptions
|
|
294
|
+
? (_b = runnerOptions.strictlyOrderedTargets) !== null && _b !== void 0 ? _b : ['build']
|
|
295
|
+
: [];
|
|
296
|
+
// Strictly Ordered Targets depend on their dependencies
|
|
297
|
+
for (const target of strictlyOrderedTargets) {
|
|
298
|
+
defaults[target] = defaults[target] || [];
|
|
299
|
+
defaults[target].push({
|
|
300
|
+
target,
|
|
301
|
+
projects: 'dependencies',
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return defaults;
|
|
305
|
+
}
|
|
306
|
+
//# 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,yDAAsD;AACtD,yDAAyD;AACzD,2BAAkC;AAClC,2EAGqC;AAErC,kEAA8D;AAC9D,sEAAkE;AAClE,sDAAmD;AACnD,gEAIwC;AACxC,6EAAuE;AACvE,sGAA+F;AAC/F,oEAAoE;AAGpE,MAAM,EACJ,MAAM,EACN,oBAAoB,EACpB,UAAU,EACV,OAAO,EACP,KAAK,GACN,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAW7C,MAAM,aAAa;IACjB,YAAY,CAAC,IAAU,IAAS,CAAC;IAEjC,SAAS,CAAC,IAAU,IAAS,CAAC;IAE9B,OAAO,CAAC,IAAU,EAAE,IAAY,IAAS,CAAC;CAC3C;AAED,SAAe,uBAAuB,CACpC,GAA4B,EAC5B,OAA+B,EAC/B,OAAY,EACZ,WAAwB,EACxB,KAAY,EACZ,QAAgB,EAChB,KAAa;;QAEb,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACvB,iBAAiB,CAAC,IAAA,iBAAY,EAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CACtD,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,WAAW,CAC5B,OAAO,CAAC,YAAY,EACpB,2BAA2B,CAAC,MAAM,EAAE,OAAc,CAAC,CACpD,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAE9B,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,IAAA,8CAAkB,EAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1E,OAAO,MAAM,YAAY,CACvB,GAAG,EACH,WAAW,EACX,KAAK,EACL,OAAO,EACP,EAAE,EACF,KAAK,EACL,OAAO,CACR,CAAC;IACJ,CAAC;CAAA;AAED,SAAe,YAAY,CACzB,GAA4B,EAC5B,WAAwB,EACxB,K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IAED,MAAM,QAAQ,GAA0B,MAAA,MAAM,CAAC,kBAAkB,mCAAI,EAAE,CAAC;IAExE,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,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,37 @@
|
|
|
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
|
+
const chalk = require('chalk');
|
|
7
|
+
class EndOfRunMessage {
|
|
8
|
+
constructor(runContext, taskExecutions) {
|
|
9
|
+
this.runContext = runContext;
|
|
10
|
+
this.taskExecutions = taskExecutions;
|
|
11
|
+
}
|
|
12
|
+
printCacheHitsMessage() {
|
|
13
|
+
if (environment_1.AGENT_RUNNING_IN_DISTRIBUTED_EXECUTION)
|
|
14
|
+
return;
|
|
15
|
+
const hits = this.taskExecutions
|
|
16
|
+
.filter((t) => this.runContext.statuses[t.hash] === 'remote-cache-hit')
|
|
17
|
+
.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
|
+
const message = [];
|
|
23
|
+
if (hits.length > 0) {
|
|
24
|
+
message.push(`Nx Cloud made it possible to reuse ${tasks}${this.runContext.runUrl ? `: ${this.runContext.runUrl}` : ''}`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (this.runContext.runUrl) {
|
|
28
|
+
message.push(`See Nx Cloud run details at ${this.runContext.runUrl}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (message.length > 0) {
|
|
32
|
+
(0, print_message_1.printMessage)(message.join(' '));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.EndOfRunMessage = EndOfRunMessage;
|
|
37
|
+
//# 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,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/B,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,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc;aAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,kBAAkB,CAAC;aACtE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAE7B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAChD,OAAO;SACR;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,QAAQ,CAAC;QACnE,MAAM,OAAO,GAAG,EAAW,CAAC;QAC5B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,OAAO,CAAC,IAAI,CACV,sCAAsC,KAAK,GACzC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAC3D,EAAE,CACH,CAAC;SACH;aAAM;YACL,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;gBAC1B,OAAO,CAAC,IAAI,CAAC,+BAA+B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;aACvE;SACF;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,IAAA,4BAAY,EAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SACjC;IACH,CAAC;CACF;AAlCD,0CAkCC"}
|
|
@@ -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","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/terminal-output/message-reporter.ts"],"names":[],"mappings":";;;AACA,iEAA6D;AAE7D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAEzD,MAAa,eAAe;IAK1B,YAA6B,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;QAJ5D,eAAU,GAAkB,IAAI,CAAC;QACjC,aAAQ,GAAkB,IAAI,CAAC;QAC/B,YAAO,GAAkB,IAAI,CAAC;IAEiC,CAAC;IAEhE,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ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ACrB;aAAM,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAClD,IACE,IAAI,CAAC,OAAO,CAAC,iBAAiB,KAAK,KAAK;gBACxC,IAAI,CAAC,OAAO,CAAC,iBAAiB,KAAK,SAAS;gBAE5C,OAAO,IAAI,CAAC;YACd,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO;gBAC5B,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO;gBACzB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;SACrB;aAAM;YACL,IAAI,OAAO,GAAG,EAAE,CAAC;YACjB,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE;gBAC5D,OAAO,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;aAC1C;iBAAM,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE;gBACxC,OAAO,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;aAClC;YACD,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-ob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AE;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,126 @@
|
|
|
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.schematic = exports.generator = void 0;
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const rxjs_1 = require("rxjs");
|
|
15
|
+
function updateNxJson(json, token) {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
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
|
+
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
|
+
if (process.env.NX_CLOUD_API) {
|
|
24
|
+
options.url = process.env.NX_CLOUD_API;
|
|
25
|
+
}
|
|
26
|
+
json.tasksRunnerOptions = {
|
|
27
|
+
default: {
|
|
28
|
+
runner: '@nrwl/nx-cloud',
|
|
29
|
+
options,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function updateNxJsonUsingNx(host, token) {
|
|
34
|
+
try {
|
|
35
|
+
const jsonUtils = require('nx/src/utils/json');
|
|
36
|
+
const json = jsonUtils.parseJson(host.read('nx.json', 'utf-8'));
|
|
37
|
+
updateNxJson(json, token);
|
|
38
|
+
host.write('nx.json', jsonUtils.serializeJson(json));
|
|
39
|
+
}
|
|
40
|
+
catch (ee) {
|
|
41
|
+
const json = JSON.parse(host.read('nx.json', 'utf-8'));
|
|
42
|
+
updateNxJson(json, token);
|
|
43
|
+
host.write('nx.json', JSON.stringify(json, null, 2));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function updateNxJsonUsingNrwlWorkspace(token) {
|
|
47
|
+
return require('@nrwl/workspace').updateJsonInTree('nx.json', (json) => {
|
|
48
|
+
updateNxJson(json, token);
|
|
49
|
+
return json;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function readNpmScope() {
|
|
53
|
+
const nxJson = JSON.parse((0, fs_1.readFileSync)('nx.json').toString());
|
|
54
|
+
return nxJson.npmScope;
|
|
55
|
+
}
|
|
56
|
+
function removeTrailingSlash(apiUrl) {
|
|
57
|
+
return apiUrl[apiUrl.length - 1] === '/'
|
|
58
|
+
? apiUrl.substr(0, apiUrl.length - 1)
|
|
59
|
+
: apiUrl;
|
|
60
|
+
}
|
|
61
|
+
function createNxCloudWorkspace(workspaceName) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://api.nrwl.io`);
|
|
64
|
+
const response = yield require('axios').post(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
|
|
65
|
+
workspaceName,
|
|
66
|
+
});
|
|
67
|
+
if (response.data.message) {
|
|
68
|
+
throw new Error(response.data.message);
|
|
69
|
+
}
|
|
70
|
+
return response.data;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function printMessage(url) {
|
|
74
|
+
const { output } = require('../../utilities/nx-imports');
|
|
75
|
+
let host = 'nx.app';
|
|
76
|
+
try {
|
|
77
|
+
host = new (require('url').URL)(url).host;
|
|
78
|
+
}
|
|
79
|
+
catch (e) { }
|
|
80
|
+
output.note({
|
|
81
|
+
title: `Nx Cloud has been enabled`,
|
|
82
|
+
bodyLines: [
|
|
83
|
+
`Your workspace is currently public. Anybody with code access can view the workspace on ${host}. `,
|
|
84
|
+
`You can connect the workspace to your Nx Cloud account at ${url} (You can do this later.)`,
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function printMessageTaskExecutor(url) {
|
|
89
|
+
return {
|
|
90
|
+
name: 'NxCloudPrintMessage',
|
|
91
|
+
create: () => {
|
|
92
|
+
return Promise.resolve(() => {
|
|
93
|
+
return new rxjs_1.Observable((obs) => {
|
|
94
|
+
printMessage(url);
|
|
95
|
+
obs.next();
|
|
96
|
+
obs.complete();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function generator(host) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
const r = yield createNxCloudWorkspace(readNpmScope());
|
|
105
|
+
updateNxJsonUsingNx(host, r.token);
|
|
106
|
+
return () => printMessage(r.url);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
exports.generator = generator;
|
|
110
|
+
function schematic() {
|
|
111
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const r = yield createNxCloudWorkspace(readNpmScope());
|
|
113
|
+
return (host, context) => {
|
|
114
|
+
const engineHost = context.engine.workflow.engineHost;
|
|
115
|
+
engineHost.registerTaskExecutor(printMessageTaskExecutor(r.url));
|
|
116
|
+
context.addTask({
|
|
117
|
+
toConfiguration() {
|
|
118
|
+
return { name: 'NxCloudPrintMessage' };
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
updateNxJsonUsingNrwlWorkspace(r.token)(host, context);
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
exports.schematic = schematic;
|
|
126
|
+
//# sourceMappingURL=init.js.map
|