mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 01:25:39 +00:00
e8b508144f
Summary: This is an initial step of rewriting the CLI interface to use `rnpm` one (commander, plugins etc.). It's scope is to move all existing commands to use rnpm CLI interface, so that we get plugins, flags and our existing ecosystem working out of the box. <s>This is still WIP and some of the commands are left commented out.</s> For the `config` of `rnpm` (functions get info about project and dependency), <s>I am thinking we can merge them with</s> we decided to merge it with [`default.config.js`](e57683e420/local-cli/default.config.js (L33)
), so they are available on the `new Config()` [instance](e57683e420/local-cli/cliEntry.js (L59)
) (which means we don't have to change anything and current plugins, like runIOS and runAndroid can just start using it [w/o depending on any extra argument](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e Closes https://github.com/facebook/react-native/pull/7899 Differential Revision: D3613193 Pulled By: bestander fbshipit-source-id: 09a072f3b21e5239dfcd8da88a205bd28dc5d037
66 lines
1.8 KiB
JavaScript
66 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
var blacklist = require('../packager/blacklist');
|
|
var path = require('path');
|
|
var rnpmConfig = require('./rnpm/core/src/config');
|
|
|
|
/**
|
|
* Default configuration for the CLI.
|
|
*
|
|
* If you need to override any of this functions do so by defining the file
|
|
* `rn-cli.config.js` on the root of your project with the functions you need
|
|
* to tweak.
|
|
*/
|
|
var config = {
|
|
getProjectRoots() {
|
|
return getRoots();
|
|
},
|
|
|
|
getProjectConfig: rnpmConfig.getProjectConfig,
|
|
getDependencyConfig: rnpmConfig.getDependencyConfig,
|
|
|
|
/**
|
|
* Specify where to look for assets that are referenced using
|
|
* `image!<image_name>`. Asset directories for images referenced using
|
|
* `./<image.extension>` don't require any entry in here.
|
|
*/
|
|
getAssetRoots() {
|
|
return getRoots();
|
|
},
|
|
|
|
/**
|
|
* Returns a regular expression for modules that should be ignored by the
|
|
* packager on a given platform.
|
|
*/
|
|
getBlacklistRE(platform) {
|
|
return blacklist(platform);
|
|
},
|
|
|
|
/**
|
|
* Returns the path to a custom transformer. This can also be overridden
|
|
* with the --transformer commandline argument.
|
|
*/
|
|
getTransformModulePath() {
|
|
return require.resolve('../packager/transformer');
|
|
},
|
|
};
|
|
|
|
function getRoots() {
|
|
var root = process.env.REACT_NATIVE_APP_ROOT;
|
|
if (root) {
|
|
return [path.resolve(root)];
|
|
}
|
|
if (__dirname.match(/node_modules[\/\\]react-native[\/\\]local-cli$/)) {
|
|
// Packager is running from node_modules.
|
|
// This is the default case for all projects created using 'react-native init'.
|
|
return [path.resolve(__dirname, '../../..')];
|
|
} else if (__dirname.match(/Pods[\/\\]React[\/\\]packager$/)) {
|
|
// React Native was installed using CocoaPods.
|
|
return [path.resolve(__dirname, '../../..')];
|
|
} else {
|
|
return [path.resolve(__dirname, '..')];
|
|
}
|
|
}
|
|
|
|
module.exports = config;
|