Skip to content

Commit

Permalink
chore: revert to v1.1.0-alpha.6
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaclennan committed Jun 7, 2019
1 parent 9b3af7c commit b61e3a0
Show file tree
Hide file tree
Showing 33 changed files with 6,354 additions and 14,996 deletions.
72 changes: 51 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ storybook server.
## Initial Install

In order to start developing you will need git and node >=v8 installed on your
computer. For many development tasks you will also need the Android SDK
installed. Please use [yarn](https://yarnpkg.com/en/) to ensure that you get
deterministic builds and use the `yarn.lock` file.
computer. For many development tasks you will also need the Android SDK installed.

```sh
git clone https://github.com/digidem/mapeo-mobile.git
cd mapeo-mobile
yarn
npm install
```

## Storybook
Expand All @@ -25,21 +23,53 @@ yarn
components in isolation. You can see how a component renders with different
props as inputs, and changes you make to the code will update in realtime
through the storybook UI. What you see in the Storybook UI is defined by
"stories" which are in the [`src/stories`](src/stories) folder. You do not need
the Android SDK in order to develop with storybook. You can also run the
storybook app on an iOS (Apple) phone.
"stories" which are in the [`src/stories`](src/stories) folder.

To install and run the app in storybook mode on a device:
### Storybook Web

**_Storybook web is fragile, it currently requires some code modifications for
everything to work correctly on web_**

The easiest way to get started without setting up your machine for mobile
development is to use Storybook web. It uses
[`react-native-web`](https://github.com/necolas/react-native-web) interally in
order to render react-native components in a browser. Note that layout and
colors do not appear exactly the same in the browser, and you may need to add
some additional styles to get things looking right. To start the storybook web
server:

```sh
cd storybook
yarn
yarn start
npm run storybook-web
```

Your default browser should open with the Storybook interface. You can browse
different stories, and as you edit a component you will see your changes update
in real-time.

### Storybook Native

For a development environment that is closer to the actual app end-users will
see you can run storybook on a device or in the Android emulator. To install and
run the app in storybook mode on a device:

```sh
npm run android-storybook
```

You can edit components and write new stories and see how components on-screen
render in isolation.

Optionally you can also start a server that will give you a web interface to
control what you see on the mobile device:

```sh
adb reverse tcp:7007 tcp:7007
npm run storybook-native
```

You will probably need to reload the storybook mobile app for the web app to be
able to control the mobile app.

## Full App Development

### Pre-requisites
Expand Down Expand Up @@ -74,21 +104,21 @@ Connect your phone with USB, or start up the emulator, then build and run the
dev version of the app on your device:

```sh
yarn android
npm run android
```

You can configure the app to reload whenever you make a change: shake the device
to bring up the developer menu, and select "Enable Live Reload". Whenever you
change the code the app should reload. Changes to any code in the `src/frontend`
folder will appear immediately after a reload. If you change anything in
`src/backend` you will need to re-run `yarn android` in order to see changes.
If you are tired of shaking the phone you can enter `yarn dev-menu` from your
`src/backend` you will need to re-run `npm run android` in order to see changes.
If you are tired of shaking the phone you can enter `npm run dev-menu` from your
computer.

`yarn android` does two things: starts "Metro bundler" in one window, and
`npm run android` does two things: starts "Metro bundler" in one window, and
then builds and installs the dev version of Mapeo on the connected device. To
start Metro bundler on its own (e.g. if you already have the app installed), use
`yarn start`.
`npm start`.

## Release Variants

Expand Down Expand Up @@ -142,7 +172,7 @@ These builds are available at http://mapeo-apks.ddem.us/?prefix=dev/
To create an Alpha release:

```sh
yarn release:alpha
npm run release:alpha
git push --follow-tags origin master
```

Expand All @@ -156,7 +186,7 @@ for internal testing and can be unstable.
To create a Beta release:

```sh
yarn release:beta
npm run release:beta
git push --follow-tags origin master
```

Expand All @@ -176,7 +206,7 @@ updated for any users who have signed up to the open beta track: https://play.go
To create a Production release:

```sh
yarn release
npm run release
git push --follow-tags origin master
```

Expand All @@ -188,8 +218,8 @@ QA variant is created for production releases.

### `error: bundling failed: ReferenceError: Module not registered in graph`

If you see this error from the Metro Bundler it is most likely that you ran `yarn` and added modules when the Metro Bundler was already running (`yarn start`). Try quitting with bundler with `Ctrl-C` and then re-starting it with
`yarn start`. If that doesn't work also try restarting with a new cache with `yarn start --reset-cache`.
If you see this error from the Metro Bundler it is most likely that you ran `npm install` and added modules when the Metro Bundler was already running (`npm start`). Try quitting with bundler with `Ctrl-C` and then re-starting it with
`npm start`. If that doesn't work also try restarting with a new cache with `npm start --reset-cache`.

### `ENOSPC` Error in gradle build

Expand Down
24 changes: 18 additions & 6 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf', 'Octicons.ttf', 'MaterialCommunityIcons.ttf', 'FontAwesome.ttf' ]
]

apply from: "./react.gradle"
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
Expand Down Expand Up @@ -142,9 +146,21 @@ android {
dimension "version"
applicationIdSuffix ".qa"
versionNameSuffix "-qa"
buildConfigField "boolean", "isStorybook", "false"
}
storybook {
dimension "version"
applicationIdSuffix ".storybook"
// We use this config field in MainApplication.java to set the
// bundle name for loading different code for the storybook version
buildConfigField "boolean", "isStorybook", "true"
// This sets a custom entry file for the storybook version of the
// app. This requires a custom react.gradle see `./react.gradle`
ext.entryFile = "storybook-native/index.js"
}
app {
dimension "version"
buildConfigField "boolean", "isStorybook", "false"
}
}
buildTypes {
Expand All @@ -158,8 +174,9 @@ android {
// build with the default debug keystore
productFlavors.qa.signingConfig signingConfigs.release
productFlavors.app.signingConfig signingConfig
productFlavors.storybook.signingConfig signingConfig
signingConfig null
// QA flavors share the same applicationId between
// Storybook and QA flavors share the same applicationId between
// release and debug builds, but the main app flavor has a suffix
// for debug builds, so that when developing you can have the debug
// version and the release version on your phone at the same time
Expand Down Expand Up @@ -196,11 +213,6 @@ android {
}
}

apply from: "../../node_modules/react-native/react.gradle"
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"


dependencies {
implementation project(':react-native-share')
implementation project(':react-native-keep-awake')
Expand Down
25 changes: 25 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Needed for expo-core to work
-keepclassmembers class * {
@expo.core.interfaces.ExpoProp *;
}
-keepclassmembers class * {
@expo.core.interfaces.ExpoMethod *;
}
4 changes: 3 additions & 1 deletion android/app/src/main/java/com/mapeo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
public class MainActivity extends ReactFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this); // react-native-splash-screen
if (!BuildConfig.isStorybook) {
SplashScreen.show(this); // react-native-splash-screen
}
super.onCreate(savedInstanceState);
}

Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/java/com/mapeo/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected List<ReactPackage> getPackages() {

@Override
protected String getJSMainModuleName() {
return "index";
return BuildConfig.isStorybook ? "storybook-native/index" : "index";
}
};

