@nx/devkit 23.1.1 → 23.1.3

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.
@@ -1,4 +1,4 @@
1
- export { signalToCode, createProjectRootMappingsFromProjectConfigurations, PluginCache, safeWriteFileCache, emitPluginWorkerLog, resolveImplementation, resolveSchema, ImplementationResolutionError, SchemaResolutionError, resolvePrompt, PromptResolutionError, acknowledgeBuildScripts, } from 'nx/src/devkit-internals';
1
+ export { signalToCode, createProjectRootMappingsFromProjectConfigurations, PluginCache, safeWriteFileCache, emitPluginWorkerLog, resolveImplementation, resolveSchema, ImplementationResolutionError, SchemaResolutionError, resolvePrompt, PromptResolutionError, acknowledgeBuildScripts, getCatalogManager, } from 'nx/src/devkit-internals';
2
2
  export { determineArtifactNameAndDirectoryOptions, getRelativeCwd, type FileExtensionType, } from './src/generators/artifact-name-and-directory-utils';
3
3
  export { getE2EWebServerInfo, type E2EWebServerDetails, } from './src/generators/e2e-web-server-info-utils';
4
4
  export { forEachExecutorOptions } from './src/generators/executor-options-utils';
@@ -13,7 +13,6 @@ export { getDeclaredPackageVersion, getInstalledPackageVersion, } from './src/ut
13
13
  export { assertSupportedInstalledPackageVersion, assertSupportedPackageVersion, } from './src/utils/version-floor';
14
14
  export { createAsyncIterable, combineAsyncIterables, mapAsyncIterable, } from './src/utils/async-iterable';
15
15
  export { calculateHashForCreateNodes, calculateHashesForCreateNodes, } from './src/utils/calculate-hash-for-create-nodes';
16
- export { getCatalogManager } from 'nx/src/utils/catalog';
17
16
  export { loadConfigFile, clearRequireCache } from './src/utils/config-utils';
18
17
  export { findPluginForConfigFile } from './src/utils/find-plugin-for-config-file';
19
18
  export { getNamedInputs } from './src/utils/get-named-inputs';
@@ -21,3 +20,5 @@ export { logShowProjectCommand } from './src/utils/log-show-project-command';
21
20
  export { eachValueFrom } from './src/utils/rxjs-for-await';
22
21
  export { checkAndCleanWithSemver } from './src/utils/semver';
23
22
  export { camelize, capitalize, classify, dasherize, } from './src/utils/string-utils';
23
+ export { runCommandsExecutor, type TaskResult, type Agent, type BatchExecutorTaskResult, BatchFunctionRunner, type BatchResults, type CLIErrorMessageConfig, type CLINoteMessageConfig, type CLISuccessMessageConfig, type CLIWarnMessageConfig, Cache, type CachedResult, type Change, type ChangedFile, CompositeLifeCycle, DeletedFileChange, type DependsOnEntryLocation, type FileChange, type FileDataDependency, type FileMapCache, type FinalConfigForProject, FsTree, type GeneratorInformation, type InputDefinition, type JsonInput, LARGE_BUFFER, type LifeCycle, LockFileChange, NX_PREFIX, type NormalizedTargetDependencyConfig, type NxCloudOnBoardingStatus, type NxReleaseVersionConfiguration, type PackageJson, type PackageJsonDependencySection, type PackageManagerCommands, type ProjectRootMappings, RemoteCacheV2, type RunCommandsOptions, SyncError, type SyncGeneratorResult, TEN_MEGABYTES, TargetProjectLocator, type TaskMetadata, type TaskStatus, type TaskWithCachedResult, type TasksRunner, type UnregisterCallback, WholeFileChange, buildProjectGraphAndSourceMapsWithoutDaemon, calculateFileChanges, calculateReverseDeps, codeFrameColumns, combineGlobPatterns, connectToNxCloud, createDirectory, createLockFile, createNxCloudOnboardingURL, createNxCloudOnboardingURLForWelcomeApp, createPackageJson, createProjectGraphAndSourceMapsAsync, createProjectRootMappings, createRunManyDynamicOutputRenderer, createTaskId, daemonClient, deduceDefaultBase, defaultFileRead, deriveGroupNameFromTarget, directoryExists, expandDependencyConfigSyntaxSugar, expandInitiatingTasksThroughNoop, expandWildcardTargetConfiguration, fileDataDepTarget, fileDataDepType, fileExists, filterUsingGlobPatterns, findAllProjectNodeDependencies, findInstalledPlugins, findMatchingConfigFiles, findMatchingProjects, findProjectForPath, findProjectsNpmDependencies, forceRegisterEsmLoader, getCliPath, getCustomHasher, getDependencyConfigs, getExecutorForTask, getExecutorInformation, getExecutorNameForTask, getFilesInDirectoryUsingContext, getGeneratorInformation, getGlobPatternsFromPackageManagerWorkspaces, getLastValueFromAsyncIterableIterator, getLatestCommitSha, getLockFileName, getNxCloudAppOnBoardingUrl, getNxCloudUrl, getNxRequirePaths, getOutputs, getPrintableCommandArgsForTask, getRelativeProjectJsonSchemaPath, getSerializedArgsForTask, getSourceDirOfDependentProjects, getTargetConfigurationForTask, getTargetInputs, getUnparsedOverrideArgs, getWorkspacePackagesFromGraph, globWithWorkspaceContext, handleProjectGraphError, hashFile, hashObject, hashWithWorkspaceContext, interpolate, isBuiltinModuleImport, isCI, isCacheableTask, isDeletedFileChange, isLockFileChange, isNpmProject, isNxCloudUsed, isProjectGraphExternalNode, isProjectGraphProjectNode, isRelativePath, isWholeFileChange, killProcessTreeGraceful, loadTsFile, mergeTargetConfigurations, normalizeDependencyConfigDefinition, normalizeDependencyConfigProjects, normalizeTargetDependencyWithStringProjects, nxVersion, orange, parseExecutor, preventRecursionInGraphConstruction, readCachedProjectConfiguration, readFileIfExisting, readFileMapCache, readModulePackageJson, readNxJsonFromDisk, readNxMigrateConfig, readPackageJson, readProjectAndTargetFromTargetString, registerTsConfigPaths, registerTsProject, removeTasksFromTaskGraph, requireWithTsconfigFallback, resetWorkspaceContext, runNxSync, safeExecFileSync, safeSpawn, setWorkspaceRoot, setupAiAgentsGenerator, setupWorkspaceContext, shouldStreamOutput, toNewFormat, toOldFormat, transformLegacyOutputs, unparse, validateOutputs, workspaceDataDirectory, workspaceRootInner, } from 'nx/src/devkit-internals';
24
+ export type { AfterAllProjectsVersioned } from 'nx/release';
package/dist/internal.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.eachValueFrom = exports.logShowProjectCommand = exports.getNamedInputs = exports.findPluginForConfigFile = exports.clearRequireCache = exports.loadConfigFile = exports.getCatalogManager = exports.calculateHashesForCreateNodes = exports.calculateHashForCreateNodes = exports.mapAsyncIterable = exports.combineAsyncIterables = exports.createAsyncIterable = exports.assertSupportedPackageVersion = exports.assertSupportedInstalledPackageVersion = exports.getInstalledPackageVersion = exports.getDeclaredPackageVersion = exports.addPlugin = exports.upsertTargetDefault = exports.updateTargetDefault = exports.readTargetDefaultsForTarget = exports.findTargetDefault = exports.addE2eCiTargetDefaults = exports.addBuildTargetDefaults = exports.promptWhenInteractive = exports.resolveImportPath = exports.ensureRootProjectName = exports.determineProjectNameAndRootOptions = exports.toProjectRelativePath = exports.deleteMatchingProperties = exports.processTargetOutputs = exports.NoTargetsToMigrateError = exports.migrateProjectExecutorsToPluginV1 = exports.migrateProjectExecutorsToPlugin = exports.AggregatedLog = exports.forEachExecutorOptions = exports.getE2EWebServerInfo = exports.getRelativeCwd = exports.determineArtifactNameAndDirectoryOptions = exports.acknowledgeBuildScripts = exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.createProjectRootMappingsFromProjectConfigurations = exports.signalToCode = void 0;
4
- exports.dasherize = exports.classify = exports.capitalize = exports.camelize = exports.checkAndCleanWithSemver = void 0;
3
+ exports.eachValueFrom = exports.logShowProjectCommand = exports.getNamedInputs = exports.findPluginForConfigFile = exports.clearRequireCache = exports.loadConfigFile = exports.calculateHashesForCreateNodes = exports.calculateHashForCreateNodes = exports.mapAsyncIterable = exports.combineAsyncIterables = exports.createAsyncIterable = exports.assertSupportedPackageVersion = exports.assertSupportedInstalledPackageVersion = exports.getInstalledPackageVersion = exports.getDeclaredPackageVersion = exports.addPlugin = exports.upsertTargetDefault = exports.updateTargetDefault = exports.readTargetDefaultsForTarget = exports.findTargetDefault = exports.addE2eCiTargetDefaults = exports.addBuildTargetDefaults = exports.promptWhenInteractive = exports.resolveImportPath = exports.ensureRootProjectName = exports.determineProjectNameAndRootOptions = exports.toProjectRelativePath = exports.deleteMatchingProperties = exports.processTargetOutputs = exports.NoTargetsToMigrateError = exports.migrateProjectExecutorsToPluginV1 = exports.migrateProjectExecutorsToPlugin = exports.AggregatedLog = exports.forEachExecutorOptions = exports.getE2EWebServerInfo = exports.getRelativeCwd = exports.determineArtifactNameAndDirectoryOptions = exports.getCatalogManager = exports.acknowledgeBuildScripts = exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.createProjectRootMappingsFromProjectConfigurations = exports.signalToCode = void 0;
4
+ exports.findMatchingProjects = exports.findMatchingConfigFiles = exports.findInstalledPlugins = exports.findAllProjectNodeDependencies = exports.filterUsingGlobPatterns = exports.fileExists = exports.fileDataDepType = exports.fileDataDepTarget = exports.expandWildcardTargetConfiguration = exports.expandInitiatingTasksThroughNoop = exports.expandDependencyConfigSyntaxSugar = exports.directoryExists = exports.deriveGroupNameFromTarget = exports.defaultFileRead = exports.deduceDefaultBase = exports.daemonClient = exports.createTaskId = exports.createRunManyDynamicOutputRenderer = exports.createProjectRootMappings = exports.createProjectGraphAndSourceMapsAsync = exports.createPackageJson = exports.createNxCloudOnboardingURLForWelcomeApp = exports.createNxCloudOnboardingURL = exports.createLockFile = exports.createDirectory = exports.connectToNxCloud = exports.combineGlobPatterns = exports.codeFrameColumns = exports.calculateReverseDeps = exports.calculateFileChanges = exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.WholeFileChange = exports.TargetProjectLocator = exports.TEN_MEGABYTES = exports.SyncError = exports.RemoteCacheV2 = exports.NX_PREFIX = exports.LockFileChange = exports.LARGE_BUFFER = exports.FsTree = exports.DeletedFileChange = exports.CompositeLifeCycle = exports.Cache = exports.BatchFunctionRunner = exports.runCommandsExecutor = exports.dasherize = exports.classify = exports.capitalize = exports.camelize = exports.checkAndCleanWithSemver = void 0;
5
+ exports.normalizeTargetDependencyWithStringProjects = exports.normalizeDependencyConfigProjects = exports.normalizeDependencyConfigDefinition = exports.mergeTargetConfigurations = exports.loadTsFile = exports.killProcessTreeGraceful = exports.isWholeFileChange = exports.isRelativePath = exports.isProjectGraphProjectNode = exports.isProjectGraphExternalNode = exports.isNxCloudUsed = exports.isNpmProject = exports.isLockFileChange = exports.isDeletedFileChange = exports.isCacheableTask = exports.isCI = exports.isBuiltinModuleImport = exports.interpolate = exports.hashWithWorkspaceContext = exports.hashObject = exports.hashFile = exports.handleProjectGraphError = exports.globWithWorkspaceContext = exports.getWorkspacePackagesFromGraph = exports.getUnparsedOverrideArgs = exports.getTargetInputs = exports.getTargetConfigurationForTask = exports.getSourceDirOfDependentProjects = exports.getSerializedArgsForTask = exports.getRelativeProjectJsonSchemaPath = exports.getPrintableCommandArgsForTask = exports.getOutputs = exports.getNxRequirePaths = exports.getNxCloudUrl = exports.getNxCloudAppOnBoardingUrl = exports.getLockFileName = exports.getLatestCommitSha = exports.getLastValueFromAsyncIterableIterator = exports.getGlobPatternsFromPackageManagerWorkspaces = exports.getGeneratorInformation = exports.getFilesInDirectoryUsingContext = exports.getExecutorNameForTask = exports.getExecutorInformation = exports.getExecutorForTask = exports.getDependencyConfigs = exports.getCustomHasher = exports.getCliPath = exports.forceRegisterEsmLoader = exports.findProjectsNpmDependencies = exports.findProjectForPath = void 0;
6
+ exports.workspaceRootInner = exports.workspaceDataDirectory = exports.validateOutputs = exports.unparse = exports.transformLegacyOutputs = exports.toOldFormat = exports.toNewFormat = exports.shouldStreamOutput = exports.setupWorkspaceContext = exports.setupAiAgentsGenerator = exports.setWorkspaceRoot = exports.safeSpawn = exports.safeExecFileSync = exports.runNxSync = exports.resetWorkspaceContext = exports.requireWithTsconfigFallback = exports.removeTasksFromTaskGraph = exports.registerTsProject = exports.registerTsConfigPaths = exports.readProjectAndTargetFromTargetString = exports.readPackageJson = exports.readNxMigrateConfig = exports.readNxJsonFromDisk = exports.readModulePackageJson = exports.readFileMapCache = exports.readFileIfExisting = exports.readCachedProjectConfiguration = exports.preventRecursionInGraphConstruction = exports.parseExecutor = exports.orange = exports.nxVersion = void 0;
5
7
  var devkit_internals_1 = require("nx/src/devkit-internals");
