Commit Graph
1362 Commits
Author SHA1 Message Date
Kacper Wiszczuk 558567ae02 Rename files to ts 2019-05-18 12:14:34 +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
Elliot Hesp 8a796051c0 chore: Update npm version badge link (#391) 2019-05-16 14:25:34 +02:00
Michał Pierzchała d3f3aca16f v2.0.0-alpha.20 v2.0.0-alpha.20 2019-05-15 17:21:57 +02:00
Michał Pierzchała 287fecfed8 chore: bump lerna to latest 2019-05-15 17:13:51 +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 7de5c3e172 fix: run "config" from react-native binary in autolinking scripts (#384)
* fix: run "config" from react-native binary

* use yarn run when necessary and fallback to accessing binary with Node

* filter out non-json stuff in gradle implementation

* use yarn --silent
2019-05-14 12:30:37 +02:00
Michał Pierzchała 6947ae2894 v2.0.0-alpha.19 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 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
Janic Duplessis 093ce51172 chore: Update prettier config (#379) 2019-05-08 21:15:48 +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
Mike Grabowski a851637bd8 docs: add maintainers section (#369)
* Add `maintainers` section

* Update README.md

* Polacy nie gęsi, swój język mają xd
2019-05-06 13:59:36 +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 v2.0.0-alpha.17 2019-04-25 16:17:49 +02:00
Orta c1a8ec8861 [ios] Ensure that the right cwd is set up for auto-linking dependencies (#354)
* [ios] Ensure that the right cwd is set up for auto-linking dependencies

* [autolink] Switch to DIing in the root path as a param in to use_native_modules

* [autolink] Docs for autolink root changes
2019-04-25 16:15:30 +02:00
Orta 9315f05de2 Update autolinking.md (#355) 2019-04-25 07:47:34 +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 89a1420f3d chore: update wording in docs 2019-04-23 23:22:34 +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 v2.0.0-alpha.15 2019-04-23 23:04:02 +02:00
Mike Grabowski 527d81dbab feat: add dependency and project documentation (#350)
* Add dependency documentation and links

* Update

* Update

* Add project desc

* Move notice above

* add catch-all doc

* Typo

* Rename the type

* Update docs/configuration.md

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

* Update docs/configuration.md

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

* Do where not when

* Plural
2019-04-23 22:58:59 +02:00
Mike Grabowski 34f7df2bfe feat: add platforms doc (#349)
* Add platforms doc

* Migration guide

* Update docs/platforms.md

Co-Authored-By: grabbou <[email protected]>
2019-04-23 21:02:13 +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
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