Commit Graph

286 Commits

Author SHA1 Message Date
Philipp von Weitershausen dd9b3e13a9 Allow rn-cli.config.js to specify the default transformer
Summary:
This will allow consumers to supply their own transformer to all `react-native` cli commands by simply implementing `rn-cli.config.js` and overriding `getTransformModulePath()`. That way they don't have to fork various parts of the iOS and Android build system that React Native already provides just to add a `--transformer` command line argument.

**Test plan:** Applied this patch to the React Native version in my app, implemented `getTransformModulePath()` in my `rn-cli.config.js`, and verified that my custom transformer is invoked.
Closes https://github.com/facebook/react-native/pull/7961

Differential Revision: D3404201

Pulled By: foghina

fbshipit-source-id: c7eaa85de84d485d06d23a2ffea899821b2cf71c
2016-06-22 08:13:26 -07:00
Nathan Azaria 9845f49581 Fixed setDefaults not being called in React Native apps, fixed typo
Reviewed By: javache

Differential Revision: D3469296

fbshipit-source-id: 032472fede4bfbd051b0f725f35368b22edcc130
2016-06-22 07:13:26 -07:00
Johannes Scharlach 523d39ad92 fix banner for old node version
Summary:
The file is used to notify users when they are using a node version < 4. Therefore we should not allow arrow functions. This was pointed out at the time when the arrow function was introduced but merged anyways: db3a00d58c (commitcomment-16590379)

Trying to run the code with Node version 0.10.32

Before:
```
…/node_modules/react-native/local-cli/server/formatBanner.js:48
    chalkFunction: (fn) => fn,
                         ^
SyntaxError: Unexpected token >
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (…/node_modules/react-native/local-cli/server/checkNodeVersion.js:12:20)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
Closes https://github.com/facebook/react-native/pull/8310

Differential Revision: D3469092

Pulled By: javache

fbshipit-source-id: 757e8b121f6cd6971dd7d73cda92fcb6fcbe5066
2016-06-22 03:43:33 -07:00
Mark Oswald 5276db492a fix runIOS: appPath is hardcoded, read from log
Summary:
The runIOS command currently assumes the path to the `xcodebuild` product - it's hardcoded

```
  const appPath = `build/Build/Products/Debug-iphonesimulator/${inferredSchemeName}.app`;
