nx 23.1.1 → 23.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/release/changelog-renderer/index.js +4 -5
- package/dist/release/index.d.ts +1 -1
- package/dist/src/command-line/add/add.js +5 -0
- package/dist/src/command-line/affected/affected.js +1 -0
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +2 -2
- package/dist/src/command-line/import/import.js +1 -2
- package/dist/src/command-line/init/init-v2.js +4 -5
- package/dist/src/command-line/migrate/migrate.d.ts +4 -0
- package/dist/src/command-line/migrate/migrate.js +89 -26
- package/dist/src/command-line/release/changelog.js +5 -0
- package/dist/src/command-line/release/index.d.ts +1 -1
- package/dist/src/command-line/release/utils/git.js +1 -1
- package/dist/src/command-line/release/utils/release-graph.d.ts +17 -0
- package/dist/src/command-line/release/utils/release-graph.js +71 -19
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +6 -0
- package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
- package/dist/src/command-line/release/version/release-group-processor.js +80 -6
- package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
- package/dist/src/command-line/release/version/version-actions.js +9 -1
- package/dist/src/command-line/release/version.js +9 -5
- package/dist/src/command-line/reset/reset.js +6 -1
- package/dist/src/command-line/run/run-one.js +1 -0
- package/dist/src/command-line/run-many/run-many.js +1 -0
- package/dist/src/command-line/watch/watch.js +13 -0
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +52 -1
- package/dist/src/daemon/client/client.js +160 -36
- package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
- package/dist/src/daemon/client/daemon-environment.js +110 -2
- package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
- package/dist/src/daemon/message-types/daemon-message.d.ts +33 -0
- package/dist/src/daemon/message-types/daemon-message.js +48 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
- package/dist/src/daemon/server/latest-nx.js +5 -2
- package/dist/src/daemon/server/server.js +24 -0
- package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
- package/dist/src/daemon/server/shutdown-utils.js +11 -4
- package/dist/src/daemon/socket-utils.d.ts +1 -0
- package/dist/src/daemon/socket-utils.js +24 -3
- package/dist/src/daemon/tmp-dir.d.ts +43 -3
- package/dist/src/daemon/tmp-dir.js +437 -15
- package/dist/src/devkit-internals.d.ts +94 -4
- package/dist/src/devkit-internals.js +194 -5
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +5 -0
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +9 -2
- package/dist/src/generators/tree.d.ts +4 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
- package/dist/src/native/index.d.ts +10 -0
- package/dist/src/native/index.js +71 -28
- package/dist/src/native/native-bindings.js +1 -0
- package/dist/src/native/native-file-cache-location.d.ts +17 -1
- package/dist/src/native/native-file-cache-location.js +86 -12
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
- package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
- package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +60 -0
- package/dist/src/plugins/js/lock-file/project-graph-pruning.js +14 -8
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +2 -0
- package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
- package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
- package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
- package/dist/src/project-graph/error-types.d.ts +12 -1
- package/dist/src/project-graph/error-types.js +27 -2
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +18 -1
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
- package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
- package/dist/src/project-graph/project-graph.js +20 -0
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +5 -1
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +133 -3
- package/dist/src/tasks-runner/task-env.js +5 -2
- package/dist/src/tasks-runner/utils.js +2 -6
- package/dist/src/utils/assert-workspace-validity.js +7 -2
- package/dist/src/utils/fileutils.d.ts +5 -0
- package/dist/src/utils/fileutils.js +7 -2
- package/dist/src/utils/git-worktrees.d.ts +30 -0
- package/dist/src/utils/git-worktrees.js +212 -0
- package/dist/src/utils/ignore.d.ts +128 -1
- package/dist/src/utils/ignore.js +182 -12
- package/dist/src/utils/long-running-target.d.ts +10 -0
- package/dist/src/utils/long-running-target.js +19 -0
- package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
- package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
- package/dist/src/utils/nx-tmp-dir.js +40 -0
- package/dist/src/utils/owned-private-dir.d.ts +132 -0
- package/dist/src/utils/owned-private-dir.js +323 -0
- package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
- package/dist/src/utils/package-manager-config/bunfig.js +49 -0
- package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
- package/dist/src/utils/package-manager-config/npmrc.js +124 -0
- package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
- package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
- package/dist/src/utils/package-manager.d.ts +21 -2
- package/dist/src/utils/package-manager.js +244 -47
- package/dist/src/utils/provenance.js +6 -14
- package/dist/src/utils/registry-config/bun.d.ts +2 -0
- package/dist/src/utils/registry-config/bun.js +257 -0
- package/dist/src/utils/registry-config/index.d.ts +13 -0
- package/dist/src/utils/registry-config/index.js +102 -0
- package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
- package/dist/src/utils/registry-config/pnpm.js +1551 -0
- package/dist/src/utils/registry-config/utils.d.ts +195 -0
- package/dist/src/utils/registry-config/utils.js +496 -0
- package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-berry.js +612 -0
- package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
- package/dist/src/utils/safe-spawn.d.ts +24 -0
- package/dist/src/utils/safe-spawn.js +104 -0
- package/dist/src/utils/shell-quoting.d.ts +15 -0
- package/dist/src/utils/shell-quoting.js +35 -0
- package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
- package/dist/src/utils/wait-for-socket-connection.js +14 -8
- package/migrations.json +6 -0
- package/package.json +12 -12
- package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
- package/dist/src/utils/min-release-age/npmrc.js +0 -45
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.acknowledgeBuildScripts = exports.getCatalogDependenciesFromPackageJson = exports.getCatalogManager = void 0;
|
|
3
|
+
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.isTsEsmNamedExportLinkageError = exports.isRequireInEsmScopeError = 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.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 = 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.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 = void 0;
|
|
5
7
|
const tslib_1 = require("tslib");
|
|
6
8
|
/**
|
|
7
|
-
* Note to developers: STOP! These
|
|
9
|
+
* Note to developers: STOP! These are nx internals, not part of the public
|
|
10
|
+
* @nx/devkit API.
|
|
8
11
|
*
|
|
9
|
-
*
|
|
12
|
+
* This barrel is NOT under @nx/devkit's version-tolerance contract. That contract
|
|
13
|
+
* (nx at the current major +/- 1, per devkit's peerDependencies) covers the public
|
|
14
|
+
* @nx/devkit API only. Two classes of consumer read this file, and the rules
|
|
15
|
+
* differ:
|
|
16
|
+
*
|
|
17
|
+
* 1. packages/devkit/src/ — devkit's own implementation. It ships to external
|
|
18
|
+
* plugins, so it *does* run under the +/- 1 tolerance (@nx/devkit@23 may be
|
|
19
|
+
* installed against nx@22) and must still guard: check at runtime, or only
|
|
20
|
+
* use symbols that have existed since the oldest supported nx major.
|
|
21
|
+
* 2. First-party plugins in this repo, via @nx/devkit/internal. They release in
|
|
22
|
+
* lockstep with nx, so they require an exactly matching nx version and need
|
|
23
|
+
* no guarding.
|
|
24
|
+
*
|
|
25
|
+
* See packages/devkit/CLAUDE.md.
|
|
10
26
|
*/
|
|
11
27
|
var package_manager_1 = require("./utils/package-manager");
|
|
12
28
|
Object.defineProperty(exports, "createTempNpmDirectory", { enumerable: true, get: function () { return package_manager_1.createTempNpmDirectory; } });
|
|
@@ -29,8 +45,14 @@ var find_matching_projects_1 = require("./utils/find-matching-projects");
|
|
|
29
45
|
Object.defineProperty(exports, "findMatchingProjects", { enumerable: true, get: function () { return find_matching_projects_1.findMatchingProjects; } });
|
|
30
46
|
var target_defaults_1 = require("./project-graph/utils/project-configuration/target-defaults");
|
|
31
47
|
Object.defineProperty(exports, "readTargetDefaultsForTarget", { enumerable: true, get: function () { return target_defaults_1.readTargetDefaultsForTarget; } });
|
|
48
|
+
// Only the tree-bound checkers and their type cross the boundary. The
|
|
49
|
+
// primitives they are built from carry preconditions a caller can violate - a
|
|
50
|
+
// chain must be resolved from the file's own directory, and the array it
|
|
51
|
+
// returns is the memo cache itself - and nothing outside this package needs
|
|
52
|
+
// them.
|
|
32
53
|
var ignore_1 = require("./utils/ignore");
|
|
33
|
-
Object.defineProperty(exports, "
|
|
54
|
+
Object.defineProperty(exports, "createGitIgnoreChecker", { enumerable: true, get: function () { return ignore_1.createGitIgnoreChecker; } });
|
|
55
|
+
Object.defineProperty(exports, "createPrettierIgnoreChecker", { enumerable: true, get: function () { return ignore_1.createPrettierIgnoreChecker; } });
|
|
34
56
|
var split_target_1 = require("./utils/split-target");
|
|
35
57
|
Object.defineProperty(exports, "splitTarget", { enumerable: true, get: function () { return split_target_1.splitTarget; } });
|
|
36
58
|
var params_1 = require("./utils/params");
|
|
@@ -63,6 +85,8 @@ var register_1 = require("./plugins/js/utils/register");
|
|
|
63
85
|
Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return register_1.registerTsProject; } });
|
|
64
86
|
Object.defineProperty(exports, "loadTsFile", { enumerable: true, get: function () { return register_1.loadTsFile; } });
|
|
65
87
|
Object.defineProperty(exports, "forceRegisterEsmLoader", { enumerable: true, get: function () { return register_1.forceRegisterEsmLoader; } });
|
|
88
|
+
Object.defineProperty(exports, "isRequireInEsmScopeError", { enumerable: true, get: function () { return register_1.isRequireInEsmScopeError; } });
|
|
89
|
+
Object.defineProperty(exports, "isTsEsmNamedExportLinkageError", { enumerable: true, get: function () { return register_1.isTsEsmNamedExportLinkageError; } });
|
|
66
90
|
Object.defineProperty(exports, "requireWithTsconfigFallback", { enumerable: true, get: function () { return register_1.requireWithTsconfigFallback; } });
|
|
67
91
|
var utils_1 = require("./tasks-runner/utils");
|
|
68
92
|
Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return utils_1.interpolate; } });
|
|
@@ -99,3 +123,168 @@ Object.defineProperty(exports, "getCatalogManager", { enumerable: true, get: fun
|
|
|
99
123
|
Object.defineProperty(exports, "getCatalogDependenciesFromPackageJson", { enumerable: true, get: function () { return catalog_1.getCatalogDependenciesFromPackageJson; } });
|
|
100
124
|
var acknowledge_build_scripts_1 = require("./utils/acknowledge-build-scripts");
|
|
101
125
|
Object.defineProperty(exports, "acknowledgeBuildScripts", { enumerable: true, get: function () { return acknowledge_build_scripts_1.acknowledgeBuildScripts; } });
|
|
126
|
+
// Exposed for first-party plugins in this repo (imported via @nx/devkit/internal).
|
|
127
|
+
var run_commands_impl_1 = require("./executors/run-commands/run-commands.impl");
|
|
128
|
+
Object.defineProperty(exports, "runCommandsExecutor", { enumerable: true, get: function () { return tslib_1.__importDefault(run_commands_impl_1).default; } });
|
|
129
|
+
var angular_json_1 = require("./adapter/angular-json");
|
|
130
|
+
Object.defineProperty(exports, "toNewFormat", { enumerable: true, get: function () { return angular_json_1.toNewFormat; } });
|
|
131
|
+
Object.defineProperty(exports, "toOldFormat", { enumerable: true, get: function () { return angular_json_1.toOldFormat; } });
|
|
132
|
+
var set_up_ai_agents_1 = require("./ai/set-up-ai-agents/set-up-ai-agents");
|
|
133
|
+
Object.defineProperty(exports, "setupAiAgentsGenerator", { enumerable: true, get: function () { return set_up_ai_agents_1.setupAiAgentsGenerator; } });
|
|
134
|
+
var generator_utils_1 = require("./command-line/generate/generator-utils");
|
|
135
|
+
Object.defineProperty(exports, "getGeneratorInformation", { enumerable: true, get: function () { return generator_utils_1.getGeneratorInformation; } });
|
|
136
|
+
var watch_1 = require("./command-line/watch/watch");
|
|
137
|
+
Object.defineProperty(exports, "BatchFunctionRunner", { enumerable: true, get: function () { return watch_1.BatchFunctionRunner; } });
|
|
138
|
+
var project_graph_1 = require("./config/project-graph");
|
|
139
|
+
Object.defineProperty(exports, "fileDataDepTarget", { enumerable: true, get: function () { return project_graph_1.fileDataDepTarget; } });
|
|
140
|
+
Object.defineProperty(exports, "fileDataDepType", { enumerable: true, get: function () { return project_graph_1.fileDataDepType; } });
|
|
141
|
+
Object.defineProperty(exports, "isProjectGraphExternalNode", { enumerable: true, get: function () { return project_graph_1.isProjectGraphExternalNode; } });
|
|
142
|
+
Object.defineProperty(exports, "isProjectGraphProjectNode", { enumerable: true, get: function () { return project_graph_1.isProjectGraphProjectNode; } });
|
|
143
|
+
var client_1 = require("./daemon/client/client");
|
|
144
|
+
Object.defineProperty(exports, "daemonClient", { enumerable: true, get: function () { return client_1.daemonClient; } });
|
|
145
|
+
var run_commands_impl_2 = require("./executors/run-commands/run-commands.impl");
|
|
146
|
+
Object.defineProperty(exports, "LARGE_BUFFER", { enumerable: true, get: function () { return run_commands_impl_2.LARGE_BUFFER; } });
|
|
147
|
+
var tree_1 = require("./generators/tree");
|
|
148
|
+
Object.defineProperty(exports, "FsTree", { enumerable: true, get: function () { return tree_1.FsTree; } });
|
|
149
|
+
var project_configuration_1 = require("./generators/utils/project-configuration");
|
|
150
|
+
Object.defineProperty(exports, "getRelativeProjectJsonSchemaPath", { enumerable: true, get: function () { return project_configuration_1.getRelativeProjectJsonSchemaPath; } });
|
|
151
|
+
var file_hasher_2 = require("./hasher/file-hasher");
|
|
152
|
+
Object.defineProperty(exports, "hashFile", { enumerable: true, get: function () { return file_hasher_2.hashFile; } });
|
|
153
|
+
var task_hasher_1 = require("./hasher/task-hasher");
|
|
154
|
+
Object.defineProperty(exports, "filterUsingGlobPatterns", { enumerable: true, get: function () { return task_hasher_1.filterUsingGlobPatterns; } });
|
|
155
|
+
Object.defineProperty(exports, "getTargetInputs", { enumerable: true, get: function () { return task_hasher_1.getTargetInputs; } });
|
|
156
|
+
var native_1 = require("./native");
|
|
157
|
+
Object.defineProperty(exports, "killProcessTreeGraceful", { enumerable: true, get: function () { return native_1.killProcessTreeGraceful; } });
|
|
158
|
+
var connect_to_nx_cloud_1 = require("./nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud");
|
|
159
|
+
Object.defineProperty(exports, "connectToNxCloud", { enumerable: true, get: function () { return connect_to_nx_cloud_1.connectToNxCloud; } });
|
|
160
|
+
var onboarding_1 = require("./nx-cloud/utilities/onboarding");
|
|
161
|
+
Object.defineProperty(exports, "createNxCloudOnboardingURLForWelcomeApp", { enumerable: true, get: function () { return onboarding_1.createNxCloudOnboardingURLForWelcomeApp; } });
|
|
162
|
+
Object.defineProperty(exports, "getNxCloudAppOnBoardingUrl", { enumerable: true, get: function () { return onboarding_1.getNxCloudAppOnBoardingUrl; } });
|
|
163
|
+
var url_shorten_1 = require("./nx-cloud/utilities/url-shorten");
|
|
164
|
+
Object.defineProperty(exports, "createNxCloudOnboardingURL", { enumerable: true, get: function () { return url_shorten_1.createNxCloudOnboardingURL; } });
|
|
165
|
+
var lock_file_1 = require("./plugins/js/lock-file/lock-file");
|
|
166
|
+
Object.defineProperty(exports, "createLockFile", { enumerable: true, get: function () { return lock_file_1.createLockFile; } });
|
|
167
|
+
Object.defineProperty(exports, "getLockFileName", { enumerable: true, get: function () { return lock_file_1.getLockFileName; } });
|
|
168
|
+
var create_package_json_1 = require("./plugins/js/package-json/create-package-json");
|
|
169
|
+
Object.defineProperty(exports, "createPackageJson", { enumerable: true, get: function () { return create_package_json_1.createPackageJson; } });
|
|
170
|
+
Object.defineProperty(exports, "findProjectsNpmDependencies", { enumerable: true, get: function () { return create_package_json_1.findProjectsNpmDependencies; } });
|
|
171
|
+
var target_project_locator_1 = require("./plugins/js/project-graph/build-dependencies/target-project-locator");
|
|
172
|
+
Object.defineProperty(exports, "TargetProjectLocator", { enumerable: true, get: function () { return target_project_locator_1.TargetProjectLocator; } });
|
|
173
|
+
Object.defineProperty(exports, "isBuiltinModuleImport", { enumerable: true, get: function () { return target_project_locator_1.isBuiltinModuleImport; } });
|
|
174
|
+
var get_workspace_packages_from_graph_1 = require("./plugins/js/utils/get-workspace-packages-from-graph");
|
|
175
|
+
Object.defineProperty(exports, "getWorkspacePackagesFromGraph", { enumerable: true, get: function () { return get_workspace_packages_from_graph_1.getWorkspacePackagesFromGraph; } });
|
|
176
|
+
var register_2 = require("./plugins/js/utils/register");
|
|
177
|
+
Object.defineProperty(exports, "registerTsConfigPaths", { enumerable: true, get: function () { return register_2.registerTsConfigPaths; } });
|
|
178
|
+
var package_json_2 = require("./plugins/package-json");
|
|
179
|
+
Object.defineProperty(exports, "getGlobPatternsFromPackageManagerWorkspaces", { enumerable: true, get: function () { return package_json_2.getGlobPatternsFromPackageManagerWorkspaces; } });
|
|
180
|
+
var file_utils_1 = require("./project-graph/file-utils");
|
|
181
|
+
Object.defineProperty(exports, "DeletedFileChange", { enumerable: true, get: function () { return file_utils_1.DeletedFileChange; } });
|
|
182
|
+
Object.defineProperty(exports, "LockFileChange", { enumerable: true, get: function () { return file_utils_1.LockFileChange; } });
|
|
183
|
+
Object.defineProperty(exports, "TEN_MEGABYTES", { enumerable: true, get: function () { return file_utils_1.TEN_MEGABYTES; } });
|
|
184
|
+
Object.defineProperty(exports, "WholeFileChange", { enumerable: true, get: function () { return file_utils_1.WholeFileChange; } });
|
|
185
|
+
Object.defineProperty(exports, "calculateFileChanges", { enumerable: true, get: function () { return file_utils_1.calculateFileChanges; } });
|
|
186
|
+
Object.defineProperty(exports, "defaultFileRead", { enumerable: true, get: function () { return file_utils_1.defaultFileRead; } });
|
|
187
|
+
Object.defineProperty(exports, "isDeletedFileChange", { enumerable: true, get: function () { return file_utils_1.isDeletedFileChange; } });
|
|
188
|
+
Object.defineProperty(exports, "isLockFileChange", { enumerable: true, get: function () { return file_utils_1.isLockFileChange; } });
|
|
189
|
+
Object.defineProperty(exports, "isWholeFileChange", { enumerable: true, get: function () { return file_utils_1.isWholeFileChange; } });
|
|
190
|
+
Object.defineProperty(exports, "readPackageJson", { enumerable: true, get: function () { return file_utils_1.readPackageJson; } });
|
|
191
|
+
var nx_deps_cache_1 = require("./project-graph/nx-deps-cache");
|
|
192
|
+
Object.defineProperty(exports, "readFileMapCache", { enumerable: true, get: function () { return nx_deps_cache_1.readFileMapCache; } });
|
|
193
|
+
var operators_1 = require("./project-graph/operators");
|
|
194
|
+
Object.defineProperty(exports, "isNpmProject", { enumerable: true, get: function () { return operators_1.isNpmProject; } });
|
|
195
|
+
var project_graph_2 = require("./project-graph/project-graph");
|
|
196
|
+
Object.defineProperty(exports, "buildProjectGraphAndSourceMapsWithoutDaemon", { enumerable: true, get: function () { return project_graph_2.buildProjectGraphAndSourceMapsWithoutDaemon; } });
|
|
197
|
+
Object.defineProperty(exports, "createProjectGraphAndSourceMapsAsync", { enumerable: true, get: function () { return project_graph_2.createProjectGraphAndSourceMapsAsync; } });
|
|
198
|
+
Object.defineProperty(exports, "handleProjectGraphError", { enumerable: true, get: function () { return project_graph_2.handleProjectGraphError; } });
|
|
199
|
+
Object.defineProperty(exports, "preventRecursionInGraphConstruction", { enumerable: true, get: function () { return project_graph_2.preventRecursionInGraphConstruction; } });
|
|
200
|
+
Object.defineProperty(exports, "readCachedProjectConfiguration", { enumerable: true, get: function () { return project_graph_2.readCachedProjectConfiguration; } });
|
|
201
|
+
var cache_1 = require("./tasks-runner/cache");
|
|
202
|
+
Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return cache_1.Cache; } });
|
|
203
|
+
var default_tasks_runner_1 = require("./tasks-runner/default-tasks-runner");
|
|
204
|
+
Object.defineProperty(exports, "RemoteCacheV2", { enumerable: true, get: function () { return default_tasks_runner_1.RemoteCacheV2; } });
|
|
205
|
+
var life_cycle_1 = require("./tasks-runner/life-cycle");
|
|
206
|
+
Object.defineProperty(exports, "CompositeLifeCycle", { enumerable: true, get: function () { return life_cycle_1.CompositeLifeCycle; } });
|
|
207
|
+
var dynamic_run_many_terminal_output_life_cycle_1 = require("./tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle");
|
|
208
|
+
Object.defineProperty(exports, "createRunManyDynamicOutputRenderer", { enumerable: true, get: function () { return dynamic_run_many_terminal_output_life_cycle_1.createRunManyDynamicOutputRenderer; } });
|
|
209
|
+
var utils_2 = require("./tasks-runner/utils");
|
|
210
|
+
Object.defineProperty(exports, "calculateReverseDeps", { enumerable: true, get: function () { return utils_2.calculateReverseDeps; } });
|
|
211
|
+
Object.defineProperty(exports, "createTaskId", { enumerable: true, get: function () { return utils_2.createTaskId; } });
|
|
212
|
+
Object.defineProperty(exports, "expandDependencyConfigSyntaxSugar", { enumerable: true, get: function () { return utils_2.expandDependencyConfigSyntaxSugar; } });
|
|
213
|
+
Object.defineProperty(exports, "expandInitiatingTasksThroughNoop", { enumerable: true, get: function () { return utils_2.expandInitiatingTasksThroughNoop; } });
|
|
214
|
+
Object.defineProperty(exports, "expandWildcardTargetConfiguration", { enumerable: true, get: function () { return utils_2.expandWildcardTargetConfiguration; } });
|
|
215
|
+
Object.defineProperty(exports, "getCliPath", { enumerable: true, get: function () { return utils_2.getCliPath; } });
|
|
216
|
+
Object.defineProperty(exports, "getCustomHasher", { enumerable: true, get: function () { return utils_2.getCustomHasher; } });
|
|
217
|
+
Object.defineProperty(exports, "getDependencyConfigs", { enumerable: true, get: function () { return utils_2.getDependencyConfigs; } });
|
|
218
|
+
Object.defineProperty(exports, "getExecutorForTask", { enumerable: true, get: function () { return utils_2.getExecutorForTask; } });
|
|
219
|
+
Object.defineProperty(exports, "getExecutorNameForTask", { enumerable: true, get: function () { return utils_2.getExecutorNameForTask; } });
|
|
220
|
+
Object.defineProperty(exports, "getOutputs", { enumerable: true, get: function () { return utils_2.getOutputs; } });
|
|
221
|
+
Object.defineProperty(exports, "getPrintableCommandArgsForTask", { enumerable: true, get: function () { return utils_2.getPrintableCommandArgsForTask; } });
|
|
222
|
+
Object.defineProperty(exports, "getSerializedArgsForTask", { enumerable: true, get: function () { return utils_2.getSerializedArgsForTask; } });
|
|
223
|
+
Object.defineProperty(exports, "getTargetConfigurationForTask", { enumerable: true, get: function () { return utils_2.getTargetConfigurationForTask; } });
|
|
224
|
+
Object.defineProperty(exports, "getUnparsedOverrideArgs", { enumerable: true, get: function () { return utils_2.getUnparsedOverrideArgs; } });
|
|
225
|
+
Object.defineProperty(exports, "isCacheableTask", { enumerable: true, get: function () { return utils_2.isCacheableTask; } });
|
|
226
|
+
Object.defineProperty(exports, "normalizeDependencyConfigDefinition", { enumerable: true, get: function () { return utils_2.normalizeDependencyConfigDefinition; } });
|
|
227
|
+
Object.defineProperty(exports, "normalizeDependencyConfigProjects", { enumerable: true, get: function () { return utils_2.normalizeDependencyConfigProjects; } });
|
|
228
|
+
Object.defineProperty(exports, "normalizeTargetDependencyWithStringProjects", { enumerable: true, get: function () { return utils_2.normalizeTargetDependencyWithStringProjects; } });
|
|
229
|
+
Object.defineProperty(exports, "readProjectAndTargetFromTargetString", { enumerable: true, get: function () { return utils_2.readProjectAndTargetFromTargetString; } });
|
|
230
|
+
Object.defineProperty(exports, "removeTasksFromTaskGraph", { enumerable: true, get: function () { return utils_2.removeTasksFromTaskGraph; } });
|
|
231
|
+
Object.defineProperty(exports, "shouldStreamOutput", { enumerable: true, get: function () { return utils_2.shouldStreamOutput; } });
|
|
232
|
+
Object.defineProperty(exports, "transformLegacyOutputs", { enumerable: true, get: function () { return utils_2.transformLegacyOutputs; } });
|
|
233
|
+
Object.defineProperty(exports, "unparse", { enumerable: true, get: function () { return utils_2.unparse; } });
|
|
234
|
+
Object.defineProperty(exports, "validateOutputs", { enumerable: true, get: function () { return utils_2.validateOutputs; } });
|
|
235
|
+
var async_iterator_1 = require("./utils/async-iterator");
|
|
236
|
+
Object.defineProperty(exports, "getLastValueFromAsyncIterableIterator", { enumerable: true, get: function () { return async_iterator_1.getLastValueFromAsyncIterableIterator; } });
|
|
237
|
+
var cache_directory_1 = require("./utils/cache-directory");
|
|
238
|
+
Object.defineProperty(exports, "workspaceDataDirectory", { enumerable: true, get: function () { return cache_directory_1.workspaceDataDirectory; } });
|
|
239
|
+
var child_process_1 = require("./utils/child-process");
|
|
240
|
+
Object.defineProperty(exports, "runNxSync", { enumerable: true, get: function () { return child_process_1.runNxSync; } });
|
|
241
|
+
var code_frames_1 = require("./utils/code-frames");
|
|
242
|
+
Object.defineProperty(exports, "codeFrameColumns", { enumerable: true, get: function () { return code_frames_1.codeFrameColumns; } });
|
|
243
|
+
var default_base_1 = require("./utils/default-base");
|
|
244
|
+
Object.defineProperty(exports, "deduceDefaultBase", { enumerable: true, get: function () { return default_base_1.deduceDefaultBase; } });
|
|
245
|
+
var fileutils_2 = require("./utils/fileutils");
|
|
246
|
+
Object.defineProperty(exports, "createDirectory", { enumerable: true, get: function () { return fileutils_2.createDirectory; } });
|
|
247
|
+
Object.defineProperty(exports, "directoryExists", { enumerable: true, get: function () { return fileutils_2.directoryExists; } });
|
|
248
|
+
Object.defineProperty(exports, "fileExists", { enumerable: true, get: function () { return fileutils_2.fileExists; } });
|
|
249
|
+
Object.defineProperty(exports, "isRelativePath", { enumerable: true, get: function () { return fileutils_2.isRelativePath; } });
|
|
250
|
+
Object.defineProperty(exports, "readFileIfExisting", { enumerable: true, get: function () { return fileutils_2.readFileIfExisting; } });
|
|
251
|
+
var git_utils_1 = require("./utils/git-utils");
|
|
252
|
+
Object.defineProperty(exports, "getLatestCommitSha", { enumerable: true, get: function () { return git_utils_1.getLatestCommitSha; } });
|
|
253
|
+
var globs_1 = require("./utils/globs");
|
|
254
|
+
Object.defineProperty(exports, "combineGlobPatterns", { enumerable: true, get: function () { return globs_1.combineGlobPatterns; } });
|
|
255
|
+
var installation_directory_1 = require("./utils/installation-directory");
|
|
256
|
+
Object.defineProperty(exports, "getNxRequirePaths", { enumerable: true, get: function () { return installation_directory_1.getNxRequirePaths; } });
|
|
257
|
+
var logger_2 = require("./utils/logger");
|
|
258
|
+
Object.defineProperty(exports, "NX_PREFIX", { enumerable: true, get: function () { return logger_2.NX_PREFIX; } });
|
|
259
|
+
var output_1 = require("./utils/output");
|
|
260
|
+
Object.defineProperty(exports, "orange", { enumerable: true, get: function () { return output_1.orange; } });
|
|
261
|
+
var nx_cloud_utils_1 = require("./utils/nx-cloud-utils");
|
|
262
|
+
Object.defineProperty(exports, "getNxCloudUrl", { enumerable: true, get: function () { return nx_cloud_utils_1.getNxCloudUrl; } });
|
|
263
|
+
Object.defineProperty(exports, "isNxCloudUsed", { enumerable: true, get: function () { return nx_cloud_utils_1.isNxCloudUsed; } });
|
|
264
|
+
var package_json_3 = require("./utils/package-json");
|
|
265
|
+
Object.defineProperty(exports, "readNxMigrateConfig", { enumerable: true, get: function () { return package_json_3.readNxMigrateConfig; } });
|
|
266
|
+
// Sourced from the leaf module rather than ./utils/plugins: the barrel index
|
|
267
|
+
// pulls output.ts and core-plugins.ts into the eager closure for a function that
|
|
268
|
+
// depends on neither.
|
|
269
|
+
var atomizer_utils_1 = require("./utils/plugins/atomizer-utils");
|
|
270
|
+
Object.defineProperty(exports, "deriveGroupNameFromTarget", { enumerable: true, get: function () { return atomizer_utils_1.deriveGroupNameFromTarget; } });
|
|
271
|
+
var installed_plugins_1 = require("./utils/plugins/installed-plugins");
|
|
272
|
+
Object.defineProperty(exports, "findInstalledPlugins", { enumerable: true, get: function () { return installed_plugins_1.findInstalledPlugins; } });
|
|
273
|
+
var project_graph_utils_1 = require("./utils/project-graph-utils");
|
|
274
|
+
Object.defineProperty(exports, "findAllProjectNodeDependencies", { enumerable: true, get: function () { return project_graph_utils_1.findAllProjectNodeDependencies; } });
|
|
275
|
+
Object.defineProperty(exports, "getSourceDirOfDependentProjects", { enumerable: true, get: function () { return project_graph_utils_1.getSourceDirOfDependentProjects; } });
|
|
276
|
+
var sync_generators_1 = require("./utils/sync-generators");
|
|
277
|
+
Object.defineProperty(exports, "SyncError", { enumerable: true, get: function () { return sync_generators_1.SyncError; } });
|
|
278
|
+
var versions_1 = require("./utils/versions");
|
|
279
|
+
Object.defineProperty(exports, "nxVersion", { enumerable: true, get: function () { return versions_1.nxVersion; } });
|
|
280
|
+
var workspace_context_2 = require("./utils/workspace-context");
|
|
281
|
+
Object.defineProperty(exports, "getFilesInDirectoryUsingContext", { enumerable: true, get: function () { return workspace_context_2.getFilesInDirectoryUsingContext; } });
|
|
282
|
+
Object.defineProperty(exports, "globWithWorkspaceContext", { enumerable: true, get: function () { return workspace_context_2.globWithWorkspaceContext; } });
|
|
283
|
+
Object.defineProperty(exports, "resetWorkspaceContext", { enumerable: true, get: function () { return workspace_context_2.resetWorkspaceContext; } });
|
|
284
|
+
Object.defineProperty(exports, "setupWorkspaceContext", { enumerable: true, get: function () { return workspace_context_2.setupWorkspaceContext; } });
|
|
285
|
+
var workspace_root_1 = require("./utils/workspace-root");
|
|
286
|
+
Object.defineProperty(exports, "setWorkspaceRoot", { enumerable: true, get: function () { return workspace_root_1.setWorkspaceRoot; } });
|
|
287
|
+
Object.defineProperty(exports, "workspaceRootInner", { enumerable: true, get: function () { return workspace_root_1.workspaceRootInner; } });
|
|
288
|
+
var safe_spawn_1 = require("./utils/safe-spawn");
|
|
289
|
+
Object.defineProperty(exports, "safeExecFileSync", { enumerable: true, get: function () { return safe_spawn_1.safeExecFileSync; } });
|
|
290
|
+
Object.defineProperty(exports, "safeSpawn", { enumerable: true, get: function () { return safe_spawn_1.safeSpawn; } });
|
package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ import type { Tree } from '../tree';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function formatChangedFilesWithPrettierIfAvailable(tree: Tree, options?: {
|
|
12
12
|
silent?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Tree-relative paths to leave untouched. Both platform-native and
|
|
15
|
+
* forward-slash separators are accepted.
|
|
16
|
+
*/
|
|
17
|
+
excludePaths?: Set<string>;
|
|
13
18
|
}): Promise<void>;
|
|
14
19
|
export declare function formatFilesWithPrettierIfAvailable(files: {
|
|
15
20
|
path: string;
|
package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.formatFilesWithPrettierIfAvailable = formatFilesWithPrettierIfAvailable;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
7
7
|
const is_using_prettier_1 = require("../../utils/is-using-prettier");
|
|
8
|
+
const path_1 = require("../../utils/path");
|
|
8
9
|
const installation_directory_1 = require("../../utils/installation-directory");
|
|
9
10
|
/**
|
|
10
11
|
* Formats all the created or updated files using Prettier
|
|
@@ -19,7 +20,13 @@ async function formatChangedFilesWithPrettierIfAvailable(tree, options) {
|
|
|
19
20
|
if (process.env.NX_SKIP_FORMAT === 'true') {
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
|
-
const
|
|
23
|
+
const excludedPaths = options?.excludePaths
|
|
24
|
+
? new Set(Array.from(options.excludePaths, path_1.normalizePath))
|
|
25
|
+
: undefined;
|
|
26
|
+
const files = new Set(tree
|
|
27
|
+
.listChanges()
|
|
28
|
+
.filter((file) => file.type !== 'DELETE' &&
|
|
29
|
+
!excludedPaths?.has((0, path_1.normalizePath)(file.path))));
|
|
23
30
|
const results = await formatFilesWithPrettierIfAvailable(Array.from(files), tree.root, options);
|
|
24
31
|
for (const [path, content] of results) {
|
|
25
32
|
tree.write(path, content);
|
|
@@ -28,7 +35,7 @@ async function formatChangedFilesWithPrettierIfAvailable(tree, options) {
|
|
|
28
35
|
async function formatFilesWithPrettierIfAvailable(files, root, options) {
|
|
29
36
|
const results = new Map();
|
|
30
37
|
// Check here as well for direct callers of this function
|
|
31
|
-
if (process.env.NX_SKIP_FORMAT === 'true') {
|
|
38
|
+
if (process.env.NX_SKIP_FORMAT === 'true' || files.length === 0) {
|
|
32
39
|
return results;
|
|
33
40
|
}
|
|
34
41
|
let prettier;
|
|
@@ -19,12 +19,14 @@ export interface Tree {
|
|
|
19
19
|
*/
|
|
20
20
|
root: string;
|
|
21
21
|
/**
|
|
22
|
-
* Read the contents of a file.
|
|
22
|
+
* Read the contents of a file. `null` when the file does not exist - an
|
|
23
|
+
* empty file reads as empty, not as missing.
|
|
23
24
|
* @param filePath A path to a file.
|
|
24
25
|
*/
|
|
25
26
|
read(filePath: string): Buffer | null;
|
|
26
27
|
/**
|
|
27
|
-
* Read the contents of a file as string.
|
|
28
|
+
* Read the contents of a file as string. `null` when the file does not
|
|
29
|
+
* exist - an empty file reads as `''`, not as missing.
|
|
28
30
|
* @param filePath A path to a file.
|
|
29
31
|
* @param encoding the encoding for the result
|
|
30
32
|
*/
|
|
@@ -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
|
+
```
|