nx 19.7.0-canary.20240822-d6a0cfb → 19.7.0-canary.20240827-61ecd4b
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.json +12 -1
- package/package.json +12 -12
- package/src/command-line/connect/connect-to-nx-cloud.js +7 -6
- package/src/command-line/graph/graph.d.ts +18 -1
- package/src/command-line/graph/graph.js +35 -18
- package/src/command-line/login/command-object.d.ts +2 -0
- package/src/command-line/login/command-object.js +16 -0
- package/src/command-line/login/login.d.ts +5 -0
- package/src/command-line/login/login.js +16 -0
- package/src/command-line/logout/command-object.d.ts +2 -0
- package/src/command-line/logout/command-object.js +12 -0
- package/src/command-line/logout/logout.d.ts +4 -0
- package/src/command-line/logout/logout.js +13 -0
- package/src/command-line/migrate/migrate.js +5 -36
- package/src/command-line/nx-commands.js +7 -3
- package/src/command-line/yargs-utils/shared-options.d.ts +2 -1
- package/src/command-line/yargs-utils/shared-options.js +11 -15
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.js +4 -2
- package/src/devkit-exports.d.ts +1 -0
- package/src/hasher/node-task-hasher-impl.d.ts +1 -1
- package/src/hasher/node-task-hasher-impl.js +34 -16
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/utilities/axios.js +1 -6
- package/src/plugins/js/package-json/create-package-json.d.ts +1 -0
- package/src/plugins/js/package-json/create-package-json.js +24 -0
- package/src/tasks-runner/default-tasks-runner.js +1 -1
- package/src/tasks-runner/init-tasks-runner.d.ts +2 -0
- package/src/tasks-runner/init-tasks-runner.js +1 -0
- package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.d.ts +4 -6
- package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +5 -0
- package/src/tasks-runner/run-command.js +1 -1
- package/src/tasks-runner/task-orchestrator.d.ts +2 -1
- package/src/tasks-runner/task-orchestrator.js +5 -2
- package/src/utils/package-json.d.ts +3 -0
package/src/core/graph/styles.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{
|
1
|
+
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{46134:()=>{}},s=>{var e;e=46134,s(s.s=e)}]);
|
@@ -72,9 +72,11 @@ class DaemonClient {
|
|
72
72
|
// CI=true,env=undefined => no daemon
|
73
73
|
// CI=true,env=false => no daemon
|
74
74
|
// CI=true,env=true => daemon
|
75
|
+
// docker=true,env=undefined => no daemon
|
76
|
+
// docker=true,env=false => no daemon
|
77
|
+
// docker=true,env=true => daemon
|
75
78
|
// WASM => no daemon because file watching does not work
|
76
|
-
if (((0, is_ci_1.isCI)() && env !== 'true') ||
|
77
|
-
isDocker() ||
|
79
|
+
if ((((0, is_ci_1.isCI)() || isDocker()) && env !== 'true') ||
|
78
80
|
(0, tmp_dir_1.isDaemonDisabled)() ||
|
79
81
|
nxJsonIsNotPresent() ||
|
80
82
|
(useDaemonProcessOption === undefined && env === 'false') ||
|
package/src/devkit-exports.d.ts
CHANGED
@@ -67,6 +67,7 @@ export { readNxJson, updateNxJson, } from './generators/utils/project-configurat
|
|
67
67
|
* @category Project Graph
|
68
68
|
*/
|
69
69
|
export type { ProjectFileMap, FileMap, FileData, ProjectGraph, ProjectGraphDependency, ProjectGraphNode, ProjectGraphProjectNode, ProjectGraphExternalNode, ProjectGraphProcessorContext, } from './config/project-graph';
|
70
|
+
export type { GraphJson } from './command-line/graph/graph';
|
70
71
|
/**
|
71
72
|
* @category Project Graph
|
72
73
|
*/
|
@@ -38,7 +38,7 @@ export declare class NodeTaskHasherImpl implements TaskHasherImpl {
|
|
38
38
|
private findExternalDependencyNodeName;
|
39
39
|
private hashSingleProjectInputs;
|
40
40
|
private hashProjectInputs;
|
41
|
-
private
|
41
|
+
private hashRootFilesets;
|
42
42
|
private hashProjectConfig;
|
43
43
|
private hashTsConfig;
|
44
44
|
private hashProjectFileset;
|
@@ -299,10 +299,10 @@ class NodeTaskHasherImpl {
|
|
299
299
|
this.hashProjectFileset(projectName, projectFilesets),
|
300
300
|
this.hashProjectConfig(projectName),
|
301
301
|
this.hashTsConfig(projectName),
|
302
|
-
...
|
303
|
-
|
304
|
-
|
305
|
-
|
302
|
+
...(workspaceFilesets.length
|
303
|
+
? [this.hashRootFilesets(workspaceFilesets)]
|
304
|
+
: []),
|
305
|
+
this.hashRootFilesets(this.legacyFilesetInputs.map((r) => r.fileset)),
|
306
306
|
...[...notFilesets, ...this.legacyRuntimeInputs].map((r) => r['runtime']
|
307
307
|
? this.hashRuntime(env, r['runtime'])
|
308
308
|
: this.hashEnv(env, r['env'])),
|
@@ -320,22 +320,40 @@ class NodeTaskHasherImpl {
|
|
320
320
|
}
|
321
321
|
return Promise.all(partialHashes).then((hashes) => hashes.flat());
|
322
322
|
}
|
323
|
-
async
|
324
|
-
const mapKey =
|
325
|
-
const withoutWorkspaceRoot = fileset.substring(16);
|
323
|
+
async hashRootFilesets(filesets) {
|
324
|
+
const mapKey = `workspace:[${filesets.join(',')}]`;
|
326
325
|
if (!this.filesetHashes[mapKey]) {
|
327
326
|
this.filesetHashes[mapKey] = new Promise(async (res) => {
|
328
327
|
const parts = [];
|
329
|
-
const
|
330
|
-
|
331
|
-
|
328
|
+
const negativePatterns = [];
|
329
|
+
const positivePatterns = [];
|
330
|
+
for (const fileset of filesets) {
|
331
|
+
if (fileset.startsWith('!')) {
|
332
|
+
negativePatterns.push(fileset.substring(17));
|
333
|
+
}
|
334
|
+
else {
|
335
|
+
positivePatterns.push(fileset.substring(16));
|
336
|
+
}
|
332
337
|
}
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
338
|
+
for (const fileset of positivePatterns) {
|
339
|
+
const withoutWorkspaceRoot = fileset;
|
340
|
+
// Used to shortcut minimatch if not necessary
|
341
|
+
const matchingFile = this.allWorkspaceFiles.find((t) => t.file === withoutWorkspaceRoot);
|
342
|
+
// shortcut because there is a direct match
|
343
|
+
if (matchingFile) {
|
344
|
+
if (!negativePatterns.some((p) => (0, minimatch_1.minimatch)(matchingFile.file, p))) {
|
345
|
+
parts.push(matchingFile.hash);
|
346
|
+
}
|
347
|
+
// No direct match, check if pattern matched
|
348
|
+
}
|
349
|
+
else {
|
350
|
+
this.allWorkspaceFiles
|
351
|
+
.filter((f) => (0, minimatch_1.minimatch)(f.file, withoutWorkspaceRoot) &&
|
352
|
+
!negativePatterns.some((p) => (0, minimatch_1.minimatch)(f.file, p)))
|
353
|
+
.forEach((f) => {
|
354
|
+
parts.push(f.hash);
|
355
|
+
});
|
356
|
+
}
|
339
357
|
}
|
340
358
|
const value = (0, file_hasher_1.hashArray)(parts);
|
341
359
|
res({
|
Binary file
|
@@ -11,12 +11,7 @@ function createApiAxiosInstance(options) {
|
|
11
11
|
const nxCloudId = options.nxCloudId;
|
12
12
|
// TODO(lourw): Update message with NxCloudId once it is supported
|
13
13
|
if (!accessToken && !nxCloudId) {
|
14
|
-
|
15
|
-
throw new Error(`Unable to authenticate. Please connect your workspace to Nx Cloud to define a valid Nx Cloud Id. If you are in a CI context, please set the NX_CLOUD_ACCESS_TOKEN environment variable or define an access token in your nx.json.`);
|
16
|
-
}
|
17
|
-
else {
|
18
|
-
throw new Error(`Unable to authenticate. Either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable. If you do not want to use Nx Cloud for this command, either set NX_NO_CLOUD=true, or pass the --no-cloud flag.`);
|
19
|
-
}
|
14
|
+
throw new Error(`Unable to authenticate. If you are connecting to Nx Cloud locally, set an Nx Cloud ID in your nx.json with "nx connect". If you are in a CI context, please set the NX_CLOUD_ACCESS_TOKEN environment variable or define an access token in your nx.json.`);
|
20
15
|
}
|
21
16
|
if (options.customProxyConfigPath) {
|
22
17
|
const { nxCloudProxyConfig } = require((0, path_1.join)(process.cwd(), options.customProxyConfigPath));
|
@@ -19,6 +19,7 @@ export declare function createPackageJson(projectName: string, graph: ProjectGra
|
|
19
19
|
isProduction?: boolean;
|
20
20
|
helperDependencies?: string[];
|
21
21
|
skipPackageManager?: boolean;
|
22
|
+
skipOverrides?: boolean;
|
22
23
|
}, fileMap?: ProjectFileMap): PackageJson;
|
23
24
|
export declare function findProjectsNpmDependencies(projectNode: ProjectGraphProjectNode, graph: ProjectGraph, target: string, rootPackageJson: PackageJson, options: {
|
24
25
|
helperDependencies?: string[];
|
@@ -121,6 +121,30 @@ function createPackageJson(projectName, graph, options = {}, fileMap = null) {
|
|
121
121
|
}
|
122
122
|
packageJson.packageManager = rootPackageJson.packageManager;
|
123
123
|
}
|
124
|
+
// region Overrides/Resolutions
|
125
|
+
// npm
|
126
|
+
if (rootPackageJson.overrides && !options.skipOverrides) {
|
127
|
+
packageJson.overrides = {
|
128
|
+
...rootPackageJson.overrides,
|
129
|
+
...packageJson.overrides,
|
130
|
+
};
|
131
|
+
}
|
132
|
+
// pnpm
|
133
|
+
if (rootPackageJson.pnpm?.overrides && !options.skipOverrides) {
|
134
|
+
packageJson.pnpm ??= {};
|
135
|
+
packageJson.pnpm.overrides = {
|
136
|
+
...rootPackageJson.pnpm.overrides,
|
137
|
+
...packageJson.pnpm.overrides,
|
138
|
+
};
|
139
|
+
}
|
140
|
+
// yarn
|
141
|
+
if (rootPackageJson.resolutions && !options.skipOverrides) {
|
142
|
+
packageJson.resolutions = {
|
143
|
+
...rootPackageJson.resolutions,
|
144
|
+
...packageJson.resolutions,
|
145
|
+
};
|
146
|
+
}
|
147
|
+
// endregion Overrides/Resolutions
|
124
148
|
return packageJson;
|
125
149
|
}
|
126
150
|
function findProjectsNpmDependencies(projectNode, graph, target, rootPackageJson, options, fileMap) {
|
@@ -56,7 +56,7 @@ const defaultTasksRunner = async (tasks, options, context) => {
|
|
56
56
|
};
|
57
57
|
exports.defaultTasksRunner = defaultTasksRunner;
|
58
58
|
async function runAllTasks(tasks, options, context) {
|
59
|
-
const orchestrator = new task_orchestrator_1.TaskOrchestrator(context.hasher, context.initiatingProject, context.projectGraph, context.taskGraph, options, context.nxArgs?.nxBail, context.daemon);
|
59
|
+
const orchestrator = new task_orchestrator_1.TaskOrchestrator(context.hasher, context.initiatingProject, context.projectGraph, context.taskGraph, options, context.nxArgs?.nxBail, context.daemon, context.nxArgs?.outputStyle);
|
60
60
|
return orchestrator.run();
|
61
61
|
}
|
62
62
|
exports.default = exports.defaultTasksRunner;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { NxArgs } from '../utils/command-line-utils';
|
2
2
|
import { Task, TaskGraph } from '../config/task-graph';
|
3
|
+
import { TaskResult } from './life-cycle';
|
3
4
|
export declare function initTasksRunner(nxArgs: NxArgs): Promise<{
|
4
5
|
invoke: (opts: {
|
5
6
|
tasks: Task[];
|
@@ -7,5 +8,6 @@ export declare function initTasksRunner(nxArgs: NxArgs): Promise<{
|
|
7
8
|
}) => Promise<{
|
8
9
|
status: number;
|
9
10
|
taskGraph: TaskGraph;
|
11
|
+
taskResults: Record<string, TaskResult>;
|
10
12
|
}>;
|
11
13
|
}>;
|
@@ -1,17 +1,15 @@
|
|
1
1
|
import { TaskStatus } from '../tasks-runner';
|
2
|
-
import type { LifeCycle } from '../life-cycle';
|
2
|
+
import type { LifeCycle, TaskResult } from '../life-cycle';
|
3
3
|
import { Task } from '../../config/task-graph';
|
4
4
|
export declare class InvokeRunnerTerminalOutputLifeCycle implements LifeCycle {
|
5
5
|
private readonly tasks;
|
6
6
|
failedTasks: Task[];
|
7
7
|
cachedTasks: Task[];
|
8
|
+
private taskResults;
|
8
9
|
constructor(tasks: Task[]);
|
9
10
|
startCommand(): void;
|
10
11
|
endCommand(): void;
|
11
|
-
endTasks(taskResults:
|
12
|
-
task: Task;
|
13
|
-
status: TaskStatus;
|
14
|
-
code: number;
|
15
|
-
}[]): void;
|
12
|
+
endTasks(taskResults: TaskResult[]): void;
|
16
13
|
printTaskTerminalOutput(task: Task, cacheStatus: TaskStatus, terminalOutput: string): void;
|
14
|
+
getTaskResults(): Record<string, TaskResult>;
|
17
15
|
}
|
@@ -8,6 +8,7 @@ class InvokeRunnerTerminalOutputLifeCycle {
|
|
8
8
|
this.tasks = tasks;
|
9
9
|
this.failedTasks = [];
|
10
10
|
this.cachedTasks = [];
|
11
|
+
this.taskResults = {};
|
11
12
|
}
|
12
13
|
startCommand() {
|
13
14
|
output_1.output.log({
|
@@ -45,6 +46,7 @@ class InvokeRunnerTerminalOutputLifeCycle {
|
|
45
46
|
}
|
46
47
|
endTasks(taskResults) {
|
47
48
|
for (let t of taskResults) {
|
49
|
+
this.taskResults[t.task.id] = t;
|
48
50
|
if (t.status === 'failure') {
|
49
51
|
this.failedTasks.push(t.task);
|
50
52
|
}
|
@@ -63,5 +65,8 @@ class InvokeRunnerTerminalOutputLifeCycle {
|
|
63
65
|
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
64
66
|
output_1.output.logCommandOutput(args.join(' '), cacheStatus, terminalOutput);
|
65
67
|
}
|
68
|
+
getTaskResults() {
|
69
|
+
return this.taskResults;
|
70
|
+
}
|
66
71
|
}
|
67
72
|
exports.InvokeRunnerTerminalOutputLifeCycle = InvokeRunnerTerminalOutputLifeCycle;
|
@@ -441,7 +441,7 @@ function getTasksRunnerPath(runner, nxJson) {
|
|
441
441
|
nxJson.tasksRunnerOptions?.[runner]?.options?.accessToken ||
|
442
442
|
// Cloud access token specified in env var.
|
443
443
|
process.env.NX_CLOUD_ACCESS_TOKEN ||
|
444
|
-
// Nx Cloud
|
444
|
+
// Nx Cloud ID specified in nxJson
|
445
445
|
nxJson.nxCloudId;
|
446
446
|
return isCloudRunner ? 'nx-cloud' : require.resolve('./default-tasks-runner');
|
447
447
|
}
|
@@ -12,6 +12,7 @@ export declare class TaskOrchestrator {
|
|
12
12
|
private readonly options;
|
13
13
|
private readonly bail;
|
14
14
|
private readonly daemon;
|
15
|
+
private readonly outputStyle;
|
15
16
|
private cache;
|
16
17
|
private forkedProcessTaskRunner;
|
17
18
|
private tasksSchedule;
|
@@ -23,7 +24,7 @@ export declare class TaskOrchestrator {
|
|
23
24
|
private waitingForTasks;
|
24
25
|
private groups;
|
25
26
|
private bailed;
|
26
|
-
constructor(hasher: TaskHasher, initiatingProject: string | undefined, projectGraph: ProjectGraph, taskGraph: TaskGraph, options: DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient);
|
27
|
+
constructor(hasher: TaskHasher, initiatingProject: string | undefined, projectGraph: ProjectGraph, taskGraph: TaskGraph, options: DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient, outputStyle: string);
|
27
28
|
run(): Promise<{
|
28
29
|
[id: string]: TaskStatus;
|
29
30
|
}>;
|
@@ -19,7 +19,7 @@ const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
|
|
19
19
|
const nx_json_1 = require("../config/nx-json");
|
20
20
|
class TaskOrchestrator {
|
21
21
|
// endregion internal state
|
22
|
-
constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon) {
|
22
|
+
constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon, outputStyle) {
|
23
23
|
this.hasher = hasher;
|
24
24
|
this.initiatingProject = initiatingProject;
|
25
25
|
this.projectGraph = projectGraph;
|
@@ -27,6 +27,7 @@ class TaskOrchestrator {
|
|
27
27
|
this.options = options;
|
28
28
|
this.bail = bail;
|
29
29
|
this.daemon = daemon;
|
30
|
+
this.outputStyle = outputStyle;
|
30
31
|
this.cache = process.env.NX_DB_CACHE === 'true'
|
31
32
|
? new cache_1.DbCache({
|
32
33
|
// Remove this in Nx 21
|
@@ -209,7 +210,9 @@ class TaskOrchestrator {
|
|
209
210
|
const pipeOutput = await this.pipeOutputCapture(task);
|
210
211
|
// obtain metadata
|
211
212
|
const temporaryOutputPath = this.cache.temporaryOutputPath(task);
|
212
|
-
const streamOutput =
|
213
|
+
const streamOutput = this.outputStyle === 'static'
|
214
|
+
? false
|
215
|
+
: (0, utils_1.shouldStreamOutput)(task, this.initiatingProject);
|
213
216
|
let env = pipeOutput
|
214
217
|
? (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, process.env.FORCE_COLOR === undefined
|
215
218
|
? 'true'
|