nx 23.2.0-beta.7 → 23.2.0-beta.8

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.
Files changed (130) hide show
  1. package/dist/bin/init-local.js +3 -5
  2. package/dist/release/changelog-renderer/index.js +4 -5
  3. package/dist/src/adapter/ngcli-adapter.js +60 -1
  4. package/dist/src/command-line/completion/command-object.js +7 -12
  5. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +17 -23
  6. package/dist/src/command-line/generate/generate.js +35 -35
  7. package/dist/src/command-line/import/import.js +18 -40
  8. package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
  9. package/dist/src/command-line/init/command-object.js +4 -2
  10. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  11. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +8 -21
  12. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  13. package/dist/src/command-line/init/implementation/angular/index.js +6 -15
  14. package/dist/src/command-line/init/init-v1.js +8 -18
  15. package/dist/src/command-line/init/init-v2.js +26 -56
  16. package/dist/src/command-line/migrate/agentic/definitions.js +35 -8
  17. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +22 -3
  18. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +13 -10
  19. package/dist/src/command-line/migrate/agentic/handoff.d.ts +3 -1
  20. package/dist/src/command-line/migrate/agentic/handoff.js +4 -2
  21. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  22. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  23. package/dist/src/command-line/migrate/agentic/select.js +20 -30
  24. package/dist/src/command-line/migrate/agentic/types.d.ts +19 -3
  25. package/dist/src/command-line/migrate/agentic/types.js +13 -4
  26. package/dist/src/command-line/migrate/command-object.d.ts +3 -0
  27. package/dist/src/command-line/migrate/command-object.js +13 -0
  28. package/dist/src/command-line/migrate/execute-migration.d.ts +14 -0
  29. package/dist/src/command-line/migrate/execute-migration.js +30 -9
  30. package/dist/src/command-line/migrate/migrate-analytics.d.ts +28 -0
  31. package/dist/src/command-line/migrate/migrate-analytics.js +51 -1
  32. package/dist/src/command-line/migrate/migrate-commits.d.ts +8 -2
  33. package/dist/src/command-line/migrate/migrate-commits.js +66 -19
  34. package/dist/src/command-line/migrate/migrate-config.d.ts +4 -2
  35. package/dist/src/command-line/migrate/migrate-config.js +12 -4
  36. package/dist/src/command-line/migrate/migrate.d.ts +9 -2
  37. package/dist/src/command-line/migrate/migrate.js +179 -56
  38. package/dist/src/command-line/migrate/multi-major.js +7 -10
  39. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  40. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  41. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  42. package/dist/src/command-line/migrate/run/index.d.ts +7 -0
  43. package/dist/src/command-line/migrate/run/index.js +19 -1
  44. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  45. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  46. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  47. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  48. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  49. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  50. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  51. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  52. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  53. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  54. package/dist/src/command-line/migrate/run/util.d.ts +58 -0
  55. package/dist/src/command-line/migrate/run/util.js +139 -7
  56. package/dist/src/command-line/migrate/run/worker.d.ts +1 -0
  57. package/dist/src/command-line/migrate/run/worker.js +308 -45
  58. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  59. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  60. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  61. package/dist/src/command-line/migrate/step-actions.js +12 -0
  62. package/dist/src/command-line/migrate/text.d.ts +18 -0
  63. package/dist/src/command-line/migrate/text.js +26 -0
  64. package/dist/src/command-line/migrate/version-skew-guard.d.ts +6 -4
  65. package/dist/src/command-line/migrate/version-skew-guard.js +34 -14
  66. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +16 -20
  67. package/dist/src/command-line/release/changelog.js +6 -17
  68. package/dist/src/command-line/release/plan.js +15 -28
  69. package/dist/src/command-line/release/release.js +6 -17
  70. package/dist/src/command-line/release/utils/remote-release-clients/github.js +16 -22
  71. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
  72. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  73. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  74. package/dist/src/core/graph/main.js +1 -1
  75. package/dist/src/devkit-internals.d.ts +2 -0
  76. package/dist/src/devkit-internals.js +12 -4
  77. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  78. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  79. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  80. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  81. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  82. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  83. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +128 -2
  84. package/dist/src/tasks-runner/run-command.js +17 -32
  85. package/dist/src/tasks-runner/task-env.js +5 -2
  86. package/dist/src/tasks-runner/utils.js +2 -6
  87. package/dist/src/utils/analytics-prompt.js +4 -7
  88. package/dist/src/utils/exit-codes.d.ts +9 -0
  89. package/dist/src/utils/exit-codes.js +19 -0
  90. package/dist/src/utils/fileutils.d.ts +5 -0
  91. package/dist/src/utils/fileutils.js +7 -2
  92. package/dist/src/utils/git-utils.d.ts +33 -2
  93. package/dist/src/utils/git-utils.js +156 -8
  94. package/dist/src/utils/long-running-target.d.ts +10 -0
  95. package/dist/src/utils/long-running-target.js +19 -0
  96. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  97. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  98. package/dist/src/utils/min-release-age/packument.js +1 -1
  99. package/dist/src/utils/nx-console-prompt.js +3 -6
  100. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  101. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  102. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  103. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  104. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  105. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  106. package/dist/src/utils/package-manager.d.ts +21 -2
  107. package/dist/src/utils/package-manager.js +244 -47
  108. package/dist/src/utils/params.d.ts +7 -1
  109. package/dist/src/utils/params.js +64 -6
  110. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  111. package/dist/src/utils/prompt-helpers.js +111 -0
  112. package/dist/src/utils/provenance.js +6 -14
  113. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  114. package/dist/src/utils/registry-config/bun.js +257 -0
  115. package/dist/src/utils/registry-config/index.d.ts +13 -0
  116. package/dist/src/utils/registry-config/index.js +102 -0
  117. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  118. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  119. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  120. package/dist/src/utils/registry-config/utils.js +496 -0
  121. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  122. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  123. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  124. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  125. package/dist/src/utils/safe-spawn.d.ts +24 -0
  126. package/dist/src/utils/safe-spawn.js +104 -0
  127. package/migrations.json +6 -0
  128. package/package.json +17 -13
  129. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  130. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -29,6 +29,7 @@ export { findMatchingProjects } from './utils/find-matching-projects';