```
https://github.com/facebook/react-native/blob/master/local-cli/runIOS/runIOS.js#L87

This can be a problem, when you e.g. install a release version of the app to the simulator using the cli. We use a separate schema for that, which can be selected with `--scheme`.

This fix reads the output of the `xcodebuild` call and searches for the path and the name of the *.app file. If it's found, then it will be used to spawn in the simulator. If not, the default (as before) is used.
Closes https://github.com/facebook/react-native/pull/8250

Differential Revision: D3469074

Pulled By: javache

fbshipit-source-id: b10c7e6f48268b0c71dfcbfa661f8e5960c3aaa6
2016-06-22 03:43:33 -07:00
Patricio Beltran d1690a8f9e Support vscode as a React Editor
Summary:
When opening a text editor from react native there are a list of editors being supported. This PR adds `VSCode` to that.

As a difference with the current supported editors, `VSCode` has a notion of `workspace` (a directory that contains all of the project's files). The `workspace` can be passed to `VSCode` as a parameter so that if the workspace is already open we don't get new instances of `VSCode` every time a new file is open. The `workspace` is gotten by comparing the file location with the different `project roots`.

This code relies on `VSCode`'s `code` command, which it's documentation can be found at: https://code.visualstudio.com/Docs/editor/codebasics#_launching-from-the-command-line
Closes https://github.com/facebook/react-native/pull/7757

Differential Revision: D3463761

fbshipit-source-id: ee9ec999747ad6d16d95ec8317f551f3535286c9
2016-06-21 11:09:24 -07:00
Alex Kotliarskyi bc8954babb Use messageSocket to broadcast reload command on global shortcut
Reviewed By: yungsters

Differential Revision: D3433464

fbshipit-source-id: 74111f419d224310b546e7c80fa871417436e1ab
2016-06-20 10:58:32 -07:00
David Aurelio 62bb09d1f6 make module IDs deterministic when bundling
Summary:
This makes sure that `getModuleId` is called on modules in the order returned by `node-haste`, rather than waiting for a couple of promises to resolve before calling the function.

Related: #7758

Reviewed By: frantic

Differential Revision: D3450853

fbshipit-source-id: 7f26590b39b94ade32c73a8db9fd31d283d57549
2016-06-17 12:58:49 -07:00
David Aurelio ae6afcf3f6 move bundle signature to own file
Reviewed By: tadeuzagallo

Differential Revision: D3437491

fbshipit-source-id: c2e00932bacd799d547110c7214374c51ff0b830
2016-06-17 06:28:30 -07:00
Felix Oghina 49f20f4154 Add ReactInstanceHolder
Reviewed By: astreet

Differential Revision: D3328342

fbshipit-source-id: af4e825d0b7c2d3d4490094a939e97cc527dd242
2016-06-17 04:13:29 -07:00
Tony Xiao 93ff5799a5 Add $(inherited) to OTHER_LDFLAGS in xcodeproj template
Summary:
This is particularly important when using generated xcode project together with cocoapods (or anything that leverages a custom xcconfig)

If we do not set `$(inherited)`, then user will get cryptic "Symbol(s) not found for architecture ..." errors that will be really difficult to track down, especially for beginners. This happens because without setting `$(inherited)` we are essentially overriding settings provided on project level (rather than target level) as well as `.xcconfig` level.

**Test plan (required)**

```bash
react-native init MyProject
cd ios
pod init
```
Now go and add a pod to the `Podfile`, say
```ruby
pod 'HockeySDK'
```
And try to use it in `AppDelegate.m`
```objc
...
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];
[[BITHockeyManager sharedHockeyManager] startManager];
```

Before this change, you'll get errors like this
![image](https://cloud.githubusercontent.com/assets/696842/15801450/feb3c036-2a4
Closes https://github.com/facebook/react-native/pull/7927

Differential Revision: D3430228

Pulled By: javache

fbshipit-source-id: ef453ad2e822726db0159d24ec93e301192e21de
2016-06-14 03:02:32 -07:00
Nathan Azaria 8c29a52c54 Implemented automatic IP detection for iOS
Summary:
Implemented automatic IP detection for iOS, based on #6345 and #6362.
As the previous pull requests did, this works by writing the IP address of the host to a file.
Closes https://github.com/facebook/react-native/pull/8091

Differential Revision: D3427657

Pulled By: javache

fbshipit-source-id: 3f534c9b32c4d6fb9615fc2e2c3c3aef421454c5
2016-06-13 15:58:36 -07:00
Valeri Karpov 402e7eaac2 Don't clobber user-defined environment variables
Summary:
Re: javache 's suggestions from https://github.com/facebook/react-native/pull/7878. Didn't want to deal with the merge conflict so I'm opening a separate PR. Here's the original justification:

If I want to set NODE_ENV to "baconator", I should be allowed to. Mutating global state that most devs assume to be immutable is just abysmal dev practice, especially since this mutation only happens when you're building for prod, not running on the simulator.

To test this, run env NODE_ENV=baconator ./gradlew assembleRelease with babel-plugin-transform-inline-environment-variables in your app/.babelrc. You'll see that the final app has NODE_ENV=production.

As a side note, running with babel-plugin-transform-inline-environment-variables in the top-level .babelrc crashes horribly with a compiler error.

For anybody who runs into this bug and doesn't feel like waiting for this to get merged, I wrote a quick babel plugin to remove assignments to process.env, which is sufficient to fix this issue.
Closes https://github.com/facebook/react-native/pull/8057

Differential Revision: D3419950

Pulled By: javache

fbshipit-source-id: dc541cad0a99906433e5c14bbc93ce66b4ed325e
2016-06-10 15:28:29 -07:00
Tim Yung b03a725447 RN: Clear Debug Console on Reload JS
Summary:
Clears the debug console whenever the React Native JS is reloaded.

NOTE: This respects "Preserve log" in Chrome by default.

Reviewed By: jingc

Differential Revision: D3409713

fbshipit-source-id: ce215e3125cf43ab3ea5811c707fab9dfa4bcbb3
2016-06-08 19:13:25 -07:00
Nicolas Charpentier 2a92b52ac8 Add Fresco to ProGuard
Summary:
Motivation #7760
Closes https://github.com/facebook/react-native/pull/7781

Differential Revision: D3397772

fbshipit-source-id: 02b6fd4a403da590fd1c55c554eca00e15899a03
2016-06-06 22:58:42 -07:00
Philipp von Weitershausen 588f01e998 Packager: accept relative --transformer paths everywhere.
Summary:
`react-native start` already ensures that the `--transformer` path is understood to be relative to CWD, not to the module that ends up importing that file. `react-native bundle` and `react-native dependencies` didn't up until this point.

**Test plan:** Ensured that `react-native bundle ... --transformer ./relative/path` works with this patch applied.
Closes https://github.com/facebook/react-native/pull/7857

Differential Revision: D3393777

fbshipit-source-id: 303a226fae9c8087c3dd3b2e8d004462ca66665e
2016-06-06 17:58:25 -07:00
Kasim Tan f49f28ce15 Fix typo (shoud -> should)
Summary: Closes https://github.com/facebook/react-native/pull/7928

Differential Revision: D3390537

fbshipit-source-id: 97ce2331d0942ffe21078b3aec27daed20cd8af5
2016-06-04 16:43:41 -07:00
Philipp von Weitershausen 58fb91e62b Android: allow app/build.gradle to specify how node gets invoked for the packager
Summary:
**Test plan:** With the given patch applied to `react.gradle`, I specified the following in my `android/app/build.gradle`:
```
project.ext.react = [
  nodeExecutableAndArgs: ["node", "--max_old_space_size=4096"]
]
```
and ensured in a `./gradlew installDebug --debug` run that the packager gets indeed invoked with these parameters.
Closes https://github.com/facebook/react-native/pull/7903

Differential Revision: D3390543

fbshipit-source-id: cf440b36633420b8f67070f47dfabf4c84cb28a7
2016-06-04 15:58:24 -07:00
Sean Kozer 0f35f7c6d5 Link React library to Tests target
Summary:
Fixes https://github.com/facebook/react-native/issues/2685
Closes https://github.com/facebook/react-native/pull/7918

Differential Revision: D3389814

fbshipit-source-id: d5054dae386d66e8055c883581f142ec24e60e18
2016-06-03 21:43:22 -07:00
Martin Konicek 7028929d8f 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
2016-06-03 09:13:20 -07:00
Konstantin Raev f22e9353a7 Made react installed via reac-native init strict to unbreak 15.1.0
Summary:
React@15.1.0 is incompatible with React-Native@0.26.
This PR was cherry-picked to 0.26-stable branch now.

What this change does:
- react-native-cli (major release bump) saves exact versions of react-native and react (only in npm2) dependencies into package.json
- local-cli saves exact version of react (only npm3) dependency into package.json
Closes https://github.com/facebook/react-native/pull/7879

Differential Revision: D3384705

Pulled By: davidaurelio

fbshipit-source-id: d4dff418f9659bd083ae8826433a4e7c0355d03b
2016-06-03 03:43:31 -07:00
Kasim Tan a7f1428d4a Fix comment typos
Summary: Closes https://github.com/facebook/react-native/pull/7901

Differential Revision: D3384624

Pulled By: javache

fbshipit-source-id: 741343dec5406af1855624069dd8dc426a93bdb3
2016-06-03 02:43:57 -07:00
Philipp von Weitershausen 1f2027a1fe Android: allow app/build.gradle to specify additional packager arguments
Summary:
If for instance you're using a custom transformer, having this hook will let you specify it without forking all of react.gradle

**Test plan:** Specified some additional packager args in my app's `android/app/build.gradle`:
```groovy
project.ext.react = [
  bundleInDebug: true,
  extraPackagerArgs: ["--transformer", "path/to/my/transformer.js"]
]
```
and ensured they show up when gradle invokes the bundler.
Closes https://github.com/facebook/react-native/pull/7858

Differential Revision: D3382996

Pulled By: mkonicek

fbshipit-source-id: 437b2e6c902931d45b9d2f7ec97c833ba0cd3217
2016-06-02 17:28:39 -07:00
Andrew Sardone 0f57702cd8 Enable ATS w/ localhost exception for generated iOS proj
Summary:
Building off of the work in https://github.com/facebook/react-native/pull/5290, this…

- Remove the total disabling of ATS from the react-native generated iOS project in favor of a localhost exception
Closes https://github.com/facebook/react-native/pull/5355

Differential Revision: D2837517

fbshipit-source-id: ba4b7bd2f6ba4359f5d45175944b990f9927db3b
2016-05-31 12:28:23 -07:00
Jeremy Wyld af149b3a11 Correctly reference cwd instead of __dirname
Summary:
This is for issue #7670.  I consider this a typo, but maybe you don't.

In order to see the problem, you need to have the packager search for the configuration in a place that doesn't have one and the default configuration can't be provided.  It's likely that no one is doing this and also why this probably wasn't seen.
Closes https://github.com/facebook/react-native/pull/7671

Differential Revision: D3350412

fbshipit-source-id: 5f9b520f7d5cbc749e2b898e7bbf2cd84d81ace0
2016-05-25 17:43:22 -07:00
Francois Dumas 84f82e5cdd use RN version from node_modules instead of jcenter
Summary:
the current `build.gradle` configuration make all third-party plugins to pull react native from jcenter instead of using version from `node_modules`.

For example, a newly generated project with RN 0.25 using https://github.com/ProjectSeptemberInc/gl-react-native leads to the following gradle output:

```
Download https://jcenter.bintray.com/com/facebook/stetho/stetho-okhttp/1.2.0/stetho-okhttp-1.2.0.pom
Download https://jcenter.bintray.com/com/facebook/stetho/stetho/1.2.0/stetho-1.2.0.pom
Download https://jcenter.bintray.com/com/facebook/stetho/stetho/1.2.0/stetho-1.2.0.jar
Download https://jcenter.bintray.com/com/facebook/stetho/stetho-okhttp/1.2.0/stetho-okhttp-1.2.0.jar
Download https://jcenter.bintray.com/com/facebook/react/react-native/0.20.1/react-native-0.20.1.aar
```
Closes https://github.com/facebook/react-native/pull/7470

Differential Revision: D3346526

Pulled By: mkonicek

fbshipit-source-id: 0f1d051f4340f35403931727982900a9fc7abad5
2016-05-25 07:58:23 -07:00
Alex Kotliarskyi 11449359e5 Add index page for packager
Summary:
When packager is running, visiting localhost:8081 produces ugly 404 "GET / not found"
This diff adds a simple index.html page that has a title and link to documentation.

It's a super tiny detail, but I hope it makes things a little nicer. Improvements are welcome.

Maybe we could include an offline copy of React Native's docs website?

Reviewed By: vjeux

Differential Revision: D3341242

fbshipit-source-id: c8cd4b647e69eb520ea8bc978bea070551225912
2016-05-24 11:58:23 -07:00
MIYOKAWA, Nobuyoshi 8f9a3aa0e2 Add .iml to ignore target.
Summary:
Sorry for trivial one, but I feel no need to share '.iml' in a project, so it should be ignored.
Closes https://github.com/facebook/react-native/pull/7689

Differential Revision: D3334367

fbshipit-source-id: 2a68aa93084a51d0b3d24427c71bc7c12e41ed78
2016-05-23 04:58:24 -07:00
Janic Duplessis 6961fd23ba Use a separate babel config for the local-cli and the packager
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.

I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.

**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.

I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155

Reviewed By: bestander

Differential Revision: D3301008

Pulled By: davidaurelio

fbshipit-source-id: 504180d158a1e50bc03e28fb0d1e53d0731ce32f
2016-05-21 06:58:26 -07:00
Mike Grabowski 149d0b91c2 Merge rnpm into react-native
Summary:
This is initial (first step) in the merging process. For now, we are just going to move our code as is into `local-cli` folder (first commit). There were other tweaks made in separate commits to make it easier to go through the code as the diff is expected to be rather large. The purpose of this is to make it easier to start working in small batches and improving the CLI incrementally on a daily basis.

Current codebase will still leave in `rnpm` organisation on Github where we keep working on new features, bugs and ship releases to `npm` until we finish our integration and provide a nice interface for users to migrate (in case it changes at all)

Flow, Jest and npm will ignore this folder for now until we integrate it properly.

Tests are to be rewritten from mocha to jest in `rnpm/link`. We will hook them all up as soon as we start using them in local-cli.

For now, there's no point in having them running and possibly breaking the builds.

We will announce next steps with Kureev later this week
Closes https://github.com/facebook/react-native/pull/7550

Differential Revision: D3327772

Pulled By: mkonicek

fbshipit-source-id: 90faa4bd78476d93ed21b1253e0d95c755d28a30
2016-05-20 04:58:26 -07:00
Mike Grabowski e3bbd300f6 Update upgrade command with 0.26 breaking changes
Summary:
Generally it feels that at some point we will just integrate `rnpm upgrade` directly here, but this is a super temporary quick workaround for the people upgrading to 0.26. We might want to change it later to 0.27 and update this message in case we have any other stuff to upgrade.

![screen shot 2016-05-18 at 14 28 47](https://cloud.githubusercontent.com/assets/2464966/15358460/df3b1b66-1d04-11e6-825c-fa18fa96ee6e.png)

It is supposed to work for 0.26.0, 0.26.1 and all the others up to 0.27.
Closes https://github.com/facebook/react-native/pull/7614

Differential Revision: D3316420

fbshipit-source-id: 3861b4228ee878464e18ba3de1f3e0c12d5f30d1
2016-05-18 07:28:52 -07:00
Andrew Jack 6bbaff2944 Upgrade to OkHttp3
Summary:
Update to [OkHttp](https://github.com/square/okhttp) to [OkHttp3](https://publicobject.com/2015/12/12/com-squareup-okhttp3/)

We must also update:
- Fresco to 0.10.0
- okio to 1.8.0

**Motivation**
Reasons for upgrading:
* Issue #4021
* "We discovered that RN Android sometimes fails to connect to the latest stable version of NGINX when HTTP/2 is enabled. We aren't seeing errors with other HTTP clients so we think it's specific to RN and OkHttp. Square has fixed several HTTP/2 bugs over the past eight months." - ide
* OkHttp3 will be maintained & improved, but OkHttp2 will only receive [security fixes](https://publicobject.com/2016/02/11/okhttp-certificate-pinning-vulnerability/)
* Cleaner APIs - "Get and Set prefixes are avoided"
* Deprecated/Removed - HttpURLConnection & Apache HTTP
* React Native apps are currently being forced to bundle two versions of OkHttp (v2 & v3), if another library uses v3
* Improved WebSocket performance - [CHANGELOG.md](https://github.com/square/okhttp/blob/master
Closes https://github.com/facebook/react-native/pull/6113

Reviewed By: andreicoman11, lexs

Differential Revision: D3292375

Pulled By: bestander

fbshipit-source-id: 7c7043eaa2ea63f95854108b401c4066098d67f7
2016-05-17 12:43:39 -07:00
David Aurelio 9092198b1b Terminate startup code with a null byte, too (indexed file random access bundles)
Reviewed By: javache

Differential Revision: D3310269

fbshipit-source-id: d0fbf5afd6baecf50ec568e8694a15c96e6a9c85
2016-05-17 09:58:44 -07:00
David Aurelio 2f41c56f59 change to fixed size offset table + indexed lookup
Reviewed By: javache

Differential Revision: D3281989

fbshipit-source-id: 52db9f441dd46024eafac46ae8d32b26640cad71
2016-05-16 04:43:24 -07:00
Shane O'Sullivan fa5d1fefa1 Make the root view background color explicit
Summary:
The default white background for the root view causes an unattractive flash when loading any app with a non-white background.  Almost every developer has to search for how to fix it.

This change makes the background color explicit in the file, so it can be easily change to match the color of the splash screen and the main screen without having to search for it.

**Test plan (required)**
Launched my app and it still has a white flash for the background before loading the app.  I changed the background colors to other values and the flash was that color.
Closes https://github.com/facebook/react-native/pull/7570

Differential Revision: D3303451

Pulled By: vjeux

fbshipit-source-id: 61dbab768095c430bcb583bafb57575a7d767e6f
2016-05-14 22:43:20 -07:00
David Aurelio b4e970f6c3 Use continuous module IDs for random access bundles
Reviewed By: bestander

Differential Revision: D3292980

fbshipit-source-id: ab5791d31add42a26cf55a0309564330c383eaa2
2016-05-12 17:28:25 -07:00
Tomas Roos cd9271567f Add flow directive to index.android.js
Summary:
iOS template contains flow directive in top comment. Android should too for consistency.
Closes https://github.com/facebook/react-native/pull/7482

Differential Revision: D3281131

fbshipit-source-id: d9a77196faed5e41753d09768721e1da1e6cc60a
2016-05-10 03:11:21 -07:00
jsdevel d4cc5b53c7 Setting current working directory for dev server.
Summary:
* This allows `react-native` to work for users on fedora.
* `react-native run-android` was failing because the launch packager script was unable to find packager.sh (see `source` in `man bash`).
* This change sets cwd for the dev server when run with `run-android`.
Closes https://github.com/facebook/react-native/pull/7316

Differential Revision: D3255866

fb-gh-sync-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
fbshipit-source-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
2016-05-04 02:45:29 -07:00
Sawyer Hood 9425bcff8f Updated a warning string in upgrade.js
Summary:
I inserted an 'in' in the warning message that is displayed when the user's package.json file doesn't have a valid version number for react native.

Test plan
---------------
-run upgrade.js on a project with an invalid version number.
Closes https://github.com/facebook/react-native/pull/7314

Differential Revision: D3245839

fb-gh-sync-id: e38f3be0884d8c75f9610faced85d5c81c24a49e
fbshipit-source-id: e38f3be0884d8c75f9610faced85d5c81c24a49e
2016-04-30 18:21:17 -07:00
Janic Duplessis f8f9362c05 Reverted commit D3242754
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.

I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.

**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.

I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155

Differential Revision: D3242754

Pulled By: eczarny

fb-gh-sync-id: 6cd349e284b7d92a1b2cc8b5c0e26adbfb0d9a2f
fbshipit-source-id: 6cd349e284b7d92a1b2cc8b5c0e26adbfb0d9a2f
2016-04-30 16:54:31 -07:00
Janic Duplessis 19429f79b2 Use a separate babel config for the local-cli and the packager
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.

I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.

**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.

I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155

Differential Revision: D3242754

Pulled By: davidaurelio

fb-gh-sync-id: 02880c841c10562d5f107e1c975d668e55cc619f
fbshipit-source-id: 02880c841c10562d5f107e1c975d668e55cc619f
2016-04-30 16:25:24 -07:00
David Aurelio 34dd17cae5 Add encoding/hash signature to JS files
Reviewed By: tadeuzagallo

Differential Revision: D3241028

fb-gh-sync-id: 737ae64cf3a3f4f121076dbfe933d5fe71e07817
fbshipit-source-id: 737ae64cf3a3f4f121076dbfe933d5fe71e07817
2016-04-30 09:44:23 -07:00
Mark Oswald 90f9f48498 add reset-cache command to bundle
Summary:
Currently the `react-native bundle` has no option to reset the file cache. For example changing the .babelrc has no effect on the bundling process. `react-native start` has it already implemented, so this is just a small addition.

**Test plan (required)**

the issue:

- `react-native init` a new project
- run `react-native bundle` (should work as expected)
- create `.babelrc` with empty object ```{}```
- rerun `react-native bundle`
- should fail now with `Unexptected token` (no babel plugins configured)
 - if not failing, your cache already hit (clear $TMPDIR to get the error)
- delete .babelrc and rerun `bundle`
- still failing, but it should went back to normal
- delete your $TMPDIR contents
- works again

The option `--reset-cache` should fix that
Closes https://github.com/facebook/react-native/pull/7297

Differential Revision: D3241259

Pulled By: davidaurelio

fb-gh-sync-id: 0ed5b58aa1f021d72021f4c80fbc57d2e7e8181f
fbshipit-source-id: 0ed5b58aa1f021d72021f4c80fbc57d2e7e8181f
2016-04-29 10:38:29 -07:00
David Aurelio cccb8db175 Unify source map approach for RA bundles on iOS/Android
Reviewed By: javache

Differential Revision: D3229780

fb-gh-sync-id: a3148d7626b32a2e6803ae8c35ac75025a992a32
fbshipit-source-id: a3148d7626b32a2e6803ae8c35ac75025a992a32
2016-04-29 10:16:22 -07:00
Shawn Wilsher 856f9e9fed Add `--version` to `local-cli/cli.js`
Summary:
[Buck](https://buckbuild.com) has a concept of a versioned tool.  In order to
properly use RN with Buck, the `cli.js` script should return the proper version
when passed `--version`.

Reviewed By: astreet

Differential Revision: D3197207

fb-gh-sync-id: 12ea35587cf492eb89d7dd102e93bdd26bc813c0
fbshipit-source-id: 12ea35587cf492eb89d7dd102e93bdd26bc813c0
2016-04-29 09:25:32 -07:00
Martin Konicek 12caa363a1 Remove 'react-native link'
Summary:
`react-native link` was an early experiment, [rnpm](https://github.com/rnpm/rnpm) does this much better. After merging this PR we should merge rnpm so that `react-native link` works again :)

grabbou Kureev Just making some space here :)

This reverts 4e5a2bc079.

**Test Plan**

e2e tests on Travis and CircleCI
Closes https://github.com/facebook/react-native/pull/7290

Differential Revision: D3240702

Pulled By: mkonicek

fb-gh-sync-id: 6aac83fac599ba3db0dd0a7ac48653ebabd93491
fbshipit-source-id: 6aac83fac599ba3db0dd0a7ac48653ebabd93491
2016-04-29 05:27:28 -07:00
Jagdeep Nagpal 3d0d426d46 Renamed --flavor to --variant
Summary:
This small update to runAndroid.js which renames --flavor to --variant.
~~`react-native run-android --flavor=staging`~~

~~doesn't work as it needs build type as well~~

~~so at present it needs to be like this~~

~~`react-native run-android --flavor=stagingDebug`~~

~~it looks messy, instead if we want to use the original spec then Debug must be concatenated to the end all the time as run-android was speced to trigger only debug builds~~
Closes https://github.com/facebook/react-native/pull/7036

Differential Revision: D3240692

Pulled By: mkonicek

fb-gh-sync-id: ef4570797b53ac8f76d0b86a263916ac5bdb0581
fbshipit-source-id: ef4570797b53ac8f76d0b86a263916ac5bdb0581
2016-04-29 05:18:24 -07:00
Janic Duplessis 891b87e7fb Launch the packager with `react-native run-android` on Windows
Summary:
Adds support for launching the packager in a new window on Windows.

**Test plan (required)**

Tested that the packager is launched in a completely independent process. This means that exiting the `react-native run-android` command should not close the packager window and it should exit properly when completed even if the packager window is still opened. Pretty much made sure it behaves exactly like on mac.

Also tested that an error in the packager will not close the window immediately to show the error stack trace.
Closes https://github.com/facebook/react-native/pull/7129

Differential Revision: D3240628

Pulled By: mkonicek

fb-gh-sync-id: 007582250536481d2b2376f9a201f8f415fc1080
fbshipit-source-id: 007582250536481d2b2376f9a201f8f415fc1080
2016-04-29 04:14:22 -07:00
David Aurelio e3c18c3990 Upgrade to node-haste@2.10.0 and allow to specify extra node modules
Summary: This upgrades to node-haste@2.10.0 and allows to expose folders as additional node modules from rn-cli.config.js

Reviewed By: bestander

Differential Revision: D3232595

fb-gh-sync-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
fbshipit-source-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
2016-04-28 06:33:27 -07:00
Alex Kotliarskyi 8295d27a90 Fix usage of react-native cli inside package.json scripts
Summary:
IIRC we made `wrong-react-native` to warn people in case they installed `react-native` globally (instead of `react-native-cli` what the guide suggests). To do that we added `bin` entry to React Native's `package.json` that points to `local-cli/wrong-react-native.js`

However, this means that if we have a project that uses `react-native` package and has call to `react-native` CLI inside its package.json, npm will execute *local* override (which just prints a confusing in this context error message).

In fact, the template we generate with `react-native init` has `react-native start` as `start` script, which makes it useless. Let's fix it by making `wrong-react-native` script smarter – it can detect that it has been executed from local `node_modules` and run the actual CLI.

cc vjeux ide
Closes https://github.com/facebook/react-native/pull/7243

Differential Revision: D3226645

Pulled By: frantic

fb-gh-sync-id: be094eb0e70e491da4ebefc2abf11cff56c4c5b7
fbshipit-source-id: be094eb0e70e491da4ebefc2abf11cff56c4c5b7
2016-04-26 15:42:35 -07:00
James Ide 6fac6db4d4 Use xcodebuild and delete "Framework Search Paths" for Xcode 7.3 to un-stall the tests
Summary:The Obj-C tests were stalling when we updated TravisCI to use the OS X image with Xcode 7.3 and iOS 9.3.

On my own MBP with Xcode 7.3 the tests stall as well. Running `./scripts/objc-test.sh` prints out a warning near the end, which says `ld` couldn't find a Frameworks folder under the iPhoneSimulator9.3 SDK directory. Indeed, this directory doesn't exist on my computer. When creating a brand new project with unit tests and UI tests, both test targets don't specify "Framework Search Paths" so I don't think we need to specify it anymore.
Closes https://github.com/facebook/react-native/pull/7168

Differential Revision: D3216524

fb-gh-sync-id: 3097bda98d78289ecdba86801bcd461f3311ac47
fbshipit-source-id: 3097bda98d78289ecdba86801bcd461f3311ac47
2016-04-22 23:04:19 -07:00