6
8
  Object.defineProperty(exports, "signalToCode", { enumerable: true, get: function () { return devkit_internals_1.signalToCode; } });
7
9
  Object.defineProperty(exports, "createProjectRootMappingsFromProjectConfigurations", { enumerable: true, get: function () { return devkit_internals_1.createProjectRootMappingsFromProjectConfigurations; } });
@@ -15,6 +17,12 @@ Object.defineProperty(exports, "SchemaResolutionError", { enumerable: true, get:
15
17
  Object.defineProperty(exports, "resolvePrompt", { enumerable: true, get: function () { return devkit_internals_1.resolvePrompt; } });
16
18
  Object.defineProperty(exports, "PromptResolutionError", { enumerable: true, get: function () { return devkit_internals_1.PromptResolutionError; } });
17
19
  Object.defineProperty(exports, "acknowledgeBuildScripts", { enumerable: true, get: function () { return devkit_internals_1.acknowledgeBuildScripts; } });
20
+ // getCatalogManager takes the barrel route here because this file *is*
21
+ // @nx/devkit/internal — first-party consumers only, released in lockstep. Its
22
+ // class-1 siblings in packages/devkit/src/utils/ (semver.ts, package-json.ts)
23
+ // ship to external plugins under the +/- 1 tolerance, so they must keep
24
+ // importing nx/src/utils/catalog directly. See packages/devkit/CLAUDE.md.
25
+ Object.defineProperty(exports, "getCatalogManager", { enumerable: true, get: function () { return devkit_internals_1.getCatalogManager; } });
18
26
  // Generators
19
27
  var artifact_name_and_directory_utils_1 = require("./src/generators/artifact-name-and-directory-utils");
20
28
  Object.defineProperty(exports, "determineArtifactNameAndDirectoryOptions", { enumerable: true, get: function () { return artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions; } });
@@ -62,9 +70,6 @@ Object.defineProperty(exports, "mapAsyncIterable", { enumerable: true, get: func
62
70
  var calculate_hash_for_create_nodes_1 = require("./src/utils/calculate-hash-for-create-nodes");
63
71
  Object.defineProperty(exports, "calculateHashForCreateNodes", { enumerable: true, get: function () { return calculate_hash_for_create_nodes_1.calculateHashForCreateNodes; } });
64
72
  Object.defineProperty(exports, "calculateHashesForCreateNodes", { enumerable: true, get: function () { return calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes; } });
65
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports -- nx/src/utils/catalog exists since nx 22.0.0, the whole supported range; swap to the nx/src/devkit-internals re-export in v25
66
- var catalog_1 = require("nx/src/utils/catalog");
67
- Object.defineProperty(exports, "getCatalogManager", { enumerable: true, get: function () { return catalog_1.getCatalogManager; } });
68
73
  var config_utils_1 = require("./src/utils/config-utils");
69
74
  Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return config_utils_1.loadConfigFile; } });
70
75
  Object.defineProperty(exports, "clearRequireCache", { enumerable: true, get: function () { return config_utils_1.clearRequireCache; } });
@@ -83,3 +88,131 @@ Object.defineProperty(exports, "camelize", { enumerable: true, get: function ()
83
88
  Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return string_utils_1.capitalize; } });
84
89
  Object.defineProperty(exports, "classify", { enumerable: true, get: function () { return string_utils_1.classify; } });
85
90
  Object.defineProperty(exports, "dasherize", { enumerable: true, get: function () { return string_utils_1.dasherize; } });
