Commit Graph
184 Commits
Author SHA1 Message Date
Michał Pierzchała 4a3d3e3220 feat: log error stacktrace by default 2019-05-20 17:18:02 +02:00
Michał Pierzchała ba14149103 v2.0.0-alpha.21 2019-05-20 14:53:47 +02:00
Mike GrabowskiandMichał Pierzchała 1d2f2546ca chore: improve RNPM warnings (#395)
* Improve RNPM warnings

* Update packages/cli/src/tools/config/readConfigFromDisk.js

Co-Authored-By: Michał Pierzchała <[email protected]>

* Fix lint error
2019-05-20 14:50:41 +02:00
Kacper WiszczukandMichał Pierzchała b03f7413cc chore: migrate tools to TypeScript (#296)
* Migrate tools package to Typescript

* Prebuild ts

* Improve yarn build-clean

* Remove unnecessary statements

* Fix linting

* Fix eslint

* Update packages/tools/src/isPackagerRunning.ts

Co-Authored-By: Michał Pierzchała <[email protected]>

* adjust package.json

* add vscode helper settings

* remove dead node-fetch references
2019-05-17 22:32:54 +02:00
Lucas Bento c2fb83fb64 feat: support init with custom project directory (#365)
* Change `packageName` to `projectName` & add `projectPath` argument

* Add a way to specify a custom project path to init the app on

* Force the `init` command to create the project path recursively

* Add test for providing the project path on init

* Throw error if custom project path doesn’t exist and can’t be created

* Fix type error on `customProjectPath`

* Create directory before running the test with custom project path

* Use `mkdirp` to create project folder & Use `inquirer` to prompt for a directory replace

* Specify `directory` as an option

* Handle custom directory path after react logo

* Check if `ios` folder exists before trying to open it

* Update `init` tests

* Add `directory` type

* Remove unused `inquirer` from `init` test

* Only remove the project folder if it didn’t exist before running `init`

* Remove correct directory if it didn’t exist before `init`

* simplify

* make directory an argument instead of a flag

* update descriptions

* fix test

* use --directory after all

* address feedback; remove version handling from createFromTemplate

* flip the default
2019-05-17 18:25:11 +02:00
Michał Pierzchała d3f3aca16f v2.0.0-alpha.20 2019-05-15 17:21:57 +02:00
Lucas Bento 27b2b52aa4 feat: Show message if CocoaPods installation takes long (#390)
* Add message that shows only if `cocoapods` installation take more than 30 seconds

* adjustments
2019-05-15 17:03:39 +02:00
Lucas Bento 875a025d6f feat: automatically install pods in legacy init (#386) 2019-05-15 16:53:53 +02:00
yinhf 6fb96af8d3 fix: config.reporter undefined bug (#376)
* fix: config.reporter undefined bug

* refactor

* Update loadMetroConfig.js
2019-05-15 15:38:24 +02:00
Michał Pierzchała a41b7a3198 chore: upgrade joi to @hapi/joi to remove npm warnings (#388) 2019-05-15 15:00:37 +02:00
Lucas Bento 5612dde7cc Improve CocoaPods prompt question when running init (#389) 2019-05-15 09:25:00 +02:00
Michał Pierzchała 6947ae2894 v2.0.0-alpha.19 2019-05-13 12:25:44 +02:00
Eric Lewis c423d20317 Add openURLMiddleware (#383)
* Add openURLMiddleware

This allow’s react-native to open Chrome windows arbitrarily.

* Upgrade open, add launchBrowser command.
2019-05-13 11:22:31 +01:00
Lucas Bento 23c52cfbd1 feat: automatically run pod install when running init command (#373)
* Specify `.xcworkspace` on run instructions instead of `.xcodeproj`

* Add `command-exists` package

* Remove unneeded space after log message

* Run `pod install` and check for cocoa pods when running `init` command

* Put pods installation directly on `init` file and verify if `Podfile` exists before running

* Revert change to space

* Remove unneeded `console.log`

* `cd` back to the directory after pod installation

* Throw with `CLIError` instead of `Error`

* Remove unneeded `try…catch`

* Fix wrong uppercased word

* Try to install `cocoapods` without sudo before trying with it

* Run pods installation only on macOS

* Check which extension for the project to print out on the run instructions for iOS

* Use `fs` instead of `fs-extra`

* Move `installPods` to separate file

* Add missing `logger` import

* Fix warnings on duplicated variable declaration

* fixups
2019-05-12 09:38:08 +02:00
Michał Pierzchała 1e60601fac v2.0.0-alpha.18 2019-05-10 15:21:25 +02:00
Michał Pierzchała bae68953cd feat: improve run-android error messages; rename "installDebug" -> "task" (#372)
* chore: cleanup run-android implementation

* feat: overhaul gradle install errors

* fix copying executables by bringing back chmod

* rename 'installDebug' -> 'task'

* cleanup unused args from refactor

* use inherit and don't show null error

* simplify creating gradle args

* adjust descriptions

* use logger

* Add support for multiple tasks

* Change function name to match current functionality

* Change task to tasks
2019-05-10 15:19:52 +02:00
Janic Duplessis c3ed10c0e2 Use require.resolve to resolve package path (#378)
* Use `require.resolve` to resolve package path

* resolveNodeModule -> resolveNodeModuleDir
2019-05-08 23:38:37 +02:00
Ville Immonen 809aef93f2 fix: reporter config option (#370)
The `loadConfig` function in `metro-config` reads the `reporter` option
from the second argument (`defaultConfigOverrides`) instead of the
first argument (`argv`), so we need to pass it in that object to
make the `customLogReporterPath` CLI option work.
2019-05-06 20:14:40 +02:00
Michał Pierzchała 8ba322ebba fix: refactor init for less duplication; fix handling versioned templates (#364)
* chore: refactor init for less duplication

* fix handling versioned packages

* polish error messages a bit

* support npm tags
2019-05-06 16:30:05 +02:00
Michał Pierzchała c7fe3a33ce feat: copy all files in init through streams (#363)
* feat: copy all files in init through streams

* fix asynchrony

* only replace file if necessary
2019-04-30 18:01:21 +02:00
Michał Pierzchała 93e3eb6873 feat: init from tarball (#362)
* feat: init from tarball

* adjust error message

* skip flaky config test

* update docs

* update snapshots
2019-04-29 11:37:17 +02:00
Michał Pierzchała 267d3680d7 fix: init from url (#361) 2019-04-29 10:58:28 +02:00
Kacper Wiszczuk dbe2fd867f feat(breaking): remove legacy library command (#358)
feat(breaking): remove legacy `library` command
2019-04-26 15:19:03 +02:00
Michał Pierzchała 483003e5d6 v2.0.0-alpha.17 2019-04-25 16:17:49 +02:00
Kacper Wiszczuk afa9680253 feat: improve copying binary files in init (#353) 2019-04-24 20:33:31 +02:00
Pavlos Vinieratos 53d8f78719 chore: change upgrade to use new diff files approach (#348)
* use diff files and dont rely on gh

* lint

* update snapshots

* update link to diff table
2019-04-24 10:56:31 +02:00
Mike Grabowski 477ecc9bdf fix: ignore undefined when renaming 2019-04-23 23:18:22 +02:00
Mike Grabowski 58b9143fc3 v2.0.0-alpha.15 2019-04-23 23:04:02 +02:00
Kacper Wiszczuk 86986a1c2e docs: add init documentation (#347)
* docs: add init documentation

* docs: add mentions in other files

* docs: revert

* Update docs/init.md

Co-Authored-By: Esemesek <[email protected]>
2019-04-23 19:54:31 +02:00
Mike Grabowski bca56c9f3c docs: initial documentation of plugins (#345)
* fix: typos in Autolinking & use same repo for both examples

* structure new files

* Add documentation for plugins and update naming in one place

* Update index.js

* Fix flow and update docs

* Update

* Prefix

* Updates

* Take advantage of Joi

* Update docs/plugins.md

Co-Authored-By: grabbou <[email protected]>

* Update docs/plugins.md

Co-Authored-By: grabbou <[email protected]>

* Some other tweaks

* Placeholder for dependency

* Updates

* Delete linking.md

* fix tests
2019-04-23 19:41:42 +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
Michał Pierzchała 513d27bd4c v2.0.0-alpha.14 2019-04-20 11:50:31 +02:00
Michał Pierzchała 827daa4c16 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
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 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 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 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 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 2019-04-18 16:32:28 +02:00
Michał Pierzchała 60606efd56 v2.0.0-alpha.7 2019-04-17 22:20:33 +02:00
Eloy Durán 76f079ee8a feat: autolink on iOS 2019-04-16 22:54:46 +02:00
Brent Vatne fb94fef712 Add support for assetPlugins argument to start command (#318)
* Add support for assetPlugins argument to start command

* Add assetPlugins arg type
2019-04-16 22:31:44 +02:00