From 0b33718dbe9bdc1a3feb55cb98bc71e3fe7489cc Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 19 Mar 2026 01:45:24 +0100 Subject: [PATCH] refactor: merge @pnpm/fs.find-packages into @pnpm/workspace.projects-reader (#11021) * refactor: merge @pnpm/fs.find-packages into @pnpm/workspace.projects-reader The find-packages package had only one production consumer (projects-reader). Inlining it removes a separate published package with minimal value as a standalone utility. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: sort devDependencies and add tsconfig reference for meta-updater Co-Authored-By: Claude Opus 4.6 (1M context) * fix: remove circular tsconfig reference Co-Authored-By: Claude Opus 4.6 (1M context) * fix: exclude circular tsconfig reference in meta-updater Co-Authored-By: Claude Opus 4.6 (1M context) * refactor: move getConfig from cli/utils to pnpm CLI package getConfig and installConfigDepsAndLoadHooks were the only functions in cli/utils that pulled in heavy deps (env-installer, store.connection-manager, hooks.pnpmfile, default-reporter). Moving them to the pnpm CLI package (their only consumer) dramatically reduces the dependency weight of cli/utils, breaking the circular tsconfig reference chain that previously required fs.find-packages to be a separate package. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: sort imports Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Claude Opus 4.6 (1M context) --- .changeset/five-lies-travel.md | 1 - .changeset/polite-carpets-relax.md | 1 - cli/utils/package.json | 16 +- cli/utils/src/index.ts | 1 - cli/utils/test/tsconfig.json | 18 -- cli/utils/tsconfig.json | 18 -- fs/find-packages/CHANGELOG.md | 296 ------------------ fs/find-packages/README.md | 51 --- fs/find-packages/example.js | 6 - fs/find-packages/package.json | 52 --- fs/find-packages/test/tsconfig.json | 18 -- fs/find-packages/tsconfig.json | 19 -- fs/find-packages/tsconfig.lint.json | 8 - pnpm-lock.yaml | 73 +---- pnpm/package.json | 1 + {cli/utils => pnpm}/src/getConfig.ts | 0 pnpm/src/main.ts | 2 +- {cli/utils => pnpm}/test/getConfig.test.ts | 3 +- pnpm/tsconfig.json | 3 + workspace/projects-reader/package.json | 6 +- .../projects-reader/src/findPackages.ts | 4 +- workspace/projects-reader/src/index.ts | 4 +- .../components/component-1/package.json | 0 .../components/component-2/package.json | 0 .../many-pkgs-2/libs/foo/package.json | 0 .../many-pkgs-2/package.json | 0 .../components/component-1/package.yaml | 0 .../components/component-2/package.json5 | 0 .../libs/foo/package.json | 0 .../components/component-1/package.json | 0 .../components/component-2/package.json | 0 .../many-pkgs/libs/foo/package.json | 0 .../one-pkg/foo/package.json | 0 .../projects-reader/test/findPackages.ts | 4 +- workspace/projects-reader/tsconfig.json | 2 +- .../workspace-manifest-writer/package.json | 2 +- .../test/removeCatalogs.test.ts | 2 +- .../workspace-manifest-writer/tsconfig.json | 6 +- 38 files changed, 42 insertions(+), 575 deletions(-) delete mode 100644 cli/utils/test/tsconfig.json delete mode 100644 fs/find-packages/CHANGELOG.md delete mode 100644 fs/find-packages/README.md delete mode 100644 fs/find-packages/example.js delete mode 100644 fs/find-packages/package.json delete mode 100644 fs/find-packages/test/tsconfig.json delete mode 100644 fs/find-packages/tsconfig.json delete mode 100644 fs/find-packages/tsconfig.lint.json rename {cli/utils => pnpm}/src/getConfig.ts (100%) rename {cli/utils => pnpm}/test/getConfig.test.ts (96%) rename fs/find-packages/src/index.ts => workspace/projects-reader/src/findPackages.ts (94%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs-2/components/component-1/package.json (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs-2/components/component-2/package.json (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs-2/libs/foo/package.json (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs-2/package.json (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs-with-different-manifest-types/components/component-1/package.yaml (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs-with-different-manifest-types/components/component-2/package.json5 (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs-with-different-manifest-types/libs/foo/package.json (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs/components/component-1/package.json (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs/components/component-2/package.json (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/many-pkgs/libs/foo/package.json (100%) rename {fs/find-packages/test/fixtures => workspace/projects-reader/test/findPackages-fixtures}/one-pkg/foo/package.json (100%) rename fs/find-packages/test/index.ts => workspace/projects-reader/test/findPackages.ts (95%) diff --git a/.changeset/five-lies-travel.md b/.changeset/five-lies-travel.md index 0232bf0fe5..0bc238ad22 100644 --- a/.changeset/five-lies-travel.md +++ b/.changeset/five-lies-travel.md @@ -126,7 +126,6 @@ "@pnpm/engine.runtime.node-resolver": major "@pnpm/installing.linking.hoist": major "@pnpm/deps.peer-range": major -"@pnpm/fs.find-packages": major "@pnpm/fs.hard-link-dir": major "@pnpm/installing.deps-installer": major "@pnpm/store.cafs-types": major diff --git a/.changeset/polite-carpets-relax.md b/.changeset/polite-carpets-relax.md index 73741196cc..70723b20cc 100644 --- a/.changeset/polite-carpets-relax.md +++ b/.changeset/polite-carpets-relax.md @@ -113,7 +113,6 @@ "@pnpm/engine.runtime.node-resolver": major "@pnpm/installing.linking.hoist": major "@pnpm/deps.peer-range": major -"@pnpm/fs.find-packages": major "@pnpm/fs.hard-link-dir": major "@pnpm/installing.deps-installer": major "@pnpm/store.cafs-types": major diff --git a/cli/utils/package.json b/cli/utils/package.json index 7d5d759194..a1253d4f4b 100644 --- a/cli/utils/package.json +++ b/cli/utils/package.json @@ -24,24 +24,17 @@ "!*.map" ], "scripts": { - "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", + "lint": "eslint \"src/**/*.ts\"", "prepublishOnly": "pnpm run compile", "compile": "tsgo --build && pnpm run lint --fix", - "test": "pnpm run compile && pnpm run _test", - "_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest" + "test": "pnpm run compile" }, "dependencies": { - "@pnpm/cli.default-reporter": "workspace:*", "@pnpm/cli.meta": "workspace:*", "@pnpm/config.package-is-installable": "workspace:*", - "@pnpm/config.reader": "workspace:*", "@pnpm/error": "workspace:*", - "@pnpm/hooks.pnpmfile": "workspace:*", - "@pnpm/installing.env-installer": "workspace:*", "@pnpm/pkg-manifest.utils": "workspace:*", - "@pnpm/store.connection-manager": "workspace:*", "@pnpm/types": "workspace:*", - "@pnpm/util.lex-comparator": "catalog:", "@pnpm/workspace.project-manifest-reader": "workspace:*", "chalk": "catalog:", "load-json-file": "catalog:" @@ -50,11 +43,8 @@ "@pnpm/logger": "catalog:" }, "devDependencies": { - "@jest/globals": "catalog:", "@pnpm/cli.utils": "workspace:*", - "@pnpm/logger": "workspace:*", - "@pnpm/prepare": "workspace:*", - "@types/ramda": "catalog:" + "@pnpm/logger": "workspace:*" }, "engines": { "node": ">=22.13" diff --git a/cli/utils/src/index.ts b/cli/utils/src/index.ts index 3253403eac..a6466e7907 100644 --- a/cli/utils/src/index.ts +++ b/cli/utils/src/index.ts @@ -1,6 +1,5 @@ import { packageManager } from '@pnpm/cli.meta' -export { calcPnpmfilePathsOfPluginDeps, getConfig, installConfigDepsAndLoadHooks } from './getConfig.js' export * from './packageIsInstallable.js' export * from './readDepNameCompletions.js' export * from './readProjectManifest.js' diff --git a/cli/utils/test/tsconfig.json b/cli/utils/test/tsconfig.json deleted file mode 100644 index 67ce5e1d0e..0000000000 --- a/cli/utils/test/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "noEmit": false, - "outDir": "../node_modules/.test.lib", - "rootDir": "..", - "isolatedModules": true - }, - "include": [ - "**/*.ts", - "../../../__typings__/**/*.d.ts" - ], - "references": [ - { - "path": ".." - } - ] -} diff --git a/cli/utils/tsconfig.json b/cli/utils/tsconfig.json index 459d913169..debd0ab843 100644 --- a/cli/utils/tsconfig.json +++ b/cli/utils/tsconfig.json @@ -9,15 +9,9 @@ "../../__typings__/**/*.d.ts" ], "references": [ - { - "path": "../../__utils__/prepare" - }, { "path": "../../config/package-is-installable" }, - { - "path": "../../config/reader" - }, { "path": "../../core/error" }, @@ -27,24 +21,12 @@ { "path": "../../core/types" }, - { - "path": "../../hooks/pnpmfile" - }, - { - "path": "../../installing/env-installer" - }, { "path": "../../pkg-manifest/utils" }, - { - "path": "../../store/connection-manager" - }, { "path": "../../workspace/project-manifest-reader" }, - { - "path": "../default-reporter" - }, { "path": "../meta" } diff --git a/fs/find-packages/CHANGELOG.md b/fs/find-packages/CHANGELOG.md deleted file mode 100644 index cf9cecbbbb..0000000000 --- a/fs/find-packages/CHANGELOG.md +++ /dev/null @@ -1,296 +0,0 @@ -# @pnpm/fs.find-packages - -## 1000.0.17 - -### Patch Changes - -- Updated dependencies [7c1382f] -- Updated dependencies [dee39ec] - - @pnpm/types@1000.9.0 - - @pnpm/read-project-manifest@1001.1.4 - -## 1000.0.16 - -### Patch Changes - -- @pnpm/read-project-manifest@1001.1.3 - -## 1000.0.15 - -### Patch Changes - -- @pnpm/read-project-manifest@1001.1.2 - -## 1000.0.14 - -### Patch Changes - -- Updated dependencies [e792927] - - @pnpm/types@1000.8.0 - - @pnpm/read-project-manifest@1001.1.1 - -## 1000.0.13 - -### Patch Changes - -- Updated dependencies [d1edf73] -- Updated dependencies [86b33e9] - - @pnpm/read-project-manifest@1001.1.0 - -## 1000.0.12 - -### Patch Changes - -- Updated dependencies [1a07b8f] -- Updated dependencies [1a07b8f] -- Updated dependencies [1a07b8f] - - @pnpm/types@1000.7.0 - - @pnpm/read-project-manifest@1001.0.0 - -## 1000.0.11 - -### Patch Changes - -- c00360b: Update `@pnpm/util.lex-comparator` to v3.0.2. -- Updated dependencies [5ec7255] - - @pnpm/types@1000.6.0 - - @pnpm/read-project-manifest@1000.0.11 - -## 1000.0.10 - -### Patch Changes - -- Updated dependencies [5b73df1] - - @pnpm/types@1000.5.0 - - @pnpm/read-project-manifest@1000.0.10 - -## 1000.0.9 - -### Patch Changes - -- c85aaf8: Do not hang indefinitely, when there is a glob that starts with `!/` in `pnpm-workspace.yaml`. This fixes a regression introduced by [#9169](https://github.com/pnpm/pnpm/pull/9169). -- Updated dependencies [750ae7d] - - @pnpm/types@1000.4.0 - - @pnpm/read-project-manifest@1000.0.9 - -## 1000.0.8 - -### Patch Changes - -- Updated dependencies [5f7be64] -- Updated dependencies [5f7be64] - - @pnpm/types@1000.3.0 - - @pnpm/read-project-manifest@1000.0.8 - -## 1000.0.7 - -### Patch Changes - -- b8b0c68: `fast-glob` replace with `tinyglobby` to reduce the size of the pnpm CLI dependencies [#9169](https://github.com/pnpm/pnpm/pull/9169). -- Updated dependencies [a5e4965] - - @pnpm/types@1000.2.1 - - @pnpm/read-project-manifest@1000.0.7 - -## 1000.0.6 - -### Patch Changes - -- Updated dependencies [8fcc221] - - @pnpm/types@1000.2.0 - - @pnpm/read-project-manifest@1000.0.6 - -## 1000.0.5 - -### Patch Changes - -- Updated dependencies [1e229d7] - - @pnpm/read-project-manifest@1000.0.5 - -## 1000.0.4 - -### Patch Changes - -- Updated dependencies [b562deb] - - @pnpm/types@1000.1.1 - - @pnpm/read-project-manifest@1000.0.4 - -## 1000.0.3 - -### Patch Changes - -- Updated dependencies [e050221] - - @pnpm/read-project-manifest@1000.0.3 - -## 1000.0.2 - -### Patch Changes - -- Updated dependencies [9591a18] - - @pnpm/types@1000.1.0 - - @pnpm/read-project-manifest@1000.0.2 - -## 1000.0.1 - -### Patch Changes - -- @pnpm/read-project-manifest@1000.0.1 - -## 4.0.6 - -### Patch Changes - -- @pnpm/read-project-manifest@6.0.10 - -## 4.0.5 - -### Patch Changes - -- @pnpm/read-project-manifest@6.0.9 - -## 4.0.4 - -### Patch Changes - -- Updated dependencies [d500d9f] - - @pnpm/types@12.2.0 - - @pnpm/read-project-manifest@6.0.8 - -## 4.0.3 - -### Patch Changes - -- Updated dependencies [7ee59a1] - - @pnpm/types@12.1.0 - - @pnpm/read-project-manifest@6.0.7 - -## 4.0.2 - -### Patch Changes - -- Updated dependencies [cb006df] - - @pnpm/types@12.0.0 - - @pnpm/read-project-manifest@6.0.6 - -## 4.0.1 - -### Patch Changes - -- Updated dependencies [0ef168b] - - @pnpm/types@11.1.0 - - @pnpm/read-project-manifest@6.0.5 - -## 4.0.0 - -### Major Changes - -- dd00eeb: Renamed dir to rootDir in the Project object. - -### Patch Changes - -- Updated dependencies [dd00eeb] -- Updated dependencies - - @pnpm/types@11.0.0 - - @pnpm/read-project-manifest@6.0.4 - -## 3.0.3 - -### Patch Changes - -- 13e55b2: If install is performed on a subset of workspace projects, always create an up-to-date lockfile first. So, a partial install can be performed only on a fully resolved (non-partial) lockfile [#8165](https://github.com/pnpm/pnpm/issues/8165). -- Updated dependencies [13e55b2] - - @pnpm/types@10.1.1 - - @pnpm/read-project-manifest@6.0.3 - -## 3.0.2 - -### Patch Changes - -- Updated dependencies [45f4262] - - @pnpm/types@10.1.0 - - @pnpm/read-project-manifest@6.0.2 - -## 3.0.1 - -### Patch Changes - -- @pnpm/read-project-manifest@6.0.1 - -## 3.0.0 - -### Major Changes - -- 43cdd87: Node.js v16 support dropped. Use at least Node.js v18.12. - -### Patch Changes - -- Updated dependencies [7733f3a] -- Updated dependencies [43cdd87] -- Updated dependencies [730929e] - - @pnpm/types@10.0.0 - - @pnpm/read-project-manifest@6.0.0 - -## 2.0.10 - -### Patch Changes - -- Updated dependencies [4d34684f1] - - @pnpm/types@9.4.2 - - @pnpm/read-project-manifest@5.0.10 - -## 2.0.9 - -### Patch Changes - -- Updated dependencies - - @pnpm/types@9.4.1 - - @pnpm/read-project-manifest@5.0.9 - -## 2.0.8 - -### Patch Changes - -- Updated dependencies [43ce9e4a6] - - @pnpm/types@9.4.0 - - @pnpm/read-project-manifest@5.0.8 - -## 2.0.7 - -### Patch Changes - -- Updated dependencies [d774a3196] - - @pnpm/types@9.3.0 - - @pnpm/read-project-manifest@5.0.7 - -## 2.0.6 - -### Patch Changes - -- @pnpm/read-project-manifest@5.0.6 - -## 2.0.5 - -### Patch Changes - -- e9aa6f682: Apply fixes from @typescript-eslint v6 for nullish coalescing and optional chains. No behavior changes are expected with this change. - - @pnpm/read-project-manifest@5.0.5 - -## 2.0.4 - -### Patch Changes - -- Updated dependencies [aa2ae8fe2] - - @pnpm/types@9.2.0 - - @pnpm/read-project-manifest@5.0.4 - -## 2.0.3 - -### Patch Changes - -- Updated dependencies [b4892acc5] - - @pnpm/read-project-manifest@5.0.3 - -## 2.0.2 - -### Patch Changes - -- @pnpm/read-project-manifest@5.0.2 diff --git a/fs/find-packages/README.md b/fs/find-packages/README.md deleted file mode 100644 index 1b3a8c2405..0000000000 --- a/fs/find-packages/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# @pnpm/fs.find-packages - -> Find all packages inside a directory - - -[![npm version](https://img.shields.io/npm/v/@pnpm/fs.find-packages.svg)](https://www.npmjs.com/package/@pnpm/fs.find-packages) - - -## Installation - -```sh -pnpm add @pnpm/fs.find-packages -``` - -## Usage - -```js -const path = require('path') -const findPkgs = require('@pnpm/fs.find-packages') - -findPkgs(path.join(import.meta.dirname, 'test', 'fixture')) - .then(pkgs => console.log(pkgs)) - .catch(err => console.error(err)) - //> [ { path: '/home/zkochan/src/find-packages/test/fixture/pkg', - // manifest: { name: 'foo', version: '1.0.0' }, - // writeProjectManifest: [AsyncFunction] } ] -``` - -## API - -### `findPackages(dir, [opts])` - -#### `dir` - -The directory in which to search for packages. - -#### `opts` - -Parameters normally passed to [glob](https://www.npmjs.com/package/glob) - -#### `opts.patterns` - -Array of globs to use as package locations. For example: `['packages/**', 'utils/**']`. - -#### `opts.ignore` - -Patterns to ignore when searching for packages. By default: `**/node_modules/**`, `**/bower_components/**`, `**/test/**`, `**/tests/**`. - -## License - -MIT © [Zoltan Kochan](https://www.kochan.io) diff --git a/fs/find-packages/example.js b/fs/find-packages/example.js deleted file mode 100644 index 204862d55d..0000000000 --- a/fs/find-packages/example.js +++ /dev/null @@ -1,6 +0,0 @@ -const path = require('path') -const findPkgs = require('@pnpm/fs.find-packages') - -findPkgs(path.join(import.meta.dirname, 'test/fixtures/one-pkg')) - .then(pkgs => console.log(pkgs)) - .catch(err => console.error(err)) diff --git a/fs/find-packages/package.json b/fs/find-packages/package.json deleted file mode 100644 index 032b4f61b3..0000000000 --- a/fs/find-packages/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@pnpm/fs.find-packages", - "version": "1000.0.17", - "description": "Find all packages inside a directory", - "keywords": [ - "pnpm", - "pnpm11", - "find", - "package" - ], - "license": "MIT", - "funding": "https://opencollective.com/pnpm", - "repository": "https://github.com/pnpm/pnpm/tree/main/fs/find-packages", - "homepage": "https://github.com/pnpm/pnpm/tree/main/fs/find-packages#readme", - "bugs": { - "url": "https://github.com/pnpm/pnpm/issues" - }, - "type": "module", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "exports": { - ".": "./lib/index.js" - }, - "files": [ - "lib", - "!*.map" - ], - "scripts": { - "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest", - "test": "pnpm run compile && pnpm run _test", - "prepublishOnly": "pnpm run compile", - "compile": "tsgo --build && pnpm run lint --fix" - }, - "dependencies": { - "@pnpm/types": "workspace:*", - "@pnpm/util.lex-comparator": "catalog:", - "@pnpm/workspace.project-manifest-reader": "workspace:*", - "p-filter": "catalog:", - "tinyglobby": "catalog:" - }, - "devDependencies": { - "@jest/globals": "catalog:", - "@pnpm/fs.find-packages": "workspace:*" - }, - "engines": { - "node": ">=22.13" - }, - "jest": { - "preset": "@pnpm/jest-config" - } -} diff --git a/fs/find-packages/test/tsconfig.json b/fs/find-packages/test/tsconfig.json deleted file mode 100644 index 67ce5e1d0e..0000000000 --- a/fs/find-packages/test/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "noEmit": false, - "outDir": "../node_modules/.test.lib", - "rootDir": "..", - "isolatedModules": true - }, - "include": [ - "**/*.ts", - "../../../__typings__/**/*.d.ts" - ], - "references": [ - { - "path": ".." - } - ] -} diff --git a/fs/find-packages/tsconfig.json b/fs/find-packages/tsconfig.json deleted file mode 100644 index 5d0164ce3c..0000000000 --- a/fs/find-packages/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "@pnpm/tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": "src" - }, - "include": [ - "src/**/*.ts", - "../../__typings__/**/*.d.ts" - ], - "references": [ - { - "path": "../../core/types" - }, - { - "path": "../../workspace/project-manifest-reader" - } - ] -} diff --git a/fs/find-packages/tsconfig.lint.json b/fs/find-packages/tsconfig.lint.json deleted file mode 100644 index 1bbe711971..0000000000 --- a/fs/find-packages/tsconfig.lint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": [ - "src/**/*.ts", - "test/**/*.ts", - "../../__typings__/**/*.d.ts" - ] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ff50281673..9de225f803 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2181,39 +2181,21 @@ importers: cli/utils: dependencies: - '@pnpm/cli.default-reporter': - specifier: workspace:* - version: link:../default-reporter '@pnpm/cli.meta': specifier: workspace:* version: link:../meta '@pnpm/config.package-is-installable': specifier: workspace:* version: link:../../config/package-is-installable - '@pnpm/config.reader': - specifier: workspace:* - version: link:../../config/reader '@pnpm/error': specifier: workspace:* version: link:../../core/error - '@pnpm/hooks.pnpmfile': - specifier: workspace:* - version: link:../../hooks/pnpmfile - '@pnpm/installing.env-installer': - specifier: workspace:* - version: link:../../installing/env-installer '@pnpm/pkg-manifest.utils': specifier: workspace:* version: link:../../pkg-manifest/utils - '@pnpm/store.connection-manager': - specifier: workspace:* - version: link:../../store/connection-manager '@pnpm/types': specifier: workspace:* version: link:../../core/types - '@pnpm/util.lex-comparator': - specifier: 'catalog:' - version: 3.0.2 '@pnpm/workspace.project-manifest-reader': specifier: workspace:* version: link:../../workspace/project-manifest-reader @@ -2224,21 +2206,12 @@ importers: specifier: 'catalog:' version: 7.0.1 devDependencies: - '@jest/globals': - specifier: 'catalog:' - version: 30.0.5 '@pnpm/cli.utils': specifier: workspace:* version: 'link:' '@pnpm/logger': specifier: workspace:* version: link:../../core/logger - '@pnpm/prepare': - specifier: workspace:* - version: link:../../__utils__/prepare - '@types/ramda': - specifier: 'catalog:' - version: 0.29.12 config/commands: dependencies: @@ -4372,31 +4345,6 @@ importers: specifier: workspace:* version: 'link:' - fs/find-packages: - dependencies: - '@pnpm/types': - specifier: workspace:* - version: link:../../core/types - '@pnpm/util.lex-comparator': - specifier: 'catalog:' - version: 3.0.2 - '@pnpm/workspace.project-manifest-reader': - specifier: workspace:* - version: link:../../workspace/project-manifest-reader - p-filter: - specifier: 'catalog:' - version: 4.1.0 - tinyglobby: - specifier: 'catalog:' - version: 0.2.15 - devDependencies: - '@jest/globals': - specifier: 'catalog:' - version: 30.0.5 - '@pnpm/fs.find-packages': - specifier: workspace:* - version: 'link:' - fs/graceful-fs: dependencies: graceful-fs: @@ -7193,6 +7141,9 @@ importers: '@pnpm/fs.msgpack-file': specifier: workspace:* version: link:../fs/msgpack-file + '@pnpm/hooks.pnpmfile': + specifier: workspace:* + version: link:../hooks/pnpmfile '@pnpm/installing.client': specifier: workspace:* version: link:../installing/client @@ -8997,15 +8948,21 @@ importers: '@pnpm/constants': specifier: workspace:* version: link:../../core/constants - '@pnpm/fs.find-packages': - specifier: workspace:* - version: link:../../fs/find-packages '@pnpm/types': specifier: workspace:* version: link:../../core/types '@pnpm/util.lex-comparator': specifier: 'catalog:' version: 3.0.2 + '@pnpm/workspace.project-manifest-reader': + specifier: workspace:* + version: link:../project-manifest-reader + p-filter: + specifier: 'catalog:' + version: 4.1.0 + tinyglobby: + specifier: 'catalog:' + version: 0.2.15 devDependencies: '@jest/globals': specifier: 'catalog:' @@ -9148,15 +9105,15 @@ importers: specifier: 'catalog:' version: 2.8.2 devDependencies: - '@pnpm/fs.find-packages': - specifier: workspace:* - version: link:../../fs/find-packages '@pnpm/prepare': specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/prepare-temp-dir': specifier: workspace:* version: link:../../__utils__/prepare-temp-dir + '@pnpm/workspace.projects-reader': + specifier: workspace:* + version: link:../projects-reader '@pnpm/workspace.workspace-manifest-writer': specifier: workspace:* version: 'link:' diff --git a/pnpm/package.json b/pnpm/package.json index 7fa5f99c43..5a4aed98ed 100644 --- a/pnpm/package.json +++ b/pnpm/package.json @@ -85,6 +85,7 @@ "@pnpm/cli.command": "workspace:*", "@pnpm/cli.common-cli-options-help": "workspace:*", "@pnpm/config.reader": "workspace:*", + "@pnpm/hooks.pnpmfile": "workspace:*", "@pnpm/installing.env-installer": "workspace:*", "@pnpm/config.version-policy": "workspace:*", "@pnpm/constants": "workspace:*", diff --git a/cli/utils/src/getConfig.ts b/pnpm/src/getConfig.ts similarity index 100% rename from cli/utils/src/getConfig.ts rename to pnpm/src/getConfig.ts diff --git a/pnpm/src/main.ts b/pnpm/src/main.ts index 2d843e693a..481f7cf0c8 100644 --- a/pnpm/src/main.ts +++ b/pnpm/src/main.ts @@ -11,7 +11,6 @@ import { stripVTControlCharacters as stripAnsi } from 'node:util' import { isExecutedByCorepack, packageManager } from '@pnpm/cli.meta' import type { ParsedCliArgs } from '@pnpm/cli.parse-cli-args' -import { getConfig, installConfigDepsAndLoadHooks } from '@pnpm/cli.utils' import type { Config } from '@pnpm/config.reader' import { executionTimeLogger, scopeLogger } from '@pnpm/core-loggers' import { PnpmError } from '@pnpm/error' @@ -27,6 +26,7 @@ import semver from 'semver' import { checkForUpdates } from './checkForUpdates.js' import { pnpmCmds, rcOptionsTypes, skipPackageManagerCheckForCommand } from './cmd/index.js' import { formatUnknownOptionsError } from './formatError.js' +import { getConfig, installConfigDepsAndLoadHooks } from './getConfig.js' import { parseCliArgs } from './parseCliArgs.js' import { initReporter, type ReporterType } from './reporter/index.js' import { switchCliVersion } from './switchCliVersion.js' diff --git a/cli/utils/test/getConfig.test.ts b/pnpm/test/getConfig.test.ts similarity index 96% rename from cli/utils/test/getConfig.test.ts rename to pnpm/test/getConfig.test.ts index 6c97d8c8ed..4236572c0a 100644 --- a/cli/utils/test/getConfig.test.ts +++ b/pnpm/test/getConfig.test.ts @@ -3,9 +3,10 @@ import fs from 'node:fs' import path from 'node:path' import { jest } from '@jest/globals' -import { calcPnpmfilePathsOfPluginDeps, getConfig } from '@pnpm/cli.utils' import { prepare } from '@pnpm/prepare' +import { calcPnpmfilePathsOfPluginDeps, getConfig } from '../src/getConfig.js' + beforeEach(() => { jest.spyOn(console, 'warn') }) diff --git a/pnpm/tsconfig.json b/pnpm/tsconfig.json index 1de3ba4b5e..e242a8d0e4 100644 --- a/pnpm/tsconfig.json +++ b/pnpm/tsconfig.json @@ -101,6 +101,9 @@ { "path": "../fs/msgpack-file" }, + { + "path": "../hooks/pnpmfile" + }, { "path": "../installing/client" }, diff --git a/workspace/projects-reader/package.json b/workspace/projects-reader/package.json index 4e60e6c16c..3ea01c775f 100644 --- a/workspace/projects-reader/package.json +++ b/workspace/projects-reader/package.json @@ -33,9 +33,11 @@ "dependencies": { "@pnpm/cli.utils": "workspace:*", "@pnpm/constants": "workspace:*", - "@pnpm/fs.find-packages": "workspace:*", "@pnpm/types": "workspace:*", - "@pnpm/util.lex-comparator": "catalog:" + "@pnpm/util.lex-comparator": "catalog:", + "@pnpm/workspace.project-manifest-reader": "workspace:*", + "p-filter": "catalog:", + "tinyglobby": "catalog:" }, "peerDependencies": { "@pnpm/logger": "catalog:" diff --git a/fs/find-packages/src/index.ts b/workspace/projects-reader/src/findPackages.ts similarity index 94% rename from fs/find-packages/src/index.ts rename to workspace/projects-reader/src/findPackages.ts index 7e08db68f0..eaa8530e17 100644 --- a/fs/find-packages/src/index.ts +++ b/workspace/projects-reader/src/findPackages.ts @@ -15,13 +15,13 @@ const DEFAULT_IGNORE = [ '**/tests/**', ] -export interface Options { +export interface FindPackagesOptions { ignore?: string[] includeRoot?: boolean patterns?: string[] } -export async function findPackages (root: string, opts?: Options): Promise { +export async function findPackages (root: string, opts?: FindPackagesOptions): Promise { opts = opts ?? {} const globOpts = { ...opts, cwd: root, expandDirectories: false } globOpts.ignore = opts.ignore ?? DEFAULT_IGNORE diff --git a/workspace/projects-reader/src/index.ts b/workspace/projects-reader/src/index.ts index fab37d2185..977d7564be 100644 --- a/workspace/projects-reader/src/index.ts +++ b/workspace/projects-reader/src/index.ts @@ -1,9 +1,11 @@ import { packageIsInstallable } from '@pnpm/cli.utils' -import { findPackages } from '@pnpm/fs.find-packages' import { logger } from '@pnpm/logger' import type { Project, ProjectManifest, SupportedArchitectures } from '@pnpm/types' import { lexCompare } from '@pnpm/util.lex-comparator' +import { findPackages } from './findPackages.js' + +export { findPackages, type FindPackagesOptions } from './findPackages.js' export type { Project } export interface FindWorkspaceProjectsOpts { diff --git a/fs/find-packages/test/fixtures/many-pkgs-2/components/component-1/package.json b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs-2/components/component-1/package.json similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs-2/components/component-1/package.json rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs-2/components/component-1/package.json diff --git a/fs/find-packages/test/fixtures/many-pkgs-2/components/component-2/package.json b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs-2/components/component-2/package.json similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs-2/components/component-2/package.json rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs-2/components/component-2/package.json diff --git a/fs/find-packages/test/fixtures/many-pkgs-2/libs/foo/package.json b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs-2/libs/foo/package.json similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs-2/libs/foo/package.json rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs-2/libs/foo/package.json diff --git a/fs/find-packages/test/fixtures/many-pkgs-2/package.json b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs-2/package.json similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs-2/package.json rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs-2/package.json diff --git a/fs/find-packages/test/fixtures/many-pkgs-with-different-manifest-types/components/component-1/package.yaml b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs-with-different-manifest-types/components/component-1/package.yaml similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs-with-different-manifest-types/components/component-1/package.yaml rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs-with-different-manifest-types/components/component-1/package.yaml diff --git a/fs/find-packages/test/fixtures/many-pkgs-with-different-manifest-types/components/component-2/package.json5 b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs-with-different-manifest-types/components/component-2/package.json5 similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs-with-different-manifest-types/components/component-2/package.json5 rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs-with-different-manifest-types/components/component-2/package.json5 diff --git a/fs/find-packages/test/fixtures/many-pkgs-with-different-manifest-types/libs/foo/package.json b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs-with-different-manifest-types/libs/foo/package.json similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs-with-different-manifest-types/libs/foo/package.json rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs-with-different-manifest-types/libs/foo/package.json diff --git a/fs/find-packages/test/fixtures/many-pkgs/components/component-1/package.json b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs/components/component-1/package.json similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs/components/component-1/package.json rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs/components/component-1/package.json diff --git a/fs/find-packages/test/fixtures/many-pkgs/components/component-2/package.json b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs/components/component-2/package.json similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs/components/component-2/package.json rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs/components/component-2/package.json diff --git a/fs/find-packages/test/fixtures/many-pkgs/libs/foo/package.json b/workspace/projects-reader/test/findPackages-fixtures/many-pkgs/libs/foo/package.json similarity index 100% rename from fs/find-packages/test/fixtures/many-pkgs/libs/foo/package.json rename to workspace/projects-reader/test/findPackages-fixtures/many-pkgs/libs/foo/package.json diff --git a/fs/find-packages/test/fixtures/one-pkg/foo/package.json b/workspace/projects-reader/test/findPackages-fixtures/one-pkg/foo/package.json similarity index 100% rename from fs/find-packages/test/fixtures/one-pkg/foo/package.json rename to workspace/projects-reader/test/findPackages-fixtures/one-pkg/foo/package.json diff --git a/fs/find-packages/test/index.ts b/workspace/projects-reader/test/findPackages.ts similarity index 95% rename from fs/find-packages/test/index.ts rename to workspace/projects-reader/test/findPackages.ts index 0a42e2733e..9a376b33d7 100644 --- a/fs/find-packages/test/index.ts +++ b/workspace/projects-reader/test/findPackages.ts @@ -1,7 +1,7 @@ /// import path from 'node:path' -import { findPackages } from '@pnpm/fs.find-packages' +import { findPackages } from '@pnpm/workspace.projects-reader' function compare (a: string | undefined, b: string | undefined) { if (a == null) return 1 @@ -9,7 +9,7 @@ function compare (a: string | undefined, b: string | undefined) { return a.localeCompare(b) } -const fixtures = path.join(import.meta.dirname, 'fixtures') +const fixtures = path.join(import.meta.dirname, 'findPackages-fixtures') test('finds package', async () => { const root = path.join(fixtures, 'one-pkg') diff --git a/workspace/projects-reader/tsconfig.json b/workspace/projects-reader/tsconfig.json index 4af4307097..f5054773ca 100644 --- a/workspace/projects-reader/tsconfig.json +++ b/workspace/projects-reader/tsconfig.json @@ -22,7 +22,7 @@ "path": "../../core/types" }, { - "path": "../../fs/find-packages" + "path": "../project-manifest-reader" }, { "path": "../workspace-manifest-reader" diff --git a/workspace/workspace-manifest-writer/package.json b/workspace/workspace-manifest-writer/package.json index 167f6dd723..02668f5721 100644 --- a/workspace/workspace-manifest-writer/package.json +++ b/workspace/workspace-manifest-writer/package.json @@ -43,9 +43,9 @@ "yaml": "catalog:" }, "devDependencies": { - "@pnpm/fs.find-packages": "workspace:*", "@pnpm/prepare": "workspace:*", "@pnpm/prepare-temp-dir": "workspace:*", + "@pnpm/workspace.projects-reader": "workspace:*", "@pnpm/workspace.workspace-manifest-writer": "workspace:*", "@types/ramda": "catalog:", "@types/write-file-atomic": "catalog:", diff --git a/workspace/workspace-manifest-writer/test/removeCatalogs.test.ts b/workspace/workspace-manifest-writer/test/removeCatalogs.test.ts index e182e159b2..d381b2592b 100644 --- a/workspace/workspace-manifest-writer/test/removeCatalogs.test.ts +++ b/workspace/workspace-manifest-writer/test/removeCatalogs.test.ts @@ -2,9 +2,9 @@ import fs from 'node:fs' import path from 'node:path' import { WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants' -import { findPackages } from '@pnpm/fs.find-packages' import { prepare } from '@pnpm/prepare' import { tempDir } from '@pnpm/prepare-temp-dir' +import { findPackages } from '@pnpm/workspace.projects-reader' import { updateWorkspaceManifest } from '@pnpm/workspace.workspace-manifest-writer' import { readYamlFileSync } from 'read-yaml-file' import { writeYamlFileSync } from 'write-yaml-file' diff --git a/workspace/workspace-manifest-writer/tsconfig.json b/workspace/workspace-manifest-writer/tsconfig.json index 039ba421b2..415a296f3d 100644 --- a/workspace/workspace-manifest-writer/tsconfig.json +++ b/workspace/workspace-manifest-writer/tsconfig.json @@ -24,9 +24,6 @@ { "path": "../../core/types" }, - { - "path": "../../fs/find-packages" - }, { "path": "../../lockfile/types" }, @@ -36,6 +33,9 @@ { "path": "../../yaml/document-sync" }, + { + "path": "../projects-reader" + }, { "path": "../workspace-manifest-reader" }