mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
react-native link (aka rnpm) support for Windows
Summary:
Seeing as [Windows is a supported platform](72157cf991/packager/defaults.js (L22)) until platforms can better manager their own CLI and packager needs.
Linking 3rd party libraries should be supported first, because then I'd like to do a follow up PR with grabbou to identify how we can effectively move RNPM functionality out of react-native core and eventually housed in each external platform's repo. The goal would be working with cpojer and hopefully andrewimm to help keep external platform needs in their respective repos, for rnpm/packager _et al._ Seeing as this is a major discussion point, I've made this PR first. Making small steps towards this goal, seems to be the approved methodology from all.
Additionally, I have a merged PR that makes an excellent place for documenting the CLI when it advances, as preparatio
Closes https://github.com/facebook/react-native/pull/11282
Differential Revision: D4311391
fbshipit-source-id: be9a836344be4aed6c4732b0ce4947c2a16b6dad
This commit is contained in:
committed by
Facebook Github Bot
parent
f3dbf3ea89
commit
445182c707
@@ -16,8 +16,10 @@ const chalk = require('chalk');
|
||||
const isEmpty = require('lodash').isEmpty;
|
||||
const promiseWaterfall = require('./promiseWaterfall');
|
||||
const registerDependencyAndroid = require('./android/registerNativeModule');
|
||||
const registerDependencyWindows = require('./windows/registerNativeModule');
|
||||
const registerDependencyIOS = require('./ios/registerNativeModule');
|
||||
const isInstalledAndroid = require('./android/isInstalled');
|
||||
const isInstalledWindows = require('./windows/isInstalled');
|
||||
const isInstalledIOS = require('./ios/isInstalled');
|
||||
const copyAssetsAndroid = require('./android/copyAssets');
|
||||
const copyAssetsIOS = require('./ios/copyAssets');
|
||||
@@ -58,6 +60,33 @@ const linkDependencyAndroid = (androidProject, dependency) => {
|
||||
});
|
||||
};
|
||||
|
||||
const linkDependencyWindows = (windowsProject, dependency) => {
|
||||
|
||||
if (!windowsProject || !dependency.config.windows) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isInstalled = isInstalledWindows(windowsProject, dependency.config.windows);
|
||||
|
||||
if (isInstalled) {
|
||||
log.info(chalk.grey(`Windows module ${dependency.name} is already linked`));
|
||||
return null;
|
||||
}
|
||||
|
||||
return pollParams(dependency.config.params).then(params => {
|
||||
log.info(`Linking ${dependency.name} windows dependency`);
|
||||
|
||||
registerDependencyWindows(
|
||||
dependency.name,
|
||||
dependency.config.windows,
|
||||
params,
|
||||
windowsProject
|
||||
);
|
||||
|
||||
log.info(`Windows module ${dependency.name} has been successfully linked`);
|
||||
});
|
||||
};
|
||||
|
||||
const linkDependencyIOS = (iOSProject, dependency) => {
|
||||
if (!iOSProject || !dependency.config.ios) {
|
||||
return;
|
||||
@@ -96,7 +125,7 @@ const linkAssets = (project, assets) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates project and linkes all dependencies to it
|
||||
* Updates project and links all dependencies to it
|
||||
*
|
||||
* If optional argument [packageName] is provided, it's the only one that's checked
|
||||
*/
|
||||
@@ -128,6 +157,7 @@ function link(args, config) {
|
||||
() => promisify(dependency.config.commands.prelink || commandStub),
|
||||
() => linkDependencyAndroid(project.android, dependency),
|
||||
() => linkDependencyIOS(project.ios, dependency),
|
||||
() => linkDependencyWindows(project.windows, dependency),
|
||||
() => promisify(dependency.config.commands.postlink || commandStub),
|
||||
]));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user