nx 19.2.0-canary.20240525-af463c4 → 19.2.0-canary.20240530-316dcb9
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/package.json +12 -12
- package/src/command-line/init/implementation/add-nx-to-monorepo.js +8 -0
- package/src/command-line/init/implementation/add-nx-to-nest.js +4 -0
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +4 -0
- package/src/command-line/init/implementation/angular/index.js +4 -0
- package/src/command-line/init/init-v2.js +4 -0
- package/src/command-line/show/project.js +7 -1
- package/src/command-line/yargs-utils/shared-options.js +9 -1
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/daemon/server/server.js +1 -0
- package/src/devkit-internals.d.ts +1 -0
- package/src/devkit-internals.js +3 -1
- package/src/plugins/js/index.js +6 -2
- package/src/plugins/js/lock-file/pnpm-parser.js +219 -88
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +7 -25
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +567 -287
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
- package/src/plugins/package-json-workspaces/create-nodes.js +1 -0
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +1 -0
- package/src/tasks-runner/create-task-graph.d.ts +3 -3
- package/src/tasks-runner/create-task-graph.js +5 -5
- package/src/tasks-runner/run-command.js +3 -4
- package/src/tasks-runner/utils.d.ts +1 -2
- package/src/tasks-runner/utils.js +22 -12
- package/src/utils/package-json.d.ts +2 -1
- package/src/utils/package-json.js +11 -1
- package/src/utils/params.d.ts +1 -1
- package/src/utils/params.js +5 -4
- package/src/utils/print-help.js +1 -1
@@ -7,6 +7,7 @@ const getTouchedProjectsFromLockFile = (fileChanges, projectGraphNodes) => {
|
|
7
7
|
'yarn.lock',
|
8
8
|
'pnpm-lock.yaml',
|
9
9
|
'pnpm-lock.yml',
|
10
|
+
'bun.lockb',
|
10
11
|
];
|
11
12
|
if (fileChanges.some((f) => lockFiles.includes(f.file))) {
|
12
13
|
return Object.values(projectGraphNodes).map((p) => p.name);
|
@@ -70,6 +70,7 @@ function buildProjectConfigurationFromPackageJson(packageJson, path, nxJson) {
|
|
70
70
|
projectType,
|
71
71
|
...packageJson.nx,
|
72
72
|
targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson),
|
73
|
+
metadata: (0, package_json_1.getMetadataFromPackageJson)(packageJson),
|
73
74
|
};
|
74
75
|
}
|
75
76
|
exports.buildProjectConfigurationFromPackageJson = buildProjectConfigurationFromPackageJson;
|
@@ -39,6 +39,7 @@ function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, workspac
|
|
39
39
|
name,
|
40
40
|
root,
|
41
41
|
targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson),
|
42
|
+
metadata: (0, package_json_1.getMetadataFromPackageJson)(packageJson),
|
42
43
|
};
|
43
44
|
}
|
44
45
|
catch (e) {
|
@@ -2,7 +2,7 @@ import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
|
2
2
|
import { Task, TaskGraph } from '../config/task-graph';
|
3
3
|
import { TargetDefaults, TargetDependencies } from '../config/nx-json';
|
4
4
|
export declare class ProcessTasks {
|
5
|
-
private readonly
|
5
|
+
private readonly extraTargetDependencies;
|
6
6
|
private readonly projectGraph;
|
7
7
|
private readonly seen;
|
8
8
|
readonly tasks: {
|
@@ -11,7 +11,7 @@ export declare class ProcessTasks {
|
|
11
11
|
readonly dependencies: {
|
12
12
|
[k: string]: string[];
|
13
13
|
};
|
14
|
-
constructor(
|
14
|
+
constructor(extraTargetDependencies: TargetDependencies, projectGraph: ProjectGraph);
|
15
15
|
processTasks(projectNames: string[], targets: string[], configuration: string, overrides: Object, excludeTaskDependencies: boolean): string[];
|
16
16
|
processTask(task: Task, projectUsedToDeriveDependencies: string, configuration: string, overrides: Object): void;
|
17
17
|
private processTasksForMatchingProjects;
|
@@ -21,5 +21,5 @@ export declare class ProcessTasks {
|
|
21
21
|
resolveConfiguration(project: ProjectGraphProjectNode, target: string, configuration: string | undefined): string;
|
22
22
|
getId(project: string, target: string, configuration: string | undefined): string;
|
23
23
|
}
|
24
|
-
export declare function createTaskGraph(projectGraph: ProjectGraph,
|
24
|
+
export declare function createTaskGraph(projectGraph: ProjectGraph, extraTargetDependencies: TargetDependencies, projectNames: string[], targets: string[], configuration: string | undefined, overrides: Object, excludeTaskDependencies?: boolean): TaskGraph;
|
25
25
|
export declare function mapTargetDefaultsToDependencies(defaults: TargetDefaults | undefined): TargetDependencies;
|
@@ -6,8 +6,8 @@ const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
6
6
|
const find_matching_projects_1 = require("../utils/find-matching-projects");
|
7
7
|
const output_1 = require("../utils/output");
|
8
8
|
class ProcessTasks {
|
9
|
-
constructor(
|
10
|
-
this.
|
9
|
+
constructor(extraTargetDependencies, projectGraph) {
|
10
|
+
this.extraTargetDependencies = extraTargetDependencies;
|
11
11
|
this.projectGraph = projectGraph;
|
12
12
|
this.seen = new Set();
|
13
13
|
this.tasks = {};
|
@@ -58,7 +58,7 @@ class ProcessTasks {
|
|
58
58
|
return;
|
59
59
|
}
|
60
60
|
this.seen.add(seenKey);
|
61
|
-
const dependencyConfigs = (0, utils_1.getDependencyConfigs)({ project: task.target.project, target: task.target.target }, this.
|
61
|
+
const dependencyConfigs = (0, utils_1.getDependencyConfigs)({ project: task.target.project, target: task.target.target }, this.extraTargetDependencies, this.projectGraph);
|
62
62
|
for (const dependencyConfig of dependencyConfigs) {
|
63
63
|
const taskOverrides = dependencyConfig.params === 'forward'
|
64
64
|
? overrides
|
@@ -189,8 +189,8 @@ class ProcessTasks {
|
|
189
189
|
}
|
190
190
|
}
|
191
191
|
exports.ProcessTasks = ProcessTasks;
|
192
|
-
function createTaskGraph(projectGraph,
|
193
|
-
const p = new ProcessTasks(
|
192
|
+
function createTaskGraph(projectGraph, extraTargetDependencies, projectNames, targets, configuration, overrides, excludeTaskDependencies = false) {
|
193
|
+
const p = new ProcessTasks(extraTargetDependencies, projectGraph);
|
194
194
|
const roots = p.processTasks(projectNames, targets, configuration, overrides, excludeTaskDependencies);
|
195
195
|
return {
|
196
196
|
roots,
|
@@ -58,8 +58,8 @@ async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks
|
|
58
58
|
}
|
59
59
|
}
|
60
60
|
}
|
61
|
-
function createTaskGraphAndValidateCycles(projectGraph,
|
62
|
-
const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph,
|
61
|
+
function createTaskGraphAndValidateCycles(projectGraph, extraTargetDependencies, projectNames, nxArgs, overrides, extraOptions) {
|
62
|
+
const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph, extraTargetDependencies, projectNames, nxArgs.targets, nxArgs.configuration, overrides, extraOptions.excludeTaskDependencies);
|
63
63
|
const cycle = (0, task_graph_utils_1.findCycle)(taskGraph);
|
64
64
|
if (cycle) {
|
65
65
|
if (process.env.NX_IGNORE_CYCLES === 'true' || nxArgs.nxIgnoreCycles) {
|
@@ -81,9 +81,8 @@ function createTaskGraphAndValidateCycles(projectGraph, defaultDependencyConfigs
|
|
81
81
|
}
|
82
82
|
async function runCommand(projectsToRun, projectGraph, { nxJson }, nxArgs, overrides, initiatingProject, extraTargetDependencies, extraOptions) {
|
83
83
|
const status = await (0, params_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
84
|
-
const defaultDependencyConfigs = mergeTargetDependencies(nxJson.targetDefaults, extraTargetDependencies);
|
85
84
|
const projectNames = projectsToRun.map((t) => t.name);
|
86
|
-
const taskGraph = createTaskGraphAndValidateCycles(projectGraph,
|
85
|
+
const taskGraph = createTaskGraphAndValidateCycles(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
|
87
86
|
const tasks = Object.values(taskGraph.tasks);
|
88
87
|
const { lifeCycle, renderIsDone } = await getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, nxArgs, nxJson, overrides);
|
89
88
|
const status = await invokeTasksRunner({
|
@@ -2,11 +2,10 @@ import { Task, TaskGraph } from '../config/task-graph';
|
|
2
2
|
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
3
3
|
import { TargetConfiguration, TargetDependencyConfig } from '../config/workspace-json-project-json';
|
4
4
|
import { CustomHasher, ExecutorConfig } from '../config/misc-interfaces';
|
5
|
-
export declare function getCommandAsString(execCommand: string, task: Task): string;
|
6
5
|
export declare function getDependencyConfigs({ project, target }: {
|
7
6
|
project: string;
|
8
7
|
target: string;
|
9
|
-
},
|
8
|
+
}, extraTargetDependencies: Record<string, (TargetDependencyConfig | string)[]>, projectGraph: ProjectGraph): TargetDependencyConfig[] | undefined;
|
10
9
|
export declare function expandDependencyConfigSyntaxSugar(dependencyConfigString: string, graph: ProjectGraph): TargetDependencyConfig;
|
11
10
|
export declare function getOutputs(p: Record<string, ProjectGraphProjectNode>, target: Task['target'], overrides: Task['overrides']): string[];
|
12
11
|
declare class InvalidOutputsError extends Error {
|
@@ -1,8 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeIdsFromGraph = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.getTargetConfigurationForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.getOutputs = exports.expandDependencyConfigSyntaxSugar = exports.getDependencyConfigs =
|
3
|
+
exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeIdsFromGraph = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.getTargetConfigurationForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.getOutputs = exports.expandDependencyConfigSyntaxSugar = exports.getDependencyConfigs = void 0;
|
4
4
|
const output_1 = require("../utils/output");
|
5
5
|
const path_1 = require("path");
|
6
|
+
const posix_1 = require("path/posix");
|
6
7
|
const workspace_root_1 = require("../utils/workspace-root");
|
7
8
|
const path_2 = require("../utils/path");
|
8
9
|
const fileutils_1 = require("../utils/fileutils");
|
@@ -10,14 +11,10 @@ const serialize_overrides_into_command_line_1 = require("../utils/serialize-over
|
|
10
11
|
const split_target_1 = require("../utils/split-target");
|
11
12
|
const executor_utils_1 = require("../command-line/run/executor-utils");
|
12
13
|
const project_graph_1 = require("../project-graph/project-graph");
|
13
|
-
function
|
14
|
-
const args = getPrintableCommandArgsForTask(task);
|
15
|
-
return [execCommand, 'nx', ...args].join(' ').trim();
|
16
|
-
}
|
17
|
-
exports.getCommandAsString = getCommandAsString;
|
18
|
-
function getDependencyConfigs({ project, target }, defaultDependencyConfigs, projectGraph) {
|
14
|
+
function getDependencyConfigs({ project, target }, extraTargetDependencies, projectGraph) {
|
19
15
|
const dependencyConfigs = (projectGraph.nodes[project].data?.targets[target]?.dependsOn ??
|
20
|
-
|
16
|
+
// This is passed into `run-command` from programmatic invocations
|
17
|
+
extraTargetDependencies[target] ??
|
21
18
|
[]).map((config) => typeof config === 'string'
|
22
19
|
? expandDependencyConfigSyntaxSugar(config, projectGraph)
|
23
20
|
: config);
|
@@ -170,18 +167,32 @@ function getOutputsForTargetAndConfiguration(taskTargetOrTask, overridesOrNode,
|
|
170
167
|
}
|
171
168
|
}
|
172
169
|
exports.getOutputsForTargetAndConfiguration = getOutputsForTargetAndConfiguration;
|
170
|
+
/**
|
171
|
+
* Matches portions of a string which need to be interpolated.
|
172
|
+
* Matches anything within curly braces, excluding the braces.
|
173
|
+
*/
|
174
|
+
const replacementRegex = /{([\s\S]+?)}/g;
|
173
175
|
function interpolate(template, data) {
|
176
|
+
// Path is absolute or doesn't need interpolation
|
177
|
+
if (template.startsWith('/') || !replacementRegex.test(template)) {
|
178
|
+
return template;
|
179
|
+
}
|
174
180
|
if (template.includes('{workspaceRoot}', 1)) {
|
175
181
|
throw new Error(`Output '${template}' is invalid. {workspaceRoot} can only be used at the beginning of the expression.`);
|
176
182
|
}
|
177
183
|
if (data.projectRoot == '.' && template.includes('{projectRoot}', 1)) {
|
178
184
|
throw new Error(`Output '${template}' is invalid. When {projectRoot} is '.', it can only be used at the beginning of the expression.`);
|
179
185
|
}
|
180
|
-
|
186
|
+
const parts = template.split('/').map((s) => _interpolate(s, data));
|
187
|
+
return (0, posix_1.join)(...parts).replace('{workspaceRoot}/', '');
|
188
|
+
}
|
189
|
+
exports.interpolate = interpolate;
|
190
|
+
function _interpolate(template, data) {
|
191
|
+
let res = template;
|
181
192
|
if (data.projectRoot == '.') {
|
182
|
-
res = res.replace('{projectRoot}
|
193
|
+
res = res.replace('{projectRoot}', '');
|
183
194
|
}
|
184
|
-
return res.replace(
|
195
|
+
return res.replace(replacementRegex, (match) => {
|
185
196
|
let value = data;
|
186
197
|
let path = match.slice(1, -1).trim().split('.');
|
187
198
|
for (let idx = 0; idx < path.length; idx++) {
|
@@ -193,7 +204,6 @@ function interpolate(template, data) {
|
|
193
204
|
return value;
|
194
205
|
});
|
195
206
|
}
|
196
|
-
exports.interpolate = interpolate;
|
197
207
|
function getTargetConfigurationForTask(task, projectGraph) {
|
198
208
|
const project = projectGraph.nodes[task.target.project].data;
|
199
209
|
return project.targets[task.target.target];
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { InputDefinition, TargetConfiguration } from '../config/workspace-json-project-json';
|
1
|
+
import { InputDefinition, ProjectMetadata, TargetConfiguration } from '../config/workspace-json-project-json';
|
2
2
|
import { PackageManagerCommands } from './package-manager';
|
3
3
|
export interface NxProjectPackageJsonConfiguration {
|
4
4
|
implicitDependencies?: string[];
|
@@ -67,6 +67,7 @@ export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigra
|
|
67
67
|
packageGroup?: ArrayPackageGroup;
|
68
68
|
};
|
69
69
|
export declare function buildTargetFromScript(script: string, scripts: Record<string, string>, packageManagerCommand: PackageManagerCommands): TargetConfiguration;
|
70
|
+
export declare function getMetadataFromPackageJson(packageJson: PackageJson): ProjectMetadata;
|
70
71
|
export declare function readTargetsFromPackageJson(packageJson: PackageJson): Record<string, TargetConfiguration<any>>;
|
71
72
|
/**
|
72
73
|
* Uses `require.resolve` to read the package.json for a module.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.readModulePackageJson = exports.readModulePackageJsonWithoutFallbacks = exports.readTargetsFromPackageJson = exports.buildTargetFromScript = exports.readNxMigrateConfig = exports.normalizePackageGroup = void 0;
|
3
|
+
exports.readModulePackageJson = exports.readModulePackageJsonWithoutFallbacks = exports.readTargetsFromPackageJson = exports.getMetadataFromPackageJson = exports.buildTargetFromScript = exports.readNxMigrateConfig = exports.normalizePackageGroup = void 0;
|
4
4
|
const fs_1 = require("fs");
|
5
5
|
const path_1 = require("path");
|
6
6
|
const project_configuration_utils_1 = require("../project-graph/utils/project-configuration-utils");
|
@@ -53,6 +53,16 @@ function buildTargetFromScript(script, scripts = {}, packageManagerCommand) {
|
|
53
53
|
}
|
54
54
|
exports.buildTargetFromScript = buildTargetFromScript;
|
55
55
|
let packageManagerCommand;
|
56
|
+
function getMetadataFromPackageJson(packageJson) {
|
57
|
+
const { scripts, nx } = packageJson ?? {};
|
58
|
+
const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
|
59
|
+
return {
|
60
|
+
targetGroups: {
|
61
|
+
'NPM Scripts': includedScripts,
|
62
|
+
},
|
63
|
+
};
|
64
|
+
}
|
65
|
+
exports.getMetadataFromPackageJson = getMetadataFromPackageJson;
|
56
66
|
function readTargetsFromPackageJson(packageJson) {
|
57
67
|
const { scripts, nx, private: isPrivate } = packageJson ?? {};
|
58
68
|
const res = {};
|
package/src/utils/params.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { NxJsonConfiguration } from '../config/nx-json';
|
2
|
-
import type {
|
2
|
+
import type { ProjectsConfigurations, TargetConfiguration } from '../config/workspace-json-project-json';
|
3
3
|
type PropertyDescription = {
|
4
4
|
type?: string | string[];
|
5
5
|
required?: string[];
|
package/src/utils/params.js
CHANGED
@@ -4,7 +4,6 @@ exports.getPromptsForSchema = exports.convertSmartDefaultsIntoNamedParams = expo
|
|
4
4
|
const logger_1 = require("./logger");
|
5
5
|
const output_1 = require("./output");
|
6
6
|
const client_1 = require("../daemon/client/client");
|
7
|
-
const LIST_CHOICE_DISPLAY_LIMIT = 10;
|
8
7
|
async function handleErrors(isVerbose, fn) {
|
9
8
|
try {
|
10
9
|
return await fn();
|
@@ -602,10 +601,12 @@ function getPromptsForSchema(opts, schema, projectsConfigurations) {
|
|
602
601
|
return e.message;
|
603
602
|
}
|
604
603
|
};
|
604
|
+
// Limit the number of choices displayed so that the prompt fits on the screen
|
605
|
+
const limitForChoicesDisplayed = process.stdout.rows - question.message.split('\n').length;
|
605
606
|
if (v.type === 'string' && v.enum && Array.isArray(v.enum)) {
|
606
607
|
question.type = 'autocomplete';
|
607
608
|
question.choices = [...v.enum];
|
608
|
-
question.limit =
|
609
|
+
question.limit = limitForChoicesDisplayed;
|
609
610
|
}
|
610
611
|
else if (v.type === 'string' &&
|
611
612
|
(v.$default?.$source === 'projectName' ||
|
@@ -615,7 +616,7 @@ function getPromptsForSchema(opts, schema, projectsConfigurations) {
|
|
615
616
|
projectsConfigurations) {
|
616
617
|
question.type = 'autocomplete';
|
617
618
|
question.choices = Object.keys(projectsConfigurations.projects);
|
618
|
-
question.limit =
|
619
|
+
question.limit = limitForChoicesDisplayed;
|
619
620
|
}
|
620
621
|
else if (v.type === 'number' || v['x-prompt'].type == 'number') {
|
621
622
|
question.type = 'numeral';
|
@@ -642,7 +643,7 @@ function getPromptsForSchema(opts, schema, projectsConfigurations) {
|
|
642
643
|
};
|
643
644
|
}
|
644
645
|
});
|
645
|
-
question.limit =
|
646
|
+
question.limit = limitForChoicesDisplayed;
|
646
647
|
}
|
647
648
|
else if (v.type === 'boolean') {
|
648
649
|
question.type = 'confirm';
|
package/src/utils/print-help.js
CHANGED
@@ -226,7 +226,7 @@ function generateLinkOutput({ pluginName, name, type, }) {
|
|
226
226
|
!pluginName.startsWith(nrwlPackagePrefix)) {
|
227
227
|
return '';
|
228
228
|
}
|
229
|
-
const link = `https://nx.dev/
|
229
|
+
const link = `https://nx.dev/nx-api/${pluginName.substring(pluginName.startsWith(nxPackagePrefix)
|
230
230
|
? nxPackagePrefix.length
|
231
231
|
: nrwlPackagePrefix.length)}/${type}/${name}`;
|
232
232
|
return `\n\n${chalk.dim('Find more information and examples at:')} ${chalk.bold(link)}`;
|