nx 24.1.0-beta.1 → 24.1.0-beta.2
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/src/command-line/release/utils/repository-git-tags.js +3 -3
- package/dist/src/command-line/reset/reset.js +51 -2
- package/dist/src/daemon/client/daemon-environment.js +15 -0
- package/dist/src/devkit-internals.d.ts +3 -3
- package/dist/src/devkit-internals.js +6 -3
- package/dist/src/generators/utils/glob.js +3 -3
- package/dist/src/hasher/hash-task.d.ts +3 -1
- package/dist/src/hasher/hash-task.js +3 -2
- package/dist/src/native/index.d.ts +0 -4
- package/dist/src/native/index.js +13 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/plugins/js/index.js +24 -9
- package/dist/src/plugins/js/lock-file/bun-parser.d.ts +74 -2
- package/dist/src/plugins/js/lock-file/bun-parser.js +971 -139
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +32 -12
- package/dist/src/plugins/js/lock-file/lock-file.js +189 -43
- package/dist/src/plugins/js/lock-file/npm-parser.d.ts +1 -0
- package/dist/src/plugins/js/lock-file/npm-parser.js +66 -2
- package/dist/src/plugins/js/lock-file/pnpm-parser.d.ts +5 -1
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +107 -54
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +52 -10
- package/dist/src/plugins/js/lock-file/pruned-output.js +132 -66
- package/dist/src/plugins/js/lock-file/utils/local-path-hashes.d.ts +27 -0
- package/dist/src/plugins/js/lock-file/utils/local-path-hashes.js +155 -0
- package/dist/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
- package/dist/src/plugins/js/lock-file/utils/package-json.js +2 -1
- package/dist/src/plugins/js/package-json/create-package-json.d.ts +1 -0
- package/dist/src/plugins/js/package-json/create-package-json.js +197 -8
- package/dist/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
- package/dist/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +2 -2
- package/dist/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.js +16 -9
- package/dist/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +17 -28
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +47 -1
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +261 -15
- package/dist/src/project-graph/error-types.d.ts +2 -2
- package/dist/src/project-graph/error-types.js +2 -2
- package/dist/src/tasks-runner/init-tasks-runner.js +23 -17
- package/dist/src/tasks-runner/task-orchestrator.js +16 -2
- package/dist/src/tasks-runner/tasks-schedule.js +1 -1
- package/dist/src/tasks-runner/utils.d.ts +2 -1
- package/dist/src/tasks-runner/utils.js +2 -1
- package/dist/src/utils/find-matching-projects.js +7 -9
- package/dist/src/utils/handle-import.js +8 -2
- package/dist/src/utils/json.js +5 -0
- package/dist/src/utils/package-json.d.ts +7 -0
- package/dist/src/utils/package-json.js +9 -0
- package/package.json +13 -12
|
@@ -110,11 +110,11 @@ async function _RepoGitTags_alwaysCheckAllBranches(checkAllBranchesWhen) {
|
|
|
110
110
|
// Check if any glob pattern matches next
|
|
111
111
|
if (!alwaysCheckAllBranches) {
|
|
112
112
|
alwaysCheckAllBranches = checkAllBranchesWhen.some((pattern) => {
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
113
|
+
const matcher = new minimatch_1.Minimatch(pattern, { dot: true });
|
|
114
|
+
if (matcher.set.length === 0) {
|
|
115
115
|
return false;
|
|
116
116
|
}
|
|
117
|
-
return
|
|
117
|
+
return matcher.match(currentBranch);
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resetHandler = resetHandler;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
5
6
|
const client_1 = require("../../daemon/client/client");
|
|
6
7
|
const tmp_dir_1 = require("../../daemon/tmp-dir");
|
|
7
8
|
const cache_directory_1 = require("../../utils/cache-directory");
|
|
@@ -141,14 +142,62 @@ function removeInstalledNxCloudClient() {
|
|
|
141
142
|
}
|
|
142
143
|
function cleanupCacheEntries() {
|
|
143
144
|
return incrementalBackoff(INCREMENTAL_BACKOFF_FIRST_DELAY, INCREMENTAL_BACKOFF_MAX_DURATION, () => {
|
|
144
|
-
(
|
|
145
|
+
removeNxOwnedCacheEntries(cache_directory_1.cacheDir);
|
|
145
146
|
// `cacheDir` is the shared directory whenever sharing is available, so
|
|
146
147
|
// this is the checkout's own `.nx/cache`: still there from before the
|
|
147
148
|
// move, and still what a later run falls back to if `~/.nx` stops being
|
|
148
149
|
// reachable. Reset means both.
|
|
149
|
-
|
|
150
|
+
const checkoutCache = (0, cache_directory_1.cacheDirectoryForWorkspace)(workspace_root_1.workspaceRoot);
|
|
151
|
+
if (checkoutCache !== cache_directory_1.cacheDir) {
|
|
152
|
+
removeNxOwnedCacheEntries(checkoutCache);
|
|
153
|
+
}
|
|
150
154
|
});
|
|
151
155
|
}
|
|
156
|
+
// xxh3-64 task hashes are decimal (`hasher.rs`). Older hashes and
|
|
157
|
+
// `<hash>.tar.zst` archives are hex. The DB names its files `{id}-v{schema}.db`.
|
|
158
|
+
const TASK_HASH = /^(?:\d{1,20}|[0-9a-fA-F]{16,64})$/;
|
|
159
|
+
const NX_DATABASE_FILE = /^.+-v\d+\.(?:db(?:-wal|-shm|-journal)?|lock)$/;
|
|
160
|
+
function isNxOwnedCacheEntry(name, isDirectory, isSymbolicLink) {
|
|
161
|
+
if (name === 'terminalOutputs' ||
|
|
162
|
+
name === 'batchOutputs' ||
|
|
163
|
+
name === 'run.json' ||
|
|
164
|
+
name.startsWith('.nx-write-probe-')) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
if (TASK_HASH.test(name)) {
|
|
168
|
+
// A hash is a directory of outputs. A regular file with the same name
|
|
169
|
+
// belongs to whoever put it there; a symlink is removed as the link only.
|
|
170
|
+
return isDirectory || isSymbolicLink;
|
|
171
|
+
}
|
|
172
|
+
if (hasHashPrefix(name, '.commit') || hasHashPrefix(name, '.tar.zst')) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
return NX_DATABASE_FILE.test(name);
|
|
176
|
+
}
|
|
177
|
+
function hasHashPrefix(name, suffix) {
|
|
178
|
+
return name.endsWith(suffix) && TASK_HASH.test(name.slice(0, -suffix.length));
|
|
179
|
+
}
|
|
180
|
+
function removeNxOwnedCacheEntries(dir) {
|
|
181
|
+
let stat;
|
|
182
|
+
try {
|
|
183
|
+
// `lstat` so a symlink is left in place instead of deleting through it.
|
|
184
|
+
stat = (0, node_fs_1.lstatSync)(dir);
|
|
185
|
+
}
|
|
186
|
+
catch (e) {
|
|
187
|
+
if (e?.code === 'ENOENT') {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
throw e;
|
|
191
|
+
}
|
|
192
|
+
if (!stat.isDirectory()) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
for (const entry of (0, node_fs_1.readdirSync)(dir, { withFileTypes: true })) {
|
|
196
|
+
if (isNxOwnedCacheEntry(entry.name, entry.isDirectory(), entry.isSymbolicLink())) {
|
|
197
|
+
(0, node_fs_1.rmSync)((0, node_path_1.join)(dir, entry.name), { recursive: true, force: true });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
152
201
|
/** Skips the no-op when the two resolve to one directory. */
|
|
153
202
|
function removeIfDistinct(dir, from) {
|
|
154
203
|
if (dir !== from) {
|
|
@@ -100,6 +100,8 @@ const DAEMON_ENV_VARS_EXCLUSIONS = new Set([
|
|
|
100
100
|
'COPILOT_AGENT_SESSION_ID',
|
|
101
101
|
'COPILOT_CLI_BINARY_VERSION',
|
|
102
102
|
'CLAUDE_PID',
|
|
103
|
+
// Editors / IDEs
|
|
104
|
+
'NX_CONSOLE',
|
|
103
105
|
// Shell mechanics
|
|
104
106
|
'_',
|
|
105
107
|
'SHLVL',
|
|
@@ -172,6 +174,17 @@ const DAEMON_ENV_VARS_EXCLUSIONS = new Set([
|
|
|
172
174
|
// macOS internals
|
|
173
175
|
'__CF_USER_TEXT_ENCODING',
|
|
174
176
|
'__CFBundleIdentifier',
|
|
177
|
+
// Set by git per invocation when Nx runs from a hook. Exact entries rather
|
|
178
|
+
// than a GIT_ prefix, which would also swallow GIT_DIR.
|
|
179
|
+
'GIT_INDEX_FILE',
|
|
180
|
+
'GIT_PREFIX',
|
|
181
|
+
'GIT_REFLOG_ACTION',
|
|
182
|
+
'GIT_AUTHOR_NAME',
|
|
183
|
+
'GIT_AUTHOR_EMAIL',
|
|
184
|
+
'GIT_AUTHOR_DATE',
|
|
185
|
+
'GIT_COMMITTER_NAME',
|
|
186
|
+
'GIT_COMMITTER_EMAIL',
|
|
187
|
+
'GIT_COMMITTER_DATE',
|
|
175
188
|
]);
|
|
176
189
|
/**
|
|
177
190
|
* Env var prefixes that should never be sent to the daemon.
|
|
@@ -191,6 +204,8 @@ const DAEMON_ENV_PREFIX_EXCLUSIONS = [
|
|
|
191
204
|
// Package managers (process-scoped)
|
|
192
205
|
'npm_',
|
|
193
206
|
'pnpm_',
|
|
207
|
+
'PNPM_',
|
|
208
|
+
'COREPACK_',
|
|
194
209
|
// Nx Cloud runner/agent vars (per-worker values like NX_CLOUD_WORKER_ID
|
|
195
210
|
// and NX_CLOUD_EXECUTION_ID diverge between distributed-execution workers
|
|
196
211
|
// and cannot affect the project graph; without this every worker that
|
|
@@ -97,7 +97,7 @@ export { connectToNxCloud } from './nx-cloud/generators/connect-to-nx-cloud/conn
|
|
|
97
97
|
export type { NxCloudOnBoardingStatus } from './nx-cloud/models/onboarding-status';
|
|
98
98
|
export { createNxCloudOnboardingURLForWelcomeApp, getNxCloudAppOnBoardingUrl, } from './nx-cloud/utilities/onboarding';
|
|
99
99
|
export { createNxCloudOnboardingURL } from './nx-cloud/utilities/url-shorten';
|
|
100
|
-
export { createLockFile, generatePrunedDeployOutput, getLockFileName, } from './plugins/js/lock-file/lock-file';
|
|
100
|
+
export { createLockFile, generatePrunedDeployOutput, getLockFileName, hasTextBunLockfile, } from './plugins/js/lock-file/lock-file';
|
|
101
101
|
export { createPackageJson, findProjectsNpmDependencies, } from './plugins/js/package-json/create-package-json';
|
|
102
102
|
export { TargetProjectLocator, isBuiltinModuleImport, } from './plugins/js/project-graph/build-dependencies/target-project-locator';
|
|
103
103
|
export { getWorkspacePackagesFromGraph } from './plugins/js/utils/get-workspace-packages-from-graph';
|
|
@@ -131,14 +131,14 @@ export { deduceDefaultBase } from './utils/default-base';
|
|
|
131
131
|
export { createDirectory, directoryExists, fileExists, isRelativePath, readFileIfExisting, } from './utils/fileutils';
|
|
132
132
|
export { getLatestCommitSha, getVcsRemoteInfo } from './utils/git-utils';
|
|
133
133
|
export { combineGlobPatterns, isGlobPattern } from './utils/globs';
|
|
134
|
-
export { getNxRequirePaths } from './utils/installation-directory';
|
|
134
|
+
export { getNxRequirePaths, resolveInstalledPackage, } from './utils/installation-directory';
|
|
135
135
|
export { NX_PREFIX } from './utils/logger';
|
|
136
136
|
export type { CLIErrorMessageConfig, CLINoteMessageConfig, CLISuccessMessageConfig, CLIWarnMessageConfig, } from './utils/output';
|
|
137
137
|
export { orange } from './utils/output';
|
|
138
138
|
export { getNxCloudUrl, isNxCloudUsed } from './utils/nx-cloud-utils';
|
|
139
139
|
export type { PackageJson, PackageJsonDependencySection, } from './utils/package-json';
|
|
140
140
|
export { readNxMigrateConfig } from './utils/package-json';
|
|
141
|
-
export { dropEmptyPeerDependencySections, movePeerDependencyToDependencies, relocatePrunedLocalPathSpec, warnUnshippableLocalPathSpec, } from './plugins/js/lock-file/pruned-output';
|
|
141
|
+
export { dropEmptyPeerDependencySections, movePeerDependencyToDependencies, relocatePrunedLocalPathSpec, resolveWorkspaceModuleDependency, warnUnshippableLocalPathSpec, } from './plugins/js/lock-file/pruned-output';
|
|
142
142
|
export type { PackageManagerCommands } from './utils/package-manager';
|
|
143
143
|
export { deriveGroupNameFromTarget } from './utils/plugins/atomizer-utils';
|
|
144
144
|
export { findInstalledPlugins } from './utils/plugins/installed-plugins';
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hashDaemonClientEnv = exports.getEnvPathsForTask = exports.getGraphTimeDotEnvForTask = exports.getEnvFilesForTask = 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.confirmationPrompt = exports.textPrompt = exports.multiselectPrompt = exports.selectPrompt = exports.splitTarget = exports.createPrettierIgnoreChecker = exports.createOxfmtIgnoreChecker = exports.createGitIgnoreChecker = exports.readTargetDefaultsForTarget = exports.createTargetDefaultsResults = exports.findMatchingProjects = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.findMatchingTargetNames = exports.resolveNxTokensInOptions = exports.resolveCommandSyntacticSugar = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.parseExecutor = exports.getExecutorInformation = exports.parseVersionFromPackageManagerField = exports.createTempNpmDirectory = void 0;
|
|
4
4
|
exports.isProjectGraphProjectNode = exports.isProjectGraphExternalNode = exports.fileDataDepType = exports.fileDataDepTarget = exports.BatchFunctionRunner = exports.getGeneratorInformation = exports.setupAiAgentsGenerator = exports.toOldFormat = exports.toNewFormat = exports.runCommandsExecutor = exports.acknowledgeDeclaredBuildScripts = exports.acknowledgeBuildScripts = exports.getCatalogDependenciesFromPackageJson = exports.getCatalogManager = exports.checkFilesAreOutputs = exports.checkFilesAreInputs = exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.handleImport = exports.pathExists = exports.getPath = exports.findFilesWithDynamicImports = exports.findFilesInCircularPath = exports.expandIgnoredCircularDependencies = exports.circularPathHasPair = exports.checkCircularPath = exports.computeJsonLineNumbers = exports.handleErrors = exports.signalToCode = exports.globalSpinner = exports.readYamlFile = exports.oxfmtConfigFiles = exports.formatFilesWithOxfmt = exports.detectFormatterInTree = exports.detectFormatter = exports.prettierConfigFiles = exports.isUsingPrettierInTree = exports.createOverrides = exports.createCliOptions = exports.isCI = exports.applyDaemonEnvFromClient = exports.getAppliedDaemonClientEnv = exports.getDaemonClientEnvGeneration = void 0;
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.resolveStartupHost = exports.safeSpawn = exports.safeExecFileSync = exports.workspaceRootInner = exports.setWorkspaceRoot = exports.setupWorkspaceContext = exports.resetWorkspaceContext = exports.globWithWorkspaceContext = exports.getFilesInDirectoryUsingContext = exports.nxVersion = exports.SyncError = exports.quoteShellArg = exports.getSourceDirOfDependentProjects = exports.findAllProjectNodeDependencies = exports.findInstalledPlugins = exports.deriveGroupNameFromTarget = exports.warnUnshippableLocalPathSpec = exports.relocatePrunedLocalPathSpec = exports.movePeerDependencyToDependencies = exports.dropEmptyPeerDependencySections = exports.readNxMigrateConfig = void 0;
|
|
5
|
+
exports.handleProjectGraphError = exports.createProjectGraphAndSourceMapsAsync = exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.isNpmProject = exports.findClosestMatches = exports.readSourceMapsCache = exports.readFileMapCache = exports.readPackageJson = exports.isWholeFileChange = exports.isLockFileChange = exports.isDeletedFileChange = exports.defaultFileRead = exports.calculateFileChanges = exports.WholeFileChange = exports.TEN_MEGABYTES = exports.LockFileChange = exports.DeletedFileChange = exports.buildPackageJsonWorkspacesMatcher = exports.buildPackageJsonPatterns = exports.getGlobPatternsFromPackageManagerWorkspaces = exports.registerTsConfigPaths = exports.getWorkspacePackagesFromGraph = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.findProjectsNpmDependencies = exports.createPackageJson = exports.hasTextBunLockfile = exports.getLockFileName = exports.generatePrunedDeployOutput = exports.createLockFile = exports.createNxCloudOnboardingURL = exports.getNxCloudAppOnBoardingUrl = exports.createNxCloudOnboardingURLForWelcomeApp = exports.connectToNxCloud = exports.killChildOnHostExit = exports.transformProjectGraphForProjectMatching = exports.unmatchedProjectPatterns = exports.readShebangHeaders = exports.killProcessTreeGraceful = exports.isAiAgent = exports.getTargetInputs = exports.filterUsingGlobPatterns = exports.hashFile = exports.getRelativeProjectJsonSchemaPath = exports.flushChanges = exports.FsTree = exports.normalizeRunCommandsArgs = exports.interpolateArgsIntoCommand = exports.LARGE_BUFFER = exports.daemonClient = void 0;
|
|
6
|
+
exports.orange = exports.NX_PREFIX = exports.resolveInstalledPackage = exports.getNxRequirePaths = exports.isGlobPattern = exports.combineGlobPatterns = exports.getVcsRemoteInfo = 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.createFileMapUsingProjectGraph = exports.readCachedProjectConfiguration = exports.preventRecursionInGraphConstruction = void 0;
|
|
7
|
+
exports.resolveStartupHost = exports.safeSpawn = exports.safeExecFileSync = exports.workspaceRootInner = exports.setWorkspaceRoot = exports.setupWorkspaceContext = exports.resetWorkspaceContext = exports.globWithWorkspaceContext = exports.getFilesInDirectoryUsingContext = exports.nxVersion = exports.SyncError = exports.quoteShellArg = exports.getSourceDirOfDependentProjects = exports.findAllProjectNodeDependencies = exports.findInstalledPlugins = exports.deriveGroupNameFromTarget = exports.warnUnshippableLocalPathSpec = exports.resolveWorkspaceModuleDependency = exports.relocatePrunedLocalPathSpec = exports.movePeerDependencyToDependencies = exports.dropEmptyPeerDependencySections = exports.readNxMigrateConfig = exports.isNxCloudUsed = exports.getNxCloudUrl = void 0;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
9
|
/**
|
|
10
10
|
* Note to developers: STOP! These are nx internals, not part of the public
|
|
@@ -222,6 +222,7 @@ var lock_file_1 = require("./plugins/js/lock-file/lock-file");
|
|
|
222
222
|
Object.defineProperty(exports, "createLockFile", { enumerable: true, get: function () { return lock_file_1.createLockFile; } });
|
|
223
223
|
Object.defineProperty(exports, "generatePrunedDeployOutput", { enumerable: true, get: function () { return lock_file_1.generatePrunedDeployOutput; } });
|
|
224
224
|
Object.defineProperty(exports, "getLockFileName", { enumerable: true, get: function () { return lock_file_1.getLockFileName; } });
|
|
225
|
+
Object.defineProperty(exports, "hasTextBunLockfile", { enumerable: true, get: function () { return lock_file_1.hasTextBunLockfile; } });
|
|
225
226
|
var create_package_json_1 = require("./plugins/js/package-json/create-package-json");
|
|
226
227
|
Object.defineProperty(exports, "createPackageJson", { enumerable: true, get: function () { return create_package_json_1.createPackageJson; } });
|
|
227
228
|
Object.defineProperty(exports, "findProjectsNpmDependencies", { enumerable: true, get: function () { return create_package_json_1.findProjectsNpmDependencies; } });
|
|
@@ -322,6 +323,7 @@ Object.defineProperty(exports, "combineGlobPatterns", { enumerable: true, get: f
|
|
|
322
323
|
Object.defineProperty(exports, "isGlobPattern", { enumerable: true, get: function () { return globs_1.isGlobPattern; } });
|
|
323
324
|
var installation_directory_1 = require("./utils/installation-directory");
|
|
324
325
|
Object.defineProperty(exports, "getNxRequirePaths", { enumerable: true, get: function () { return installation_directory_1.getNxRequirePaths; } });
|
|
326
|
+
Object.defineProperty(exports, "resolveInstalledPackage", { enumerable: true, get: function () { return installation_directory_1.resolveInstalledPackage; } });
|
|
325
327
|
var logger_2 = require("./utils/logger");
|
|
326
328
|
Object.defineProperty(exports, "NX_PREFIX", { enumerable: true, get: function () { return logger_2.NX_PREFIX; } });
|
|
327
329
|
var output_1 = require("./utils/output");
|
|
@@ -335,6 +337,7 @@ var pruned_output_1 = require("./plugins/js/lock-file/pruned-output");
|
|
|
335
337
|
Object.defineProperty(exports, "dropEmptyPeerDependencySections", { enumerable: true, get: function () { return pruned_output_1.dropEmptyPeerDependencySections; } });
|
|
336
338
|
Object.defineProperty(exports, "movePeerDependencyToDependencies", { enumerable: true, get: function () { return pruned_output_1.movePeerDependencyToDependencies; } });
|
|
337
339
|
Object.defineProperty(exports, "relocatePrunedLocalPathSpec", { enumerable: true, get: function () { return pruned_output_1.relocatePrunedLocalPathSpec; } });
|
|
340
|
+
Object.defineProperty(exports, "resolveWorkspaceModuleDependency", { enumerable: true, get: function () { return pruned_output_1.resolveWorkspaceModuleDependency; } });
|
|
338
341
|
Object.defineProperty(exports, "warnUnshippableLocalPathSpec", { enumerable: true, get: function () { return pruned_output_1.warnUnshippableLocalPathSpec; } });
|
|
339
342
|
// Sourced from the leaf module rather than ./utils/plugins: the barrel index
|
|
340
343
|
// pulls output.ts and core-plugins.ts into the eager closure for a function that
|
|
@@ -33,12 +33,12 @@ async function globAsync(tree, patterns) {
|
|
|
33
33
|
function combineGlobResultsWithTree(tree, patterns, results) {
|
|
34
34
|
const matches = new Set(results);
|
|
35
35
|
const combinedGlob = (0, globs_1.combineGlobPatterns)(patterns);
|
|
36
|
-
const matcher = minimatch_1.
|
|
37
|
-
if (
|
|
36
|
+
const matcher = new minimatch_1.Minimatch(combinedGlob);
|
|
37
|
+
if (matcher.set.length === 0) {
|
|
38
38
|
throw new Error('Invalid glob pattern: ' + combinedGlob);
|
|
39
39
|
}
|
|
40
40
|
for (const change of tree.listChanges()) {
|
|
41
|
-
if (change.type !== 'UPDATE' && matcher.
|
|
41
|
+
if (change.type !== 'UPDATE' && matcher.match(change.path)) {
|
|
42
42
|
if (change.type === 'CREATE') {
|
|
43
43
|
matches.add(change.path);
|
|
44
44
|
}
|
|
@@ -4,7 +4,9 @@ import { Task, TaskGraph } from '../config/task-graph';
|
|
|
4
4
|
import { type UltracacheConfigurations, TaskDetails } from '../native';
|
|
5
5
|
import { TaskHasher } from './task-hasher';
|
|
6
6
|
export declare function getTaskDetails(): TaskDetails | null;
|
|
7
|
-
export declare function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher: TaskHasher, projectGraph: ProjectGraph, taskGraph: TaskGraph, nxJson: NxJsonConfiguration, tasksDetails: TaskDetails | null, ultracacheConfigurations?: UltracacheConfigurations
|
|
7
|
+
export declare function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher: TaskHasher, projectGraph: ProjectGraph, taskGraph: TaskGraph, nxJson: NxJsonConfiguration, tasksDetails: TaskDetails | null, ultracacheConfigurations?: UltracacheConfigurations,
|
|
8
|
+
/** The tasks to hash; an agent runs a few tasks of a larger task graph. */
|
|
9
|
+
tasks?: Task[]): Promise<Set<string>>;
|
|
8
10
|
export declare function hashTask(hasher: TaskHasher, projectGraph: ProjectGraph, taskGraph: TaskGraph, task: Task, env: NodeJS.ProcessEnv, taskDetails: TaskDetails | null): Promise<void>;
|
|
9
11
|
/**
|
|
10
12
|
* Batch-hash `tasks`. `perTaskEnvs` must contain an entry keyed by
|
|
@@ -24,7 +24,9 @@ function getTaskDetails() {
|
|
|
24
24
|
}
|
|
25
25
|
return taskDetails;
|
|
26
26
|
}
|
|
27
|
-
async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGraph, taskGraph, nxJson, tasksDetails, ultracacheConfigurations
|
|
27
|
+
async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGraph, taskGraph, nxJson, tasksDetails, ultracacheConfigurations,
|
|
28
|
+
/** The tasks to hash; an agent runs a few tasks of a larger task graph. */
|
|
29
|
+
tasks = Object.values(taskGraph.tasks)) {
|
|
28
30
|
performance.mark('hashMultipleTasks:start');
|
|
29
31
|
const projects = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects;
|
|
30
32
|
// An Ultracache configuration can make a task depend on producer outputs its declared
|
|
@@ -32,7 +34,6 @@ async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGrap
|
|
|
32
34
|
const deferredByConfiguration = ultracacheConfigurations
|
|
33
35
|
? new Set((0, native_1.getUltracacheDeferredTaskIds)(ultracacheConfigurations, taskGraph))
|
|
34
36
|
: null;
|
|
35
|
-
const tasks = Object.values(taskGraph.tasks);
|
|
36
37
|
// TODO(v25): remove custom hasher support (NXC-5052).
|
|
37
38
|
const tasksWithHashers = await Promise.all(tasks.map(async (task) => {
|
|
38
39
|
const customHasher = (0, utils_1.getCustomHasher)(task, projects);
|
|
@@ -114,10 +114,6 @@ export declare class HttpRemoteCache {
|
|
|
114
114
|
store(hash: string, cacheDirectory: string, terminalOutput: string, code: number): Promise<boolean>
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
/**
|
|
118
|
-
* The hasher's handle on an index: lists only after catching up with the
|
|
119
|
-
* watch behind it.
|
|
120
|
-
*/
|
|
121
117
|
export declare class IgnoredIndexReader {
|
|
122
118
|
|
|
123
119
|
}
|
package/dist/src/native/index.js
CHANGED
|
@@ -167,9 +167,12 @@ Module._load = function (request, parent, isMain) {
|
|
|
167
167
|
try {
|
|
168
168
|
return originalLoad.apply(this, [tmpFile, parent, isMain]);
|
|
169
169
|
} catch (e) {
|
|
170
|
+
// ENOENT: the resolver's realpath can lose the file to a concurrent
|
|
171
|
+
// `nx reset` after its stat found it.
|
|
170
172
|
if (
|
|
171
173
|
e.code === 'EACCES' ||
|
|
172
174
|
e.code === 'EPERM' ||
|
|
175
|
+
e.code === 'ENOENT' ||
|
|
173
176
|
e.code === 'MODULE_NOT_FOUND' ||
|
|
174
177
|
e.code === 'ERR_DLOPEN_FAILED'
|
|
175
178
|
) {
|
|
@@ -188,6 +191,10 @@ Module._load = function (request, parent, isMain) {
|
|
|
188
191
|
let cacheError = null;
|
|
189
192
|
for (let attempt = 1; attempt <= MAX_COPY_RETRIES; attempt++) {
|
|
190
193
|
attemptsMade = attempt;
|
|
194
|
+
// A concurrent `nx reset` or a tmp cleaner can remove the directory.
|
|
195
|
+
if (attempt > 1 && !ensureSecureNativeFileCacheLocation()) {
|
|
196
|
+
return originalLoad.apply(this, [nativeLocation, parent, isMain]);
|
|
197
|
+
}
|
|
191
198
|
// First copy to a unique location for each process
|
|
192
199
|
try {
|
|
193
200
|
copyFileSync(nativeLocation, tmpTmpFile);
|
|
@@ -197,6 +204,9 @@ Module._load = function (request, parent, isMain) {
|
|
|
197
204
|
// have left a partial file behind.
|
|
198
205
|
cacheError = e;
|
|
199
206
|
removeIfPresent(tmpTmpFile);
|
|
207
|
+
if (e.code === 'ENOENT') {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
200
210
|
break;
|
|
201
211
|
}
|
|
202
212
|
|
|
@@ -211,6 +221,9 @@ Module._load = function (request, parent, isMain) {
|
|
|
211
221
|
// reports it as a missing optional dependency, which it is not.
|
|
212
222
|
cacheError = e;
|
|
213
223
|
removeIfPresent(tmpTmpFile);
|
|
224
|
+
if (e.code === 'ENOENT') {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
214
227
|
break;
|
|
215
228
|
}
|
|
216
229
|
return loadFromCache();
|
|
Binary file
|
|
Binary file
|
|
@@ -15,6 +15,7 @@ const versions_1 = require("../../utils/versions");
|
|
|
15
15
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
16
16
|
const bun_parser_1 = require("./lock-file/bun-parser");
|
|
17
17
|
const lock_file_1 = require("./lock-file/lock-file");
|
|
18
|
+
const local_path_hashes_1 = require("./lock-file/utils/local-path-hashes");
|
|
18
19
|
const build_dependencies_1 = require("./project-graph/build-dependencies/build-dependencies");
|
|
19
20
|
const config_1 = require("./utils/config");
|
|
20
21
|
exports.name = 'nx/js/dependencies-and-lockfile';
|
|
@@ -22,16 +23,18 @@ exports.name = 'nx/js/dependencies-and-lockfile';
|
|
|
22
23
|
// createDependencies, so both parse the one createNodes read.
|
|
23
24
|
let cachedLockFile;
|
|
24
25
|
let cachedKeyMap;
|
|
26
|
+
let cachedInstalledLocalPathNodes;
|
|
25
27
|
exports.createNodes = [
|
|
26
28
|
(0, globs_1.combineGlobPatterns)(lock_file_1.LOCKFILES),
|
|
27
29
|
(files, _, context) => {
|
|
28
30
|
// A long-lived process must not reuse a lockfile this computation skipped.
|
|
29
31
|
cachedLockFile = undefined;
|
|
30
32
|
cachedKeyMap = undefined;
|
|
33
|
+
cachedInstalledLocalPathNodes = undefined;
|
|
31
34
|
return (0, plugins_1.createNodesFromFiles)(internalCreateNodes, files, _, context);
|
|
32
35
|
},
|
|
33
36
|
];
|
|
34
|
-
function internalCreateNodes(lockFile, _, context) {
|
|
37
|
+
async function internalCreateNodes(lockFile, _, context) {
|
|
35
38
|
const pluginConfig = (0, config_1.jsPluginConfig)(context.nxJsonConfiguration);
|
|
36
39
|
if (!pluginConfig.analyzeLockfile) {
|
|
37
40
|
return {};
|
|
@@ -45,23 +48,31 @@ function internalCreateNodes(lockFile, _, context) {
|
|
|
45
48
|
const lockFileContents = packageManager !== 'bun'
|
|
46
49
|
? (0, fs_1.readFileSync)(lockFilePath, 'utf-8')
|
|
47
50
|
: (0, bun_parser_1.readBunLockFile)(lockFilePath);
|
|
48
|
-
const
|
|
51
|
+
const bunPatchFileHashes = lockFile === bun_parser_1.BUN_TEXT_LOCK_FILE
|
|
52
|
+
? (0, bun_parser_1.getBunPatchFileHashes)(workspace_root_1.workspaceRoot)
|
|
53
|
+
: undefined;
|
|
54
|
+
const lockFileHash = getLockFileHash(lockFileContents, bunPatchFileHashes);
|
|
49
55
|
cachedLockFile = { packageManager, lockFile, lockFileContents, lockFileHash };
|
|
50
56
|
const cached = readCache(externalNodesCache, lockFileHash);
|
|
51
|
-
|
|
57
|
+
// An older build of the same version writes no record, so its entry misses
|
|
58
|
+
if (cached?.installedLocalPathNodes) {
|
|
52
59
|
cachedKeyMap = deserializeKeyMap(cached.keyMap, cached.nodes);
|
|
60
|
+
cachedInstalledLocalPathNodes = cached.installedLocalPathNodes;
|
|
53
61
|
return {
|
|
54
|
-
externalNodes: cached.nodes,
|
|
62
|
+
externalNodes: await (0, local_path_hashes_1.foldLocalPathHashes)(cached.nodes, cached.localPathSources ?? {}, workspace_root_1.workspaceRoot),
|
|
55
63
|
};
|
|
56
64
|
}
|
|
57
|
-
const { nodes: externalNodes, keyMap } = (0, lock_file_1.getLockFileNodes)(packageManager, lockFile, lockFileContents, lockFileHash, context);
|
|
65
|
+
const { nodes: externalNodes, keyMap, localPathSources = {}, installedLocalPathNodes, } = (0, lock_file_1.getLockFileNodes)(packageManager, lockFile, lockFileContents, lockFileHash, context, bunPatchFileHashes);
|
|
58
66
|
cachedKeyMap = keyMap;
|
|
67
|
+
cachedInstalledLocalPathNodes = installedLocalPathNodes;
|
|
59
68
|
writeCache(externalNodesCache, lockFileHash, {
|
|
60
69
|
nodes: externalNodes,
|
|
61
70
|
keyMap: serializeKeyMap(keyMap),
|
|
71
|
+
localPathSources,
|
|
72
|
+
installedLocalPathNodes,
|
|
62
73
|
});
|
|
63
74
|
return {
|
|
64
|
-
externalNodes,
|
|
75
|
+
externalNodes: await (0, local_path_hashes_1.foldLocalPathHashes)(externalNodes, localPathSources, workspace_root_1.workspaceRoot),
|
|
65
76
|
};
|
|
66
77
|
}
|
|
67
78
|
const createDependencies = (_, ctx) => {
|
|
@@ -88,14 +99,18 @@ const createDependencies = (_, ctx) => {
|
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
perf_hooks_1.performance.mark('build typescript dependencies - start');
|
|
91
|
-
const explicitProjectDependencies = (0, build_dependencies_1.buildExplicitDependencies)(pluginConfig, ctx);
|
|
102
|
+
const explicitProjectDependencies = (0, build_dependencies_1.buildExplicitDependencies)(pluginConfig, ctx, cachedInstalledLocalPathNodes);
|
|
92
103
|
perf_hooks_1.performance.mark('build typescript dependencies - end');
|
|
93
104
|
perf_hooks_1.performance.measure('build typescript dependencies', 'build typescript dependencies - start', 'build typescript dependencies - end');
|
|
94
105
|
return lockfileDependencies.concat(explicitProjectDependencies);
|
|
95
106
|
};
|
|
96
107
|
exports.createDependencies = createDependencies;
|
|
97
|
-
function getLockFileHash(lockFileContents) {
|
|
98
|
-
return (0, file_hasher_1.hashArray)([
|
|
108
|
+
function getLockFileHash(lockFileContents, bunPatchFileHashes = new Map()) {
|
|
109
|
+
return (0, file_hasher_1.hashArray)([
|
|
110
|
+
versions_1.nxVersion,
|
|
111
|
+
lockFileContents,
|
|
112
|
+
...[...bunPatchFileHashes].flat(),
|
|
113
|
+
]);
|
|
99
114
|
}
|
|
100
115
|
// Serialize keyMap to JSON-friendly format
|
|
101
116
|
function serializeKeyMap(keyMap) {
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { type ProjectGraphExternalNode } from '../../../config/project-graph';
|
|
1
|
+
import { type ProjectGraph, type ProjectGraphExternalNode } from '../../../config/project-graph';
|
|
2
2
|
import type { CreateDependenciesContext } from '../../../project-graph/plugins';
|
|
3
3
|
import { type RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
|
4
|
+
import type { PackageJson } from '../../../utils/package-json';
|
|
5
|
+
import { type LocalPathArtifactTarget } from './pruned-output';
|
|
6
|
+
import type { NormalizedPackageJson } from './utils/package-json';
|
|
7
|
+
declare const DEPENDENCY_TYPES: readonly ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
|
|
8
|
+
export interface PinnedManifestSpec {
|
|
9
|
+
depType: (typeof DEPENDENCY_TYPES)[number];
|
|
10
|
+
name: string;
|
|
11
|
+
spec: string;
|
|
12
|
+
}
|
|
4
13
|
export { BUN_LOCK_FILE, BUN_TEXT_LOCK_FILE } from './lock-file-names';
|
|
5
14
|
export declare class BunLockfileParseError extends Error {
|
|
6
15
|
readonly cause?: Error;
|
|
@@ -10,4 +19,67 @@ export declare function readBunLockFile(lockFilePath: string): string;
|
|
|
10
19
|
export declare function getBunTextLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
|
11
20
|
/** @internal */
|
|
12
21
|
export declare function clearCache(): void;
|
|
13
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @param patchFileHashes the {@link getBunPatchFileHashes} that `lockFileHash`
|
|
24
|
+
* covers, folded into the hashes of the packages they patch. Omitted, patched
|
|
25
|
+
* packages hash like unpatched ones.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getBunTextLockfileNodes(lockFileContent: string, lockFileHash: string, patchFileHashes?: Map<string, string>): Record<string, ProjectGraphExternalNode>;
|
|
28
|
+
/**
|
|
29
|
+
* The workspace-relative sources of the `nodes` that install from the local
|
|
30
|
+
* file tree, keyed by node name. The lockfile records only their paths, so the
|
|
31
|
+
* contents of these sources are what change when the packages do.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getBunLocalPathNodeSources(lockFileContent: string, lockFileHash: string, nodes: Record<string, ProjectGraphExternalNode>): Record<string, string[]>;
|
|
34
|
+
/**
|
|
35
|
+
* The local-path node each workspace installs per dependency name, keyed by
|
|
36
|
+
* its path ('.' for the root). Aliases are left out.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getBunInstalledLocalPathNodes(lockFileContent: string, lockFileHash: string, nodes: Record<string, ProjectGraphExternalNode>): Record<string, Record<string, string>>;
|
|
39
|
+
/**
|
|
40
|
+
* Writes the bun.lock for a standalone install of `packageJson`, with every
|
|
41
|
+
* package at the version the root lockfile installs for it. Dependencies are
|
|
42
|
+
* resolved through the root lockfile's keys, since the project graph records
|
|
43
|
+
* no dependencies of a nested package. The kept packages are laid out in a new
|
|
44
|
+
* tree rooted at the pruned manifest. Bun rebuilds its hoisting on install, so
|
|
45
|
+
* each dependency only has to resolve to the same package, except that a
|
|
46
|
+
* bundled tree stays under its bundler.
|
|
47
|
+
*
|
|
48
|
+
* Workspace modules become `file:./workspace_modules/<name>` dependencies.
|
|
49
|
+
* `projectRoot` is where the manifest's local-path specs resolve from, and it
|
|
50
|
+
* locates the project's own workspace entry, whose resolutions are kept for
|
|
51
|
+
* the specs it declares even where an override replaced them. `onPinnedSpec`
|
|
52
|
+
* receives the locked version the output declares for such a dependency.
|
|
53
|
+
* Returns an empty string for a manifest without dependencies, which gets no
|
|
54
|
+
* lockfile.
|
|
55
|
+
*/
|
|
56
|
+
export declare function stringifyBunLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson, workspaceRootPath: string, projectRoot?: string, onPinnedSpec?: (pin: PinnedManifestSpec) => void): string;
|
|
57
|
+
/**
|
|
58
|
+
* The `.patch` files a pruned Bun output ships for the patches its bun.lock
|
|
59
|
+
* keeps. Bun applies the patches the manifest declares, so the same entries
|
|
60
|
+
* replace any `patchedDependencies` the manifest inherited.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getPrunedBunPatchArtifacts(workspaceRootPath: string, lockFileContent: string, packageJson: PackageJson): Array<{
|
|
63
|
+
path: string;
|
|
64
|
+
content: string;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* The local packages a pruned bun.lock installs, which the output ships under
|
|
68
|
+
* `local_path_modules/` (see `getLocalPathArtifacts`). Copied workspace modules
|
|
69
|
+
* ship through copy-workspace-modules instead.
|
|
70
|
+
*/
|
|
71
|
+
export declare function getPrunedBunLocalPathTargets(lockFileContent: string): LocalPathArtifactTarget[];
|
|
72
|
+
/**
|
|
73
|
+
* Fails the pruned build when a `link:` package of the pruned bun.lock requires
|
|
74
|
+
* a dependency the app does not install. Bun installs no dependencies of a
|
|
75
|
+
* link, which loads them from the install root.
|
|
76
|
+
*/
|
|
77
|
+
export declare function validatePrunedBunLocalPathClosure(packageJson: PackageJson, workspaceRootPath: string, lockFileContent: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* Hashes the patch files the root package.json declares, keyed by the declared
|
|
80
|
+
* path. bun.lock records only the path, so these hashes are what change when a
|
|
81
|
+
* patch file does. A missing file gets its own hash, apart from an unpatched
|
|
82
|
+
* package's.
|
|
83
|
+
*/
|
|
84
|
+
export declare function getBunPatchFileHashes(workspaceRootPath: string): Map<string, string>;
|
|
85
|
+
export declare function getBunLockfilePatchKeys(lockFileContent: string): string[];
|