@nx/devkit 23.2.0-beta.0 → 23.2.0-beta.10

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,6 @@
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
+ export { detectFormatterInTree, prettierConfigFiles, oxfmtConfigFiles, } from 'nx/src/devkit-internals';
3
+ export type { FormatterType } from 'nx/src/devkit-internals';
2
4
  export { determineArtifactNameAndDirectoryOptions, getRelativeCwd, type FileExtensionType, } from './src/generators/artifact-name-and-directory-utils';
3
5
  export { getE2EWebServerInfo, type E2EWebServerDetails, } from './src/generators/e2e-web-server-info-utils';
4
6
  export { forEachExecutorOptions } from './src/generators/executor-options-utils';
@@ -6,14 +8,13 @@ export { AggregatedLog } from './src/generators/plugin-migrations/aggregate-log-
6
8
  export { migrateProjectExecutorsToPlugin, migrateProjectExecutorsToPluginV1, NoTargetsToMigrateError, type InferredTargetConfiguration, } from './src/generators/plugin-migrations/executor-to-plugin-migrator';
7
9
  export { processTargetOutputs, deleteMatchingProperties, toProjectRelativePath, } from './src/generators/plugin-migrations/plugin-migration-utils';
8
10
  export { determineProjectNameAndRootOptions, ensureRootProjectName, resolveImportPath, } from './src/generators/project-name-and-root-utils';
9
- export { promptWhenInteractive } from './src/generators/prompt';
11
+ export { isInteractive } from './src/generators/prompt';
10
12
  export { addBuildTargetDefaults, addE2eCiTargetDefaults, findTargetDefault, readTargetDefaultsForTarget, updateTargetDefault, upsertTargetDefault, } from './src/generators/target-defaults-utils';
11
13
  export { addPlugin } from './src/utils/add-plugin';
12
14
  export { getDeclaredPackageVersion, getInstalledPackageVersion, } from './src/utils/installed-version';
13
15
  export { assertSupportedInstalledPackageVersion, assertSupportedPackageVersion, } from './src/utils/version-floor';
14
16
  export { createAsyncIterable, combineAsyncIterables, mapAsyncIterable, } from './src/utils/async-iterable';
15
17
  export { calculateHashForCreateNodes, calculateHashesForCreateNodes, } from './src/utils/calculate-hash-for-create-nodes';
16
- export { getCatalogManager } from 'nx/src/utils/catalog';
17
18
  export { loadConfigFile, clearRequireCache } from './src/utils/config-utils';
18
19
  export { findPluginForConfigFile } from './src/utils/find-plugin-for-config-file';
19
20
  export { getNamedInputs } from './src/utils/get-named-inputs';
@@ -21,3 +22,5 @@ export { logShowProjectCommand } from './src/utils/log-show-project-command';
21
22
  export { eachValueFrom } from './src/utils/rxjs-for-await';
22
23
  export { checkAndCleanWithSemver } from './src/utils/semver';
23
24
  export { camelize, capitalize, classify, dasherize, } from './src/utils/string-utils';
25
+ 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, confirmationPrompt, 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, buildPackageJsonPatterns, buildPackageJsonWorkspacesMatcher, buildProjectGraphAndSourceMapsWithoutDaemon, calculateFileChanges, calculateReverseDeps, codeFrameColumns, combineGlobPatterns, connectToNxCloud, createDirectory, createLockFile, createNxCloudOnboardingURL, createNxCloudOnboardingURLForWelcomeApp, createPackageJson, createProjectGraphAndSourceMapsAsync, createProjectRootMappings, createRunManyDynamicOutputRenderer, createTargetDefaultsResults, createTaskId, daemonClient, deduceDefaultBase, defaultFileRead, deriveGroupNameFromTarget, directoryExists, dropEmptyPeerDependencySections, expandDependencyConfigSyntaxSugar, expandInitiatingTasksThroughNoop, expandWildcardTargetConfiguration, fileDataDepTarget, fileDataDepType, fileExists, filterUsingGlobPatterns, findAllProjectNodeDependencies, findInstalledPlugins, findMatchingConfigFiles, findMatchingProjects, findMatchingTargetNames, findProjectForPath, findProjectsNpmDependencies, forceRegisterEsmLoader, generatePrunedDeployOutput, 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, handleImport, handleProjectGraphError, hashFile, hashObject, hashWithWorkspaceContext, interpolate, isBuiltinModuleImport, isCI, isCacheableTask, isDeletedFileChange, isLockFileChange, isNpmProject, isNxCloudUsed, isProjectGraphExternalNode, isProjectGraphProjectNode, isRelativePath, isWholeFileChange, killProcessTreeGraceful, loadTsFile, mergeTargetConfigurations, movePeerDependencyToDependencies, multiselectPrompt, normalizeDependencyConfigDefinition, normalizeDependencyConfigProjects, normalizeTargetDependencyWithStringProjects, nxVersion, orange, parseExecutor, parseVersionFromPackageManagerField, preventRecursionInGraphConstruction, readCachedProjectConfiguration, readFileIfExisting, readFileMapCache, readModulePackageJson, readNxJsonFromDisk, readNxMigrateConfig, readPackageJson, readProjectAndTargetFromTargetString, registerTsConfigPaths, registerTsProject, relocatePrunedLocalPathSpec, removeTasksFromTaskGraph, requireWithTsconfigFallback, resetWorkspaceContext, resolveCommandSyntacticSugar, runNxSync, safeExecFileSync, safeSpawn, selectPrompt, setWorkspaceRoot, setupAiAgentsGenerator, setupWorkspaceContext, shouldStreamOutput, toNewFormat, toOldFormat, transformLegacyOutputs, textPrompt, unparse, validateOutputs, warnUnshippableLocalPathSpec, workspaceDataDirectory, workspaceRootInner, } from 'nx/src/devkit-internals';
26
+ 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.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.isInteractive = 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.oxfmtConfigFiles = exports.prettierConfigFiles = exports.detectFormatterInTree = 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.expandWildcardTargetConfiguration = exports.expandInitiatingTasksThroughNoop = exports.expandDependencyConfigSyntaxSugar = exports.dropEmptyPeerDependencySections = exports.directoryExists = exports.deriveGroupNameFromTarget = exports.defaultFileRead = exports.deduceDefaultBase = exports.daemonClient = exports.createTaskId = exports.createTargetDefaultsResults = 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.buildPackageJsonWorkspacesMatcher = exports.buildPackageJsonPatterns = exports.WholeFileChange = exports.TargetProjectLocator = exports.TEN_MEGABYTES = exports.SyncError = exports.RemoteCacheV2 = exports.NX_PREFIX = exports.LockFileChange = exports.LARGE_BUFFER = exports.FsTree = exports.confirmationPrompt = exports.DeletedFileChange = exports.CompositeLifeCycle = exports.Cache = exports.BatchFunctionRunner = exports.runCommandsExecutor = exports.dasherize = exports.classify = exports.capitalize = exports.camelize = exports.checkAndCleanWithSemver = exports.eachValueFrom = exports.logShowProjectCommand = exports.getNamedInputs = void 0;
5
+ exports.isNpmProject = exports.isLockFileChange = exports.isDeletedFileChange = exports.isCacheableTask = exports.isCI = exports.isBuiltinModuleImport = exports.interpolate = exports.hashWithWorkspaceContext = exports.hashObject = exports.hashFile = exports.handleProjectGraphError = exports.handleImport = 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.generatePrunedDeployOutput = exports.forceRegisterEsmLoader = exports.findProjectsNpmDependencies = exports.findProjectForPath = exports.findMatchingTargetNames = exports.findMatchingProjects = exports.findMatchingConfigFiles = exports.findInstalledPlugins = exports.findAllProjectNodeDependencies = exports.filterUsingGlobPatterns = exports.fileExists = exports.fileDataDepType = exports.fileDataDepTarget = void 0;
6
+ exports.workspaceRootInner = exports.workspaceDataDirectory = exports.warnUnshippableLocalPathSpec = exports.validateOutputs = exports.unparse = exports.textPrompt = exports.transformLegacyOutputs = exports.toOldFormat = exports.toNewFormat = exports.shouldStreamOutput = exports.setupWorkspaceContext = exports.setupAiAgentsGenerator = exports.setWorkspaceRoot = exports.selectPrompt = exports.safeSpawn = exports.safeExecFileSync = exports.runNxSync = exports.resolveCommandSyntacticSugar = exports.resetWorkspaceContext = exports.requireWithTsconfigFallback = exports.removeTasksFromTaskGraph = exports.relocatePrunedLocalPathSpec = exports.registerTsProject = exports.registerTsConfigPaths = exports.readProjectAndTargetFromTargetString = exports.readPackageJson = exports.readNxMigrateConfig = exports.readNxJsonFromDisk = exports.readModulePackageJson = exports.readFileMapCache = exports.readFileIfExisting = exports.readCachedProjectConfiguration = exports.preventRecursionInGraphConstruction = exports.parseVersionFromPackageManagerField = exports.parseExecutor = exports.orange = exports.nxVersion = exports.normalizeTargetDependencyWithStringProjects = exports.normalizeDependencyConfigProjects = exports.normalizeDependencyConfigDefinition = exports.multiselectPrompt = exports.movePeerDependencyToDependencies = exports.mergeTargetConfigurations = exports.loadTsFile = exports.killProcessTreeGraceful = exports.isWholeFileChange = exports.isRelativePath = exports.isProjectGraphProjectNode = exports.isProjectGraphExternalNode = exports.isNxCloudUsed = 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,22 @@ 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; } });
26
+ // Formatter detection and setup. `@nx/js` needs these to write and detect a
27
+ // workspace's formatter config, and it depends on `@nx/devkit` rather than on
28
+ // `nx`, so this is its declared route to them. Against an older nx they arrive
29
+ // as `undefined` rather than as a load error; `@nx/js` turns that into one
30
+ // descriptive error up front (`assertNxSupportsFormatters`) instead of carrying
31
+ // a fallback per call site.
32
+ var devkit_internals_2 = require("nx/src/devkit-internals");
33
+ Object.defineProperty(exports, "detectFormatterInTree", { enumerable: true, get: function () { return devkit_internals_2.detectFormatterInTree; } });
34
+ Object.defineProperty(exports, "prettierConfigFiles", { enumerable: true, get: function () { return devkit_internals_2.prettierConfigFiles; } });
35
+ Object.defineProperty(exports, "oxfmtConfigFiles", { enumerable: true, get: function () { return devkit_internals_2.oxfmtConfigFiles; } });
18
36
  // Generators
