mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Replace glob@^7.0.0 with tinyglobby@^0.2.15 (#54737)
Summary: This replaces `glob@^7.0.0` with `tinyglobby@^0.2.15`. `glob@7` has been deprecated for a while and some versions after had security notices released for them. The plan is to backport this PR to `0.81.x` and onwards. > [!NOTE] > This is a stopgap solution until `fs.glob` becomes generally available with the EOL of Node v20 Succeeds: - https://github.com/facebook/react-native/issues/54669 - https://github.com/facebook/react-native/issues/48875 ## Changelog: [GENERAL] [SECURITY] - Replace `glob@^7.0.0` with `tinyglobby@^0.2.15` Pull Request resolved: https://github.com/facebook/react-native/pull/54737 Test Plan: - Ran all modified commands manually and `pod install in `rn-tester` - NOTE: `ios-prebuild`-related scripts haven't been run manually yet Reviewed By: robhogan Differential Revision: D88069145 Pulled By: huntie fbshipit-source-id: 0c455342a4c6d1d6605fd09fe47b418e5d751491
This commit is contained in:
1 parent
b447d267a8
commit
41eace0093
17 files changed
+159
-160
No files matched your search
+15
-13
@@ -20,10 +20,10 @@ const {
|
||||
const babel = require('@babel/core');
|
||||
const translate = require('flow-api-translator');
|
||||
const {promises: fs} = require('fs');
|
||||
const glob = require('glob');
|
||||
const micromatch = require('micromatch');
|
||||
const path = require('path');
|
||||
const prettier = require('prettier');
|
||||
const {globSync} = require('tinyglobby');
|
||||
const ts = require('typescript');
|
||||
const {parseArgs, styleText} = require('util');
|
||||
|
||||
@@ -103,15 +103,15 @@ async function buildPackage(packageName /*: string */) {
|
||||
const {emitTypeScriptDefs} = getBuildOptions(packageName);
|
||||
const entryPoints = await getEntryPoints(packageName);
|
||||
|
||||
const files = glob
|
||||
.sync(path.resolve(PACKAGES_DIR, packageName, SRC_DIR, '**/*'), {
|
||||
nodir: true,
|
||||
})
|
||||
.filter(
|
||||
file =>
|
||||
!entryPoints.has(file) &&
|
||||
!entryPoints.has(file.replace(/\.js$/, '.flow.js')),
|
||||
);
|
||||
const files = globSync('**/*', {
|
||||
cwd: path.resolve(PACKAGES_DIR, packageName, SRC_DIR),
|
||||
onlyFiles: true,
|
||||
absolute: true,
|
||||
}).filter(
|
||||
file =>
|
||||
!entryPoints.has(file) &&
|
||||
!entryPoints.has(file.replace(/\.js$/, '.flow.js')),
|
||||
);
|
||||
|
||||
process.stdout.write(
|
||||
`${packageName} ${styleText('dim', '.').repeat(72 - packageName.length)} `,
|
||||
@@ -429,9 +429,11 @@ function normalizeExportsTarget(target /*: string */) /*: string */ {
|
||||
}
|
||||
|
||||
function validateTypeScriptDefs(packageName /*: string */) {
|
||||
const files = glob.sync(
|
||||
path.resolve(PACKAGES_DIR, packageName, BUILD_DIR, '**/*.d.ts'),
|
||||
);
|
||||
const files = globSync('**/*.d.ts', {
|
||||
cwd: path.resolve(PACKAGES_DIR, packageName, BUILD_DIR),
|
||||
absolute: true,
|
||||
onlyFiles: true,
|
||||
});
|
||||
const compilerOptions = {
|
||||
...getTypeScriptCompilerOptions(packageName),
|
||||
noEmit: true,
|
||||
|
||||
@@ -13,13 +13,14 @@ packages/react-native/**/*.h
|
||||
[exclude]
|
||||
; Collection of paths we're sure aren't part of the public API. These
|
||||
; will always override anything in [include].
|
||||
packages/react-native/ReactCommon/jsinspector-modern/tests/*
|
||||
packages/react-native/ReactCommon/react/Nativemodule/samples/*
|
||||
packages/react-native/ReactCommon/react/test_utils/*
|
||||
packages/react-native/ReactCommon/react/utils/*
|
||||
packages/react-native/ReactCommon/react/featureflags/*
|
||||
packages/react-native/Libraries/WebSocket/*
|
||||
packages/react-native/Libraries/Wrapper/Example/*
|
||||
; Patterns end in *.h to only match exact files and never directories
|
||||
packages/react-native/ReactCommon/jsinspector-modern/tests/*.h
|
||||
packages/react-native/ReactCommon/react/Nativemodule/samples/*.h
|
||||
packages/react-native/ReactCommon/react/test_utils/*.h
|
||||
packages/react-native/ReactCommon/react/utils/*.h
|
||||
packages/react-native/ReactCommon/react/featureflags/*.h
|
||||
packages/react-native/Libraries/WebSocket/*.h
|
||||
packages/react-native/Libraries/Wrapper/Example/*.h
|
||||
|
||||
[settings]
|
||||
output=scripts/cxx-api/ReactNativeCPP.api
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
const {execSync} = require('child_process');
|
||||
const fs = require('fs');
|
||||
const glob = require('glob');
|
||||
const ini = require('ini');
|
||||
const path = require('path');
|
||||
const {globSync} = require('tinyglobby');
|
||||
const {styleText} = require('util');
|
||||
|
||||
const CONFIG_PATH = path.join(__dirname, './public-api.conf');
|
||||
@@ -179,17 +179,13 @@ function main() {
|
||||
|
||||
let start = performance.now();
|
||||
|
||||
let files /*: string[]*/ = [];
|
||||
for (const searchGlob of config.include) {
|
||||
// glob 7 doesn't support searchGlob as a string[]
|
||||
files = files.concat(
|
||||
glob.sync(searchGlob, {
|
||||
ignore: config.exclude,
|
||||
root: GLOB_PROJECT_ROOT,
|
||||
}),
|
||||
);
|
||||
}
|
||||
files = Array.from(new Set(files));
|
||||
const files = globSync(config.include, {
|
||||
// WARN: Unlike glob, this will exclude directories to be traversed too right now
|
||||
// This means that glob patterns in here must match exact files only
|
||||
ignore: config.exclude,
|
||||
cwd: GLOB_PROJECT_ROOT,
|
||||
expandDirectories: false,
|
||||
});
|
||||
|
||||
// Sort the files to make the output deterministic
|
||||
files.sort();
|
||||
|
||||
@@ -23,11 +23,11 @@ const {
|
||||
// $FlowFixMe[cannot-resolve-module]
|
||||
} = require('@microsoft/api-extractor');
|
||||
const {promises: fs} = require('fs');
|
||||
const glob = require('glob');
|
||||
const {diff} = require('jest-diff');
|
||||
const path = require('path');
|
||||
const prettier = require('prettier');
|
||||
const osTempDir = require('temp-dir');
|
||||
const {globSync} = require('tinyglobby');
|
||||
const {styleText} = require('util');
|
||||
|
||||
const inputFilesPostTransforms: $ReadOnlyArray<PluginObj<mixed>> = [
|
||||
@@ -163,12 +163,11 @@ async function validateSnapshots(
|
||||
}
|
||||
|
||||
async function findPackagesWithTypedef() {
|
||||
const packagesWithGeneratedTypes = glob
|
||||
.sync(`${PACKAGES_DIR}/**/types_generated`, {nodir: false})
|
||||
.map(typesPath =>
|
||||
path.relative(PACKAGES_DIR, typesPath).split('/').slice(0, -1).join('/'),
|
||||
);
|
||||
|
||||
const packagesWithGeneratedTypes = globSync('**/types_generated', {
|
||||
cwd: PACKAGES_DIR,
|
||||
onlyDirectories: true,
|
||||
expandDirectories: false,
|
||||
}).map(typesPath => path.dirname(typesPath));
|
||||
const packagesWithNames = await Promise.all(
|
||||
packagesWithGeneratedTypes.map(async pkg => {
|
||||
const packageJsonContent = await fs.readFile(
|
||||
@@ -202,7 +201,11 @@ async function preparePackagesInTempDir(
|
||||
}),
|
||||
);
|
||||
|
||||
const typeDefs = glob.sync(`${tempDirectory}/**/*.d.ts`);
|
||||
const typeDefs = globSync('**/*.d.ts', {
|
||||
cwd: tempDirectory,
|
||||
onlyFiles: true,
|
||||
absolute: true,
|
||||
});
|
||||
await Promise.all(
|
||||
typeDefs.map(async file => {
|
||||
const source = await fs.readFile(file, 'utf-8');
|
||||
@@ -223,7 +226,11 @@ async function rewriteLocalImports(
|
||||
tempDirectory: string,
|
||||
packages: $ReadOnlyArray<{directory: string, name: string}>,
|
||||
) {
|
||||
const definitions = glob.sync(`${tempDirectory}/**/*.d.ts`);
|
||||
const definitions = globSync('**/*.d.ts', {
|
||||
cwd: tempDirectory,
|
||||
onlyFiles: true,
|
||||
absolute: true,
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
definitions.map(async file => {
|
||||
|
||||
@@ -17,8 +17,8 @@ const {
|
||||
} = require('./constants');
|
||||
const {execSync} = require('child_process');
|
||||
const fs = require('fs');
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
const {globSync} = require('tinyglobby');
|
||||
const util = require('util');
|
||||
|
||||
/*::
|
||||
@@ -142,7 +142,11 @@ async function createBuildStructure(
|
||||
// Now let's use glob to get the final list of files
|
||||
const sources = dependency.files.sources;
|
||||
sources.forEach(source => {
|
||||
const sourceFiles = glob.sync(source, {cwd: sourceFolder});
|
||||
const sourceFiles = globSync(source, {
|
||||
cwd: sourceFolder,
|
||||
expandDirectories: false,
|
||||
onlyFiles: false,
|
||||
});
|
||||
sourceFiles.forEach(sourceFile => {
|
||||
const sourcePath = path.join(sourceFolder, sourceFile);
|
||||
const targetPath = path.join(targetFolder, sourceFile);
|
||||
@@ -180,7 +184,11 @@ async function createHeaderStructure(
|
||||
// Now let's use glob to get the final list of files
|
||||
const headers = dependency.files.headers;
|
||||
headers.forEach(source => {
|
||||
const sourceFiles = glob.sync(source, {cwd: sourceFolder});
|
||||
const sourceFiles = globSync(source, {
|
||||
cwd: sourceFolder,
|
||||
expandDirectories: false,
|
||||
onlyFiles: false,
|
||||
});
|
||||
sourceFiles.forEach(sourceFile => {
|
||||
// get source path
|
||||
const sourcePath = path.join(sourceFolder, sourceFile);
|
||||
@@ -234,7 +242,11 @@ async function copyResources(
|
||||
|
||||
// Copy all resources
|
||||
resources.forEach(source => {
|
||||
const sourceFiles = glob.sync(source, {cwd: rootFolder});
|
||||
const sourceFiles = globSync(source, {
|
||||
cwd: rootFolder,
|
||||
expandDirectories: false,
|
||||
onlyFiles: false,
|
||||
});
|
||||
sourceFiles.forEach(sourceFile => {
|
||||
const sourcePath = path.resolve(rootFolder, sourceFile);
|
||||
const targetPath = path.join(targetFolder, path.basename(sourceFile));
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
const {REACT_NATIVE_PACKAGE_DIR, REPO_ROOT} = require('./consts');
|
||||
const {promises: fs} = require('fs');
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
const {globSync} = require('tinyglobby');
|
||||
|
||||
const WORKSPACES_CONFIG = '{packages,private}/*';
|
||||
|
||||
@@ -71,15 +71,12 @@ async function getPackages(
|
||||
} = filter;
|
||||
|
||||
const packagesEntries = await Promise.all(
|
||||
glob
|
||||
.sync(`${WORKSPACES_CONFIG}/package.json`, {
|
||||
cwd: REPO_ROOT,
|
||||
absolute: true,
|
||||
ignore: includeReactNative
|
||||
? []
|
||||
: ['packages/react-native/package.json'],
|
||||
})
|
||||
.map(parsePackageInfo),
|
||||
globSync(`${WORKSPACES_CONFIG}/package.json`, {
|
||||
cwd: REPO_ROOT,
|
||||
absolute: true,
|
||||
ignore: includeReactNative ? [] : ['packages/react-native/package.json'],
|
||||
expandDirectories: false,
|
||||
}).map(parsePackageInfo),
|
||||
);
|
||||
|
||||
return Object.fromEntries(
|
||||
|
||||
Reference in new issue
Block a user