diff --git a/package-lock.json b/package-lock.json index 55934d38..34f6fd3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,11 +12,11 @@ "chalk": "^5.3.0", "cli-table3": "^0.6.3", "commander": "^11.1.0", + "fast-glob": "^3.3.2", "fast-memoize": "^2.5.2", "find-up": "5.0.0", "fp-and-or": "^1.0.2", "get-stdin": "^8.0.0", - "globby": "^11.0.4", "hosted-git-info": "^5.1.0", "ini": "^4.1.1", "js-yaml": "^4.1.0", @@ -32,7 +32,6 @@ "prompts-ncu": "^3.0.0", "rc-config-loader": "^4.1.3", "remote-git-tags": "^3.0.0", - "rimraf": "^5.0.5", "semver": "^7.5.4", "semver-utils": "^1.1.4", "source-map-support": "^0.5.21", @@ -67,7 +66,6 @@ "@types/progress": "^2.0.6", "@types/prompts": "^2.4.7", "@types/remote-git-tags": "^4.0.1", - "@types/rimraf": "^3.0.2", "@types/semver": "^7.5.4", "@types/semver-utils": "^1.1.2", "@types/sinon": "^17.0.0", @@ -1329,17 +1327,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/minimatch": "^5.1.2", - "@types/node": "*" - } - }, "node_modules/@types/hosted-git-info": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/@types/hosted-git-info/-/hosted-git-info-3.0.4.tgz", @@ -1532,17 +1519,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/glob": "*", - "@types/node": "*" - } - }, "node_modules/@types/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.4.tgz", @@ -2024,6 +2000,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -3182,6 +3159,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, "license": "MIT", "dependencies": { "path-type": "^4.0.0" @@ -4033,10 +4011,9 @@ "license": "MIT" }, "node_modules/fast-glob": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", - "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", - "license": "MIT", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -4560,6 +4537,7 @@ "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, "license": "MIT", "dependencies": { "array-union": "^2.1.0", @@ -4801,6 +4779,7 @@ "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 4" @@ -7327,6 +7306,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -7842,23 +7822,6 @@ "node": ">=0.10.0" } }, - "node_modules/rimraf": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", - "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", - "dependencies": { - "glob": "^10.3.7" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/run-con": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/run-con/-/run-con-1.3.2.tgz", @@ -8206,6 +8169,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" diff --git a/package.json b/package.json index 24adc4f4..f80f7239 100644 --- a/package.json +++ b/package.json @@ -63,11 +63,11 @@ "chalk": "^5.3.0", "cli-table3": "^0.6.3", "commander": "^11.1.0", + "fast-glob": "^3.3.2", "fast-memoize": "^2.5.2", "find-up": "5.0.0", "fp-and-or": "^1.0.2", "get-stdin": "^8.0.0", - "globby": "^11.0.4", "hosted-git-info": "^5.1.0", "ini": "^4.1.1", "js-yaml": "^4.1.0", diff --git a/src/lib/getAllPackages.ts b/src/lib/getAllPackages.ts index fac81dff..2f9f2fa0 100644 --- a/src/lib/getAllPackages.ts +++ b/src/lib/getAllPackages.ts @@ -1,5 +1,5 @@ +import glob, { type Options as GlobOptions } from 'fast-glob' import fs from 'fs/promises' -import globby from 'globby' import yaml from 'js-yaml' import path from 'path' import untildify from 'untildify' @@ -12,6 +12,10 @@ import programError from './programError' type PnpmWorkspaces = string[] | { packages: string[] } +const globOptions: GlobOptions = { + ignore: ['**/node_modules/**'], +} + /** Reads, parses, and resolves workspaces from a pnpm-workspace file at the same path as the package file. */ const readPnpmWorkspaces = async (pkgPath: string): Promise => { const pnpmWorkspacesPath = path.join(path.dirname(pkgPath), 'pnpm-workspace.yaml') @@ -64,11 +68,7 @@ async function getWorkspacePackageInfos( ) // e.g. [packages/a/package.json, ...] - const allWorkspacePackageFilepaths: string[] = [ - ...globby.sync(workspacePackageGlob, { - ignore: ['**/node_modules/**'], - }), - ] + const allWorkspacePackageFilepaths: string[] = glob.sync(workspacePackageGlob, globOptions) // Get the package names from the package files. // If a package does not have a name, use the folder name. @@ -97,21 +97,19 @@ async function getWorkspacePackageInfos( // add workspace packages // --workspace - const selectedWorkspacePackageInfos: PackageInfo[] = allWorkspacePackageInfos.filter( - (packageInfo: PackageInfo) => + const selectedWorkspacePackageInfos: PackageInfo[] = allWorkspacePackageInfos.filter((packageInfo: PackageInfo) => + /* ignore coverage on optional-chaining */ + /* c8 ignore next */ + options.workspace?.some((workspace: string) => /* ignore coverage on optional-chaining */ /* c8 ignore next */ - options.workspace?.some( - (workspace: string) => - /* ignore coverage on optional-chaining */ - /* c8 ignore next */ - workspaces?.some( - (workspacePattern: string) => - packageInfo.name === workspace || - packageInfo.filepath === - path.join(cwd, path.dirname(workspacePattern), workspace, defaultPackageFilename).replace(/\\/g, '/'), - ), + workspaces?.some( + (workspacePattern: string) => + packageInfo.name === workspace || + packageInfo.filepath === + path.join(cwd, path.dirname(workspacePattern), workspace, defaultPackageFilename).replace(/\\/g, '/'), ), + ), ) return [selectedWorkspacePackageInfos, allWorkspacePackageNames] } @@ -140,9 +138,7 @@ async function getAllPackages(options: Options): Promise<[PackageInfo[], string[ // * NOT a workspace // * a workspace and have requested an upgrade of the workspace-root const globPattern = rootPackageFile.replace(/\\/g, '/') - const rootPackagePaths = globby.sync(globPattern, { - ignore: ['**/node_modules/**'], - }) + const rootPackagePaths = glob.sync(globPattern, globOptions) // realistically there should only be zero or one const rootPackages = [ ...(await Promise.all(