29
29
  export { readTargetDefaultsForTarget } from './project-graph/utils/project-configuration/target-defaults';
30
30
  export { createGitIgnoreChecker, createPrettierIgnoreChecker, type TreeIgnoreChecker, } from './utils/ignore';
31
31
  export { splitTarget } from './utils/split-target';
32
+ export { selectPrompt, multiselectPrompt, textPrompt, confirmationPrompt, type Choice as PromptChoice, } from './utils/prompt-helpers';
32
33
  export { combineOptionsForExecutor } from './utils/params';
33
34
  export { sortObjectByKeys } from './utils/object-sort';
34
35
  export { stripIndent } from './utils/logger';
@@ -131,3 +132,4 @@ export { SyncError } from './utils/sync-generators';
131
132
  export { nxVersion } from './utils/versions';
132
133
  export { getFilesInDirectoryUsingContext, globWithWorkspaceContext, resetWorkspaceContext, setupWorkspaceContext, } from './utils/workspace-context';
133
134
  export { setWorkspaceRoot, workspaceRootInner } from './utils/workspace-root';
135
+ export { safeExecFileSync, safeSpawn } from './utils/safe-spawn';
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkFilesAreInputs = exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.handleImport = exports.signalToCode = exports.globalSpinner = exports.readYamlFile = exports.isUsingPrettierInTree = exports.isCI = exports.interpolate = exports.requireWithTsconfigFallback = exports.forceRegisterEsmLoader = exports.loadTsFile = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappings = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.installPackageToTmpAsync = exports.installPackageToTmp = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.createPrettierIgnoreChecker = exports.createGitIgnoreChecker = exports.readTargetDefaultsForTarget = exports.findMatchingProjects = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.parseExecutor = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
4
- exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.isNpmProject = exports.readFileMapCache = exports.readPackageJson = exports.isWholeFileChange = exports.isLockFileChange = exports.isDeletedFileChange = exports.defaultFileRead = exports.calculateFileChanges = exports.WholeFileChange = exports.TEN_MEGABYTES = exports.LockFileChange = exports.DeletedFileChange = exports.buildPackageJsonWorkspacesMatcher = exports.buildPackageJsonPatterns = exports.getGlobPatternsFromPackageManagerWorkspaces = exports.registerTsConfigPaths = exports.getWorkspacePackagesFromGraph = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.findProjectsNpmDependencies = exports.createPackageJson = exports.getLockFileName = exports.createLockFile = exports.createNxCloudOnboardingURL = exports.getNxCloudAppOnBoardingUrl = exports.createNxCloudOnboardingURLForWelcomeApp = exports.connectToNxCloud = exports.killProcessTreeGraceful = exports.getTargetInputs = exports.filterUsingGlobPatterns = exports.hashFile = exports.getRelativeProjectJsonSchemaPath = exports.FsTree = exports.LARGE_BUFFER = exports.daemonClient = exports.isProjectGraphProjectNode = exports.isProjectGraphExternalNode = exports.fileDataDepType = exports.fileDataDepTarget = exports.BatchFunctionRunner = exports.getGeneratorInformation = exports.setupAiAgentsGenerator = exports.toOldFormat = exports.toNewFormat = exports.runCommandsExecutor = exports.acknowledgeBuildScripts = exports.getCatalogDependenciesFromPackageJson = exports.getCatalogManager = exports.checkFilesAreOutputs = void 0;
5
- exports.isNxCloudUsed = exports.getNxCloudUrl = exports.orange = exports.NX_PREFIX = exports.getNxRequirePaths = exports.combineGlobPatterns = exports.getLatestCommitSha = exports.readFileIfExisting = exports.isRelativePath = exports.fileExists = exports.directoryExists = exports.createDirectory = exports.deduceDefaultBase = exports.codeFrameColumns = exports.runNxSync = exports.workspaceDataDirectory = exports.getLastValueFromAsyncIterableIterator = exports.validateOutputs = exports.unparse = exports.transformLegacyOutputs = exports.shouldStreamOutput = exports.removeTasksFromTaskGraph = exports.readProjectAndTargetFromTargetString = exports.normalizeTargetDependencyWithStringProjects = exports.normalizeDependencyConfigProjects = exports.normalizeDependencyConfigDefinition = exports.isCacheableTask = exports.getUnparsedOverrideArgs = exports.getTargetConfigurationForTask = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getOutputs = exports.getExecutorNameForTask = exports.getExecutorForTask = exports.getDependencyConfigs = exports.getCustomHasher = exports.getCliPath = exports.expandWildcardTargetConfiguration = exports.expandInitiatingTasksThroughNoop = exports.expandDependencyConfigSyntaxSugar = exports.createTaskId = exports.calculateReverseDeps = exports.createRunManyDynamicOutputRenderer = exports.CompositeLifeCycle = exports.RemoteCacheV2 = exports.Cache = exports.readCachedProjectConfiguration = exports.preventRecursionInGraphConstruction = exports.handleProjectGraphError = exports.createProjectGraphAndSourceMapsAsync = void 0;
6
- exports.workspaceRootInner = exports.setWorkspaceRoot = exports.setupWorkspaceContext = exports.resetWorkspaceContext = exports.globWithWorkspaceContext = exports.getFilesInDirectoryUsingContext = exports.nxVersion = exports.SyncError = exports.getSourceDirOfDependentProjects = exports.findAllProjectNodeDependencies = exports.findInstalledPlugins = exports.deriveGroupNameFromTarget = exports.readNxMigrateConfig = void 0;
3
+ exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.handleImport = exports.signalToCode = exports.globalSpinner = exports.readYamlFile = exports.isUsingPrettierInTree = exports.isCI = exports.interpolate = exports.requireWithTsconfigFallback = exports.forceRegisterEsmLoader = exports.loadTsFile = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappings = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.installPackageToTmpAsync = exports.installPackageToTmp = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.confirmationPrompt = exports.textPrompt = exports.multiselectPrompt = exports.selectPrompt = exports.splitTarget = exports.createPrettierIgnoreChecker = exports.createGitIgnoreChecker = exports.readTargetDefaultsForTarget = exports.findMatchingProjects = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.parseExecutor = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
4
+ exports.isWholeFileChange = exports.isLockFileChange = exports.isDeletedFileChange = exports.defaultFileRead = exports.calculateFileChanges = exports.WholeFileChange = exports.TEN_MEGABYTES = exports.LockFileChange = exports.DeletedFileChange = exports.buildPackageJsonWorkspacesMatcher = exports.buildPackageJsonPatterns = exports.getGlobPatternsFromPackageManagerWorkspaces = exports.registerTsConfigPaths = exports.getWorkspacePackagesFromGraph = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.findProjectsNpmDependencies = exports.createPackageJson = exports.getLockFileName = exports.createLockFile = exports.createNxCloudOnboardingURL = exports.getNxCloudAppOnBoardingUrl = exports.createNxCloudOnboardingURLForWelcomeApp = exports.connectToNxCloud = exports.killProcessTreeGraceful = exports.getTargetInputs = exports.filterUsingGlobPatterns = exports.hashFile = exports.getRelativeProjectJsonSchemaPath = exports.FsTree = exports.LARGE_BUFFER = exports.daemonClient = exports.isProjectGraphProjectNode = exports.isProjectGraphExternalNode = exports.fileDataDepType = exports.fileDataDepTarget = exports.BatchFunctionRunner = exports.getGeneratorInformation = exports.setupAiAgentsGenerator = exports.toOldFormat = exports.toNewFormat = exports.runCommandsExecutor = exports.acknowledgeBuildScripts = exports.getCatalogDependenciesFromPackageJson = exports.getCatalogManager = exports.checkFilesAreOutputs = exports.checkFilesAreInputs = exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = void 0;
5
+ exports.getNxRequirePaths = exports.combineGlobPatterns = exports.getLatestCommitSha = exports.readFileIfExisting = exports.isRelativePath = exports.fileExists = exports.directoryExists = exports.createDirectory = exports.deduceDefaultBase = exports.codeFrameColumns = exports.runNxSync = exports.workspaceDataDirectory = exports.getLastValueFromAsyncIterableIterator = exports.validateOutputs = exports.unparse = exports.transformLegacyOutputs = exports.shouldStreamOutput = exports.removeTasksFromTaskGraph = exports.readProjectAndTargetFromTargetString = exports.normalizeTargetDependencyWithStringProjects = exports.normalizeDependencyConfigProjects = exports.normalizeDependencyConfigDefinition = exports.isCacheableTask = exports.getUnparsedOverrideArgs = exports.getTargetConfigurationForTask = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getOutputs = exports.getExecutorNameForTask = exports.getExecutorForTask = exports.getDependencyConfigs = exports.getCustomHasher = exports.getCliPath = exports.expandWildcardTargetConfiguration = exports.expandInitiatingTasksThroughNoop = exports.expandDependencyConfigSyntaxSugar = exports.createTaskId = exports.calculateReverseDeps = exports.createRunManyDynamicOutputRenderer = exports.CompositeLifeCycle = exports.RemoteCacheV2 = exports.Cache = exports.readCachedProjectConfiguration = exports.preventRecursionInGraphConstruction = exports.handleProjectGraphError = exports.createProjectGraphAndSourceMapsAsync = exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.isNpmProject = exports.readFileMapCache = exports.readPackageJson = void 0;
6
+ exports.safeSpawn = exports.safeExecFileSync = exports.workspaceRootInner = exports.setWorkspaceRoot = exports.setupWorkspaceContext = exports.resetWorkspaceContext = exports.globWithWorkspaceContext = exports.getFilesInDirectoryUsingContext = exports.nxVersion = exports.SyncError = exports.getSourceDirOfDependentProjects = exports.findAllProjectNodeDependencies = exports.findInstalledPlugins = exports.deriveGroupNameFromTarget = exports.readNxMigrateConfig = exports.isNxCloudUsed = exports.getNxCloudUrl = exports.orange = exports.NX_PREFIX = void 0;
7
7
  const tslib_1 = require("tslib");
