nx 18.3.0 → 18.3.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/.eslintrc.json +4 -0
- package/bin/nx.js +7 -19
- package/package.json +12 -12
- package/src/command-line/add/add.js +3 -1
- package/src/command-line/add/command-object.d.ts +1 -0
- package/src/command-line/add/command-object.js +6 -1
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +6 -3
- package/src/core/graph/main.js +1 -1
- package/src/daemon/cache.js +18 -0
- package/src/daemon/client/client.js +3 -4
- package/src/daemon/server/handle-hash-tasks.js +2 -2
- package/src/daemon/server/project-graph-incremental-recomputation.js +1 -2
- package/src/daemon/socket-utils.js +2 -2
- package/src/native/index.d.ts +1 -4
- package/src/native/index.js +67 -259
- package/src/native/native-bindings.js +268 -0
- package/src/native/transform-objects.js +1 -0
- package/src/project-graph/error-types.d.ts +27 -1
- package/src/project-graph/error-types.js +52 -1
- package/src/project-graph/plugins/isolation/index.js +8 -4
- package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
- package/src/project-graph/plugins/isolation/plugin-pool.js +4 -10
- package/src/project-graph/plugins/utils.js +1 -1
- package/src/project-graph/project-graph.d.ts +2 -24
- package/src/project-graph/project-graph.js +11 -52
- package/src/tasks-runner/init-tasks-runner.js +2 -0
- package/src/tasks-runner/task-orchestrator.js +47 -29
- package/src/utils/dotenv.d.ts +7 -0
- package/src/utils/dotenv.js +22 -0
- package/src/utils/params.js +20 -17
- package/src/daemon/daemon-project-graph-error.d.ts +0 -8
- package/src/daemon/daemon-project-graph-error.js +0 -13
@@ -214,37 +214,55 @@ class TaskOrchestrator {
|
|
214
214
|
if (process.env.NX_RUN_COMMANDS_DIRECTLY !== 'false' &&
|
215
215
|
targetConfiguration.executor === 'nx:run-commands' &&
|
216
216
|
!shouldPrefix) {
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
217
|
+
try {
|
218
|
+
const { schema } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
219
|
+
const isRunOne = this.initiatingProject != null;
|
220
|
+
const combinedOptions = (0, params_1.combineOptionsForExecutor)(task.overrides, task.target.configuration ??
|
221
|
+
targetConfiguration.defaultConfiguration, targetConfiguration, schema, task.target.project, (0, path_1.relative)(task.projectRoot ?? workspace_root_1.workspaceRoot, process.cwd()), process.env.NX_VERBOSE_LOGGING === 'true');
|
222
|
+
if (combinedOptions.env) {
|
223
|
+
env = {
|
224
|
+
...env,
|
225
|
+
...combinedOptions.env,
|
226
|
+
};
|
227
|
+
}
|
228
|
+
if (streamOutput) {
|
229
|
+
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
230
|
+
output_1.output.logCommand(args.join(' '));
|
231
|
+
}
|
232
|
+
const { success, terminalOutput } = await (0, run_commands_impl_1.default)({
|
233
|
+
...combinedOptions,
|
234
|
+
env,
|
235
|
+
usePty: isRunOne && !this.tasksSchedule.hasTasks(),
|
236
|
+
streamOutput,
|
237
|
+
}, {
|
238
|
+
root: workspace_root_1.workspaceRoot, // only root is needed in runCommandsImpl
|
239
|
+
});
|
240
|
+
const status = success ? 'success' : 'failure';
|
241
|
+
if (!streamOutput) {
|
242
|
+
this.options.lifeCycle.printTaskTerminalOutput(task, status, terminalOutput);
|
243
|
+
}
|
244
|
+
(0, fs_1.writeFileSync)(temporaryOutputPath, terminalOutput);
|
245
|
+
results.push({
|
246
|
+
task,
|
247
|
+
status,
|
248
|
+
terminalOutput,
|
249
|
+
});
|
229
250
|
}
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
251
|
+
catch (e) {
|
252
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
253
|
+
console.error(e);
|
254
|
+
}
|
255
|
+
else {
|
256
|
+
console.error(e.message);
|
257
|
+
}
|
258
|
+
const terminalOutput = e.stack ?? e.message ?? '';
|
259
|
+
(0, fs_1.writeFileSync)(temporaryOutputPath, terminalOutput);
|
260
|
+
results.push({
|
261
|
+
task,
|
262
|
+
status: 'failure',
|
263
|
+
terminalOutput,
|
264
|
+
});
|
241
265
|
}
|
242
|
-
(0, fs_1.writeFileSync)(temporaryOutputPath, terminalOutput);
|
243
|
-
results.push({
|
244
|
-
task,
|
245
|
-
status,
|
246
|
-
terminalOutput,
|
247
|
-
});
|
248
266
|
}
|
249
267
|
else {
|
250
268
|
// cache prep
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.loadRootEnvFiles = void 0;
|
4
|
+
const dotenv_1 = require("dotenv");
|
5
|
+
const dotenv_expand_1 = require("dotenv-expand");
|
6
|
+
const workspace_root_1 = require("./workspace-root");
|
7
|
+
const path_1 = require("path");
|
8
|
+
/**
|
9
|
+
* This loads dotenv files from:
|
10
|
+
* - .env
|
11
|
+
* - .local.env
|
12
|
+
* - .env.local
|
13
|
+
*/
|
14
|
+
function loadRootEnvFiles(root = workspace_root_1.workspaceRoot) {
|
15
|
+
for (const file of ['.local.env', '.env.local', '.env']) {
|
16
|
+
const myEnv = (0, dotenv_1.config)({
|
17
|
+
path: (0, path_1.join)(root, file),
|
18
|
+
});
|
19
|
+
(0, dotenv_expand_1.expand)(myEnv);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
exports.loadRootEnvFiles = loadRootEnvFiles;
|
package/src/utils/params.js
CHANGED
@@ -176,26 +176,29 @@ function validateObject(opts, schema, definitions) {
|
|
176
176
|
}
|
177
177
|
}
|
178
178
|
if (schema.oneOf) {
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
catch (e) {
|
186
|
-
errors.push(e);
|
187
|
-
}
|
188
|
-
}
|
189
|
-
if (errors.length === schema.oneOf.length) {
|
190
|
-
throw new Error(`Options did not match schema. Please fix 1 of the following errors:\n${errors
|
191
|
-
.map((e) => ' - ' + e.message)
|
192
|
-
.join('\n')}`);
|
179
|
+
const matches = [];
|
180
|
+
const errors = [];
|
181
|
+
for (const propertyDescription of schema.oneOf) {
|
182
|
+
try {
|
183
|
+
validateObject(opts, propertyDescription, definitions);
|
184
|
+
matches.push(propertyDescription);
|
193
185
|
}
|
194
|
-
|
195
|
-
|
196
|
-
throw new Error(`Options did not match schema.`);
|
186
|
+
catch (error) {
|
187
|
+
errors.push(error);
|
197
188
|
}
|
198
189
|
}
|
190
|
+
// If the options matched none of the oneOf property descriptions
|
191
|
+
if (matches.length === 0) {
|
192
|
+
throw new Error(`Options did not match schema: ${JSON.stringify(opts, null, 2)}.\nPlease fix 1 of the following errors:\n${errors
|
193
|
+
.map((e) => ' - ' + e.message)
|
194
|
+
.join('\n')}`);
|
195
|
+
}
|
196
|
+
// If the options matched none of the oneOf property descriptions
|
197
|
+
if (matches.length > 1) {
|
198
|
+
throw new Error(`Options did not match schema: ${JSON.stringify(opts, null, 2)}.\nShould only match one of \n${matches
|
199
|
+
.map((m) => ' - ' + JSON.stringify(m))
|
200
|
+
.join('\n')}`);
|
201
|
+
}
|
199
202
|
}
|
200
203
|
(schema.required ?? []).forEach((p) => {
|
201
204
|
if (opts[p] === undefined) {
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { ProjectGraph } from '../config/project-graph';
|
2
|
-
import { ConfigurationSourceMaps } from '../project-graph/utils/project-configuration-utils';
|
3
|
-
export declare class DaemonProjectGraphError extends Error {
|
4
|
-
errors: any[];
|
5
|
-
readonly projectGraph: ProjectGraph;
|
6
|
-
readonly sourceMaps: ConfigurationSourceMaps;
|
7
|
-
constructor(errors: any[], projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps);
|
8
|
-
}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.DaemonProjectGraphError = void 0;
|
4
|
-
class DaemonProjectGraphError extends Error {
|
5
|
-
constructor(errors, projectGraph, sourceMaps) {
|
6
|
-
super(`The Daemon Process threw an error while calculating the project graph. Convert this error to a ProjectGraphError to get more information.`);
|
7
|
-
this.errors = errors;
|
8
|
-
this.projectGraph = projectGraph;
|
9
|
-
this.sourceMaps = sourceMaps;
|
10
|
-
this.name = this.constructor.name;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
exports.DaemonProjectGraphError = DaemonProjectGraphError;
|