Browse Source
Fix storybook and provide __STORYBOOK_ENV__ global
master
meriadec
7 years ago
No known key found for this signature in database
GPG Key ID: 1D2FC2305E2CB399
6 changed files with
16 additions and
11 deletions
-
.eslintrc
-
flow-defs/globals.js
-
src/globals.js
-
src/renderer/createStore.js
-
src/renderer/init.js
-
webpack/plugins.js
|
|
@ -11,6 +11,7 @@ |
|
|
|
"__PRINT_MODE__": false, |
|
|
|
"__GLOBAL_STYLES__": false, |
|
|
|
"__APP_VERSION__": false, |
|
|
|
"__STORYBOOK_ENV__": false, |
|
|
|
"__static": false, |
|
|
|
"window": false, |
|
|
|
"document": false, |
|
|
|
|
|
@ -8,6 +8,7 @@ declare var __PRINT_MODE__: string |
|
|
|
declare var __SENTRY_URL__: string |
|
|
|
declare var __GLOBAL_STYLES__: string |
|
|
|
declare var __APP_VERSION__: string |
|
|
|
declare var __STORYBOOK_ENV__: string |
|
|
|
declare var __static: string |
|
|
|
declare var describe: Function |
|
|
|
declare var test: Function |
|
|
|
|
|
@ -1,8 +1,13 @@ |
|
|
|
// @flow
|
|
|
|
|
|
|
|
const { NODE_ENV } = process.env |
|
|
|
const { NODE_ENV, STORYBOOK_ENV } = process.env |
|
|
|
|
|
|
|
global.__ENV__ = NODE_ENV === 'development' ? NODE_ENV : 'production' |
|
|
|
global.__DEV__ = global.__ENV__ === 'development' |
|
|
|
global.__PROD__ = !global.__DEV__ |
|
|
|
global.__STORYBOOK_ENV__ = STORYBOOK_ENV === '1' |
|
|
|
global.__GLOBAL_STYLES__ = require('./styles/reset') |
|
|
|
|
|
|
|
if (STORYBOOK_ENV === '1') { |
|
|
|
global.__APP_VERSION__ = '1.0.0' |
|
|
|
} |
|
|
|
|
|
@ -6,7 +6,6 @@ import thunk from 'redux-thunk' |
|
|
|
import createHistory from 'history/createHashHistory' |
|
|
|
import type { HashHistory } from 'history' |
|
|
|
import logger from 'middlewares/logger' |
|
|
|
import sentry from 'middlewares/sentry' |
|
|
|
import reducers from 'reducers' |
|
|
|
|
|
|
|
type Props = { |
|
|
@ -20,7 +19,10 @@ export default ({ state, history, dbMiddleware }: Props) => { |
|
|
|
if (!history) { |
|
|
|
history = createHistory() |
|
|
|
} |
|
|
|
const middlewares = [routerMiddleware(history), thunk, logger, sentry] |
|
|
|
const middlewares = [routerMiddleware(history), thunk, logger] |
|
|
|
if (!__STORYBOOK_ENV__) { |
|
|
|
middlewares.push(require('middlewares/sentry').default) |
|
|
|
} |
|
|
|
if (dbMiddleware) { |
|
|
|
middlewares.push(dbMiddleware) |
|
|
|
} |
|
|
|
|
|
@ -11,6 +11,8 @@ import moment from 'moment' |
|
|
|
import createStore from 'renderer/createStore' |
|
|
|
import events from 'renderer/events' |
|
|
|
|
|
|
|
import { enableGlobalTab, isGlobalTabEnabled } from 'config/global-tab' |
|
|
|
|
|
|
|
import { fetchAccounts } from 'actions/accounts' |
|
|
|
import { fetchSettings } from 'actions/settings' |
|
|
|
import { isLocked } from 'reducers/application' |
|
|
@ -29,15 +31,8 @@ import 'styles/global' |
|
|
|
|
|
|
|
const rootNode = document.getElementById('app') |
|
|
|
|
|
|
|
// Github like focus style:
|
|
|
|
// - focus states are not visible by default
|
|
|
|
// - first time user hit tab, enable global tab to see focus states
|
|
|
|
let IS_GLOBAL_TAB_ENABLED = false |
|
|
|
const TAB_KEY = 9 |
|
|
|
|
|
|
|
export const isGlobalTabEnabled = () => IS_GLOBAL_TAB_ENABLED |
|
|
|
export const enableGlobalTab = () => (IS_GLOBAL_TAB_ENABLED = true) |
|
|
|
|
|
|
|
async function init() { |
|
|
|
if (process.env.LEDGER_RESET_ALL) { |
|
|
|
await hardReset() |
|
|
|
|
|
@ -3,7 +3,7 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') |
|
|
|
const pkg = require('../package.json') |
|
|
|
require('../src/globals') |
|
|
|
|
|
|
|
const { BUNDLE_ANALYZER, SENTRY_URL } = process.env |
|
|
|
const { BUNDLE_ANALYZER, SENTRY_URL, STORYBOOK_ENV } = process.env |
|
|
|
|
|
|
|
module.exports = type => { |
|
|
|
const plugins = [ |
|
|
@ -13,6 +13,7 @@ module.exports = type => { |
|
|
|
__DEV__, |
|
|
|
__PROD__, |
|
|
|
__SENTRY_URL__: JSON.stringify(SENTRY_URL || null), |
|
|
|
__STORYBOOK_ENV__: JSON.stringify(STORYBOOK_ENV), |
|
|
|
'process.env.NODE_ENV': JSON.stringify(__ENV__), |
|
|
|
}), |
|
|
|
] |
|
|
|