Skip to content

Commit

Permalink
Update references to the CLI (facebook#23052)
Browse files Browse the repository at this point in the history
Summary:
This updates React Native to use latest CLI. We also create Metro configuration, because CLI looks for React Native in "node_modules" by default. Since we are running React Native from source, it will fail to find required files.

To avoid hacky logic to detect if we are running from source backed into the CLI, I decided to leverage the Metro configuration instead.
Pull Request resolved: facebook#23052

Reviewed By: rickhanlonii

Differential Revision: D13719938

Pulled By: cpojer

fbshipit-source-id: 1f40a40b3cdbb07ccd42daf75feb457556d3e40f
  • Loading branch information
grabbou authored and facebook-github-bot committed Jan 21, 2019
1 parent be9be96 commit 224bc99
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 327 deletions.
3 changes: 3 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
; require from fbjs/lib instead: require('fbjs/lib/warning')
.*/node_modules/warning/.*

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

[libs]
Expand Down
3 changes: 3 additions & 0 deletions .flowconfig.android
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
; require from fbjs/lib instead: require('fbjs/lib/warning')
.*/node_modules/warning/.*

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

[libs]
Expand Down
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

var cli = require('react-native-local-cli');
var cli = require('@react-native-community/cli');

if (require.main === module) {
cli.run();
Expand Down
7 changes: 4 additions & 3 deletions jest/hasteImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ if (REACT_NATIVE_CI) {

function getPlugins() {
try {
const findPlugins = require('react-native-local-cli/core/findPlugins');
// @todo do not rely on private files
const findPlugins = require('@react-native-community/cli/build/core/findPlugins');

return findPlugins([path.resolve(__dirname, pluginsPath)]);
} catch (_) {
return findPlugins(path.resolve(__dirname, pluginsPath));
} catch (e) {
return {
haste: {
providesModuleNodeModules: [],
Expand Down
2 changes: 1 addition & 1 deletion jest/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const generate = require('@babel/generator').default;

const nodeFiles = new RegExp(
[
'/metro(?:-[^/]*)?/', // metro, metro-core, metro-source-map, metro-etc
'/metro(?:-[^/]*)?/', // metro, metro-core, metro-source-map, metro-etc.
].join('|'),
);
const nodeOptions = babelRegisterOnly.config([nodeFiles]);
Expand Down
2 changes: 1 addition & 1 deletion local-cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

var cli = require('react-native-local-cli');
var cli = require('@react-native-community/cli');

if (require.main === module) {
cli.run();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"prop-types": "^15.5.8",
"react-clone-referenced-element": "^1.0.1",
"react-devtools-core": "^3.6.0",
"react-native-local-cli": "1.0.0-alpha.4",
"@react-native-community/cli": "^1.1.0",
"regenerator-runtime": "^0.11.0",
"rimraf": "^2.5.4",
"semver": "^5.0.3",
Expand Down
2 changes: 1 addition & 1 deletion react-native-git-upgrade/cliEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ async function run(requestedVersion, cliArgs) {
const generatorDir = path.resolve(
process.cwd(),
'node_modules',
'react-native-local-cli',
'@react-native-community/cli',
'generator',
);
let projectBackupCreated = false;
Expand Down
13 changes: 12 additions & 1 deletion rn-cli.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,16 @@ module.exports = {
extraNodeModules: {
'react-native': __dirname,
},
getPolyfills,
serializer: {
getModulesRunBeforeMainModule: () => [
require.resolve('./Libraries/Core/InitializeCore'),
],
getPolyfills,
},
resolver: {
hasteImplModulePath: require.resolve('./jest/hasteImpl'),
},
transformer: {
assetRegistryPath: require.resolve('./Libraries/Image/AssetRegistry'),
},
};
455 changes: 137 additions & 318 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 224bc99

Please sign in to comment.