Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
./flow/app.js.flow
./app/components/App/App.js.flow
./app/components/App/AppBar.js.flow
./app/components/Base/Animated.js.flow
./app/components/FlexBox/Flex.js.flow
./app/components/Layout/AppCard.js.flow
./app/components/Layout/Header.js.flow
./app/components/Layout/Home.js.flow
Expand All @@ -23,6 +25,7 @@
./app/components/Layout/Router.js.flow
./app/components/ReactNative/Info.js.flow
./app/components/Terminal/Console.js.flow
./app/lib/exec.js.flow

[options]
emoji=true
Expand Down
6 changes: 5 additions & 1 deletion app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ const Loading = () => (
<div>Loading</div>
);

const persistor = persistStore(store);

// persistor.purge();

const App = () => (
<Provider store={store}>
<PersistGate loading={<Loading />} persistor={persistStore(store)}>
<PersistGate loading={<Loading />} persistor={persistor}>
<Layout />
</PersistGate>
</Provider>
Expand Down
3 changes: 2 additions & 1 deletion app/components/Base/Animated.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import omit from 'lodash/omit';

Expand Down Expand Up @@ -80,7 +81,7 @@ const effects = [
'slideOutUp',
];

const Animated = (props) => {
const Animated = (props: $AnimatedProps) => {
const names = ['animated'];
const remove = [];
for (const effect of effects) {
Expand Down
8 changes: 8 additions & 0 deletions app/components/Base/Animated.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @flow

declare type $AnimatedReactProps = {
+children?: any,
};

declare type $AnimatedProps =
& $AnimatedReactProps;
5 changes: 1 addition & 4 deletions app/components/FlexBox/Flex.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// @flow
import React from 'react';

type $FlexProps = {
children: any,
};

const makeStyle = (props: $FlexProps) => {
const {style: propsStyle = {}} = props;
const style = {...propsStyle, display: 'flex', flexDirection: 'row'};
Expand Down
8 changes: 8 additions & 0 deletions app/components/FlexBox/Flex.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @flow

declare type $FlexReactProps = {
children: any,
};

declare type $FlexProps =
& $FlexReactProps;
2 changes: 1 addition & 1 deletion app/components/Layout/Init.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Init extends PureComponent<$InitProps, $InitState> {
};
onToggle = (
event: SyntheticInputEvent<HTMLInputElement>,
isInputChecked: boolean
isInputChecked: boolean,
) => this.setState({expo: isInputChecked});
onChangeName = (event: SyntheticInputEvent<HTMLInputElement>) => this.setState({
name: event.target.value,
Expand Down
1 change: 1 addition & 0 deletions app/components/Layout/Page.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React from 'react';

import {pageStyle} from '../../styles/main';
Expand Down
30 changes: 9 additions & 21 deletions app/components/Terminal/Console.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// @flow
import map from 'lodash/map';
import React, {PureComponent} from 'react';
import {Card, CardHeader, CardActions} from 'material-ui/Card';
import Chip from 'material-ui/Chip';
import {green800, redA700} from 'material-ui/styles/colors';
import Avatar from 'material-ui/Avatar';
import OpenFolderIcon from 'material-ui/svg-icons/file/folder-open';
import TermIcon from 'material-ui/svg-icons/action/code';
import stripAnsi from 'strip-ansi';
import Chip from 'material-ui/Chip';
import DoneIcon from 'material-ui/svg-icons/action/done';
import ErrorIcon from 'material-ui/svg-icons/alert/error';
import {green800, redA700} from 'material-ui/styles/colors';
import map from 'lodash/map';
import OpenFolderIcon from 'material-ui/svg-icons/file/folder-open';
import React, {PureComponent} from 'react';
import stripAnsi from 'strip-ansi';
import TermIcon from 'material-ui/svg-icons/action/code';

import {consoleStyle} from '../../styles/main';
import exec from '../../lib/exec';
import Row from '../FlexBox/Row';

Expand Down Expand Up @@ -96,7 +97,7 @@ class Terminal extends PureComponent<$TerminalProps, $TerminalState> {
{this.props.cwd}
</Chip>
</Row>
<div style={styles.console} id="terminal">
<div style={consoleStyle} id="terminal">
{map(this.state.output, (output, index) => {
const lines = stripAnsi(output.message).split('\n');
return (
Expand All @@ -113,16 +114,3 @@ class Terminal extends PureComponent<$TerminalProps, $TerminalState> {
}

export default Terminal;

const styles = {
console: {
backgroundColor: '#000',
borderRadius: 8,
boxShadow: '1px 1px 2px 2px rgba(0, 0, 0, 0.25)',
color: '#fff',
marginTop: 12,
maxHeight: 300,
overflow: 'auto',
padding: 10,
},
};
71 changes: 0 additions & 71 deletions app/components/Terminal/Runner.js

This file was deleted.

26 changes: 14 additions & 12 deletions app/helpers/fsHelpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs';
// eslint-disable-next-line import/no-unresolved, import/extensions
import {remote} from 'electron';
import first from 'lodash/first';

Expand All @@ -16,7 +17,7 @@ export const read = (file, options = {}) => new Promise((resolve, reject) => {
let source = '';
fs.createReadStream(file, options)
.on('error', reject)
.on('data', data => {
.on('data', (data) => {
source += data.toString();
})
.on('end', () => {
Expand All @@ -36,15 +37,16 @@ export const stat = dir => new Promise(async (resolve, reject) => {

const defaultProperties = ['openDirectory'];

export const pickFile = ({properties = defaultProperties} = {}) => new Promise(async (resolve, reject) => {
try {
let path;
const directories = await remote.dialog.showOpenDialog({properties});
if (directories) {
path = first(directories);
export const pickFile = ({properties = defaultProperties} = {}) =>
new Promise(async (resolve, reject) => {
try {
let path;
const directories = await remote.dialog.showOpenDialog({properties});
if (directories) {
path = first(directories);
}
resolve(path);
} catch (error) {
reject(error);
}
resolve(path);
} catch (error) {
reject(error);
}
});
});
13 changes: 0 additions & 13 deletions app/helpers/projectsHelpers.js

This file was deleted.

10 changes: 7 additions & 3 deletions app/lib/exec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// @flow
import {spawn} from 'child_process';
import Emitter from 'events';

const $spawn = (cmd, options = {}) => {
const $spawn = (cmd: string, options: $ExecOptions = {}) => {
const emitter = new Emitter();
let ps;
setTimeout(() => {
try {
const [entry, ...bits] = cmd.trim().split(/\s+/);
const ps = spawn(entry, bits, options);
ps = spawn(entry, bits, options);
let done = false;
emitter.emit('pid', ps.pid);
ps
Expand Down Expand Up @@ -42,7 +44,9 @@ const $spawn = (cmd, options = {}) => {
emitter.on('write', message => ps.stdin.write(message));
emitter.on('kill', () => $spawn(`kill -9 ${ps.pid}`));
} catch (error) {
console.log(error.stack);
if (emitter) {
emitter.emit('error', error);
}
}
});
return emitter;
Expand Down
5 changes: 5 additions & 0 deletions app/lib/exec.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow

declare type $ExecOptions = {
cwd?: string,
};
13 changes: 5 additions & 8 deletions app/redux/actions/infoActions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import * as types from '../types';
import store from '../store';
import stripAnsi from 'strip-ansi';
import compact from 'lodash/compact';
import stripAnsi from 'strip-ansi';

import * as types from '../types';
import exec from '../../lib/exec';
import store from '../store';

// eslint-disable-next-line import/prefer-default-export
export const getInfo = async (app) => {
try {
let data = '';
const ps = exec('react-native info', {cwd: app.path});
ps.on('error', error => {
ps.on('error', (error) => {
store.dispatch({
type: types.ERROR,
payload: {error},
Expand All @@ -28,20 +29,17 @@ export const getInfo = async (app) => {
.replace(/\n/g, ':NL:')
.replace(/^.+Environment:(.+)Packages:.+$/, '$1')
.replace(/:NL:/g, '\n');
console.log(environmentString);
const environment = {};
const lines = compact(environmentString.split(/\n/));
for (const line of lines) {
const [key, ...value] = line.trim().split(':');
environment[key] = value.join(':').trim();
}
console.log({environment});
const packagesString = stripped
.replace(/\n/g, ':NL:')
.replace(/^.+Packages:(.+)$/, '$1')
.replace(/:NL:/g, '\n')
.trim();
console.log(packagesString);
const packages = {};
const lines2 = compact(packagesString.split(/\n/));
lines2.shift();
Expand All @@ -50,7 +48,6 @@ export const getInfo = async (app) => {
const [wanted, installed] = value.join(':').split(' => ');
packages[key] = {wanted: wanted.trim(), installed: installed.trim()};
}
console.log({packages});
store.dispatch({
type: types.GOT_INFO,
payload: {app, info: {environment, packages}},
Expand Down
17 changes: 0 additions & 17 deletions app/redux/actions/initActions.js

This file was deleted.

5 changes: 0 additions & 5 deletions app/redux/reducers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// @flow
export {default as androidRunStatus} from './reducers/androidRunStatusReducer';
export {default as apps} from './reducers/appsReducer';
export {default as base} from './reducers/baseReducer';
export {default as error} from './reducers/errorReducer';
export {default as info} from './reducers/infoReducer';
export {default as iOSRunStatus} from './reducers/iOSRunStatusReducer';
export {default as metroOptions} from './reducers/metroOptionsReducer';
export {default as metroOutput} from './reducers/metroOutputReducer';
export {default as metroStatus} from './reducers/metroStatusReducer';
export {default as selected} from './reducers/selectedReducer';
export {default as routerIndex} from './reducers/routerIndexReducer';
Loading