Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(js): switch to picomatch #30079

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"@types/marked": "^2.0.0",
"@types/node": "20.16.10",
"@types/npm-package-arg": "6.1.1",
"@types/picomatch": "3.0.2",
"@types/react": "18.3.1",
"@types/react-dom": "18.3.0",
"@types/semver": "^7.5.8",
Expand Down Expand Up @@ -363,6 +364,7 @@
"next-seo": "^5.13.0",
"node-machine-id": "1.1.12",
"npm-run-path": "^4.0.1",
"picomatch": "4.0.2",
"preact": "10.25.4",
"react": "18.3.1",
"react-copy-to-clipboard": "^5.1.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"name": "fast-glob",
"message": "Please use `tinyglobby` instead."
},
{
"name": "minimatch",
"message": "Please use `picomatch` instead."
},
{
"name": "fs-extra",
"message": "Please use equivalent utilities from `node:fs` instead."
Expand Down
2 changes: 1 addition & 1 deletion packages/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
"ignore": "^5.0.4",
"js-tokens": "^4.0.0",
"jsonc-parser": "3.2.0",
"minimatch": "9.0.3",
"npm-package-arg": "11.0.1",
"npm-run-path": "^4.0.1",
"ora": "5.3.0",
"picomatch": "4.0.2",
"semver": "^7.5.3",
"source-map-support": "0.5.19",
"tinyglobby": "^0.2.10",
Expand Down
4 changes: 2 additions & 2 deletions packages/js/src/plugins/typescript/plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { detectPackageManager, type CreateNodesContext } from '@nx/devkit';
import { TempFs } from '@nx/devkit/internal-testing-utils';
import { minimatch } from 'minimatch';
import picomatch = require('picomatch');
import { mkdirSync, rmdirSync } from 'node:fs';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { getLockFileName } from 'nx/src/plugins/js/lock-file/lock-file';
Expand Down Expand Up @@ -3773,7 +3773,7 @@ async function applyFilesToTempFsAndContext(
await tempFs.createFiles(fileSys);
// @ts-expect-error update otherwise readonly property for testing
context.configFiles = Object.keys(fileSys).filter((file) =>
minimatch(file, createNodesV2[0], { dot: true })
picomatch(createNodesV2[0], { dot: true })(file)
);
setupWorkspaceContext(tempFs.tempDir);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/js/src/plugins/typescript/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
type TargetConfiguration,
} from '@nx/devkit';
import { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';
import { minimatch } from 'minimatch';
import picomatch = require('picomatch');
import { existsSync, readdirSync, statSync } from 'node:fs';
import {
basename,
Expand Down Expand Up @@ -548,8 +548,8 @@ function getInputs(
if (
!otherFilesInclude.some(
(includePath) =>
minimatch(normalize(includePath), normalize(excludePath)) ||
minimatch(normalize(excludePath), normalize(includePath))
picomatch(normalize(excludePath))(normalize(includePath)) ||
picomatch(normalize(includePath))(normalize(excludePath))
)
) {
excludePaths.add(excludePath);
Expand Down
8 changes: 4 additions & 4 deletions packages/js/src/utils/assets/copy-assets-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { minimatch } from 'minimatch';
import picomatch = require('picomatch');
import {
copyFileSync,
existsSync,
Expand Down Expand Up @@ -169,8 +169,8 @@ export class CopyAssetsHandler {
const pathFromRoot = path.relative(this.rootDir, event.path);
for (const ag of this.assetGlobs) {
if (
minimatch(pathFromRoot, ag.pattern) &&
!ag.ignore?.some((ig) => minimatch(pathFromRoot, ig)) &&
picomatch(ag.pattern)(pathFromRoot) &&
!ag.ignore?.some((ig) => picomatch(ig)(pathFromRoot)) &&
!this.ignore.ignores(pathFromRoot)
) {
const relPath = path.relative(ag.input, pathFromRoot);
Expand All @@ -192,7 +192,7 @@ export class CopyAssetsHandler {
private filesToEvent(files: string[], assetGlob: AssetEntry): FileEvent[] {
return files.reduce((acc, src) => {
if (
!assetGlob.ignore?.some((ig) => minimatch(src, ig)) &&
!assetGlob.ignore?.some((ig) => picomatch(ig)(src)) &&
!this.ignore.ignores(src)
) {
const relPath = path.relative(assetGlob.input, src);
Expand Down
4 changes: 2 additions & 2 deletions packages/js/src/utils/package-manager-workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type GeneratorCallback,
type Tree,
} from '@nx/devkit';
import { minimatch } from 'minimatch';
import picomatch = require('picomatch');
import { join } from 'node:path/posix';
import { getGlobPatternsFromPackageManagerWorkspaces } from 'nx/src/plugins/package-json';
import { PackageJson } from 'nx/src/utils/package-json';
Expand All @@ -30,7 +30,7 @@ export function getProjectPackageManagerWorkspaceState(
(path) => readJson(tree, path, { expectComments: true })
);
const isIncluded = patterns.some((p) =>
minimatch(join(projectRoot, 'package.json'), p)
picomatch(p)(join(projectRoot, 'package.json'))
);

return isIncluded ? 'included' : 'excluded';
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.