19
37
  var artifact_name_and_directory_utils_1 = require("./src/generators/artifact-name-and-directory-utils");
20
38
  Object.defineProperty(exports, "determineArtifactNameAndDirectoryOptions", { enumerable: true, get: function () { return artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions; } });
@@ -38,7 +56,7 @@ Object.defineProperty(exports, "determineProjectNameAndRootOptions", { enumerabl
38
56
  Object.defineProperty(exports, "ensureRootProjectName", { enumerable: true, get: function () { return project_name_and_root_utils_1.ensureRootProjectName; } });
39
57
  Object.defineProperty(exports, "resolveImportPath", { enumerable: true, get: function () { return project_name_and_root_utils_1.resolveImportPath; } });
40
58
  var prompt_1 = require("./src/generators/prompt");
41
- Object.defineProperty(exports, "promptWhenInteractive", { enumerable: true, get: function () { return prompt_1.promptWhenInteractive; } });
59
+ Object.defineProperty(exports, "isInteractive", { enumerable: true, get: function () { return prompt_1.isInteractive; } });
42
60
  var target_defaults_utils_1 = require("./src/generators/target-defaults-utils");
43
61
  Object.defineProperty(exports, "addBuildTargetDefaults", { enumerable: true, get: function () { return target_defaults_utils_1.addBuildTargetDefaults; } });
44
62
  Object.defineProperty(exports, "addE2eCiTargetDefaults", { enumerable: true, get: function () { return target_defaults_utils_1.addE2eCiTargetDefaults; } });
@@ -62,9 +80,6 @@ Object.defineProperty(exports, "mapAsyncIterable", { enumerable: true, get: func
62
80
  var calculate_hash_for_create_nodes_1 = require("./src/utils/calculate-hash-for-create-nodes");
63
81
  Object.defineProperty(exports, "calculateHashForCreateNodes", { enumerable: true, get: function () { return calculate_hash_for_create_nodes_1.calculateHashForCreateNodes; } });
64
82
  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
83
  var config_utils_1 = require("./src/utils/config-utils");
69
84
  Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return config_utils_1.loadConfigFile; } });
70
85
  Object.defineProperty(exports, "clearRequireCache", { enumerable: true, get: function () { return config_utils_1.clearRequireCache; } });
@@ -83,3 +98,147 @@ Object.defineProperty(exports, "camelize", { enumerable: true, get: function ()
83
98
  Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return string_utils_1.capitalize; } });
84
99
  Object.defineProperty(exports, "classify", { enumerable: true, get: function () { return string_utils_1.classify; } });
85
100
  Object.defineProperty(exports, "dasherize", { enumerable: true, get: function () { return string_utils_1.dasherize; } });