91
+ // Re-exported for first-party plugins in this repo.
92
+ var devkit_internals_2 = require("nx/src/devkit-internals");
93
+ Object.defineProperty(exports, "runCommandsExecutor", { enumerable: true, get: function () { return devkit_internals_2.runCommandsExecutor; } });
94
+ Object.defineProperty(exports, "BatchFunctionRunner", { enumerable: true, get: function () { return devkit_internals_2.BatchFunctionRunner; } });
95
+ Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return devkit_internals_2.Cache; } });
96
+ Object.defineProperty(exports, "CompositeLifeCycle", { enumerable: true, get: function () { return devkit_internals_2.CompositeLifeCycle; } });
97
+ Object.defineProperty(exports, "DeletedFileChange", { enumerable: true, get: function () { return devkit_internals_2.DeletedFileChange; } });
98
+ Object.defineProperty(exports, "FsTree", { enumerable: true, get: function () { return devkit_internals_2.FsTree; } });
99
+ Object.defineProperty(exports, "LARGE_BUFFER", { enumerable: true, get: function () { return devkit_internals_2.LARGE_BUFFER; } });
100
+ Object.defineProperty(exports, "LockFileChange", { enumerable: true, get: function () { return devkit_internals_2.LockFileChange; } });
101
+ Object.defineProperty(exports, "NX_PREFIX", { enumerable: true, get: function () { return devkit_internals_2.NX_PREFIX; } });
102
+ Object.defineProperty(exports, "RemoteCacheV2", { enumerable: true, get: function () { return devkit_internals_2.RemoteCacheV2; } });
103
+ Object.defineProperty(exports, "SyncError", { enumerable: true, get: function () { return devkit_internals_2.SyncError; } });
104
+ Object.defineProperty(exports, "TEN_MEGABYTES", { enumerable: true, get: function () { return devkit_internals_2.TEN_MEGABYTES; } });
105
+ Object.defineProperty(exports, "TargetProjectLocator", { enumerable: true, get: function () { return devkit_internals_2.TargetProjectLocator; } });
106
+ Object.defineProperty(exports, "WholeFileChange", { enumerable: true, get: function () { return devkit_internals_2.WholeFileChange; } });
107
+ Object.defineProperty(exports, "buildProjectGraphAndSourceMapsWithoutDaemon", { enumerable: true, get: function () { return devkit_internals_2.buildProjectGraphAndSourceMapsWithoutDaemon; } });
108
+ Object.defineProperty(exports, "calculateFileChanges", { enumerable: true, get: function () { return devkit_internals_2.calculateFileChanges; } });
109
+ Object.defineProperty(exports, "calculateReverseDeps", { enumerable: true, get: function () { return devkit_internals_2.calculateReverseDeps; } });
110
+ Object.defineProperty(exports, "codeFrameColumns", { enumerable: true, get: function () { return devkit_internals_2.codeFrameColumns; } });
111
+ Object.defineProperty(exports, "combineGlobPatterns", { enumerable: true, get: function () { return devkit_internals_2.combineGlobPatterns; } });
112
+ Object.defineProperty(exports, "connectToNxCloud", { enumerable: true, get: function () { return devkit_internals_2.connectToNxCloud; } });
113
+ Object.defineProperty(exports, "createDirectory", { enumerable: true, get: function () { return devkit_internals_2.createDirectory; } });
114
+ Object.defineProperty(exports, "createLockFile", { enumerable: true, get: function () { return devkit_internals_2.createLockFile; } });
115
+ Object.defineProperty(exports, "createNxCloudOnboardingURL", { enumerable: true, get: function () { return devkit_internals_2.createNxCloudOnboardingURL; } });
116
+ Object.defineProperty(exports, "createNxCloudOnboardingURLForWelcomeApp", { enumerable: true, get: function () { return devkit_internals_2.createNxCloudOnboardingURLForWelcomeApp; } });
117
+ Object.defineProperty(exports, "createPackageJson", { enumerable: true, get: function () { return devkit_internals_2.createPackageJson; } });
118
+ Object.defineProperty(exports, "createProjectGraphAndSourceMapsAsync", { enumerable: true, get: function () { return devkit_internals_2.createProjectGraphAndSourceMapsAsync; } });
119
+ Object.defineProperty(exports, "createProjectRootMappings", { enumerable: true, get: function () { return devkit_internals_2.createProjectRootMappings; } });
120
+ Object.defineProperty(exports, "createRunManyDynamicOutputRenderer", { enumerable: true, get: function () { return devkit_internals_2.createRunManyDynamicOutputRenderer; } });
121
+ Object.defineProperty(exports, "createTaskId", { enumerable: true, get: function () { return devkit_internals_2.createTaskId; } });
122
+ Object.defineProperty(exports, "daemonClient", { enumerable: true, get: function () { return devkit_internals_2.daemonClient; } });
123
+ Object.defineProperty(exports, "deduceDefaultBase", { enumerable: true, get: function () { return devkit_internals_2.deduceDefaultBase; } });
124
+ Object.defineProperty(exports, "defaultFileRead", { enumerable: true, get: function () { return devkit_internals_2.defaultFileRead; } });
125
+ Object.defineProperty(exports, "deriveGroupNameFromTarget", { enumerable: true, get: function () { return devkit_internals_2.deriveGroupNameFromTarget; } });
126
+ Object.defineProperty(exports, "directoryExists", { enumerable: true, get: function () { return devkit_internals_2.directoryExists; } });
127
+ Object.defineProperty(exports, "expandDependencyConfigSyntaxSugar", { enumerable: true, get: function () { return devkit_internals_2.expandDependencyConfigSyntaxSugar; } });
128
+ Object.defineProperty(exports, "expandInitiatingTasksThroughNoop", { enumerable: true, get: function () { return devkit_internals_2.expandInitiatingTasksThroughNoop; } });
129
+ Object.defineProperty(exports, "expandWildcardTargetConfiguration", { enumerable: true, get: function () { return devkit_internals_2.expandWildcardTargetConfiguration; } });
130
+ Object.defineProperty(exports, "fileDataDepTarget", { enumerable: true, get: function () { return devkit_internals_2.fileDataDepTarget; } });
131
+ Object.defineProperty(exports, "fileDataDepType", { enumerable: true, get: function () { return devkit_internals_2.fileDataDepType; } });
132
+ Object.defineProperty(exports, "fileExists", { enumerable: true, get: function () { return devkit_internals_2.fileExists; } });
133
+ Object.defineProperty(exports, "filterUsingGlobPatterns", { enumerable: true, get: function () { return devkit_internals_2.filterUsingGlobPatterns; } });
134
+ Object.defineProperty(exports, "findAllProjectNodeDependencies", { enumerable: true, get: function () { return devkit_internals_2.findAllProjectNodeDependencies; } });
135
+ Object.defineProperty(exports, "findInstalledPlugins", { enumerable: true, get: function () { return devkit_internals_2.findInstalledPlugins; } });
136
+ Object.defineProperty(exports, "findMatchingConfigFiles", { enumerable: true, get: function () { return devkit_internals_2.findMatchingConfigFiles; } });
137
+ Object.defineProperty(exports, "findMatchingProjects", { enumerable: true, get: function () { return devkit_internals_2.findMatchingProjects; } });
138
+ Object.defineProperty(exports, "findProjectForPath", { enumerable: true, get: function () { return devkit_internals_2.findProjectForPath; } });
139
+ Object.defineProperty(exports, "findProjectsNpmDependencies", { enumerable: true, get: function () { return devkit_internals_2.findProjectsNpmDependencies; } });
140
+ Object.defineProperty(exports, "forceRegisterEsmLoader", { enumerable: true, get: function () { return devkit_internals_2.forceRegisterEsmLoader; } });
141
+ Object.defineProperty(exports, "getCliPath", { enumerable: true, get: function () { return devkit_internals_2.getCliPath; } });
142
+ Object.defineProperty(exports, "getCustomHasher", { enumerable: true, get: function () { return devkit_internals_2.getCustomHasher; } });
143
+ Object.defineProperty(exports, "getDependencyConfigs", { enumerable: true, get: function () { return devkit_internals_2.getDependencyConfigs; } });
144
+ Object.defineProperty(exports, "getExecutorForTask", { enumerable: true, get: function () { return devkit_internals_2.getExecutorForTask; } });
145
+ Object.defineProperty(exports, "getExecutorInformation", { enumerable: true, get: function () { return devkit_internals_2.getExecutorInformation; } });
146
+ Object.defineProperty(exports, "getExecutorNameForTask", { enumerable: true, get: function () { return devkit_internals_2.getExecutorNameForTask; } });
147
+ Object.defineProperty(exports, "getFilesInDirectoryUsingContext", { enumerable: true, get: function () { return devkit_internals_2.getFilesInDirectoryUsingContext; } });
148
+ Object.defineProperty(exports, "getGeneratorInformation", { enumerable: true, get: function () { return devkit_internals_2.getGeneratorInformation; } });
149
+ Object.defineProperty(exports, "getGlobPatternsFromPackageManagerWorkspaces", { enumerable: true, get: function () { return devkit_internals_2.getGlobPatternsFromPackageManagerWorkspaces; } });
150
+ Object.defineProperty(exports, "getLastValueFromAsyncIterableIterator", { enumerable: true, get: function () { return devkit_internals_2.getLastValueFromAsyncIterableIterator; } });
151
+ Object.defineProperty(exports, "getLatestCommitSha", { enumerable: true, get: function () { return devkit_internals_2.getLatestCommitSha; } });
152
+ Object.defineProperty(exports, "getLockFileName", { enumerable: true, get: function () { return devkit_internals_2.getLockFileName; } });
153
+ Object.defineProperty(exports, "getNxCloudAppOnBoardingUrl", { enumerable: true, get: function () { return devkit_internals_2.getNxCloudAppOnBoardingUrl; } });
154
+ Object.defineProperty(exports, "getNxCloudUrl", { enumerable: true, get: function () { return devkit_internals_2.getNxCloudUrl; } });
155
+ Object.defineProperty(exports, "getNxRequirePaths", { enumerable: true, get: function () { return devkit_internals_2.getNxRequirePaths; } });
156
+ Object.defineProperty(exports, "getOutputs", { enumerable: true, get: function () { return devkit_internals_2.getOutputs; } });
157
+ Object.defineProperty(exports, "getPrintableCommandArgsForTask", { enumerable: true, get: function () { return devkit_internals_2.getPrintableCommandArgsForTask; } });
158
+ Object.defineProperty(exports, "getRelativeProjectJsonSchemaPath", { enumerable: true, get: function () { return devkit_internals_2.getRelativeProjectJsonSchemaPath; } });
159
+ Object.defineProperty(exports, "getSerializedArgsForTask", { enumerable: true, get: function () { return devkit_internals_2.getSerializedArgsForTask; } });
160
+ Object.defineProperty(exports, "getSourceDirOfDependentProjects", { enumerable: true, get: function () { return devkit_internals_2.getSourceDirOfDependentProjects; } });
161
+ Object.defineProperty(exports, "getTargetConfigurationForTask", { enumerable: true, get: function () { return devkit_internals_2.getTargetConfigurationForTask; } });
162
+ Object.defineProperty(exports, "getTargetInputs", { enumerable: true, get: function () { return devkit_internals_2.getTargetInputs; } });
163
+ Object.defineProperty(exports, "getUnparsedOverrideArgs", { enumerable: true, get: function () { return devkit_internals_2.getUnparsedOverrideArgs; } });
164
+ Object.defineProperty(exports, "getWorkspacePackagesFromGraph", { enumerable: true, get: function () { return devkit_internals_2.getWorkspacePackagesFromGraph; } });
165
+ Object.defineProperty(exports, "globWithWorkspaceContext", { enumerable: true, get: function () { return devkit_internals_2.globWithWorkspaceContext; } });
166
+ Object.defineProperty(exports, "handleProjectGraphError", { enumerable: true, get: function () { return devkit_internals_2.handleProjectGraphError; } });
167
+ Object.defineProperty(exports, "hashFile", { enumerable: true, get: function () { return devkit_internals_2.hashFile; } });
168
+ Object.defineProperty(exports, "hashObject", { enumerable: true, get: function () { return devkit_internals_2.hashObject; } });
169
+ Object.defineProperty(exports, "hashWithWorkspaceContext", { enumerable: true, get: function () { return devkit_internals_2.hashWithWorkspaceContext; } });
170
+ Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return devkit_internals_2.interpolate; } });
171
+ Object.defineProperty(exports, "isBuiltinModuleImport", { enumerable: true, get: function () { return devkit_internals_2.isBuiltinModuleImport; } });
172
+ Object.defineProperty(exports, "isCI", { enumerable: true, get: function () { return devkit_internals_2.isCI; } });
173
+ Object.defineProperty(exports, "isCacheableTask", { enumerable: true, get: function () { return devkit_internals_2.isCacheableTask; } });
174
+ Object.defineProperty(exports, "isDeletedFileChange", { enumerable: true, get: function () { return devkit_internals_2.isDeletedFileChange; } });
175
+ Object.defineProperty(exports, "isLockFileChange", { enumerable: true, get: function () { return devkit_internals_2.isLockFileChange; } });
176
+ Object.defineProperty(exports, "isNpmProject", { enumerable: true, get: function () { return devkit_internals_2.isNpmProject; } });
177
+ Object.defineProperty(exports, "isNxCloudUsed", { enumerable: true, get: function () { return devkit_internals_2.isNxCloudUsed; } });
178
+ Object.defineProperty(exports, "isProjectGraphExternalNode", { enumerable: true, get: function () { return devkit_internals_2.isProjectGraphExternalNode; } });
179
+ Object.defineProperty(exports, "isProjectGraphProjectNode", { enumerable: true, get: function () { return devkit_internals_2.isProjectGraphProjectNode; } });
180
+ Object.defineProperty(exports, "isRelativePath", { enumerable: true, get: function () { return devkit_internals_2.isRelativePath; } });
181
+ Object.defineProperty(exports, "isWholeFileChange", { enumerable: true, get: function () { return devkit_internals_2.isWholeFileChange; } });
182
+ Object.defineProperty(exports, "killProcessTreeGraceful", { enumerable: true, get: function () { return devkit_internals_2.killProcessTreeGraceful; } });
183
+ Object.defineProperty(exports, "loadTsFile", { enumerable: true, get: function () { return devkit_internals_2.loadTsFile; } });
184
+ Object.defineProperty(exports, "mergeTargetConfigurations", { enumerable: true, get: function () { return devkit_internals_2.mergeTargetConfigurations; } });
185
+ Object.defineProperty(exports, "normalizeDependencyConfigDefinition", { enumerable: true, get: function () { return devkit_internals_2.normalizeDependencyConfigDefinition; } });
186
+ Object.defineProperty(exports, "normalizeDependencyConfigProjects", { enumerable: true, get: function () { return devkit_internals_2.normalizeDependencyConfigProjects; } });
187
+ Object.defineProperty(exports, "normalizeTargetDependencyWithStringProjects", { enumerable: true, get: function () { return devkit_internals_2.normalizeTargetDependencyWithStringProjects; } });
188
+ Object.defineProperty(exports, "nxVersion", { enumerable: true, get: function () { return devkit_internals_2.nxVersion; } });
189
+ Object.defineProperty(exports, "orange", { enumerable: true, get: function () { return devkit_internals_2.orange; } });
190
+ Object.defineProperty(exports, "parseExecutor", { enumerable: true, get: function () { return devkit_internals_2.parseExecutor; } });
191
+ Object.defineProperty(exports, "preventRecursionInGraphConstruction", { enumerable: true, get: function () { return devkit_internals_2.preventRecursionInGraphConstruction; } });
192
+ Object.defineProperty(exports, "readCachedProjectConfiguration", { enumerable: true, get: function () { return devkit_internals_2.readCachedProjectConfiguration; } });
193
+ Object.defineProperty(exports, "readFileIfExisting", { enumerable: true, get: function () { return devkit_internals_2.readFileIfExisting; } });
194
+ Object.defineProperty(exports, "readFileMapCache", { enumerable: true, get: function () { return devkit_internals_2.readFileMapCache; } });
195
+ Object.defineProperty(exports, "readModulePackageJson", { enumerable: true, get: function () { return devkit_internals_2.readModulePackageJson; } });
196
+ Object.defineProperty(exports, "readNxJsonFromDisk", { enumerable: true, get: function () { return devkit_internals_2.readNxJsonFromDisk; } });
197
+ Object.defineProperty(exports, "readNxMigrateConfig", { enumerable: true, get: function () { return devkit_internals_2.readNxMigrateConfig; } });
198
+ Object.defineProperty(exports, "readPackageJson", { enumerable: true, get: function () { return devkit_internals_2.readPackageJson; } });
199
+ Object.defineProperty(exports, "readProjectAndTargetFromTargetString", { enumerable: true, get: function () { return devkit_internals_2.readProjectAndTargetFromTargetString; } });
200
+ Object.defineProperty(exports, "registerTsConfigPaths", { enumerable: true, get: function () { return devkit_internals_2.registerTsConfigPaths; } });
201
+ Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return devkit_internals_2.registerTsProject; } });
202
+ Object.defineProperty(exports, "removeTasksFromTaskGraph", { enumerable: true, get: function () { return devkit_internals_2.removeTasksFromTaskGraph; } });
203
+ Object.defineProperty(exports, "requireWithTsconfigFallback", { enumerable: true, get: function () { return devkit_internals_2.requireWithTsconfigFallback; } });
204
+ Object.defineProperty(exports, "resetWorkspaceContext", { enumerable: true, get: function () { return devkit_internals_2.resetWorkspaceContext; } });
205
+ Object.defineProperty(exports, "runNxSync", { enumerable: true, get: function () { return devkit_internals_2.runNxSync; } });
206
+ Object.defineProperty(exports, "safeExecFileSync", { enumerable: true, get: function () { return devkit_internals_2.safeExecFileSync; } });
207
+ Object.defineProperty(exports, "safeSpawn", { enumerable: true, get: function () { return devkit_internals_2.safeSpawn; } });
208
+ Object.defineProperty(exports, "setWorkspaceRoot", { enumerable: true, get: function () { return devkit_internals_2.setWorkspaceRoot; } });
209
+ Object.defineProperty(exports, "setupAiAgentsGenerator", { enumerable: true, get: function () { return devkit_internals_2.setupAiAgentsGenerator; } });
210
+ Object.defineProperty(exports, "setupWorkspaceContext", { enumerable: true, get: function () { return devkit_internals_2.setupWorkspaceContext; } });
211
+ Object.defineProperty(exports, "shouldStreamOutput", { enumerable: true, get: function () { return devkit_internals_2.shouldStreamOutput; } });
212
+ Object.defineProperty(exports, "toNewFormat", { enumerable: true, get: function () { return devkit_internals_2.toNewFormat; } });
213
+ Object.defineProperty(exports, "toOldFormat", { enumerable: true, get: function () { return devkit_internals_2.toOldFormat; } });
214
+ Object.defineProperty(exports, "transformLegacyOutputs", { enumerable: true, get: function () { return devkit_internals_2.transformLegacyOutputs; } });
215
+ Object.defineProperty(exports, "unparse", { enumerable: true, get: function () { return devkit_internals_2.unparse; } });
216
+ Object.defineProperty(exports, "validateOutputs", { enumerable: true, get: function () { return devkit_internals_2.validateOutputs; } });
217
+ Object.defineProperty(exports, "workspaceDataDirectory", { enumerable: true, get: function () { return devkit_internals_2.workspaceDataDirectory; } });
218
+ Object.defineProperty(exports, "workspaceRootInner", { enumerable: true, get: function () { return devkit_internals_2.workspaceRootInner; } });
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @category Ng CLI Adapter
3
3
  */
