react-native link calls into rnpm

Summary:
An initial integration of rnpm into 'react-native link'.

**Test plan (required)**

    react-native init MyApp
    cd MyApp
    # copied local-cli into MyApp's node_modules
    npm install --save react-native-vector-icons
    react-native link react-native-vector-icons

The link code ran, Android build files were modified.
Closes https://github.com/facebook/react-native/pull/7895

Reviewed By: bestander

Differential Revision: D3379197

Pulled By: mkonicek

fbshipit-source-id: 597158623ed072d7a7fc55a01624233a0f79de23
This commit is contained in:
Martin Konicek 2016-06-03 09:05:14 -07:00 committed by Facebook Github Bot 7
parent d16c6e926c
commit 7028929d8f
5 changed files with 22 additions and 4 deletions

View File

@ -15,6 +15,7 @@ const defaultConfig = require('./default.config');
const dependencies = require('./dependencies/dependencies');
const generate = require('./generate/generate');
const library = require('./library/library');
const link = require('./rnpm/link/src/link');
const path = require('path');
const Promise = require('promise');
const runAndroid = require('./runAndroid/runAndroid');
@ -29,6 +30,14 @@ const version = require('./version/version');
const fs = require('fs');
const gracefulFs = require('graceful-fs');
// Just a helper to proxy 'react-native link' to rnpm
const linkWrapper = (args, config) => {
const rnpmConfig = require('./rnpm/core/src/config');
return new Promise((resolve, reject) => {
link(rnpmConfig, args.slice(1)).then(resolve, reject);
});
}
// graceful-fs helps on getting an error when we run out of file
// descriptors. When that happens it will enqueue the operation and retry it.
gracefulFs.gracefulify(fs);
@ -42,7 +51,8 @@ const documentedCommands = {
'run-android': [runAndroid, 'builds your app and starts it on a connected Android emulator or device'],
'run-ios': [runIOS, 'builds your app and starts it on iOS simulator'],
'upgrade': [upgrade, 'upgrade your app\'s template files to the latest version; run this after ' +
'updating the react-native version in your package.json and running npm install']
'updating the react-native version in your package.json and running npm install'],
'link': [linkWrapper, 'link a library'],
};
const exportedCommands = {dependencies: dependencies};

View File

@ -1,4 +1,4 @@
const toCamelCase = require('to-camel-case');
const toCamelCase = require('lodash').camelCase;
module.exports = function applyParams(str, params, prefix) {
return str.replace(

View File

@ -1,4 +1,4 @@
const toCamelCase = require('to-camel-case');
const toCamelCase = require('lodash').camelCase;
module.exports = function makeStringsPatch(params, prefix) {
const patch = Object.keys(params).map(param => {

View File

@ -1,7 +1,7 @@
const fs = require('fs');
const getReactVersion = require('../getReactNativeVersion');
const getPrefix = require('./getPrefix');
const toCamelCase = require('to-camel-case');
const toCamelCase = require('lodash').camelCase;
const revokePatch = require('./patches/revokePatch');
const makeSettingsPatch = require('./patches/makeSettingsPatch');

View File

@ -150,20 +150,26 @@
"event-target-shim": "^1.0.5",
"fbjs": "^0.8.3",
"fbjs-scripts": "^0.7.0",
"fs-extra": "^0.26.2",
"glob": "^5.0.15",
"graceful-fs": "^4.1.3",
"image-size": "^0.3.5",
"immutable": "~3.7.6",
"inquirer": "^0.12.0",
"joi": "^6.6.1",
"json-stable-stringify": "^1.0.1",
"json5": "^0.4.0",
"jstransform": "^11.0.3",
"lodash": "^3.10.1",
"mime": "^1.3.4",
"mkdirp": "^0.5.1",
"module-deps": "^3.9.1",
"node-fetch": "^1.3.3",
"node-haste": "~2.12.0",
"npmlog": "^2.0.4",
"opn": "^3.0.2",
"optimist": "^0.6.1",
"plist": "^1.2.0",
"progress": "^1.1.8",
"promise": "^7.1.1",
"react-clone-referenced-element": "^1.0.1",
@ -180,6 +186,8 @@
"wordwrap": "^1.0.0",
"worker-farm": "^1.3.1",
"ws": "^0.8.0",
"xcode": "^0.8.2",
"xmldoc": "^0.4.0",
"yargs": "^3.24.0",
"yeoman-environment": "^1.2.7",
"yeoman-generator": "^0.20.3"