mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
b38f80aeb6
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44339 We require the wrapper code for in repository calls to these packages directly from node (i.e. using CommonJS). This wrapper code typically sits at the entrypoint of the build packages (i.e. `index.js`). NOTE: This unblocks an issue preventing me from landing further work on the `helloworld` cli replacing the community template. ## Problem: The [flow-api-translator](https://www.npmjs.com/package/flow-api-translator) library doesn't allow CommonJS `module.exports` when generating TypeScript Type Defintions. ## Change 1. At the built time, this strips out our wrapper code and sets up the dist/ folder appropriately for npm distribution. 2. Updated the `package.json` files to consistently share Flow types Changelog: [Internal] refactor build packages output to remove wrapper. NOTE: Added better error messages when users deviated from the current pattern: {F1501571608} Reviewed By: huntie Differential Revision: D56762162 fbshipit-source-id: f110b31e4ad780998dbc81a2482891ac8d8c6458
@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
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:
$ ./fancy-framework android clean
🧹 let me clean your Android caches
Gradle: // a bunch of gradle output
Gradle: ....
Features
"@react-native/core-cli-utils/version.js"contains the platform and tooling version requirements for react-native.
Contributing
Changes to this package can be made locally and linked against your app. Please see the Contributing guide.