4
- export { wrapAngularDevkitSchematic, mockSchematicsForTesting, NxScopedHost, } from 'nx/src/adapter/ngcli-adapter';
4
+ export { wrapAngularDevkitSchematic, mockSchematicsForTesting, NxScopedHost, createBuilderContext, } from 'nx/src/adapter/ngcli-adapter';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NxScopedHost = exports.mockSchematicsForTesting = exports.wrapAngularDevkitSchematic = void 0;
3
+ exports.createBuilderContext = exports.NxScopedHost = exports.mockSchematicsForTesting = exports.wrapAngularDevkitSchematic = void 0;
4
4
  /**
5
5
  * @category Ng CLI Adapter
6
6
  */
@@ -9,3 +9,4 @@ var ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
9
9
  Object.defineProperty(exports, "wrapAngularDevkitSchematic", { enumerable: true, get: function () { return ngcli_adapter_1.wrapAngularDevkitSchematic; } });
10
10
  Object.defineProperty(exports, "mockSchematicsForTesting", { enumerable: true, get: function () { return ngcli_adapter_1.mockSchematicsForTesting; } });
11
11
  Object.defineProperty(exports, "NxScopedHost", { enumerable: true, get: function () { return ngcli_adapter_1.NxScopedHost; } });
12
+ Object.defineProperty(exports, "createBuilderContext", { enumerable: true, get: function () { return ngcli_adapter_1.createBuilderContext; } });
@@ -1,6 +1,8 @@
1
1
  import { Tree } from 'nx/src/devkit-exports';
