Skip to content

Commit 824e0fa

Browse files
authored
Merge pull request #70 from co2-git/v0.1.5
V0.1.5
2 parents b9ad441 + 1fab03a commit 824e0fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+8069
-279
lines changed

.circleci/config.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
branches:
9+
only:
10+
- master
11+
- develop
12+
- /^v\d+\.\d+\.\d+$/
13+
- /^version\/\d+\.\d+\.\d+$/
14+
docker:
15+
# specify the version you desire here
16+
- image: circleci/node:8.11
17+
18+
# Specify service dependencies here if necessary
19+
# CircleCI maintains a library of pre-built images
20+
# documented at https://circleci.com/docs/2.0/circleci-images/
21+
# - image: circleci/mongo:3.4.4
22+
23+
working_directory: ~/repo
24+
25+
steps:
26+
- checkout
27+
28+
# Download and cache dependencies
29+
- restore_cache:
30+
keys:
31+
- v1-dependencies-{{ checksum "package.json" }}
32+
# fallback to using the latest cache if no exact match is found
33+
- v1-dependencies-
34+
35+
- run: yarn install
36+
37+
- save_cache:
38+
paths:
39+
- node_modules
40+
key: v1-dependencies-{{ checksum "package.json" }}
41+
42+
# run tests!
43+
- run: yarn test

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
"object-curly-spacing": ["error", "never"],
1010
"no-restricted-syntax": 0,
1111
"guard-for-in": 0,
12+
"function-paren-newline": 0,
1213

