From 6501f5d48d153e2eee999cb7ee55e9ad246f672f Mon Sep 17 00:00:00 2001 From: Wyatt McBain Date: Fri, 3 Mar 2017 01:18:33 -0500 Subject: [PATCH 1/3] Begin TypeScript refactor, nav done --- .eslintrc | 111 ----- .vscode/settings.json | 6 + package.json | 16 +- src/redux/ducks/{config.js => config.tsx} | 2 +- .../ducks/{constants.js => constants.tsx} | 4 +- src/redux/ducks/{device.js => device.tsx} | 4 +- src/redux/ducks/{intl.js => intl.tsx} | 0 src/redux/ducks/nav.js | 67 --- src/redux/ducks/nav.tsx | 92 ++++ src/{types.js => types.tsx} | 0 src/types/actions.js | 23 - src/types/actions.tsx | 1 + src/types/core.js | 23 - src/types/core.tsx | 22 + src/types/{intl.js => intl.tsx} | 4 +- src/types/nav.js | 57 --- src/types/nav.tsx | 57 +++ .../common/{NavButton.js => NavButton.tsx} | 0 src/ui/routes/{constants.js => constants.tsx} | 4 +- .../{constants.js => constants.tsx} | 0 .../{leftHorizontal.js => leftHorizontal.tsx} | 18 +- src/ui/routes/routes.js | 48 -- src/ui/routes/routes.tsx | 66 +++ tsconfig.json | 16 + tslint.json | 49 ++ yarn.lock | 424 +++++++++++++----- 26 files changed, 660 insertions(+), 454 deletions(-) delete mode 100644 .eslintrc create mode 100644 .vscode/settings.json rename src/redux/ducks/{config.js => config.tsx} (78%) rename src/redux/ducks/{constants.js => constants.tsx} (66%) rename src/redux/ducks/{device.js => device.tsx} (77%) rename src/redux/ducks/{intl.js => intl.tsx} (100%) delete mode 100644 src/redux/ducks/nav.js create mode 100644 src/redux/ducks/nav.tsx rename src/{types.js => types.tsx} (100%) delete mode 100644 src/types/actions.js create mode 100644 src/types/actions.tsx delete mode 100644 src/types/core.js create mode 100644 src/types/core.tsx rename src/types/{intl.js => intl.tsx} (85%) delete mode 100644 src/types/nav.js create mode 100644 src/types/nav.tsx rename src/ui/partials/common/{NavButton.js => NavButton.tsx} (100%) rename src/ui/routes/{constants.js => constants.tsx} (81%) rename src/ui/routes/interpolators/{constants.js => constants.tsx} (100%) rename src/ui/routes/interpolators/{leftHorizontal.js => leftHorizontal.tsx} (79%) delete mode 100644 src/ui/routes/routes.js create mode 100644 src/ui/routes/routes.tsx create mode 100644 tsconfig.json create mode 100644 tslint.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index c80e91f..0000000 --- a/.eslintrc +++ /dev/null @@ -1,111 +0,0 @@ -{ - "env": { - "node": true, - "mocha": true, - "browser": true, - "es6": true - }, - "extends": "standard", - "parser": "babel-eslint", - "parserOptions": { - "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "jsx": true - }, - "sourceType": "module" - }, - "plugins": [ - "react", - "react-native", - "flowtype" - ], - "globals": { - "gql": true, - "ga": true, - "describe": true, - "it": true, - "test": true, - "expect": true, - "jest": true, - "__DEV__": true - }, - "rules": { - "indent": [ - "error", - 2 - ], - "linebreak-style": [ - "error", - "unix" - ], - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "never" - ], - "space-before-function-paren": 0, - "react/jsx-uses-vars": 1, - "react/react-in-jsx-scope": 1, - "flowtype/boolean-style": [ - 2, - "bool" - ], - "flowtype/define-flow-type": 1, - "flowtype/delimiter-dangle": [ - 2, - "never" - ], - "flowtype/generic-spacing": [ - 2, - "never" - ], - "flowtype/no-primitive-constructor-types": 2, - "flowtype/no-weak-types": 0, - "flowtype/object-type-delimiter": [ - 2, - "comma" - ], - "flowtype/require-parameter-type": 1, - "flowtype/require-return-type": [ - 1, - "always", - { "annotateUndefined": "never" } - ], - "flowtype/require-valid-file-annotation": [ - 1, - "none" - ], - "flowtype/semi": [ - 2, - "always" - ], - "flowtype/space-after-type-colon": [ - 2, - "always" - ], - "flowtype/space-before-generic-bracket": [ - 2, - "never" - ], - "flowtype/space-before-type-colon": [ - 2, - "never" - ], - "flowtype/type-id-match": 0, - "flowtype/union-intersection-spacing": [ - 2, - "always" - ], - "flowtype/use-flow-type": 1, - "flowtype/valid-syntax": 1 - }, - "settings": { - "onlyFilesWithFlowAnnotation": true, - "flowtype": { - "onlyFilesWithFlowAnnotation": true - } - } -} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..165c9e5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib", + "vsicons.presets.angular": false, + "typescript.validate.enable": true, + "tslint.enable": true +} diff --git a/package.json b/package.json index 2c4cd0e..79fbfc0 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "flow": "flow; test $? -eq 0 -o $? -eq 2", "ios": "react-native run-ios && yarn run build:strings", "install": "flow-typed update", - "lint": "eslint src __tests__", + "lint": "tslint", "lint:fix": "eslint --fix src __tests__", "start": "concurrently \"react-native run-ios\" \"ANDROID_HOME=/Users/$(whoami)/Library/Android/sdk react-native run-android\" && yarn run build:strings", "test": "npm run lint && npm run test:jest-no-cache", @@ -21,10 +21,18 @@ "test:update-snapshots": "jest --coverage --no-cache -u" }, "dependencies": { + "@types/graphql": "^0.8.6", + "@types/react": "^15.0.12", + "@types/react-intl": "^2.2.2", + "@types/react-native": "^0.37.13", + "@types/react-redux": "^4.4.36", + "@types/redux": "^3.6.0", + "@types/redux-persist": "^4.0.0", "apollo-client": "^0.5.25", "graphql": "^0.6.1", "graphql-tag": "^0.1.7", "graphql-tools": "^0.6.2", + "graphql-typings": "^0.0.1-beta-2", "react": "~15.4.0-rc.4", "react-apollo": "^0.7.2", "react-intl": "^2.2.3", @@ -43,11 +51,9 @@ "babel-core": "^6.8.0", "babel-eslint": "^6.1.0", "babel-jest": "18.0.0", - "babel-loader": "^6.2.4", "babel-plugin-react-intl": "^2.3.1", "babel-preset-react-native": "1.9.1", "concurrently": "^3.1.0", - "eslint": "^3.13.0", "eslint-config-standard": "^6.2.1", "eslint-plugin-babel": "^3.3.0", "eslint-plugin-flowtype": "^2.29.1", @@ -61,7 +67,9 @@ "react-addons-test-utils": "^15.4.2", "react-dom": "^15.4.2", "react-test-renderer": "15.4.1", - "redux-mock-store": "^1.2.1" + "redux-mock-store": "^1.2.1", + "tslint": "^4.5.1", + "typescript": "^2.2.1" }, "jest": { "preset": "react-native", diff --git a/src/redux/ducks/config.js b/src/redux/ducks/config.tsx similarity index 78% rename from src/redux/ducks/config.js rename to src/redux/ducks/config.tsx index 8f5bd61..f7d49b5 100644 --- a/src/redux/ducks/config.js +++ b/src/redux/ducks/config.tsx @@ -1,6 +1,6 @@ /* @flow */ -import type { ConfigState } from '../../types' +import { ConfigState } from '../../types' const initialState = { appName: '', diff --git a/src/redux/ducks/constants.js b/src/redux/ducks/constants.tsx similarity index 66% rename from src/redux/ducks/constants.js rename to src/redux/ducks/constants.tsx index 7b38ed8..507f780 100644 --- a/src/redux/ducks/constants.js +++ b/src/redux/ducks/constants.tsx @@ -1,6 +1,4 @@ -// Routing -export const PUSH = '@appPlayground/routes/PUSH' -export const POP = '@appPlayground/routes/POP' + // Localization export const SET_LOCALE = '@ratebeer/intl/SET_LOCALE' diff --git a/src/redux/ducks/device.js b/src/redux/ducks/device.tsx similarity index 77% rename from src/redux/ducks/device.js rename to src/redux/ducks/device.tsx index 0ddd618..980c9d6 100644 --- a/src/redux/ducks/device.js +++ b/src/redux/ducks/device.tsx @@ -1,6 +1,8 @@ /* @flow */ -import type { DeviceState } from '../../types' +interface DeviceState { + isReactNative: boolean +} const initialState = { isReactNative: false, diff --git a/src/redux/ducks/intl.js b/src/redux/ducks/intl.tsx similarity index 100% rename from src/redux/ducks/intl.js rename to src/redux/ducks/intl.tsx diff --git a/src/redux/ducks/nav.js b/src/redux/ducks/nav.js deleted file mode 100644 index f1e217d..0000000 --- a/src/redux/ducks/nav.js +++ /dev/null @@ -1,67 +0,0 @@ -/* flow */ - -import routes from '../../ui/routes/routes' - -import type { - Route, - NavState, - Action -} from '../../types' - -import { HORIZONTAL, directionByPush } from '../../ui/routes/constants' - -import { PUSH, POP } from './constants' - -const initialState = { - index: 0, - pushDirection: HORIZONTAL, - routes: [routes.home] -} - -export default (state: NavState = initialState, action: Action = {}): NavState => { - if (!action.type) return state - - switch (action.type) { - - case PUSH: - const route = action.payload.route - const routes = state.routes.slice() - routes.push(route) - - return { - index: routes.length - 1, - routes, - pushDirection: directionByPush[route.pushType], - interpolator: route.interpolator - } - - case POP: - if (state.index <= 0) { return state } - // es lint is complaining, so humoring it - const popRoutes = state.routes - const lastRoute = popRoutes.pop() - - return { - index: popRoutes.length - 1, - routes: popRoutes, - pushDirection: directionByPush[lastRoute.pushType], - interpolator: lastRoute.interpolator - } - - default: - return state - } -} - -const push = (route: Route): Action => { - return { - type: PUSH, - payload: { route: route } - } -} - -export const showLeft = (): Action => push(routes.left) -export const showRight = (): Action => push(routes.right) -export const showModal = (): Action => push(routes.modal) - -export const pop = (): Action => { return { type: POP } } diff --git a/src/redux/ducks/nav.tsx b/src/redux/ducks/nav.tsx new file mode 100644 index 0000000..288bee8 --- /dev/null +++ b/src/redux/ducks/nav.tsx @@ -0,0 +1,92 @@ +import { BasicAction } from '../../types' + +import routes, { + Route, + PushDirection, + PushType, + NavInterpolator +} from '../../ui/routes/routes' + +export const PUSH = '@appPlayground/routes/PUSH' +export const POP = '@appPlayground/routes/POP' + +const directionByPush = (type: PushType): PushDirection => { + switch (type) { + case (PushType.default): return PushDirection.horizontal + case (PushType.modal): return PushDirection.vertical + } +} + +export interface NavState { + index: number, + routes: Route[], + pushDirection: PushDirection, + interpolator?: NavInterpolator +} + +const initialState = { + index: 0, + pushDirection: PushDirection.horizontal, + routes: [routes.home] +} + +export interface NavAction { + type: string, + payload: { + route: Route + } +} + +const isNavAction = (action: any): action is NavAction => { + return action.payload !== undefined + && action.payload.route !== undefined +} + +export default (state: NavState = initialState, action?: BasicAction | NavAction): NavState => { + if (!action) return state + + switch (action.type) { + + case PUSH: + if (!isNavAction(action)) return + const route = action.payload.route + const routes = state.routes.slice() + routes.push(route) + + return { + index: routes.length - 1, + routes, + pushDirection: directionByPush[route.pushType], + interpolator: route.interpolator + } + + case POP: + if (state.index <= 0) { return state } + // es lint is complaining, so humoring it + const popRoutes = state.routes + const lastRoute = popRoutes.pop() + + return { + index: popRoutes.length - 1, + routes: popRoutes, + pushDirection: directionByPush[lastRoute.pushType], + interpolator: lastRoute.interpolator + } + + default: + return state + } +} + +const push = (route: Route): NavAction => { + return { + type: PUSH, + payload: { route: route } + } +} + +export const showLeft = (): NavAction => push(routes.left) +export const showRight = (): NavAction => push(routes.right) +export const showModal = (): NavAction => push(routes.modal) + +export const pop = (): BasicAction => { return { type: POP } } diff --git a/src/types.js b/src/types.tsx similarity index 100% rename from src/types.js rename to src/types.tsx diff --git a/src/types/actions.js b/src/types/actions.js deleted file mode 100644 index d561faa..0000000 --- a/src/types/actions.js +++ /dev/null @@ -1,23 +0,0 @@ -/* @flow */ - -import { REHYDRATE } from 'redux-persist/constants' -import { - PUSH, - POP, - SET_LOCALE, - LOCALE_SHOULD_UPDATE, - LOCALE_DID_UPDATE -} from '../redux/ducks/constants' - -import type { NativeState } from './core' -import type { Route } from './nav' -import type { SupportedLocale } from './intl' - -export type Action = - { type: REHYDRATE, payload: NativeState } - | { type: PUSH, payload: { route: Route } } - | { type: POP } - | { type: SET_LOCALE, payload: { locale: SupportedLocale } } - | { type: LOCALE_SHOULD_UPDATE } - | { type: LOCALE_DID_UPDATE } - ; diff --git a/src/types/actions.tsx b/src/types/actions.tsx new file mode 100644 index 0000000..c2d5666 --- /dev/null +++ b/src/types/actions.tsx @@ -0,0 +1 @@ +export type BasicAction = { type: String } diff --git a/src/types/core.js b/src/types/core.js deleted file mode 100644 index a8dbd78..0000000 --- a/src/types/core.js +++ /dev/null @@ -1,23 +0,0 @@ -/* @flow */ - -import type { NavState } from './nav' -import type { IntlState } from './intl' - -export type ConfigState = { - appName: string, - appVersion: string -}; - -export type DeviceState = { - isReactNative: bool, - platform: string -}; - -export type NativeState = { - config: ConfigState, - device: DeviceState, - intl: IntlState, - apollo: Object, - error: ?Object, - nav: NavState -}; diff --git a/src/types/core.tsx b/src/types/core.tsx new file mode 100644 index 0000000..50bfa83 --- /dev/null +++ b/src/types/core.tsx @@ -0,0 +1,22 @@ +/* @flow */ + +import { NavState } from './nav' +// import type { IntlState } from './intl' + +export interface ConfigState { + appName: string, + appVersion: string +} + +export interface DeviceState { + isReactNative: boolean, + platform: string +}; + +export type NativeState = { + config: ConfigState, + device: DeviceState, + // intl: IntlState, + apollo: Object, + nav: NavState +}; diff --git a/src/types/intl.js b/src/types/intl.tsx similarity index 85% rename from src/types/intl.js rename to src/types/intl.tsx index e4dd627..5fafc9e 100644 --- a/src/types/intl.js +++ b/src/types/intl.tsx @@ -1,10 +1,10 @@ /* @flow */ -export type IntlState = { +export interface IntlState { defaultLocale: string, currentLocale: string, supportedLocales: SupportedLocale[], - isDirty: bool, + isDirty: boolean, messages: { [key: string]: { id: string, diff --git a/src/types/nav.js b/src/types/nav.js deleted file mode 100644 index faaf8f0..0000000 --- a/src/types/nav.js +++ /dev/null @@ -1,57 +0,0 @@ -/* @flow */ -import React from 'react' // eslint-disable-line no-unused-vars - -import type { NavigationSceneRendererProps } from 'react-native' - -import { - PUSH, - POP -} from '../redux/ducks/constants' - -import { - MODAL, - DEFAULT, - VERTICAL, - HORIZONTAL -} from '../ui/routes/constants' - -import { - SCENE, - HEADER -} from '../ui/routes/interpolators/constants' - -export type SubNavProps = { - onNavigateBack: ?Function // View NavigationHeader.js -}; - -export type SubNavRenderer = (navProps: SubNavProps) => ?React$Element; - -export type InterpolatorType = SCENE | HEADER; - -export type Interpolator= (props: NavigationSceneRendererProps) => Object; - -export type NavInterpolator = { - [key: InterpolatorType]: Interpolator -}; - -export type NavPushType = MODAL | DEFAULT; - -export type RouteType = PUSH | POP; - -export type PushDirection = VERTICAL | HORIZONTAL; - -export type Route = { - key: string, - title: string, - pushType: NavPushType, - rightNavRenderer?: SubNavRenderer, - leftNavRenderer?: SubNavRenderer, - interpolator?: NavInterpolator -}; - -export type NavState = { - index: number, - routes: Route[], - pushDirection: PushDirection, - interpolator?: NavInterpolator -}; diff --git a/src/types/nav.tsx b/src/types/nav.tsx new file mode 100644 index 0000000..0d24947 --- /dev/null +++ b/src/types/nav.tsx @@ -0,0 +1,57 @@ +import * as React from 'react' +import { ReactElement } from 'react' + +import { + PUSH, + POP +} from '../redux/ducks/constants' + +import { + MODAL, + DEFAULT, + VERTICAL, + HORIZONTAL +} from '../ui/routes/constants' + +import { + SCENE, + HEADER +} from '../ui/routes/interpolators/constants' + +import { NavigationSceneRendererProps } from 'react-native' + +export interface SubNavProps { + onNavigateBack: Function | null +} + +export type SubNavRenderer = (navProps: SubNavProps) => ReactElement | null + +export type InterpolatorType = 'scene' | 'header' + +export type Interpolator= (props: NavigationSceneRendererProps) => Object + +export type NavInterpolator = { + [key: string]: Interpolator +} + +export type NavPushType = 'modal' | 'default' + +export type RouteType = 'push' | 'pop' + +export type PushDirection = 'vertical' | 'horizontal' + +export interface Route { + key: string, + title: string, + pushType?: NavPushType, + rightNavRenderer?: SubNavRenderer, + leftNavRenderer?: SubNavRenderer, + interpolator?: NavInterpolator +} + +export interface NavState { + index: number, + routes: Route[], + pushDirection: PushDirection, + interpolator?: NavInterpolator +} diff --git a/src/ui/partials/common/NavButton.js b/src/ui/partials/common/NavButton.tsx similarity index 100% rename from src/ui/partials/common/NavButton.js rename to src/ui/partials/common/NavButton.tsx diff --git a/src/ui/routes/constants.js b/src/ui/routes/constants.tsx similarity index 81% rename from src/ui/routes/constants.js rename to src/ui/routes/constants.tsx index ac99e2b..5cfd373 100644 --- a/src/ui/routes/constants.js +++ b/src/ui/routes/constants.tsx @@ -1,5 +1,5 @@ -export const MODAL = 'MODAL' -export const DEFAULT = 'DEFAULT' +export const MODAL = 'modal' +export const DEFAULT = 'default' export const VERTICAL = 'vertical' export const HORIZONTAL = 'horizontal' diff --git a/src/ui/routes/interpolators/constants.js b/src/ui/routes/interpolators/constants.tsx similarity index 100% rename from src/ui/routes/interpolators/constants.js rename to src/ui/routes/interpolators/constants.tsx diff --git a/src/ui/routes/interpolators/leftHorizontal.js b/src/ui/routes/interpolators/leftHorizontal.tsx similarity index 79% rename from src/ui/routes/interpolators/leftHorizontal.js rename to src/ui/routes/interpolators/leftHorizontal.tsx index 9edc153..b31114f 100644 --- a/src/ui/routes/interpolators/leftHorizontal.js +++ b/src/ui/routes/interpolators/leftHorizontal.tsx @@ -1,9 +1,9 @@ // Check NavigationCardStackStyleInterpolator.js (Basically copypasta here) // Also more on this subject: http://www.reactnativediary.com/2016/12/22/navigation-experimental-custom-transition-2.html // -import type { NavigationSceneRendererProps } from 'react-native' +import { NavigationSceneRendererProps } from 'react-native' -import { SCENE, HEADER } from './constants' +export type InterpolatorType = 'scene' | 'header' const forInitial = (props: NavigationSceneRendererProps): Object => { const { navigationState, scene } = props @@ -26,13 +26,13 @@ const headerInterpolator = (props: NavigationSceneRendererProps): Object => { return { opacity: position.interpolate({ inputRange: [ index - 1, index, index + 1 ], - outputRange: ([ 0, 1, 0 ]: Array) + outputRange: ([ 0, 1, 0 ]) }), transform: [ { translateX: position.interpolate({ inputRange: [ index - 1, index + 1 ], - outputRange: ([ -200, 200 ]: Array) + outputRange: ([ -200, 200 ]) }) } ] @@ -51,18 +51,18 @@ const sceneInterpolator = (props: NavigationSceneRendererProps): Object => { const opacity = position.interpolate({ inputRange, - outputRange: ([1, 1, 0.3, 0]: Array) + outputRange: ([1, 1, 0.3, 0]) }) const scale = position.interpolate({ inputRange, - outputRange: ([1, 1, 0.95, 0.95]: Array) + outputRange: ([1, 1, 0.95, 0.95]) }) const translateY = 0 const translateX = position.interpolate({ inputRange, - outputRange: ([-width, 0, 10, 10]: Array) + outputRange: ([-width, 0, 10, 10]) }) return { @@ -76,6 +76,6 @@ const sceneInterpolator = (props: NavigationSceneRendererProps): Object => { } export default { - [SCENE]: sceneInterpolator, - [HEADER]: headerInterpolator + ['scene']: sceneInterpolator, + ['header']: headerInterpolator } diff --git a/src/ui/routes/routes.js b/src/ui/routes/routes.js deleted file mode 100644 index c8dde37..0000000 --- a/src/ui/routes/routes.js +++ /dev/null @@ -1,48 +0,0 @@ -/* @flow */ - -import React, { Component } from 'react' // eslint-disable-line no-unused-vars - -import { - DEFAULT, - HOME, - LEFT, - MODAL, - MODAL_TITLE, - RIGHT -} from './constants' - -import leftHorizontal from './interpolators/leftHorizontal' - -import NavButton from '../partials/common/NavButton' - -const button = (title: string): () => React$Element => { - return (): React$Element => () -} - -export default { - home: { - key: HOME, - title: HOME, - pushType: DEFAULT, - leftNavRenderer: button(LEFT), - rightNavRenderer: button(RIGHT) - }, - left: { - key: LEFT, - title: LEFT, - pushType: DEFAULT, - leftNavRenderer: (): null => { return null }, - rightNavRenderer: button(HOME), - interpolator: leftHorizontal - }, - modal: { - key: MODAL_TITLE, - title: MODAL_TITLE, - pushType: MODAL - }, - right: { - key: RIGHT, - title: RIGHT, - pushType: DEFAULT - } -} diff --git a/src/ui/routes/routes.tsx b/src/ui/routes/routes.tsx new file mode 100644 index 0000000..1b4086f --- /dev/null +++ b/src/ui/routes/routes.tsx @@ -0,0 +1,66 @@ +import * as React from 'react' +import { ReactElement } from 'react' +import { NavigationSceneRendererProps } from 'react-native' + +import leftHorizontal from './interpolators/leftHorizontal' + +import NavButton from '../partials/common/NavButton' + +const button = (title: string) => (): ReactElement => () + +export interface SubNavProps { + onNavigateBack: Function | null +} + +export type Interpolator= (props: NavigationSceneRendererProps) => Object + +export type NavInterpolator = { + [key: string]: Interpolator +} + +export enum PushType { + modal, + default +} + +export enum PushDirection { + vertical, + horizontal +} + +export type SubNavRenderer = (navProps: SubNavProps) => ReactElement | null + +export interface Route { + title: string, + pushType?: PushType, + rightNavRenderer?: SubNavRenderer, + leftNavRenderer?: SubNavRenderer, + interpolator?: NavInterpolator +} + +export type SceneKeys = + 'Home' + | 'Left' + | 'Right' + | 'Modal' + +export default { + home: { + title: 'Home', + leftNavRenderer: button('Left'), + rightNavRenderer: button('Right') + }, + left: { + title: 'Left', + leftNavRenderer: (): null => { return null }, + rightNavRenderer: button('Home'), + interpolator: leftHorizontal + }, + modal: { + title: 'Modal', + pushType: PushType.modal + }, + right: { + title: 'Right' + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b7e12cc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": false, + "sourceMap": false, + "rootDir": "src/", + "outDir": "build/", + "watch": true, + "jsx": "react" + }, + "exclude": [ + "node_modules", + "build" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..88bf31e --- /dev/null +++ b/tslint.json @@ -0,0 +1,49 @@ +{ + "rules": { + "class-name": true, + "comment-format": [true, "check-space"], + "indent": [true, "spaces"], + "no-duplicate-variable": true, + "no-eval": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-var-keyword": true, + "one-line": [true, "check-open-brace", "check-whitespace"], + "quotemark": [true, "single"], + "semicolon": [false], + "triple-equals": [true, "allow-null-check"], + "typedef-whitespace": [true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }], + "variable-name": [true, "ban-keywords"], + "whitespace": [true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + }, + "jsRules": { + "indent": [true, "spaces"], + "no-duplicate-variable": true, + "no-eval": true, + "no-trailing-whitespace": true, + "one-line": [true, "check-open-brace", "check-whitespace"], + "quotemark": [true, "double"], + "semicolon": [false, "always", "ignore-interfaces"], + "triple-equals": [true, "allow-null-check"], + "variable-name": [true, "ban-keywords"], + "whitespace": [true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} diff --git a/yarn.lock b/yarn.lock index 028c7ed..614232c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10,6 +10,10 @@ version "3.4.34" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.4.34.tgz#d5335792823bb09cddd5e38c3d211b709183854d" +"@types/graphql@^0.8.6": + version "0.8.6" + resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-0.8.6.tgz#b34fb880493ba835b0c067024ee70130d6f9bb68" + "@types/isomorphic-fetch@0.0.30": version "0.0.30" resolved "https://registry.yarnpkg.com/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.30.tgz#a21717624cde9a48c2db53a4e500fc5c32a99bbc" @@ -26,9 +30,40 @@ version "0.0.26" resolved "https://registry.yarnpkg.com/@types/promises-a-plus/-/promises-a-plus-0.0.26.tgz#64d992f8e715dc6bb975766391eae54985fa4fe2" -"@types/redux@^3.5.29": - version "3.6.31" - resolved "https://registry.yarnpkg.com/@types/redux/-/redux-3.6.31.tgz#40eafa7575db36b912ce0059b85de98c205b0708" +"@types/react-intl@^2.2.2": + version "2.2.2" + resolved "https://registry.yarnpkg.com/@types/react-intl/-/react-intl-2.2.2.tgz#dbd7387d078d5a241d0becbe5fe83aee37c5b1a2" + dependencies: + "@types/react" "*" + +"@types/react-native@^0.37.13": + version "0.37.13" + resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.37.13.tgz#65548f892ed6e55ef87add1ffeec72275b4152b7" + dependencies: + "@types/react" "*" + +"@types/react-redux@^4.4.36": + version "4.4.36" + resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-4.4.36.tgz#5d1e768f3291c66c8e54d8a48e42f7cb554a7d87" + dependencies: + "@types/react" "*" + redux "^3.6.0" + +"@types/react@*", "@types/react@^15.0.12": + version "15.0.12" + resolved "https://registry.yarnpkg.com/@types/react/-/react-15.0.12.tgz#aea95e45631bd745be45d65c2dc02327848212f2" + +"@types/redux-persist@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/redux-persist/-/redux-persist-4.0.0.tgz#9c9f29eef079e2c36ed5b02141a11b117854a514" + dependencies: + redux "^3.6.0" + +"@types/redux@^3.5.29", "@types/redux@^3.6.0": + version "3.6.0" + resolved "https://registry.yarnpkg.com/@types/redux/-/redux-3.6.0.tgz#f1ebe1e5411518072e4fdfca5c76e16e74c1399a" + dependencies: + redux "*" "@types/sinon@^1.16.29": version "1.16.34" @@ -96,6 +131,12 @@ amdefine@>=0.0.4: version "1.0.1" resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" +ansi-align@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-1.1.0.tgz#2f0c1658829739add5ebb15e6b0c6e3423f016ba" + dependencies: + string-width "^1.0.1" + ansi-escapes@^1.1.0, ansi-escapes@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" @@ -294,7 +335,7 @@ babel-cli@^6.8.0: optionalDependencies: chokidar "^1.6.1" -babel-code-frame@^6.16.0, babel-code-frame@^6.22.0: +babel-code-frame@^6.16.0, babel-code-frame@^6.20.0, babel-code-frame@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" dependencies: @@ -450,15 +491,6 @@ babel-jest@18.0.0, babel-jest@^18.0.0: babel-plugin-istanbul "^3.0.0" babel-preset-jest "^18.0.0" -babel-loader@^6.2.4: - version "6.2.10" - resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-6.2.10.tgz#adefc2b242320cd5d15e65b31cea0e8b1b02d4b0" - dependencies: - find-cache-dir "^0.1.1" - loader-utils "^0.2.11" - mkdirp "^0.5.1" - object-assign "^4.0.1" - babel-messages@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.22.0.tgz#36066a214f1217e4ed4164867669ecb39e3ea575" @@ -956,10 +988,6 @@ beeper@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809" -big.js@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" - binary-extensions@^1.0.0: version "1.8.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" @@ -999,6 +1027,18 @@ boom@2.x.x: dependencies: hoek "2.x.x" +boxen@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.0.0.tgz#b2694baf1f605f708ff0177c12193b22f29aaaab" + dependencies: + ansi-align "^1.1.0" + camelcase "^4.0.0" + chalk "^1.1.1" + cli-boxes "^1.0.0" + string-width "^2.0.0" + term-size "^0.1.0" + widest-line "^1.0.0" + bplist-creator@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/bplist-creator/-/bplist-creator-0.0.4.tgz#4ac0496782e127a85c1d2026a4f5eb22a7aff991" @@ -1074,6 +1114,14 @@ camelcase@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" +camelcase@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.0.0.tgz#8b0f90d44be5e281b903b9887349b92595ef07f2" + +capture-stack-trace@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" + cardinal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/cardinal/-/cardinal-1.0.0.tgz#50e21c1b0aa37729f9377def196b5a9cec932ee9" @@ -1139,6 +1187,10 @@ circular-json@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d" +cli-boxes@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143" + cli-cursor@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" @@ -1214,10 +1266,6 @@ commander@^2.8.1, commander@^2.9.0: dependencies: graceful-readlink ">= 1.0.0" -commondir@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" - compressible@~2.0.5: version "2.0.9" resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.9.tgz#6daab4e2b599c2770dd9e21e7a891b1c5a755425" @@ -1260,6 +1308,17 @@ concurrently@^3.1.0: spawn-default-shell "^1.1.0" tree-kill "^1.1.0" +configstore@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.0.0.tgz#e1b8669c1803ccc50b545e92f8e6e79aa80e0196" + dependencies: + dot-prop "^4.1.0" + graceful-fs "^4.1.2" + mkdirp "^0.5.0" + unique-string "^1.0.0" + write-file-atomic "^1.1.2" + xdg-basedir "^3.0.0" + connect-timeout@~1.6.2: version "1.6.2" resolved "https://registry.yarnpkg.com/connect-timeout/-/connect-timeout-1.6.2.tgz#de9a5ec61e33a12b6edaab7b5f062e98c599b88e" @@ -1352,6 +1411,19 @@ crc@3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/crc/-/crc-3.3.0.tgz#fa622e1bc388bf257309082d6b65200ce67090ba" +create-error-class@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" + dependencies: + capture-stack-trace "^1.0.0" + +cross-spawn-async@^2.1.1: + version "2.2.5" + resolved "https://registry.yarnpkg.com/cross-spawn-async/-/cross-spawn-async-2.2.5.tgz#845ff0c0834a3ded9d160daca6d390906bb288cc" + dependencies: + lru-cache "^4.0.0" + which "^1.2.8" + cross-spawn@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-3.0.1.tgz#1256037ecb9f0c5f79e3d6ef135e30770184b982" @@ -1369,6 +1441,10 @@ cryptiles@2.x.x: dependencies: boom "2.x.x" +crypto-random-string@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" + csrf@~3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/csrf/-/csrf-3.0.4.tgz#ba01423e5b5bea7b655e38b0bdd1323954cbdaa5" @@ -1491,7 +1567,7 @@ detect-indent@^4.0.0: dependencies: repeating "^2.0.0" -diff@^3.0.0: +diff@^3.0.0, diff@^3.0.1: version "3.2.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" @@ -1506,12 +1582,22 @@ dom-walk@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.1.tgz#672226dc74c8f799ad35307df936aba11acd6018" +dot-prop@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.1.1.tgz#a8493f0b7b5eeec82525b5c7587fa7de7ca859c1" + dependencies: + is-obj "^1.0.0" + duplexer2@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" dependencies: readable-stream "~1.1.9" +duplexer3@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" + ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" @@ -1522,10 +1608,6 @@ ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" -emojis-list@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" - encoding@^0.1.11: version "0.1.12" resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" @@ -1710,46 +1792,7 @@ eslint@3.12.0: text-table "~0.2.0" user-home "^2.0.0" -eslint@^3.13.0: - version "3.15.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.15.0.tgz#bdcc6a6c5ffe08160e7b93c066695362a91e30f2" - dependencies: - babel-code-frame "^6.16.0" - chalk "^1.1.3" - concat-stream "^1.4.6" - debug "^2.1.1" - doctrine "^1.2.2" - escope "^3.6.0" - espree "^3.4.0" - estraverse "^4.2.0" - esutils "^2.0.2" - file-entry-cache "^2.0.0" - glob "^7.0.3" - globals "^9.14.0" - ignore "^3.2.0" - imurmurhash "^0.1.4" - inquirer "^0.12.0" - is-my-json-valid "^2.10.0" - is-resolvable "^1.0.0" - js-yaml "^3.5.1" - json-stable-stringify "^1.0.0" - levn "^0.3.0" - lodash "^4.0.0" - mkdirp "^0.5.0" - natural-compare "^1.4.0" - optionator "^0.8.2" - path-is-inside "^1.0.1" - pluralize "^1.2.1" - progress "^1.1.8" - require-uncached "^1.0.2" - shelljs "^0.7.5" - strip-bom "^3.0.0" - strip-json-comments "~2.0.1" - table "^3.7.8" - text-table "~0.2.0" - user-home "^2.0.0" - -espree@^3.3.1, espree@^3.4.0: +espree@^3.3.1: version "3.4.0" resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.0.tgz#41656fa5628e042878025ef467e78f125cb86e1d" dependencies: @@ -1808,6 +1851,17 @@ exec-sh@^0.2.0: dependencies: merge "^1.1.3" +execa@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.4.0.tgz#4eb6467a36a095fabb2970ff9d5e3fb7bce6ebc3" + dependencies: + cross-spawn-async "^2.1.1" + is-stream "^1.1.0" + npm-run-path "^1.0.0" + object-assign "^4.0.1" + path-key "^1.0.0" + strip-eof "^1.0.0" + exit-hook@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" @@ -1938,14 +1992,6 @@ finalhandler@0.4.0: on-finished "~2.3.0" unpipe "~1.0.0" -find-cache-dir@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-0.1.1.tgz#c8defae57c8a52a8a784f9e31c57c742e993a0b9" - dependencies: - commondir "^1.0.1" - mkdirp "^0.5.1" - pkg-dir "^1.0.0" - find-up@^1.0.0, find-up@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -1953,6 +1999,12 @@ find-up@^1.0.0, find-up@^1.1.2: path-exists "^2.0.0" pinkie-promise "^2.0.0" +findup-sync@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16" + dependencies: + glob "~5.0.0" + flat-cache@^1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96" @@ -2091,6 +2143,10 @@ get-caller-file@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + getpass@^0.1.1: version "0.1.6" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" @@ -2116,7 +2172,7 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob@^5.0.15: +glob@^5.0.15, glob@~5.0.0: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" dependencies: @@ -2126,7 +2182,7 @@ glob@^5.0.15: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6: +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" dependencies: @@ -2165,6 +2221,22 @@ glogg@^1.0.0: dependencies: sparkles "^1.0.0" +got@^6.7.1: + version "6.7.1" + resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" + dependencies: + create-error-class "^3.0.0" + duplexer3 "^0.1.4" + get-stream "^3.0.0" + is-redirect "^1.0.0" + is-retry-allowed "^1.0.0" + is-stream "^1.0.0" + lowercase-keys "^1.0.0" + safe-buffer "^5.0.1" + timed-out "^4.0.0" + unzip-response "^2.0.1" + url-parse-lax "^1.0.0" + graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -2196,6 +2268,10 @@ graphql-tools@^0.6.2: lodash.uniq "^4.3.0" node-uuid "^1.4.7" +graphql-typings@^0.0.1-beta-2: + version "0.0.1-beta-2" + resolved "https://registry.yarnpkg.com/graphql-typings/-/graphql-typings-0.0.1-beta-2.tgz#b53e6b92372e6e4d1bb4e9cc79f8a5bb7ec53f25" + graphql@^0.6.1: version "0.6.2" resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.6.2.tgz#19cdcb17e5862d64396a0684f92f7be64e90e7af" @@ -2480,6 +2556,10 @@ is-fullwidth-code-point@^1.0.0: dependencies: number-is-nan "^1.0.0" +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + is-glob@^2.0.0, is-glob@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" @@ -2495,12 +2575,20 @@ is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4: jsonpointer "^4.0.0" xtend "^4.0.0" +is-npm@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" + is-number@^2.0.2, is-number@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" dependencies: kind-of "^3.0.2" +is-obj@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" + is-path-cwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" @@ -2529,13 +2617,21 @@ is-property@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" +is-redirect@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" + is-resolvable@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" dependencies: tryit "^1.0.1" -is-stream@^1.0.1: +is-retry-allowed@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" + +is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -2965,10 +3061,20 @@ klaw@^1.0.0: optionalDependencies: graceful-fs "^4.1.9" +latest-version@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.0.0.tgz#3104f008c0c391084107f85a344bc61e38970649" + dependencies: + package-json "^3.0.0" + lazy-cache@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" +lazy-req@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lazy-req/-/lazy-req-2.0.0.tgz#c9450a363ecdda2e6f0c70132ad4f37f8f06f2b4" + lcid@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" @@ -2996,15 +3102,6 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" -loader-utils@^0.2.11: - version "0.2.16" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.16.tgz#f08632066ed8282835dff88dfb52704765adee6d" - dependencies: - big.js "^3.1.3" - emojis-list "^2.0.0" - json5 "^0.5.0" - object-assign "^4.0.1" - lodash-es@^4.16.0, lodash-es@^4.2.0, lodash-es@^4.2.1: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7" @@ -3191,7 +3288,11 @@ loose-envify@^1.0.0, loose-envify@^1.1.0: dependencies: js-tokens "^3.0.0" -lru-cache@^4.0.1: +lowercase-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306" + +lru-cache@^4.0.0, lru-cache@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e" dependencies: @@ -3445,6 +3546,12 @@ normalize-path@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" +npm-run-path@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-1.0.0.tgz#f5c32bf595fe81ae927daec52e82f8b000ac3c8f" + dependencies: + path-key "^1.0.0" + npmlog@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-2.0.4.tgz#98b52530f2514ca90d09ec5b22c8846722375692" @@ -3521,7 +3628,7 @@ opn@^3.0.2: dependencies: object-assign "^4.0.1" -optimist@^0.6.1: +optimist@^0.6.1, optimist@~0.6.0: version "0.6.1" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" dependencies: @@ -3565,6 +3672,15 @@ output-file-sync@^1.1.0: mkdirp "^0.5.1" object-assign "^4.1.0" +package-json@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/package-json/-/package-json-3.1.0.tgz#ce281900fe8052150cc6709c6c006c18fdb2f379" + dependencies: + got "^6.7.1" + registry-auth-token "^3.0.1" + registry-url "^3.0.3" + semver "^5.1.0" + parse-glob@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" @@ -3602,6 +3718,10 @@ path-is-inside@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" +path-key@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-1.0.0.tgz#5d53d578019646c0d68800db4e146e6bdc2ac7af" + path-parse@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" @@ -3636,12 +3756,6 @@ pinkie@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" -pkg-dir@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4" - dependencies: - find-up "^1.0.0" - plist@1.2.0, plist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/plist/-/plist-1.2.0.tgz#084b5093ddc92506e259f874b8d9b1afb8c79593" @@ -3659,6 +3773,10 @@ prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" +prepend-http@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" + preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" @@ -3734,7 +3852,7 @@ raw-body@~2.1.2: iconv-lite "0.4.13" unpipe "1.0.0" -rc@~1.1.6: +rc@^1.0.1, rc@^1.1.6, rc@~1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/rc/-/rc-1.1.6.tgz#43651b76b6ae53b5c802f1151fa3fc3b059969c9" dependencies: @@ -4016,7 +4134,7 @@ redux-persist@^4.0.1: lodash "^4.11.1" lodash-es "^4.16.0" -redux@^3.3.1, redux@^3.6.0: +redux@*, redux@^3.3.1, redux@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/redux/-/redux-3.6.0.tgz#887c2b3d0b9bd86eca2be70571c27654c19e188d" dependencies: @@ -4060,6 +4178,18 @@ regexpu-core@^2.0.0: regjsgen "^0.2.0" regjsparser "^0.1.4" +registry-auth-token@^3.0.1: + version "3.1.0" + resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.1.0.tgz#997c08256e0c7999837b90e944db39d8a790276b" + dependencies: + rc "^1.1.6" + +registry-url@^3.0.3: + version "3.1.0" + resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" + dependencies: + rc "^1.0.1" + regjsgen@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" @@ -4136,7 +4266,7 @@ resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" -resolve@^1.1.6, resolve@^1.2.0: +resolve@^1.1.6, resolve@^1.1.7, resolve@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.0.tgz#9589c3f2f6149d1417a40becc1663db6ec6bc26c" @@ -4198,6 +4328,10 @@ rxjs@^5.0.0-rc.5: dependencies: symbol-observable "^1.0.1" +safe-buffer@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" + sane@~1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/sane/-/sane-1.4.1.tgz#88f763d74040f5f0c256b6163db399bf110ac715" @@ -4213,6 +4347,12 @@ sax@^1.1.4, sax@~1.1.1: version "1.1.6" resolved "https://registry.yarnpkg.com/sax/-/sax-1.1.6.tgz#5d616be8a5e607d54e114afae55b7eaf2fcc3240" +semver-diff@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" + dependencies: + semver "^5.0.3" + "semver@2 || 3 || 4 || 5", semver@5.x, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" @@ -4419,6 +4559,13 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" +string-width@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.0.0.tgz#635c5436cc72a6e0c387ceca278d4e2eec52687e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^3.0.0" + string.prototype.codepointat@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz#6b26e9bd3afcaa7be3b4269b526de1b82000ac78" @@ -4453,14 +4600,14 @@ strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + strip-json-comments@~1.0.1, strip-json-comments@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - supports-color@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a" @@ -4524,6 +4671,12 @@ temp@0.8.3: os-tmpdir "^1.0.0" rimraf "~2.2.6" +term-size@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/term-size/-/term-size-0.1.1.tgz#87360b96396cab5760963714cda0d0cbeecad9ca" + dependencies: + execa "^0.4.0" + test-exclude@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-3.3.0.tgz#7a17ca1239988c98367b0621456dbb7d4bc38977" @@ -4557,6 +4710,10 @@ time-stamp@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.0.1.tgz#9f4bd23559c9365966f3302dbba2b07c6b99b151" +timed-out@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" + tmpl@1.0.x: version "1.0.4" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" @@ -4589,10 +4746,28 @@ tryit@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" +tslint@^4.5.1: + version "4.5.1" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-4.5.1.tgz#05356871bef23a434906734006fc188336ba824b" + dependencies: + babel-code-frame "^6.20.0" + colors "^1.1.2" + diff "^3.0.1" + findup-sync "~0.3.0" + glob "^7.1.1" + optimist "~0.6.0" + resolve "^1.1.7" + tsutils "^1.1.0" + update-notifier "^2.0.0" + tsscmp@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/tsscmp/-/tsscmp-1.0.5.tgz#7dc4a33af71581ab4337da91d85ca5427ebd9a97" +tsutils@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.1.0.tgz#94e0c267624eeb1b63561ba8ec0bcff71b4e2872" + tunnel-agent@~0.4.1: version "0.4.3" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" @@ -4626,6 +4801,10 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" +typescript@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.1.tgz#4862b662b988a4c8ff691cc7969622d24db76ae9" + ua-parser-js@^0.7.9: version "0.7.12" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb" @@ -4664,10 +4843,39 @@ ultron@1.0.x: version "1.0.2" resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.0.2.tgz#ace116ab557cd197386a4e88f4685378c8b2e4fa" +unique-string@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" + dependencies: + crypto-random-string "^1.0.0" + unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" +unzip-response@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" + +update-notifier@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.1.0.tgz#ec0c1e53536b76647a24b77cb83966d9315123d9" + dependencies: + boxen "^1.0.0" + chalk "^1.0.0" + configstore "^3.0.0" + is-npm "^1.0.0" + latest-version "^3.0.0" + lazy-req "^2.0.0" + semver-diff "^2.0.0" + xdg-basedir "^3.0.0" + +url-parse-lax@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" + dependencies: + prepend-http "^1.0.1" + user-home@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" @@ -4768,7 +4976,7 @@ which-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" -which@^1.0.5, which@^1.1.1, which@^1.2.11, which@^1.2.9: +which@^1.0.5, which@^1.1.1, which@^1.2.11, which@^1.2.8, which@^1.2.9: version "1.2.12" resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192" dependencies: @@ -4780,6 +4988,12 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.1" +widest-line@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-1.0.0.tgz#0c09c85c2a94683d0d7eaf8ee097d564bf0e105c" + dependencies: + string-width "^1.0.1" + window-size@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" @@ -4818,7 +5032,7 @@ wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" -write-file-atomic@^1.2.0: +write-file-atomic@^1.1.2, write-file-atomic@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.1.tgz#7d45ba32316328dd1ec7d90f60ebc0d845bb759a" dependencies: @@ -4847,6 +5061,10 @@ xcode@^0.8.9: pegjs "0.9.0" simple-plist "0.1.4" +xdg-basedir@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" + "xml-name-validator@>= 2.0.1 < 3.0.0": version "2.0.1" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635" From a52cbdd70f5971e9dcd9f99a258980d9f3790ecb Mon Sep 17 00:00:00 2001 From: Wyatt McBain Date: Fri, 3 Mar 2017 22:02:00 -0500 Subject: [PATCH 2/3] intl updates --- .babelrc | 2 +- .gitignore | 2 + .vscode/tasks.json | 11 ++++ index.android.js | 2 +- index.ios.js | 2 +- package.json | 2 +- scripts/buildLocalizedStrings.js | 6 +- {intl => src/intl}/locales/_default.json | 0 .../intl/locales/default.tsx | 0 .../intl}/messages/src/ui/scenes/Home.json | 0 src/redux/ducks/intl.tsx | 39 +++++++++---- src/redux/ducks/lib/{intl.js => intl.tsx} | 8 +-- src/redux/ducks/nav.tsx | 28 ++++----- src/types/actions.tsx | 2 +- src/types/intl.tsx | 17 ------ src/types/nav.tsx | 57 ------------------- 16 files changed, 66 insertions(+), 112 deletions(-) create mode 100644 .vscode/tasks.json rename {intl => src/intl}/locales/_default.json (100%) rename intl/locales/default.js => src/intl/locales/default.tsx (100%) rename {intl => src/intl}/messages/src/ui/scenes/Home.json (100%) rename src/redux/ducks/lib/{intl.js => intl.tsx} (78%) delete mode 100644 src/types/intl.tsx delete mode 100644 src/types/nav.tsx diff --git a/.babelrc b/.babelrc index e9956da..5a92b61 100644 --- a/.babelrc +++ b/.babelrc @@ -5,7 +5,7 @@ "plugins": [ [ "react-intl", { - "messagesDir": "./intl/messages", + "messagesDir": "./src/intl/messages", "enforceDescriptions": false } ] diff --git a/.gitignore b/.gitignore index 7b4f2ca..f8ae954 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,5 @@ fastlane/screenshots coverage/ flow-typed/npm + +build/ diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..1d769aa --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,11 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "0.1.0", + "command": "tsc", + "isShellCommand": true, + "args": ["-w", "-p", "."], + "showOutput": "silent", + "isBackground": true, + "problemMatcher": "$tsc-watch" +} \ No newline at end of file diff --git a/index.android.js b/index.android.js index de7b966..d137250 100644 --- a/index.android.js +++ b/index.android.js @@ -1 +1 @@ -import './src/main' +import './build/main' diff --git a/index.ios.js b/index.ios.js index de7b966..d137250 100644 --- a/index.ios.js +++ b/index.ios.js @@ -1 +1 @@ -import './src/main' +import './build/main' diff --git a/package.json b/package.json index 79fbfc0..a2fd246 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "/__tests__/__setup__.js" ], "modulePaths": [ - "src", + "build", "/node_modules/" ], "setupFiles": [ diff --git a/scripts/buildLocalizedStrings.js b/scripts/buildLocalizedStrings.js index a146357..5a8bdcb 100644 --- a/scripts/buildLocalizedStrings.js +++ b/scripts/buildLocalizedStrings.js @@ -11,8 +11,8 @@ const fs = require('fs') const globSync = require('glob').sync const mkdirpSync = require('mkdirp').sync -const filePattern = './intl/messages/**/*.json' -const outputDir = './intl/locales/' +const filePattern = './src/intl/messages/**/*.json' +const outputDir = './src/intl/locales/' const messages = globSync(filePattern) .map((filename) => fs.readFileSync(filename, 'utf8')) @@ -35,4 +35,4 @@ const defaultJson = JSON.stringify(JSON.parse(`{ "en": ${messagesJson} }`), null // This is what we send for translations fs.writeFileSync(outputDir + '_default.json', defaultJson, null, 2) // This is `en`, our default locale -fs.writeFileSync(outputDir + 'default.js', `/* eslint-disable quotes */\nexport default ${messagesJson}\n`, null, 2) +fs.writeFileSync(outputDir + 'default.tsx', `/* eslint-disable quotes */\nexport default ${messagesJson}\n`, null, 2) diff --git a/intl/locales/_default.json b/src/intl/locales/_default.json similarity index 100% rename from intl/locales/_default.json rename to src/intl/locales/_default.json diff --git a/intl/locales/default.js b/src/intl/locales/default.tsx similarity index 100% rename from intl/locales/default.js rename to src/intl/locales/default.tsx diff --git a/intl/messages/src/ui/scenes/Home.json b/src/intl/messages/src/ui/scenes/Home.json similarity index 100% rename from intl/messages/src/ui/scenes/Home.json rename to src/intl/messages/src/ui/scenes/Home.json diff --git a/src/redux/ducks/intl.tsx b/src/redux/ducks/intl.tsx index 1b58d24..3b94ffe 100644 --- a/src/redux/ducks/intl.tsx +++ b/src/redux/ducks/intl.tsx @@ -1,13 +1,27 @@ -/* @flow */ - -import type { - IntlState, - SupportedLocale, - Action -} from '../../types' +import { BasicAction } from '../../types' import messages from './lib/intl' +export interface SetLocaleAction { + type: string, + payload: { + locale: string + } +} + +const isSetLocaleAction = (action: any): action is SetLocaleAction => { + return action.payload !== undefined + && action.payload.locale !== undefined +} + +export interface IntlState { + defaultLocale: string, + currentLocale: string, + supportedLocales: string[], + isDirty: boolean, + messages: { [key: string]: { [key: string]: string } } +} + export const initialState = { defaultLocale: 'en', currentLocale: 'en', @@ -23,12 +37,15 @@ import { LOCALE_DID_UPDATE } from './constants' -export default (state: IntlState = initialState, action?: Action): IntlState => { +export default (state: IntlState = initialState, action?: BasicAction | SetLocaleAction): IntlState => { if (!action) return state switch (action.type) { case SET_LOCALE: + if (!isSetLocaleAction(action)) return state + if (state.supportedLocales.indexOf(action.payload.locale) === -1) return state + return { ...state, currentLocale: action.payload.locale @@ -50,11 +67,11 @@ export default (state: IntlState = initialState, action?: Action): IntlState => } } -export const setLocale = (locale: SupportedLocale): Action => ({ +export const setLocale = (locale: string): SetLocaleAction => ({ type: SET_LOCALE, payload: { locale } }) -export const localeShouldUpdate = (): Action => ({ type: LOCALE_SHOULD_UPDATE }) +export const localeShouldUpdate = (): BasicAction => ({ type: LOCALE_SHOULD_UPDATE }) -export const localeDidUpdate = (): Action => ({ type: LOCALE_DID_UPDATE }) +export const localeDidUpdate = (): BasicAction => ({ type: LOCALE_DID_UPDATE }) diff --git a/src/redux/ducks/lib/intl.js b/src/redux/ducks/lib/intl.tsx similarity index 78% rename from src/redux/ducks/lib/intl.js rename to src/redux/ducks/lib/intl.tsx index a6e00df..f549b33 100644 --- a/src/redux/ducks/lib/intl.js +++ b/src/redux/ducks/lib/intl.tsx @@ -1,20 +1,18 @@ -/* @flow */ - import { addLocaleData } from 'react-intl' // When adding a support for a new locale you'll want to pull // locale data here from react-intl. Note that regional locales // such as en-UK are included as part of the greater set of // locale data associated with the country code. -import en from 'react-intl/locale-data/en' +import * as en from 'react-intl/locale-data/en' // You then destructure the import and add the locale data here. addLocaleData([...en]) // Import the actual translated messages keyed by id here. -import enMessages from '../../../../intl/locales/default' +import enMessages from '../../../intl/locales/default' // Add to this export and then 🚀 export default { - en: enMessages + 'en': enMessages } diff --git a/src/redux/ducks/nav.tsx b/src/redux/ducks/nav.tsx index 288bee8..7648ce4 100644 --- a/src/redux/ducks/nav.tsx +++ b/src/redux/ducks/nav.tsx @@ -10,6 +10,18 @@ import routes, { export const PUSH = '@appPlayground/routes/PUSH' export const POP = '@appPlayground/routes/POP' +export interface NavAction { + type: string, + payload: { + route: Route + } +} + +const isNavAction = (action: any): action is NavAction => { + return action.payload !== undefined + && action.payload.route !== undefined +} + const directionByPush = (type: PushType): PushDirection => { switch (type) { case (PushType.default): return PushDirection.horizontal @@ -30,25 +42,14 @@ const initialState = { routes: [routes.home] } -export interface NavAction { - type: string, - payload: { - route: Route - } -} - -const isNavAction = (action: any): action is NavAction => { - return action.payload !== undefined - && action.payload.route !== undefined -} - export default (state: NavState = initialState, action?: BasicAction | NavAction): NavState => { if (!action) return state switch (action.type) { case PUSH: - if (!isNavAction(action)) return + if (!isNavAction(action)) return state + const route = action.payload.route const routes = state.routes.slice() routes.push(route) @@ -62,7 +63,6 @@ export default (state: NavState = initialState, action?: BasicAction | NavAction case POP: if (state.index <= 0) { return state } - // es lint is complaining, so humoring it const popRoutes = state.routes const lastRoute = popRoutes.pop() diff --git a/src/types/actions.tsx b/src/types/actions.tsx index c2d5666..7f98ee5 100644 --- a/src/types/actions.tsx +++ b/src/types/actions.tsx @@ -1 +1 @@ -export type BasicAction = { type: String } +export type BasicAction = { type: string } diff --git a/src/types/intl.tsx b/src/types/intl.tsx deleted file mode 100644 index 5fafc9e..0000000 --- a/src/types/intl.tsx +++ /dev/null @@ -1,17 +0,0 @@ -/* @flow */ - -export interface IntlState { - defaultLocale: string, - currentLocale: string, - supportedLocales: SupportedLocale[], - isDirty: boolean, - messages: { - [key: string]: { - id: string, - defaultMessage: string - } - } -}; - -// TODO: When locals are added, a case should be added here. -export type SupportedLocale = 'en'; diff --git a/src/types/nav.tsx b/src/types/nav.tsx deleted file mode 100644 index 0d24947..0000000 --- a/src/types/nav.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import * as React from 'react' -import { ReactElement } from 'react' - -import { - PUSH, - POP -} from '../redux/ducks/constants' - -import { - MODAL, - DEFAULT, - VERTICAL, - HORIZONTAL -} from '../ui/routes/constants' - -import { - SCENE, - HEADER -} from '../ui/routes/interpolators/constants' - -import { NavigationSceneRendererProps } from 'react-native' - -export interface SubNavProps { - onNavigateBack: Function | null -} - -export type SubNavRenderer = (navProps: SubNavProps) => ReactElement | null - -export type InterpolatorType = 'scene' | 'header' - -export type Interpolator= (props: NavigationSceneRendererProps) => Object - -export type NavInterpolator = { - [key: string]: Interpolator -} - -export type NavPushType = 'modal' | 'default' - -export type RouteType = 'push' | 'pop' - -export type PushDirection = 'vertical' | 'horizontal' - -export interface Route { - key: string, - title: string, - pushType?: NavPushType, - rightNavRenderer?: SubNavRenderer, - leftNavRenderer?: SubNavRenderer, - interpolator?: NavInterpolator -} - -export interface NavState { - index: number, - routes: Route[], - pushDirection: PushDirection, - interpolator?: NavInterpolator -} From 20d362faba2ff367aea699e047dc0ec7cd6606a3 Mon Sep 17 00:00:00 2001 From: Wyatt McBain Date: Fri, 3 Mar 2017 22:09:44 -0500 Subject: [PATCH 3/3] intl --- src/app/Root.js | 2 -- src/main.js | 2 -- src/redux/ducks/config.tsx | 7 ++++--- src/redux/ducks/constants.tsx | 6 ------ src/redux/ducks/device.tsx | 7 +++---- src/redux/ducks/intl.tsx | 10 ++++------ src/redux/epics/intl.js | 14 ------------- src/redux/epics/intl.tsx | 8 ++++++++ src/redux/{initial.js => initial.tsx} | 2 -- src/redux/initialState.js | 2 -- src/types.tsx | 4 ---- src/types/core.tsx | 20 +++++-------------- src/ui/RootContainer.js | 2 -- .../custom/NavigationHeaderInterpolatable.js | 2 -- src/ui/factories/intl.js | 2 -- src/ui/scenes/Home.js | 2 -- src/ui/scenes/Left.js | 2 -- src/ui/scenes/Modal.js | 2 -- src/ui/scenes/Right.js | 2 -- 19 files changed, 24 insertions(+), 74 deletions(-) delete mode 100644 src/redux/ducks/constants.tsx delete mode 100644 src/redux/epics/intl.js create mode 100644 src/redux/epics/intl.tsx rename src/redux/{initial.js => initial.tsx} (97%) diff --git a/src/app/Root.js b/src/app/Root.js index 1dc7f52..6f7b21a 100644 --- a/src/app/Root.js +++ b/src/app/Root.js @@ -1,5 +1,3 @@ -/* @flow */ - // React import React, { Component } from 'react' // eslint-disable-line no-unused-vars diff --git a/src/main.js b/src/main.js index 1cc97df..0789d2f 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,3 @@ -/* @flow */ - // React import React from 'react' // eslint-disable-line no-unused-vars import { AppRegistry, AsyncStorage, Platform } from 'react-native' diff --git a/src/redux/ducks/config.tsx b/src/redux/ducks/config.tsx index f7d49b5..f55eb2c 100644 --- a/src/redux/ducks/config.tsx +++ b/src/redux/ducks/config.tsx @@ -1,6 +1,7 @@ -/* @flow */ - -import { ConfigState } from '../../types' +export interface ConfigState { + appName: string, + appVersion: string +} const initialState = { appName: '', diff --git a/src/redux/ducks/constants.tsx b/src/redux/ducks/constants.tsx deleted file mode 100644 index 507f780..0000000 --- a/src/redux/ducks/constants.tsx +++ /dev/null @@ -1,6 +0,0 @@ - - -// Localization -export const SET_LOCALE = '@ratebeer/intl/SET_LOCALE' -export const LOCALE_SHOULD_UPDATE = '@ratebeer/intl/LOCALE_SHOULD_UPDATE' -export const LOCALE_DID_UPDATE = '@ratebeer/intl/LOCALE_DID_UPDATE' diff --git a/src/redux/ducks/device.tsx b/src/redux/ducks/device.tsx index 980c9d6..0e82795 100644 --- a/src/redux/ducks/device.tsx +++ b/src/redux/ducks/device.tsx @@ -1,7 +1,6 @@ -/* @flow */ - -interface DeviceState { - isReactNative: boolean +export interface DeviceState { + isReactNative: boolean, + platform: string } const initialState = { diff --git a/src/redux/ducks/intl.tsx b/src/redux/ducks/intl.tsx index 3b94ffe..f6c31a5 100644 --- a/src/redux/ducks/intl.tsx +++ b/src/redux/ducks/intl.tsx @@ -2,6 +2,10 @@ import { BasicAction } from '../../types' import messages from './lib/intl' +export const SET_LOCALE = '@ratebeer/intl/SET_LOCALE' +export const LOCALE_SHOULD_UPDATE = '@ratebeer/intl/LOCALE_SHOULD_UPDATE' +export const LOCALE_DID_UPDATE = '@ratebeer/intl/LOCALE_DID_UPDATE' + export interface SetLocaleAction { type: string, payload: { @@ -31,12 +35,6 @@ export const initialState = { } Object.freeze(initialState) -import { - SET_LOCALE, - LOCALE_SHOULD_UPDATE, - LOCALE_DID_UPDATE -} from './constants' - export default (state: IntlState = initialState, action?: BasicAction | SetLocaleAction): IntlState => { if (!action) return state diff --git a/src/redux/epics/intl.js b/src/redux/epics/intl.js deleted file mode 100644 index 877cea0..0000000 --- a/src/redux/epics/intl.js +++ /dev/null @@ -1,14 +0,0 @@ -/* @flow */ - -import 'rxjs/add/operator/map' - -import { SET_LOCALE } from '../ducks/constants' -import { localeShouldUpdate } from '../ducks/intl' - -// Using flow types with epics is a bit weird as parameter is a stream -/* eslint-disable flowtype/require-parameter-type, flowtype/require-return-type */ - -// $FlowFixMe -export const localeUpdateEpic = (action$, store) => - action$.ofType(SET_LOCALE) - .map((action) => localeShouldUpdate()) diff --git a/src/redux/epics/intl.tsx b/src/redux/epics/intl.tsx new file mode 100644 index 0000000..513228c --- /dev/null +++ b/src/redux/epics/intl.tsx @@ -0,0 +1,8 @@ +import 'rxjs/add/operator/map' + +import { SET_LOCALE } from '../ducks/intl' +import { localeShouldUpdate } from '../ducks/intl' + +export const localeUpdateEpic = (action$, store) => + action$.ofType(SET_LOCALE) + .map((action) => localeShouldUpdate()) diff --git a/src/redux/initial.js b/src/redux/initial.tsx similarity index 97% rename from src/redux/initial.js rename to src/redux/initial.tsx index 319d274..e0070c4 100644 --- a/src/redux/initial.js +++ b/src/redux/initial.tsx @@ -1,5 +1,3 @@ -/* @flow */ - import { combineReducers } from 'redux' import config from './ducks/config' diff --git a/src/redux/initialState.js b/src/redux/initialState.js index 5a9bd05..ca9ef39 100644 --- a/src/redux/initialState.js +++ b/src/redux/initialState.js @@ -1,5 +1,3 @@ -/* @flow */ - import config from './ducks/config' import device from './ducks/device' import nav from './ducks/nav' diff --git a/src/types.tsx b/src/types.tsx index 5bb0ef6..200647b 100644 --- a/src/types.tsx +++ b/src/types.tsx @@ -1,6 +1,2 @@ -/* @flow */ - -export * from './types/nav' -export * from './types/intl' export * from './types/core' export * from './types/actions' diff --git a/src/types/core.tsx b/src/types/core.tsx index 50bfa83..843da9d 100644 --- a/src/types/core.tsx +++ b/src/types/core.tsx @@ -1,22 +1,12 @@ -/* @flow */ - -import { NavState } from './nav' -// import type { IntlState } from './intl' - -export interface ConfigState { - appName: string, - appVersion: string -} - -export interface DeviceState { - isReactNative: boolean, - platform: string -}; +import { NavState } from '../redux/ducks/nav' +import { IntlState } from '../redux/ducks/intl' +import { DeviceState } from '../redux/ducks/device' +import { ConfigState } from '../redux/ducks/config' export type NativeState = { config: ConfigState, device: DeviceState, - // intl: IntlState, + intl: IntlState, apollo: Object, nav: NavState }; diff --git a/src/ui/RootContainer.js b/src/ui/RootContainer.js index 7ec1723..7311e98 100644 --- a/src/ui/RootContainer.js +++ b/src/ui/RootContainer.js @@ -1,5 +1,3 @@ -/* @flow */ - import React, { Component } from 'react' // eslint-disable-line no-unused-vars import { NavigationExperimental, Platform, BackAndroid } from 'react-native' diff --git a/src/ui/custom/NavigationHeaderInterpolatable.js b/src/ui/custom/NavigationHeaderInterpolatable.js index d5f428e..a55a572 100644 --- a/src/ui/custom/NavigationHeaderInterpolatable.js +++ b/src/ui/custom/NavigationHeaderInterpolatable.js @@ -1,5 +1,3 @@ -/* @flow */ - import React from 'react' // eslint-disable-line no-unused-vars import { NavigationExperimental } from 'react-native' import type { NavigationSceneRendererProps } from 'react-native' // eslint-disable-line no-duplicate-imports diff --git a/src/ui/factories/intl.js b/src/ui/factories/intl.js index 44d312f..46d11f9 100644 --- a/src/ui/factories/intl.js +++ b/src/ui/factories/intl.js @@ -1,5 +1,3 @@ -/* @flow */ - import React from 'react' // eslint-disable-line no-unused-vars import { Text } from 'react-native' diff --git a/src/ui/scenes/Home.js b/src/ui/scenes/Home.js index 33f77e5..3216092 100644 --- a/src/ui/scenes/Home.js +++ b/src/ui/scenes/Home.js @@ -1,5 +1,3 @@ -/* @flow */ - import React, { Component } from 'react' // eslint-disable-line no-unused-vars import { StyleSheet, diff --git a/src/ui/scenes/Left.js b/src/ui/scenes/Left.js index 055d7de..ded8e9e 100644 --- a/src/ui/scenes/Left.js +++ b/src/ui/scenes/Left.js @@ -1,5 +1,3 @@ -/* @flow */ - import React, { Component } from 'react' // eslint-disable-line no-unused-vars import { StyleSheet, diff --git a/src/ui/scenes/Modal.js b/src/ui/scenes/Modal.js index 31f7d73..62360f0 100644 --- a/src/ui/scenes/Modal.js +++ b/src/ui/scenes/Modal.js @@ -1,5 +1,3 @@ -/* @flow */ - import React, { Component } from 'react' // eslint-disable-line no-unused-vars import { StyleSheet, diff --git a/src/ui/scenes/Right.js b/src/ui/scenes/Right.js index 3aeaed7..fdad1ba 100644 --- a/src/ui/scenes/Right.js +++ b/src/ui/scenes/Right.js @@ -1,5 +1,3 @@ -/* @flow */ - import React, { Component } from 'react' // eslint-disable-line no-unused-vars import { StyleSheet,