2
2
  /**
3
- * Formats all the created or updated files using Prettier
3
+ * Formats the created or updated files using Prettier, skipping `node_modules`,
4
+ * `.git`, the nx and yarn caches, and anything the workspace's root
5
+ * `.gitignore` or `.prettierignore` covers
4
6
  * @param tree - the file system tree
5
7
  * @param options - options for the formatFiles function
6
8
  *
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const devkit_exports_1 = require("nx/src/devkit-exports");
6
6
  const devkit_internals_1 = require("nx/src/devkit-internals");
7
7
  const path = tslib_1.__importStar(require("path"));
8
+ const nx_ignore_internals_1 = require("../utils/nx-ignore-internals");
8
9
  // Prettier v3 (ESM) exposes its API as named exports; v2 (CJS) exposes it under
9
10
  // `.default` when loaded via `import()`. Return whichever carries the API, or
10
11
  // null if prettier isn't installed.
@@ -18,7 +19,9 @@ async function importPrettier() {
18
19
  }
19
20
  }
20
21
  /**
21
- * Formats all the created or updated files using Prettier
22
+ * Formats the created or updated files using Prettier, skipping `node_modules`,
23
+ * `.git`, the nx and yarn caches, and anything the workspace's root
24
+ * `.gitignore` or `.prettierignore` covers
22
25
  * @param tree - the file system tree
23
26
  * @param options - options for the formatFiles function
24
27
  *
@@ -56,7 +59,16 @@ async function formatFiles(tree, options = {}) {
56
59
  catch { }
57
60
  if (!prettier)
58
61
  return;
59
- const files = new Set(tree.listChanges().filter((file) => file.type !== 'DELETE'));
62
+ // `getFileInfo` below looks like it filters ignored files but only covers its
63
+ // own built-in `node_modules` skip: with no `ignorePath` it never reads the
64
+ // workspace's ignore files, so `ignored` is false for everything else
65
+ // (measured).
66
+ //
67
+ // The optional call is the older-nx path - see `NOTHING_IGNORED`.
68
+ const { isIgnoredFile } = (0, devkit_internals_1.createPrettierIgnoreChecker)?.(tree) ?? nx_ignore_internals_1.NOTHING_IGNORED;
69
+ const files = new Set(tree
70
+ .listChanges()
71
+ .filter((file) => file.type !== 'DELETE' && !isIgnoredFile(file.path)));
60
72
  const changedPrettierInTree = getChangedPrettierConfigInTree(tree);
61
73
  await Promise.all(Array.from(files).map(async (file) => {
62
74
  try {
@@ -1,6 +1,5 @@
1
1
  import type { ProjectConfiguration } from 'nx/src/config/workspace-json-project-json';
2
- import { type CreateNodes, type NxJsonConfiguration, type ProjectGraph, type TargetConfiguration, type Tree } from 'nx/src/devkit-exports';
3
- import { logger as devkitLogger } from 'nx/src/devkit-exports';
2
+ import { type CreateNodes, type NxJsonConfiguration, type ProjectGraph, type TargetConfiguration, type Tree, logger as devkitLogger } from 'nx/src/devkit-exports';
4
3
  export type InferredTargetConfiguration = TargetConfiguration & {
5
4
  name: string;
6
5
  };
@@ -14,7 +14,6 @@ const devkit_internals_1 = require("nx/src/devkit-internals");
14
14
  const executor_options_utils_1 = require("../executor-options-utils");
15
15
  const target_defaults_utils_1 = require("../target-defaults-utils");
16
16
  const plugin_migration_utils_1 = require("./plugin-migration-utils");
17
- const devkit_exports_2 = require("nx/src/devkit-exports");
18
17
  class ExecutorToPluginMigrator {
19
18
  constructor(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, createNodesV2, specificProjectToMigrate, filters, logger) {
20
19
  _ExecutorToPluginMigrator_instances.add(this);
@@ -45,7 +44,7 @@ class ExecutorToPluginMigrator {
45
44
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_specificProjectToMigrate, specificProjectToMigrate, "f");
46
45
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_skipProjectFilter, filters?.skipProjectFilter ?? ((...args) => false), "f");
47
46
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_skipTargetFilter, filters?.skipTargetFilter ?? ((...args) => false), "f");
48
- tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_logger, logger ?? devkit_exports_2.logger, "f");
47
+ tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_logger, logger ?? devkit_exports_1.logger, "f");
49
48
  }
50
49
  async run() {
51
50
  await tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_init).call(this);
@@ -1,5 +1,12 @@
1
1
  import type { Tree } from 'nx/src/devkit-exports';
2
2
  /**
3
3
  * Utility to act on all files in a tree that are not ignored by git.
4
+ *
5
+ * Ignore files cascade, so a nested `.gitignore` covers the files under it and a
6
+ * nested negation overrides the root. They are read from the tree, not disk, so
7
+ * one a generator wrote in the same run counts.
8
+ *
9
+ * `node_modules`, `.git` and the nx and yarn caches are never visited, whatever
10
+ * the workspace's ignore files say.
4
11
  */
5
12
  export declare function visitNotIgnoredFiles(tree: Tree, dirPath: string, visitor: (path: string) => void): void;
@@ -3,25 +3,50 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.visitNotIgnoredFiles = visitNotIgnoredFiles;
4
4
  const devkit_internals_1 = require("nx/src/devkit-internals");
5
5
  const path_1 = require("path");
6
+ const nx_ignore_internals_1 = require("../utils/nx-ignore-internals");
6
7
  /**
7
8
  * Utility to act on all files in a tree that are not ignored by git.
9
+ *
10
+ * Ignore files cascade, so a nested `.gitignore` covers the files under it and a
11
+ * nested negation overrides the root. They are read from the tree, not disk, so
12
+ * one a generator wrote in the same run counts.
13
+ *
14
+ * `node_modules`, `.git` and the nx and yarn caches are never visited, whatever
15
+ * the workspace's ignore files say.
8
16
  */
