|
1 | 1 | <a href="https://www.callstack.com/open-source?utm_campaign=generic&utm_source=github&utm_medium=referral&utm_content=react-native-legal" align="center"> |
2 | 2 | <picture> |
3 | | - <img alt="React Native Legal" src="https://github.com/user-attachments/assets/dd266822-1f3c-48ff-816c-7aaeb95d85aa"> |
| 3 | + <img alt="React Native Legal" src="./images/banner.jpg"> |
4 | 4 | </picture> |
5 | 5 | </a> |
6 | 6 |
|
|
10 | 10 |
|
11 | 11 | --- |
12 | 12 |
|
13 | | -| Android | iOS | AndroidTV | tvOS | |
14 | | -| - | - | - | - | |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +- [Documentation](#documentation) |
| 19 | +- [Installation](#installation) |
| 20 | + - [React Native](#react-native) |
| 21 | + - [Standalone CLI](#standalone-cli) |
| 22 | + - [Node.js - API](#nodejs---api) |
| 23 | +- [Usage](#usage) |
| 24 | + - [I want to generate licenses in my Expo project ](#i-want-to-generate-licenses-in-my-expo-project-) |
| 25 | + - [I want to generate licenses reports in my bare RN project ](#i-want-to-generate-licenses-reports-in-my-bare-rn-project-) |
| 26 | + - [I want to generate licenses reports in my Node.js project](#i-want-to-generate-licenses-reports-in-my-nodejs-project) |
| 27 | + - [I want to customize the presentation of the licenses in my JS/TS project](#i-want-to-customize-the-presentation-of-the-licenses-in-my-jsts-project) |
| 28 | +- [Expo](#expo) |
| 29 | +- [Contributing](#contributing) |
| 30 | +- [Acknowledgements](#acknowledgements) |
| 31 | +- [License](#license) |
| 32 | + |
| 33 | +Automagically generate license acknowledgements for your React Native app and any Node.js project 🚀 |
| 34 | + |
| 35 | +| Android | iOS | AndroidTV | tvOS | |
| 36 | +| ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | |
15 | 37 | |  |  |  |  | |
16 | 38 |
|
| 39 | +## Documentation |
| 40 | + |
| 41 | +You can find the full documentation for all packages in this repository at [callstackincubator.github.io/react-native-legal](https://callstackincubator.github.io/react-native-legal/). |
| 42 | + |
17 | 43 | ## Installation |
18 | 44 |
|
| 45 | +### React Native |
| 46 | + |
19 | 47 | ```sh |
20 | 48 | yarn add react-native-legal |
21 | 49 | ``` |
|
26 | 54 | npm i --save react-native-legal |
27 | 55 | ``` |
28 | 56 |
|
| 57 | +### Standalone CLI |
| 58 | + |
| 59 | +```sh |
| 60 | +yarn add -D license-kit |
| 61 | +``` |
| 62 | + |
| 63 | +or |
| 64 | + |
| 65 | +```sh |
| 66 | +npm i --save-dev license-kit |
| 67 | +``` |
| 68 | + |
| 69 | +### Node.js - API |
| 70 | + |
| 71 | +```sh |
| 72 | +yarn add @callstack/react-native-legal-shared |
| 73 | +``` |
| 74 | + |
| 75 | +or |
| 76 | + |
| 77 | +```sh |
| 78 | +npm i --save @callstack/react-native-legal-shared |
| 79 | +``` |
| 80 | + |
29 | 81 | ## Usage |
30 | 82 |
|
31 | | -This tool is split into 2 parts: |
32 | | -- a library that lets you display native screen with a list of all dependencies and their licenses |
33 | | -- a [config plugin](https://docs.expo.dev/config-plugins/introduction/?redirected) (for Expo projects) and a [custom community cli plugin](https://github.com/react-native-community/cli/blob/main/docs/plugins.md) (for bare RN projects) |
| 83 | +This tool is split into 4 parts: |
| 84 | + |
| 85 | +- a React Native library that lets you display native screen with a list of all dependencies and their licenses |
| 86 | +- an [Expo config plugin](https://docs.expo.dev/config-plugins/introduction/?redirected) (for Expo projects) and a [custom community cli plugin](https://github.com/react-native-community/cli/blob/main/docs/plugins.md) (for bare RN projects) |
| 87 | +- a standalone CLI tool that can be used in any Node.js project to generate license metadata |
| 88 | +- a shared package that exposes the core functionality of the license management tool, allowing customization of presentation logic in your Node.js scripts |
34 | 89 |
|
35 | 90 | ### I want to generate licenses in my Expo project <a name="usage-expo"></a> |
36 | 91 |
|
@@ -68,7 +123,7 @@ function MyComponent() { |
68 | 123 |
|
69 | 124 | 3. Use [Prebuild](https://docs.expo.dev/workflow/prebuild/) or [EAS](https://docs.expo.dev/eas/) to build the app |
70 | 125 |
|
71 | | -### I want to generate licenses in my bare RN project <a name="usage-bare-rn"></a> |
| 126 | +### I want to generate licenses reports in my bare RN project <a name="usage-bare-rn"></a> |
72 | 127 |
|
73 | 128 | 1. Invoke the CLI plugin from the root of your RN app |
74 | 129 |
|
@@ -102,6 +157,49 @@ function MyComponent() { |
102 | 157 | } |
103 | 158 | ``` |
104 | 159 |
|
| 160 | +### I want to generate licenses reports in my Node.js project |
| 161 | + |
| 162 | +You can use the `license-kit` CLI tool to generate license reports in your Node.js project. Here's how to do it: |
| 163 | + |
| 164 | +1. Run the CLI tool from the root of your Node.js project: |
| 165 | + |
| 166 | +```sh |
| 167 | +npx license-kit report --format markdown --output ./public/licenses.md |
| 168 | +``` |
| 169 | + |
| 170 | +or |
| 171 | + |
| 172 | +```sh |
| 173 | +yarn license-kit report --format markdown --output ./public/licenses.md |
| 174 | +``` |
| 175 | + |
| 176 | +This will scan your project's dependencies and generate a license report in the specified format (JSON, Markdown, raw text, or AboutLibraries-compatible JSON metadata). |
| 177 | + |
| 178 | +For a list of supported flags and the default values, run `npx license-kit --help` or read them documented [in the package's README](./packages/license-kit/README.md#command-line-options). To read more about a specific command, run `npx license-kit <command> --help`, e.g. `npx license-kit report --help`. |
| 179 | + |
| 180 | +### I want to customize the presentation of the licenses in my JS/TS project |
| 181 | + |
| 182 | +You can use the `@callstack/react-native-legal-shared` package to access the core functionalities of the license management tool. Here's a basic example of how to use it: |
| 183 | + |
| 184 | +```typescript |
| 185 | +import { |
| 186 | + generateAboutLibrariesNPMOutput, |
| 187 | + generateLicensePlistNPMOutput, |
| 188 | + scanDependencies, |
| 189 | +} from '@callstack/react-native-legal-shared'; |
| 190 | + |
| 191 | +// scan dependencies of a package |
| 192 | +const licenses = scanDependencies(packageJsonPath); |
| 193 | + |
| 194 | +// generate AboutLibraries-compatible JSON metadata |
| 195 | +const aboutLibrariesCompatibleReport = generateAboutLibrariesNPMOutput(licenses); |
| 196 | + |
| 197 | +// generate LicensePlist-compatible metadata |
| 198 | +const licensePlistReport = generateLicensePlistNPMOutput(licenses); |
| 199 | +``` |
| 200 | + |
| 201 | +For more advanced usage, read the [programmatic usage documentation](https://callstackincubator.github.io/react-native-legal/docs/programmatic-usage#usage). |
| 202 | + |
105 | 203 | ## Expo |
106 | 204 |
|
107 | 205 | - ✅ You can use this library with [Development Builds](https://docs.expo.dev/development/introduction/) by adding `react-native-legal` to your `app.json`/`app.config.js` plugins array. |
|
0 commit comments