From 753eaa64379e0f143ac116fb65a22dbf4762b122 Mon Sep 17 00:00:00 2001 From: co2-git Date: Sun, 15 Apr 2018 13:25:31 +0100 Subject: [PATCH] Fix #16 --- .flowconfig | 3 + app/App.js | 6 +- app/components/Base/Animated.js | 3 +- app/components/Base/Animated.js.flow | 8 +++ app/components/FlexBox/Flex.js | 5 +- app/components/FlexBox/Flex.js.flow | 8 +++ app/components/Layout/Init.js | 2 +- app/components/Layout/Page.js | 1 + app/components/Terminal/Console.js | 30 +++----- app/components/Terminal/Runner.js | 71 ------------------- app/helpers/fsHelpers.js | 26 +++---- app/helpers/projectsHelpers.js | 13 ---- app/lib/exec.js | 10 ++- app/lib/exec.js.flow | 5 ++ app/redux/actions/infoActions.js | 13 ++-- app/redux/actions/initActions.js | 17 ----- app/redux/reducers.js | 5 -- app/redux/reducers/appsReducer.js | 9 --- app/redux/reducers/baseReducer.js | 7 -- app/redux/reducers/main.js | 15 ---- app/redux/reducers/metroOptionsReducer.js | 13 ---- app/redux/reducers/metroOutputReducer.js | 11 --- app/redux/reducers/metroStatusReducer.js | 21 ------ app/redux/reducers/projectsReducer.js | 7 -- app/redux/reducers/selectedReducer.js | 17 ----- app/redux/types.js | 25 ------- app/styles/main.js | 11 +++ .../redux => draft}/actions/androidActions.js | 2 - {app/redux => draft}/actions/bundleActions.js | 4 +- {app/redux => draft}/actions/iOSActions.js | 0 {app/redux => draft}/actions/metroActions.js | 10 +-- .../actions/terminalActions.js | 0 {app => draft}/components/Android/Home.js | 0 {app => draft}/components/Android/Log.js | 0 {app => draft}/components/Android/Run.js | 0 .../components/Android/RunSettings.js | 0 {app => draft}/components/Bundle.js | 4 +- {app => draft}/components/Command/Init.js | 0 {app => draft}/components/Command/Start.js | 0 .../components}/Config.js | 0 {app => draft}/components/Expo/Eject.js | 0 .../components/Expo/EjectSettings.js | 0 {app => draft}/components/Expo/Home.js | 0 .../ReactNative => draft/components}/Home.js | 0 {app => draft}/components/IOS/Home.js | 0 {app => draft}/components/IOS/Log.js | 0 {app => draft}/components/IOS/Run.js | 0 {app => draft}/components/IOS/RunSettings.js | 0 .../components/NativeModules/Home.js | 0 .../components/NativeModules/Install.js | 0 .../NativeModules/InstallSettings.js | 0 .../components/NativeModules/Link.js | 0 .../components/NativeModules/NewLibrary.js | 0 .../components/NativeModules/Uninstall.js | 0 .../components/NativeModules/Unlink.js | 0 {app => draft}/components/Packager/Home.js | 0 .../components/Packager/PackagerSettings.js | 0 {app => draft}/components/Packager/Start.js | 0 {app => draft}/components/Unbundle.js | 0 .../components}/Upgrade.js | 0 package.json | 4 +- 61 files changed, 91 insertions(+), 295 deletions(-) create mode 100644 app/components/Base/Animated.js.flow create mode 100644 app/components/FlexBox/Flex.js.flow delete mode 100644 app/components/Terminal/Runner.js delete mode 100644 app/helpers/projectsHelpers.js create mode 100644 app/lib/exec.js.flow delete mode 100644 app/redux/actions/initActions.js delete mode 100644 app/redux/reducers/baseReducer.js delete mode 100644 app/redux/reducers/main.js delete mode 100644 app/redux/reducers/metroOptionsReducer.js delete mode 100644 app/redux/reducers/metroOutputReducer.js delete mode 100644 app/redux/reducers/metroStatusReducer.js delete mode 100644 app/redux/reducers/projectsReducer.js delete mode 100644 app/redux/reducers/selectedReducer.js rename {app/redux => draft}/actions/androidActions.js (95%) rename {app/redux => draft}/actions/bundleActions.js (92%) rename {app/redux => draft}/actions/iOSActions.js (100%) rename {app/redux => draft}/actions/metroActions.js (92%) rename {app/redux => draft}/actions/terminalActions.js (100%) rename {app => draft}/components/Android/Home.js (100%) rename {app => draft}/components/Android/Log.js (100%) rename {app => draft}/components/Android/Run.js (100%) rename {app => draft}/components/Android/RunSettings.js (100%) rename {app => draft}/components/Bundle.js (97%) rename {app => draft}/components/Command/Init.js (100%) rename {app => draft}/components/Command/Start.js (100%) rename {app/components/ReactNative => draft/components}/Config.js (100%) rename {app => draft}/components/Expo/Eject.js (100%) rename {app => draft}/components/Expo/EjectSettings.js (100%) rename {app => draft}/components/Expo/Home.js (100%) rename {app/components/ReactNative => draft/components}/Home.js (100%) rename {app => draft}/components/IOS/Home.js (100%) rename {app => draft}/components/IOS/Log.js (100%) rename {app => draft}/components/IOS/Run.js (100%) rename {app => draft}/components/IOS/RunSettings.js (100%) rename {app => draft}/components/NativeModules/Home.js (100%) rename {app => draft}/components/NativeModules/Install.js (100%) rename {app => draft}/components/NativeModules/InstallSettings.js (100%) rename {app => draft}/components/NativeModules/Link.js (100%) rename {app => draft}/components/NativeModules/NewLibrary.js (100%) rename {app => draft}/components/NativeModules/Uninstall.js (100%) rename {app => draft}/components/NativeModules/Unlink.js (100%) rename {app => draft}/components/Packager/Home.js (100%) rename {app => draft}/components/Packager/PackagerSettings.js (100%) rename {app => draft}/components/Packager/Start.js (100%) rename {app => draft}/components/Unbundle.js (100%) rename {app/components/ReactNative => draft/components}/Upgrade.js (100%) diff --git a/.flowconfig b/.flowconfig index 25e46b0..cca52e8 100644 --- a/.flowconfig +++ b/.flowconfig @@ -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 @@ -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 diff --git a/app/App.js b/app/App.js index e1b9643..2f37956 100644 --- a/app/App.js +++ b/app/App.js @@ -12,9 +12,13 @@ const Loading = () => (
Loading
); +const persistor = persistStore(store); + +// persistor.purge(); + const App = () => ( - } persistor={persistStore(store)}> + } persistor={persistor}> diff --git a/app/components/Base/Animated.js b/app/components/Base/Animated.js index f6ffe4e..b7c2241 100644 --- a/app/components/Base/Animated.js +++ b/app/components/Base/Animated.js @@ -1,3 +1,4 @@ +// @flow import React from 'react'; import omit from 'lodash/omit'; @@ -80,7 +81,7 @@ const effects = [ 'slideOutUp', ]; -const Animated = (props) => { +const Animated = (props: $AnimatedProps) => { const names = ['animated']; const remove = []; for (const effect of effects) { diff --git a/app/components/Base/Animated.js.flow b/app/components/Base/Animated.js.flow new file mode 100644 index 0000000..5fb71db --- /dev/null +++ b/app/components/Base/Animated.js.flow @@ -0,0 +1,8 @@ +// @flow + +declare type $AnimatedReactProps = { + +children?: any, +}; + +declare type $AnimatedProps = + & $AnimatedReactProps; diff --git a/app/components/FlexBox/Flex.js b/app/components/FlexBox/Flex.js index a70e150..9112901 100644 --- a/app/components/FlexBox/Flex.js +++ b/app/components/FlexBox/Flex.js @@ -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'}; diff --git a/app/components/FlexBox/Flex.js.flow b/app/components/FlexBox/Flex.js.flow new file mode 100644 index 0000000..bea969f --- /dev/null +++ b/app/components/FlexBox/Flex.js.flow @@ -0,0 +1,8 @@ +// @flow + +declare type $FlexReactProps = { + children: any, +}; + +declare type $FlexProps = + & $FlexReactProps; diff --git a/app/components/Layout/Init.js b/app/components/Layout/Init.js index ce3d16f..b24eef3 100644 --- a/app/components/Layout/Init.js +++ b/app/components/Layout/Init.js @@ -67,7 +67,7 @@ class Init extends PureComponent<$InitProps, $InitState> { }; onToggle = ( event: SyntheticInputEvent, - isInputChecked: boolean + isInputChecked: boolean, ) => this.setState({expo: isInputChecked}); onChangeName = (event: SyntheticInputEvent) => this.setState({ name: event.target.value, diff --git a/app/components/Layout/Page.js b/app/components/Layout/Page.js index b687308..05af5db 100644 --- a/app/components/Layout/Page.js +++ b/app/components/Layout/Page.js @@ -1,3 +1,4 @@ +// @flow import React from 'react'; import {pageStyle} from '../../styles/main'; diff --git a/app/components/Terminal/Console.js b/app/components/Terminal/Console.js index bb0b8bb..cff2441 100644 --- a/app/components/Terminal/Console.js +++ b/app/components/Terminal/Console.js @@ -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'; @@ -96,7 +97,7 @@ class Terminal extends PureComponent<$TerminalProps, $TerminalState> { {this.props.cwd} -
+
{map(this.state.output, (output, index) => { const lines = stripAnsi(output.message).split('\n'); return ( @@ -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, - }, -}; diff --git a/app/components/Terminal/Runner.js b/app/components/Terminal/Runner.js deleted file mode 100644 index 8864017..0000000 --- a/app/components/Terminal/Runner.js +++ /dev/null @@ -1,71 +0,0 @@ -import {Card, CardActions, CardHeader, CardMedia, CardTitle, CardText} from 'material-ui/Card'; -import {Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarTitle} from 'material-ui/Toolbar'; -import DropDownMenu from 'material-ui/DropDownMenu'; -import FlatButton from 'material-ui/FlatButton'; -import MenuItem from 'material-ui/MenuItem'; -import PlayIcon from 'material-ui/svg-icons/av/play-arrow'; -import RaisedButton from 'material-ui/RaisedButton'; -import React, {PureComponent} from 'react'; -import StopIcon from 'material-ui/svg-icons/av/stop'; -import {Tabs, Tab} from 'material-ui/Tabs'; -import {Column, Row} from 'reactors-flex'; -import {blueGrey500, lightBlue900} from 'material-ui/styles/colors'; -import Router from 'reactors-router'; -import {Dimensions} from 'reactors'; - -import Terminal from './Console'; - -const Foo = () => ( -
- -
- {this.props.buttonComponent} -
- this.setState({tab}, () => { - Router.get(`${this.props.app.path}-packager-start`).go(tab); - })} - > - - - -
- - - {this.props.app.settingsComponent} - - - {this.props.app.settingsComponent} - - -
-); - -class Start extends PureComponent { - state = {tab: 'Settings'}; - render = () => ( -
- - - - {this.props.app.settingsComponent} - - - {this.props.buttonComponent} - - -
- ); -} - -export default Start; diff --git a/app/helpers/fsHelpers.js b/app/helpers/fsHelpers.js index ebcefae..e7366b6 100644 --- a/app/helpers/fsHelpers.js +++ b/app/helpers/fsHelpers.js @@ -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'; @@ -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', () => { @@ -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); - } -}); + }); diff --git a/app/helpers/projectsHelpers.js b/app/helpers/projectsHelpers.js deleted file mode 100644 index 7412bb3..0000000 --- a/app/helpers/projectsHelpers.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import {Column, Row} from 'reactors-flex'; -import {Text} from 'reactors'; - -export const printAppName = (dir) => { - const [name, base] = dir.split(/\//).reverse(); - return ( - - {base}/ - {name} - - ); -}; diff --git a/app/lib/exec.js b/app/lib/exec.js index ac691ec..84f45c1 100644 --- a/app/lib/exec.js +++ b/app/lib/exec.js @@ -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 @@ -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; diff --git a/app/lib/exec.js.flow b/app/lib/exec.js.flow new file mode 100644 index 0000000..ba2d442 --- /dev/null +++ b/app/lib/exec.js.flow @@ -0,0 +1,5 @@ +// @flow + +declare type $ExecOptions = { + cwd?: string, +}; diff --git a/app/redux/actions/infoActions.js b/app/redux/actions/infoActions.js index a7ea34e..1185aa4 100644 --- a/app/redux/actions/infoActions.js +++ b/app/redux/actions/infoActions.js @@ -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}, @@ -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(); @@ -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}}, diff --git a/app/redux/actions/initActions.js b/app/redux/actions/initActions.js deleted file mode 100644 index d517c44..0000000 --- a/app/redux/actions/initActions.js +++ /dev/null @@ -1,17 +0,0 @@ -import path from 'path'; - -import * as types from '../types'; -import store from '../store'; -import exec from '../../lib/exec'; - -export const init = async (app) => { - try { - const dirname = path.dirname(app.path); - const name = path.basename(app.path); - const ps = exec(`react-native init ${name}`, {cwd: dirname}); - ps.on('error', error => store.dispatch({type: types.ERROR, payload: {error}})); - ps.on('data', data => store.dispatch({type: types.INIT_OUTPUT, payload: {data, app}})); - } catch (error) { - store.dispatch({type: types.ERROR, payload: {error}}); - } -}; diff --git a/app/redux/reducers.js b/app/redux/reducers.js index 29789ac..cd38d25 100644 --- a/app/redux/reducers.js +++ b/app/redux/reducers.js @@ -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'; diff --git a/app/redux/reducers/appsReducer.js b/app/redux/reducers/appsReducer.js index 8a78996..8e17c00 100644 --- a/app/redux/reducers/appsReducer.js +++ b/app/redux/reducers/appsReducer.js @@ -1,6 +1,5 @@ import uniqBy from 'lodash/uniqBy'; import reject from 'lodash/reject'; -import map from 'lodash/map'; import * as types from '../types'; @@ -13,14 +12,6 @@ const reducer = (state = initialState, action) => { if (action.type === types.CLOSE_APP) { return reject(state, {path: action.payload.app.path}); } - if (action.type === types.APP_HAS_PACKAGE) { - return map(state, app => { - if (app.path === action.payload.path) { - app.hasPackage = action.payload.hasPackage; - } - return app; - }); - } return state; }; diff --git a/app/redux/reducers/baseReducer.js b/app/redux/reducers/baseReducer.js deleted file mode 100644 index aaccdc5..0000000 --- a/app/redux/reducers/baseReducer.js +++ /dev/null @@ -1,7 +0,0 @@ -const initialState = ''; - -const reducer = (state = initialState, action) => { - return state; -}; - -export default reducer; diff --git a/app/redux/reducers/main.js b/app/redux/reducers/main.js deleted file mode 100644 index 5d4fe53..0000000 --- a/app/redux/reducers/main.js +++ /dev/null @@ -1,15 +0,0 @@ -import * as types from '../types'; - -const initialState = { - dir: process.cwd(), -}; - -const mainReducer = (state = initialState, action) => { - const nextState = {...state}; - if (action.type === types.CHANGE_DIR) { - nextState.dir = action.payload.dir; - } - return nextState; -}; - -export default mainReducer; diff --git a/app/redux/reducers/metroOptionsReducer.js b/app/redux/reducers/metroOptionsReducer.js deleted file mode 100644 index 2eb8dec..0000000 --- a/app/redux/reducers/metroOptionsReducer.js +++ /dev/null @@ -1,13 +0,0 @@ -import * as types from '../types'; - -const initialState = { - port: 8081, -}; -const metroOptionsReducer = (state = initialState, action) => { - const nextState = {...state}; - if (action.type === types.CHANGE_METRO_PORT) { - nextState.port = action.payload.port; - } - return nextState; -}; -export default metroOptionsReducer; diff --git a/app/redux/reducers/metroOutputReducer.js b/app/redux/reducers/metroOutputReducer.js deleted file mode 100644 index aacacd6..0000000 --- a/app/redux/reducers/metroOutputReducer.js +++ /dev/null @@ -1,11 +0,0 @@ -import * as types from '../types'; - -const initialState = []; -const metroOutputReducer = (state = initialState, action) => { - const nextState = [...state]; - if (action.type === types.METRO_OUTPUT) { - nextState.push(action.payload.data); - } - return nextState; -}; -export default metroOutputReducer; diff --git a/app/redux/reducers/metroStatusReducer.js b/app/redux/reducers/metroStatusReducer.js deleted file mode 100644 index 15795bc..0000000 --- a/app/redux/reducers/metroStatusReducer.js +++ /dev/null @@ -1,21 +0,0 @@ -import find from 'lodash/find'; -import filter from 'lodash/filter'; -import * as types from '../types'; - -const initialState = {}; - -const metroStatusReducer = (state = initialState, action) => { - if (action.type === types.START_METRO) { - return { - ...state, - [action.payload.app.path]: { - code: null, - on: true, - pid: null, - }, - }; - } - return state; -}; - -export default metroStatusReducer; diff --git a/app/redux/reducers/projectsReducer.js b/app/redux/reducers/projectsReducer.js deleted file mode 100644 index a8c3dc6..0000000 --- a/app/redux/reducers/projectsReducer.js +++ /dev/null @@ -1,7 +0,0 @@ -const initialState = {}; - -const reducer = (state = initialState, action) => { - return state; -}; - -export default reducer; diff --git a/app/redux/reducers/selectedReducer.js b/app/redux/reducers/selectedReducer.js deleted file mode 100644 index 152b2d6..0000000 --- a/app/redux/reducers/selectedReducer.js +++ /dev/null @@ -1,17 +0,0 @@ -import * as types from '../types'; - -const initialState = { - app: null, -}; - -const reducer = (state = initialState, action) => { - if (action.type === types.SELECT_APP) { - return {...state, app: action.payload.path}; - } - if (action.type === types.CLOSE_APP && action.payload.app.path === state.app) { - return {...state, app: null}; - } - return state; -}; - -export default reducer; diff --git a/app/redux/types.js b/app/redux/types.js index b0b1040..d28b037 100644 --- a/app/redux/types.js +++ b/app/redux/types.js @@ -9,33 +9,8 @@ export const SWITCH_ROUTE = 'RNRX/ROUTER/SWITCH'; // APPS export const OPEN_APP = 'RNRX/APPS/OPEN'; -export const SELECT_APP = 'RNRX/APPS/SELECT'; export const CLOSE_APP = 'RNRX/APPS/CLOSE'; -export const APP_HAS_PACKAGE = 'RNRX/APPS/HAS_PACKAGE'; - -// METRO -export const START_METRO = 'RNRX/METRO/START'; -export const METRO_DOWN = 'RNRX/METRO/DOWN'; -export const METRO_OUTPUT = 'RNRX/METRO/OUTPUT'; -export const METRO_PID = 'RNRX/METRO/PID'; -export const CHANGE_METRO_PORT = 'RNRX/METRO/CHANGE_PORT'; - -// INIT -export const INIT_OUTPUT = 'RNRX/INIT/OUTPUT'; // INFO -export const GET_INFO = 'RNRX/INFO/GET'; export const GOT_INFO = 'RNRX/INFO/GOT'; export const FAILED_GETTING_INFO = 'RNRX/INFO/FAILED'; - -// RUN ANDROID -export const RUN_ANDROID = 'RNRX/ANDROID/RUN/RUNNING'; -export const FAILED_RUNNING_ANDROID = 'RNRX/ANDROID/RUN/FAILED'; -export const STOP_ANDROID = 'RNRX/ANDROID/STOP/STOPPING'; -export const FAILED_STOPPING_ANDROID = 'RNRX/ANDROID/STOP/FAILED'; - -// RUN IOS -export const RUN_IOS = 'RNRX/IOS/RUN/RUNNING'; -export const FAILED_RUNNING_IOS = 'RNRX/IOS/RUN/FAILED'; -export const STOP_IOS = 'RNRX/IOS/STOP/STOPPING'; -export const FAILED_STOPPING_IOS = 'RNRX/IOS/STOP/FAILED'; diff --git a/app/styles/main.js b/app/styles/main.js index 02f8076..331ecfe 100644 --- a/app/styles/main.js +++ b/app/styles/main.js @@ -4,3 +4,14 @@ export const pageStyle = { overflow: 'auto', width: '100vw', }; + +export const consoleStyle = { + 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, +}; diff --git a/app/redux/actions/androidActions.js b/draft/actions/androidActions.js similarity index 95% rename from app/redux/actions/androidActions.js rename to draft/actions/androidActions.js index 3d7acf9..ee3be14 100644 --- a/app/redux/actions/androidActions.js +++ b/draft/actions/androidActions.js @@ -1,8 +1,6 @@ import * as types from '../types'; import store from '../store'; -import exec from '../../lib/exec'; - export const run = async (app) => { const onError = (error) => { store.dispatch({ diff --git a/app/redux/actions/bundleActions.js b/draft/actions/bundleActions.js similarity index 92% rename from app/redux/actions/bundleActions.js rename to draft/actions/bundleActions.js index 9365292..a151d5d 100644 --- a/app/redux/actions/bundleActions.js +++ b/draft/actions/bundleActions.js @@ -11,8 +11,8 @@ export const bundleRequest = (options = {}) => { `--bundle-output ${options.bundleOutput}`, ]; const bundle = exec(`node ${cli} bundle ${args.join(' ')}`, {cwd: state.main.dir}); - bundle.on('error', error => { - console.log(error) + bundle.on('error', (error) => { + console.log(error); }); bundle.on('failed', status => store.dispatch({type: types.BUNDLE_FAILED, payload: {status}})); bundle.on('data', data => store.dispatch({type: types.BUNDLE_OUTPUT, payload: {data}})); diff --git a/app/redux/actions/iOSActions.js b/draft/actions/iOSActions.js similarity index 100% rename from app/redux/actions/iOSActions.js rename to draft/actions/iOSActions.js diff --git a/app/redux/actions/metroActions.js b/draft/actions/metroActions.js similarity index 92% rename from app/redux/actions/metroActions.js rename to draft/actions/metroActions.js index d8d058e..3caed27 100644 --- a/app/redux/actions/metroActions.js +++ b/draft/actions/metroActions.js @@ -8,8 +8,8 @@ export const startMetroRequest = ({port = 8081, app}) => { exec(`adb reverse tcp:${port} tcp:${port}`); const {path: dir} = app; const metro = exec(`node ${cli} start --port ${port}`, {cwd: dir}); - metro.on('error', error => { - console.log(error) + metro.on('error', (error) => { + console.log(error); }); metro.on('failed', status => store.dispatch({type: types.METRO_DOWN, payload: {status}})); metro.on('data', data => store.dispatch({type: types.METRO_OUTPUT, payload: {data}})); @@ -18,16 +18,16 @@ export const startMetroRequest = ({port = 8081, app}) => { export const changePort = (port) => { store.dispatch({type: types.CHANGE_METRO_PORT, payload: {port}}); -} +}; export const stopMetroRequest = () => { const {metroStatus} = store.getState(); if (metroStatus.state === 'started' && metroStatus.pid) { - store.dispatch({type: types.METRO_OUTPUT, payload: {data: {message: '!! RECEIVED KILL SIGNAL !!'}}}) + store.dispatch({type: types.METRO_OUTPUT, payload: {data: {message: '!! RECEIVED KILL SIGNAL !!'}}}); exec(`kill -9 ${metroStatus.pid}`) .on('done', () => store.dispatch({type: types.METRO_DOWN, payload: {status: 'KILLED'}})); } -} +}; export const start = async (app) => { try { diff --git a/app/redux/actions/terminalActions.js b/draft/actions/terminalActions.js similarity index 100% rename from app/redux/actions/terminalActions.js rename to draft/actions/terminalActions.js diff --git a/app/components/Android/Home.js b/draft/components/Android/Home.js similarity index 100% rename from app/components/Android/Home.js rename to draft/components/Android/Home.js diff --git a/app/components/Android/Log.js b/draft/components/Android/Log.js similarity index 100% rename from app/components/Android/Log.js rename to draft/components/Android/Log.js diff --git a/app/components/Android/Run.js b/draft/components/Android/Run.js similarity index 100% rename from app/components/Android/Run.js rename to draft/components/Android/Run.js diff --git a/app/components/Android/RunSettings.js b/draft/components/Android/RunSettings.js similarity index 100% rename from app/components/Android/RunSettings.js rename to draft/components/Android/RunSettings.js diff --git a/app/components/Bundle.js b/draft/components/Bundle.js similarity index 97% rename from app/components/Bundle.js rename to draft/components/Bundle.js index d181cd1..1f86eb6 100644 --- a/app/components/Bundle.js +++ b/draft/components/Bundle.js @@ -120,9 +120,7 @@ class Bundle extends PureComponent { ); } -const selector = state => { - return {bundle: state.bundle}; -} +const selector = state => ({bundle: state.bundle}); export default connect(selector)(Bundle); diff --git a/app/components/Command/Init.js b/draft/components/Command/Init.js similarity index 100% rename from app/components/Command/Init.js rename to draft/components/Command/Init.js diff --git a/app/components/Command/Start.js b/draft/components/Command/Start.js similarity index 100% rename from app/components/Command/Start.js rename to draft/components/Command/Start.js diff --git a/app/components/ReactNative/Config.js b/draft/components/Config.js similarity index 100% rename from app/components/ReactNative/Config.js rename to draft/components/Config.js diff --git a/app/components/Expo/Eject.js b/draft/components/Expo/Eject.js similarity index 100% rename from app/components/Expo/Eject.js rename to draft/components/Expo/Eject.js diff --git a/app/components/Expo/EjectSettings.js b/draft/components/Expo/EjectSettings.js similarity index 100% rename from app/components/Expo/EjectSettings.js rename to draft/components/Expo/EjectSettings.js diff --git a/app/components/Expo/Home.js b/draft/components/Expo/Home.js similarity index 100% rename from app/components/Expo/Home.js rename to draft/components/Expo/Home.js diff --git a/app/components/ReactNative/Home.js b/draft/components/Home.js similarity index 100% rename from app/components/ReactNative/Home.js rename to draft/components/Home.js diff --git a/app/components/IOS/Home.js b/draft/components/IOS/Home.js similarity index 100% rename from app/components/IOS/Home.js rename to draft/components/IOS/Home.js diff --git a/app/components/IOS/Log.js b/draft/components/IOS/Log.js similarity index 100% rename from app/components/IOS/Log.js rename to draft/components/IOS/Log.js diff --git a/app/components/IOS/Run.js b/draft/components/IOS/Run.js similarity index 100% rename from app/components/IOS/Run.js rename to draft/components/IOS/Run.js diff --git a/app/components/IOS/RunSettings.js b/draft/components/IOS/RunSettings.js similarity index 100% rename from app/components/IOS/RunSettings.js rename to draft/components/IOS/RunSettings.js diff --git a/app/components/NativeModules/Home.js b/draft/components/NativeModules/Home.js similarity index 100% rename from app/components/NativeModules/Home.js rename to draft/components/NativeModules/Home.js diff --git a/app/components/NativeModules/Install.js b/draft/components/NativeModules/Install.js similarity index 100% rename from app/components/NativeModules/Install.js rename to draft/components/NativeModules/Install.js diff --git a/app/components/NativeModules/InstallSettings.js b/draft/components/NativeModules/InstallSettings.js similarity index 100% rename from app/components/NativeModules/InstallSettings.js rename to draft/components/NativeModules/InstallSettings.js diff --git a/app/components/NativeModules/Link.js b/draft/components/NativeModules/Link.js similarity index 100% rename from app/components/NativeModules/Link.js rename to draft/components/NativeModules/Link.js diff --git a/app/components/NativeModules/NewLibrary.js b/draft/components/NativeModules/NewLibrary.js similarity index 100% rename from app/components/NativeModules/NewLibrary.js rename to draft/components/NativeModules/NewLibrary.js diff --git a/app/components/NativeModules/Uninstall.js b/draft/components/NativeModules/Uninstall.js similarity index 100% rename from app/components/NativeModules/Uninstall.js rename to draft/components/NativeModules/Uninstall.js diff --git a/app/components/NativeModules/Unlink.js b/draft/components/NativeModules/Unlink.js similarity index 100% rename from app/components/NativeModules/Unlink.js rename to draft/components/NativeModules/Unlink.js diff --git a/app/components/Packager/Home.js b/draft/components/Packager/Home.js similarity index 100% rename from app/components/Packager/Home.js rename to draft/components/Packager/Home.js diff --git a/app/components/Packager/PackagerSettings.js b/draft/components/Packager/PackagerSettings.js similarity index 100% rename from app/components/Packager/PackagerSettings.js rename to draft/components/Packager/PackagerSettings.js diff --git a/app/components/Packager/Start.js b/draft/components/Packager/Start.js similarity index 100% rename from app/components/Packager/Start.js rename to draft/components/Packager/Start.js diff --git a/app/components/Unbundle.js b/draft/components/Unbundle.js similarity index 100% rename from app/components/Unbundle.js rename to draft/components/Unbundle.js diff --git a/app/components/ReactNative/Upgrade.js b/draft/components/Upgrade.js similarity index 100% rename from app/components/ReactNative/Upgrade.js rename to draft/components/Upgrade.js diff --git a/package.json b/package.json index 47bc1f5..8e866c5 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "build:osx": "yarn build darwin", "build:linux": "yarn build linux", "build:windows": "yarn build win32", - "build:all": "npm-run-parallel build:osx build:linux build:windows" + "build:all": "npm-run-parallel build:osx build:linux build:windows", + "eslint": "eslint app --fix", + "test": "yarn eslint" }, "dependencies": { "babel-polyfill": "^6.26.0",