9
17
  function visitNotIgnoredFiles(tree, dirPath = tree.root, visitor) {
10
- const ig = (0, devkit_internals_1.getIgnoreObjectForTree)(tree);
11
- dirPath = normalizePathRelativeToRoot(dirPath, tree.root);
12
- if (dirPath !== '' && ig?.ignores(dirPath)) {
18
+ (0, nx_ignore_internals_1.assertNxSupportsIgnoreCheckers)();
19
+ // Built once for the whole traversal.
20
+ const isIgnored = (0, devkit_internals_1.createGitIgnoreChecker)(tree);
21
+ const start = normalizePathRelativeToRoot(dirPath, tree.root);
22
+ // The caller's own directory is the only one nothing has checked - every
23
+ // deeper one is checked before it is descended into.
24
+ if (start !== '' && isIgnored.isIgnoredDirectory(start)) {
13
25
  return;
14
26
  }
27
+ visitDirectory(tree, start, visitor, isIgnored);
28
+ }
29
+ /**
30
+ * Callers must have cleared `dirPath` already - both call sites do.
31
+ *
32
+ * Not descending into an ignored directory is what makes the answers match git,
33
+ * not just what makes them fast: git refuses to re-include a file inside an
34
+ * excluded directory, and `isIgnoredFile` alone does not implement that rule
35
+ * (see `isIgnoredByChain`). Flattening this into a per-file filter would start
36
+ * visiting files git ignores.
37
+ */
38
+ function visitDirectory(tree, dirPath, visitor, isIgnored) {
15
39
  for (const child of tree.children(dirPath)) {
16
- const fullPath = (0, path_1.join)(dirPath, child);
17
- if (ig?.ignores(fullPath)) {
18
- continue;
19
- }
40
+ // Joined as POSIX rather than with `path.join`: tree paths are POSIX, and
41
+ // on Windows a backslash-separated path silently matches nothing.
42
+ const fullPath = dirPath ? `${dirPath}/${child}` : child;
20
43
  if (tree.isFile(fullPath)) {
21
- visitor(fullPath);
44
+ if (!isIgnored.isIgnoredFile(fullPath)) {
45
+ visitor(fullPath);
46
+ }
22
47
  }
23
- else {
24
- visitNotIgnoredFiles(tree, fullPath, visitor);
48
+ else if (!isIgnored.isIgnoredDirectory(fullPath)) {
49
+ visitDirectory(tree, fullPath, visitor, isIgnored);
25
50
  }
26
51
  }
27
52
  }
@@ -1,5 +1,8 @@
1
1
  export declare let dynamicImport: Function;
2
2
  export declare function loadConfigFile<T extends object = any>(configFilePath: string, tsconfigFileNames?: string[]): Promise<T>;
3
+ export declare function isTranspilerRecoverableError(err: unknown, path: string): boolean;
4
+ export declare function clearConfigFromRequireCache(rootId: string, cache?: NodeJS.Dict<NodeModule>): void;
5
+ export declare function unwrapCjsInterop(path: string, module: unknown, cache?: NodeJS.Dict<NodeModule>): unknown;
3
6
  export declare function getRootTsConfigPath(): string | null;
4
7
  export declare function getRootTsConfigFileName(): string | null;
5
8
  export declare function clearRequireCache(): void;
@@ -2,11 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dynamicImport = void 0;
4
4
  exports.loadConfigFile = loadConfigFile;
5
+ exports.isTranspilerRecoverableError = isTranspilerRecoverableError;
6
+ exports.clearConfigFromRequireCache = clearConfigFromRequireCache;
7
+ exports.unwrapCjsInterop = unwrapCjsInterop;
5
8
  exports.getRootTsConfigPath = getRootTsConfigPath;
6
9
  exports.getRootTsConfigFileName = getRootTsConfigFileName;
7
10
  exports.clearRequireCache = clearRequireCache;
8
11
  const fs_1 = require("fs");
9
12
  const node_url_1 = require("node:url");
13
+ const node_util_1 = require("node:util");
10
14
  const devkit_exports_1 = require("nx/src/devkit-exports");
11
15
  const devkit_internals_1 = require("nx/src/devkit-internals");
12
16
  const path_1 = require("path");
@@ -27,8 +31,22 @@ function isTypeScriptFile(extension) {
27
31
  }
28
32
  async function loadTypeScriptModule(path, extension, tsconfigFileNames) {
29
33
  const tsConfigPath = getTypeScriptConfigPath(path, tsconfigFileNames);
34
+ const modulePath = resolveModulePath(path);
30
35
  if (!tsConfigPath) {
31
- return await loadModuleByExtension(path, extension);
36
+ // The tsconfig-less path needs the same ESM-registry routing as below:
37
+ // require() of a sync-ESM .ts serves the stale registry entry on reloads.
38
+ if (esmRegistryPaths.has(modulePath)) {
39
+ // Clear first so an ESM-to-CJS rewrite re-evaluates instead of the
40
+ // import() serving the cached require.cache entry.
41
+ clearConfigFromRequireCache(modulePath);
42
+ return unwrapCjsInterop(path, await loadESM(path));
43
+ }
44
+ clearConfigFromRequireCache(modulePath);
45
+ const result = await loadModuleByExtension(path, extension);
46
+ if (node_util_1.types.isModuleNamespaceObject(result)) {
47
+ esmRegistryPaths.add(modulePath);
48
+ }
49
+ return result;
32
50
  }
33
51
  // loadTsFile was added in nx@23. @nx/devkit's peer range supports older
34
52
  // nx majors, so fall back to the legacy registerTsProject + require path
@@ -42,57 +60,202 @@ async function loadTypeScriptModule(path, extension, tsconfigFileNames) {
42
60
  cleanup();
43
61
  }
44
62
  }
63
+ // require.cache busting cannot invalidate a module the ESM registry
64
+ // holds; reloads of known-ESM paths need a cache-busted import().
65
+ if (esmRegistryPaths.has(modulePath)) {
66
+ return await loadTsFileViaImport(path, tsConfigPath);
67
+ }
68
+ // A CJS-shaped .ts stays in require.cache and may have changed on disk
69
+ // since; clear it so the reload re-reads the file.
70
+ clearConfigFromRequireCache(modulePath);
45
71
  // Both .ts and .mts go through loadTsFile first. Node 22.12+ supports
46
72
  // require() of synchronous ESM by default, and loadTsFile's lazy fallback
47
73
  // covers swc/ts-node + tsconfig-paths registration when needed (swc-node
48
74
  // hooks .cts/.mts/.ts via Module._extensions). Async-only ESM modules
49
75
  // (top-level await) throw ERR_REQUIRE_ASYNC_MODULE and fall through to
50
- // dynamic import(). ERR_REQUIRE_ESM is the legacy code for the same case
51
- // - kept for older Node lines.
76
+ // dynamic import(). ERR_REQUIRE_ESM is the legacy code for the same case,
77
+ // kept for older Node lines.
52
78
  try {
53
- return (0, devkit_internals_1.loadTsFile)(path, tsConfigPath);
79
+ const result = (0, devkit_internals_1.loadTsFile)(path, tsConfigPath);
80
+ if (node_util_1.types.isModuleNamespaceObject(result)) {
81
+ esmRegistryPaths.add(modulePath);
82
+ }
83
+ return result;
54
84
  }
55
85
  catch (e) {
56
86
  if (e?.code !== 'ERR_REQUIRE_ESM' &&
57
87
  e?.code !== 'ERR_REQUIRE_ASYNC_MODULE') {
58
88
  throw e;
59
89
  }
60
- // The module must be loaded via dynamic import(). Register
61
- // tsconfig-paths first so workspace alias imports resolve, then try a
62
- // native dynamic import. Node 22.18+ LTS strips TS types on the ESM
63
- // path natively, so pure-ESM TLA configs load without any swc/ts-node
64
- // ESM loader. Only escalate to forceRegisterEsmLoader (which throws
65
- // when neither @swc-node/register nor ts-node is installed) if the
66
- // native attempt hits unsupported TS syntax.
90
+ return await loadTsFileViaImport(path, tsConfigPath);
91
+ }
92
+ }
93
+ // Resolved paths of configs that require() loaded as synchronous ESM;
94
+ // reloads of these route through a cache-busted import(). On globalThis so the
95
+ // state survives clearRequireCache evicting this module itself (a
96
+ // workspace-linked devkit resolves outside node_modules).
97
+ const esmRegistryPaths = (globalThis[Symbol.for('@nx/devkit:esmRegistryPaths')] ??= new Set());
98
+ // Error codes from the load machinery (resolution, type stripping) that
99
+ // warrant registering swc/ts-node + tsconfig-paths and importing again.
100
+ // Unlisted errors propagate unchanged so a failing config is not
101
+ // re-evaluated. A not-found error can also come from the config's own
102
+ // dynamic import()/require() of a missing module, in which case the retry
103
+ // re-runs its top-level side effects; accepted so that static alias and
104
+ // extensionless imports (which fail at link time, before any user code
105
+ // runs) stay recoverable.
106
+ const ESM_LOAD_FALLBACK_ERROR_CODES = new Set([
107
+ 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX',
108
+ 'ERR_MODULE_NOT_FOUND',
109
+ 'MODULE_NOT_FOUND',
110
+ 'ERR_UNKNOWN_FILE_EXTENSION',
111
+ ]);
112
+ // Code-less errors that loadTsFile recovers on first load via the swc/
113
+ // ts-node fallback: a CJS-only global (__dirname, __filename, require) or a
114
+ // type-only named import evaluated on the native ESM path. Reloads must
115
+ // recover them too or an edit that introduces one turns into a hard graph
116
+ // failure. Prefer the host nx's classifiers so the gate matches what its
117
+ // loadTsFile recovers; nx versions that support the error classes without
118
+ // re-exporting the classifiers fall back to local replicas of them.
119
+ function isTranspilerRecoverableError(err, path) {
120
+ return ((typeof devkit_internals_1.isRequireInEsmScopeError === 'function'
121
+ ? (0, devkit_internals_1.isRequireInEsmScopeError)(err, path)
122
+ : isRequireInEsmScopeErrorReplica(err, path)) ||
123
+ (typeof devkit_internals_1.isTsEsmNamedExportLinkageError === 'function'
124
+ ? (0, devkit_internals_1.isTsEsmNamedExportLinkageError)(err, path)
125
+ : isTsEsmNamedExportLinkageErrorReplica(err, path)));
126
+ }
127
+ function isRequireInEsmScopeErrorReplica(err, filePath) {
128
+ if (!(err instanceof ReferenceError)) {
129
+ return false;
130
+ }
131
+ if (!(filePath.endsWith('.ts') || filePath.endsWith('.mts'))) {
132
+ return false;
133
+ }
134
+ return /(require|__dirname|__filename) is not defined/.test(err.message);
135
+ }
136
+ function isTsEsmNamedExportLinkageErrorReplica(err, filePath) {
137
+ if (!(err instanceof SyntaxError)) {
138
+ return false;
139
+ }
140
+ return ((filePath.endsWith('.ts') || filePath.endsWith('.mts')) &&
141
+ err.message.includes('does not provide an export named'));
142
+ }
143
+ // Invalidates a config module and its local CommonJS dependency subtree,
144
+ // leaving unrelated cached modules untouched (a broad clear re-evaluates
145
+ // them and breaks singleton identity). Walks each module's recorded
146
+ // children AND the cache-current instance for the same id, since another
147
+ // config may retain an older instance of a shared dependency. Detaches the
148
+ // root from its requiring parent so repeated reloads don't accumulate
149
+ // Module objects in the parent's children array.
150
+ function clearConfigFromRequireCache(rootId, cache = require.cache) {
151
+ const root = cache[rootId];
152
+ if (!root) {
153
+ return;
154
+ }
155
+ const visited = new Set();
156
+ const idsToDelete = new Set();
157
+ const queue = [root];
158
+ while (queue.length) {
159
+ const mod = queue.pop();
160
+ if (!mod || visited.has(mod)) {
161
+ continue;
162
+ }
163
+ visited.add(mod);
164
+ if (packageInstallationDirectories.some((dir) => mod.id.includes(dir))) {
165
+ continue;
166
+ }
167
+ idsToDelete.add(mod.id);
168
+ const current = cache[mod.id];
169
+ if (current && current !== mod) {
170
+ queue.push(current);
171
+ }
172
+ for (const child of mod.children) {
173
+ queue.push(child);
174
+ }
175
+ }
176
+ for (const id of idsToDelete) {
177
+ delete cache[id];
178
+ }
179
+ if (root.parent) {
180
+ root.parent.children = root.parent.children.filter((child) => child.id !== rootId);
181
+ }
182
+ }
183
+ // Canonical key for require.cache checks and esmRegistryPaths: a symlinked
184
+ // config's caller path differs from require's resolved filename.
185
+ function resolveModulePath(path) {
186
+ try {
187
+ return require.resolve(path);
188
+ }
189
+ catch {
190
+ return path;
191
+ }
192
+ }
193
+ async function loadTsFileViaImport(path, tsConfigPath) {
194
+ // Clear any prior require.cache entry so an ESM-to-CJS rewrite (or a
195
+ // loader-classified CJS load) re-evaluates instead of serving the cached
196
+ // copy.
197
+ clearConfigFromRequireCache(resolveModulePath(path));
198
+ // Try a bare native import first: Node 22.18+ strips TS types on the ESM
199
+ // path natively, and registerTsProject must NOT run up front. A
200
+ // registered swc/ts-node ESM loader intercepts every subsequent import
201
+ // in the process (it cannot be unregistered) and may classify a .ts
202
+ // config as CommonJS, defeating loadESM's cache-busting query on
203
+ // reloads. Register only when the native attempt fails.
204
+ try {
205
+ return unwrapCjsInterop(path, await loadESM(path));
206
+ }
207
+ catch (esmErr) {
208
+ if (!ESM_LOAD_FALLBACK_ERROR_CODES.has(esmErr?.code) &&
209
+ !isTranspilerRecoverableError(esmErr, path)) {
210
+ throw esmErr;
211
+ }
67
212
  const cleanup = (0, devkit_internals_1.registerTsProject)(tsConfigPath);
68
213
  try {
69
- return await loadESM(path);
214
+ return unwrapCjsInterop(path, await loadESM(path));
70
215
  }
71
- catch (esmErr) {
72
- if (esmErr?.code !== 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX' ||
216
+ catch (retryErr) {
217
+ if (isTranspilerRecoverableError(retryErr, path)) {
218
+ // A registered swc ESM loader compiles the retry to CJS, but
219
+ // ts-node/esm keeps the file ESM, so CJS globals stay undefined on
220
+ // the import path. Route through the CJS transpiler hook
221
+ // registerTsProject installed; it reads fresh from disk. A
222
+ // namespace result means no hook intercepted and require() hit the
223
+ // stale ESM registry, so surface the error instead.
224
+ const required = require(path);
225
+ if (!node_util_1.types.isModuleNamespaceObject(required)) {
226
+ return required;
227
+ }
228
+ throw retryErr;
229
+ }
230
+ if (retryErr?.code !== 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX' ||
73
231
  typeof devkit_internals_1.forceRegisterEsmLoader !== 'function') {
74
- throw esmErr;
232
+ throw retryErr;
75
233
  }
76
- // Module.register is global and one-shot per process. After this
77
- // runs, every subsequent ESM import in the process is routed
78
- // through the registered loader, forfeiting Node's native TS
79
- // stripping for the dynamic-import path. If neither swc-node nor
80
- // ts-node is installed, forceRegisterEsmLoader throws - surface the
81
- // original ESM error in that case so the user sees the real
82
- // problem, not a misleading "loader missing" message.
234
+ // Loader registration cannot be undone. Preserve the import error
235
+ // if registration itself fails.
83
236
  try {
84
237
  (0, devkit_internals_1.forceRegisterEsmLoader)();
85
238
  }
86
239
  catch {
87
- throw esmErr;
240
+ throw retryErr;
88
241
  }
89
- return await loadESM(path);
242
+ return unwrapCjsInterop(path, await loadESM(path));
90
243
  }
91
244
  finally {
92
245
  cleanup();
93
246
  }
94
247
  }
95
248
  }
249
+ // Some loaders emit CJS for a dynamic import, wrapping module.exports in
250
+ // namespace.default (the __esModule marker is optional), so cache identity is
251
+ // the discriminator: a require(esm) entry holds the namespace itself, and the
252
+ // entry check stops a default-less namespace from matching undefined.
253
+ function unwrapCjsInterop(path, module, cache = require.cache) {
254
+ const entry = cache[resolveModulePath(path)];
255
+ const cjsExports = module
256
+ ?.default;
257
+ return entry && entry.exports === cjsExports ? cjsExports : module;
258
+ }
96
259
  function getTypeScriptConfigPath(path, tsconfigFileNames) {
97
260
  const siblingFiles = (0, fs_1.readdirSync)((0, path_1.dirname)(path));
98
261
  const tsConfigFileName = (tsconfigFileNames ?? ['tsconfig.json']).find((name) => siblingFiles.includes(name));
@@ -165,7 +328,14 @@ async function loadCommonJS(path) {
165
328
  }
166
329
  return require(path);
167
330
  }
331
+ // Global monotonic counter (not Date.now()) so two reloads never share a
332
+ // cache-busting URL, across same-millisecond loads, module reloads, and
333
+ // devkit copies.
334
+ const esmLoadState = (globalThis[Symbol.for('@nx/devkit:esmLoadState')] ??= { count: 0 });
168
335
  async function loadESM(path) {
169
- const pathAsFileUrl = (0, node_url_1.pathToFileURL)(path).pathname;
170
- return await (0, exports.dynamicImport)(`${pathAsFileUrl}?t=${Date.now()}`);
336
+ // Keep the full file URL (.pathname would drop a UNC authority); the
337
+ // unique query gives each reload a fresh ESM registry key.
338
+ const fileUrl = (0, node_url_1.pathToFileURL)(path);
339
+ fileUrl.searchParams.set('t', (esmLoadState.count++).toString());
340
+ return await (0, exports.dynamicImport)(fileUrl.href);
171
341
  }
@@ -1,15 +1,21 @@
1
- import type { Tree } from 'nx/src/devkit-exports';
1
+ import { type Tree } from 'nx/src/devkit-exports';
2
2
  /**
3
3
  * Returns the concrete version of a package as resolved by Node module
4
4
  * resolution from the workspace. Reads the installed package's own
5
5
  * `package.json` — not the workspace's declared range.
6
6
  *
7
7
  * Use this from executor / runtime contexts where node_modules is present.
8
- * Generator-time code should use `getDeclaredPackageVersion` instead.
8
+ * Generator-time code should read from the tree first (the declared range or
9
+ * `getInstalledPackageVersionFromTree`) and may fall back to this with
10
+ * `requirePaths` restricted to the workspace root.
11
+ *
12
+ * Pass `requirePaths` to resolve from specific directories only (e.g. the
13
+ * workspace root, excluding the `.nx/installation` fallback); otherwise the
14
+ * default nx require paths are used.
9
15
  *
10
16
  * Returns `null` when the package is not resolvable.
11
17
  */
12
- export declare function getInstalledPackageVersion(packageName: string): string | null;
18
+ export declare function getInstalledPackageVersion(packageName: string, requirePaths?: string[]): string | null;
13
19
  /**
14
20
  * Returns the declared version of a package as read from the workspace's
15
21
  * `package.json`, normalized to a plain semver string (range markers
@@ -23,6 +29,13 @@ export declare function getInstalledPackageVersion(packageName: string): string
23
29
  * `getInstalledPackageVersion` instead.
24
30
  */
25
31
  export declare function getDeclaredPackageVersion(tree: Tree, packageName: string, latestKnownVersion?: string): string | null;
32
+ /**
33
+ * Reads the installed version of a package from the tree's `node_modules`,
34
+ * so it reflects in-flight tree changes and stays controllable in tests.
35
+ * Returns `null` when the package is not present in the tree's
36
+ * `node_modules`.
37
+ */
38
+ export declare function getInstalledPackageVersionFromTree(tree: Tree, packageName: string): string | null;
26
39
  export declare const NON_SEMVER_DIST_TAGS: readonly ['latest', 'next'];
27
40
  export type NonSemverDistTag = (typeof NON_SEMVER_DIST_TAGS)[number];
28
41
  export declare function isNonSemverDistTag(version: string): version is NonSemverDistTag;
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NON_SEMVER_DIST_TAGS = void 0;
4
4
  exports.getInstalledPackageVersion = getInstalledPackageVersion;
5
5
  exports.getDeclaredPackageVersion = getDeclaredPackageVersion;
6
+ exports.getInstalledPackageVersionFromTree = getInstalledPackageVersionFromTree;
6
7
  exports.isNonSemverDistTag = isNonSemverDistTag;
7
8
  exports.normalizeSemver = normalizeSemver;
8
9
  const devkit_internals_1 = require("nx/src/devkit-internals");
10
+ const devkit_exports_1 = require("nx/src/devkit-exports");
9
11
  const semver_1 = require("semver");
10
12
  const package_json_1 = require("./package-json");
11
13
  /**
@@ -14,14 +16,22 @@ const package_json_1 = require("./package-json");
14
16
  * `package.json` — not the workspace's declared range.
15
17
  *
16
18
  * Use this from executor / runtime contexts where node_modules is present.
17
- * Generator-time code should use `getDeclaredPackageVersion` instead.
19
+ * Generator-time code should read from the tree first (the declared range or
20
+ * `getInstalledPackageVersionFromTree`) and may fall back to this with
21
+ * `requirePaths` restricted to the workspace root.
22
+ *
23
+ * Pass `requirePaths` to resolve from specific directories only (e.g. the
24
+ * workspace root, excluding the `.nx/installation` fallback); otherwise the
25
+ * default nx require paths are used.
18
26
  *
19
27
  * Returns `null` when the package is not resolvable.
20
28
  */
21
- function getInstalledPackageVersion(packageName) {
29
+ function getInstalledPackageVersion(packageName, requirePaths) {
22
30
  try {
23
- const { packageJson } = (0, devkit_internals_1.readModulePackageJson)(packageName);
24
- return packageJson.version ?? null;
31
+ const { packageJson } = requirePaths
32
+ ? (0, devkit_internals_1.readModulePackageJson)(packageName, requirePaths)
33
+ : (0, devkit_internals_1.readModulePackageJson)(packageName);
34
+ return typeof packageJson.version === 'string' ? packageJson.version : null;
25
35
  }
26
36
  catch {
27
37
  return null;
@@ -48,6 +58,21 @@ function getDeclaredPackageVersion(tree, packageName, latestKnownVersion) {
48
58
  }
49
59
  return latestKnownVersion ? normalizeSemver(latestKnownVersion) : null;
50
60
  }
61
+ /**
62
+ * Reads the installed version of a package from the tree's `node_modules`,
63
+ * so it reflects in-flight tree changes and stays controllable in tests.
64
+ * Returns `null` when the package is not present in the tree's
65
+ * `node_modules`.
66
+ */
67
+ function getInstalledPackageVersionFromTree(tree, packageName) {
68
+ try {
69
+ const { version } = (0, devkit_exports_1.readJson)(tree, `node_modules/${packageName}/package.json`);
70
+ return typeof version === 'string' ? version : null;
71
+ }
72
+ catch {
73
+ return null;
74
+ }
75
+ }
51
76
  exports.NON_SEMVER_DIST_TAGS = ['latest', 'next'];
52
77
  function isNonSemverDistTag(version) {
53
78
  return exports.NON_SEMVER_DIST_TAGS.includes(version);
@@ -141,9 +141,13 @@ class DevkitTreeFromAngularDevkitTree {
141
141
  return (0, path_1.relative)(this.root, (0, path_1.join)(this.root, path));
142
142
  }
143
143
  read(filePath, encoding) {
144
- return encoding
145
- ? this.tree.read(filePath).toString(encoding)
146
- : this.tree.read(filePath);
144
+ // The schematics tree already returns null for a missing file, so honouring
145
+ // the `Tree` contract is a matter of not dereferencing it.
146
+ const content = this.tree.read(filePath);
147
+ if (content === null) {
148
+ return null;
149
+ }
150
+ return encoding ? content.toString(encoding) : content;
147
151
  }
148
152
  rename(from, to) {
149
153
  this.tree.rename(from, to);
@@ -0,0 +1,23 @@
1
+ import type { TreeIgnoreChecker } from 'nx/src/devkit-internals';
2
+ /**
3
+ * `@nx/devkit`'s `nx` peer spans a major either side, so an older nx that
4
+ * predates the ignore checkers can legally be installed alongside it, and a
5
+ * missing CommonJS named export arrives as `undefined` rather than as a load
6
+ * error. The two callers want opposite things from that, so they get different
7
+ * helpers - see `NOTHING_IGNORED` for the other half.
8
+ *
9
+ * A tree walk cannot degrade: without a checker nothing would be ignored, and
10
+ * the walker would descend into `node_modules` and hand a migration every file
11
+ * in it to rewrite. That is worse than the older nx's own behaviour, which at
12
+ * least read the root `.gitignore`, so this fails instead - once, by name.
13
+ */
14
+ export declare function assertNxSupportsIgnoreCheckers(): void;
15
+ /**
16
+ * The degrade the other way, for formatting.
17
+ *
18
+ * Filtering nothing is what devkit did before the checkers existed - with no
19
+ * `ignorePath`, prettier's own `getFileInfo` never read the workspace's ignore
20
+ * files either (measured) - so an older nx gets the formatting behaviour it has
21
+ * always had rather than a generator that refuses to run.
22
+ */
23
+ export declare const NOTHING_IGNORED: TreeIgnoreChecker;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NOTHING_IGNORED = void 0;
4
+ exports.assertNxSupportsIgnoreCheckers = assertNxSupportsIgnoreCheckers;
5
+ const devkit_internals_1 = require("nx/src/devkit-internals");
6
+ /**
7
+ * `@nx/devkit`'s `nx` peer spans a major either side, so an older nx that
8
+ * predates the ignore checkers can legally be installed alongside it, and a
9
+ * missing CommonJS named export arrives as `undefined` rather than as a load
10
+ * error. The two callers want opposite things from that, so they get different
11
+ * helpers - see `NOTHING_IGNORED` for the other half.
12
+ *
13
+ * A tree walk cannot degrade: without a checker nothing would be ignored, and
14
+ * the walker would descend into `node_modules` and hand a migration every file
15
+ * in it to rewrite. That is worse than the older nx's own behaviour, which at
16
+ * least read the root `.gitignore`, so this fails instead - once, by name.
17
+ */
18
+ function assertNxSupportsIgnoreCheckers() {
19
+ if (devkit_internals_1.createGitIgnoreChecker) {
20
+ return;
21
+ }
22
+ throw new Error('The installed version of nx does not export the ignore checkers that @nx/devkit needs to decide which files a generator may touch. ' +
23
+ 'This happens when nx and @nx/devkit are on different major versions. Run `nx migrate latest` to bring them into line.');
24
+ }
25
+ /**
26
+ * The degrade the other way, for formatting.
27
+ *
28
+ * Filtering nothing is what devkit did before the checkers existed - with no
29
+ * `ignorePath`, prettier's own `getFileInfo` never read the workspace's ignore
30
+ * files either (measured) - so an older nx gets the formatting behaviour it has
31
+ * always had rather than a generator that refuses to run.
32
+ */
33
+ exports.NOTHING_IGNORED = {
34
+ isIgnoredFile: () => false,
35
+ isIgnoredDirectory: () => false,
36
+ };
@@ -1,4 +1,4 @@
1
- import type { Tree } from 'nx/src/devkit-exports';
1
+ import { type Tree } from 'nx/src/devkit-exports';
2
2
  /**
3
3
  * Throws a standardized error when a package is installed at a version below
4
4
  * a plugin's supported floor.
@@ -15,9 +15,21 @@ export declare function throwForUnsupportedVersion(packageName: string, installe
15
15
  /**
16
16
  * Asserts that a package detected in the workspace is at or above the
17
17
  * plugin's supported floor. No-op when the package is not detected
18
- * (fresh-install path) or when declared as `latest`/`next`. Throws via
19
- * `throwForUnsupportedVersion` (with the original declared range for
20
- * clarity) when below floor.
18
+ * (fresh-install path) or when declared as `latest`/`next`.
19
+ *
20
+ * Resolution order:
21
+ * - When the installed version satisfies the declared range, the installed
22
+ * version decides. This resolves open ranges (e.g. `>=4.8.4 <6.1.0`) to
23
+ * what is actually installed.
24
+ * - An exact declared version is compared to the floor directly.
25
+ * - A declared range that cannot reach the floor throws as unsupported. A
26
+ * range that straddles the floor cannot be judged without an installed
27
+ * version (the lockfile may pin either side), so when none resolves it
28
+ * throws asking to install dependencies first.
29
+ *
30
+ * Prereleases count as their release version throughout (e.g. `6.0.0-rc.1`
31
+ * as `6.0.0`), for installed versions, exact declared versions, and range
32
+ * endpoints alike.
21
33
  *
22
34
  * Use from generator entry points to fail fast on unsupported workspaces
23
35
  * before writing any incompatible config.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.throwForUnsupportedVersion = throwForUnsupportedVersion;
4
4
  exports.assertSupportedPackageVersion = assertSupportedPackageVersion;
5
5
  exports.assertSupportedInstalledPackageVersion = assertSupportedInstalledPackageVersion;
6
+ const devkit_exports_1 = require("nx/src/devkit-exports");
6
7
  const semver_1 = require("semver");
7
8
  const installed_version_1 = require("./installed-version");
8
9
  const package_json_1 = require("./package-json");
@@ -27,9 +28,21 @@ function throwForUnsupportedVersion(packageName, installedVersion, floor) {
27
28
  /**
28
29
  * Asserts that a package detected in the workspace is at or above the
29
30
  * plugin's supported floor. No-op when the package is not detected
30
- * (fresh-install path) or when declared as `latest`/`next`. Throws via
31
- * `throwForUnsupportedVersion` (with the original declared range for
32
- * clarity) when below floor.
31
+ * (fresh-install path) or when declared as `latest`/`next`.
32
+ *
33
+ * Resolution order:
34
+ * - When the installed version satisfies the declared range, the installed
35
+ * version decides. This resolves open ranges (e.g. `>=4.8.4 <6.1.0`) to
36
+ * what is actually installed.
37
+ * - An exact declared version is compared to the floor directly.
38
+ * - A declared range that cannot reach the floor throws as unsupported. A
39
+ * range that straddles the floor cannot be judged without an installed
40
+ * version (the lockfile may pin either side), so when none resolves it
41
+ * throws asking to install dependencies first.
42
+ *
43
+ * Prereleases count as their release version throughout (e.g. `6.0.0-rc.1`
44
+ * as `6.0.0`), for installed versions, exact declared versions, and range
45
+ * endpoints alike.
33
46
  *
34
47
  * Use from generator entry points to fail fast on unsupported workspaces
35
48
  * before writing any incompatible config.
@@ -39,11 +52,64 @@ function assertSupportedPackageVersion(tree, packageName, minSupportedVersion) {
39
52
  if (!declared || (0, installed_version_1.isNonSemverDistTag)(declared)) {
40
53
  return;
41
54
  }
42
- const cleaned = (0, installed_version_1.normalizeSemver)(declared);
43
- if (cleaned && (0, semver_1.lt)(cleaned, minSupportedVersion)) {
55
+ const installed = (0, installed_version_1.getInstalledPackageVersionFromTree)(tree, packageName) ??
56
+ getInstalledPackageVersionFromProcess(tree, packageName);
57
+ if (installed) {
58
+ // An installed prerelease can match the declared range in either form:
59
+ // raw (a same-tuple prerelease comparator) or as its release version.
60
+ const release = (0, semver_1.coerce)(installed)?.version ?? installed;
61
+ if ((0, semver_1.satisfies)(installed, declared) || (0, semver_1.satisfies)(release, declared)) {
62
+ if ((0, semver_1.lt)(release, minSupportedVersion)) {
63
+ throwForUnsupportedVersion(packageName, installed, minSupportedVersion);
64
+ }
65
+ return;
66
+ }
67
+ }
68
+ const cleaned = (0, semver_1.clean)(declared);
69
+ if (cleaned) {
70
+ // Strip any prerelease so it counts as its release version.
71
+ const release = (0, semver_1.coerce)(cleaned)?.version ?? cleaned;
72
+ if ((0, semver_1.lt)(release, minSupportedVersion)) {
73
+ throwForUnsupportedVersion(packageName, declared, minSupportedVersion);
74
+ }
75
+ return;
76
+ }
77
+ if ((0, semver_1.validRange)(declared)) {
78
+ // The `-0` floor comparator admits prereleases of the floor version, so
79
+ // a range reaching the floor only through its prereleases still counts.
80
+ if (!(0, semver_1.intersects)(declared, `>=${minSupportedVersion}-0`)) {
81
+ throwForUnsupportedVersion(packageName, declared, minSupportedVersion);
82
+ }
83
+ const min = (0, semver_1.minVersion)(declared);
84
+ const rangeMinimum = min ? `${min.major}.${min.minor}.${min.patch}` : null;
85
+ if (rangeMinimum && (0, semver_1.lt)(rangeMinimum, minSupportedVersion)) {
86
+ throw new Error(`Unable to determine the installed version of \`${packageName}\`.\n\n` +
87
+ ` Declared: ${declared}\n` +
88
+ ` Supported: >= ${minSupportedVersion}\n\n` +
89
+ `The declared range allows versions below the supported minimum. ` +
90
+ `Install the workspace dependencies so the installed version can be verified, then try again.`);
91
+ }
92
+ return;
93
+ }
94
+ const coerced = (0, semver_1.coerce)(declared)?.version;
95
+ if (coerced && (0, semver_1.lt)(coerced, minSupportedVersion)) {
44
96
  throwForUnsupportedVersion(packageName, declared, minSupportedVersion);
45
97
  }
46
98
  }
99
+ /**
100
+ * Module-resolution fallback for installs without a `node_modules` layout
101
+ * (e.g. Yarn PnP). Only valid when the tree is the running process's
102
+ * workspace; unit trees (e.g. rooted at `/virtual`) must not resolve
103
+ * packages from the process environment. Resolves from the workspace root
104
+ * only, so a copy hoisted into `.nx/installation` cannot shadow the
105
+ * workspace's own install.
106
+ */
107
+ function getInstalledPackageVersionFromProcess(tree, packageName) {
108
+ if (tree.root !== devkit_exports_1.workspaceRoot) {
109
+ return null;
110
+ }
111
+ return (0, installed_version_1.getInstalledPackageVersion)(packageName, [tree.root]);
112
+ }
47
113
  /**
48
114
  * Asserts that a package installed in the workspace is at or above the
49
115
  * plugin's supported floor. No-op when the package is not resolvable from
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/devkit",
3
- "version": "23.1.1",
3
+ "version": "23.1.3",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -40,6 +40,15 @@
40
40
  ],
41
41
  "internal-testing-utils": [
42
42
  "dist/internal-testing-utils.d.ts"
43
+ ],
44
+ "internal-testing-utils/mock-project-graph": [
45
+ "dist/internal-testing-utils/mock-project-graph.d.ts"
46
+ ],
47
+ "internal-testing-utils/mock-fs": [
48
+ "dist/internal-testing-utils/mock-fs.d.ts"
49
+ ],
50
+ "internal-testing-utils/mock-prettier": [
51
+ "dist/internal-testing-utils/mock-prettier.d.ts"
43
52
  ]
44
53
  }
45
54
  },
@@ -59,7 +68,7 @@
59
68
  },
60
69
  "devDependencies": {
61
70
  "jest": "30.3.0",
62
- "nx": "23.1.1"
71
+ "nx": "23.1.3"
63
72
  },
64
73
  "peerDependencies": {
65
74
  "nx": ">= 22 <= 24 || ^23.0.0-0"
@@ -89,6 +98,21 @@
89
98
  "types": "./dist/internal-testing-utils.d.ts",
90
99
  "default": "./dist/internal-testing-utils.js"
91
100
  },
101
+ "./internal-testing-utils/mock-project-graph": {
102
+ "@nx/nx-source": "./internal-testing-utils/mock-project-graph.ts",
103
+ "types": "./dist/internal-testing-utils/mock-project-graph.d.ts",
104
+ "default": "./dist/internal-testing-utils/mock-project-graph.js"
105
+ },
106
+ "./internal-testing-utils/mock-fs": {
107
+ "@nx/nx-source": "./internal-testing-utils/mock-fs.ts",
108
+ "types": "./dist/internal-testing-utils/mock-fs.d.ts",
109
+ "default": "./dist/internal-testing-utils/mock-fs.js"
110
+ },
111
+ "./internal-testing-utils/mock-prettier": {
112
+ "@nx/nx-source": "./internal-testing-utils/mock-prettier.ts",
113
+ "types": "./dist/internal-testing-utils/mock-prettier.d.ts",
114
+ "default": "./dist/internal-testing-utils/mock-prettier.js"
115
+ },
92
116
  "./ngcli-adapter": {
93
117
  "@nx/nx-source": "./ngcli-adapter.ts",
94
118
  "types": "./dist/ngcli-adapter.d.ts",