From 0e85e04cb4c1dfa5e795e6bf27926c71f2adb537 Mon Sep 17 00:00:00 2001 From: Hichem Fantar Date: Sat, 7 Dec 2024 17:35:51 +0100 Subject: [PATCH 1/2] Update glob dependency to version 11 and migrate from glob-promise to improve performance and maintainability --- scripts/lint-examples/package.json | 4 +- scripts/lint-examples/src/lintExamples.js | 4 +- sync-api-docs/extractDocsFromRN.js | 6 +- sync-api-docs/package.json | 4 +- website/image-check.js | 5 +- website/package.json | 6 +- yarn.lock | 86 +++++++++++------------ 7 files changed, 53 insertions(+), 62 deletions(-) diff --git a/scripts/lint-examples/package.json b/scripts/lint-examples/package.json index 4358a250ffe..bd9e1d8da90 100644 --- a/scripts/lint-examples/package.json +++ b/scripts/lint-examples/package.json @@ -17,8 +17,8 @@ "@react-native/typescript-config": "^0.76.0-rc.2", "@types/react": "^18.2.79", "eslint": "^8.57.1", - "glob-promise": "^4.2.2", - "prettier": "2.8.8", + "glob": "^11.0.0", + "prettier": "^3.4.2", "react": "18.3.1", "react-native": "^0.76.0-rc.2", "react-native-safe-area-context": "^4.11.0", diff --git a/scripts/lint-examples/src/lintExamples.js b/scripts/lint-examples/src/lintExamples.js index 938359d33d6..0b0c38c1a3c 100755 --- a/scripts/lint-examples/src/lintExamples.js +++ b/scripts/lint-examples/src/lintExamples.js @@ -10,7 +10,7 @@ const {execSync} = require('child_process'); const {promises: fs} = require('fs'); const path = require('path'); -const glob = require('glob-promise'); +const glob = require('glob'); /** * The root document to search for documents @@ -74,7 +74,7 @@ async function lintExamples({command, args, extension, writeBack}) { * @param extension extension to treat the example as if it does not specify */ async function extractExamples(extension) { - const documents = await glob('**/*.md', { + const documents = await glob.glob('**/*.md', { cwd: documentsRoot, absolute: true, }); diff --git a/sync-api-docs/extractDocsFromRN.js b/sync-api-docs/extractDocsFromRN.js index e89e4aed9b6..2c8214d8204 100644 --- a/sync-api-docs/extractDocsFromRN.js +++ b/sync-api-docs/extractDocsFromRN.js @@ -19,9 +19,7 @@ const GENERATE_ANNOTATION = '@' + 'generate-docs'; module.exports = extractDocsFromRN; async function extractDocsFromRN(rnRoot) { - // TODO: make implementation async - - const allComponentFiles = glob.sync( + const allComponentFiles = await glob.glob( path.join(rnRoot, '/Libraries/{Components,Image,}/**/*.js'), { nodir: true, @@ -32,7 +30,7 @@ async function extractDocsFromRN(rnRoot) { const docs = []; for (const file of allComponentFiles) { - const contents = fs.readFileSync(file, {encoding: 'utf-8'}); + const contents = await fs.readFile(file, {encoding: 'utf-8'}); if (!contents.includes(GENERATE_ANNOTATION)) { continue; } diff --git a/sync-api-docs/package.json b/sync-api-docs/package.json index 8eef38273a8..1b6c6b0558b 100644 --- a/sync-api-docs/package.json +++ b/sync-api-docs/package.json @@ -8,8 +8,8 @@ }, "devDependencies": { "@motiz88/react-native-docgen": "0.0.3", - "fs-extra": "^9.1.0", - "glob": "^7.1.6", + "fs-extra": "^11.2.0", + "glob": "^11.0.0", "he": "^1.2.0", "path": "^0.12.7", "react-docgen-markdown-renderer": "^2.1.3", diff --git a/website/image-check.js b/website/image-check.js index 7c9df52b145..1bcc12b776c 100644 --- a/website/image-check.js +++ b/website/image-check.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -const glob = require('glob-promise'); +const glob = require('glob'); const fs = require('fs-extra'); const path = require('path'); const siteConfig = require('./docusaurus.config.js'); @@ -14,7 +14,8 @@ const imageReferenceRegExp = new RegExp(/!\[.*?\]\((.*)\)/g); let missingAssets = []; let queue = Promise.resolve(); -glob('./docs/**/*.md') +glob + .glob('./docs/**/*.md') .then(files => { files.forEach(file => { queue = queue diff --git a/website/package.json b/website/package.json index 7fb88ab57ac..9c8bdc2de1c 100644 --- a/website/package.json +++ b/website/package.json @@ -69,10 +69,8 @@ "@react-native-website/update-redirects": "0.0.0", "@types/google.analytics": "^0.0.46", "alex": "^10.0.0", - "fs-extra": "^10.1.0", - "glob": "^8.0.3", - "glob-promise": "^4.2.2", - "path": "^0.12.7", + "fs-extra": "^11.2.0", + "glob": "^11.0.0", "remark-cli": "^12.0.1", "typescript": "^5.7.2" } diff --git a/yarn.lock b/yarn.lock index b5834466c2e..6f600da5ade 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3451,14 +3451,6 @@ "@types/qs" "*" "@types/serve-static" "*" -"@types/glob@^7.1.3": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" - integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== - dependencies: - "@types/minimatch" "*" - "@types/node" "*" - "@types/google.analytics@^0.0.46": version "0.0.46" resolved "https://registry.yarnpkg.com/@types/google.analytics/-/google.analytics-0.0.46.tgz#621be217fa21f847df62188fcaa86a7340c689da" @@ -3580,11 +3572,6 @@ resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a" integrity sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw== -"@types/minimatch@*": - version "5.1.2" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca" - integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA== - "@types/minimist@^1.2.2": version "1.2.2" resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c" @@ -6877,15 +6864,6 @@ from@~0: resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" integrity sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g== -fs-extra@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" - integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - fs-extra@^11.1.1, fs-extra@^11.2.0: version "11.2.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b" @@ -6895,7 +6873,7 @@ fs-extra@^11.1.1, fs-extra@^11.2.0: jsonfile "^6.0.1" universalify "^2.0.0" -fs-extra@^9.0.0, fs-extra@^9.0.1, fs-extra@^9.1.0: +fs-extra@^9.0.0, fs-extra@^9.0.1: version "9.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ== @@ -7026,13 +7004,6 @@ glob-parent@^6.0.1, glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" -glob-promise@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/glob-promise/-/glob-promise-4.2.2.tgz#15f44bcba0e14219cd93af36da6bb905ff007877" - integrity sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw== - dependencies: - "@types/glob" "^7.1.3" - glob-to-regexp@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" @@ -7050,6 +7021,18 @@ glob@^10.0.0, glob@^10.2.2: package-json-from-dist "^1.0.0" path-scurry "^1.11.1" +glob@^11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-11.0.0.tgz#6031df0d7b65eaa1ccb9b29b5ced16cea658e77e" + integrity sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g== + dependencies: + foreground-child "^3.1.0" + jackspeak "^4.0.1" + minimatch "^10.0.0" + minipass "^7.1.2" + package-json-from-dist "^1.0.0" + path-scurry "^2.0.0" + glob@^7.0.0, glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.2.3: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" @@ -7062,17 +7045,6 @@ glob@^7.0.0, glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.2.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^8.0.3: - version "8.1.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" - integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^5.0.1" - once "^1.3.0" - global-dirs@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-3.0.1.tgz#0c488971f066baceda21447aecb1a8b911d22485" @@ -8344,6 +8316,13 @@ jackspeak@^3.1.2: optionalDependencies: "@pkgjs/parseargs" "^0.11.0" +jackspeak@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-4.0.2.tgz#11f9468a3730c6ff6f56823a820d7e3be9bef015" + integrity sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw== + dependencies: + "@isaacs/cliui" "^8.0.2" + jake@^10.8.5: version "10.8.7" resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.7.tgz#63a32821177940c33f356e0ba44ff9d34e1c7d8f" @@ -9168,6 +9147,11 @@ lru-cache@^10.0.1, lru-cache@^10.2.0: resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== +lru-cache@^11.0.0: + version "11.0.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.0.2.tgz#fbd8e7cf8211f5e7e5d91905c415a3f55755ca39" + integrity sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -10799,6 +10783,13 @@ minimatch@3.1.2, minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.0.5, minimatch dependencies: brace-expansion "^1.1.7" +minimatch@^10.0.0: + version "10.0.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.0.1.tgz#ce0521856b453c86e25f2c4c0d03e6ff7ddc440b" + integrity sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ== + dependencies: + brace-expansion "^2.0.1" + minimatch@^5.0.1: version "5.1.6" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96" @@ -11535,6 +11526,14 @@ path-scurry@^1.11.1: lru-cache "^10.2.0" minipass "^5.0.0 || ^6.0.2 || ^7.0.0" +path-scurry@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-2.0.0.tgz#9f052289f23ad8bf9397a2a0425e7b8615c58580" + integrity sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg== + dependencies: + lru-cache "^11.0.0" + minipass "^7.1.2" + path-to-regexp@0.1.10: version "0.1.10" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.10.tgz#67e9108c5c0551b9e5326064387de4763c4d5f8b" @@ -12221,11 +12220,6 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@2.8.8: - version "2.8.8" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" - integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== - prettier@^3.4.2: version "3.4.2" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.4.2.tgz#a5ce1fb522a588bf2b78ca44c6e6fe5aa5a2b13f" From a39ce4314eccb58a747b4e4453e11b32fe15c130 Mon Sep 17 00:00:00 2001 From: Hichem Fantar Date: Sat, 7 Dec 2024 17:41:29 +0100 Subject: [PATCH 2/2] Remove unused 'path' dependency from package.json and update yarn.lock --- sync-api-docs/package.json | 1 - yarn.lock | 20 -------------------- 2 files changed, 21 deletions(-) diff --git a/sync-api-docs/package.json b/sync-api-docs/package.json index 1b6c6b0558b..90375ad6fba 100644 --- a/sync-api-docs/package.json +++ b/sync-api-docs/package.json @@ -11,7 +11,6 @@ "fs-extra": "^11.2.0", "glob": "^11.0.0", "he": "^1.2.0", - "path": "^0.12.7", "react-docgen-markdown-renderer": "^2.1.3", "tokenize-comment": "^3.0.1" } diff --git a/yarn.lock b/yarn.lock index 6f600da5ade..7ea6e018e37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11556,14 +11556,6 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -path@^0.12.7: - version "0.12.7" - resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f" - integrity sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q== - dependencies: - process "^0.11.1" - util "^0.10.3" - pause-stream@0.0.11: version "0.0.11" resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" @@ -12293,11 +12285,6 @@ process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== -process@^0.11.1: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== - promise-inflight@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" @@ -15028,13 +15015,6 @@ util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== -util@^0.10.3: - version "0.10.4" - resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901" - integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A== - dependencies: - inherits "2.0.3" - utila@~0.4: version "0.4.0" resolved "https://registry.yarnpkg.com/utila/-/utila-0.4.0.tgz#8a16a05d445657a3aea5eecc5b12a4fa5379772c"