Browse Source

Merge pull request #85 from torkelrogstad/lint

Lint
renovate/lint-staged-8.x
JimmyMow 7 years ago
committed by GitHub
parent
commit
3795936861
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .eslintrc
  2. 2
      app/components/ChannelForm/StepOne.js
  3. 2
      app/components/LndSyncing/LndSyncing.js
  4. 14
      app/containers/Root.js
  5. 22
      app/index.js
  6. 2
      app/lnd/config/index.js
  7. 2
      app/lnd/lib/lightning.js
  8. 42
      app/lnd/utils/index.js
  9. 2
      app/reducers/address.js
  10. 4
      app/reducers/channels.js
  11. 4
      app/reducers/lnd.js
  12. 6
      app/reducers/network.js
  13. 2
      app/reducers/peers.js
  14. 10
      app/routes/channels/components/Channels.js
  15. 2
      app/routes/peers/components/Peers.js
  16. 34
      app/store/configureStore.dev.js
  17. 4
      app/store/configureStore.js
  18. 2
      internals/mocks/fileMock.js
  19. 16
      internals/scripts/CheckBuiltsExist.js
  20. 8
      internals/scripts/CheckNodeEnv.js
  21. 3
      test/components/Nav.spec.js
  22. 6
      test/example.js
  23. 11
      test/reducers/__snapshots__/peers.spec.js.snap
  24. 12
      test/runTests.js
  25. 6
      webpack.config.base.js
  26. 4
      webpack.config.eslint.js
  27. 16
      webpack.config.main.prod.js
  28. 18
      webpack.config.renderer.dev.dll.js
  29. 20
      webpack.config.renderer.prod.js

2
.eslintrc

