@nx/devkit 24.0.0-canary.20261019-c4bb923 → 24.0.0-canary.20261020-e7ffd79
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/internal.d.ts +3 -2
- package/dist/internal.js +17 -7
- package/dist/src/generators/add-ready-when-signal.d.ts +17 -0
- package/dist/src/generators/add-ready-when-signal.js +81 -0
- package/dist/src/generators/plugin-migrations/conversion-warnings.d.ts +5 -0
- package/dist/src/generators/plugin-migrations/conversion-warnings.js +13 -0
- package/dist/src/generators/plugin-migrations/executor-to-plugin-migrator.d.ts +6 -0
- package/dist/src/generators/plugin-migrations/executor-to-plugin-migrator.js +58 -3
- package/dist/src/utils/readiness.d.ts +71 -0
- package/dist/src/utils/readiness.js +259 -0
- package/package.json +2 -2
package/dist/internal.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { signalToCode, createProjectRootMappingsFromProjectConfigurations, PluginCache, safeWriteFileCache, emitPluginWorkerLog, resolveImplementation, resolveSchema, ImplementationResolutionError, SchemaResolutionError, resolvePrompt, PromptResolutionError, acknowledgeBuildScripts, acknowledgeDeclaredBuildScripts, createCliOptions, createOverrides, isAiAgent, getCatalogManager, getDaemonClientEnvGeneration, getAppliedDaemonClientEnv, applyDaemonEnvFromClient, getGraphTimeDotEnvForTask, hashDaemonClientEnv, resolveStartupHost, } from 'nx/src/devkit-internals';
|
|
2
2
|
export { detectFormatterInTree, prettierConfigFiles, oxfmtConfigFiles, } from 'nx/src/devkit-internals';
|
|
3
3
|
export type { FormatterType } from 'nx/src/devkit-internals';
|
|
4
|
+
export { addReadyWhenSignalToTargets, readApplicableTargetDefaults, } from './src/generators/add-ready-when-signal';
|
|
4
5
|
export { determineArtifactNameAndDirectoryOptions, getRelativeCwd, type FileExtensionType, } from './src/generators/artifact-name-and-directory-utils';
|
|
5
6
|
export { getE2EWebServerInfo, type E2EWebServerDetails, } from './src/generators/e2e-web-server-info-utils';
|
|
6
7
|
export { forEachExecutorOptions } from './src/generators/executor-options-utils';
|
|
@@ -22,13 +23,13 @@ export { isRequireEsmRaceError, retryOnRequireEsmRace, } from './src/utils/requi
|
|
|
22
23
|
export { findPluginForConfigFile } from './src/utils/find-plugin-for-config-file';
|
|
23
24
|
export { getNamedInputs } from './src/utils/get-named-inputs';
|
|
24
25
|
export { parseNxDirectives } from './src/utils/nx-directives';
|
|
26
|
+
export { getForwardedArgs, getListeningUrl, getReadyCheckReadyWhen, getServerAddress, parseCacArgs, parseCommanderArgs, runReadyCheck, type ServerAddress, } from './src/utils/readiness';
|
|
25
27
|
export { applyTestFileDirectives } from './src/utils/test-file-directives';
|
|
26
28
|
export { hasIgnoreServerInputsDirective } from './src/utils/ignore-server-inputs-directive';
|
|
27
29
|
export { logShowProjectCommand } from './src/utils/log-show-project-command';
|
|
28
30
|
export { eachValueFrom } from './src/utils/rxjs-for-await';
|
|
29
31
|
export { checkAndCleanWithSemver } from './src/utils/semver';
|
|
30
|
-
export { splitShellArgs } from './src/utils/split-shell-args';
|
|
31
32
|
export { camelize, capitalize, classify, dasherize, } from './src/utils/string-utils';
|
|
32
|
-
export { runCommandsExecutor, type TaskResult, type Agent, type BatchExecutorTaskResult, BatchFunctionRunner, type BatchResults, type CLIErrorMessageConfig, type CLINoteMessageConfig, type CLISuccessMessageConfig, type CLIWarnMessageConfig, Cache, type CachedResult, type Change, type ChangedFile, CompositeLifeCycle, DeletedFileChange, confirmationPrompt, type FileChange, type FileDataDependency, type FileMapCache, type FinalConfigForProject, FsTree, type GeneratorInformation, type InputDefinition, type JsonInput, LARGE_BUFFER, type LifeCycle, LockFileChange, NX_PREFIX, type NormalizedTargetDependencyConfig, type NxCloudOnBoardingStatus, type NxReleaseVersionConfiguration, type PackageJson, type PackageJsonDependencySection, type PackageManagerCommands, type ProjectRootMappings, RemoteCacheV2, type RunCommandsOptions, SyncError, type SyncGeneratorResult, TEN_MEGABYTES, TargetProjectLocator, type TaskMetadata, type TaskStatus, type TaskWithCachedResult, type TasksRunner, type UnregisterCallback, WholeFileChange, buildPackageJsonPatterns, buildPackageJsonWorkspacesMatcher, buildProjectGraphAndSourceMapsWithoutDaemon, calculateFileChanges, calculateReverseDeps, codeFrameColumns, combineGlobPatterns, connectToNxCloud, createDirectory, createLockFile, createNxCloudOnboardingURL, createNxCloudOnboardingURLForWelcomeApp, createPackageJson, createProjectGraphAndSourceMapsAsync, createProjectRootMappings, createRunManyDynamicOutputRenderer, createTargetDefaultsResults, createTaskId, daemonClient, deduceDefaultBase, defaultFileRead, deriveGroupNameFromTarget, directoryExists, dropEmptyPeerDependencySections, expandDependencyConfigSyntaxSugar, expandInitiatingTasksThroughNoop, expandWildcardTargetConfiguration, fileDataDepTarget, fileDataDepType, fileExists, filterUsingGlobPatterns, findAllProjectNodeDependencies, findInstalledPlugins, findMatchingConfigFiles, findMatchingProjects, findMatchingTargetNames, findProjectForPath, findProjectsNpmDependencies, forceRegisterEsmLoader, generatePrunedDeployOutput, getCliPath, getCustomHasher, getDependencyConfigs, getEnvFilesForTask, getEnvPathsForTask, getExecutorForTask, getExecutorInformation, getExecutorNameForTask, getFilesInDirectoryUsingContext, getGeneratorInformation, getGlobPatternsFromPackageManagerWorkspaces, getLastValueFromAsyncIterableIterator, getLatestCommitSha, getLockFileName, getNxCloudAppOnBoardingUrl, getNxCloudUrl, getNxRequirePaths, getOutputs, getPrintableCommandArgsForTask, getRelativeProjectJsonSchemaPath, getSerializedArgsForTask, getSourceDirOfDependentProjects, getTargetConfigurationForTask, getTargetInputs, getUnparsedOverrideArgs, getWorkspacePackagesFromGraph, globWithWorkspaceContext, handleImport, handleProjectGraphError, hashFile, hashObject, hashWithWorkspaceContext, interpolate, isBuiltinModuleImport, isCI, isCacheableTask, isDeletedFileChange, isLockFileChange, isNpmProject, isNxCloudUsed, isProjectGraphExternalNode, isProjectGraphProjectNode, isRelativePath, isWholeFileChange, killChildOnHostExit, killProcessTreeGraceful, loadTsFile, mergeTargetConfigurations, movePeerDependencyToDependencies, multiselectPrompt, normalizeDependencyConfigDefinition, normalizeDependencyConfigProjects, normalizeTargetDependencyWithStringProjects, nxVersion, orange, parseExecutor, parseVersionFromPackageManagerField, preventRecursionInGraphConstruction, quoteShellArg, readCachedProjectConfiguration, readFileIfExisting, readFileMapCache, readModulePackageJson, readNxJsonFromDisk, readNxMigrateConfig, readPackageJson, readProjectAndTargetFromTargetString, registerTsConfigPaths, registerTsProject, relocatePrunedLocalPathSpec, removeTasksFromTaskGraph, requireWithTsconfigFallback, resetWorkspaceContext, resolveCommandSyntacticSugar, runNxSync, safeExecFileSync, safeSpawn, selectPrompt, setWorkspaceRoot, setupAiAgentsGenerator, setupWorkspaceContext, shouldStreamOutput, toNewFormat, toOldFormat, transformLegacyOutputs, textPrompt, unparse, validateOutputs, warnUnshippableLocalPathSpec, workspaceDataDirectory, workspaceRootInner, } from 'nx/src/devkit-internals';
|
|
33
|
+
export { runCommandsExecutor, type TaskResult, type Agent, type BatchExecutorTaskResult, BatchFunctionRunner, type BatchResults, type CLIErrorMessageConfig, type CLINoteMessageConfig, type CLISuccessMessageConfig, type CLIWarnMessageConfig, Cache, type CachedResult, type Change, type ChangedFile, CompositeLifeCycle, DeletedFileChange, confirmationPrompt, type FileChange, type FileDataDependency, type FileMapCache, type FinalConfigForProject, FsTree, type GeneratorInformation, type InputDefinition, type JsonInput, LARGE_BUFFER, type LifeCycle, LockFileChange, NX_PREFIX, type NormalizedTargetDependencyConfig, type NxCloudOnBoardingStatus, type NxReleaseVersionConfiguration, type PackageJson, type PackageJsonDependencySection, type PackageManagerCommands, type ProjectRootMappings, RemoteCacheV2, type RunCommandsOptions, SyncError, type SyncGeneratorResult, TEN_MEGABYTES, TargetProjectLocator, type TaskMetadata, type TaskStatus, type TaskWithCachedResult, type TasksRunner, type UnregisterCallback, WholeFileChange, buildPackageJsonPatterns, buildPackageJsonWorkspacesMatcher, buildProjectGraphAndSourceMapsWithoutDaemon, calculateFileChanges, calculateReverseDeps, codeFrameColumns, combineGlobPatterns, connectToNxCloud, createDirectory, createLockFile, createNxCloudOnboardingURL, createNxCloudOnboardingURLForWelcomeApp, createPackageJson, createProjectGraphAndSourceMapsAsync, createProjectRootMappings, createRunManyDynamicOutputRenderer, createTargetDefaultsResults, createTaskId, daemonClient, deduceDefaultBase, defaultFileRead, deriveGroupNameFromTarget, directoryExists, dropEmptyPeerDependencySections, expandDependencyConfigSyntaxSugar, expandInitiatingTasksThroughNoop, expandWildcardTargetConfiguration, fileDataDepTarget, fileDataDepType, fileExists, filterUsingGlobPatterns, findAllProjectNodeDependencies, findInstalledPlugins, findMatchingConfigFiles, findMatchingProjects, findMatchingTargetNames, findProjectForPath, findProjectsNpmDependencies, forceRegisterEsmLoader, generatePrunedDeployOutput, getCliPath, getCustomHasher, getDependencyConfigs, getEnvFilesForTask, getEnvPathsForTask, getExecutorForTask, getExecutorInformation, getExecutorNameForTask, getFilesInDirectoryUsingContext, getGeneratorInformation, getGlobPatternsFromPackageManagerWorkspaces, getLastValueFromAsyncIterableIterator, getLatestCommitSha, getLockFileName, getNxCloudAppOnBoardingUrl, getNxCloudUrl, getNxRequirePaths, getOutputs, getPrintableCommandArgsForTask, getRelativeProjectJsonSchemaPath, getSerializedArgsForTask, getSourceDirOfDependentProjects, getTargetConfigurationForTask, getTargetInputs, getUnparsedOverrideArgs, getWorkspacePackagesFromGraph, globWithWorkspaceContext, handleImport, handleProjectGraphError, hashFile, hashObject, hashWithWorkspaceContext, interpolate, isBuiltinModuleImport, isCI, isCacheableTask, isDeletedFileChange, isLockFileChange, isNpmProject, isNxCloudUsed, isProjectGraphExternalNode, isProjectGraphProjectNode, isRelativePath, isWholeFileChange, killChildOnHostExit, killProcessTreeGraceful, loadTsFile, mergeTargetConfigurations, movePeerDependencyToDependencies, multiselectPrompt, normalizeDependencyConfigDefinition, normalizeDependencyConfigProjects, normalizeTargetDependencyWithStringProjects, nxVersion, orange, parseExecutor, parseVersionFromPackageManagerField, preventRecursionInGraphConstruction, quoteShellArg, readCachedProjectConfiguration, readFileIfExisting, readFileMapCache, readModulePackageJson, readNxJsonFromDisk, readNxMigrateConfig, readPackageJson, readProjectAndTargetFromTargetString, registerTsConfigPaths, registerTsProject, relocatePrunedLocalPathSpec, removeTasksFromTaskGraph, requireWithTsconfigFallback, resetWorkspaceContext, resolveCommandSyntacticSugar, resolveNxTokensInOptions, runNxSync, safeExecFileSync, safeSpawn, selectPrompt, setWorkspaceRoot, setupAiAgentsGenerator, setupWorkspaceContext, shouldStreamOutput, toNewFormat, toOldFormat, transformLegacyOutputs, textPrompt, unparse, validateOutputs, warnUnshippableLocalPathSpec, workspaceDataDirectory, workspaceRootInner, } from 'nx/src/devkit-internals';
|
|
33
34
|
export type { AfterAllProjectsVersioned } from 'nx/release';
|
|
34
35
|
export { migrateRemovedExecutors } from './src/generators/plugin-migrations/remove-executors';
|
package/dist/internal.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.migrateRemovedExecutors = exports.workspaceRootInner = exports.workspaceDataDirectory = exports.warnUnshippableLocalPathSpec = exports.validateOutputs = exports.unparse = exports.textPrompt = exports.transformLegacyOutputs = exports.toOldFormat = exports.toNewFormat = exports.shouldStreamOutput = exports.setupWorkspaceContext = exports.setupAiAgentsGenerator = exports.setWorkspaceRoot = exports.selectPrompt = exports.safeSpawn = exports.safeExecFileSync = exports.runNxSync = exports.resolveCommandSyntacticSugar = exports.resetWorkspaceContext = exports.requireWithTsconfigFallback = exports.removeTasksFromTaskGraph = exports.relocatePrunedLocalPathSpec = exports.registerTsProject = exports.registerTsConfigPaths = exports.readProjectAndTargetFromTargetString = void 0;
|
|
3
|
+
exports.updateTargetDefault = exports.readTargetDefaultsForTarget = exports.findTargetDefault = exports.addE2eCiTargetDefaults = exports.addBuildTargetDefaults = exports.isInteractive = exports.resolveImportPath = exports.ensureRootProjectName = exports.determineProjectNameAndRootOptions = exports.toProjectRelativePath = exports.deleteMatchingProperties = exports.processTargetOutputs = exports.NoTargetsToMigrateError = exports.migrateProjectExecutorsToPluginV1 = exports.migrateProjectExecutorsToPlugin = exports.openBatchConversionSession = exports.finalizeBatchConversion = exports.AggregatedLog = exports.forEachExecutorOptions = exports.getE2EWebServerInfo = exports.getRelativeCwd = exports.determineArtifactNameAndDirectoryOptions = exports.readApplicableTargetDefaults = exports.addReadyWhenSignalToTargets = exports.oxfmtConfigFiles = exports.prettierConfigFiles = exports.detectFormatterInTree = exports.resolveStartupHost = exports.hashDaemonClientEnv = exports.getGraphTimeDotEnvForTask = exports.applyDaemonEnvFromClient = exports.getAppliedDaemonClientEnv = exports.getDaemonClientEnvGeneration = exports.getCatalogManager = exports.isAiAgent = exports.createOverrides = exports.createCliOptions = exports.acknowledgeDeclaredBuildScripts = exports.acknowledgeBuildScripts = exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.createProjectRootMappingsFromProjectConfigurations = exports.signalToCode = void 0;
|
|
4
|
+
exports.TEN_MEGABYTES = exports.SyncError = exports.RemoteCacheV2 = exports.NX_PREFIX = exports.LockFileChange = exports.LARGE_BUFFER = exports.FsTree = exports.confirmationPrompt = exports.DeletedFileChange = exports.CompositeLifeCycle = exports.Cache = exports.BatchFunctionRunner = exports.runCommandsExecutor = exports.dasherize = exports.classify = exports.capitalize = exports.camelize = exports.checkAndCleanWithSemver = exports.eachValueFrom = exports.logShowProjectCommand = exports.hasIgnoreServerInputsDirective = exports.applyTestFileDirectives = exports.runReadyCheck = exports.parseCommanderArgs = exports.parseCacArgs = exports.getServerAddress = exports.getReadyCheckReadyWhen = exports.getListeningUrl = exports.getForwardedArgs = exports.parseNxDirectives = exports.getNamedInputs = exports.findPluginForConfigFile = exports.retryOnRequireEsmRace = exports.isRequireEsmRaceError = exports.clearRequireCache = exports.loadConfigFile = exports.calculateHashesForCreateNodes = exports.calculateHashForCreateNodes = exports.mapAsyncIterable = exports.combineAsyncIterables = exports.createAsyncIterable = exports.getSatisfyingInstalledPackageVersion = exports.getResolvedPackageVersion = exports.assertSupportedPackageVersion = exports.assertSupportedInstalledPackageVersion = exports.getInstalledPackageVersionFromTree = exports.getInstalledPackageVersion = exports.getDeclaredPackageVersion = exports.addPlugin = exports.upsertTargetDefault = void 0;
|
|
5
|
+
exports.getExecutorNameForTask = exports.getExecutorInformation = exports.getExecutorForTask = exports.getEnvPathsForTask = exports.getEnvFilesForTask = exports.getDependencyConfigs = exports.getCustomHasher = exports.getCliPath = exports.generatePrunedDeployOutput = exports.forceRegisterEsmLoader = exports.findProjectsNpmDependencies = exports.findProjectForPath = exports.findMatchingTargetNames = exports.findMatchingProjects = exports.findMatchingConfigFiles = exports.findInstalledPlugins = exports.findAllProjectNodeDependencies = exports.filterUsingGlobPatterns = exports.fileExists = exports.fileDataDepType = exports.fileDataDepTarget = exports.expandWildcardTargetConfiguration = exports.expandInitiatingTasksThroughNoop = exports.expandDependencyConfigSyntaxSugar = exports.dropEmptyPeerDependencySections = exports.directoryExists = exports.deriveGroupNameFromTarget = exports.defaultFileRead = exports.deduceDefaultBase = exports.daemonClient = exports.createTaskId = exports.createTargetDefaultsResults = exports.createRunManyDynamicOutputRenderer = exports.createProjectRootMappings = exports.createProjectGraphAndSourceMapsAsync = exports.createPackageJson = exports.createNxCloudOnboardingURLForWelcomeApp = exports.createNxCloudOnboardingURL = exports.createLockFile = exports.createDirectory = exports.connectToNxCloud = exports.combineGlobPatterns = exports.codeFrameColumns = exports.calculateReverseDeps = exports.calculateFileChanges = exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.buildPackageJsonWorkspacesMatcher = exports.buildPackageJsonPatterns = exports.WholeFileChange = exports.TargetProjectLocator = void 0;
|
|
6
|
+
exports.preventRecursionInGraphConstruction = exports.parseVersionFromPackageManagerField = exports.parseExecutor = exports.orange = exports.nxVersion = exports.normalizeTargetDependencyWithStringProjects = exports.normalizeDependencyConfigProjects = exports.normalizeDependencyConfigDefinition = exports.multiselectPrompt = exports.movePeerDependencyToDependencies = exports.mergeTargetConfigurations = exports.loadTsFile = exports.killProcessTreeGraceful = exports.killChildOnHostExit = exports.isWholeFileChange = exports.isRelativePath = exports.isProjectGraphProjectNode = exports.isProjectGraphExternalNode = exports.isNxCloudUsed = exports.isNpmProject = exports.isLockFileChange = exports.isDeletedFileChange = exports.isCacheableTask = exports.isCI = exports.isBuiltinModuleImport = exports.interpolate = exports.hashWithWorkspaceContext = exports.hashObject = exports.hashFile = exports.handleProjectGraphError = exports.handleImport = exports.globWithWorkspaceContext = exports.getWorkspacePackagesFromGraph = exports.getUnparsedOverrideArgs = exports.getTargetInputs = exports.getTargetConfigurationForTask = exports.getSourceDirOfDependentProjects = exports.getSerializedArgsForTask = exports.getRelativeProjectJsonSchemaPath = exports.getPrintableCommandArgsForTask = exports.getOutputs = exports.getNxRequirePaths = exports.getNxCloudUrl = exports.getNxCloudAppOnBoardingUrl = exports.getLockFileName = exports.getLatestCommitSha = exports.getLastValueFromAsyncIterableIterator = exports.getGlobPatternsFromPackageManagerWorkspaces = exports.getGeneratorInformation = exports.getFilesInDirectoryUsingContext = void 0;
|
|
7
|
+
exports.migrateRemovedExecutors = exports.workspaceRootInner = exports.workspaceDataDirectory = exports.warnUnshippableLocalPathSpec = exports.validateOutputs = exports.unparse = exports.textPrompt = exports.transformLegacyOutputs = exports.toOldFormat = exports.toNewFormat = exports.shouldStreamOutput = exports.setupWorkspaceContext = exports.setupAiAgentsGenerator = exports.setWorkspaceRoot = exports.selectPrompt = exports.safeSpawn = exports.safeExecFileSync = exports.runNxSync = exports.resolveNxTokensInOptions = exports.resolveCommandSyntacticSugar = exports.resetWorkspaceContext = exports.requireWithTsconfigFallback = exports.removeTasksFromTaskGraph = exports.relocatePrunedLocalPathSpec = exports.registerTsProject = exports.registerTsConfigPaths = exports.readProjectAndTargetFromTargetString = exports.readPackageJson = exports.readNxMigrateConfig = exports.readNxJsonFromDisk = exports.readModulePackageJson = exports.readFileMapCache = exports.readFileIfExisting = exports.readCachedProjectConfiguration = exports.quoteShellArg = void 0;
|
|
8
8
|
var devkit_internals_1 = require("nx/src/devkit-internals");
|
|
9
9
|
Object.defineProperty(exports, "signalToCode", { enumerable: true, get: function () { return devkit_internals_1.signalToCode; } });
|
|
10
10
|
Object.defineProperty(exports, "createProjectRootMappingsFromProjectConfigurations", { enumerable: true, get: function () { return devkit_internals_1.createProjectRootMappingsFromProjectConfigurations; } });
|
|
@@ -45,6 +45,9 @@ Object.defineProperty(exports, "detectFormatterInTree", { enumerable: true, get:
|
|
|
45
45
|
Object.defineProperty(exports, "prettierConfigFiles", { enumerable: true, get: function () { return devkit_internals_2.prettierConfigFiles; } });
|
|
46
46
|
Object.defineProperty(exports, "oxfmtConfigFiles", { enumerable: true, get: function () { return devkit_internals_2.oxfmtConfigFiles; } });
|
|
47
47
|
// Generators
|
|
48
|
+
var add_ready_when_signal_1 = require("./src/generators/add-ready-when-signal");
|
|
49
|
+
Object.defineProperty(exports, "addReadyWhenSignalToTargets", { enumerable: true, get: function () { return add_ready_when_signal_1.addReadyWhenSignalToTargets; } });
|
|
50
|
+
Object.defineProperty(exports, "readApplicableTargetDefaults", { enumerable: true, get: function () { return add_ready_when_signal_1.readApplicableTargetDefaults; } });
|
|
48
51
|
var artifact_name_and_directory_utils_1 = require("./src/generators/artifact-name-and-directory-utils");
|
|
49
52
|
Object.defineProperty(exports, "determineArtifactNameAndDirectoryOptions", { enumerable: true, get: function () { return artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions; } });
|
|
50
53
|
Object.defineProperty(exports, "getRelativeCwd", { enumerable: true, get: function () { return artifact_name_and_directory_utils_1.getRelativeCwd; } });
|
|
@@ -110,6 +113,14 @@ var get_named_inputs_1 = require("./src/utils/get-named-inputs");
|
|
|
110
113
|
Object.defineProperty(exports, "getNamedInputs", { enumerable: true, get: function () { return get_named_inputs_1.getNamedInputs; } });
|
|
111
114
|
var nx_directives_1 = require("./src/utils/nx-directives");
|
|
112
115
|
Object.defineProperty(exports, "parseNxDirectives", { enumerable: true, get: function () { return nx_directives_1.parseNxDirectives; } });
|
|
116
|
+
var readiness_1 = require("./src/utils/readiness");
|
|
117
|
+
Object.defineProperty(exports, "getForwardedArgs", { enumerable: true, get: function () { return readiness_1.getForwardedArgs; } });
|
|
118
|
+
Object.defineProperty(exports, "getListeningUrl", { enumerable: true, get: function () { return readiness_1.getListeningUrl; } });
|
|
119
|
+
Object.defineProperty(exports, "getReadyCheckReadyWhen", { enumerable: true, get: function () { return readiness_1.getReadyCheckReadyWhen; } });
|
|
120
|
+
Object.defineProperty(exports, "getServerAddress", { enumerable: true, get: function () { return readiness_1.getServerAddress; } });
|
|
121
|
+
Object.defineProperty(exports, "parseCacArgs", { enumerable: true, get: function () { return readiness_1.parseCacArgs; } });
|
|
122
|
+
Object.defineProperty(exports, "parseCommanderArgs", { enumerable: true, get: function () { return readiness_1.parseCommanderArgs; } });
|
|
123
|
+
Object.defineProperty(exports, "runReadyCheck", { enumerable: true, get: function () { return readiness_1.runReadyCheck; } });
|
|
113
124
|
var test_file_directives_1 = require("./src/utils/test-file-directives");
|
|
114
125
|
Object.defineProperty(exports, "applyTestFileDirectives", { enumerable: true, get: function () { return test_file_directives_1.applyTestFileDirectives; } });
|
|
115
126
|
var ignore_server_inputs_directive_1 = require("./src/utils/ignore-server-inputs-directive");
|
|
@@ -120,8 +131,6 @@ var rxjs_for_await_1 = require("./src/utils/rxjs-for-await");
|
|
|
120
131
|
Object.defineProperty(exports, "eachValueFrom", { enumerable: true, get: function () { return rxjs_for_await_1.eachValueFrom; } });
|
|
121
132
|
var semver_1 = require("./src/utils/semver");
|
|
122
133
|
Object.defineProperty(exports, "checkAndCleanWithSemver", { enumerable: true, get: function () { return semver_1.checkAndCleanWithSemver; } });
|
|
123
|
-
var split_shell_args_1 = require("./src/utils/split-shell-args");
|
|
124
|
-
Object.defineProperty(exports, "splitShellArgs", { enumerable: true, get: function () { return split_shell_args_1.splitShellArgs; } });
|
|
125
134
|
var string_utils_1 = require("./src/utils/string-utils");
|
|
126
135
|
Object.defineProperty(exports, "camelize", { enumerable: true, get: function () { return string_utils_1.camelize; } });
|
|
127
136
|
Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return string_utils_1.capitalize; } });
|
|
@@ -258,6 +267,7 @@ Object.defineProperty(exports, "removeTasksFromTaskGraph", { enumerable: true, g
|
|
|
258
267
|
Object.defineProperty(exports, "requireWithTsconfigFallback", { enumerable: true, get: function () { return devkit_internals_3.requireWithTsconfigFallback; } });
|
|
259
268
|
Object.defineProperty(exports, "resetWorkspaceContext", { enumerable: true, get: function () { return devkit_internals_3.resetWorkspaceContext; } });
|
|
260
269
|
Object.defineProperty(exports, "resolveCommandSyntacticSugar", { enumerable: true, get: function () { return devkit_internals_3.resolveCommandSyntacticSugar; } });
|
|
270
|
+
Object.defineProperty(exports, "resolveNxTokensInOptions", { enumerable: true, get: function () { return devkit_internals_3.resolveNxTokensInOptions; } });
|
|
261
271
|
Object.defineProperty(exports, "runNxSync", { enumerable: true, get: function () { return devkit_internals_3.runNxSync; } });
|
|
262
272
|
Object.defineProperty(exports, "safeExecFileSync", { enumerable: true, get: function () { return devkit_internals_3.safeExecFileSync; } });
|
|
263
273
|
Object.defineProperty(exports, "safeSpawn", { enumerable: true, get: function () { return devkit_internals_3.safeSpawn; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ProjectGraphProjectNode, type TargetConfiguration, type TargetDefaults, type Tree } from 'nx/src/devkit-exports';
|
|
2
|
+
/**
|
|
3
|
+
* Migration body that sets `readyWhen: { signal: true }` on the targets running
|
|
4
|
+
* one of `executors`. A target is skipped when it, or the `targetDefaults` that
|
|
5
|
+
* apply to it, already set `readyWhen`, or when its own `continuous`, else the
|
|
6
|
+
* one from `targetDefaults`, is `false`. `onAdded` gets each target it sets it
|
|
7
|
+
* on, with the `targetDefaults` that apply to it. Returning `false` from it
|
|
8
|
+
* leaves that target unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export declare function addReadyWhenSignalToTargets(tree: Tree, executors: readonly string[], onAdded?: (target: TargetConfiguration, projectName: string, defaults: Partial<TargetConfiguration> | null) => boolean | void): Promise<{
|
|
11
|
+
skipAgentic: true;
|
|
12
|
+
} | void>;
|
|
13
|
+
/**
|
|
14
|
+
* The `targetDefaults` Nx applies to a target, which leaves out the entries
|
|
15
|
+
* that run another executor or a command.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readApplicableTargetDefaults(targetName: string, executor: string | undefined, targetDefaults: TargetDefaults | undefined, projectName: string, projectNode: ProjectGraphProjectNode): Partial<TargetConfiguration> | null;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addReadyWhenSignalToTargets = addReadyWhenSignalToTargets;
|
|
4
|
+
exports.readApplicableTargetDefaults = readApplicableTargetDefaults;
|
|
5
|
+
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
6
|
+
const format_files_1 = require("./format-files");
|
|
7
|
+
const target_defaults_utils_1 = require("./target-defaults-utils");
|
|
8
|
+
/**
|
|
9
|
+
* Migration body that sets `readyWhen: { signal: true }` on the targets running
|
|
10
|
+
* one of `executors`. A target is skipped when it, or the `targetDefaults` that
|
|
11
|
+
* apply to it, already set `readyWhen`, or when its own `continuous`, else the
|
|
12
|
+
* one from `targetDefaults`, is `false`. `onAdded` gets each target it sets it
|
|
13
|
+
* on, with the `targetDefaults` that apply to it. Returning `false` from it
|
|
14
|
+
* leaves that target unchanged.
|
|
15
|
+
*/
|
|
16
|
+
async function addReadyWhenSignalToTargets(tree, executors, onAdded) {
|
|
17
|
+
const targetDefaults = (0, devkit_exports_1.readNxJson)(tree)?.targetDefaults;
|
|
18
|
+
let changed = false;
|
|
19
|
+
for (const [projectName, project] of (0, devkit_exports_1.getProjects)(tree)) {
|
|
20
|
+
const projectNode = {
|
|
21
|
+
name: projectName,
|
|
22
|
+
type: 'lib',
|
|
23
|
+
data: { root: project.root, tags: project.tags },
|
|
24
|
+
};
|
|
25
|
+
let projectChanged = false;
|
|
26
|
+
for (const [targetName, target] of Object.entries(project.targets ?? {})) {
|
|
27
|
+
if (target.command || target.readyWhen !== undefined) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const defaults = readApplicableTargetDefaults(targetName, target.executor, targetDefaults, projectName, projectNode);
|
|
31
|
+
const executor = target.executor ?? (defaults?.command ? undefined : defaults?.executor);
|
|
32
|
+
if (!executor ||
|
|
33
|
+
!executors.includes(executor) ||
|
|
34
|
+
(target.continuous ?? defaults?.continuous) === false ||
|
|
35
|
+
defaults?.readyWhen !== undefined) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
target.readyWhen = { signal: true };
|
|
39
|
+
if (onAdded?.(target, projectName, defaults) === false) {
|
|
40
|
+
delete target.readyWhen;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
projectChanged = true;
|
|
44
|
+
}
|
|
45
|
+
if (projectChanged) {
|
|
46
|
+
(0, devkit_exports_1.updateProjectConfiguration)(tree, projectName, project);
|
|
47
|
+
changed = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!changed) {
|
|
51
|
+
return { skipAgentic: true };
|
|
52
|
+
}
|
|
53
|
+
await (0, format_files_1.formatFiles)(tree);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The `targetDefaults` Nx applies to a target, which leaves out the entries
|
|
57
|
+
* that run another executor or a command.
|
|
58
|
+
*/
|
|
59
|
+
function readApplicableTargetDefaults(targetName, executor, targetDefaults, projectName, projectNode) {
|
|
60
|
+
if (!targetDefaults) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
let compatibleDefaults = targetDefaults;
|
|
64
|
+
if (executor) {
|
|
65
|
+
// Nx selects the key first, then drops the entries that run something else.
|
|
66
|
+
// A dropped entry keeps its filter so that its key still wins over the rest.
|
|
67
|
+
compatibleDefaults = {};
|
|
68
|
+
for (const [key, value] of Object.entries(targetDefaults)) {
|
|
69
|
+
const entries = Array.isArray(value)
|
|
70
|
+
? value
|
|
71
|
+
: [value];
|
|
72
|
+
compatibleDefaults[key] = entries.map((entry) => entry.command || (entry.executor && entry.executor !== executor)
|
|
73
|
+
? { filter: entry.filter }
|
|
74
|
+
: entry);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return (0, target_defaults_utils_1.readTargetDefaultsForTarget)(targetName, compatibleDefaults, executor, {
|
|
78
|
+
projectName,
|
|
79
|
+
projectNode,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -8,6 +8,11 @@ import type { TargetConfiguration } from 'nx/src/devkit-exports';
|
|
|
8
8
|
export type PackageJsonIdentitySource = 'script' | 'nxTargets' | 'unparseable';
|
|
9
9
|
/** A migrated target was left untouched because package.json authors its identity. */
|
|
10
10
|
export declare function keptPreMigrationTargetWarning(targetName: string, projectName: string, source: PackageJsonIdentitySource): string;
|
|
11
|
+
/** The plugin inferred no target for a migrated project, so it was not converted. */
|
|
12
|
+
export declare function uninferredTargetWarning(targetName: string, projectName: string, root: string, rootInferred: boolean, errors: Array<{
|
|
13
|
+
file: string | null;
|
|
14
|
+
message: string;
|
|
15
|
+
}>): string;
|
|
11
16
|
/** A target's centralization was skipped before writing anything. */
|
|
12
17
|
export declare function retainedResidualsWarning(targetNames: string[], reason: string): string;
|
|
13
18
|
/** Projects whose target identity lives outside the plugin were not hoisted. */
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.keptPreMigrationTargetWarning = keptPreMigrationTargetWarning;
|
|
9
|
+
exports.uninferredTargetWarning = uninferredTargetWarning;
|
|
9
10
|
exports.retainedResidualsWarning = retainedResidualsWarning;
|
|
10
11
|
exports.excludedProjectsWarning = excludedProjectsWarning;
|
|
11
12
|
exports.revertedTargetsWarning = revertedTargetsWarning;
|
|
@@ -26,6 +27,18 @@ function withCauses(errors) {
|
|
|
26
27
|
? ` The verification pass reported errors: ${errors.join('; ')}`
|
|
27
28
|
: '';
|
|
28
29
|
}
|
|
30
|
+
/** The plugin inferred no target for a migrated project, so it was not converted. */
|
|
31
|
+
function uninferredTargetWarning(targetName, projectName, root, rootInferred, errors) {
|
|
32
|
+
const cause = rootInferred
|
|
33
|
+
? `the plugin inferred the project at ${root} without a "${targetName}" target. Check the plugin options`
|
|
34
|
+
: errors.length > 0
|
|
35
|
+
? `the plugin failed to infer it: ${[
|
|
36
|
+
// Each inference option set reports the same failure again.
|
|
37
|
+
...new Set(errors.map(({ file, message }) => file ? `${file}: ${message}` : message)),
|
|
38
|
+
].join('; ')}. Fix the error`
|
|
39
|
+
: `the plugin found no config file it detects in ${root}. Rename the config file to one the plugin detects`;
|
|
40
|
+
return `convert-to-inferred left target "${targetName}" in project "${projectName}" on its executor because ${cause}, then rerun the migration to convert it.`;
|
|
41
|
+
}
|
|
29
42
|
/** A target's centralization was skipped before writing anything. */
|
|
30
43
|
function retainedResidualsWarning(targetNames, reason) {
|
|
31
44
|
return `convert-to-inferred retained full per-project configuration for target(s) ${targetNames.join(', ')} because ${reason}; no configuration was lost, but shared configuration remains duplicated.`;
|
|
@@ -227,6 +227,7 @@ export declare function inferOncePerOptionSet<T>(tree: Tree, pluginPath: string,
|
|
|
227
227
|
rawMatchedConfigFiles: string[];
|
|
228
228
|
inferredExecutors: Set<string>;
|
|
229
229
|
inferredRoots: Set<string>;
|
|
230
|
+
createNodesErrors: CreateNodesFileError[];
|
|
230
231
|
}>;
|
|
231
232
|
/**
|
|
232
233
|
* The set of project roots a generated `include` list scopes to, or `undefined`
|
|
@@ -276,4 +277,9 @@ export declare function harvestConfigurationErrors(e: ProjectConfigurationsError
|
|
|
276
277
|
* migrated-root sets hold.
|
|
277
278
|
*/
|
|
278
279
|
export declare function buildOwnerRootByPath(graphRoots: Iterable<string>, inferredRoots: Iterable<string>): Map<string, string>;
|
|
280
|
+
interface CreateNodesFileError {
|
|
281
|
+
/** null when the plugin failed as a whole rather than on one file. */
|
|
282
|
+
file: string | null;
|
|
283
|
+
message: string;
|
|
284
|
+
}
|
|
279
285
|
export {};
|
|
@@ -991,6 +991,7 @@ async function inferOncePerOptionSet(tree, pluginPath, createNodes, createNodesV
|
|
|
991
991
|
const inferredRoots = new Set();
|
|
992
992
|
const erroredConfigFiles = new Set();
|
|
993
993
|
const inferredExecutors = new Set();
|
|
994
|
+
const createNodesErrors = [];
|
|
994
995
|
if (scope.optionSetGroups.length === 0) {
|
|
995
996
|
return {
|
|
996
997
|
inferredTargetsByOptionSet,
|
|
@@ -999,6 +1000,7 @@ async function inferOncePerOptionSet(tree, pluginPath, createNodes, createNodesV
|
|
|
999
1000
|
erroredConfigFiles: [],
|
|
1000
1001
|
inferredExecutors,
|
|
1001
1002
|
inferredRoots,
|
|
1003
|
+
createNodesErrors,
|
|
1002
1004
|
};
|
|
1003
1005
|
}
|
|
1004
1006
|
global.NX_GRAPH_CREATION = true;
|
|
@@ -1006,10 +1008,11 @@ async function inferOncePerOptionSet(tree, pluginPath, createNodes, createNodesV
|
|
|
1006
1008
|
for (const group of scope.optionSetGroups) {
|
|
1007
1009
|
const inferredByRoot = new Map();
|
|
1008
1010
|
inferredTargetsByOptionSet.set(group.id, inferredByRoot);
|
|
1009
|
-
const { result, erroredConfigFiles: groupErroredConfigFiles } = await getCreateNodesResultsForPlugin(tree, { plugin: pluginPath, options: group.options }, pluginPath, createNodes, createNodesV2, nxJson);
|
|
1011
|
+
const { result, erroredConfigFiles: groupErroredConfigFiles, createNodesErrors: groupCreateNodesErrors, } = await getCreateNodesResultsForPlugin(tree, { plugin: pluginPath, options: group.options }, pluginPath, createNodes, createNodesV2, nxJson);
|
|
1010
1012
|
for (const file of groupErroredConfigFiles) {
|
|
1011
1013
|
erroredConfigFiles.add(file);
|
|
1012
1014
|
}
|
|
1015
|
+
createNodesErrors.push(...groupCreateNodesErrors);
|
|
1013
1016
|
// The plugin's glob pattern is option-independent, so every option set
|
|
1014
1017
|
// matches the same config files; union defensively.
|
|
1015
1018
|
for (const file of result?.matchingProjectFiles ?? []) {
|
|
@@ -1084,6 +1087,7 @@ async function inferOncePerOptionSet(tree, pluginPath, createNodes, createNodesV
|
|
|
1084
1087
|
erroredConfigFiles: [...erroredConfigFiles],
|
|
1085
1088
|
inferredExecutors,
|
|
1086
1089
|
inferredRoots,
|
|
1090
|
+
createNodesErrors,
|
|
1087
1091
|
};
|
|
1088
1092
|
}
|
|
1089
1093
|
/**
|
|
@@ -1554,7 +1558,11 @@ async function migrateProjects(tree, projectGraph, pluginPath, createNodes, crea
|
|
|
1554
1558
|
const projectConfigsByName = (0, devkit_exports_1.getProjects)(tree);
|
|
1555
1559
|
// Phase 1: Infer (once per distinct option set) for the whole workspace.
|
|
1556
1560
|
const nxJson = (0, devkit_exports_1.readNxJson)(tree);
|
|
1557
|
-
const { inferredTargetsByOptionSet, matchedConfigFiles, erroredConfigFiles: erroredConfigFilesFromInference, rawMatchedConfigFiles, inferredExecutors, inferredRoots, } = await inferOncePerOptionSet(tree, pluginPath, createNodes, createNodesV2, nxJson, scope);
|
|
1561
|
+
const { inferredTargetsByOptionSet, matchedConfigFiles, erroredConfigFiles: erroredConfigFilesFromInference, rawMatchedConfigFiles, inferredExecutors, inferredRoots, createNodesErrors, } = await inferOncePerOptionSet(tree, pluginPath, createNodes, createNodesV2, nxJson, scope);
|
|
1562
|
+
// Single-project mode keeps throwing, like its skip filters do.
|
|
1563
|
+
if (!specificProjectToMigrate) {
|
|
1564
|
+
dropUninferredTargets(scope, projectGraph, inferredTargetsByOptionSet, inferredRoots, createNodesErrors, logger ?? devkit_exports_1.logger);
|
|
1565
|
+
}
|
|
1558
1566
|
// Phase 2: Per-project residual (in-memory, no re-inference). Also captures
|
|
1559
1567
|
// `baselineFinal` (the equivalence oracle consumed in Phase 4).
|
|
1560
1568
|
const residualByProject = await computeResidualByProject(tree, projectGraph, scope, inferredTargetsByOptionSet, nxJson, projectConfigsByName);
|
|
@@ -1713,9 +1721,46 @@ rawMatchedConfigFiles) {
|
|
|
1713
1721
|
spinner.updateText(`Migrations done`);
|
|
1714
1722
|
(0, devkit_exports_1.updateNxJson)(tree, nxJson);
|
|
1715
1723
|
}
|
|
1724
|
+
/**
|
|
1725
|
+
* One project the plugin cannot infer (a config file it does not match or that
|
|
1726
|
+
* fails to load) must not block converting the others. Its targets keep their
|
|
1727
|
+
* executor and are named in a warning.
|
|
1728
|
+
*/
|
|
1729
|
+
function dropUninferredTargets(scope, projectGraph, inferredTargetsByOptionSet, inferredRoots, createNodesErrors, log) {
|
|
1730
|
+
const ownerRootByPath = buildOwnerRootByPath(Object.values(projectGraph.nodes).map((node) => node.data.root), inferredRoots);
|
|
1731
|
+
const keptProjects = new Set();
|
|
1732
|
+
for (const executorScope of scope.executorScopes) {
|
|
1733
|
+
for (const [targetName, projectNames] of executorScope.targetAndProjects) {
|
|
1734
|
+
const optionSetId = executorScope.inferenceOptionSetIdsByTarget.get(targetName);
|
|
1735
|
+
for (const projectName of projectNames) {
|
|
1736
|
+
const root = projectGraph.nodes[projectName].data.root;
|
|
1737
|
+
if (inferredTargetsByOptionSet
|
|
1738
|
+
.get(optionSetId)
|
|
1739
|
+
?.get(root)
|
|
1740
|
+
?.has(targetName)) {
|
|
1741
|
+
keptProjects.add(projectName);
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
projectNames.delete(projectName);
|
|
1745
|
+
log.warn((0, conversion_warnings_1.uninferredTargetWarning)(targetName, projectName, root, inferredRoots.has(root), createNodesErrors.filter(({ file }) => file === null ||
|
|
1746
|
+
(0, devkit_internals_1.findProjectForPath)(file, ownerRootByPath) === root)));
|
|
1747
|
+
}
|
|
1748
|
+
if (projectNames.size === 0) {
|
|
1749
|
+
executorScope.targetAndProjects.delete(targetName);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
scope.executorScopes = scope.executorScopes.filter((executorScope) => executorScope.targetAndProjects.size > 0);
|
|
1754
|
+
for (const projectName of scope.pluginOptionsByProject.keys()) {
|
|
1755
|
+
if (!keptProjects.has(projectName)) {
|
|
1756
|
+
scope.pluginOptionsByProject.delete(projectName);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1716
1760
|
async function getCreateNodesResultsForPlugin(tree, pluginConfiguration, pluginPath, createNodes, createNodesV2, nxJson) {
|
|
1717
1761
|
let projectConfigs;
|
|
1718
1762
|
let erroredConfigFiles = [];
|
|
1763
|
+
const createNodesErrors = [];
|
|
1719
1764
|
try {
|
|
1720
1765
|
const plugin = new devkit_internals_1.LoadedNxPlugin({ createNodes, createNodesV2, name: pluginPath }, pluginConfiguration);
|
|
1721
1766
|
projectConfigs = await (0, devkit_internals_1.retrieveProjectConfigurations)({ specifiedPlugins: [plugin], defaultPlugins: [] }, tree.root, nxJson);
|
|
@@ -1728,10 +1773,20 @@ async function getCreateNodesResultsForPlugin(tree, pluginConfiguration, pluginP
|
|
|
1728
1773
|
// sits outside them, so the plugin is never widened to a root it would
|
|
1729
1774
|
// fail to infer (which the verification pass would otherwise revert).
|
|
1730
1775
|
erroredConfigFiles = harvestConfigurationErrors(e).erroredConfigFiles;
|
|
1776
|
+
for (const error of e.errors) {
|
|
1777
|
+
if ((0, devkit_internals_1.isAggregateCreateNodesError)(error)) {
|
|
1778
|
+
for (const [file, fileError] of error.errors) {
|
|
1779
|
+
createNodesErrors.push({
|
|
1780
|
+
file,
|
|
1781
|
+
message: fileError?.message ?? String(fileError),
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1731
1786
|
}
|
|
1732
1787
|
else {
|
|
1733
1788
|
throw e;
|
|
1734
1789
|
}
|
|
1735
1790
|
}
|
|
1736
|
-
return { result: projectConfigs, erroredConfigFiles };
|
|
1791
|
+
return { result: projectConfigs, erroredConfigFiles, createNodesErrors };
|
|
1737
1792
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type AddressInfo } from 'net';
|
|
2
|
+
/**
|
|
3
|
+
* The url of a server listening on `address`, for `emitReadySignal`. A
|
|
4
|
+
* wildcard address maps to localhost. Undefined for a socket or a pipe.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getListeningUrl(address: AddressInfo | string | null | undefined, https: boolean): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* A `readyWhen` that calls `waitForDevServer` from `module` when the task
|
|
9
|
+
* runs, with the config's file name, when given, and then `literals` as its
|
|
10
|
+
* arguments.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getReadyCheckReadyWhen(module: string, configFileName?: string, ...literals: string[]): {
|
|
13
|
+
command: string;
|
|
14
|
+
interval: number;
|
|
15
|
+
};
|
|
16
|
+
export type TaskOptions = Record<string, unknown> & {
|
|
17
|
+
cwd?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The arguments run-commands passes the task's command, as the command
|
|
21
|
+
* receives them: built by run-commands' own code, then split the way the shell
|
|
22
|
+
* splits them. A `{args.*}` command gets them as if appended, which matches a
|
|
23
|
+
* command that passes each value to the flag of its name.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getForwardedArgs(options: TaskOptions): string[];
|
|
26
|
+
export interface CacArgsOptions {
|
|
27
|
+
/** Each short flag and the camel-case option it aliases, such as `{ c: 'config' }`. */
|
|
28
|
+
aliases?: Record<string, string>;
|
|
29
|
+
/** The flags that take no value, by any of their names. */
|
|
30
|
+
booleans?: string[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The options a cac CLI, such as Rsbuild's or Rspack's, parses from `args`,
|
|
34
|
+
* before it applies option defaults and types. Ports cac's `mri()` step:
|
|
35
|
+
* - A flag takes the next argument as its value unless that starts with `-`.
|
|
36
|
+
* - A repeated flag collects its values in an array, and numeric values
|
|
37
|
+
* become numbers.
|
|
38
|
+
* - Every alias takes the value of the alias given first.
|
|
39
|
+
* - The kebab-case and camel-case spellings of an option take the value of
|
|
40
|
+
* the spelling that first appears last.
|
|
41
|
+
*
|
|
42
|
+
* Dotted names stay flat keys, where cac nests them.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseCacArgs(args: string[], { aliases, booleans }?: CacArgsOptions): Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* The options a commander 12 command, such as the Rsbuild 1.0 and 1.1 CLI's,
|
|
47
|
+
* parses from `args`, by attribute name, given its option flags such as
|
|
48
|
+
* `'-o --open [url]'`. The last value of an option wins, and no defaults or
|
|
49
|
+
* custom argument parsers apply. Throws where the command exits instead: on an
|
|
50
|
+
* unknown option, `--help` included, or a missing value.
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseCommanderArgs(args: string[], declarations: string[]): Record<string, string | true>;
|
|
53
|
+
export interface ServerAddress {
|
|
54
|
+
port: number;
|
|
55
|
+
host?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Where to probe a server, or null when its port is not a positive integer:
|
|
59
|
+
* a server that picks its port or listens on a socket can't be probed ahead.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getServerAddress(port: unknown, host: unknown): ServerAddress | null;
|
|
62
|
+
/**
|
|
63
|
+
* Runs a task-time readiness check. Reads the options the task runs with,
|
|
64
|
+
* moves to its cwd, where the CLI resolves its config, and waits until every
|
|
65
|
+
* address `resolveAddresses` returns accepts a TCP connection. Probes nothing
|
|
66
|
+
* when it returns null.
|
|
67
|
+
*/
|
|
68
|
+
export declare function runReadyCheck(resolveAddresses: (task: {
|
|
69
|
+
options: TaskOptions;
|
|
70
|
+
root: string;
|
|
71
|
+
}) => Promise<ServerAddress[] | null>): Promise<void>;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getListeningUrl = getListeningUrl;
|
|
4
|
+
exports.getReadyCheckReadyWhen = getReadyCheckReadyWhen;
|
|
5
|
+
exports.getForwardedArgs = getForwardedArgs;
|
|
6
|
+
exports.parseCacArgs = parseCacArgs;
|
|
7
|
+
exports.parseCommanderArgs = parseCommanderArgs;
|
|
8
|
+
exports.getServerAddress = getServerAddress;
|
|
9
|
+
exports.runReadyCheck = runReadyCheck;
|
|
10
|
+
const net_1 = require("net");
|
|
11
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const split_shell_args_1 = require("./split-shell-args");
|
|
14
|
+
/**
|
|
15
|
+
* The url of a server listening on `address`, for `emitReadySignal`. A
|
|
16
|
+
* wildcard address maps to localhost. Undefined for a socket or a pipe.
|
|
17
|
+
*/
|
|
18
|
+
function getListeningUrl(address, https) {
|
|
19
|
+
if (!address || typeof address === 'string') {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const host = address.address === '::' || address.address === '0.0.0.0'
|
|
23
|
+
? 'localhost'
|
|
24
|
+
: address.family === 'IPv6'
|
|
25
|
+
? `[${address.address}]`
|
|
26
|
+
: address.address;
|
|
27
|
+
return `${https ? 'https' : 'http'}://${host}:${address.port}/`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A `readyWhen` that calls `waitForDevServer` from `module` when the task
|
|
31
|
+
* runs, with the config's file name, when given, and then `literals` as its
|
|
32
|
+
* arguments.
|
|
33
|
+
*/
|
|
34
|
+
function getReadyCheckReadyWhen(module, configFileName, ...literals) {
|
|
35
|
+
// Unquoted in the command, as no quoting works in every shell
|
|
36
|
+
if (configFileName !== undefined && !/^[\w.-]+$/.test(configFileName)) {
|
|
37
|
+
throw new Error(`Unsupported config file name: ${configFileName}`);
|
|
38
|
+
}
|
|
39
|
+
const args = [
|
|
40
|
+
...(configFileName === undefined ? [] : ['process.argv[1]']),
|
|
41
|
+
...literals.map((literal) => `'${literal}'`),
|
|
42
|
+
].join(', ');
|
|
43
|
+
return {
|
|
44
|
+
command: `node -e "require('${module}').waitForDevServer(${args})"${configFileName === undefined ? '' : ` ${configFileName}`}`,
|
|
45
|
+
// Each attempt starts node, and loads the config when there is one
|
|
46
|
+
interval: 1000,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The arguments run-commands passes the task's command, as the command
|
|
51
|
+
* receives them: built by run-commands' own code, then split the way the shell
|
|
52
|
+
* splits them. A `{args.*}` command gets them as if appended, which matches a
|
|
53
|
+
* command that passes each value to the flag of its name.
|
|
54
|
+
*/
|
|
55
|
+
function getForwardedArgs(options) {
|
|
56
|
+
const commands = options.command
|
|
57
|
+
? [{ command: [options.command].flat().join(' ') }]
|
|
58
|
+
: Array.isArray(options.commands)
|
|
59
|
+
? options.commands.map((c) => typeof c === 'string' ? { command: c } : c)
|
|
60
|
+
: [];
|
|
61
|
+
// Which of several commands starts the server is unknown
|
|
62
|
+
const server = commands.length === 1 ? commands[0] : {};
|
|
63
|
+
const template = server.command?.includes('{args}') && !server.command.includes('{args.')
|
|
64
|
+
? '{args}'
|
|
65
|
+
: '';
|
|
66
|
+
const forwarded = (0, devkit_internals_1.interpolateArgsIntoCommand)(template, (0, devkit_internals_1.normalizeRunCommandsArgs)({
|
|
67
|
+
...options,
|
|
68
|
+
__unparsed__: Array.isArray(options.__unparsed__)
|
|
69
|
+
? options.__unparsed__.map(String)
|
|
70
|
+
: [],
|
|
71
|
+
}), server.forwardAllArgs ?? options.forwardAllArgs ?? true);
|
|
72
|
+
return (0, split_shell_args_1.splitShellArgs)(forwarded);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The options a cac CLI, such as Rsbuild's or Rspack's, parses from `args`,
|
|
76
|
+
* before it applies option defaults and types. Ports cac's `mri()` step:
|
|
77
|
+
* - A flag takes the next argument as its value unless that starts with `-`.
|
|
78
|
+
* - A repeated flag collects its values in an array, and numeric values
|
|
79
|
+
* become numbers.
|
|
80
|
+
* - Every alias takes the value of the alias given first.
|
|
81
|
+
* - The kebab-case and camel-case spellings of an option take the value of
|
|
82
|
+
* the spelling that first appears last.
|
|
83
|
+
*
|
|
84
|
+
* Dotted names stay flat keys, where cac nests them.
|
|
85
|
+
*/
|
|
86
|
+
function parseCacArgs(args, { aliases = {}, booleans = [] } = {}) {
|
|
87
|
+
const aliasOf = new Map();
|
|
88
|
+
for (const [short, long] of Object.entries(aliases)) {
|
|
89
|
+
aliasOf.set(short, long).set(long, short);
|
|
90
|
+
}
|
|
91
|
+
const isBoolean = (name) => booleans.includes(name) || booleans.includes(aliasOf.get(name));
|
|
92
|
+
const parsed = {};
|
|
93
|
+
const add = (name, value) => {
|
|
94
|
+
const number = Number(value);
|
|
95
|
+
const typed = typeof value === 'boolean'
|
|
96
|
+
? value
|
|
97
|
+
: isBoolean(name)
|
|
98
|
+
? value !== 'false' && value !== ''
|
|
99
|
+
: Number.isFinite(number)
|
|
100
|
+
? number
|
|
101
|
+
: value;
|
|
102
|
+
parsed[name] =
|
|
103
|
+
parsed[name] === undefined ? typed : [parsed[name], typed].flat();
|
|
104
|
+
};
|
|
105
|
+
let i = 0;
|
|
106
|
+
for (; i < args.length && args[i] !== '--'; i++) {
|
|
107
|
+
const arg = args[i];
|
|
108
|
+
const dashes = arg.match(/^-*/)[0].length;
|
|
109
|
+
if (dashes === 0)
|
|
110
|
+
continue;
|
|
111
|
+
if (arg.startsWith('no-', dashes)) {
|
|
112
|
+
parsed[arg.slice(dashes + 3)] = false;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const equals = arg.indexOf('=', dashes + 1);
|
|
116
|
+
const name = arg.slice(dashes, equals === -1 ? undefined : equals);
|
|
117
|
+
const value = (equals === -1 ? '' : arg.slice(equals + 1)) ||
|
|
118
|
+
i + 1 === args.length ||
|
|
119
|
+
args[i + 1].startsWith('-') ||
|
|
120
|
+
args[++i];
|
|
121
|
+
// `-abc` sets `a` and `b` and gives its value to `c`
|
|
122
|
+
const names = dashes === 2 ? [name] : [...name];
|
|
123
|
+
names.forEach((n, index) => add(n, index + 1 < names.length || value));
|
|
124
|
+
}
|
|
125
|
+
const synced = new Set();
|
|
126
|
+
for (const name of Object.keys(parsed)) {
|
|
127
|
+
const alias = aliasOf.get(name);
|
|
128
|
+
if (alias !== undefined && !synced.has(name)) {
|
|
129
|
+
parsed[alias] = parsed[name];
|
|
130
|
+
synced.add(alias);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const options = { '--': args.slice(i + 1) };
|
|
134
|
+
for (const [name, value] of Object.entries(parsed)) {
|
|
135
|
+
options[name.replace(/([a-z])-([a-z])/g, (_, a, b) => a + b.toUpperCase())] = value;
|
|
136
|
+
}
|
|
137
|
+
return options;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The options a commander 12 command, such as the Rsbuild 1.0 and 1.1 CLI's,
|
|
141
|
+
* parses from `args`, by attribute name, given its option flags such as
|
|
142
|
+
* `'-o --open [url]'`. The last value of an option wins, and no defaults or
|
|
143
|
+
* custom argument parsers apply. Throws where the command exits instead: on an
|
|
144
|
+
* unknown option, `--help` included, or a missing value.
|
|
145
|
+
*/
|
|
146
|
+
function parseCommanderArgs(args, declarations) {
|
|
147
|
+
const options = declarations.map((flags) => {
|
|
148
|
+
const names = flags.split(/[ |,]+/).filter((part) => part.startsWith('-'));
|
|
149
|
+
return {
|
|
150
|
+
flags,
|
|
151
|
+
names,
|
|
152
|
+
key: names
|
|
153
|
+
.at(-1)
|
|
154
|
+
.replace(/^-+/, '')
|
|
155
|
+
.split('-')
|
|
156
|
+
.reduce((key, word) => key + word[0].toUpperCase() + word.slice(1)),
|
|
157
|
+
required: flags.includes('<'),
|
|
158
|
+
optional: flags.includes('['),
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
const find = (flag) => options.find((o) => o.names.includes(flag));
|
|
162
|
+
const isOption = (arg) => arg.length > 1 && arg[0] === '-';
|
|
163
|
+
const parsed = {};
|
|
164
|
+
const rest = [...args];
|
|
165
|
+
while (rest.length > 0 && rest[0] !== '--') {
|
|
166
|
+
const arg = rest.shift();
|
|
167
|
+
let option = find(arg);
|
|
168
|
+
if (option?.required) {
|
|
169
|
+
if (rest.length === 0) {
|
|
170
|
+
throw new Error(`option '${option.flags}' argument missing`);
|
|
171
|
+
}
|
|
172
|
+
parsed[option.key] = rest.shift();
|
|
173
|
+
}
|
|
174
|
+
else if (option) {
|
|
175
|
+
parsed[option.key] =
|
|
176
|
+
option.optional && rest.length > 0 && !isOption(rest[0])
|
|
177
|
+
? rest.shift()
|
|
178
|
+
: true;
|
|
179
|
+
}
|
|
180
|
+
else if (arg.length > 2 &&
|
|
181
|
+
arg[0] === '-' &&
|
|
182
|
+
arg[1] !== '-' &&
|
|
183
|
+
(option = find(arg.slice(0, 2)))) {
|
|
184
|
+
// `-abc` gives `a` the value `bc`, or sets it and goes on with `-bc`
|
|
185
|
+
if (option.required || option.optional) {
|
|
186
|
+
parsed[option.key] = arg.slice(2);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
parsed[option.key] = true;
|
|
190
|
+
rest.unshift(`-${arg.slice(2)}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else if (/^--[^=]+=/.test(arg) &&
|
|
194
|
+
(option = find(arg.slice(0, arg.indexOf('=')))) &&
|
|
195
|
+
(option.required || option.optional)) {
|
|
196
|
+
parsed[option.key] = arg.slice(arg.indexOf('=') + 1);
|
|
197
|
+
}
|
|
198
|
+
else if (isOption(arg)) {
|
|
199
|
+
throw new Error(`unknown option '${arg}'`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return parsed;
|
|
203
|
+
}
|
|
204
|
+
// The probe reaches these on loopback
|
|
205
|
+
const LOOPBACK_HOSTS = new Set(['', 'localhost', '0.0.0.0', '::']);
|
|
206
|
+
/**
|
|
207
|
+
* Where to probe a server, or null when its port is not a positive integer:
|
|
208
|
+
* a server that picks its port or listens on a socket can't be probed ahead.
|
|
209
|
+
*/
|
|
210
|
+
function getServerAddress(port, host) {
|
|
211
|
+
const number = Number(port);
|
|
212
|
+
if (!Number.isInteger(number) || number <= 0)
|
|
213
|
+
return null;
|
|
214
|
+
return typeof host === 'string' && !LOOPBACK_HOSTS.has(host)
|
|
215
|
+
? { port: number, host }
|
|
216
|
+
: { port: number };
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Runs a task-time readiness check. Reads the options the task runs with,
|
|
220
|
+
* moves to its cwd, where the CLI resolves its config, and waits until every
|
|
221
|
+
* address `resolveAddresses` returns accepts a TCP connection. Probes nothing
|
|
222
|
+
* when it returns null.
|
|
223
|
+
*/
|
|
224
|
+
async function runReadyCheck(resolveAddresses) {
|
|
225
|
+
const options = readTaskOptions();
|
|
226
|
+
const root = (0, path_1.resolve)(options.cwd ?? '.');
|
|
227
|
+
process.chdir(root);
|
|
228
|
+
const addresses = await resolveAddresses({ options, root });
|
|
229
|
+
if (addresses) {
|
|
230
|
+
await Promise.all(addresses.map(waitForAddress));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function readTaskOptions() {
|
|
234
|
+
try {
|
|
235
|
+
return JSON.parse(process.env.NX_TASK_OPTIONS ?? '{}');
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
return {};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async function waitForAddress({ port, host }) {
|
|
242
|
+
const hosts = host ? [host] : ['127.0.0.1', '::1'];
|
|
243
|
+
while (!(await Promise.any(hosts.map((h) => connects(port, h))).catch(() => false))) {
|
|
244
|
+
await new Promise((r) => setTimeout(r, 250));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function connects(port, host) {
|
|
248
|
+
return new Promise((resolve, reject) => {
|
|
249
|
+
const socket = (0, net_1.createConnection)({ port, host });
|
|
250
|
+
socket.once('connect', () => {
|
|
251
|
+
socket.destroy();
|
|
252
|
+
resolve(true);
|
|
253
|
+
});
|
|
254
|
+
socket.once('error', (e) => {
|
|
255
|
+
socket.destroy();
|
|
256
|
+
reject(e);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/devkit",
|
|
3
|
-
"version": "24.0.0-canary.
|
|
3
|
+
"version": "24.0.0-canary.20261020-e7ffd79",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"jest": "30.3.0",
|
|
70
|
-
"nx": "24.0.0-canary.
|
|
70
|
+
"nx": "24.0.0-canary.20261020-e7ffd79"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"nx": ">= 23 <= 25 || ^24.0.0-0"
|