mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-18 05:42:27 -04:00
feat: add cleanupUnusedCatalogs config (#9793)
This commit is contained in:
7
.changeset/large-ducks-wear.md
Normal file
7
.changeset/large-ducks-wear.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
"@pnpm/plugin-commands-installation": minor
|
||||||
|
"@pnpm/workspace.manifest-writer": minor
|
||||||
|
"pnpm": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Added the `cleanupUnusedCatalogs` configuration. When set to `true`, pnpm will remove unused catalog entries during installation [#9793](https://github.com/pnpm/pnpm/pull/9793).
|
||||||
@@ -152,6 +152,7 @@ export interface Config extends OptionsFromRootManifest {
|
|||||||
workspacePackagePatterns?: string[]
|
workspacePackagePatterns?: string[]
|
||||||
catalogs?: Catalogs
|
catalogs?: Catalogs
|
||||||
catalogMode?: 'strict' | 'prefer' | 'manual'
|
catalogMode?: 'strict' | 'prefer' | 'manual'
|
||||||
|
cleanupUnusedCatalogs?: boolean
|
||||||
reporter?: string
|
reporter?: string
|
||||||
aggregateOutput: boolean
|
aggregateOutput: boolean
|
||||||
linkWorkspacePackages: boolean | 'deep'
|
linkWorkspacePackages: boolean | 'deep'
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface StrictInstallOptions {
|
|||||||
autoInstallPeersFromHighestMatch: boolean
|
autoInstallPeersFromHighestMatch: boolean
|
||||||
catalogs: Catalogs
|
catalogs: Catalogs
|
||||||
catalogMode: 'strict' | 'prefer' | 'manual'
|
catalogMode: 'strict' | 'prefer' | 'manual'
|
||||||
|
cleanupUnusedCatalogs: boolean
|
||||||
frozenLockfile: boolean
|
frozenLockfile: boolean
|
||||||
frozenLockfileIfExists: boolean
|
frozenLockfileIfExists: boolean
|
||||||
enableGlobalVirtualStore: boolean
|
enableGlobalVirtualStore: boolean
|
||||||
@@ -244,6 +245,7 @@ const defaults = (opts: InstallOptions): StrictInstallOptions => {
|
|||||||
!process.setgid ||
|
!process.setgid ||
|
||||||
process.getuid?.() !== 0,
|
process.getuid?.() !== 0,
|
||||||
catalogMode: 'manual',
|
catalogMode: 'manual',
|
||||||
|
cleanupUnusedCatalogs: false,
|
||||||
useLockfile: true,
|
useLockfile: true,
|
||||||
saveLockfile: true,
|
saveLockfile: true,
|
||||||
useGitBranchLockfile: false,
|
useGitBranchLockfile: false,
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export type InstallDepsOptions = Pick<Config,
|
|||||||
| 'bin'
|
| 'bin'
|
||||||
| 'catalogs'
|
| 'catalogs'
|
||||||
| 'catalogMode'
|
| 'catalogMode'
|
||||||
|
| 'cleanupUnusedCatalogs'
|
||||||
| 'cliOptions'
|
| 'cliOptions'
|
||||||
| 'dedupePeerDependents'
|
| 'dedupePeerDependents'
|
||||||
| 'depth'
|
| 'depth'
|
||||||
@@ -321,6 +322,8 @@ when running add/update with the --workspace option')
|
|||||||
writeProjectManifest(updatedProject.manifest),
|
writeProjectManifest(updatedProject.manifest),
|
||||||
updateWorkspaceManifest(opts.workspaceDir ?? opts.dir, {
|
updateWorkspaceManifest(opts.workspaceDir ?? opts.dir, {
|
||||||
updatedCatalogs,
|
updatedCatalogs,
|
||||||
|
cleanupUnusedCatalogs: opts.cleanupUnusedCatalogs,
|
||||||
|
allProjects: opts.allProjects,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
@@ -346,6 +349,8 @@ when running add/update with the --workspace option')
|
|||||||
writeProjectManifest(updatedManifest),
|
writeProjectManifest(updatedManifest),
|
||||||
updateWorkspaceManifest(opts.workspaceDir ?? opts.dir, {
|
updateWorkspaceManifest(opts.workspaceDir ?? opts.dir, {
|
||||||
updatedCatalogs,
|
updatedCatalogs,
|
||||||
|
cleanupUnusedCatalogs: opts.cleanupUnusedCatalogs,
|
||||||
|
allProjects,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ export type RecursiveOptions = CreateStoreControllerOptions & Pick<Config,
|
|||||||
| 'lockfileIncludeTarballUrl'
|
| 'lockfileIncludeTarballUrl'
|
||||||
| 'sharedWorkspaceLockfile'
|
| 'sharedWorkspaceLockfile'
|
||||||
| 'tag'
|
| 'tag'
|
||||||
|
| 'cleanupUnusedCatalogs'
|
||||||
> & {
|
> & {
|
||||||
include?: IncludedDependencies
|
include?: IncludedDependencies
|
||||||
includeDirect?: IncludedDependencies
|
includeDirect?: IncludedDependencies
|
||||||
@@ -293,6 +294,8 @@ export async function recursive (
|
|||||||
})
|
})
|
||||||
promises.push(updateWorkspaceManifest(opts.workspaceDir, {
|
promises.push(updateWorkspaceManifest(opts.workspaceDir, {
|
||||||
updatedCatalogs,
|
updatedCatalogs,
|
||||||
|
cleanupUnusedCatalogs: opts.cleanupUnusedCatalogs,
|
||||||
|
allProjects,
|
||||||
}))
|
}))
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
}
|
}
|
||||||
@@ -441,6 +444,8 @@ export async function recursive (
|
|||||||
|
|
||||||
await updateWorkspaceManifest(opts.workspaceDir, {
|
await updateWorkspaceManifest(opts.workspaceDir, {
|
||||||
updatedCatalogs,
|
updatedCatalogs,
|
||||||
|
cleanupUnusedCatalogs: opts.cleanupUnusedCatalogs,
|
||||||
|
allProjects,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
282
pnpm-lock.yaml
generated
282
pnpm-lock.yaml
generated
@@ -812,7 +812,7 @@ importers:
|
|||||||
version: link:../packages/logger
|
version: link:../packages/logger
|
||||||
'@pnpm/meta-updater':
|
'@pnpm/meta-updater':
|
||||||
specifier: 'catalog:'
|
specifier: 'catalog:'
|
||||||
version: 2.0.6(@types/node@22.15.29)(typanion@3.14.0)
|
version: 2.0.6(@types/node@18.19.34)(typanion@3.14.0)
|
||||||
'@pnpm/object.key-sorting':
|
'@pnpm/object.key-sorting':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../object/key-sorting
|
version: link:../object/key-sorting
|
||||||
@@ -8496,6 +8496,9 @@ importers:
|
|||||||
'@pnpm/object.key-sorting':
|
'@pnpm/object.key-sorting':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../object/key-sorting
|
version: link:../../object/key-sorting
|
||||||
|
'@pnpm/types':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../../packages/types
|
||||||
'@pnpm/workspace.read-manifest':
|
'@pnpm/workspace.read-manifest':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../read-manifest
|
version: link:../read-manifest
|
||||||
@@ -8506,6 +8509,12 @@ importers:
|
|||||||
specifier: 'catalog:'
|
specifier: 'catalog:'
|
||||||
version: 5.0.0
|
version: 5.0.0
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
'@pnpm/fs.find-packages':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../../fs/find-packages
|
||||||
|
'@pnpm/prepare':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../../__utils__/prepare
|
||||||
'@pnpm/prepare-temp-dir':
|
'@pnpm/prepare-temp-dir':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../__utils__/prepare-temp-dir
|
version: link:../../__utils__/prepare-temp-dir
|
||||||
@@ -8840,10 +8849,6 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@babel/core': ^7.0.0-0
|
'@babel/core': ^7.0.0-0
|
||||||
|
|
||||||
'@babel/runtime@7.27.4':
|
|
||||||
resolution: {integrity: sha512-t3yaEOuGu9NlIZ+hIeGbBjFtZT7j2cb2tg0fuaJKeGotchRjjLfrBA9Kwf8quhpP1EUuxModQg04q/mBwyg8uA==}
|
|
||||||
engines: {node: '>=6.9.0'}
|
|
||||||
|
|
||||||
'@babel/runtime@7.28.2':
|
'@babel/runtime@7.28.2':
|
||||||
resolution: {integrity: sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA==}
|
resolution: {integrity: sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
@@ -15885,8 +15890,6 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@babel/runtime@7.27.4': {}
|
|
||||||
|
|
||||||
'@babel/runtime@7.28.2': {}
|
'@babel/runtime@7.28.2': {}
|
||||||
|
|
||||||
'@babel/template@7.27.2':
|
'@babel/template@7.27.2':
|
||||||
@@ -16585,14 +16588,14 @@ snapshots:
|
|||||||
'@jest/test-result': 29.7.0
|
'@jest/test-result': 29.7.0
|
||||||
'@jest/transform': 29.7.0(@babel/types@7.26.10)
|
'@jest/transform': 29.7.0(@babel/types@7.26.10)
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 18.19.34
|
'@types/node': 22.15.29
|
||||||
ansi-escapes: 4.3.2
|
ansi-escapes: 4.3.2
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
ci-info: 3.9.0
|
ci-info: 3.9.0
|
||||||
exit: 0.1.2
|
exit: 0.1.2
|
||||||
graceful-fs: 4.2.11(patch_hash=68ebc232025360cb3dcd3081f4067f4e9fc022ab6b6f71a3230e86c7a5b337d1)
|
graceful-fs: 4.2.11(patch_hash=68ebc232025360cb3dcd3081f4067f4e9fc022ab6b6f71a3230e86c7a5b337d1)
|
||||||
jest-changed-files: 29.7.0
|
jest-changed-files: 29.7.0
|
||||||
jest-config: 29.7.0(@babel/types@7.26.10)(@types/node@18.19.34)(ts-node@10.9.2(@types/node@18.19.34)(typescript@5.5.4))
|
jest-config: 29.7.0(@babel/types@7.26.10)(@types/node@22.15.29)(ts-node@10.9.2(@types/node@18.19.34)(typescript@5.5.4))
|
||||||
jest-haste-map: 29.7.0
|
jest-haste-map: 29.7.0
|
||||||
jest-message-util: 29.7.0
|
jest-message-util: 29.7.0
|
||||||
jest-regex-util: 29.6.3
|
jest-regex-util: 29.6.3
|
||||||
@@ -16730,7 +16733,7 @@ snapshots:
|
|||||||
'@jest/schemas': 29.6.3
|
'@jest/schemas': 29.6.3
|
||||||
'@types/istanbul-lib-coverage': 2.0.6
|
'@types/istanbul-lib-coverage': 2.0.6
|
||||||
'@types/istanbul-reports': 3.0.4
|
'@types/istanbul-reports': 3.0.4
|
||||||
'@types/node': 18.19.34
|
'@types/node': 22.15.29
|
||||||
'@types/yargs': 17.0.33
|
'@types/yargs': 17.0.33
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
|
|
||||||
@@ -16796,7 +16799,7 @@ snapshots:
|
|||||||
|
|
||||||
'@npmcli/fs@4.0.0':
|
'@npmcli/fs@4.0.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
semver: 7.7.1
|
semver: 7.7.2
|
||||||
|
|
||||||
'@pkgjs/parseargs@0.11.0':
|
'@pkgjs/parseargs@0.11.0':
|
||||||
optional: true
|
optional: true
|
||||||
@@ -16866,28 +16869,6 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- typanion
|
- typanion
|
||||||
|
|
||||||
'@pnpm/cli-utils@1000.1.5(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/cli-meta': 1000.0.8
|
|
||||||
'@pnpm/config': 1003.1.1(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/config.deps-installer': 1000.0.5(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))
|
|
||||||
'@pnpm/default-reporter': 1002.0.1(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/error': 1000.0.2
|
|
||||||
'@pnpm/logger': 1001.0.0
|
|
||||||
'@pnpm/manifest-utils': 1001.0.1(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/package-is-installable': 1000.0.10(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/pnpmfile': 1001.2.2(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/read-project-manifest': 1000.0.11
|
|
||||||
'@pnpm/store-connection-manager': 1002.0.3(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)
|
|
||||||
'@pnpm/types': 1000.6.0
|
|
||||||
chalk: 4.1.2
|
|
||||||
load-json-file: 6.2.0
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@pnpm/worker'
|
|
||||||
- domexception
|
|
||||||
- supports-color
|
|
||||||
- typanion
|
|
||||||
|
|
||||||
'@pnpm/client@1000.0.19(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@18.19.34))(typanion@3.14.0)':
|
'@pnpm/client@1000.0.19(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@18.19.34))(typanion@3.14.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pnpm/default-resolver': 1002.0.2(@pnpm/logger@1001.0.0)
|
'@pnpm/default-resolver': 1002.0.2(@pnpm/logger@1001.0.0)
|
||||||
@@ -16907,25 +16888,6 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- typanion
|
- typanion
|
||||||
|
|
||||||
'@pnpm/client@1000.0.19(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/default-resolver': 1002.0.2(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/directory-fetcher': 1000.1.7(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/fetch': 1000.2.2(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/fetching-types': 1000.1.0
|
|
||||||
'@pnpm/git-fetcher': 1001.0.8(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)
|
|
||||||
'@pnpm/network.auth-header': 1000.0.3
|
|
||||||
'@pnpm/resolver-base': 1003.0.1
|
|
||||||
'@pnpm/tarball-fetcher': 1001.0.8(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)
|
|
||||||
'@pnpm/types': 1000.6.0
|
|
||||||
ramda: '@pnpm/ramda@0.28.1'
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@pnpm/logger'
|
|
||||||
- '@pnpm/worker'
|
|
||||||
- domexception
|
|
||||||
- supports-color
|
|
||||||
- typanion
|
|
||||||
|
|
||||||
'@pnpm/colorize-semver-diff@1.0.1':
|
'@pnpm/colorize-semver-diff@1.0.1':
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
@@ -16959,28 +16921,6 @@ snapshots:
|
|||||||
- domexception
|
- domexception
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@pnpm/config.deps-installer@1000.0.5(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/config.config-writer': 1000.0.5
|
|
||||||
'@pnpm/core-loggers': 1001.0.1(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/error': 1000.0.2
|
|
||||||
'@pnpm/fetch': 1000.2.2(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/logger': 1001.0.0
|
|
||||||
'@pnpm/network.auth-header': 1000.0.3
|
|
||||||
'@pnpm/npm-resolver': 1004.0.1(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/package-store': 1002.0.4(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))
|
|
||||||
'@pnpm/parse-wanted-dependency': 1001.0.0
|
|
||||||
'@pnpm/pick-registry-for-package': 1000.0.8
|
|
||||||
'@pnpm/read-modules-dir': 1000.0.0
|
|
||||||
'@pnpm/read-package-json': 1000.0.9
|
|
||||||
'@pnpm/types': 1000.6.0
|
|
||||||
'@zkochan/rimraf': 3.0.2
|
|
||||||
get-npm-tarball-url: 2.1.0
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@pnpm/worker'
|
|
||||||
- domexception
|
|
||||||
- supports-color
|
|
||||||
|
|
||||||
'@pnpm/config.env-replace@1.1.0': {}
|
'@pnpm/config.env-replace@1.1.0': {}
|
||||||
|
|
||||||
'@pnpm/config.env-replace@3.0.1': {}
|
'@pnpm/config.env-replace@3.0.1': {}
|
||||||
@@ -17290,19 +17230,6 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- typanion
|
- typanion
|
||||||
|
|
||||||
'@pnpm/git-fetcher@1001.0.8(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/fetcher-base': 1000.0.11
|
|
||||||
'@pnpm/fs.packlist': 2.0.0
|
|
||||||
'@pnpm/logger': 1001.0.0
|
|
||||||
'@pnpm/prepare-package': 1000.0.16(@pnpm/logger@1001.0.0)(typanion@3.14.0)
|
|
||||||
'@pnpm/worker': 1000.1.7(@pnpm/logger@packages+logger)(@types/node@22.15.29)
|
|
||||||
'@zkochan/rimraf': 3.0.2
|
|
||||||
execa: safe-execa@0.1.2
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
- typanion
|
|
||||||
|
|
||||||
'@pnpm/git-resolver@1001.0.2(@pnpm/logger@1001.0.0)':
|
'@pnpm/git-resolver@1001.0.2(@pnpm/logger@1001.0.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pnpm/fetch': 1000.2.2(@pnpm/logger@1001.0.0)
|
'@pnpm/fetch': 1000.2.2(@pnpm/logger@1001.0.0)
|
||||||
@@ -17449,24 +17376,6 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- typanion
|
- typanion
|
||||||
|
|
||||||
'@pnpm/meta-updater@2.0.6(@types/node@22.15.29)(typanion@3.14.0)':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/find-workspace-dir': 1000.1.0
|
|
||||||
'@pnpm/logger': 1001.0.0
|
|
||||||
'@pnpm/types': 1000.6.0
|
|
||||||
'@pnpm/worker': 1000.1.7(@pnpm/logger@packages+logger)(@types/node@22.15.29)
|
|
||||||
'@pnpm/workspace.find-packages': 1000.0.25(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)
|
|
||||||
'@pnpm/workspace.read-manifest': 1000.1.5
|
|
||||||
load-json-file: 7.0.1
|
|
||||||
meow: 11.0.0
|
|
||||||
print-diff: 2.0.0
|
|
||||||
write-json-file: 5.0.0
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@types/node'
|
|
||||||
- domexception
|
|
||||||
- supports-color
|
|
||||||
- typanion
|
|
||||||
|
|
||||||
'@pnpm/network.agent@2.0.3':
|
'@pnpm/network.agent@2.0.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pnpm/network.config': 2.1.0
|
'@pnpm/network.config': 2.1.0
|
||||||
@@ -17647,30 +17556,6 @@ snapshots:
|
|||||||
semver: 7.7.2
|
semver: 7.7.2
|
||||||
ssri: 10.0.5
|
ssri: 10.0.5
|
||||||
|
|
||||||
'@pnpm/package-requester@1004.0.2(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/core-loggers': 1001.0.1(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/dependency-path': 1000.0.9
|
|
||||||
'@pnpm/error': 1000.0.2
|
|
||||||
'@pnpm/fetcher-base': 1000.0.11
|
|
||||||
'@pnpm/graceful-fs': 1000.0.0
|
|
||||||
'@pnpm/logger': 1001.0.0
|
|
||||||
'@pnpm/package-is-installable': 1000.0.10(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/pick-fetcher': 1000.0.0
|
|
||||||
'@pnpm/read-package-json': 1000.0.9
|
|
||||||
'@pnpm/resolver-base': 1003.0.1
|
|
||||||
'@pnpm/store-controller-types': 1003.0.2
|
|
||||||
'@pnpm/store.cafs': 1000.0.13
|
|
||||||
'@pnpm/types': 1000.6.0
|
|
||||||
'@pnpm/worker': 1000.1.7(@pnpm/logger@packages+logger)(@types/node@22.15.29)
|
|
||||||
p-defer: 3.0.0
|
|
||||||
p-limit: 3.1.0
|
|
||||||
p-queue: 6.6.2
|
|
||||||
promise-share: 1.0.0
|
|
||||||
ramda: '@pnpm/ramda@0.28.1'
|
|
||||||
semver: 7.7.2
|
|
||||||
ssri: 10.0.5
|
|
||||||
|
|
||||||
'@pnpm/package-store@1002.0.4(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@18.19.34))':
|
'@pnpm/package-store@1002.0.4(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@18.19.34))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pnpm/create-cafs-store': 1000.0.14(@pnpm/logger@1001.0.0)
|
'@pnpm/create-cafs-store': 1000.0.14(@pnpm/logger@1001.0.0)
|
||||||
@@ -17687,22 +17572,6 @@ snapshots:
|
|||||||
ramda: '@pnpm/ramda@0.28.1'
|
ramda: '@pnpm/ramda@0.28.1'
|
||||||
ssri: 10.0.5
|
ssri: 10.0.5
|
||||||
|
|
||||||
'@pnpm/package-store@1002.0.4(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/create-cafs-store': 1000.0.14(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/fetcher-base': 1000.0.11
|
|
||||||
'@pnpm/logger': 1001.0.0
|
|
||||||
'@pnpm/package-requester': 1004.0.2(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))
|
|
||||||
'@pnpm/resolver-base': 1003.0.1
|
|
||||||
'@pnpm/store-controller-types': 1003.0.2
|
|
||||||
'@pnpm/store.cafs': 1000.0.13
|
|
||||||
'@pnpm/types': 1000.6.0
|
|
||||||
'@pnpm/worker': 1000.1.7(@pnpm/logger@packages+logger)(@types/node@22.15.29)
|
|
||||||
'@zkochan/rimraf': 3.0.2
|
|
||||||
load-json-file: 6.2.0
|
|
||||||
ramda: '@pnpm/ramda@0.28.1'
|
|
||||||
ssri: 10.0.5
|
|
||||||
|
|
||||||
'@pnpm/parse-overrides@1000.0.2':
|
'@pnpm/parse-overrides@1000.0.2':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pnpm/catalogs.resolver': 1000.0.2
|
'@pnpm/catalogs.resolver': 1000.0.2
|
||||||
@@ -17919,25 +17788,6 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- typanion
|
- typanion
|
||||||
|
|
||||||
'@pnpm/store-connection-manager@1002.0.3(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/cli-meta': 1000.0.8
|
|
||||||
'@pnpm/client': 1000.0.19(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)
|
|
||||||
'@pnpm/config': 1003.1.1(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/error': 1000.0.2
|
|
||||||
'@pnpm/logger': 1001.0.0
|
|
||||||
'@pnpm/package-store': 1002.0.4(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))
|
|
||||||
'@pnpm/server': 1001.0.4(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/store-path': 1000.0.2
|
|
||||||
'@zkochan/diable': 1.0.2
|
|
||||||
delay: 5.0.0
|
|
||||||
dir-is-case-sensitive: 2.0.0
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@pnpm/worker'
|
|
||||||
- domexception
|
|
||||||
- supports-color
|
|
||||||
- typanion
|
|
||||||
|
|
||||||
'@pnpm/store-controller-types@1001.0.3':
|
'@pnpm/store-controller-types@1001.0.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pnpm/fetcher-base': 1000.0.5
|
'@pnpm/fetcher-base': 1000.0.5
|
||||||
@@ -18011,28 +17861,6 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- typanion
|
- typanion
|
||||||
|
|
||||||
'@pnpm/tarball-fetcher@1001.0.8(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/core-loggers': 1001.0.1(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/error': 1000.0.2
|
|
||||||
'@pnpm/fetcher-base': 1000.0.11
|
|
||||||
'@pnpm/fetching-types': 1000.1.0
|
|
||||||
'@pnpm/fs.packlist': 2.0.0
|
|
||||||
'@pnpm/graceful-fs': 1000.0.0
|
|
||||||
'@pnpm/logger': 1001.0.0
|
|
||||||
'@pnpm/prepare-package': 1000.0.16(@pnpm/logger@1001.0.0)(typanion@3.14.0)
|
|
||||||
'@pnpm/worker': 1000.1.7(@pnpm/logger@packages+logger)(@types/node@22.15.29)
|
|
||||||
'@zkochan/retry': 0.2.0
|
|
||||||
lodash.throttle: 4.1.1
|
|
||||||
p-map-values: 1.0.0
|
|
||||||
path-temp: 2.1.0
|
|
||||||
ramda: '@pnpm/ramda@0.28.1'
|
|
||||||
rename-overwrite: 6.0.3
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- domexception
|
|
||||||
- supports-color
|
|
||||||
- typanion
|
|
||||||
|
|
||||||
'@pnpm/tarball-resolver@1002.0.2':
|
'@pnpm/tarball-resolver@1002.0.2':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pnpm/fetching-types': 1000.1.0
|
'@pnpm/fetching-types': 1000.1.0
|
||||||
@@ -18080,26 +17908,6 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@types/node'
|
- '@types/node'
|
||||||
|
|
||||||
'@pnpm/worker@1000.1.7(@pnpm/logger@packages+logger)(@types/node@22.15.29)':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/cafs-types': 1000.0.0
|
|
||||||
'@pnpm/create-cafs-store': 1000.0.14(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/crypto.polyfill': 1000.1.0
|
|
||||||
'@pnpm/error': 1000.0.2
|
|
||||||
'@pnpm/exec.pkg-requires-build': 1000.0.8
|
|
||||||
'@pnpm/fs.hard-link-dir': 1000.0.1(@pnpm/logger@1001.0.0)
|
|
||||||
'@pnpm/graceful-fs': 1000.0.0
|
|
||||||
'@pnpm/logger': link:packages/logger
|
|
||||||
'@pnpm/store.cafs': 1000.0.13
|
|
||||||
'@pnpm/symlink-dependency': 1000.0.9(@pnpm/logger@1001.0.0)
|
|
||||||
'@rushstack/worker-pool': 0.4.9(@types/node@22.15.29)
|
|
||||||
is-windows: 1.0.2
|
|
||||||
load-json-file: 6.2.0
|
|
||||||
p-limit: 3.1.0
|
|
||||||
shell-quote: 1.8.3
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@types/node'
|
|
||||||
|
|
||||||
'@pnpm/workspace.find-packages@1000.0.15(@pnpm/logger@1000.0.0)':
|
'@pnpm/workspace.find-packages@1000.0.15(@pnpm/logger@1000.0.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pnpm/cli-utils': 1000.0.15(@pnpm/logger@1000.0.0)
|
'@pnpm/cli-utils': 1000.0.15(@pnpm/logger@1000.0.0)
|
||||||
@@ -18123,20 +17931,6 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- typanion
|
- typanion
|
||||||
|
|
||||||
'@pnpm/workspace.find-packages@1000.0.25(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)':
|
|
||||||
dependencies:
|
|
||||||
'@pnpm/cli-utils': 1000.1.5(@pnpm/logger@1001.0.0)(@pnpm/worker@1000.1.7(@pnpm/logger@1001.0.0)(@types/node@22.15.29))(typanion@3.14.0)
|
|
||||||
'@pnpm/constants': 1001.1.0
|
|
||||||
'@pnpm/fs.find-packages': 1000.0.11
|
|
||||||
'@pnpm/logger': 1001.0.0
|
|
||||||
'@pnpm/types': 1000.6.0
|
|
||||||
'@pnpm/util.lex-comparator': 3.0.2
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@pnpm/worker'
|
|
||||||
- domexception
|
|
||||||
- supports-color
|
|
||||||
- typanion
|
|
||||||
|
|
||||||
'@pnpm/workspace.manifest-writer@1000.1.4':
|
'@pnpm/workspace.manifest-writer@1000.1.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pnpm/constants': 1001.1.0
|
'@pnpm/constants': 1001.1.0
|
||||||
@@ -18338,7 +18132,7 @@ snapshots:
|
|||||||
|
|
||||||
'@types/isexe@2.0.2':
|
'@types/isexe@2.0.2':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 18.19.34
|
'@types/node': 22.15.29
|
||||||
|
|
||||||
'@types/istanbul-lib-coverage@2.0.6': {}
|
'@types/istanbul-lib-coverage@2.0.6': {}
|
||||||
|
|
||||||
@@ -18461,7 +18255,7 @@ snapshots:
|
|||||||
|
|
||||||
'@types/touch@3.1.5':
|
'@types/touch@3.1.5':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 18.19.34
|
'@types/node': 22.15.29
|
||||||
|
|
||||||
'@types/treeify@1.0.3': {}
|
'@types/treeify@1.0.3': {}
|
||||||
|
|
||||||
@@ -19817,7 +19611,7 @@ snapshots:
|
|||||||
|
|
||||||
date-fns@2.30.0:
|
date-fns@2.30.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.27.4
|
'@babel/runtime': 7.28.2
|
||||||
|
|
||||||
dayjs@1.11.7: {}
|
dayjs@1.11.7: {}
|
||||||
|
|
||||||
@@ -19922,7 +19716,7 @@ snapshots:
|
|||||||
|
|
||||||
didyoumean2@6.0.1:
|
didyoumean2@6.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.27.4
|
'@babel/runtime': 7.28.2
|
||||||
fastest-levenshtein: 1.0.16
|
fastest-levenshtein: 1.0.16
|
||||||
lodash.deburr: 4.1.0
|
lodash.deburr: 4.1.0
|
||||||
|
|
||||||
@@ -21529,6 +21323,38 @@ snapshots:
|
|||||||
- babel-plugin-macros
|
- babel-plugin-macros
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
jest-config@29.7.0(@babel/types@7.26.10)(@types/node@22.15.29)(ts-node@10.9.2(@types/node@18.19.34)(typescript@5.5.4)):
|
||||||
|
dependencies:
|
||||||
|
'@babel/core': 7.26.10
|
||||||
|
'@jest/test-sequencer': 29.7.0
|
||||||
|
'@jest/types': 29.6.3
|
||||||
|
babel-jest: 29.7.0(@babel/core@7.26.10)(@babel/types@7.26.10)
|
||||||
|
chalk: 4.1.2
|
||||||
|
ci-info: 3.9.0
|
||||||
|
deepmerge: 4.3.1
|
||||||
|
glob: 7.2.3
|
||||||
|
graceful-fs: 4.2.11(patch_hash=68ebc232025360cb3dcd3081f4067f4e9fc022ab6b6f71a3230e86c7a5b337d1)
|
||||||
|
jest-circus: 29.7.0(@babel/types@7.26.10)
|
||||||
|
jest-environment-node: 29.7.0
|
||||||
|
jest-get-type: 29.6.3
|
||||||
|
jest-regex-util: 29.6.3
|
||||||
|
jest-resolve: 29.7.0
|
||||||
|
jest-runner: 29.7.0(@babel/types@7.26.10)
|
||||||
|
jest-util: 29.7.0
|
||||||
|
jest-validate: 29.7.0
|
||||||
|
micromatch: 4.0.8
|
||||||
|
parse-json: 5.2.0
|
||||||
|
pretty-format: 29.7.0
|
||||||
|
slash: 3.0.0
|
||||||
|
strip-json-comments: 3.1.1
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/node': 22.15.29
|
||||||
|
ts-node: 10.9.2(@types/node@18.19.34)(typescript@5.5.4)
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@babel/types'
|
||||||
|
- babel-plugin-macros
|
||||||
|
- supports-color
|
||||||
|
|
||||||
jest-diff@29.7.0:
|
jest-diff@29.7.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
@@ -21713,7 +21539,7 @@ snapshots:
|
|||||||
jest-util@29.7.0:
|
jest-util@29.7.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 18.19.34
|
'@types/node': 22.15.29
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
ci-info: 3.9.0
|
ci-info: 3.9.0
|
||||||
graceful-fs: 4.2.11(patch_hash=68ebc232025360cb3dcd3081f4067f4e9fc022ab6b6f71a3230e86c7a5b337d1)
|
graceful-fs: 4.2.11(patch_hash=68ebc232025360cb3dcd3081f4067f4e9fc022ab6b6f71a3230e86c7a5b337d1)
|
||||||
@@ -22350,7 +22176,7 @@ snapshots:
|
|||||||
make-fetch-happen: 14.0.3
|
make-fetch-happen: 14.0.3
|
||||||
nopt: 8.1.0
|
nopt: 8.1.0
|
||||||
proc-log: 5.0.0
|
proc-log: 5.0.0
|
||||||
semver: 7.7.1
|
semver: 7.7.2
|
||||||
tar: 7.4.3
|
tar: 7.4.3
|
||||||
which: 5.0.0
|
which: 5.0.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -23266,7 +23092,7 @@ snapshots:
|
|||||||
semver-range-intersect@0.3.1:
|
semver-range-intersect@0.3.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/semver': 6.2.7
|
'@types/semver': 6.2.7
|
||||||
semver: 7.7.1
|
semver: 7.7.2
|
||||||
|
|
||||||
semver-utils@1.1.4: {}
|
semver-utils@1.1.4: {}
|
||||||
|
|
||||||
@@ -24203,7 +24029,7 @@ snapshots:
|
|||||||
|
|
||||||
version-selector-type@3.0.0:
|
version-selector-type@3.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
semver: 7.7.1
|
semver: 7.7.2
|
||||||
|
|
||||||
vfile-message@2.0.4:
|
vfile-message@2.0.4:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -35,11 +35,14 @@
|
|||||||
"@pnpm/constants": "workspace:*",
|
"@pnpm/constants": "workspace:*",
|
||||||
"@pnpm/lockfile.types": "workspace:*",
|
"@pnpm/lockfile.types": "workspace:*",
|
||||||
"@pnpm/object.key-sorting": "workspace:*",
|
"@pnpm/object.key-sorting": "workspace:*",
|
||||||
|
"@pnpm/types": "workspace:*",
|
||||||
"@pnpm/workspace.read-manifest": "workspace:*",
|
"@pnpm/workspace.read-manifest": "workspace:*",
|
||||||
"ramda": "catalog:",
|
"ramda": "catalog:",
|
||||||
"write-yaml-file": "catalog:"
|
"write-yaml-file": "catalog:"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@pnpm/fs.find-packages": "workspace:*",
|
||||||
|
"@pnpm/prepare": "workspace:*",
|
||||||
"@pnpm/prepare-temp-dir": "workspace:*",
|
"@pnpm/prepare-temp-dir": "workspace:*",
|
||||||
"@pnpm/workspace.manifest-writer": "workspace:*",
|
"@pnpm/workspace.manifest-writer": "workspace:*",
|
||||||
"@types/ramda": "catalog:",
|
"@types/ramda": "catalog:",
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import { WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants'
|
|||||||
import writeYamlFile from 'write-yaml-file'
|
import writeYamlFile from 'write-yaml-file'
|
||||||
import equals from 'ramda/src/equals'
|
import equals from 'ramda/src/equals'
|
||||||
import { sortKeysByPriority } from '@pnpm/object.key-sorting'
|
import { sortKeysByPriority } from '@pnpm/object.key-sorting'
|
||||||
|
import {
|
||||||
|
type Project,
|
||||||
|
} from '@pnpm/types'
|
||||||
|
|
||||||
async function writeManifestFile (dir: string, manifest: Partial<WorkspaceManifest>): Promise<void> {
|
async function writeManifestFile (dir: string, manifest: Partial<WorkspaceManifest>): Promise<void> {
|
||||||
manifest = sortKeysByPriority({
|
manifest = sortKeysByPriority({
|
||||||
@@ -25,9 +28,14 @@ async function writeManifestFile (dir: string, manifest: Partial<WorkspaceManife
|
|||||||
export async function updateWorkspaceManifest (dir: string, opts: {
|
export async function updateWorkspaceManifest (dir: string, opts: {
|
||||||
updatedFields?: Partial<WorkspaceManifest>
|
updatedFields?: Partial<WorkspaceManifest>
|
||||||
updatedCatalogs?: Catalogs
|
updatedCatalogs?: Catalogs
|
||||||
|
cleanupUnusedCatalogs?: boolean
|
||||||
|
allProjects?: Project[]
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const manifest = await readWorkspaceManifest(dir) ?? {} as WorkspaceManifest
|
const manifest = await readWorkspaceManifest(dir) ?? {} as WorkspaceManifest
|
||||||
let shouldBeUpdated = opts.updatedCatalogs != null && addCatalogs(manifest, opts.updatedCatalogs)
|
let shouldBeUpdated = opts.updatedCatalogs != null && addCatalogs(manifest, opts.updatedCatalogs)
|
||||||
|
if (opts.cleanupUnusedCatalogs) {
|
||||||
|
shouldBeUpdated = removePackagesFromWorkspaceCatalog(manifest, opts.allProjects ?? []) || shouldBeUpdated
|
||||||
|
}
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(opts.updatedFields ?? {})) {
|
for (const [key, value] of Object.entries(opts.updatedFields ?? {})) {
|
||||||
if (!equals(manifest[key as keyof WorkspaceManifest], value)) {
|
if (!equals(manifest[key as keyof WorkspaceManifest], value)) {
|
||||||
@@ -90,3 +98,83 @@ function addCatalogs (manifest: Partial<WorkspaceManifest>, newCatalogs: Catalog
|
|||||||
|
|
||||||
return shouldBeUpdated
|
return shouldBeUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removePackagesFromWorkspaceCatalog (manifest: Partial<WorkspaceManifest>, packagesJson: Project[]): boolean {
|
||||||
|
let shouldBeUpdated = false
|
||||||
|
|
||||||
|
if (manifest.catalog == null && manifest.catalogs == null) {
|
||||||
|
return shouldBeUpdated
|
||||||
|
}
|
||||||
|
const packageReferences: Record<string, Set<string>> = {}
|
||||||
|
|
||||||
|
for (const pkg of packagesJson) {
|
||||||
|
const pkgManifest = pkg.manifest
|
||||||
|
const dependencyTypes = [
|
||||||
|
pkgManifest.dependencies,
|
||||||
|
pkgManifest.devDependencies,
|
||||||
|
pkgManifest.optionalDependencies,
|
||||||
|
pkgManifest.peerDependencies,
|
||||||
|
]
|
||||||
|
|
||||||
|
for (const deps of dependencyTypes) {
|
||||||
|
if (!deps) continue
|
||||||
|
|
||||||
|
for (const [pkgName, version] of Object.entries(deps)) {
|
||||||
|
if (!packageReferences[pkgName]) {
|
||||||
|
packageReferences[pkgName] = new Set()
|
||||||
|
}
|
||||||
|
packageReferences[pkgName].add(version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (manifest.catalog) {
|
||||||
|
const packagesToRemove = Object.keys(manifest.catalog).filter(pkg =>
|
||||||
|
!packageReferences[pkg]?.has('catalog:')
|
||||||
|
)
|
||||||
|
|
||||||
|
for (const pkg of packagesToRemove) {
|
||||||
|
delete manifest.catalog![pkg]
|
||||||
|
shouldBeUpdated = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(manifest.catalog).length === 0) {
|
||||||
|
delete manifest.catalog
|
||||||
|
shouldBeUpdated = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (manifest.catalogs) {
|
||||||
|
const catalogsToRemove: string[] = []
|
||||||
|
|
||||||
|
for (const [catalogName, catalog] of Object.entries(manifest.catalogs)) {
|
||||||
|
if (!catalog) continue
|
||||||
|
|
||||||
|
const packagesToRemove = Object.keys(catalog).filter(pkg => {
|
||||||
|
const references = packageReferences[pkg]
|
||||||
|
return !references?.has(`catalog:${catalogName}`) && !references?.has('catalog:')
|
||||||
|
})
|
||||||
|
|
||||||
|
for (const pkg of packagesToRemove) {
|
||||||
|
delete catalog[pkg]
|
||||||
|
shouldBeUpdated = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(catalog).length === 0) {
|
||||||
|
catalogsToRemove.push(catalogName)
|
||||||
|
shouldBeUpdated = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const catalogName of catalogsToRemove) {
|
||||||
|
delete manifest.catalogs[catalogName]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(manifest.catalogs).length === 0) {
|
||||||
|
delete manifest.catalogs
|
||||||
|
shouldBeUpdated = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return shouldBeUpdated
|
||||||
|
}
|
||||||
|
|||||||
298
workspace/manifest-writer/test/removeCatalogs.test.ts
Normal file
298
workspace/manifest-writer/test/removeCatalogs.test.ts
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
import path from 'path'
|
||||||
|
import fs from 'fs'
|
||||||
|
import { WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants'
|
||||||
|
import { tempDir } from '@pnpm/prepare-temp-dir'
|
||||||
|
import { prepare } from '@pnpm/prepare'
|
||||||
|
import { updateWorkspaceManifest } from '@pnpm/workspace.manifest-writer'
|
||||||
|
import { sync as readYamlFile } from 'read-yaml-file'
|
||||||
|
import { sync as writeYamlFile } from 'write-yaml-file'
|
||||||
|
import { findPackages } from '@pnpm/fs.find-packages'
|
||||||
|
|
||||||
|
test('remove the default catalog if it is empty', async () => {
|
||||||
|
const dir = tempDir(false)
|
||||||
|
const filePath = path.join(dir, WORKSPACE_MANIFEST_FILENAME)
|
||||||
|
prepare({
|
||||||
|
dependencies: {
|
||||||
|
foo: '^0.1.2',
|
||||||
|
},
|
||||||
|
}, { tempDir: dir })
|
||||||
|
const allProjects = await findPackages(dir)
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
updatedCatalogs: {
|
||||||
|
default: {},
|
||||||
|
},
|
||||||
|
allProjects,
|
||||||
|
})
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
updatedCatalogs: {
|
||||||
|
default: {
|
||||||
|
foo: '^0.1.2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalog: {
|
||||||
|
foo: '^0.1.2',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
cleanupUnusedCatalogs: true,
|
||||||
|
allProjects,
|
||||||
|
})
|
||||||
|
expect(fs.existsSync(filePath)).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('remove the unused default catalog', async () => {
|
||||||
|
const dir = tempDir(false)
|
||||||
|
const filePath = path.join(dir, WORKSPACE_MANIFEST_FILENAME)
|
||||||
|
writeYamlFile(filePath, {
|
||||||
|
catalog: {
|
||||||
|
bar: '3.2.1',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
updatedCatalogs: {
|
||||||
|
default: {
|
||||||
|
foo: '^0.1.2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalog: {
|
||||||
|
bar: '3.2.1',
|
||||||
|
foo: '^0.1.2',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
prepare({
|
||||||
|
dependencies: {
|
||||||
|
foo: '^0.1.2',
|
||||||
|
bar: 'catalog:',
|
||||||
|
},
|
||||||
|
}, { tempDir: dir })
|
||||||
|
const allProjects = await findPackages(dir)
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
cleanupUnusedCatalogs: true,
|
||||||
|
allProjects,
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalog: {
|
||||||
|
bar: '3.2.1',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test('remove the unused default catalog with catalogs', async () => {
|
||||||
|
const dir = tempDir(false)
|
||||||
|
const filePath = path.join(dir, WORKSPACE_MANIFEST_FILENAME)
|
||||||
|
writeYamlFile(filePath, {
|
||||||
|
catalogs: {
|
||||||
|
default: {
|
||||||
|
bar: '3.2.1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
updatedCatalogs: {
|
||||||
|
default: {
|
||||||
|
foo: '^0.1.2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalogs: {
|
||||||
|
default: {
|
||||||
|
bar: '3.2.1',
|
||||||
|
foo: '^0.1.2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
prepare({
|
||||||
|
dependencies: {
|
||||||
|
foo: '^0.1.2',
|
||||||
|
bar: 'catalog:',
|
||||||
|
},
|
||||||
|
}, { tempDir: dir })
|
||||||
|
const allProjects = await findPackages(dir)
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
cleanupUnusedCatalogs: true,
|
||||||
|
allProjects,
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalogs: {
|
||||||
|
default: {
|
||||||
|
bar: '3.2.1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test('remove the unused named catalog', async () => {
|
||||||
|
const dir = tempDir(false)
|
||||||
|
const filePath = path.join(dir, WORKSPACE_MANIFEST_FILENAME)
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
updatedCatalogs: {
|
||||||
|
foo: {
|
||||||
|
abc: '0.1.2',
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
def: '3.2.1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalogs: {
|
||||||
|
foo: {
|
||||||
|
abc: '0.1.2',
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
def: '3.2.1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
prepare({
|
||||||
|
dependencies: {
|
||||||
|
abc: '0.1.2',
|
||||||
|
def: 'catalog:bar',
|
||||||
|
},
|
||||||
|
}, { tempDir: dir })
|
||||||
|
const allProjects = await findPackages(dir)
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
cleanupUnusedCatalogs: true,
|
||||||
|
allProjects,
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalogs: {
|
||||||
|
bar: {
|
||||||
|
def: '3.2.1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test('remove all unused named catalogs', async () => {
|
||||||
|
const dir = tempDir(false)
|
||||||
|
const filePath = path.join(dir, WORKSPACE_MANIFEST_FILENAME)
|
||||||
|
writeYamlFile(filePath, {
|
||||||
|
catalogs: {
|
||||||
|
foo: {
|
||||||
|
ghi: '7.8.9',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
updatedCatalogs: {
|
||||||
|
foo: {
|
||||||
|
abc: '0.1.2',
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
def: '3.2.1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalogs: {
|
||||||
|
foo: {
|
||||||
|
abc: '0.1.2',
|
||||||
|
ghi: '7.8.9',
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
def: '3.2.1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
prepare({
|
||||||
|
dependencies: {
|
||||||
|
def: 'catalog:bar',
|
||||||
|
ghi: 'catalog:foo',
|
||||||
|
},
|
||||||
|
}, { tempDir: dir })
|
||||||
|
const allProjects = await findPackages(dir)
|
||||||
|
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
cleanupUnusedCatalogs: true,
|
||||||
|
allProjects,
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalogs: {
|
||||||
|
bar: {
|
||||||
|
def: '3.2.1',
|
||||||
|
},
|
||||||
|
foo: {
|
||||||
|
ghi: '7.8.9',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
prepare({
|
||||||
|
dependencies: {
|
||||||
|
def: '3.2.1',
|
||||||
|
},
|
||||||
|
}, { tempDir: dir })
|
||||||
|
const _allProjects = await findPackages(dir)
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
cleanupUnusedCatalogs: true,
|
||||||
|
allProjects: _allProjects,
|
||||||
|
})
|
||||||
|
expect(fs.existsSync(filePath)).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('same pkg with different version', async () => {
|
||||||
|
const dir = tempDir(false)
|
||||||
|
const filePath = path.join(dir, WORKSPACE_MANIFEST_FILENAME)
|
||||||
|
writeYamlFile(filePath, {
|
||||||
|
catalogs: {
|
||||||
|
foo: {
|
||||||
|
ghi: '7.8.9',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
updatedCatalogs: {
|
||||||
|
foo: {
|
||||||
|
abc: '0.1.2',
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
def: '3.2.1',
|
||||||
|
abc: '1.2.3',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalogs: {
|
||||||
|
foo: {
|
||||||
|
abc: '0.1.2',
|
||||||
|
ghi: '7.8.9',
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
def: '3.2.1',
|
||||||
|
abc: '1.2.3',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
prepare({
|
||||||
|
dependencies: {
|
||||||
|
def: 'catalog:bar',
|
||||||
|
ghi: 'catalog:foo',
|
||||||
|
abc: 'catalog:foo',
|
||||||
|
},
|
||||||
|
optionalDependencies: {
|
||||||
|
abc: 'catalog:bar',
|
||||||
|
},
|
||||||
|
}, { tempDir: dir })
|
||||||
|
const allProjects = await findPackages(dir)
|
||||||
|
await updateWorkspaceManifest(dir, {
|
||||||
|
cleanupUnusedCatalogs: true,
|
||||||
|
allProjects,
|
||||||
|
})
|
||||||
|
expect(readYamlFile(filePath)).toStrictEqual({
|
||||||
|
catalogs: {
|
||||||
|
bar: {
|
||||||
|
abc: '1.2.3',
|
||||||
|
def: '3.2.1',
|
||||||
|
},
|
||||||
|
foo: {
|
||||||
|
abc: '0.1.2',
|
||||||
|
ghi: '7.8.9',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -9,12 +9,18 @@
|
|||||||
"../../__typings__/**/*.d.ts"
|
"../../__typings__/**/*.d.ts"
|
||||||
],
|
],
|
||||||
"references": [
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "../../__utils__/prepare"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "../../__utils__/prepare-temp-dir"
|
"path": "../../__utils__/prepare-temp-dir"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "../../catalogs/types"
|
"path": "../../catalogs/types"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "../../fs/find-packages"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "../../lockfile/types"
|
"path": "../../lockfile/types"
|
||||||
},
|
},
|
||||||
@@ -24,6 +30,9 @@
|
|||||||
{
|
{
|
||||||
"path": "../../packages/constants"
|
"path": "../../packages/constants"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "../../packages/types"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "../read-manifest"
|
"path": "../read-manifest"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user