Expand Down
3 changes: 3 additions & 0 deletions android/app/src/storybook/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Mapeo Design</string>
</resources>
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"android": "yarn build:backend && yarn android-no-backend-rebuild",
"android": "npm run build:backend && npm run android-no-backend-rebuild",
"android-no-backend-rebuild": "react-native run-android --variant=appDebug --appIdSuffix=debug",
"android-storybook": "react-native run-android --variant=storybookDebug --appIdSuffix=storybook.debug",
"build:backend": "./scripts/build-backend.sh",
"build:release": "yarn build:backend && ./scripts/build-release-android.sh",
"build:release": "npm run build:backend && ./scripts/build-release-android.sh",
"build:storybook": "./node_modules/@storybook/react/bin/build.js -c ./storybook-web -s ./public -o ./build --no-dll",
"test": "jest",
"lint": "eslint *.js \"src/**/*.js\"",
"flow": "flow",
Expand All @@ -18,7 +20,9 @@
"release": "standard-version",
"release:alpha": "standard-version --prerelease alpha",
"release:beta": "standard-version --prerelease beta",
"release-notes": "conventional-changelog -r 2 -p angular"
"release-notes": "conventional-changelog -r 2 -p angular",
"storybook-native": "./node_modules/@storybook/react-native-server/bin/index.js -p 7007 -c ./storybook-native",
"storybook-web": "./node_modules/@storybook/react/bin/index.js -c ./storybook-web -s ./public -p 5005 --ci"
},
"dependencies": {
"@react-native-community/async-storage": "^1.3.1",
Expand Down Expand Up @@ -63,6 +67,14 @@
"utm": "^1.1.1"
},
"devDependencies": {
"@storybook/addon-actions": "^5.1.0-rc.0",
"@storybook/addon-info": "^5.1.0-rc.0",
"@storybook/addon-links": "^5.1.0-rc.0",
"@storybook/addon-viewport": "^5.1.0-rc.0",
"@storybook/addons": "^5.1.0-rc.0",
"@storybook/react": "^5.1.0-rc.0",
"@storybook/react-native": "^5.1.0-rc.0",
"@storybook/react-native-server": "^5.1.0-rc.0",
"@turf/random": "^6.0.2",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ cp -r ./src/backend ./nodejs-assets
mv ./nodejs-assets/backend ./nodejs-assets/nodejs-project

echo "Installing dependencies..."
cd ./nodejs-assets/nodejs-project && yarn && cd ../..
cd ./nodejs-assets/nodejs-project && npm i && cd ../..

echo -en "Minifying with noderify..."
cd ./nodejs-assets/nodejs-project
"$(yarn bin)/noderify" \
"$(npm bin)/noderify" \
--replace.bindings=bindings-noderify-nodejs-mobile \
--filter=rn-bridge \
--filter=original-fs \
Expand Down
4 changes: 2 additions & 2 deletions scripts/deep-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ rm -rf node_modules/
./gradlew clean
./gradlew cleanBuildCache
)
yarn
yarn start --reset-cache
npm install
npm start -- --reset-cache
Loading

0 comments on commit b61e3a0

Please sign in to comment.