mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 01:25:39 +00:00
9f01f96770
Summary: This PR moves `react` from dependencies to peerDependencies. In general, this would have only been important for those people using packages that depend on `react` and were using npm@2...npm@3 would automatically de-dupe. However, when #5812 gets merged, dependencies will be scoped to react-native (on both npm@2 & npm@3), thus breaking projects that are using a package like `react-redux` for example, which depends on `react`. There would be two copies of React installed, and due to the use of haste modules in `react`, this would break the packager and cause naming collisions. This PR does three things - 1. Moves the dependency from dependencies to peerDependencies 2. Updates the local-cli to run `npm install react --save` when a new project is initialized. 3. Updates `react-native upgrade` to warn if `react` is not listed in the package.json's dependencies. **Note: This will require a shrinkwrap update.** Closes https://github.com/facebook/react-native/pull/5813 Reviewed By: svcscm Differential Revision: D2918380 Pulled By: androidtrunkagent fb-gh-sync-id: 6e4234a45284be2fdf6fedf29e70b2d2d0262486 shipit-source-id: 6e4234a45284be2fdf6fedf29e70b2d2d0262486
95 lines
2.6 KiB
JavaScript
95 lines
2.6 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
'use strict';
|
|
|
|
var path = require('path');
|
|
var yeoman = require('yeoman-generator');
|
|
var utils = require('../generator-utils');
|
|
|
|
module.exports = yeoman.generators.NamedBase.extend({
|
|
constructor: function() {
|
|
yeoman.generators.NamedBase.apply(this, arguments);
|
|
|
|
this.option('skip-ios', {
|
|
desc: 'Skip generating iOS files',
|
|
type: Boolean,
|
|
defaults: false
|
|
});
|
|
this.option('skip-android', {
|
|
desc: 'Skip generating Android files',
|
|
type: Boolean,
|
|
defaults: false
|
|
});
|
|
this.option('upgrade', {
|
|
desc: 'Specify an upgrade',
|
|
type: Boolean,
|
|
defaults: false
|
|
});
|
|
|
|
// this passes command line arguments down to the composed generators
|
|
var args = {args: arguments[0], options: this.options};
|
|
if (!this.options['skip-ios']) {
|
|
this.composeWith('react:ios', args, {
|
|
local: require.resolve(path.resolve(__dirname, '..', 'generator-ios'))
|
|
});
|
|
}
|
|
if (!this.options['skip-android']) {
|
|
this.composeWith('react:android', args, {
|
|
local: require.resolve(path.resolve(__dirname, '..', 'generator-android'))
|
|
});
|
|
}
|
|
},
|
|
|
|
configuring: function() {
|
|
utils.copyAndReplace(
|
|
this.templatePath('../../../.flowconfig'),
|
|
this.destinationPath('.flowconfig'),
|
|
{ 'Libraries\/react-native\/react-native-interface.js' : 'node_modules/react-native/Libraries/react-native/react-native-interface.js' }
|
|
);
|
|
|
|
this.fs.copy(
|
|
this.templatePath('_gitignore'),
|
|
this.destinationPath('.gitignore')
|
|
);
|
|
this.fs.copy(
|
|
this.templatePath('_watchmanconfig'),
|
|
this.destinationPath('.watchmanconfig')
|
|
);
|
|
},
|
|
|
|
writing: function() {
|
|
if (this.options.upgrade) {
|
|
// never upgrade index.*.js files
|
|
return;
|
|
}
|
|
if (!this.options['skip-ios']) {
|
|
this.fs.copyTpl(
|
|
this.templatePath('index.ios.js'),
|
|
this.destinationPath('index.ios.js'),
|
|
{name: this.name}
|
|
);
|
|
}
|
|
if (!this.options['skip-android']) {
|
|
this.fs.copyTpl(
|
|
this.templatePath('index.android.js'),
|
|
this.destinationPath('index.android.js'),
|
|
{name: this.name}
|
|
);
|
|
}
|
|
},
|
|
|
|
install: function() {
|
|
if (this.options.upgrade) {
|
|
return;
|
|
}
|
|
|
|
this.npmInstall('react', { '--save': true });
|
|
}
|
|
});
|