1314
// Flow
1415
"flowtype/boolean-style": [
@@ -70,6 +71,7 @@ module.exports = {
7071
"extends": ["airbnb-base", "plugin:react/recommended"],
7172
"globals": {
7273
"document": true,
74+
"window": true,
7375
},
7476
"settings": {
7577
"flowtype": {

.flowconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,33 @@
1414

1515
[libs]
1616
./flow/app.js.flow
17+
./app/components/Android/APK.js.flow
18+
./app/components/Android/APKs.js.flow
1719
./app/components/Android/Home.js.flow
18-
./app/components/Android/Run.js.flow
19-
./app/components/Android/RunOptions.js.flow
2020
./app/components/App/App.js.flow
2121
./app/components/App/AppBar.js.flow
2222
./app/components/App/AppBottomBar.js.flow
2323
./app/components/Base/Animated.js.flow
2424
./app/components/Base/IconWithLabel.js.flow
2525
./app/components/FlexBox/Flex.js.flow
26+
./app/components/IOS/Home.js.flow
2627
./app/components/Layout/AppCard.js.flow
28+
./app/components/Layout/DrawerMenu.js.flow
2729
./app/components/Layout/Header.js.flow
2830
./app/components/Layout/Home.js.flow
2931
./app/components/Layout/Init.js.flow
3032
./app/components/Layout/Layout.js.flow
3133
./app/components/Layout/Open.js.flow
3234
./app/components/Layout/Page.js.flow
35+
./app/components/Layout/Route.js.flow
3336
./app/components/Layout/Router.js.flow
37+
./app/components/Platform/Home.js.flow
38+
./app/components/Platform/Logs.js.flow
39+
./app/components/Platform/Run.js.flow
40+
./app/components/Platform/RunOptions.js.flow
3441
./app/components/ReactNative/Info.js.flow
42+
./app/components/Router/XRoute.js.flow
43+
./app/components/Router/XRouter.js.flow
3544
./app/components/Terminal/Console.js.flow
3645

3746
[options]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 co2
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
ReactNative
22
===
33

4+
[![CircleCI](https://circleci.com/gh/co2-git/ReactNative.svg?style=shield)](https://circleci.com/gh/co2-git/ReactNative) [![GitHub version](https://badge.fury.io/gh/co2-git%2FReactNative.svg)](https://github.com/co2-git/ReactNative) [![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
5+
6+
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=francooisrv&url=https://github.com/co2-git/ReactNative&title=badges&language=&tags=github&category=software) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/co2-git/ReactNative/graphs/commit-activity) [![GitHub license](https://img.shields.io/github/license/co2-git/ReactNative.svg)](https://github.com/co2-git/ReactNative/blob/master/LICENSE)
7+
8+
[![Github Releases (by Release)](https://img.shields.io/github/downloads/co2-git/ReactNative/v0.1.4/total.svg)](https://GitHub.com/co2-git/ReactNative/releases/) [![GitHub contributors](https://img.shields.io/github/contributors/co2-git/ReactNative.svg)](https://GitHub.com/co2-git/ReactNative/graphs/contributors/)
9+
10+
[![GitHub stars](https://img.shields.io/github/stars/co2-git/ReactNative.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/co2-git/ReactNative/stargazers/) [![GitHub forks](https://img.shields.io/github/forks/co2-git/ReactNative.svg?style=social&label=Fork&maxAge=2592000)](https://github.com/co2-git/ReactNative/network/)
11+
12+
[![GitHub issues](https://img.shields.io/github/issues/co2-git/ReactNative.svg)](https://GitHub.com/co2-git/ReactNative/issues/) [![GitHub issues-closed](https://img.shields.io/github/issues-closed/co2-git/ReactNative.svg)](https://GitHub.com/co2-git/ReactNative/issues?q=is%3Aissue+is%3Aclosed) [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/Naereen/badges.svg)](http://isitmaintained.com/project/Naereen/badges "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/co2-git/badges.svg)](http://isitmaintained.com/project/co2-git/badges "Percentage of issues still open")
13+
14+
[![GitHub pull-requests](https://img.shields.io/github/issues-pr/co2-git/ReactNative.svg)](https://GitHub.com/co2-git/ReactNative/pull/) [![GitHub pull-requests closed](https://img.shields.io/github/issues-pr-closed/co2-git/ReactNative.svg)](https://GitHub.com/co2-git/ReactNative/pull/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
15+
===
16+
417
GUI client for React Native. It is built with electron so it works on Linux, Mac and Windows.
518

619
# Downloads

app/App.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
// @flow
12
import 'babel-polyfill';
23

34
import {PersistGate} from 'redux-persist/integration/react';
5+
import {persistStore} from 'redux-persist';
46
import {Provider} from 'react-redux';
57
import React from 'react';
6-
import {persistStore} from 'redux-persist';
78

89
import Layout from './components/Layout/Layout';
910
import store from './redux/store';
@@ -14,12 +15,10 @@ const Loading = () => (
1415

1516
const persistor = persistStore(store);
1617

17-
// persistor.purge();
18-
1918
const App = () => (
2019
<Provider store={store}>
2120
<PersistGate loading={<Loading />} persistor={persistor}>
22-
<Layout />
21+
<Layout persistor={persistor} />
2322
</PersistGate>
2423
</Provider>
2524
);

app/components/Android/APK.js

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// @flow
2+
import ActionAndroid from 'material-ui/svg-icons/action/android';
3+
import RemoveIcon from 'material-ui/svg-icons/navigation/more-vert';
4+
import CircularProgress from 'material-ui/CircularProgress';
5+
import RaisedButton from 'material-ui/RaisedButton';
6+
import React, {PureComponent} from 'react';
7+
import Subheader from 'material-ui/Subheader';
8+
import {Card, CardText, CardHeader, CardActions} from 'material-ui/Card';
9+
import path from 'path';
10+
11+
import {dragAPK} from '../../redux/actions/androidActions';
12+
import {roundUp} from '../../helpers/mathHelpers';
13+
import {dangerBackgroundColor, dangerColor} from '../../styles/vars/colors';
14+
import Terminal from '../Terminal/Console';
15+
16+
class APK extends PureComponent<$APKProps, $APKState> {
17+
state = {showTerminal: false, showFailMessage: false};
18+
render = () => (
19+
<Card style={{marginBottom: 12}}>
20+
<CardHeader
21+
title={this.props.title}
22+
subtitle={this.props.subtitle}
23+
/>
24+
<CardActions>
25+
{this.props.loading && (
26+
<CircularProgress />
27+
)}
28+
{!this.props.loading && !this.props.data && (
29+
<Subheader style={{color: dangerColor}}>No APK found</Subheader>
30+
)}
31+
{!this.props.loading && !this.props.data && (
32+
<div>
33+
<RaisedButton
34+
label="Look again"
35+
onClick={this.props.lookAgain}
36+
/>
37+
<RemoveIcon />
38+
<RaisedButton
39+
label="Generate APK"
40+
secondary
41+
onClick={() => {
42+
if (this.state.showTerminal) {
43+
this.setState({showTerminal: false, showFailMessage: false}, () => {
44+
setTimeout(() => this.setState({showTerminal: true}), 750);
45+
});
46+
} else {
47+
this.setState({showTerminal: true});
48+
}
49+
}}
50+
/>
51+
</div>
52+
)}
53+
{!this.props.loading && this.props.data && (
54+
<div>
55+
<span
56+
draggable
57+
onDragStart={() => {
58+
const {data} = this.props;
59+
if (data) {
60+
dragAPK(data.path);
61+
}
62+
}}
63+
>
64+
<RaisedButton
65+
label={`${this.props.title} (${roundUp(this.props.data.size)} MB)`}
66+
primary
67+
icon={<ActionAndroid />}
68+
/>
69+
</span>
70+
<RemoveIcon />
71+
<RaisedButton
72+
label="Generate APK"
73+
secondary
74+
onClick={this.props.lookAgain}
75+
/>
76+
</div>
77+
)}
78+
<CardText expandable>
79+
{this.state.showTerminal && (
80+
<div>
81+
{this.props.title === 'Release' && this.state.showFailMessage && (
82+
<div
83+
style={{
84+
padding: 12,
85+
color: dangerColor,
86+
fontWeight: 'bold',
87+
border: `2px solid ${dangerColor}`,
88+
borderRadius: 4,
89+
backgroundColor: dangerBackgroundColor,
90+
marginBottom: 12,
91+
}}
92+
>
93+
Build failed! Are you sure you read the <a
94+
href="https://facebook.github.io/react-native/docs/signed-apk-android.html"
95+
target="_blank"
96+
rel="noopener noreferrer"
97+
>doc</a>?
98+
</div>
99+
)}
100+
<Terminal
101+
command={`${
102+
path.join(this.props.app.path, 'android', 'gradlew')
103+
} assemble${this.props.title}`}
104+
cwd={path.join(this.props.app.path, 'android')}
105+
onDone={this.props.lookAgain}
106+
onFail={() => this.setState({showFailMessage: true})}
107+
/>
108+
</div>
109+
)}
110+
</CardText>
111+
</CardActions>
112+
</Card>
113+
);
114+
}
115+
116+
export default APK;

app/components/Android/APK.js.flow

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// @flow
2+
3+
declare type $APKVariant =
4+
| 'Debug'
5+
| 'Release'
6+
;
7+
8+
declare type $APKData = {|
9+
+path: string,
10+
+size: number,
11+
|};
12+
13+
declare type $APKOwnProps = {|
14+
+app: $App,
15+
+data: ?$APKData,
16+
+loading: boolean,
17+
+lookAgain: () => void,
18+
+subtitle: string,
19+
+title: $APKVariant,
20+
|};
21+
22+
declare type $APKProps =
23+
& $APKOwnProps
24+
;
25+
26+
declare type $APKState = {|
27+
showTerminal: boolean,
28+
showFailMessage: boolean,
29+
|};

app/components/Android/APKs.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// @flow
2+
import map from 'lodash/map';
3+
import React, {PureComponent} from 'react';
4+
5+
import {getAPK} from '../../redux/actions/androidActions';
6+
import {raiseError} from '../../redux/actions/errorsActions';
7+
import APK from './APK';
8+
9+
class APKs extends PureComponent<$APKsProps, $APKsState> {
10+
state = {
11+
debug: null,
12+
release: null,
13+
getDebug: false,
14+
getRelease: false,
15+
};
16+
componentDidMount = () => {
17+
this.getApks('debug', 'release');
18+
};
19+
render = () => (
20+
<div>
21+
<APK
22+
title="Debug"
23+
subtitle="APK with React Native developer tools"
24+
loading={this.state.getDebug}
25+
data={this.state.debug}
26+
lookAgain={() => {
27+
this.getApks('debug');
28+
}}
29+
app={this.props.app}
30+
/>
31+
<APK
32+
title="Release"
33+
subtitle="Play Store ready production APK"
34+
loading={this.state.getRelease}
35+
data={this.state.release}
36+
lookAgain={() => {
37+
this.getApks('release');
38+
}}
39+
app={this.props.app}
40+
/>
41+
</div>
42+
);
43+
getApks = async (...variants: Array<'debug' | 'release'>) => {
44+
try {
45+
const partial = {};
46+
variants.forEach((variant) => {
47+
if (variant === 'debug') {
48+
partial.getDebug = true;
49+
partial.debug = null;
50+
}
51+
});
52+
this.setState(partial);
53+
const results = await Promise.all(map(
54+
variants,
55+
variant => getAPK(this.props.app, variant),
56+
));
57+
const partial2 = {};
58+
variants.forEach((variant, index) => {
59+
if (variant === 'debug') {
60+
partial2.getDebug = false;
61+
partial2.debug = results[index];
62+
}
63+
});
64+
this.setState(partial2);
65+
} catch (error) {
66+
if (error.code !== 'ENOENT') {
67+
raiseError(error);
68+
}
69+
}
70+
}
71+
}
72+
73+
export default APKs;

0 commit comments

Comments
 (0)