101
+ // Re-exported for first-party plugins in this repo.
102
+ var devkit_internals_3 = require("nx/src/devkit-internals");
103
+ Object.defineProperty(exports, "runCommandsExecutor", { enumerable: true, get: function () { return devkit_internals_3.runCommandsExecutor; } });
104
+ Object.defineProperty(exports, "BatchFunctionRunner", { enumerable: true, get: function () { return devkit_internals_3.BatchFunctionRunner; } });
105
+ Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return devkit_internals_3.Cache; } });
106
+ Object.defineProperty(exports, "CompositeLifeCycle", { enumerable: true, get: function () { return devkit_internals_3.CompositeLifeCycle; } });
107
+ Object.defineProperty(exports, "DeletedFileChange", { enumerable: true, get: function () { return devkit_internals_3.DeletedFileChange; } });
108
+ Object.defineProperty(exports, "confirmationPrompt", { enumerable: true, get: function () { return devkit_internals_3.confirmationPrompt; } });
109
+ Object.defineProperty(exports, "FsTree", { enumerable: true, get: function () { return devkit_internals_3.FsTree; } });
110
+ Object.defineProperty(exports, "LARGE_BUFFER", { enumerable: true, get: function () { return devkit_internals_3.LARGE_BUFFER; } });
111
+ Object.defineProperty(exports, "LockFileChange", { enumerable: true, get: function () { return devkit_internals_3.LockFileChange; } });
112
+ Object.defineProperty(exports, "NX_PREFIX", { enumerable: true, get: function () { return devkit_internals_3.NX_PREFIX; } });
113
+ Object.defineProperty(exports, "RemoteCacheV2", { enumerable: true, get: function () { return devkit_internals_3.RemoteCacheV2; } });
114
+ Object.defineProperty(exports, "SyncError", { enumerable: true, get: function () { return devkit_internals_3.SyncError; } });
115
+ Object.defineProperty(exports, "TEN_MEGABYTES", { enumerable: true, get: function () { return devkit_internals_3.TEN_MEGABYTES; } });
116
+ Object.defineProperty(exports, "TargetProjectLocator", { enumerable: true, get: function () { return devkit_internals_3.TargetProjectLocator; } });
117
+ Object.defineProperty(exports, "WholeFileChange", { enumerable: true, get: function () { return devkit_internals_3.WholeFileChange; } });
118
+ Object.defineProperty(exports, "buildPackageJsonPatterns", { enumerable: true, get: function () { return devkit_internals_3.buildPackageJsonPatterns; } });
119
+ Object.defineProperty(exports, "buildPackageJsonWorkspacesMatcher", { enumerable: true, get: function () { return devkit_internals_3.buildPackageJsonWorkspacesMatcher; } });
120
+ Object.defineProperty(exports, "buildProjectGraphAndSourceMapsWithoutDaemon", { enumerable: true, get: function () { return devkit_internals_3.buildProjectGraphAndSourceMapsWithoutDaemon; } });
121
+ Object.defineProperty(exports, "calculateFileChanges", { enumerable: true, get: function () { return devkit_internals_3.calculateFileChanges; } });
122
+ Object.defineProperty(exports, "calculateReverseDeps", { enumerable: true, get: function () { return devkit_internals_3.calculateReverseDeps; } });
123
+ Object.defineProperty(exports, "codeFrameColumns", { enumerable: true, get: function () { return devkit_internals_3.codeFrameColumns; } });
124
+ Object.defineProperty(exports, "combineGlobPatterns", { enumerable: true, get: function () { return devkit_internals_3.combineGlobPatterns; } });
125
+ Object.defineProperty(exports, "connectToNxCloud", { enumerable: true, get: function () { return devkit_internals_3.connectToNxCloud; } });
126
+ Object.defineProperty(exports, "createDirectory", { enumerable: true, get: function () { return devkit_internals_3.createDirectory; } });
127
+ Object.defineProperty(exports, "createLockFile", { enumerable: true, get: function () { return devkit_internals_3.createLockFile; } });
128
+ Object.defineProperty(exports, "createNxCloudOnboardingURL", { enumerable: true, get: function () { return devkit_internals_3.createNxCloudOnboardingURL; } });
129
+ Object.defineProperty(exports, "createNxCloudOnboardingURLForWelcomeApp", { enumerable: true, get: function () { return devkit_internals_3.createNxCloudOnboardingURLForWelcomeApp; } });
130
+ Object.defineProperty(exports, "createPackageJson", { enumerable: true, get: function () { return devkit_internals_3.createPackageJson; } });
131
+ Object.defineProperty(exports, "createProjectGraphAndSourceMapsAsync", { enumerable: true, get: function () { return devkit_internals_3.createProjectGraphAndSourceMapsAsync; } });
132
+ Object.defineProperty(exports, "createProjectRootMappings", { enumerable: true, get: function () { return devkit_internals_3.createProjectRootMappings; } });
133
+ Object.defineProperty(exports, "createRunManyDynamicOutputRenderer", { enumerable: true, get: function () { return devkit_internals_3.createRunManyDynamicOutputRenderer; } });
134
+ Object.defineProperty(exports, "createTargetDefaultsResults", { enumerable: true, get: function () { return devkit_internals_3.createTargetDefaultsResults; } });
135
+ Object.defineProperty(exports, "createTaskId", { enumerable: true, get: function () { return devkit_internals_3.createTaskId; } });
136
+ Object.defineProperty(exports, "daemonClient", { enumerable: true, get: function () { return devkit_internals_3.daemonClient; } });
137
+ Object.defineProperty(exports, "deduceDefaultBase", { enumerable: true, get: function () { return devkit_internals_3.deduceDefaultBase; } });
138
+ Object.defineProperty(exports, "defaultFileRead", { enumerable: true, get: function () { return devkit_internals_3.defaultFileRead; } });
139
+ Object.defineProperty(exports, "deriveGroupNameFromTarget", { enumerable: true, get: function () { return devkit_internals_3.deriveGroupNameFromTarget; } });
140
+ Object.defineProperty(exports, "directoryExists", { enumerable: true, get: function () { return devkit_internals_3.directoryExists; } });
141
+ Object.defineProperty(exports, "dropEmptyPeerDependencySections", { enumerable: true, get: function () { return devkit_internals_3.dropEmptyPeerDependencySections; } });
142
+ Object.defineProperty(exports, "expandDependencyConfigSyntaxSugar", { enumerable: true, get: function () { return devkit_internals_3.expandDependencyConfigSyntaxSugar; } });
143
+ Object.defineProperty(exports, "expandInitiatingTasksThroughNoop", { enumerable: true, get: function () { return devkit_internals_3.expandInitiatingTasksThroughNoop; } });
144
+ Object.defineProperty(exports, "expandWildcardTargetConfiguration", { enumerable: true, get: function () { return devkit_internals_3.expandWildcardTargetConfiguration; } });
145
+ Object.defineProperty(exports, "fileDataDepTarget", { enumerable: true, get: function () { return devkit_internals_3.fileDataDepTarget; } });
146
+ Object.defineProperty(exports, "fileDataDepType", { enumerable: true, get: function () { return devkit_internals_3.fileDataDepType; } });
147
+ Object.defineProperty(exports, "fileExists", { enumerable: true, get: function () { return devkit_internals_3.fileExists; } });
148
+ Object.defineProperty(exports, "filterUsingGlobPatterns", { enumerable: true, get: function () { return devkit_internals_3.filterUsingGlobPatterns; } });
149
+ Object.defineProperty(exports, "findAllProjectNodeDependencies", { enumerable: true, get: function () { return devkit_internals_3.findAllProjectNodeDependencies; } });
150
+ Object.defineProperty(exports, "findInstalledPlugins", { enumerable: true, get: function () { return devkit_internals_3.findInstalledPlugins; } });
151
+ Object.defineProperty(exports, "findMatchingConfigFiles", { enumerable: true, get: function () { return devkit_internals_3.findMatchingConfigFiles; } });
152
+ Object.defineProperty(exports, "findMatchingProjects", { enumerable: true, get: function () { return devkit_internals_3.findMatchingProjects; } });
153
+ Object.defineProperty(exports, "findMatchingTargetNames", { enumerable: true, get: function () { return devkit_internals_3.findMatchingTargetNames; } });
154
+ Object.defineProperty(exports, "findProjectForPath", { enumerable: true, get: function () { return devkit_internals_3.findProjectForPath; } });
155
+ Object.defineProperty(exports, "findProjectsNpmDependencies", { enumerable: true, get: function () { return devkit_internals_3.findProjectsNpmDependencies; } });
156
+ Object.defineProperty(exports, "forceRegisterEsmLoader", { enumerable: true, get: function () { return devkit_internals_3.forceRegisterEsmLoader; } });
157
+ Object.defineProperty(exports, "generatePrunedDeployOutput", { enumerable: true, get: function () { return devkit_internals_3.generatePrunedDeployOutput; } });
158
+ Object.defineProperty(exports, "getCliPath", { enumerable: true, get: function () { return devkit_internals_3.getCliPath; } });
159
+ Object.defineProperty(exports, "getCustomHasher", { enumerable: true, get: function () { return devkit_internals_3.getCustomHasher; } });
160
+ Object.defineProperty(exports, "getDependencyConfigs", { enumerable: true, get: function () { return devkit_internals_3.getDependencyConfigs; } });
161
+ Object.defineProperty(exports, "getExecutorForTask", { enumerable: true, get: function () { return devkit_internals_3.getExecutorForTask; } });
162
+ Object.defineProperty(exports, "getExecutorInformation", { enumerable: true, get: function () { return devkit_internals_3.getExecutorInformation; } });
163
+ Object.defineProperty(exports, "getExecutorNameForTask", { enumerable: true, get: function () { return devkit_internals_3.getExecutorNameForTask; } });
164
+ Object.defineProperty(exports, "getFilesInDirectoryUsingContext", { enumerable: true, get: function () { return devkit_internals_3.getFilesInDirectoryUsingContext; } });
165
+ Object.defineProperty(exports, "getGeneratorInformation", { enumerable: true, get: function () { return devkit_internals_3.getGeneratorInformation; } });
166
+ Object.defineProperty(exports, "getGlobPatternsFromPackageManagerWorkspaces", { enumerable: true, get: function () { return devkit_internals_3.getGlobPatternsFromPackageManagerWorkspaces; } });
167
+ Object.defineProperty(exports, "getLastValueFromAsyncIterableIterator", { enumerable: true, get: function () { return devkit_internals_3.getLastValueFromAsyncIterableIterator; } });
168
+ Object.defineProperty(exports, "getLatestCommitSha", { enumerable: true, get: function () { return devkit_internals_3.getLatestCommitSha; } });
169
+ Object.defineProperty(exports, "getLockFileName", { enumerable: true, get: function () { return devkit_internals_3.getLockFileName; } });
170
+ Object.defineProperty(exports, "getNxCloudAppOnBoardingUrl", { enumerable: true, get: function () { return devkit_internals_3.getNxCloudAppOnBoardingUrl; } });
171
+ Object.defineProperty(exports, "getNxCloudUrl", { enumerable: true, get: function () { return devkit_internals_3.getNxCloudUrl; } });
172
+ Object.defineProperty(exports, "getNxRequirePaths", { enumerable: true, get: function () { return devkit_internals_3.getNxRequirePaths; } });
173
+ Object.defineProperty(exports, "getOutputs", { enumerable: true, get: function () { return devkit_internals_3.getOutputs; } });
174
+ Object.defineProperty(exports, "getPrintableCommandArgsForTask", { enumerable: true, get: function () { return devkit_internals_3.getPrintableCommandArgsForTask; } });
175
+ Object.defineProperty(exports, "getRelativeProjectJsonSchemaPath", { enumerable: true, get: function () { return devkit_internals_3.getRelativeProjectJsonSchemaPath; } });
176
+ Object.defineProperty(exports, "getSerializedArgsForTask", { enumerable: true, get: function () { return devkit_internals_3.getSerializedArgsForTask; } });
177
+ Object.defineProperty(exports, "getSourceDirOfDependentProjects", { enumerable: true, get: function () { return devkit_internals_3.getSourceDirOfDependentProjects; } });
178
+ Object.defineProperty(exports, "getTargetConfigurationForTask", { enumerable: true, get: function () { return devkit_internals_3.getTargetConfigurationForTask; } });
179
+ Object.defineProperty(exports, "getTargetInputs", { enumerable: true, get: function () { return devkit_internals_3.getTargetInputs; } });
180
+ Object.defineProperty(exports, "getUnparsedOverrideArgs", { enumerable: true, get: function () { return devkit_internals_3.getUnparsedOverrideArgs; } });
181
+ Object.defineProperty(exports, "getWorkspacePackagesFromGraph", { enumerable: true, get: function () { return devkit_internals_3.getWorkspacePackagesFromGraph; } });
182
+ Object.defineProperty(exports, "globWithWorkspaceContext", { enumerable: true, get: function () { return devkit_internals_3.globWithWorkspaceContext; } });
183
+ Object.defineProperty(exports, "handleImport", { enumerable: true, get: function () { return devkit_internals_3.handleImport; } });
184
+ Object.defineProperty(exports, "handleProjectGraphError", { enumerable: true, get: function () { return devkit_internals_3.handleProjectGraphError; } });
185
+ Object.defineProperty(exports, "hashFile", { enumerable: true, get: function () { return devkit_internals_3.hashFile; } });
186
+ Object.defineProperty(exports, "hashObject", { enumerable: true, get: function () { return devkit_internals_3.hashObject; } });
187
+ Object.defineProperty(exports, "hashWithWorkspaceContext", { enumerable: true, get: function () { return devkit_internals_3.hashWithWorkspaceContext; } });
188
+ Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return devkit_internals_3.interpolate; } });
189
+ Object.defineProperty(exports, "isBuiltinModuleImport", { enumerable: true, get: function () { return devkit_internals_3.isBuiltinModuleImport; } });
190
+ Object.defineProperty(exports, "isCI", { enumerable: true, get: function () { return devkit_internals_3.isCI; } });
191
+ Object.defineProperty(exports, "isCacheableTask", { enumerable: true, get: function () { return devkit_internals_3.isCacheableTask; } });
192
+ Object.defineProperty(exports, "isDeletedFileChange", { enumerable: true, get: function () { return devkit_internals_3.isDeletedFileChange; } });
193
+ Object.defineProperty(exports, "isLockFileChange", { enumerable: true, get: function () { return devkit_internals_3.isLockFileChange; } });
194
+ Object.defineProperty(exports, "isNpmProject", { enumerable: true, get: function () { return devkit_internals_3.isNpmProject; } });
195
+ Object.defineProperty(exports, "isNxCloudUsed", { enumerable: true, get: function () { return devkit_internals_3.isNxCloudUsed; } });
196
+ Object.defineProperty(exports, "isProjectGraphExternalNode", { enumerable: true, get: function () { return devkit_internals_3.isProjectGraphExternalNode; } });
197
+ Object.defineProperty(exports, "isProjectGraphProjectNode", { enumerable: true, get: function () { return devkit_internals_3.isProjectGraphProjectNode; } });
198
+ Object.defineProperty(exports, "isRelativePath", { enumerable: true, get: function () { return devkit_internals_3.isRelativePath; } });
199
+ Object.defineProperty(exports, "isWholeFileChange", { enumerable: true, get: function () { return devkit_internals_3.isWholeFileChange; } });
200
+ Object.defineProperty(exports, "killProcessTreeGraceful", { enumerable: true, get: function () { return devkit_internals_3.killProcessTreeGraceful; } });
201
+ Object.defineProperty(exports, "loadTsFile", { enumerable: true, get: function () { return devkit_internals_3.loadTsFile; } });
202
+ Object.defineProperty(exports, "mergeTargetConfigurations", { enumerable: true, get: function () { return devkit_internals_3.mergeTargetConfigurations; } });
203
+ Object.defineProperty(exports, "movePeerDependencyToDependencies", { enumerable: true, get: function () { return devkit_internals_3.movePeerDependencyToDependencies; } });
204
+ Object.defineProperty(exports, "multiselectPrompt", { enumerable: true, get: function () { return devkit_internals_3.multiselectPrompt; } });
205
+ Object.defineProperty(exports, "normalizeDependencyConfigDefinition", { enumerable: true, get: function () { return devkit_internals_3.normalizeDependencyConfigDefinition; } });
206
+ Object.defineProperty(exports, "normalizeDependencyConfigProjects", { enumerable: true, get: function () { return devkit_internals_3.normalizeDependencyConfigProjects; } });
207
+ Object.defineProperty(exports, "normalizeTargetDependencyWithStringProjects", { enumerable: true, get: function () { return devkit_internals_3.normalizeTargetDependencyWithStringProjects; } });
208
+ Object.defineProperty(exports, "nxVersion", { enumerable: true, get: function () { return devkit_internals_3.nxVersion; } });
209
+ Object.defineProperty(exports, "orange", { enumerable: true, get: function () { return devkit_internals_3.orange; } });
210
+ Object.defineProperty(exports, "parseExecutor", { enumerable: true, get: function () { return devkit_internals_3.parseExecutor; } });
211
+ Object.defineProperty(exports, "parseVersionFromPackageManagerField", { enumerable: true, get: function () { return devkit_internals_3.parseVersionFromPackageManagerField; } });
212
+ Object.defineProperty(exports, "preventRecursionInGraphConstruction", { enumerable: true, get: function () { return devkit_internals_3.preventRecursionInGraphConstruction; } });
213
+ Object.defineProperty(exports, "readCachedProjectConfiguration", { enumerable: true, get: function () { return devkit_internals_3.readCachedProjectConfiguration; } });
214
+ Object.defineProperty(exports, "readFileIfExisting", { enumerable: true, get: function () { return devkit_internals_3.readFileIfExisting; } });
215
+ Object.defineProperty(exports, "readFileMapCache", { enumerable: true, get: function () { return devkit_internals_3.readFileMapCache; } });
216
+ Object.defineProperty(exports, "readModulePackageJson", { enumerable: true, get: function () { return devkit_internals_3.readModulePackageJson; } });
217
+ Object.defineProperty(exports, "readNxJsonFromDisk", { enumerable: true, get: function () { return devkit_internals_3.readNxJsonFromDisk; } });
218
+ Object.defineProperty(exports, "readNxMigrateConfig", { enumerable: true, get: function () { return devkit_internals_3.readNxMigrateConfig; } });
219
+ Object.defineProperty(exports, "readPackageJson", { enumerable: true, get: function () { return devkit_internals_3.readPackageJson; } });
220
+ Object.defineProperty(exports, "readProjectAndTargetFromTargetString", { enumerable: true, get: function () { return devkit_internals_3.readProjectAndTargetFromTargetString; } });
221
+ Object.defineProperty(exports, "registerTsConfigPaths", { enumerable: true, get: function () { return devkit_internals_3.registerTsConfigPaths; } });
222
+ Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return devkit_internals_3.registerTsProject; } });
223
+ Object.defineProperty(exports, "relocatePrunedLocalPathSpec", { enumerable: true, get: function () { return devkit_internals_3.relocatePrunedLocalPathSpec; } });
224
+ Object.defineProperty(exports, "removeTasksFromTaskGraph", { enumerable: true, get: function () { return devkit_internals_3.removeTasksFromTaskGraph; } });
225
+ Object.defineProperty(exports, "requireWithTsconfigFallback", { enumerable: true, get: function () { return devkit_internals_3.requireWithTsconfigFallback; } });
226
+ Object.defineProperty(exports, "resetWorkspaceContext", { enumerable: true, get: function () { return devkit_internals_3.resetWorkspaceContext; } });
227
+ Object.defineProperty(exports, "resolveCommandSyntacticSugar", { enumerable: true, get: function () { return devkit_internals_3.resolveCommandSyntacticSugar; } });
228
+ Object.defineProperty(exports, "runNxSync", { enumerable: true, get: function () { return devkit_internals_3.runNxSync; } });
229
+ Object.defineProperty(exports, "safeExecFileSync", { enumerable: true, get: function () { return devkit_internals_3.safeExecFileSync; } });
230
+ Object.defineProperty(exports, "safeSpawn", { enumerable: true, get: function () { return devkit_internals_3.safeSpawn; } });
231
+ Object.defineProperty(exports, "selectPrompt", { enumerable: true, get: function () { return devkit_internals_3.selectPrompt; } });
232
+ Object.defineProperty(exports, "setWorkspaceRoot", { enumerable: true, get: function () { return devkit_internals_3.setWorkspaceRoot; } });
233
+ Object.defineProperty(exports, "setupAiAgentsGenerator", { enumerable: true, get: function () { return devkit_internals_3.setupAiAgentsGenerator; } });
234
+ Object.defineProperty(exports, "setupWorkspaceContext", { enumerable: true, get: function () { return devkit_internals_3.setupWorkspaceContext; } });
235
+ Object.defineProperty(exports, "shouldStreamOutput", { enumerable: true, get: function () { return devkit_internals_3.shouldStreamOutput; } });
236
+ Object.defineProperty(exports, "toNewFormat", { enumerable: true, get: function () { return devkit_internals_3.toNewFormat; } });
237
+ Object.defineProperty(exports, "toOldFormat", { enumerable: true, get: function () { return devkit_internals_3.toOldFormat; } });
238
+ Object.defineProperty(exports, "transformLegacyOutputs", { enumerable: true, get: function () { return devkit_internals_3.transformLegacyOutputs; } });
239
+ Object.defineProperty(exports, "textPrompt", { enumerable: true, get: function () { return devkit_internals_3.textPrompt; } });
240
+ Object.defineProperty(exports, "unparse", { enumerable: true, get: function () { return devkit_internals_3.unparse; } });
241
+ Object.defineProperty(exports, "validateOutputs", { enumerable: true, get: function () { return devkit_internals_3.validateOutputs; } });
242
+ Object.defineProperty(exports, "warnUnshippableLocalPathSpec", { enumerable: true, get: function () { return devkit_internals_3.warnUnshippableLocalPathSpec; } });
243
+ Object.defineProperty(exports, "workspaceDataDirectory", { enumerable: true, get: function () { return devkit_internals_3.workspaceDataDirectory; } });
244
+ Object.defineProperty(exports, "workspaceRootInner", { enumerable: true, get: function () { return devkit_internals_3.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,17 +1,16 @@
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 with the configured formatter,
4
+ * skipping `node_modules`, `.git`, the nx and yarn caches, and whatever the
5
+ * workspace's ignore files cover. Which ignore files apply follows the
6
+ * formatter: prettier reads the workspace root only, oxfmt cascades.
4
7
  * @param tree - the file system tree
5
8
  * @param options - options for the formatFiles function
6
9
  *
7
10
  * @remarks
8
- * Set the environment variable `NX_SKIP_FORMAT` to `true` to skip Prettier
9
- * formatting. This is useful for repositories that use alternative formatters
10
- * like Biome, dprint, or have custom formatting requirements.
11
- *
12
- * Note: `NX_SKIP_FORMAT` only skips Prettier formatting. TSConfig path sorting
13
- * (controlled by `sortRootTsconfigPaths` option or `NX_FORMAT_SORT_TSCONFIG_PATHS`)
14
- * will still occur.
11
+ * `NX_SKIP_FORMAT=true` skips formatting - but not TSConfig path sorting,
12
+ * which is controlled by `sortRootTsconfigPaths` or
13
+ * `NX_FORMAT_SORT_TSCONFIG_PATHS`.
15
14
  */
16
15
  export declare function formatFiles(tree: Tree, options?: {
17
16
  sortRootTsconfigPaths?: boolean;
@@ -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,18 +19,17 @@ 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 with the configured formatter,
23
+ * skipping `node_modules`, `.git`, the nx and yarn caches, and whatever the
24
+ * workspace's ignore files cover. Which ignore files apply follows the
25
+ * formatter: prettier reads the workspace root only, oxfmt cascades.
22
26
  * @param tree - the file system tree
23
27
  * @param options - options for the formatFiles function
24
28
  *
25
29
  * @remarks
26
- * Set the environment variable `NX_SKIP_FORMAT` to `true` to skip Prettier
27
- * formatting. This is useful for repositories that use alternative formatters
28
- * like Biome, dprint, or have custom formatting requirements.
29
- *
30
- * Note: `NX_SKIP_FORMAT` only skips Prettier formatting. TSConfig path sorting
31
- * (controlled by `sortRootTsconfigPaths` option or `NX_FORMAT_SORT_TSCONFIG_PATHS`)
32
- * will still occur.
30
+ * `NX_SKIP_FORMAT=true` skips formatting - but not TSConfig path sorting,
31
+ * which is controlled by `sortRootTsconfigPaths` or
32
+ * `NX_FORMAT_SORT_TSCONFIG_PATHS`.
33
33
  */
34
34
  async function formatFiles(tree, options = {}) {
35
35
  options.sortRootTsconfigPaths ??=
@@ -37,26 +37,66 @@ async function formatFiles(tree, options = {}) {
37
37
  if (options.sortRootTsconfigPaths) {
38
38
  sortTsConfig(tree);
39
39
  }
40
- // Skip Prettier formatting if NX_SKIP_FORMAT is set
40
+ // Skip formatting if NX_SKIP_FORMAT is set
41
41
  // This is checked after tsconfig sorting since sorting is a separate concern
42
42
  if (process.env.NX_SKIP_FORMAT === 'true') {
43
43
  return;
44
44
  }
45
- let prettier;
46
- try {
47
- prettier = await importPrettier();
48
- /**
49
- * Even after we discovered prettier in node_modules, we need to be sure that the user is intentionally using prettier
50
- * before proceeding to format with it.
51
- */
52
- if (!(0, devkit_internals_1.isUsingPrettierInTree)(tree)) {
53
- return;
45
+ let formatterType = null;
46
+ // devkit supports nx +/- 1 major and these exports do not exist in older
47
+ // versions. A missing CommonJS named export is `undefined` rather than a
48
+ // throw, so a presence check is what handles it - not a try/catch.
49
+ if (devkit_internals_1.detectFormatterInTree) {
50
+ formatterType = (0, devkit_internals_1.detectFormatterInTree)(tree);
51
+ }
52
+ else {
53
+ try {
54
+ if ((await importPrettier()) && (0, devkit_internals_1.isUsingPrettierInTree)(tree)) {
55
+ formatterType = 'prettier';
56
+ }
54
57
  }
58
+ catch { }
55
59
  }
56
- catch { }
57
- if (!prettier)
60
+ if (!formatterType)
58
61
  return;
59
- const files = new Set(tree.listChanges().filter((file) => file.type !== 'DELETE'));
62
+ // Each formatter gets the ignore rules its own CLI applies, so a generator
63
+ // does not rewrite a file that formatter would skip. Both measured against
64
+ // the real CLIs. `.nxignore` is the exception in both directions: `format.ts`
65
+ // filters its own list through it, and neither checker reads it.
66
+ //
67
+ // `getFileInfo` below looks like it filters ignored files but with no
68
+ // `ignorePath` it only covers its built-in `node_modules` skip (measured).
69
+ // The optional call is the older-nx path - see `NOTHING_IGNORED`.
70
+ const changedFiles = (createChecker) => {
71
+ const { isIgnoredFile } = createChecker?.(tree) ?? nx_ignore_internals_1.NOTHING_IGNORED;
72
+ return new Set(tree
73
+ .listChanges()
74
+ .filter((file) => file.type !== 'DELETE' && !isIgnoredFile(file.path)));
75
+ };
76
+ // One switch rather than a checker ternary plus a dispatch `if`: those defaulted
77
+ // differently, so a third formatter would have been filtered with prettier's
78
+ // rules and then not formatted at all.
79
+ switch (formatterType) {
80
+ case 'prettier':
81
+ await formatWithPrettier(tree, changedFiles(devkit_internals_1.createPrettierIgnoreChecker));
82
+ break;
83
+ case 'oxfmt':
84
+ await formatWithOxfmt(tree, changedFiles(devkit_internals_1.createOxfmtIgnoreChecker));
85
+ break;
86
+ default: {
87
+ const unhandled = formatterType;
88
+ throw new Error(`Unhandled formatter: ${unhandled}`);
89
+ }
90
+ }
91
+ }
92
+ async function formatWithPrettier(tree, files) {
93
+ const prettier = await importPrettier();
94
+ if (!prettier) {
95
+ // Detection said this workspace formats with prettier, so silence here
96
+ // would leave a generator's files unformatted for no stated reason.
97
+ console.warn('Could not format files with prettier: prettier is configured for this workspace but is not installed.');
98
+ return;
99
+ }
60
100
  const changedPrettierInTree = getChangedPrettierConfigInTree(tree);
61
101
  await Promise.all(Array.from(files).map(async (file) => {
62
102
  try {
@@ -83,6 +123,69 @@ async function formatFiles(tree, options = {}) {
83
123
  }
84
124
  }));
85
125
  }
126
+ async function formatWithOxfmt(tree, files) {
127
+ if (!devkit_internals_1.formatFilesWithOxfmt)
128
+ return;
129
+ const staged = Array.from(files).map((file) => ({
130
+ path: file.path,
131
+ content: file.content.toString('utf-8'),
132
+ }));
133
+ try {
134
+ const { formatted, errors } = await (0, devkit_internals_1.formatFilesWithOxfmt)(staged, tree.root, getGeneratedOxfmtConfig(devkit_internals_1.oxfmtConfigFiles, files),
135
+ // The tree is the post-flush truth, and the only place it exists: disk
136
+ // cannot see a config the generator staged, and still sees one it
137
+ // deleted. Both mislead oxfmt's "two configs in one directory" check.
138
+ devkit_internals_1.oxfmtConfigFiles?.filter((name) => tree.exists(name)),
139
+ // Ignore files and the root `.editorconfig` as they will be after the
140
+ // flush: the batch is selected against the tree, so re-checking against
141
+ // disk decides a staged `.gitignore`/`.prettierignore` change twice, two
142
+ // ways, and misses a staged `.editorconfig` entirely.
143
+ //
144
+ // Only when the checkers exist. An nx without them is older than this
145
+ // argument, so it would drop the reader and filter nothing - and there is
146
+ // no pre-filter to disagree with either.
147
+ devkit_internals_1.createOxfmtIgnoreChecker
148
+ ? (relativePath) => tree.read(relativePath, 'utf-8')
149
+ : undefined);
150
+ for (const [filePath, content] of formatted) {
151
+ tree.write(filePath, content);
152
+ }
153
+ if (errors?.length) {
154
+ // One warning for the batch, but every failing file is named - oxfmt's
155
+ // `message` alone ("Unexpected token") says nothing about which file.
156
+ console.warn([`Could not format some files with oxfmt:`, ...errors].join('\n '));
157
+ }
158
+ }
159
+ catch (e) {
160
+ console.warn(`Could not format files with oxfmt. Error: "${e.message}"`);
161
+ }
162
+ }
163
+ /**
164
+ * A config the generator just created exists only in the tree, so oxfmt cannot
165
+ * discover it on disk. Hand it over so the files it writes match the config it
166
+ * ships with.
167
+ */
168
+ function getGeneratedOxfmtConfig(
169
+ // `readonly` because this only iterates: nx's `oxfmtConfigFiles` is a plain
170
+ // array today, and marking it `as const` there should not break devkit here.
171
+ configFiles,
172
+ // The caller's already-filtered set, rather than a second `listChanges()`:
173
+ // that walk stats every recorded change, and deletions are excluded from it
174
+ // for us. A deleted config is not one the generator "just created", and
175
+ // treating it as one would report an unreadable config and skip the batch.
176
+ files) {
177
+ // Keyed by path so the content comes from that same set. Re-reading through
178
+ // `tree.read` would reintroduce a `string | null` the filtering already
179
+ // rules out.
180
+ const changed = new Map(Array.from(files, (file) => [file.path, file.content]));
181
+ for (const name of configFiles ?? []) {
182
+ const content = changed.get(name);
183
+ if (content !== undefined) {
184
+ return { name, content: content.toString('utf-8') };
185
+ }
186
+ }
187
+ return undefined;
188
+ }
86
189
  function sortTsConfig(tree) {
87
190
  try {
88
191
  const tsConfigPath = getRootTsConfigPath(tree);
@@ -91,7 +194,6 @@ function sortTsConfig(tree) {
91
194
  }
92
195
  const tsconfig = (0, devkit_exports_1.readJson)(tree, tsConfigPath);
93
196
  if (!tsconfig.compilerOptions?.paths) {
94
- // no paths to sort
95
197
  return;
96
198
  }
97
199
  (0, devkit_exports_1.writeJson)(tree, tsConfigPath, {
@@ -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);
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.determineProjectNameAndRootOptions = determineProjectNameAndRootOptions;
4
4
  exports.resolveImportPath = resolveImportPath;
5
5
  exports.ensureRootProjectName = ensureRootProjectName;
6
- const enquirer_1 = require("enquirer");
6
+ const devkit_internals_1 = require("nx/src/devkit-internals");
7
+ const prompt_1 = require("./prompt");
7
8
  const devkit_exports_1 = require("nx/src/devkit-exports");
8
9
  const path_1 = require("path");
9
10
  async function determineProjectNameAndRootOptions(tree, options) {
@@ -51,6 +52,7 @@ async function determineProjectNameAndRootOptions(tree, options) {
51
52
  if (projectRoot.startsWith('..')) {
52
53
  throw new Error(`The resolved project root "${projectRoot}" is outside of the workspace root "${devkit_exports_1.workspaceRoot}".`);
53
54
  }
55
+ validateUniqueName(tree, name, projectRoot, options);
54
56
  const importPath = options.importPath ?? resolveImportPath(tree, name, projectRoot);
55
57
  return {
56
58
  projectName: name,
@@ -79,12 +81,11 @@ function resolveImportPath(tree, projectName, projectRoot) {
79
81
  }
80
82
  async function ensureRootProjectName(options, projectType) {
81
83
  if (!options.name && options.directory === '.' && getRelativeCwd() === '') {
82
- const result = await (0, enquirer_1.prompt)({
83
- type: 'input',
84
- name: 'name',
85
- message: `What do you want to name the ${projectType}?`,
86
- });
87
- options.name = result.name;
84
+ options.name = (0, prompt_1.isInteractive)()
85
+ ? await (0, devkit_internals_1.textPrompt)({
86
+ message: `What do you want to name the ${projectType}?`,
87
+ })
88
+ : undefined;
88
89
  }
89
90
  }
90
91
  function validateOptions(providedName, derivedName, directory) {
@@ -109,6 +110,18 @@ function validateOptions(providedName, derivedName, directory) {
109
110
  throw new Error(`The derived name from the provided directory should match the pattern "${pattern}". The derived name "${derivedName}" from the provided value "${directory}" does not match.`);
110
111
  }
111
112
  }
113
+ function validateUniqueName(tree, name, projectRoot, options) {
114
+ const existingProject = (0, devkit_exports_1.getProjects)(tree).get(name);
115
+ // A project at the resolved root is handled elsewhere with a more
116
+ // accurate error, so only error when the name is taken by a project
117
+ // located somewhere else.
118
+ if (!existingProject || existingProject.root === projectRoot) {
119
+ return;
120
+ }
121
+ throw new Error(options.name
122
+ ? `The provided name "${name}" is already used by the project at "${existingProject.root}". Please provide a unique name for the new project.`
123
+ : `The name "${name}" was derived from the provided directory "${options.directory}", but it is already used by the project at "${existingProject.root}". Please provide a unique name for the new project with the "--name" option.`);
124
+ }
112
125
  function getImportPath(npmScope, name) {
113
126
  return npmScope ? `${npmScope === '@' ? '' : '@'}${npmScope}/${name}` : name;
114
127
  }
@@ -1,2 +1,10 @@
1
- import { prompt } from 'enquirer';
2
- export declare function promptWhenInteractive<T>(questions: Parameters<typeof prompt>[0], defaultValue: T): Promise<T>;
1
+ /**
2
+ * Whether a generator may prompt at all. Requires a TTY, not CI, and the
3
+ * caller having opted in via NX_INTERACTIVE.
4
+ *
5
+ * Generators that cannot ask still need an answer, so callers pair this with
6
+ * the value to assume:
7
+ *
8
+ * options.name = isInteractive() ? await textPrompt({ ... }) : undefined;
9
+ */
10
+ export declare function isInteractive(): boolean;
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promptWhenInteractive = promptWhenInteractive;
4
- const enquirer_1 = require("enquirer");
3
+ exports.isInteractive = isInteractive;
5
4
  const devkit_internals_1 = require("nx/src/devkit-internals");
6
- async function promptWhenInteractive(questions, defaultValue) {
7
- if (!isInteractive()) {
8
- return defaultValue;
9
- }
10
- return await (0, enquirer_1.prompt)(questions);
11
- }
5
+ /**
6
+ * Whether a generator may prompt at all. Requires a TTY, not CI, and the
7
+ * caller having opted in via NX_INTERACTIVE.
8
+ *
9
+ * Generators that cannot ask still need an answer, so callers pair this with
10
+ * the value to assume:
11
+ *
12
+ * options.name = isInteractive() ? await textPrompt({ ... }) : undefined;
13
+ */
12
14
  function isInteractive() {
13
15
  return (!(0, devkit_internals_1.isCI)() && !!process.stdout.isTTY && process.env.NX_INTERACTIVE === 'true');
14
16
  }
@@ -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 keeps the walk from checking every
33
+ * file under one just to drop them all. It also keeps the answers matching git
34
+ * under devkit's nx skew: git refuses to re-include a file inside an excluded
35
+ * directory, and only nx versions from `createAncestorAwareIgnoreChecker`
36
+ * onward enforce that in `isIgnoredFile` itself.
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
  }
@@ -61,8 +61,10 @@ async function _addPluginInternal(tree, graph, pluginName, pluginFactory, option
61
61
  // Errors are okay for this because we're only running 1 plugin
62
62
  if ((0, devkit_internals_1.isProjectConfigurationsError)(e)) {
63
63
  projConfigs = e.partialProjectConfigurationsResult;
64
- // ignore errors from projects with no name
65
- if (!e.errors.every(devkit_internals_1.isProjectsWithNoNameError)) {
64
+ // Ignore errors about project names: running a single plugin in
65
+ // isolation cannot resolve the real project names, and they are
66
+ // irrelevant for determining the plugin options.
67
+ if (!e.errors.every(isProjectNameError)) {
66
68
  throw e;
67
69
  }
68
70
  }
@@ -102,8 +104,10 @@ async function _addPluginInternal(tree, graph, pluginName, pluginFactory, option
102
104
  // Errors are okay for this because we're only running 1 plugin
103
105
  if ((0, devkit_internals_1.isProjectConfigurationsError)(e)) {
104
106
  projConfigs = e.partialProjectConfigurationsResult;
105
- // ignore errors from projects with no name
106
- if (!e.errors.every(devkit_internals_1.isProjectsWithNoNameError)) {
107
+ // Ignore errors about project names: running a single plugin in
108
+ // isolation cannot resolve the real project names, and they are
109
+ // irrelevant for determining the plugin options.
110
+ if (!e.errors.every(isProjectNameError)) {
107
111
  throw e;
108
112
  }
109
113
  }
@@ -125,6 +129,9 @@ async function _addPluginInternal(tree, graph, pluginName, pluginFactory, option
125
129
  updatePackageScripts(tree, projConfigs);
126
130
  }
127
131
  }
132
+ function isProjectNameError(e) {
133
+ return (0, devkit_internals_1.isProjectsWithNoNameError)(e) || (0, devkit_internals_1.isMultipleProjectsWithSameNameError)(e);
134
+ }
128
135
  function updatePackageScripts(tree, projectConfigurations) {
129
136
  for (const projectConfig of Object.values(projectConfigurations.projects)) {
130
137
  const projectRoot = projectConfig.root;
@@ -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,20 @@
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
4
+ * predating the ignore checkers can be installed, and a missing CommonJS
5
+ * named export arrives as `undefined`. The two callers want opposite things
6
+ * from that - see `NOTHING_IGNORED` for the other half.
7
+ *
8
+ * A tree walk cannot degrade: with no checker the walker would descend into
9
+ * `node_modules` and hand a migration every file in it. Worse than the older
10
+ * nx's own behaviour, so this fails instead - once, by name.
11
+ */
12
+ export declare function assertNxSupportsIgnoreCheckers(): void;
13
+ /**
14
+ * The degrade the other way, for formatting.
15
+ *
16
+ * Filtering nothing is what devkit did before the checkers existed - with no
17
+ * `ignorePath`, prettier's `getFileInfo` never read the workspace's ignore
18
+ * files either (measured) - so an older nx gets the behaviour it always had.
19
+ */
20
+ export declare const NOTHING_IGNORED: TreeIgnoreChecker;
@@ -0,0 +1,33 @@
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
8
+ * predating the ignore checkers can be installed, and a missing CommonJS
9
+ * named export arrives as `undefined`. The two callers want opposite things
10
+ * from that - see `NOTHING_IGNORED` for the other half.
11
+ *
12
+ * A tree walk cannot degrade: with no checker the walker would descend into
13
+ * `node_modules` and hand a migration every file in it. Worse than the older
14
+ * nx's own behaviour, so this fails instead - once, by name.
15
+ */
16
+ function assertNxSupportsIgnoreCheckers() {
17
+ if (devkit_internals_1.createGitIgnoreChecker) {
18
+ return;
19
+ }
20
+ 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. ' +
21
+ 'This happens when nx and @nx/devkit are on different major versions. Run `nx migrate latest` to bring them into line.');
22
+ }
23
+ /**
24
+ * The degrade the other way, for formatting.
25
+ *
26
+ * Filtering nothing is what devkit did before the checkers existed - with no
27
+ * `ignorePath`, prettier's `getFileInfo` never read the workspace's ignore
28
+ * files either (measured) - so an older nx gets the behaviour it always had.
29
+ */
30
+ exports.NOTHING_IGNORED = {
31
+ isIgnoredFile: () => false,
32
+ isIgnoredDirectory: () => false,
33
+ };
@@ -3,9 +3,10 @@ import type { PackageJson, PackageJsonDependencySection } from 'nx/src/utils/pac
3
3
  /**
4
4
  * Get the resolved version of a dependency from package.json.
5
5
  *
6
- * Retrieves a package version and automatically resolves PNPM catalog references
7
- * (e.g., "catalog:default") to their actual version strings. By default, searches
8
- * `dependencies` first, then falls back to `devDependencies`.
6
+ * Retrieves a package version and automatically resolves package manager
7
+ * catalog references (e.g., "catalog:default") to their actual version
8
+ * strings. By default, searches `dependencies` first, then falls back to
9
+ * `devDependencies`.
9
10
  *
10
11
  * **Tree-based usage** (generators and migrations):
11
12
  * Use when you have a `Tree` object, which is typical in Nx generators and migrations.
@@ -442,7 +442,11 @@ function ensurePackage(pkgOrTree, requiredVersionOrPackage, maybeRequiredVersion
442
442
  return packageMapCache.get(pkg);
443
443
  }
444
444
  try {
445
- return require(pkg);
445
+ // The workspace comes first so its installed version wins; `__dirname`
446
+ // keeps the old behaviour as a fallback. A bare `require` would only
447
+ // resolve from wherever `@nx/devkit` sits, which in a monorepo can be a
448
+ // different copy of the package than the workspace depends on.
449
+ return require(require.resolve(pkg, { paths: [devkit_exports_1.workspaceRoot, __dirname] }));
446
450
  }
447
451
  catch (e) {
448
452
  if (e.code === 'ERR_REQUIRE_ESM') {
@@ -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.2.0-beta.0",
3
+ "version": "23.2.0-beta.10",
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
  },
@@ -54,12 +63,11 @@
54
63
  "tslib": "^2.3.0",
55
64
  "semver": "^7.6.3",
56
65
  "yargs-parser": "21.1.1",
57
- "minimatch": "10.2.5",
58
- "enquirer": "~2.3.6"
66
+ "minimatch": "10.2.5"
59
67
  },
60
68
  "devDependencies": {
61
69
  "jest": "30.3.0",
62
- "nx": "23.2.0-beta.0"
70
+ "nx": "23.2.0-beta.10"
63
71
  },
64
72
  "peerDependencies": {
65
73
  "nx": ">= 22 <= 24 || ^23.0.0-0"
@@ -89,6 +97,21 @@
89
97
  "types": "./dist/internal-testing-utils.d.ts",
90
98
  "default": "./dist/internal-testing-utils.js"
91
99
  },
100
+ "./internal-testing-utils/mock-project-graph": {
101
+ "@nx/nx-source": "./internal-testing-utils/mock-project-graph.ts",
102
+ "types": "./dist/internal-testing-utils/mock-project-graph.d.ts",
103
+ "default": "./dist/internal-testing-utils/mock-project-graph.js"
104
+ },
105
+ "./internal-testing-utils/mock-fs": {
106
+ "@nx/nx-source": "./internal-testing-utils/mock-fs.ts",
107
+ "types": "./dist/internal-testing-utils/mock-fs.d.ts",
108
+ "default": "./dist/internal-testing-utils/mock-fs.js"
109
+ },
110
+ "./internal-testing-utils/mock-prettier": {
111
+ "@nx/nx-source": "./internal-testing-utils/mock-prettier.ts",
112
+ "types": "./dist/internal-testing-utils/mock-prettier.d.ts",
113
+ "default": "./dist/internal-testing-utils/mock-prettier.js"
114
+ },
92
115
  "./ngcli-adapter": {
93
116
  "@nx/nx-source": "./ngcli-adapter.ts",
94
117
  "types": "./dist/ngcli-adapter.d.ts",