Skip to content

chore: switch to tinyglobby #2680

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"eslint-plugin-ft-flow": "^2.0.1",
"eslint-plugin-import": "^2.25.3",
"execa": "^5.0.0",
"fast-glob": "^3.3.2",
"husky": "^8.0.2",
"jest": "^26.6.2",
"jest-circus": "^26.6.2",
Expand All @@ -53,6 +52,7 @@
"prettier": "2.8.8",
"slash": "^3.0.0",
"string-length": "^2.0.0",
"tinyglobby": "^0.2.14",
"typescript": "^5.2.0"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-clean/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@react-native-community/cli-tools": "19.0.0",
"chalk": "^4.1.2",
"execa": "^5.0.0",
"fast-glob": "^3.3.2"
"tinyglobby": "^0.2.14"
},
"files": [
"build",
Expand Down
7 changes: 5 additions & 2 deletions packages/cli-clean/src/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {existsSync as fileExists, rm} from 'fs';
import os from 'os';
import path from 'path';
import {promisify} from 'util';
import glob from 'fast-glob';
import glob from 'tinyglobby';

type Args = {
include?: string;
Expand Down Expand Up @@ -38,7 +38,10 @@ function isDirectoryPattern(directory: string): boolean {
export async function cleanDir(directory: string): Promise<void> {
try {
if (isDirectoryPattern(directory)) {
const directories = await glob.async(directory, {onlyFiles: false});
const directories = await glob.glob(directory, {
onlyFiles: false,
expandDirectories: false,
});

for (const dir of directories) {
await rmAsync(dir, rmAsyncOptions);
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-config-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"dependencies": {
"@react-native-community/cli-tools": "19.0.0",
"chalk": "^4.1.2",
"fast-glob": "^3.3.2",
"fast-xml-parser": "^4.4.1"
"fast-xml-parser": "^4.4.1",
"tinyglobby": "^0.2.14"
},
"files": [
"build",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import glob from 'fast-glob';
import glob from 'tinyglobby';
import {extractComponentDescriptors} from './extractComponentDescriptors';
import {unixifyPaths} from '@react-native-community/cli-tools';

Expand All @@ -18,9 +18,9 @@ export function findComponentDescriptors(packageRoot: string) {
const globPattern = jsSrcsDir
? `${jsSrcsDir}/**/+(*.js|*.jsx|*.ts|*.tsx)`
: '**/+(*.js|*.jsx|*.ts|*.tsx)';
const files = glob.sync(globPattern, {
const files = glob.globSync(globPattern, {
cwd: unixifyPaths(packageRoot),
onlyFiles: true,
expandDirectories: false,
ignore: ['**/node_modules/**'],
});
const codegenComponent = files
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-config-android/src/config/findManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*
*/

import glob from 'fast-glob';
import glob from 'tinyglobby';
import path from 'path';
import {unixifyPaths} from '@react-native-community/cli-tools';

export default function findManifest(folder: string) {
let manifestPaths = glob.sync('**/AndroidManifest.xml', {
let manifestPaths = glob.globSync('**/AndroidManifest.xml', {
cwd: unixifyPaths(folder),
expandDirectories: false,
ignore: [
'**/build/**',
'**/debug/**',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import fs from 'fs';
import glob from 'fast-glob';
import glob from 'tinyglobby';
import path from 'path';
import {unixifyPaths} from '@react-native-community/cli-tools';

Expand All @@ -23,9 +23,9 @@ export function getMainActivityFiles(
patternArray.push('*.java', '*.kt');
}

return glob.sync(`**/+(${patternArray.join('|')})`, {
return glob.globSync(`**/+(${patternArray.join('|')})`, {
cwd: unixifyPaths(folder),
onlyFiles: true,
expandDirectories: false,
ignore: ['**/.cxx/**'],
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-config-apple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@react-native-community/cli-tools": "19.0.0",
"chalk": "^4.1.2",
"execa": "^5.0.0",
"fast-glob": "^3.3.2"
"tinyglobby": "^0.2.14"
},
"devDependencies": {
"@react-native-community/cli-types": "19.0.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-config-apple/src/config/findAllPodfilePaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
*/
import glob from 'fast-glob';
import glob from 'tinyglobby';
import {unixifyPaths} from '@react-native-community/cli-tools';

// These folders will be excluded from search to speed it up
Expand All @@ -14,8 +14,9 @@ const GLOB_EXCLUDE_PATTERN = [
];

export default function findAllPodfilePaths(cwd: string) {
return glob.sync('**/Podfile', {
return glob.globSync('**/Podfile', {
cwd: unixifyPaths(cwd),
expandDirectories: false,
ignore: GLOB_EXCLUDE_PATTERN,
// Stop unbounded globbing and infinite loops for projects
// with deeply nested subdirectories. The most likely result
Expand Down
7 changes: 5 additions & 2 deletions packages/cli-config-apple/src/config/findPodspec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import glob from 'fast-glob';
import glob from 'tinyglobby';
import path from 'path';
import {unixifyPaths} from '@react-native-community/cli-tools';

export default function findPodspec(folder: string): string | null {
const podspecs = glob.sync('*.podspec', {cwd: unixifyPaths(folder)});
const podspecs = glob.globSync('*.podspec', {
cwd: unixifyPaths(folder),
expandDirectories: false,
});

if (podspecs.length === 0) {
return null;
Expand Down
1 change: 0 additions & 1 deletion packages/cli-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"chalk": "^4.1.2",
"cosmiconfig": "^9.0.0",
"deepmerge": "^4.3.0",
"fast-glob": "^3.3.2",
"joi": "^17.2.1"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-link-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"@react-native-community/cli-platform-ios": "19.0.0",
"@react-native-community/cli-tools": "19.0.0",
"chalk": "^4.1.2",
"fast-glob": "^3.3.2",
"fast-xml-parser": "^4.4.1",
"opentype.js": "^1.3.4",
"plist": "^3.1.0",
"tinyglobby": "^0.2.14",
"xcode": "^3.0.1"
},
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {isProjectUsingKotlin} from '@react-native-community/cli-platform-android
import {CLIError, logger} from '@react-native-community/cli-tools';
import {XMLBuilder, XMLParser} from 'fast-xml-parser';
import fs from 'fs-extra';
import glob from 'fast-glob';
import glob from 'tinyglobby';
import OpenType from 'opentype.js';
import path from 'path';

Expand Down Expand Up @@ -77,8 +77,9 @@ function convertToAndroidResourceName(str: string) {
function getProjectFilePath(rootPath: string, name: string) {
const isUsingKotlin = isProjectUsingKotlin(rootPath);
const ext = isUsingKotlin ? 'kt' : 'java';
const filePath = glob.sync(
const filePath = glob.globSync(
path.join(rootPath, `app/src/main/java/**/${name}.${ext}`),
{expandDirectories: false},
)[0];
return filePath;
}
Expand Down
6 changes: 2 additions & 4 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

const fs = require('fs');
const path = require('path');
const glob = require('fast-glob');
const glob = require('tinyglobby');
const babel = require('@babel/core');
const chalk = require('chalk');
const micromatch = require('micromatch');
Expand Down Expand Up @@ -55,9 +55,7 @@ function getBuildPath(file, buildFolder) {
function buildNodePackage(p) {
const srcDir = path.resolve(p, SRC_DIR);
const pattern = path.resolve(srcDir, '**/*');
const files = glob.sync(pattern, {
nodir: true,
});
const files = glob.globSync(pattern, {expandDirectories: false});

process.stdout.write(adjustToTerminalWidth(`${path.basename(p)}\n`));

Expand Down
6 changes: 4 additions & 2 deletions scripts/linkPackages.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const execa = require('execa');
const chalk = require('chalk');
const path = require('path');
const glob = require('fast-glob');
const glob = require('tinyglobby');

const projects = glob.sync('packages/*/package.json');
const projects = glob.globSync('packages/*/package.json', {
expandDirectories: false,
});

projects.forEach((project) => {
const cwd = path.dirname(project);
Expand Down
60 changes: 46 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4769,17 +4769,6 @@ fast-glob@^3.2.9, fast-glob@^3.3.1:
merge2 "^1.3.0"
micromatch "^4.0.4"

fast-glob@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129"
integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==
dependencies:
"@nodelib/fs.stat" "^2.0.2"
"@nodelib/fs.walk" "^1.2.3"
glob-parent "^5.1.2"
merge2 "^1.3.0"
micromatch "^4.0.4"

fast-json-stable-stringify@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
Expand Down Expand Up @@ -4811,6 +4800,11 @@ fb-watchman@^2.0.0:
dependencies:
bser "2.1.1"

fdir@^6.4.4:
version "6.4.6"
resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.6.tgz#2b268c0232697063111bbf3f64810a2a741ba281"
integrity sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==

[email protected], figures@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af"
Expand Down Expand Up @@ -8507,6 +8501,11 @@ picomatch@^2.0.4, picomatch@^2.0.7, picomatch@^2.3.1:
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==

picomatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab"
integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==

pidtree@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.6.0.tgz#90ad7b6d42d5841e69e0a2419ef38f8883aa057c"
Expand Down Expand Up @@ -9701,7 +9700,16 @@ string-natural-compare@^3.0.1:
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -9796,7 +9804,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -9817,6 +9825,13 @@ strip-ansi@^5.0.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2"
Expand Down Expand Up @@ -10009,6 +10024,14 @@ tiny-inflate@^1.0.3:
resolved "https://registry.yarnpkg.com/tiny-inflate/-/tiny-inflate-1.0.3.tgz#122715494913a1805166aaf7c93467933eea26c4"
integrity sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==

tinyglobby@^0.2.14:
version "0.2.14"
resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.14.tgz#5280b0cf3f972b050e74ae88406c0a6a58f4079d"
integrity sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==
dependencies:
fdir "^6.4.4"
picomatch "^4.0.2"

tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
Expand Down Expand Up @@ -10665,7 +10688,7 @@ wordwrap@^1.0.0:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -10683,6 +10706,15 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down
Loading