Commit Graph
1343 Commits
Author SHA1 Message Date
Mike Grabowski 9775089a6d Add platforms doc 2019-04-23 20:45:09 +02:00
Mike Grabowski 5dd6366022 Merge branch 'feat/docs' of github.com:react-native-community/react-native-cli into feat/docs 2019-04-23 19:34:37 +02:00
Mike Grabowski 9b55f15907 fix tests 2019-04-23 18:17:13 +02:00
Mike Grabowski 6e37fca8f8 Delete linking.md 2019-04-23 17:51:48 +02:00
Mike Grabowski c1cfa7f3cc Updates 2019-04-23 17:50:39 +02:00
Mike Grabowski 4e3677d696 Placeholder for dependency 2019-04-23 17:49:02 +02:00
Mike Grabowski f6fe3a45ac Merge branch 'feat/docs' of github.com:react-native-community/react-native-cli into feat/docs 2019-04-23 17:47:41 +02:00
Mike Grabowski 1023933868 Some other tweaks 2019-04-23 17:47:39 +02:00
Michał Pierzchałaandgrabbou 29708d5fb2 Update docs/plugins.md
Co-Authored-By: grabbou <[email protected]>
2019-04-23 17:45:23 +02:00
Michał Pierzchałaandgrabbou 815032fbce Update docs/plugins.md
Co-Authored-By: grabbou <[email protected]>
2019-04-23 17:45:14 +02:00
Mike Grabowski 7d20fc5d02 Take advantage of Joi 2019-04-23 17:44:47 +02:00
Mike Grabowski 595bb1a173 Updates 2019-04-23 17:38:14 +02:00
Mike Grabowski f096feab04 Prefix 2019-04-23 17:36:18 +02:00
Mike Grabowski 7f82a866fd Update 2019-04-23 17:35:07 +02:00
Mike Grabowski ece2601210 Fix flow and update docs 2019-04-23 17:26:43 +02:00
Mike Grabowski fcf09e5034 Update index.js 2019-04-23 17:21:30 +02:00
Mike Grabowski 9158f6f613 Add documentation for plugins and update naming in one place 2019-04-23 17:20:29 +02:00
Mike Grabowski 307d7b7efb structure new files 2019-04-23 15:59:10 +02:00
Mike Grabowski 18f3069921 fix: typos in Autolinking & use same repo for both examples 2019-04-23 15:54:56 +02:00
Mike Grabowski 29ae253139 chore: remove unsupported CocoaPods options from a documentation
This is currently not supported. Let's have it as a "todo" for the future releases, ideally, upon request from someone.
2019-04-23 12:32:44 +02:00
Michał Pierzchała b306c99fda docs: update and rearrange documentation (#338)
* docs: update and rearrange documentation

* add autolinking base docs

* add init docs
2019-04-23 12:26:19 +02:00
Michał Pierzchała 1040959a30 fix: stop resolving "react-native" from package.json as a config (#341)
* fix: stop resolving "react-native" as a valid package.json config property

* add missing editTemplate file
2019-04-22 21:37:54 +02:00
Mike Diarmid 2943ec76af fix: [android] remove forward slashes from package name (#340)
Summary:
---------

The previous CLI config use to return names with `/`'s replaced with `_`'s - it no longer does this so I've moved the replacing logic into the auto-linking build script so as to avoid breaking on Gradle 5+:
![image](https://user-images.githubusercontent.com/5347038/56455870-2b883a80-635c-11e9-90ef-53f00282391f.png)


Test Plan:
----------

After change build no longer fails:

![image](https://user-images.githubusercontent.com/5347038/56455888-8883f080-635c-11e9-9bda-905baf83d3bd.png)

![image](https://user-images.githubusercontent.com/5347038/56455892-98033980-635c-11e9-9cc6-8005e866bc2b.png)
2019-04-20 12:34:26 +02:00
Michał Pierzchała 513d27bd4c v2.0.0-alpha.14 v2.0.0-alpha.14 2019-04-20 11:50:31 +02:00
Mike Diarmid 7839c05ac9 fix(autolinking): remove deprecated Gradle task syntax (#339)
Summary:
---------

Gradle 5 no longer supports the `<<` syntax - swapped to the non-shorthand syntax of `doLast {}`

Test Plan:
----------

Builds successfully with the updated syntax and `PackageList.java` file generated

![image](https://user-images.githubusercontent.com/5347038/56444115-57b9a200-62ef-11e9-94bc-16818c33e65e.png)

![image](https://user-images.githubusercontent.com/5347038/56444122-5f794680-62ef-11e9-962a-5beb06e90667.png)
2019-04-20 11:49:10 +02:00
Michał Pierzchała 827daa4c16 v2.0.0-alpha.13 v2.0.0-alpha.13 2019-04-19 19:51:30 +02:00
Mike Diarmid f1105bcf9a feat: autolinking for Android with Gradle (#258)
Provides the Android/Gradle functionality to go with https://github.com/react-native-community/react-native-cli/pull/256 & https://github.com/react-native-community/react-native-cli/pull/254

## CLI Changes

- Updated `react-native config` to include the android `sourceDir` for react native module packages

----

## Usage

These are the one-off changes required to enable this in the React Native init template (or for existing user projects).

### Modify `android/settings.gradle`

Include the following line in your Android projects `settings.gradle` file:

```groovy
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
```

### Modify `android/app/build.gradle`

Add the following line at the bottom of your Android projects `android/app/build.gradle` file:

```groovy
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
```

### Modify `MainApplication.java`

Import the PackageList class;

```java
import com.facebook.react.PackageList;
```

Replace the `protected List<ReactPackage> getPackages()` method with the following:

```java
    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // additional non auto detected packages can still be added here:
      // packages.add(new SomeReactNativePackage());
      return packages;
    }
```


### Testing

I've tested the following scenarios locally:

- User has no React Native global CLI installed
  - Will warn but continue without issue
- User has no React Native packages installed yet
  - Continues as normal with no warning
- User has more than one React Native package installed
  - Correctly adds multiple packages without issue
- User has a package installed that does not support autodetection (config == null)
  - Prints a warning but continues gracefully
- User has custom/non-linked React Native packages
  - Can be sucessfully manually added via `packages.add(new SomeReactNativePackage());` as documented above in `MainApplication.java`

To test this in a new `react-native init` project locally:

- Clone the CLI project
- Run `yarn` in the CLI project
- Run `cd packages/cli && yarn && yarn link`  in the CLI project
  - (a little hacky as it's a mono-repo)
- Run `yarn link "@react-native-community/cli"` on your React Native project
- Make the required changes as above to your React Native project

----

### Codegen Output Example

An example of the generated `PackageList.java` class:

```java
package com.facebook.react;

import android.app.Application;
import android.content.Context;
import android.content.res.Resources;

import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.List;

import com.test.BuildConfig;

// react-native-webview
import com.reactnativecommunity.webview.RNCWebViewPackage;

public class PackageList {
  private ReactNativeHost reactNativeHost;
  public PackageList(ReactNativeHost reactNativeHost) {
    this.reactNativeHost = reactNativeHost;
  }

  private ReactNativeHost getReactNativeHost() {
    return this.reactNativeHost;
  }

  private Resources getResources() {
    return this.getApplication().getResources();
  }

  private Application getApplication() {
    return this.reactNativeHost.getApplication();
  }

  private Context getApplicationContext() {
    return this.getApplication().getApplicationContext();
  }

  public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
      new RNCWebViewPackage()
    );
  }
}
```
2019-04-19 19:48:16 +02:00
Michał Pierzchała 6c575fdb29 feat: support init inside monorepos (#320) 2019-04-19 19:47:52 +02:00
Lucas Bento 256ae68244 feat: check ios-deploy installation before proceeding to build on device (#332)
Summary:
---------

This PR fixes #330, it checks if `ios-deploy` is installed or not before it actually starts building.

Test Plan:
----------

- Run `npm uninstall -g ios-deploy`;
- Run the CLI with `--device` argument and wait for it to fail;
- Run `npm i -g ios-deploy`;
- Run the CLI again and see it working.

cc @thymikee

---

### Error about `ios-deploy` not installed
![image](https://user-images.githubusercontent.com/6207220/56423345-e7d5f800-62ab-11e9-9acf-e5336685904a.png)

### Random error when executing `ios-deploy`
![image](https://user-images.githubusercontent.com/6207220/56423377-12c04c00-62ac-11e9-863a-82c12800893a.png)
2019-04-19 14:35:47 +02:00
ifsnow 90a587e583 fix: modify wrong install arguments (#337) 2019-04-19 07:57:38 +02:00
Mike Grabowski 83d58a63ac chore: top-level unknown keys are now allowed, update test case 2019-04-18 23:19:17 +02:00
Mike Grabowski 15cea82c3e v2.0.0-alpha.12 v2.0.0-alpha.12 2019-04-18 23:05:23 +02:00
Mike Grabowski 9440b15c2d handle haste (#336) 2019-04-18 23:03:57 +02:00
Mike Grabowski a0b9e31542 v2.0.0-alpha.11 v2.0.0-alpha.11 2019-04-18 22:12:34 +02:00
Mike Grabowski f7a7d4ca16 fix: update haste config with platforms too 2019-04-18 22:11:52 +02:00
Mike Grabowski ac9a85e0dd feat: support platforms that ship with project (#335)
* Project can also have platforms

* strip unknown

* Remove stripUnknown and prefer allowUnknown on one level only
2019-04-18 22:06:50 +02:00
Mike Grabowski cacaa075ba v2.0.0-alpha.10 v2.0.0-alpha.10 2019-04-18 18:03:21 +02:00
Mike Grabowski 365be100e7 fix: allow empty strings to be used as defaults 2019-04-18 18:03:02 +02:00
Mike Grabowski e7eeea4a80 v2.0.0-alpha.9 v2.0.0-alpha.9 2019-04-18 17:48:52 +02:00
Mike Grabowski c28fb93696 Support functions in default (#333) 2019-04-18 17:48:07 +02:00
Michał Pierzchała 98d88d5f43 v2.0.0-alpha.8 v2.0.0-alpha.8 2019-04-18 16:32:28 +02:00
Michał Pierzchała a759214c38 fix: publish native_modules.rb file (#331) 2019-04-18 12:19:17 +02:00
Michał Pierzchała 7d9f8cd96f feat: refactor run-ios for readability and better error messages (#328)
Summary:
---------

Refactor `run-ios` for readability and better error messages:

<img width="737" alt="Screenshot 2019-04-17 at 22 04 38" src="https://user-images.githubusercontent.com/5106466/56317371-e0540900-615c-11e9-82e2-e8ef4e706721.png">
<img width="535" alt="Screenshot 2019-04-17 at 22 05 04" src="https://user-images.githubusercontent.com/5106466/56317372-e0540900-615c-11e9-9c82-774889ee2b05.png">
<img width="621" alt="Screenshot 2019-04-17 at 22 08 00" src="https://user-images.githubusercontent.com/5106466/56317551-4e003500-615d-11e9-92dc-c06f0e092e90.png">

Followup to #310 cc @lucasbento 

Test Plan:
----------

Verified that following commands work properly:
- `run-ios`
- `run-ios --device`
- `run-ios --device phone-name`
- `run-ios --uuid asd123`
2019-04-18 11:37:03 +02:00
ifsnow d4c710448e fix: prevent unnecessary actions if android build failed (#325) 2019-04-18 06:35:56 +02:00
Michał Pierzchała 60606efd56 v2.0.0-alpha.7 v2.0.0-alpha.7 2019-04-17 22:20:33 +02:00
Lucas Bento 3a1eb61e62 fix: open Metro in the correct terminal (#310)
* Put `isPackagerRunning` function on `cli-tools` to share between iOS & Android

* Fix `terminal` argument not working when not being provided

* Fallback to the default terminal of the machine when starting the packager on `run-android`

* Delete `isPackagerRunning` as it was moved to `tools`

* Add `terminal` argument to `run-ios`

* Launch Metro from within the `runIOS` command

* Remove code & add `—terminal` argument

* Try using `REACT_TERMINAL` before the default terminal

* Put `isPackagerRunning` function on `cli-tools` to share between iOS & Android

* Fix `terminal` argument not working when not being provided

* Fallback to the default terminal of the machine when starting the packager on `run-android`

* Delete `isPackagerRunning` as it was moved to `tools`

* Add `terminal` argument to `run-ios`

* Launch Metro from within the `runIOS` command

* Remove code & add `—terminal` argument

* Try using `REACT_TERMINAL` before the default terminal

* Add tool function to get the default user terminal

* Fix `terminal` arg type

* Remove spread and specify entry twice instead

* Improve `args` being passed through functions

* Reduce code duplication

* Put `device` and `udid` variable up in the scope
2019-04-17 20:56:08 +02:00
ifsnow 1b8c097885 fix: prevent run-android failure when updating APK (#323)
Summary:
---------

If we run `react-native run-android` while it's already installed, it will fail with the following error.

```bash
info Installing the app on the device (cd android && adb -s emulator-5554 install app/build/outputs/apk/debug/app-x86-debug.apk
adb: failed to install app/build/outputs/apk/debug/app-x86-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install me.mycake without first uninstalling.]
```

In the development phase, I think using adb's install options below is much more efficient.

```
-r : Reinstall an existing app, keeping its data.
-d : Allow version code downgrade.
```


Test Plan:
----------

Not required.
2019-04-17 09:28:04 +02:00
Mike Grabowski be4be8af34 fix: give a better error message when CocoaPods linking fails (#321)
* initial commit

* Remove log

* fix: failing cocoa-pods tests

* Improve accessibility
2019-04-16 23:41:40 +02:00
Mike Grabowski 048ab93b4b chore: fix CI 2019-04-16 22:58:18 +02:00
Eloy Durán 76f079ee8a feat: autolink on iOS 2019-04-16 22:54:46 +02:00