8
8
  /**
9
9
  * Note to developers: STOP! These are nx internals, not part of the public
@@ -55,6 +55,11 @@ Object.defineProperty(exports, "createGitIgnoreChecker", { enumerable: true, get
55
55
  Object.defineProperty(exports, "createPrettierIgnoreChecker", { enumerable: true, get: function () { return ignore_1.createPrettierIgnoreChecker; } });
56
56
  var split_target_1 = require("./utils/split-target");
57
57
  Object.defineProperty(exports, "splitTarget", { enumerable: true, get: function () { return split_target_1.splitTarget; } });
58
+ var prompt_helpers_1 = require("./utils/prompt-helpers");
59
+ Object.defineProperty(exports, "selectPrompt", { enumerable: true, get: function () { return prompt_helpers_1.selectPrompt; } });
60
+ Object.defineProperty(exports, "multiselectPrompt", { enumerable: true, get: function () { return prompt_helpers_1.multiselectPrompt; } });
61
+ Object.defineProperty(exports, "textPrompt", { enumerable: true, get: function () { return prompt_helpers_1.textPrompt; } });
62
+ Object.defineProperty(exports, "confirmationPrompt", { enumerable: true, get: function () { return prompt_helpers_1.confirmationPrompt; } });
58
63
  var params_1 = require("./utils/params");
59
64
  Object.defineProperty(exports, "combineOptionsForExecutor", { enumerable: true, get: function () { return params_1.combineOptionsForExecutor; } });
60
65
  var object_sort_1 = require("./utils/object-sort");
@@ -286,3 +291,6 @@ Object.defineProperty(exports, "setupWorkspaceContext", { enumerable: true, get:
286
291
  var workspace_root_1 = require("./utils/workspace-root");
287
292
  Object.defineProperty(exports, "setWorkspaceRoot", { enumerable: true, get: function () { return workspace_root_1.setWorkspaceRoot; } });
288
293
  Object.defineProperty(exports, "workspaceRootInner", { enumerable: true, get: function () { return workspace_root_1.workspaceRootInner; } });
294
+ var safe_spawn_1 = require("./utils/safe-spawn");
295
+ Object.defineProperty(exports, "safeExecFileSync", { enumerable: true, get: function () { return safe_spawn_1.safeExecFileSync; } });
296
+ Object.defineProperty(exports, "safeSpawn", { enumerable: true, get: function () { return safe_spawn_1.safeSpawn; } });
@@ -0,0 +1,12 @@
1
+ import { Tree } from '../../generators/tree';
2
+ /**
3
+ * Target defaults resolve to a single key rather than merging, so an executor
4
+ * key hides the target name key entirely. Before Nx 23 a hidden `cache: true`
5
+ * still took effect, because cacheability was also derived from target *names*
6
+ * via `cacheableOperations`; Nx 23 removed that derivation and those targets
7
+ * silently stopped being cacheable.
8
+ *
9
+ * Write the intent into the executor key so it no longer depends on the
10
+ * deprecated fallback that restores the old behavior at run time.
11
+ */
12
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const executor_utils_1 = require("../../command-line/run/executor-utils");
5
+ const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
6
+ const json_1 = require("../../generators/utils/json");
7
+ const project_configuration_1 = require("../../generators/utils/project-configuration");
8
+ const path_1 = require("../../utils/path");
9
+ // TODO(v24): remove this migration alongside the runtime fallback it exists to
10
+ // retire (`isLegacyCachedTarget` in `target-normalization.ts`), along with its
11
+ // registration in `packages/nx/migrations.json`.
12
+ /**
13
+ * Target defaults resolve to a single key rather than merging, so an executor
14
+ * key hides the target name key entirely. Before Nx 23 a hidden `cache: true`
15
+ * still took effect, because cacheability was also derived from target *names*
16
+ * via `cacheableOperations`; Nx 23 removed that derivation and those targets
17
+ * silently stopped being cacheable.
18
+ *
19
+ * Write the intent into the executor key so it no longer depends on the
20
+ * deprecated fallback that restores the old behavior at run time.
21
+ */
22
+ async function update(tree) {
23
+ const nxJson = (0, project_configuration_1.readNxJson)(tree);
24
+ const targetDefaults = nxJson?.targetDefaults;
25
+ if (!targetDefaults) {
26
+ return;
27
+ }
28
+ const projects = (0, project_configuration_1.getProjects)(tree);
29
+ const projectsMap = {};
30
+ // `cache` on an executor key reaches every target that resolves through it,
31
+ // not just the one whose target name key enables caching. Collect them all
32
+ // per key so the decision below can be made for the key as a whole. The
33
+ // collection is a list rather than a map keyed by target name: two projects
34
+ // routinely declare the same target name through the same executor, and only
35
+ // one of them may be continuous.
36
+ const targetsByExecutorKey = new Map();
37
+ const collect = (targetName, target) => {
38
+ // `hasOwnProperty` rather than a lookup: an executor named `__proto__` or
39
+ // `constructor` resolves through the prototype chain to a truthy object, so
40
+ // a plain lookup would collect the target and stamp `Object.prototype`.
41
+ if (!target?.executor ||
42
+ !Object.prototype.hasOwnProperty.call(targetDefaults, target.executor)) {
43
+ return;
44
+ }
45
+ const targets = targetsByExecutorKey.get(target.executor) ?? [];
46
+ targets.push([targetName, target]);
47
+ targetsByExecutorKey.set(target.executor, targets);
48
+ };
49
+ for (const [projectName, project] of projects) {
50
+ projectsMap[projectName] = project;
51
+ for (const [targetName, target] of Object.entries(project.targets ?? {})) {
52
+ collect(targetName, target);
53
+ }
54
+ for (const [targetName, target] of Object.entries(packageJsonTargets(tree, project.root))) {
55
+ collect(targetName, target);
56
+ }
57
+ }
58
+ let changed = false;
59
+ for (const [key, targets] of targetsByExecutorKey) {
60
+ if (!canEnableCache(targetDefaults, key, targets, tree.root, projectsMap)) {
61
+ continue;
62
+ }
63
+ catchAllConfig(targetDefaults[key]).cache = true;
64
+ changed = true;
65
+ }
66
+ if (!changed) {
67
+ return;
68
+ }
69
+ (0, project_configuration_1.updateNxJson)(tree, nxJson);
70
+ await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
71
+ }
72
+ /**
73
+ * Whether `cache: true` can be written onto `key` without changing behavior for
74
+ * any target that resolves through it.
75
+ *
76
+ * The executor key outranks every target name key, so stamping it caches all of
77
+ * `targets` — including any that is continuous, which makes `nx.json` fail graph
78
+ * construction outright. The key is only safe when every target through it
79
+ * independently wants caching and none of them can be continuous. Anything else
80
+ * is left to the runtime fallback, which decides per target after normalization
81
+ * and can therefore see continuity this migration cannot.
82
+ */
83
+ function canEnableCache(targetDefaults, key, targets, workspaceRoot, projectsMap) {
84
+ // Targets written with `command` are rewritten to `nx:run-commands` and
85
+ // `package.json` scripts to `nx:run-script` before key selection, so neither
86
+ // names the key it resolves through. Plugins also infer continuous targets
87
+ // (`watch-deps`, dev servers) into projects whose config never mentions them.
88
+ // The target list here can never be trusted to be complete for these keys.
89
+ if (key === 'nx:run-commands' || key === 'nx:run-script') {
90
+ return false;
91
+ }
92
+ // Already decided; never override the user's value. A filtered entry counts
93
+ // as decided because its value can't be evaluated without project context.
94
+ if (declaresAnyCache(targetDefaults[key])) {
95
+ return false;
96
+ }
97
+ // `continuous` is a valid field on a target default, and this key applies it
98
+ // to every target that resolves through it. Adding `cache` would make each of
99
+ // them both cacheable and continuous, which fails graph construction — so no
100
+ // target list can make this key safe.
101
+ if (declaresAnyContinuous(targetDefaults[key])) {
102
+ return false;
103
+ }
104
+ // Only an unfiltered entry can be amended. Appending a catch-all to an
105
+ // all-filtered key would make it match targets that previously fell through
106
+ // to the target name key, silently dropping that key's `dependsOn`/`inputs`.
107
+ if (!catchAllConfig(targetDefaults[key])) {
108
+ return false;
109
+ }
110
+ // Continuity declared by the executor's schema is resolved at graph
111
+ // construction for every target through this key, so one lookup covers them
112
+ // all. For what an executor that cannot be resolved here costs, see
113
+ // {@link executorDeclaresContinuous}.
114
+ if (executorDeclaresContinuous(key, workspaceRoot, projectsMap)) {
115
+ return false;
116
+ }
117
+ for (const [targetName, target] of targets) {
118
+ if (!declaresCacheTrue(targetDefaults[targetName])) {
119
+ return false;
120
+ }
121
+ if (target.continuous || isLongRunningTargetName(targetName)) {
122
+ return false;
123
+ }
124
+ }
125
+ return true;
126
+ }
127
+ /**
128
+ * Whether the target name key declares `cache: true` on an entry that always
129
+ * applies. Mirrors `declaresCacheTrue` in `target-normalization.ts`: a filtered
130
+ * entry declaring `cache` makes the value unknowable without project context,
131
+ * so nothing is claimed. Among unfiltered entries the last wins.
132
+ */
133
+ function declaresCacheTrue(value) {
134
+ if (!value) {
135
+ return false;
136
+ }
137
+ let declared;
138
+ for (const entry of configEntries(value)) {
139
+ if (entry.cache === undefined)
140
+ continue;
141
+ if (entry.filter)
142
+ return false;
143
+ declared = entry.cache;
144
+ }
145
+ return declared === true;
146
+ }
147
+ /**
148
+ * Whether any entry declares `cache`, filtered or not — i.e. whether the value
149
+ * is already decided and must be left alone. Deliberately broader than
150
+ * {@link declaresCacheTrue}: a filtered `cache` blocks here rather than being
151
+ * read past, so the two never disagree about a filtered entry.
152
+ */
153
+ function declaresAnyCache(value) {
154
+ if (!value) {
155
+ return false;
156
+ }
157
+ return configEntries(value).some((entry) => entry.cache !== undefined);
158
+ }
159
+ /**
160
+ * Whether any entry declares `continuous: true`. Filtered entries count: which
161
+ * projects the filter matches is unknowable here, and the only case that
162
+ * matters is the one where it matches.
163
+ */
164
+ function declaresAnyContinuous(value) {
165
+ if (!value) {
166
+ return false;
167
+ }
168
+ return configEntries(value).some((entry) => entry.continuous === true);
169
+ }
170
+ /**
171
+ * The config blocks of a `targetDefaults` value. Entries that are not config
172
+ * objects are dropped rather than inspected: `nx.json` is hand-edited, and a
173
+ * `null` or scalar entry would otherwise throw while reading `.cache` off it.
174
+ */
175
+ function configEntries(value) {
176
+ const entries = Array.isArray(value) ? value : [value];
177
+ return entries.filter((entry) => !!entry && typeof entry === 'object');
178
+ }
179
+ /**
180
+ * The targets a project's `package.json` contributes to the graph.
181
+ *
182
+ * {@link getProjects} builds a root's configuration from its `project.json`
183
+ * alone whenever one exists, but the package.json plugin still creates the
184
+ * sibling `package.json`'s targets — it accepts any `package.json` that is
185
+ * either in the package manager workspaces or next to a `project.json`
186
+ * (`plugins/package-json/create-nodes.ts`). Those targets resolve through the
187
+ * same executor keys, so they belong in this decision.
188
+ *
189
+ * Targets derived from `scripts` are still not covered; they resolve through
190
+ * `nx:run-script`, which is never stamped for exactly that reason.
191
+ */
192
+ function packageJsonTargets(tree, projectRoot) {
193
+ const packageJsonPath = (0, path_1.joinPathFragments)(projectRoot, 'package.json');
194
+ if (!tree.exists(packageJsonPath)) {
195
+ return {};
196
+ }
197
+ // A parse failure is left to throw: `readJson` names the offending file,
198
+ // which is the one thing a user can act on. Shapes that parse but aren't the
199
+ // one this reads contribute no targets rather than crashing the run.
200
+ const targets = (0, json_1.readJson)(tree, packageJsonPath)?.nx?.targets;
201
+ if (!targets || typeof targets !== 'object' || Array.isArray(targets)) {
202
+ return {};
203
+ }
204
+ return targets;
205
+ }
206
+ /**
207
+ * The unfiltered config block of a `targetDefaults` value, or undefined when the
208
+ * array form carries only filtered entries and when the value is not a config
209
+ * object at all. Never creates one — see {@link canEnableCache}.
210
+ */
211
+ function catchAllConfig(value) {
212
+ // The filter check applies to both spellings: the object and single-element
213
+ // array forms of the same config have to reach the same verdict.
214
+ return configEntries(value).find((entry) => entry.filter === undefined);
215
+ }
216
+ /**
217
+ * Whether the executor's schema marks its targets continuous, resolved through
218
+ * the same `getExecutorInformation` call `normalizeTarget` makes at graph
219
+ * construction, so the two cannot drift on what continuous means.
220
+ *
221
+ * An executor that cannot be resolved is read as not continuous. That is the
222
+ * same answer `normalizeTarget` gives, but not the same trade: its lookup is
223
+ * repeated on every graph construction, so a failure there corrects itself,
224
+ * whereas this one decides a permanent edit to `nx.json`. An executor that is
225
+ * unresolvable while the migration runs and resolvable afterwards therefore
226
+ * keeps its stamped `cache` while the runtime starts marking its targets
227
+ * continuous — which `normalizeTargets` rejects with a `WorkspaceValidityError`,
228
+ * failing graph construction until `nx.json` is edited by hand.
229
+ */
230
+ function executorDeclaresContinuous(executor, workspaceRoot, projectsMap) {
231
+ try {
232
+ const [nodeModule, name] = (0, executor_utils_1.parseExecutor)(executor);
233
+ const { schema } = (0, executor_utils_1.getExecutorInformation)(nodeModule, name, workspaceRoot, projectsMap);
234
+ return !!schema.continuous;
235
+ }
236
+ catch {
237
+ return false;
238
+ }
239
+ }
240
+ /**
241
+ * Target names the pre-23 `longRunningTask` guard excluded from caching.
242
+ * Mirrors `isLongRunningTarget` in `target-normalization.ts`.
243
+ */
244
+ function isLongRunningTargetName(targetName) {
245
+ return (targetName.endsWith(':watch') ||
246
+ targetName.endsWith('-watch') ||
247
+ targetName === 'serve' ||
248
+ targetName === 'dev' ||
249
+ targetName === 'start');
250
+ }
@@ -0,0 +1,50 @@
1
+ #### Set cache on executor-based target defaults
2
+
3
+ Maintains compatibility with how cacheability was resolved before Nx 23.
4
+
5
+ Target defaults resolve to a single key rather than merging them. When a target matches both a target name key and an executor key, the executor key is the one that applies, and the target name key is not read at all. Earlier versions of Nx also derived cacheability from target names, so `"cache": true` on the target name key still took effect even when an executor key applied. Nx 23 reads cacheability from the resolved target only.
6
+
7
+ This migration copies `cache` onto each executor key that applies to a target whose target name key enables it, so those targets remain cacheable.
8
+
9
+ An executor key applies to every target that resolves through it, so the migration updates a key only when it can establish that caching is right for all of them. It leaves the key unchanged when the key already declares `cache`, when it declares `continuous: true`, when every entry on the key is filtered so none of them always applies, when a target through it is continuous or is a long-running target such as `serve`, `dev`, or `start`, when the executor's own schema marks its targets continuous, or when a target through it has no target name key enabling `cache`. It never updates the `nx:run-commands` or `nx:run-script` keys, because targets written with `command` and targets derived from `package.json` scripts resolve through those keys without naming them.
10
+
11
+ Where the migration makes no change, Nx still decides at run time, per target rather than per key: a target whose target name key enables `cache`, and whose resolved configuration still leaves `cache` undefined, gets it back and is reported as a deprecated fallback. Because that test is applied to the resolved target rather than to the key, it also covers the cases where a key looks decided but is not for this project — an executor key whose entries are all filtered, or whose only `cache` declaration is filtered out here. It equally covers the targets left behind because a sibling target through the same key does not opt in, and the targets reaching the `nx:run-commands` and `nx:run-script` keys. Three cases get no fallback and no warning. A continuous or long-running target, because caching it is invalid. A target whose resolved configuration already sets `cache`. And a target whose target name key was discarded as incompatible, because its entry named an executor the target does not use — before Nx 23 that target was cacheable, since cacheability was matched on target name alone and the entry's `executor` was never read. Restoring it here would mean setting `cache` with no executor key to point the user at and no migration able to retire the behavior, so it is deliberately left alone. Set `cache` on those targets directly.
12
+
13
+ Targets are read from each project's `project.json` and from the `nx.targets` block of its `package.json`. Targets inferred by a plugin, and targets derived from `package.json` scripts, are not visible to the migration — the latter is why the `nx:run-script` key is never updated. A key that looks safe here may still serve an inferred target. Set `cache` on the executor key by hand only after checking that no target reaching it is continuous; Nx rejects a target that is both cacheable and continuous. Nx names both keys in a run-time warning. That warning is emitted during project graph construction, so while the daemon is running it goes to `.nx/workspace-data/d/daemon.log` rather than the terminal; CI runs, where the daemon is disabled, print it normally.
14
+
15
+ #### Sample code changes
16
+
17
+ Given a project with a `build` target that uses the `@nx/angular:webpack-browser` executor:
18
+
19
+ ##### Before
20
+
21
+ ```json title="nx.json"
22
+ {
23
+ "targetDefaults": {
24
+ "build": {
25
+ "cache": true,
26
+ "dependsOn": ["^build"]
27
+ },
28
+ "@nx/angular:webpack-browser": {
29
+ "inputs": ["production", "^production"]
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ ##### After
36
+
37
+ ```json title="nx.json"
38
+ {
39
+ "targetDefaults": {
40
+ "build": {
41
+ "cache": true,
42
+ "dependsOn": ["^build"]
43
+ },
44
+ "@nx/angular:webpack-browser": {
45
+ "inputs": ["production", "^production"],
46
+ "cache": true
47
+ }
48
+ }
49
+ }
50
+ ```
Binary file
@@ -12,6 +12,16 @@ const project_graph_1 = require("../../../config/project-graph");
12
12
  const file_hasher_1 = require("../../../hasher/file-hasher");
13
13
  const project_graph_builder_1 = require("../../../project-graph/project-graph-builder");
14
14
  const json_1 = require("../../../utils/json");
15
+ // Highest bun.lock version this parser has been verified against:
16
+ // - 1: workspace packages are no longer listed with their dependencies
17
+ // - 2: identical content, stricter validation in Bun's own reader
18
+ // - 3: values in "overrides" may be objects holding rules scoped to a parent
19
+ // package (`"parent": { "child": "1.0.0" }`) and keys may carry a version
20
+ // selector (`"parent@1"`, `"child@<2"`). This parser never reads
21
+ // "overrides"; the resolved packages are listed in "packages" as before.
22
+ // Newer versions are parsed on a best-effort basis instead of being rejected
23
+ // outright.
24
+ const MAX_KNOWN_LOCKFILE_VERSION = 3;
15
25
  const DEPENDENCY_TYPES = [
16
26
  'dependencies',
17
27
  'devDependencies',
@@ -356,9 +366,12 @@ function parseLockFile(lockFileContent, lockFileHash) {
356
366
  if (typeof result.lockfileVersion !== 'number') {
357
367
  throw new Error(`Lockfile version must be a number, got ${typeof result.lockfileVersion}`);
358
368
  }
359
- const supportedVersions = [0, 1];
360
- if (!supportedVersions.includes(result.lockfileVersion)) {
361
- throw new Error(`Unsupported lockfile version ${result.lockfileVersion}. Supported versions: ${supportedVersions.join(', ')}`);
369
+ if (!Number.isInteger(result.lockfileVersion) ||
370
+ result.lockfileVersion < 0) {
371
+ throw new Error(`Unsupported lockfile version ${result.lockfileVersion}. Lockfile version must be a non-negative integer`);
372
+ }
373
+ if (result.lockfileVersion > MAX_KNOWN_LOCKFILE_VERSION) {
374
+ console.warn(`bun.lock has lockfileVersion ${result.lockfileVersion}, which is newer than the version ${MAX_KNOWN_LOCKFILE_VERSION} this version of Nx was tested with. Attempting to parse it anyway.`);
362
375
  }
363
376
  }
364
377
  if (!result.packages || typeof result.packages !== 'object') {
@@ -616,7 +629,7 @@ function processPackageForDependencies(packageKey, packageData, lockFile, index,
616
629
  const deps = packageDependencies[depType];
617
630
  if (!deps || typeof deps !== 'object')
618
631
  continue;
619
- const depDependencies = processDependencyEntries(deps, sourceNodeName, index, ctx, workspacePackages, lockFile.manifests);
632
+ const depDependencies = processDependencyEntries(deps, packageKey, sourceNodeName, lockFile, index, ctx, workspacePackages);
620
633
  dependencies.push(...depDependencies);
621
634
  }
622
635
  return dependencies;
@@ -634,12 +647,12 @@ function extractPackageDependencies(packageData) {
634
647
  }
635
648
  return undefined;
636
649
  }
637
- function processDependencyEntries(deps, sourceNodeName, index, ctx, workspacePackages, manifests) {
650
+ function processDependencyEntries(deps, sourcePackageKey, sourceNodeName, lockFile, index, ctx, workspacePackages) {
638
651
  const dependencies = [];
639
652
  const depsEntries = Object.entries(deps);
640
653
  for (const [packageName, versionSpec] of depsEntries) {
641
654
  try {
642
- const dependency = processSingleDependency(packageName, versionSpec, sourceNodeName, index, ctx, workspacePackages, manifests);
655
+ const dependency = processSingleDependency(packageName, versionSpec, sourcePackageKey, sourceNodeName, lockFile, index, ctx, workspacePackages);
643
656
  if (dependency) {
644
657
  dependencies.push(dependency);
645
658
  }
@@ -650,7 +663,7 @@ function processDependencyEntries(deps, sourceNodeName, index, ctx, workspacePac
650
663
  }
651
664
  return dependencies;
652
665
  }
653
- function processSingleDependency(packageName, versionSpec, sourceNodeName, index, ctx, workspacePackages, manifests) {
666
+ function processSingleDependency(packageName, versionSpec, sourcePackageKey, sourceNodeName, lockFile, index, ctx, workspacePackages) {
654
667
  if (typeof packageName !== 'string' || typeof versionSpec !== 'string') {
655
668
  return null;
656
669
  }
@@ -663,14 +676,22 @@ function processSingleDependency(packageName, versionSpec, sourceNodeName, index
663
676
  }
664
677
  let targetPackageName = packageName;
665
678
  let targetVersion = versionSpec;
666
- const aliasTarget = resolveAliasTarget(versionSpec);
667
- if (aliasTarget) {
679
+ // A "<parent>/<name>" entry records what this parent actually resolved the
680
+ // dependency to. Overrides scoped to a parent (bun.lock v3) can pick a
681
+ // version outside the declared range, so it takes precedence over matching
682
+ // the range against the versions in the lockfile.
683
+ const nestedVersion = resolveNestedVersion(sourcePackageKey, packageName, lockFile);
684
+ const aliasTarget = nestedVersion ? null : resolveAliasTarget(versionSpec);
685
+ if (nestedVersion) {
686
+ targetVersion = nestedVersion;
687
+ }
688
+ else if (aliasTarget) {
668
689
  targetPackageName = aliasTarget.packageName;
669
690
  targetVersion = aliasTarget.version;
670
691
  }
671
692
  else {
672
693
  // O(1) lookup using index instead of O(n) scan
673
- const resolvedVersion = findResolvedVersion(packageName, versionSpec, index, manifests);
694
+ const resolvedVersion = findResolvedVersion(packageName, versionSpec, index, lockFile.manifests);
674
695
  if (!resolvedVersion) {
675
696
  return null;
676
697
  }
@@ -693,6 +714,18 @@ function processSingleDependency(packageName, versionSpec, sourceNodeName, index
693
714
  return null;
694
715
  }
695
716
  }
717
+ function resolveNestedVersion(sourcePackageKey, packageName, lockFile) {
718
+ const nestedEntry = lockFile.packages[`${sourcePackageKey}/${packageName}`];
719
+ if (!Array.isArray(nestedEntry) || typeof nestedEntry[0] !== 'string') {
720
+ return null;
721
+ }
722
+ const { name, version } = getCachedSpecInfo(nestedEntry[0]);
723
+ // aliases ("alias@npm:real@1.0.0") are resolved to the real package by the caller
724
+ if (name !== packageName || !version || version.startsWith('npm:')) {
725
+ return null;
726
+ }
727
+ return version;
728
+ }
696
729
  function resolveTargetNodeName(targetPackageName, targetVersion, ctx) {
697
730
  const hoistedNodeName = `npm:${targetPackageName}`;
698
731
  const versionedNodeName = `npm:${targetPackageName}@${targetVersion}`;