@ -11,7 +11,7 @@
}, },
"rules": { "rules": {
"comma-dangle": ["error", "never"], "comma-dangle": ["error", "never"],
"semi": 0, "semi": ["error", "never"],
"indent": 2, "indent": 2,
"jsx-quotes": ["error", "prefer-single"], "jsx-quotes": ["error", "prefer-single"],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],

2
app/components/ChannelForm/StepOne.js

@ -5,7 +5,7 @@ import styles from './StepOne.scss'
class StepOne extends Component { class StepOne extends Component {
constructor(props) { constructor(props) {
super(props); super(props)
this.state = { this.state = {
peers: props.peers, peers: props.peers,
searchQuery: '' searchQuery: ''

2
app/components/LndSyncing/LndSyncing.js

@ -4,7 +4,7 @@ import styles from './LndSyncing.scss'
class LndSyncing extends Component { class LndSyncing extends Component {
constructor(props) { constructor(props) {
super(props); super(props)
this.state = { this.state = {
facts: [ facts: [
{ {

14
app/containers/Root.js

@ -3,9 +3,10 @@ import React from 'react'
import { Provider, connect } from 'react-redux' import { Provider, connect } from 'react-redux'
import { ConnectedRouter } from 'react-router-redux' import { ConnectedRouter } from 'react-router-redux'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { fetchBlockHeight, lndSelectors } from 'reducers/lnd'
import LoadingBolt from 'components/LoadingBolt' import LoadingBolt from '../components/LoadingBolt'
import LndSyncing from 'components/LndSyncing' import LndSyncing from '../components/LndSyncing'
import { fetchBlockHeight, lndSelectors } from '../reducers/lnd'
import Routes from '../routes' import Routes from '../routes'
const mapDispatchToProps = { const mapDispatchToProps = {
@ -18,11 +19,6 @@ const mapStateToProps = state => ({
syncPercentage: lndSelectors.syncPercentage(state) syncPercentage: lndSelectors.syncPercentage(state)
}) })
type RootType = {
store: {},
history: {}
};
const Root = ({ const Root = ({
store, store,
history, history,
@ -40,7 +36,7 @@ const Root = ({
/> />
) )
} }
// Don't launch the app without gRPC connection // Don't launch the app without gRPC connection
if (!lnd.grpcStarted) { return <LoadingBolt /> } if (!lnd.grpcStarted) { return <LoadingBolt /> }

22
app/index.js

@ -1,27 +1,27 @@
import React from 'react'; import React from 'react'
import { render } from 'react-dom'; import { render } from 'react-dom'
import { AppContainer } from 'react-hot-loader'; import { AppContainer } from 'react-hot-loader'
import Root from './containers/Root'; import Root from './containers/Root'
import { configureStore, history } from './store/configureStore'; import { configureStore, history } from './store/configureStore'
import './app.global.scss'; import './app.global.scss'
const store = configureStore(); const store = configureStore()
render( render(
<AppContainer> <AppContainer>
<Root store={store} history={history} /> <Root store={store} history={history} />
</AppContainer>, </AppContainer>,
document.getElementById('root') document.getElementById('root')
); )
if (module.hot) { if (module.hot) {
module.hot.accept('./containers/Root', () => { module.hot.accept('./containers/Root', () => {
const NextRoot = require('./containers/Root'); // eslint-disable-line global-require const NextRoot = require('./containers/Root') // eslint-disable-line global-require
render( render(
<AppContainer> <AppContainer>
<NextRoot store={store} history={history} /> <NextRoot store={store} history={history} />
</AppContainer>, </AppContainer>,
document.getElementById('root') document.getElementById('root')
); )
}); })
} }

2
app/lnd/config/index.js

@ -8,7 +8,7 @@ import { join } from 'path'
let loc let loc
switch (platform()) { switch (platform()) {
case 'darwin': case 'darwin':
loc = 'Library/Application\ Support/Lnd/tls.cert' loc = 'Library/Application Support/Lnd/tls.cert'
break break
case 'linux': case 'linux':
loc = '.lnd/tls.cert' loc = '.lnd/tls.cert'

2
app/lnd/lib/lightning.js

@ -6,7 +6,7 @@ import config from '../config'
module.exports = (rpcpath, host) => { module.exports = (rpcpath, host) => {
const lndCert = fs.readFileSync(config.cert) const lndCert = fs.readFileSync(config.cert)
const credentials = grpc.credentials.createSsl(lndCert) const credentials = grpc.credentials.createSsl(lndCert)
const rpc = grpc.load(path.join(__dirname, 'rpc.proto')) const rpc = grpc.load(path.join(__dirname, 'rpc.proto'))
return new rpc.lnrpc.Lightning(host, credentials) return new rpc.lnrpc.Lightning(host, credentials)

42
app/lnd/utils/index.js

@ -0,0 +1,42 @@
import zbase32 from 'zbase32'
function convertBigEndianBufferToLong(longBuffer) {
let longValue = 0
const byteArray = Buffer.from(longBuffer).swap64()
for (let i = byteArray.length - 1; i >= 0; i -= 1) {
longValue = (longValue * 256) + byteArray[i]
}
return longValue
}
export function decodeInvoice(payreq) {
const payreqBase32 = zbase32.decode(payreq)
const bufferHexRotated = Buffer.from(payreqBase32).toString('hex')
const bufferHex = bufferHexRotated.substr(bufferHexRotated.length - 1, bufferHexRotated.length)
+ bufferHexRotated.substr(0, bufferHexRotated.length - 1)
const buffer = Buffer.from(bufferHex, 'hex')
const pubkeyBuffer = buffer.slice(0, 33)
const pubkey = pubkeyBuffer.toString('hex')
const paymentHashBuffer = buffer.slice(33, 65)
const paymentHashHex = paymentHashBuffer.toString('hex')
const valueBuffer = buffer.slice(65, 73)
const amount = convertBigEndianBufferToLong(valueBuffer)
return {
payreq,
pubkey,
amount,
r_hash: paymentHashHex
}
}
export default {
decodeInvoice
}

2
app/reducers/address.js

@ -5,7 +5,7 @@ import { ipcRenderer } from 'electron'
export const GET_ADDRESS = 'GET_ADDRESS' export const GET_ADDRESS = 'GET_ADDRESS'
export const RECEIVE_ADDRESS = 'RECEIVE_ADDRESS' export const RECEIVE_ADDRESS = 'RECEIVE_ADDRESS'
// LND expects types to be sent as int, so this object will allow mapping from string to int // LND expects types to be sent as int, so this object will allow mapping from string to int
const addressTypes = { const addressTypes = {
p2wkh: 0, p2wkh: 0,
np2wkh: 1, np2wkh: 1,

4
app/reducers/channels.js

@ -200,13 +200,13 @@ export const channelGraphData = (event, data) => (dispatch, getState) => {
dispatch(fetchDescribeNetwork()) dispatch(fetchDescribeNetwork())
// loop through the channel updates // loop through the channel updates
for (let i = 0; i < channel_updates.length; i++) { for (let i = 0; i < channel_updates.length; i += 1) {
const channel_update = channel_updates[i] const channel_update = channel_updates[i]
const { advertising_node, connecting_node } = channel_update const { advertising_node, connecting_node } = channel_update
// if our node is involved in this update we wanna show a notification // if our node is involved in this update we wanna show a notification
if (info.data.identity_pubkey === advertising_node || info.data.identity_pubkey === connecting_node) { if (info.data.identity_pubkey === advertising_node || info.data.identity_pubkey === connecting_node) {
// this channel has to do with the user, lets fetch a new channel list for them // this channel has to do with the user, lets fetch a new channel list for them
// TODO: full fetch is probably not necessary // TODO: full fetch is probably not necessary
dispatch(fetchChannels()) dispatch(fetchChannels())

4
app/reducers/lnd.js

@ -59,7 +59,7 @@ export const lndStdout = (event, line) => (dispatch) => {
trimmed = line.slice(line.indexOf('Catching up block hashes to height') + 'Catching up block hashes to height'.length).trim() trimmed = line.slice(line.indexOf('Catching up block hashes to height') + 'Catching up block hashes to height'.length).trim()
height = trimmed.match(/[-]{0,1}[\d.]*[\d]+/g)[0] height = trimmed.match(/[-]{0,1}[\d.]*[\d]+/g)[0]
} }
dispatch({ type: RECEIVE_LINE, lndBlockHeight: height }) dispatch({ type: RECEIVE_LINE, lndBlockHeight: height })
} }
@ -95,7 +95,7 @@ const ACTION_HANDLERS = {
[GET_BLOCK_HEIGHT]: state => ({ ...state, fetchingBlockHeight: true }), [GET_BLOCK_HEIGHT]: state => ({ ...state, fetchingBlockHeight: true }),
[RECEIVE_BLOCK_HEIGHT]: (state, { blockHeight }) => ({ ...state, blockHeight, fetchingBlockHeight: false }), [RECEIVE_BLOCK_HEIGHT]: (state, { blockHeight }) => ({ ...state, blockHeight, fetchingBlockHeight: false }),
[GRPC_DISCONNECTED]: state => ({ ...state, grpcStarted: false }), [GRPC_DISCONNECTED]: state => ({ ...state, grpcStarted: false }),
[GRPC_CONNECTED]: state => ({ ...state, grpcStarted: true }) [GRPC_CONNECTED]: state => ({ ...state, grpcStarted: true })
} }

6
app/reducers/network.js

@ -111,9 +111,9 @@ const ACTION_HANDLERS = {
), ),
[SET_CURRENT_CHANNEL]: (state, { selectedChannel }) => ({ ...state, selectedChannel }), [SET_CURRENT_CHANNEL]: (state, { selectedChannel }) => ({ ...state, selectedChannel }),
[SET_CURRENT_TAB]: (state, { currentTab }) => ({ ...state, currentTab }), [SET_CURRENT_TAB]: (state, { currentTab }) => ({ ...state, currentTab }),
[SET_CURRENT_PEER]: (state, { currentPeer }) => ({ ...state, currentPeer }), [SET_CURRENT_PEER]: (state, { currentPeer }) => ({ ...state, currentPeer }),
[UPDATE_PAY_REQ]: (state, { pay_req }) => ({ ...state, pay_req }) [UPDATE_PAY_REQ]: (state, { pay_req }) => ({ ...state, pay_req })
@ -149,7 +149,7 @@ const initialState = {
currentRoute: {} currentRoute: {}
}, },
selectedChannel: {}, selectedChannel: {},
currentTab: 1, currentTab: 1,
currentPeer: {}, currentPeer: {},

2
app/reducers/peers.js

@ -124,7 +124,7 @@ const ACTION_HANDLERS = {
[GET_PEERS]: state => ({ ...state, peersLoading: true }), [GET_PEERS]: state => ({ ...state, peersLoading: true }),
[RECEIVE_PEERS]: (state, { peers }) => ({ ...state, peersLoading: false, peers }), [RECEIVE_PEERS]: (state, { peers }) => ({ ...state, peersLoading: false, peers }),
[UPDATE_SEARCH_QUERY]: (state, { searchQuery }) => ({ ...state, searchQuery }) [UPDATE_SEARCH_QUERY]: (state, { searchQuery }) => ({ ...state, searchQuery })
} }

10
app/routes/channels/components/Channels.js

@ -22,7 +22,7 @@ class Channels extends Component {
componentWillMount() { componentWillMount() {
const { fetchChannels, fetchPeers } = this.props const { fetchChannels, fetchPeers } = this.props
fetchChannels() fetchChannels()
fetchPeers() fetchPeers()
} }
@ -64,7 +64,7 @@ class Channels extends Component {
fetchChannels() fetchChannels()
// wait for the svg to appear as child // wait for the svg to appear as child
const svgTimeout = setTimeout(() => { const svgTimeout = setTimeout(() => {
if (icon[0].tagName === 'svg') { if (icon[0].tagName === 'svg') {
// spin icon for 1 sec // spin icon for 1 sec
icon[0].style.animation = 'spin 1000ms linear 1' icon[0].style.animation = 'spin 1000ms linear 1'
@ -73,7 +73,7 @@ class Channels extends Component {
}, 1) }, 1)
// clear animation after the second so we can reuse it // clear animation after the second so we can reuse it
const refreshTimeout = setTimeout(() => { const refreshTimeout = setTimeout(() => {
icon[0].style.animation = '' icon[0].style.animation = ''
this.setState({ refreshing: false }) this.setState({ refreshing: false })
clearTimeout(refreshTimeout) clearTimeout(refreshTimeout)
@ -96,7 +96,7 @@ class Channels extends Component {
</div> </div>
</div> </div>
</header> </header>
<div className={styles.search}> <div className={styles.search}>
<label className={`${styles.label} ${styles.input}`} htmlFor='channelSearch'> <label className={`${styles.label} ${styles.input}`} htmlFor='channelSearch'>
<MdSearch /> <MdSearch />
@ -187,7 +187,7 @@ Channels.propTypes = {
channels: PropTypes.object.isRequired, channels: PropTypes.object.isRequired,
currentChannels: PropTypes.array.isRequired, currentChannels: PropTypes.array.isRequired,
nonActiveFilters: PropTypes.array.isRequired, nonActiveFilters: PropTypes.array.isRequired,
updateChannelSearchQuery: PropTypes.func.isRequired, updateChannelSearchQuery: PropTypes.func.isRequired,
setCurrentChannel: PropTypes.func.isRequired, setCurrentChannel: PropTypes.func.isRequired,
openChannelForm: PropTypes.func.isRequired, openChannelForm: PropTypes.func.isRequired,

2
app/routes/peers/components/Peers.js

@ -24,7 +24,7 @@ class Peers extends Component {
} }
render() { render() {
const { const {
fetchPeers, fetchPeers,
peerFormProps, peerFormProps,
setPeerForm, setPeerForm,

34
app/store/configureStore.dev.js

@ -6,31 +6,31 @@ import { createLogger } from 'redux-logger'
import rootReducer from '../reducers' import rootReducer from '../reducers'
import ipc from '../reducers/ipc' import ipc from '../reducers/ipc'
const history = createHashHistory(); const history = createHashHistory()
const configureStore = (initialState?: counterStateType) => { const configureStore = (initialState?: counterStateType) => {
// Redux Configuration // Redux Configuration
const middleware = []; const middleware = []
const enhancers = []; const enhancers = []
// Thunk Middleware // Thunk Middleware
middleware.push(thunk); middleware.push(thunk)
// Logging Middleware // Logging Middleware
const logger = createLogger({ const logger = createLogger({
level: 'info', level: 'info',
collapsed: true collapsed: true
}); })
middleware.push(logger); middleware.push(logger)
// Router Middleware // Router Middleware
const router = routerMiddleware(history); const router = routerMiddleware(history)
middleware.push(router); middleware.push(router)
// Redux DevTools Configuration // Redux DevTools Configuration
const actionCreators = { const actionCreators = {
...routerActions ...routerActions
}; }
// If Redux DevTools Extension is installed use it, otherwise use Redux compose // If Redux DevTools Extension is installed use it, otherwise use Redux compose
/* eslint-disable no-underscore-dangle */ /* eslint-disable no-underscore-dangle */
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
@ -38,23 +38,23 @@ const configureStore = (initialState?: counterStateType) => {
// Options: http://zalmoxisus.github.io/redux-devtools-extension/API/Arguments.html // Options: http://zalmoxisus.github.io/redux-devtools-extension/API/Arguments.html
actionCreators actionCreators
}) })
: compose; : compose
/* eslint-enable no-underscore-dangle */ /* eslint-enable no-underscore-dangle */
// Apply Middleware & Compose Enhancers // Apply Middleware & Compose Enhancers
enhancers.push(applyMiddleware(...middleware, ipc)); enhancers.push(applyMiddleware(...middleware, ipc))
const enhancer = composeEnhancers(...enhancers); const enhancer = composeEnhancers(...enhancers)
// Create Store // Create Store
const store = createStore(rootReducer, initialState, enhancer); const store = createStore(rootReducer, initialState, enhancer)
if (module.hot) { if (module.hot) {
module.hot.accept('../reducers', () => module.hot.accept('../reducers', () =>
store.replaceReducer(require('../reducers')) // eslint-disable-line global-require store.replaceReducer(require('../reducers')) // eslint-disable-line global-require
); )
} }
return store; return store
}; }
export default { configureStore, history }; export default { configureStore, history }

4
app/store/configureStore.js

@ -1,6 +1,6 @@
// @flow // @flow
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
module.exports = require('./configureStore.prod'); // eslint-disable-line global-require module.exports = require('./configureStore.prod') // eslint-disable-line global-require
} else { } else {
module.exports = require('./configureStore.dev'); // eslint-disable-line global-require module.exports = require('./configureStore.dev') // eslint-disable-line global-require
} }

2
internals/mocks/fileMock.js

@ -1 +1 @@
export default 'test-file-stub'; export default 'test-file-stub'

16
internals/scripts/CheckBuiltsExist.js

@ -1,24 +1,24 @@
// @flow // @flow
// Check if the renderer and main bundles are built // Check if the renderer and main bundles are built
import path from 'path'; import path from 'path'
import chalk from 'chalk'; import chalk from 'chalk'
import fs from 'fs'; import fs from 'fs'
function CheckBuildsExist() { function CheckBuildsExist() {
const mainPath = path.join(__dirname, '..', '..', 'app', 'main.prod.js'); const mainPath = path.join(__dirname, '..', '..', 'app', 'main.prod.js')
const rendererPath = path.join(__dirname, '..', '..', 'app', 'dist', 'renderer.prod.js'); const rendererPath = path.join(__dirname, '..', '..', 'app', 'dist', 'renderer.prod.js')
if (!fs.existsSync(mainPath)) { if (!fs.existsSync(mainPath)) {
throw new Error(chalk.whiteBright.bgRed.bold( throw new Error(chalk.whiteBright.bgRed.bold(
'The main process is not built yet. Build it by running "npm run build-main"' 'The main process is not built yet. Build it by running "npm run build-main"'
)); ))
} }
if (!fs.existsSync(rendererPath)) { if (!fs.existsSync(rendererPath)) {
throw new Error(chalk.whiteBright.bgRed.bold( throw new Error(chalk.whiteBright.bgRed.bold(
'The renderer process is not built yet. Build it by running "npm run build-renderer"' 'The renderer process is not built yet. Build it by running "npm run build-renderer"'
)); ))
} }
} }
CheckBuildsExist(); CheckBuildsExist()

8
internals/scripts/CheckNodeEnv.js

@ -1,17 +1,17 @@
// @flow // @flow
import chalk from 'chalk'; import chalk from 'chalk'
export default function CheckNodeEnv(expectedEnv: string) { export default function CheckNodeEnv(expectedEnv: string) {
if (!expectedEnv) { if (!expectedEnv) {
throw new Error('"expectedEnv" not set'); throw new Error('"expectedEnv" not set')
} }
if (process.env.NODE_ENV !== expectedEnv) { if (process.env.NODE_ENV !== expectedEnv) {
/* eslint-disable */ /* eslint-disable */
console.log(chalk.whiteBright.bgRed.bold( console.log(chalk.whiteBright.bgRed.bold(
`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config` `"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`
)); ))
/* eslint-enable */ /* eslint-enable */
process.exit(2); process.exit(2)
} }
} }

3
test/components/Nav.spec.js

@ -21,9 +21,8 @@ describe('default elements', () => {
it('should render nav links', () => { it('should render nav links', () => {
expect(el.find(NavLink).at(0).props().to).toBe('/') expect(el.find(NavLink).at(0).props().to).toBe('/')
expect(el.find(NavLink).at(1).props().to).toBe('/wallet') expect(el.find(NavLink).at(1).props().to).toBe('/peers')
expect(el.find(NavLink).at(2).props().to).toBe('/channels') expect(el.find(NavLink).at(2).props().to).toBe('/channels')
expect(el.find(NavLink).at(3).props().to).toBe('/settings')
}) })
it('should render buttons', () => { it('should render buttons', () => {
expect(el.find('.button').at(0).text()).toContain('Pay') expect(el.find('.button').at(0).text()).toContain('Pay')

6
test/example.js

@ -1,5 +1,5 @@
describe('description', () => { describe('description', () => {
it('should have description', () => { it('should have description', () => {
expect(1 + 2).toBe(3); expect(1 + 2).toBe(3)
}); })
}); })

11
test/reducers/__snapshots__/peers.spec.js.snap

@ -12,6 +12,7 @@ Object {
}, },
"peers": Array [], "peers": Array [],
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;
@ -27,6 +28,7 @@ Object {
}, },
"peers": Array [], "peers": Array [],
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;
@ -44,6 +46,7 @@ Object {
"foo", "foo",
], ],
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;
@ -59,6 +62,7 @@ Object {
}, },
"peers": Array [], "peers": Array [],
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;
@ -74,6 +78,7 @@ Object {
}, },
"peers": Array [], "peers": Array [],
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;
@ -89,6 +94,7 @@ Object {
}, },
"peers": Array [], "peers": Array [],
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;
@ -104,6 +110,7 @@ Object {
}, },
"peers": Array [], "peers": Array [],
"peersLoading": true, "peersLoading": true,
"searchQuery": "",
} }
`; `;
@ -119,6 +126,7 @@ Object {
}, },
"peers": "foo", "peers": "foo",
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;
@ -134,6 +142,7 @@ Object {
}, },
"peers": Array [], "peers": Array [],
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;
@ -152,6 +161,7 @@ Object {
}, },
"peers": Array [], "peers": Array [],
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;
@ -167,5 +177,6 @@ Object {
}, },
"peers": Array [], "peers": Array [],
"peersLoading": false, "peersLoading": false,
"searchQuery": "",
} }
`; `;

12
test/runTests.js

@ -1,11 +1,11 @@
const spawn = require('cross-spawn'); const spawn = require('cross-spawn')
const path = require('path'); const path = require('path')
const s = `\\${path.sep}`; const s = `\\${path.sep}`
const pattern = process.argv[2] === 'e2e' const pattern = process.argv[2] === 'e2e'
? `test${s}e2e${s}.+\\.spec\\.js` ? `test${s}e2e${s}.+\\.spec\\.js`
: `test${s}(?!e2e${s})[^${s}]+${s}.+\\.spec\\.js$`; : `test${s}(?!e2e${s})[^${s}]+${s}.+\\.spec\\.js$`
const result = spawn.sync(path.normalize('./node_modules/.bin/jest'), [pattern], { stdio: 'inherit' }); const result = spawn.sync(path.normalize('./node_modules/.bin/jest'), [pattern], { stdio: 'inherit' })
process.exit(result.status); process.exit(result.status)

6
webpack.config.base.js

@ -2,9 +2,9 @@
* Base webpack config used across other specific configs * Base webpack config used across other specific configs
*/ */
import path from 'path'; import path from 'path'
import webpack from 'webpack'; import webpack from 'webpack'
import { dependencies as externals } from './app/package.json'; import { dependencies as externals } from './app/package.json'
export default { export default {
externals: Object.keys(externals || {}), externals: Object.keys(externals || {}),

4
webpack.config.eslint.js

@ -1,3 +1,3 @@
require('babel-register'); require('babel-register')
module.exports = require('./webpack.config.renderer.dev'); module.exports = require('./webpack.config.renderer.dev')

16
webpack.config.main.prod.js

@ -2,14 +2,14 @@
* Webpack config for production electron main process * Webpack config for production electron main process
*/ */
import webpack from 'webpack'; import webpack from 'webpack'
import merge from 'webpack-merge'; import merge from 'webpack-merge'
import BabiliPlugin from 'babili-webpack-plugin'; import BabiliPlugin from 'babili-webpack-plugin'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import baseConfig from './webpack.config.base'; import baseConfig from './webpack.config.base'
import CheckNodeEnv from './internals/scripts/CheckNodeEnv'; import CheckNodeEnv from './internals/scripts/CheckNodeEnv'
CheckNodeEnv('production'); CheckNodeEnv('production')
export default merge.smart(baseConfig, { export default merge.smart(baseConfig, {
devtool: 'source-map', devtool: 'source-map',
@ -59,4 +59,4 @@ export default merge.smart(baseConfig, {
__dirname: false, __dirname: false,
__filename: false __filename: false
} }
}); })

18
webpack.config.renderer.dev.dll.js

@ -2,16 +2,16 @@
* Builds the DLL for development electron renderer process * Builds the DLL for development electron renderer process
*/ */
import webpack from 'webpack'; import webpack from 'webpack'
import path from 'path'; import path from 'path'
import merge from 'webpack-merge'; import merge from 'webpack-merge'
import baseConfig from './webpack.config.base'; import baseConfig from './webpack.config.base'
import { dependencies } from './package.json'; import { dependencies } from './package.json'
import CheckNodeEnv from './internals/scripts/CheckNodeEnv'; import CheckNodeEnv from './internals/scripts/CheckNodeEnv'
CheckNodeEnv('development'); CheckNodeEnv('development')
const dist = path.resolve(process.cwd(), 'dll'); const dist = path.resolve(process.cwd(), 'dll')
export default merge.smart(baseConfig, { export default merge.smart(baseConfig, {
context: process.cwd(), context: process.cwd(),
@ -205,4 +205,4 @@ export default merge.smart(baseConfig, {
} }
}) })
] ]
}); })

20
webpack.config.renderer.prod.js

@ -2,16 +2,16 @@
* Build config for electron renderer process * Build config for electron renderer process
*/ */
import path from 'path'; import path from 'path'
import webpack from 'webpack'; import webpack from 'webpack'
import ExtractTextPlugin from 'extract-text-webpack-plugin'; import ExtractTextPlugin from 'extract-text-webpack-plugin'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import merge from 'webpack-merge'; import merge from 'webpack-merge'
import BabiliPlugin from 'babili-webpack-plugin'; import BabiliPlugin from 'babili-webpack-plugin'
import baseConfig from './webpack.config.base'; import baseConfig from './webpack.config.base'
import CheckNodeEnv from './internals/scripts/CheckNodeEnv'; import CheckNodeEnv from './internals/scripts/CheckNodeEnv'
CheckNodeEnv('production'); CheckNodeEnv('production')
export default merge.smart(baseConfig, { export default merge.smart(baseConfig, {
devtool: 'source-map', devtool: 'source-map',
@ -165,4 +165,4 @@ export default merge.smart(baseConfig, {
openAnalyzer: process.env.OPEN_ANALYZER === 'true' openAnalyzer: process.env.OPEN_ANALYZER === 'true'
}) })
] ]
}); })

Loading…
Cancel
Save