mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
6461dcd07b
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43287 Move react-native-community/cli clean into core per RFC-0759. Provides: - android - metro - npm - bun - watchman - yarn - cocoapods These tasks are used to clear up caching artefacts in React Native projects. This is going to be called by the `react-native-community/cli` once we publish these in an npm package. Changelog: [General][Added] RFC-0759 Move cli clean into core Reviewed By: cipolleschi Differential Revision: D53997878 fbshipit-source-id: 56907be714184abecc8e3ef677ffc83e9ee7b54d
53 lines
1.7 KiB
Markdown
53 lines
1.7 KiB
Markdown
# @react-native/core-cli-utils
|
|
|
|

|
|
|
|
A collection of utilites to help Frameworks build their React Native CLI tooling. This is not intended to be used directly use users of React Native.
|
|
|
|
## Usage
|
|
|
|
```js
|
|
import { Command } from 'commander';
|
|
import cli from '@react-native/core-cli-utils';
|
|
import debug from 'debug';
|
|
|
|
const android = new Command('android');
|
|
|
|
const frameworkFindsAndroidSrcDir = "...";
|
|
const tasks = cli.clean.android(frameworkFindsAndroidSrcDir);
|
|
const log = debug('fancy-framework:android');
|
|
|
|
android
|
|
.command('clean')
|
|
.description(cli.clean.android)
|
|
.action(async () => {
|
|
const log = debug('fancy-framework:android:clean');
|
|
log(`🧹 let me clean your Android caches`);
|
|
// Add other caches your framework needs besides the normal React Native caches
|
|
// here.
|
|
for (const task of tasks) {
|
|
try {
|
|
log(`\t ${task.label}`);
|
|
// See: https://github.com/sindresorhus/execa#lines
|
|
const {stdout} = await task.action({ lines: true })
|
|
log(stdout.join('\n\tGradle: '));
|
|
} catch (e) {
|
|
log(`\t ⚠️ whoops: ${e.message}`);
|
|
}
|
|
}
|
|
});
|
|
```
|
|
|
|
And you'd be using it like this:
|
|
|
|
```bash
|
|
$ ./fancy-framework android clean
|
|
🧹 let me clean your Android caches
|
|
Gradle: // a bunch of gradle output
|
|
Gradle: ....
|
|
```
|
|
|
|
## Contributing
|
|
|
|
Changes to this package can be made locally and linked against your app. Please see the [Contributing guide](https://reactnative.dev/contributing/overview#contributing-code).
|