From 7c8dac33912f00729f75b5d8183bd48ebb4c5bb1 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Wed, 19 May 2021 17:55:02 +0200 Subject: [PATCH] docs: add list of packages to main README (#243) --- README.md | 67 +++++++++++++++++++++++++++++++--------- package.json | 6 ++-- scripts/update-readme.js | 43 ++++++++++++++++++++++++++ yarn.lock | 9 +++++- 4 files changed, 108 insertions(+), 17 deletions(-) create mode 100644 scripts/update-readme.js diff --git a/README.md b/README.md index b81a84e56..79f7981d2 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,53 @@ - -# Contributing - -This project welcomes contributions and suggestions. Most contributions require you to agree to a -Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us -the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. - -When you submit a pull request, a CLA bot will automatically determine whether you need to provide -a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions -provided by the bot. You will only need to do this once across all repos using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or -contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +``` + ▄████████ ███▄▄▄▄ ▀████ ▐████▀ ▄█ ▄█▄ ▄█ ███ + ███ ███ ███▀▀▀██▄ ███▌ ████▀ ███ ▄███▀ ███ ▀█████████▄ + ███ ███ ███ ███ ███ ▐███ ███▐██▀ ███▌ ▀███▀▀██ + ▄███▄▄▄▄██▀ ███ ███ ▀███▄███▀ ▄█████▀ ███▌ ███ ▀ +▀▀███▀▀▀▀▀ ███ ███ ████▀██▄ ▀▀█████▄ ███▌ ███ +▀███████████ ███ ███ ▐███ ▀███ ███▐██▄ ███ ███ + ███ ███ ███ ███ ▄███ ███▄ ███ ▀███▄ ███ ███ + ███ ███ ▀█ █▀ ████ ███▄ ███ ▀█▀ █▀ ▄████▀ + ███ ███ ▀ +``` + +# rnx-kit + +`rnx-kit` is a collection of tools that are useful for React Native apps and +libraries. + +# Packages + + + + +| Name | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| [@rnx-kit/babel-plugin-import-path-remapper](https://github.com/microsoft/rnx-kit/tree/main/packages/babel-plugin-import-path-remapper) | Babel plugin for remapping 'lib/' imports to 'src/' | +| [@rnx-kit/babel-preset-metro-react-native](https://github.com/microsoft/rnx-kit/tree/main/packages/babel-preset-metro-react-native) | Babel preset for React Native applications | +| [@rnx-kit/bundle-diff](https://github.com/microsoft/rnx-kit/tree/main/packages/bundle-diff) | Simple tool for diffing the content of two bundles | +| [@rnx-kit/cli](https://github.com/microsoft/rnx-kit/tree/main/packages/cli) | Command-line interface for rnx-kit | +| [@rnx-kit/config](https://github.com/microsoft/rnx-kit/tree/main/packages/config) | Package for defining and querying information about rnx kits | +| [@rnx-kit/dep-check](https://github.com/microsoft/rnx-kit/tree/main/packages/dep-check) | Dependency checker for React Native apps | +| [@rnx-kit/metro-config](https://github.com/microsoft/rnx-kit/tree/main/packages/metro-config) | Metro config for monorepos | +| [@rnx-kit/metro-plugin-cyclic-dependencies-detector](https://github.com/microsoft/rnx-kit/tree/main/packages/metro-plugin-cyclic-dependencies-detector) | Cyclic dependencies detector for Metro | +| [@rnx-kit/metro-plugin-duplicates-checker](https://github.com/microsoft/rnx-kit/tree/main/packages/metro-plugin-duplicates-checker) | Duplicate packages checker | +| [@rnx-kit/metro-plugin-typescript-validation](https://github.com/microsoft/rnx-kit/tree/main/packages/metro-plugin-typescript-validation) | Typescript validation during Metro bundling | +| [@rnx-kit/metro-serializer](https://github.com/microsoft/rnx-kit/tree/main/packages/metro-serializer) | Metro's default JavaScript bundle serializer but with plugin support | +| [@rnx-kit/third-party-notices](https://github.com/microsoft/rnx-kit/tree/main/packages/third-party-notices) | Library and tool to build a third party notices file based on a js bundle's source map | +| [@rnx-kit/tools](https://github.com/microsoft/rnx-kit/tree/main/packages/tools) | Common tooling for the react-native-sdk | + + + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require you to agree to a +Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us +the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. + +When you submit a pull request, a CLA bot will automatically determine whether you need to provide +a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions +provided by the bot. You will only need to do this once across all repos using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or +contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/package.json b/package.json index 7acb0dd41..34344855b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "main": "index.js", "repository": { "type": "git", - "url": "https://github.com/Microsoft/rnx-kit.git" + "url": "https://github.com/microsoft/rnx-kit.git" }, "scripts": { "build": "lage build --grouped", @@ -27,12 +27,14 @@ "preinstall": "node ./scripts/preinstall.js", "postinstall": "node ./scripts/postinstall.js", "publish:beachball": "beachball publish --bump-deps -m\"📦 applying package updates ***NO_CI***\"", - "test": "lage test --verbose --grouped" + "test": "lage test --verbose --grouped", + "update-readme": "node scripts/update-readme.js" }, "devDependencies": { "@babel/core": "^7.0.0", "beachball": "^2.2.0", "lage": "^0.29.0", + "markdown-table": "^2.0.0", "metro": "^0.59.0", "metro-config": "^0.59.0", "metro-react-native-babel-preset": "^0.59.0" diff --git a/scripts/update-readme.js b/scripts/update-readme.js new file mode 100644 index 000000000..4a1247ac3 --- /dev/null +++ b/scripts/update-readme.js @@ -0,0 +1,43 @@ +const fs = require("fs"); +const markdownTable = require("markdown-table"); +const path = require("path"); + +const PACKAGE_JSON = "package.json"; +const PACKAGES = "packages"; +const README = "README.md"; +const TOKEN_START = ""; +const TOKEN_END = ""; + +function readFile(path) { + return fs.readFileSync(path, { encoding: "utf-8" }); +} + +const repoUrl = (() => { + const manifest = JSON.parse(readFile(PACKAGE_JSON)); + return manifest.repository.url.replace(/\.git$/, ""); +})(); + +const packages = fs.readdirSync(PACKAGES).reduce((packages, packageDir) => { + const packagePath = path.join(PACKAGES, packageDir); + const manifestPath = path.join(packagePath, PACKAGE_JSON); + const content = readFile(manifestPath); + const manifest = JSON.parse(content); + if (!manifest["private"]) { + const { name, description } = manifest; + const link = `[${name}](${repoUrl}/tree/main/${packagePath})`; + packages.push([link, description]); + } + return packages; +}, []); + +const table = markdownTable([["Name", "Description"], ...packages]); + +const readme = readFile(README); +const updatedReadme = readme.replace( + new RegExp(`${TOKEN_START}([^]+)${TOKEN_END}`), + `${TOKEN_START}\n\n${table}\n\n${TOKEN_END}` +); + +if (updatedReadme !== readme) { + fs.writeFileSync(README, updatedReadme); +} diff --git a/yarn.lock b/yarn.lock index 58d3800bf..6d7cbf034 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7035,6 +7035,13 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +markdown-table@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-2.0.0.tgz#194a90ced26d31fe753d8b9434430214c011865b" + integrity sha512-Ezda85ToJUBhM6WGaG6veasyym+Tbs3cMAw/ZhOPqXiYsr0jgocBV3j3nx+4lk47plLlIqjwuTm/ywVI+zjJ/A== + dependencies: + repeat-string "^1.0.0" + marked-terminal@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/marked-terminal/-/marked-terminal-4.1.1.tgz#34a6f063cd6cfe26bffaf5bac3724e24242168a9" @@ -8864,7 +8871,7 @@ repeat-element@^1.1.2: resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== -repeat-string@^1.6.1: +repeat-string@^1.0.0, repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc=