nx
Advanced tools
Comparing version 19.5.0-canary.20240706-4ae16b3 to 19.5.0-canary.20240709-92e09d9
{ | ||
"name": "nx", | ||
"version": "19.5.0-canary.20240706-4ae16b3", | ||
"version": "19.5.0-canary.20240709-92e09d9", | ||
"private": false, | ||
@@ -74,3 +74,3 @@ "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.", | ||
"ora": "5.3.0", | ||
"@nrwl/tao": "19.5.0-canary.20240706-4ae16b3" | ||
"@nrwl/tao": "19.5.0-canary.20240709-92e09d9" | ||
}, | ||
@@ -90,12 +90,12 @@ "peerDependencies": { | ||
"optionalDependencies": { | ||
"@nx/nx-darwin-x64": "19.5.0-canary.20240706-4ae16b3", | ||
"@nx/nx-darwin-arm64": "19.5.0-canary.20240706-4ae16b3", | ||
"@nx/nx-linux-x64-gnu": "19.5.0-canary.20240706-4ae16b3", | ||
"@nx/nx-linux-x64-musl": "19.5.0-canary.20240706-4ae16b3", | ||
"@nx/nx-win32-x64-msvc": "19.5.0-canary.20240706-4ae16b3", | ||
"@nx/nx-linux-arm64-gnu": "19.5.0-canary.20240706-4ae16b3", | ||
"@nx/nx-linux-arm64-musl": "19.5.0-canary.20240706-4ae16b3", | ||
"@nx/nx-linux-arm-gnueabihf": "19.5.0-canary.20240706-4ae16b3", | ||
"@nx/nx-win32-arm64-msvc": "19.5.0-canary.20240706-4ae16b3", | ||
"@nx/nx-freebsd-x64": "19.5.0-canary.20240706-4ae16b3" | ||
"@nx/nx-darwin-x64": "19.5.0-canary.20240709-92e09d9", | ||
"@nx/nx-darwin-arm64": "19.5.0-canary.20240709-92e09d9", | ||
"@nx/nx-linux-x64-gnu": "19.5.0-canary.20240709-92e09d9", | ||
"@nx/nx-linux-x64-musl": "19.5.0-canary.20240709-92e09d9", | ||
"@nx/nx-win32-x64-msvc": "19.5.0-canary.20240709-92e09d9", | ||
"@nx/nx-linux-arm64-gnu": "19.5.0-canary.20240709-92e09d9", | ||
"@nx/nx-linux-arm64-musl": "19.5.0-canary.20240709-92e09d9", | ||
"@nx/nx-linux-arm-gnueabihf": "19.5.0-canary.20240709-92e09d9", | ||
"@nx/nx-win32-arm64-msvc": "19.5.0-canary.20240709-92e09d9", | ||
"@nx/nx-freebsd-x64": "19.5.0-canary.20240709-92e09d9" | ||
}, | ||
@@ -102,0 +102,0 @@ "nx-migrations": { |
@@ -87,3 +87,3 @@ /// <reference types="node" /> | ||
success: false; | ||
error: string; | ||
error: Error; | ||
tx: string; | ||
@@ -90,0 +90,0 @@ }; |
@@ -120,3 +120,7 @@ "use strict"; | ||
type: 'createMetadataResult', | ||
payload: { success: false, error: e.stack, tx }, | ||
payload: { | ||
success: false, | ||
error: (0, serializable_error_1.createSerializableError)(e), | ||
tx, | ||
}, | ||
}; | ||
@@ -123,0 +127,0 @@ } |
@@ -246,4 +246,6 @@ "use strict"; | ||
} | ||
const innerStackTrace = ' ' + e.stack.split('\n').join('\n '); | ||
errorBodyLines.push(innerStackTrace); | ||
} | ||
error.message = errorBodyLines.join('\n'); | ||
error.stack = errorBodyLines.join('\n'); | ||
// This represents a single plugin erroring out with a hard error. | ||
@@ -250,0 +252,0 @@ errors.push(error); |
@@ -14,6 +14,7 @@ import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph'; | ||
}; | ||
private readonly allTargetNames; | ||
constructor(extraTargetDependencies: TargetDependencies, projectGraph: ProjectGraph); | ||
processTasks(projectNames: string[], targets: string[], configuration: string, overrides: Object, excludeTaskDependencies: boolean): string[]; | ||
processTask(task: Task, projectUsedToDeriveDependencies: string, configuration: string, overrides: Object): void; | ||
private processTasksForMatchingProjects; | ||
private processTasksForMultipleProjects; | ||
private processTasksForSingleProject; | ||
@@ -20,0 +21,0 @@ private processTasksForDependencies; |
@@ -6,3 +6,2 @@ "use strict"; | ||
const project_graph_utils_1 = require("../utils/project-graph-utils"); | ||
const find_matching_projects_1 = require("../utils/find-matching-projects"); | ||
const output_1 = require("../utils/output"); | ||
@@ -16,2 +15,10 @@ class ProcessTasks { | ||
this.dependencies = {}; | ||
const allTargetNames = new Set(); | ||
for (const projectName in projectGraph.nodes) { | ||
const project = projectGraph.nodes[projectName]; | ||
for (const targetName in project.data.targets ?? {}) { | ||
allTargetNames.add(targetName); | ||
} | ||
} | ||
this.allTargetNames = Array.from(allTargetNames); | ||
} | ||
@@ -63,3 +70,3 @@ processTasks(projectNames, targets, configuration, overrides, excludeTaskDependencies) { | ||
this.seen.add(seenKey); | ||
const dependencyConfigs = (0, utils_1.getDependencyConfigs)({ project: task.target.project, target: task.target.target }, this.extraTargetDependencies, this.projectGraph); | ||
const dependencyConfigs = (0, utils_1.getDependencyConfigs)({ project: task.target.project, target: task.target.target }, this.extraTargetDependencies, this.projectGraph, this.allTargetNames); | ||
for (const dependencyConfig of dependencyConfigs) { | ||
@@ -70,22 +77,3 @@ const taskOverrides = dependencyConfig.params === 'forward' | ||
if (dependencyConfig.projects) { | ||
/** LERNA SUPPORT START - Remove in v20 */ | ||
// Lerna uses `dependencies` in `prepNxOptions`, so we need to maintain | ||
// support for it until lerna can be updated to use the syntax. | ||
// | ||
// This should have been removed in v17, but the updates to lerna had not | ||
// been made yet. | ||
// | ||
// TODO(@agentender): Remove this part in v20 | ||
if (typeof dependencyConfig.projects === 'string') { | ||
if (dependencyConfig.projects === 'self') { | ||
this.processTasksForSingleProject(task, task.target.project, dependencyConfig, configuration, taskOverrides, overrides); | ||
continue; | ||
} | ||
else if (dependencyConfig.projects === 'dependencies') { | ||
this.processTasksForDependencies(projectUsedToDeriveDependencies, dependencyConfig, configuration, task, taskOverrides, overrides); | ||
continue; | ||
} | ||
} | ||
/** LERNA SUPPORT END - Remove in v17 */ | ||
this.processTasksForMatchingProjects(dependencyConfig, configuration, task, taskOverrides, overrides); | ||
this.processTasksForMultipleProjects(dependencyConfig, configuration, task, taskOverrides, overrides); | ||
} | ||
@@ -100,16 +88,12 @@ else if (dependencyConfig.dependencies) { | ||
} | ||
processTasksForMatchingProjects(dependencyConfig, configuration, task, taskOverrides, overrides) { | ||
const targetProjectSpecifiers = typeof dependencyConfig.projects === 'string' | ||
? [dependencyConfig.projects] | ||
: dependencyConfig.projects; | ||
const matchingProjects = (0, find_matching_projects_1.findMatchingProjects)(targetProjectSpecifiers, this.projectGraph.nodes); | ||
if (matchingProjects.length === 0) { | ||
processTasksForMultipleProjects(dependencyConfig, configuration, task, taskOverrides, overrides) { | ||
if (dependencyConfig.projects.length === 0) { | ||
output_1.output.warn({ | ||
title: `\`dependsOn\` is misconfigured for ${task.target.project}:${task.target.target}`, | ||
bodyLines: [ | ||
`Project patterns "${targetProjectSpecifiers}" does not match any projects.`, | ||
`Project patterns "${dependencyConfig.projects}" does not match any projects.`, | ||
], | ||
}); | ||
} | ||
for (const projectName of matchingProjects) { | ||
for (const projectName of dependencyConfig.projects) { | ||
this.processTasksForSingleProject(task, projectName, dependencyConfig, configuration, taskOverrides, overrides); | ||
@@ -116,0 +100,0 @@ } |
@@ -5,8 +5,21 @@ import { Task, TaskGraph } from '../config/task-graph'; | ||
import { CustomHasher, ExecutorConfig } from '../config/misc-interfaces'; | ||
export type NormalizedTargetDependencyConfig = TargetDependencyConfig & { | ||
projects: string[]; | ||
}; | ||
export declare function getDependencyConfigs({ project, target }: { | ||
project: string; | ||
target: string; | ||
}, extraTargetDependencies: Record<string, (TargetDependencyConfig | string)[]>, projectGraph: ProjectGraph): TargetDependencyConfig[] | undefined; | ||
export declare function expandDependencyConfigSyntaxSugar(dependencyConfigString: string, graph: ProjectGraph): TargetDependencyConfig; | ||
}, extraTargetDependencies: Record<string, (TargetDependencyConfig | string)[]>, projectGraph: ProjectGraph, allTargetNames: string[]): NormalizedTargetDependencyConfig[] | undefined; | ||
export declare function normalizeDependencyConfigDefinition(definition: string | TargetDependencyConfig, currentProject: string, graph: ProjectGraph, allTargetNames: string[]): NormalizedTargetDependencyConfig[]; | ||
export declare function normalizeDependencyConfigProjects(dependencyConfig: TargetDependencyConfig, currentProject: string, graph: ProjectGraph): NormalizedTargetDependencyConfig; | ||
export declare function expandDependencyConfigSyntaxSugar(dependencyConfigString: string | TargetDependencyConfig, graph: ProjectGraph): TargetDependencyConfig; | ||
export declare function expandWildcardTargetConfiguration(dependencyConfig: NormalizedTargetDependencyConfig, allTargetNames: string[]): NormalizedTargetDependencyConfig[]; | ||
export declare function readProjectAndTargetFromTargetString(targetString: string, projects: Record<string, ProjectGraphProjectNode>): { | ||
projects?: string[]; | ||
target: string; | ||
}; | ||
export declare function getOutputs(p: Record<string, ProjectGraphProjectNode>, target: Task['target'], overrides: Task['overrides']): string[]; | ||
export declare function normalizeTargetDependencyWithStringProjects(dependencyConfig: TargetDependencyConfig): Omit<TargetDependencyConfig, 'projects'> & { | ||
projects: string[]; | ||
}; | ||
declare class InvalidOutputsError extends Error { | ||
@@ -13,0 +26,0 @@ outputs: string[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
const output_1 = require("../utils/output"); | ||
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.normalizeTargetDependencyWithStringProjects = exports.getOutputs = exports.readProjectAndTargetFromTargetString = exports.expandWildcardTargetConfiguration = exports.expandDependencyConfigSyntaxSugar = exports.normalizeDependencyConfigProjects = exports.normalizeDependencyConfigDefinition = exports.getDependencyConfigs = void 0; | ||
const path_1 = require("path"); | ||
@@ -14,24 +13,31 @@ const posix_1 = require("path/posix"); | ||
const project_graph_1 = require("../project-graph/project-graph"); | ||
function getDependencyConfigs({ project, target }, extraTargetDependencies, projectGraph) { | ||
const find_matching_projects_1 = require("../utils/find-matching-projects"); | ||
const minimatch_1 = require("minimatch"); | ||
function getDependencyConfigs({ project, target }, extraTargetDependencies, projectGraph, allTargetNames) { | ||
const dependencyConfigs = (projectGraph.nodes[project].data?.targets[target]?.dependsOn ?? | ||
// This is passed into `run-command` from programmatic invocations | ||
extraTargetDependencies[target] ?? | ||
[]).map((config) => typeof config === 'string' | ||
? expandDependencyConfigSyntaxSugar(config, projectGraph) | ||
: config); | ||
for (const dependencyConfig of dependencyConfigs) { | ||
if (dependencyConfig.projects && dependencyConfig.dependencies) { | ||
output_1.output.error({ | ||
title: `dependsOn is improperly configured for ${project}:${target}`, | ||
bodyLines: [ | ||
`dependsOn.projects and dependsOn.dependencies cannot be used together.`, | ||
], | ||
}); | ||
process.exit(1); | ||
} | ||
} | ||
[]).flatMap((config) => normalizeDependencyConfigDefinition(config, project, projectGraph, allTargetNames)); | ||
return dependencyConfigs; | ||
} | ||
exports.getDependencyConfigs = getDependencyConfigs; | ||
function normalizeDependencyConfigDefinition(definition, currentProject, graph, allTargetNames) { | ||
return expandWildcardTargetConfiguration(normalizeDependencyConfigProjects(expandDependencyConfigSyntaxSugar(definition, graph), currentProject, graph), allTargetNames); | ||
} | ||
exports.normalizeDependencyConfigDefinition = normalizeDependencyConfigDefinition; | ||
function normalizeDependencyConfigProjects(dependencyConfig, currentProject, graph) { | ||
const noStringConfig = normalizeTargetDependencyWithStringProjects(dependencyConfig); | ||
if (noStringConfig.projects) { | ||
dependencyConfig.projects = (0, find_matching_projects_1.findMatchingProjects)(noStringConfig.projects, graph.nodes); | ||
} | ||
else if (!noStringConfig.dependencies) { | ||
dependencyConfig.projects = [currentProject]; | ||
} | ||
return dependencyConfig; | ||
} | ||
exports.normalizeDependencyConfigProjects = normalizeDependencyConfigProjects; | ||
function expandDependencyConfigSyntaxSugar(dependencyConfigString, graph) { | ||
if (typeof dependencyConfigString !== 'string') { | ||
return dependencyConfigString; | ||
} | ||
const [dependencies, targetString] = dependencyConfigString.startsWith('^') | ||
@@ -48,18 +54,50 @@ ? [true, dependencyConfigString.substring(1)] | ||
} | ||
const { projects, target } = readProjectAndTargetFromTargetString(targetString, graph.nodes); | ||
return projects ? { projects, target } : { target }; | ||
} | ||
exports.expandDependencyConfigSyntaxSugar = expandDependencyConfigSyntaxSugar; | ||
// Weakmap let's the cache get cleared by garbage collector if allTargetNames is no longer used | ||
const patternResultCache = new WeakMap(); | ||
function expandWildcardTargetConfiguration(dependencyConfig, allTargetNames) { | ||
if (!find_matching_projects_1.GLOB_CHARACTERS.some((char) => dependencyConfig.target.includes(char))) { | ||
return [dependencyConfig]; | ||
} | ||
let cache = patternResultCache.get(allTargetNames); | ||
if (!cache) { | ||
cache = new Map(); | ||
patternResultCache.set(allTargetNames, cache); | ||
} | ||
const cachedResult = cache.get(dependencyConfig.target); | ||
if (cachedResult) { | ||
return cachedResult; | ||
} | ||
const matcher = minimatch_1.minimatch.filter(dependencyConfig.target); | ||
const matchingTargets = allTargetNames.filter((t) => matcher(t)); | ||
const result = matchingTargets.map((t) => ({ | ||
...dependencyConfig, | ||
target: t, | ||
})); | ||
cache.set(dependencyConfig.target, result); | ||
return result; | ||
} | ||
exports.expandWildcardTargetConfiguration = expandWildcardTargetConfiguration; | ||
function readProjectAndTargetFromTargetString(targetString, projects) { | ||
// Support for both `project:target` and `target:with:colons` syntax | ||
const [maybeProject, ...segments] = (0, split_target_1.splitByColons)(targetString); | ||
// if no additional segments are provided, then the string references | ||
// a target of the same project | ||
if (!segments.length) { | ||
// if no additional segments are provided, then the string references | ||
// a target of the same project | ||
return { target: maybeProject }; | ||
} | ||
return { | ||
else if (maybeProject in projects) { | ||
// Only the first segment could be a project. If it is, the rest is a target. | ||
// If its not, then the whole targetString was a target with colons in its name. | ||
target: maybeProject in graph.nodes ? segments.join(':') : targetString, | ||
return { projects: [maybeProject], target: segments.join(':') }; | ||
} | ||
else { | ||
// If the first segment is a project, then we have a specific project. Otherwise, we don't. | ||
projects: maybeProject in graph.nodes ? [maybeProject] : undefined, | ||
}; | ||
return { target: targetString }; | ||
} | ||
} | ||
exports.expandDependencyConfigSyntaxSugar = expandDependencyConfigSyntaxSugar; | ||
exports.readProjectAndTargetFromTargetString = readProjectAndTargetFromTargetString; | ||
function getOutputs(p, target, overrides) { | ||
@@ -69,2 +107,28 @@ return getOutputsForTargetAndConfiguration(target, overrides, p[target.project]); | ||
exports.getOutputs = getOutputs; | ||
function normalizeTargetDependencyWithStringProjects(dependencyConfig) { | ||
if (typeof dependencyConfig.projects === 'string') { | ||
/** LERNA SUPPORT START - Remove in v20 */ | ||
// Lerna uses `dependencies` in `prepNxOptions`, so we need to maintain | ||
// support for it until lerna can be updated to use the syntax. | ||
// | ||
// This should have been removed in v17, but the updates to lerna had not | ||
// been made yet. | ||
// | ||
// TODO(@agentender): Remove this part in v20 | ||
if (dependencyConfig.projects === 'self') { | ||
delete dependencyConfig.projects; | ||
} | ||
else if (dependencyConfig.projects === 'dependencies') { | ||
dependencyConfig.dependencies = true; | ||
delete dependencyConfig.projects; | ||
return; | ||
/** LERNA SUPPORT END - Remove in v20 */ | ||
} | ||
else { | ||
dependencyConfig.projects = [dependencyConfig.projects]; | ||
} | ||
} | ||
return dependencyConfig; | ||
} | ||
exports.normalizeTargetDependencyWithStringProjects = normalizeTargetDependencyWithStringProjects; | ||
class InvalidOutputsError extends Error { | ||
@@ -71,0 +135,0 @@ constructor(outputs, invalidOutputs) { |
import type { ProjectGraphProjectNode } from '../config/project-graph'; | ||
/** | ||
* The presence of these characters in a string indicates that it might be a glob pattern. | ||
*/ | ||
export declare const GLOB_CHARACTERS: string[]; | ||
/** | ||
* Find matching project names given a list of potential project names or globs. | ||
@@ -4,0 +8,0 @@ * |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getMatchingStringsWithCache = exports.findMatchingProjects = void 0; | ||
exports.getMatchingStringsWithCache = exports.findMatchingProjects = exports.GLOB_CHARACTERS = void 0; | ||
const minimatch_1 = require("minimatch"); | ||
@@ -11,4 +11,7 @@ const validPatternTypes = [ | ||
]; | ||
const globCharacters = ['*', '|', '{', '}', '(', ')']; | ||
/** | ||
* The presence of these characters in a string indicates that it might be a glob pattern. | ||
*/ | ||
exports.GLOB_CHARACTERS = ['*', '|', '{', '}', '(', ')']; | ||
/** | ||
* Find matching project names given a list of potential project names or globs. | ||
@@ -114,3 +117,3 @@ * | ||
} | ||
if (!globCharacters.some((c) => pattern.value.includes(c))) { | ||
if (!exports.GLOB_CHARACTERS.some((c) => pattern.value.includes(c))) { | ||
return; | ||
@@ -140,3 +143,3 @@ } | ||
} | ||
if (!globCharacters.some((c) => pattern.value.includes(c))) { | ||
if (!exports.GLOB_CHARACTERS.some((c) => pattern.value.includes(c))) { | ||
continue; | ||
@@ -143,0 +146,0 @@ } |
@@ -20,3 +20,9 @@ "use strict"; | ||
return createSerializableError(v); | ||
// Support for AggregateCreateNodesError | ||
} | ||
else if (Array.isArray(v) && | ||
v.length === 2 && | ||
v[1] instanceof Error) { | ||
return [v[0], createSerializableError(v[1])]; | ||
} | ||
return v; | ||
@@ -23,0 +29,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7181766
49138
+ Added@nrwl/tao@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-darwin-arm64@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-darwin-x64@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-freebsd-x64@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-linux-arm-gnueabihf@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-linux-arm64-gnu@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-linux-arm64-musl@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-linux-x64-gnu@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-linux-x64-musl@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-win32-arm64-msvc@19.5.0-canary.20240709-92e09d9(transitive)
+ Added@nx/nx-win32-x64-msvc@19.5.0-canary.20240709-92e09d9(transitive)
- Removed@nrwl/tao@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-darwin-arm64@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-darwin-x64@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-freebsd-x64@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-linux-arm-gnueabihf@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-linux-arm64-gnu@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-linux-arm64-musl@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-linux-x64-gnu@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-linux-x64-musl@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-win32-arm64-msvc@19.5.0-canary.20240706-4ae16b3(transitive)
- Removed@nx/nx-win32-x64-msvc@19.5.0-canary.20240706-4ae16b3(transitive)