Browse Source

Merge pull request #846 from mrfelton/chore/update-babel

chore(deps): update babel to v7
renovate/lint-staged-8.x
JimmyMow 6 years ago
committed by GitHub
parent
commit
cb124200a9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      .babelrc
  2. 54
      app/lib/lnd/lightning.js
  3. 47
      app/lib/lnd/walletUnlocker.js
  4. 61
      app/lib/zap/controller.js
  5. 2
      app/main.dev.js
  6. 6
      app/store/configureStore.dev.js
  7. 23
      app/store/configureStore.prod.js
  8. 35
      babel.config.js
  9. 2
      internals/webpack/webpack.config.eslint.js
  10. 5
      internals/webpack/webpack.config.renderer.dev.js
  11. 44
      package.json
  12. 2
      test/unit/zap/controller.spec.js
  13. 1666
      yarn.lock

33
.babelrc

@ -1,33 +0,0 @@
{
"presets": [
["env", {
"targets": {
"node": 8,
"browsers": "electron 2.0"
},
"useBuiltIns": true
}],
"stage-0",
"react"
],
"plugins": ["add-module-exports", "dynamic-import-webpack", ["react-intl-auto", {
"removePrefix": "app/",
"filebase": false
}]],
"env": {
"production": {
"presets": ["react-optimize"],
"plugins": ["babel-plugin-dev-expression"]
},
"development": {
"plugins": [
"transform-class-properties",
"transform-es2015-classes",
["flow-runtime", {
"assert": true,
"annotate": true
}]
]
}
}
}

54
app/lib/lnd/lightning.js

@ -29,17 +29,23 @@ class Lightning {
service: any
lndConfig: LndConfig
subscriptions: LightningSubscriptionsType
_fsm: StateMachine
// Transitions provided by the state machine.
connect: any
disconnect: any
terminate: any
is: any
can: any
state: string
fsm: StateMachine
constructor(lndConfig: LndConfig) {
this.fsm = new StateMachine({
init: 'ready',
transitions: [
{ name: 'connect', from: 'ready', to: 'connected' },
{ name: 'disconnect', from: 'connected', to: 'ready' },
{ name: 'terminate', from: 'connected', to: 'ready' }
],
methods: {
onBeforeConnect: this.onBeforeConnect.bind(this),
onBeforeDisconnect: this.onBeforeDisconnect.bind(this),
onBeforeTerminate: this.onBeforeTerminate.bind(this)
}
})
this.mainWindow = null
this.service = null
this.lndConfig = lndConfig
@ -48,9 +54,26 @@ class Lightning {
invoices: null,
transactions: null
}
}
// Initialize the state machine.
this._fsm()
// ------------------------------------
// FSM Proxies
// ------------------------------------
connect(...args: any[]) {
return this.fsm.connect(args)
}
disconnect(...args: any[]) {
return this.fsm.disconnect(args)
}
terminate(...args: any[]) {
return this.fsm.terminate(args)
}
is(...args: any[]) {
return this.fsm.is(args)
}
can(...args: any[]) {
return this.fsm.can(args)
}
// ------------------------------------
@ -183,13 +206,4 @@ class Lightning {
}
}
StateMachine.factory(Lightning, {
init: 'ready',
transitions: [
{ name: 'connect', from: 'ready', to: 'connected' },
{ name: 'disconnect', from: 'connected', to: 'ready' },
{ name: 'terminate', from: 'connected', to: 'ready' }
]
})
export default Lightning

47
app/lib/lnd/walletUnlocker.js

@ -15,22 +15,39 @@ import { mainLog } from '../utils/log'
class WalletUnlocker {
service: any
lndConfig: LndConfig
_fsm: StateMachine
// Transitions provided by the state machine.
connect: any
disconnect: any
terminate: any
is: any
can: any
state: string
fsm: StateMachine
constructor(lndConfig: LndConfig) {
this.fsm = new StateMachine({
init: 'ready',
transitions: [
{ name: 'connect', from: 'ready', to: 'connected' },
{ name: 'disconnect', from: 'connected', to: 'ready' }
],
methods: {
onBeforeConnect: this.onBeforeConnect.bind(this),
onBeforeDisconnect: this.onBeforeDisconnect.bind(this)
}
})
this.service = null
this.lndConfig = lndConfig
}
// Initialize the state machine.
this._fsm()
// ------------------------------------
// FSM Proxies
// ------------------------------------
connect(...args: any[]) {
return this.fsm.connect(args)
}
disconnect(...args: any[]) {
return this.fsm.disconnect(args)
}
is(...args: any[]) {
return this.fsm.is(args)
}
can(...args: any[]) {
return this.fsm.can(args)
}
// ------------------------------------
@ -105,12 +122,4 @@ class WalletUnlocker {
}
}
StateMachine.factory(WalletUnlocker, {
init: 'ready',
transitions: [
{ name: 'connect', from: 'ready', to: 'connected' },
{ name: 'disconnect', from: 'connected', to: 'ready' }
]
})
export default WalletUnlocker

61
app/lib/zap/controller.js

@ -56,29 +56,36 @@ class ZapController {
walletUnlocker: WalletUnlocker
splashScreenTime: number
lndConfig: LndConfig
_fsm: StateMachine
// Transitions provided by the state machine.
startOnboarding: any
startLnd: any
connectLnd: any
terminate: any
is: any
fsm: StateMachine
/**
* Create a new ZapController instance.
* @param {BrowserWindow} mainWindow BrowserWindow instance to interact with.
*/
constructor(mainWindow: BrowserWindow) {
this.fsm = new StateMachine({
transitions: [
{ name: 'startOnboarding', from: '*', to: 'onboarding' },
{ name: 'startLnd', from: 'onboarding', to: 'running' },
{ name: 'connectLnd', from: 'onboarding', to: 'connected' },
{ name: 'terminate', from: '*', to: 'terminated' }
],
methods: {
onOnboarding: this.onOnboarding.bind(this),
onStartOnboarding: this.onStartOnboarding.bind(this),
onBeforeStartLnd: this.onBeforeStartLnd.bind(this),
onBeforeConnectLnd: this.onBeforeConnectLnd.bind(this),
onTerminated: this.onTerminated.bind(this),
onTerminate: this.onTerminate.bind(this)
}
})
// Variable to hold the main window instance.
this.mainWindow = mainWindow
// Time for the splash screen to remain visible.
this.splashScreenTime = 1500
// Initialize the state machine.
this._fsm()
// Initialise the controler with the current active config.
this.lndConfig = new LndConfig()
this.lndConfig.load()
@ -120,6 +127,29 @@ class ZapController {
})
}
// ------------------------------------
// FSM Proxies
// ------------------------------------
startOnboarding(...args: any[]) {
return this.fsm.startOnboarding(...args)
}
startLnd(...args: any[]) {
return this.fsm.startLnd(...args)
}
connectLnd(...args: any[]) {
return this.fsm.connectLnd(...args)
}
terminate(...args: any[]) {
return this.fsm.terminate(...args)
}
is(...args: any[]) {
return this.fsm.is(...args)
}
can(...args: any[]) {
return this.fsm.can(...args)
}
// ------------------------------------
// FSM Callbacks
// ------------------------------------
@ -457,13 +487,4 @@ class ZapController {
}
}
StateMachine.factory(ZapController, {
transitions: [
{ name: 'startOnboarding', from: '*', to: 'onboarding' },
{ name: 'startLnd', from: 'onboarding', to: 'running' },
{ name: 'connectLnd', from: 'onboarding', to: 'connected' },
{ name: 'terminate', from: '*', to: 'terminated' }
]
})
export default ZapController

2
app/main.dev.js

@ -107,7 +107,7 @@ app.on('ready', () => {
* - Stop gRPC and kill lnd process before the app windows are closed and the app quits.
*/
app.on('before-quit', async event => {
if (zap.state !== 'terminated') {
if (!zap.is('terminated')) {
event.preventDefault()
zap.terminate()
} else {

6
app/store/configureStore.dev.js

@ -6,9 +6,9 @@ import { createLogger } from 'redux-logger'
import rootReducer from '../reducers'
import ipc from '../reducers/ipc'
const history = createHashHistory()
export const history = createHashHistory()
const configureStore = initialState => {
export const configureStore = initialState => {
// Redux Configuration
const middleware = []
const enhancers = []
@ -55,5 +55,3 @@ const configureStore = initialState => {
return store
}
export default { configureStore, history }

23
app/store/configureStore.prod.js

@ -5,23 +5,22 @@ import { routerMiddleware } from 'react-router-redux'
import rootReducer from '../reducers'
import ipc from '../reducers/ipc'
const middleware = []
const enhancers = []
export const history = createBrowserHistory({ basename: window.location.pathname })
middleware.push(thunk)
export function configureStore(initialState) {
const middleware = []
const enhancers = []
const history = createBrowserHistory({ basename: window.location.pathname })
const router = routerMiddleware(history)
middleware.push(thunk)
middleware.push(router)
const router = routerMiddleware(history)
middleware.push(ipc)
middleware.push(router)
enhancers.push(applyMiddleware(...middleware))
const enhancer = compose(...enhancers)
middleware.push(ipc)
enhancers.push(applyMiddleware(...middleware))
const enhancer = compose(...enhancers)
function configureStore(initialState) {
return createStore(rootReducer, initialState, enhancer)
}
export default { configureStore, history }

35
babel.config.js

@ -0,0 +1,35 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 8,
browsers: 'electron 2.0'
},
useBuiltIns: 'usage'
}
],
'@babel/preset-flow',
'@babel/react'
],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-transform-classes',
'@babel/plugin-transform-destructuring',
[
'react-intl-auto',
{
removePrefix: 'app/',
filebase: false
}
]
],
env: {
production: {
presets: ['react-optimize']
}
}
}

2
internals/webpack/webpack.config.eslint.js

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

5
internals/webpack/webpack.config.renderer.dev.js

@ -63,8 +63,9 @@ export default merge.smart(baseConfig, {
// Here, we include babel plugins that are only required for the
// renderer process. The 'transform-*' plugins must be included
// before react-hot-loader/babel
'transform-class-properties',
'transform-es2015-classes',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-classes',
'@babel/plugin-proposal-export-default-from',
'react-hot-loader/babel'
]
}

44
package.json

@ -5,9 +5,9 @@
"description": "desktop application for the lightning network",
"scripts": {
"build": "concurrently --raw \"npm:build-main\" \"npm:build-renderer\"",
"build-dll": "webpack --require babel-register --config internals/webpack/webpack.config.renderer.dev.dll.js --progress",
"build-main": "webpack --require babel-register --config internals/webpack/webpack.config.main.prod.js --progress",
"build-renderer": "webpack --require babel-register --config internals/webpack/webpack.config.renderer.prod.js --progress",
"build-dll": "webpack --require @babel/register --config internals/webpack/webpack.config.renderer.dev.dll.js --progress",
"build-main": "webpack --require @babel/register --config internals/webpack/webpack.config.main.prod.js --progress",
"build-renderer": "webpack --require @babel/register --config internals/webpack/webpack.config.renderer.prod.js --progress",
"build-grpc": "rimraf app/node_modules/grpc/src/node && build install-app-deps",
"clean": "rimraf node_modules app/node_modules dll app/dist coverage .eslintcache",
"coverage": "open coverage/index.html",
@ -29,11 +29,11 @@
"lint-ci": "npm run lint && npm run lint-styles",
"package": "npm run build && npm run fetch-lnd && build",
"release": "npm run package -- --publish onTagOrDraft",
"postinstall": "concurrently --raw \"npm:flow-typed\" \"npm:build-dll\" \"build install-app-deps\" \"node node_modules/fbjs-scripts/node/check-dev-engines.js package.json\"",
"postinstall": "concurrently --raw \"npm:flow-typed\" \"npm:build-dll\" \"build install-app-deps\"",
"prestart": "npm run build",
"start": "cross-env NODE_ENV=production electron ./app/",
"start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r babel-register ./app/main.dev",
"start-renderer-dev": "node --trace-warnings -r babel-register ./node_modules/webpack-serve/lib/cli.js --config internals/webpack/webpack.config.renderer.dev.js",
"start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r @babel/register ./app/main.dev",
"start-renderer-dev": "node --trace-warnings -r @babel/register ./node_modules/webpack-serve/lib/cli.js --config internals/webpack/webpack.config.renderer.dev.js",
"test": "npm run lint && npm run lint-styles && npm run flow && npm run build && npm run test-unit && npm run test-e2e",
"test-base": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=true ELECTRON_DISABLE_SECURITY_WARNINGS=true node --trace-warnings ./node_modules/jest/bin/jest --maxWorkers=2 --forceExit",
"test-unit": "npm run test-base -- --coverage ./test/unit",
@ -47,7 +47,9 @@
"binarySite": "https://github.com/LN-Zap/lnd/releases/download"
}
},
"browserslist": "electron 3.0",
"browserslist": [
"electron 3.0"
],
"engines": {
"node": ">=8.2.1",
"npm": ">=5.3.0"
@ -191,26 +193,26 @@
}
},
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-classes": "^7.0.0",
"@babel/plugin-transform-destructuring": "^7.1.3",
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"@commitlint/cli": "^7.2.1",
"@commitlint/config-conventional": "^7.1.2",
"add-asset-html-webpack-plugin": "^3.0.1",
"babel-core": "^6.26.3",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-loader": "^7.1.4",
"babel-plugin-add-module-exports": "^1.0.0",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-dynamic-import-webpack": "^1.1.0",
"babel-plugin-flow-runtime": "^0.17.0",
"babel-loader": "^8.0.0",
"babel-plugin-react-intl": "^3.0.1",
"babel-plugin-react-intl-auto": "^1.1.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-react-optimize": "^1.0.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.26.0",
"browserslist": "^4.2.0",
"chalk": "^2.4.1",
"clean-webpack-plugin": "^0.1.19",
@ -242,12 +244,10 @@
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-react": "^7.11.1",
"extract-react-intl-messages": "^0.10.0",
"extract-react-intl-messages": "^0.11.1",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"fbjs-scripts": "^1.0.1",
"file-loader": "^2.0.0",
"flow-bin": "^0.83.0",
"flow-runtime": "^0.17.0",
"flow-typed": "^2.5.1",
"html-webpack-plugin": "^3.2.0",
"http-proxy-middleware": "^0.19.0",

2
test/unit/zap/controller.spec.js

@ -1,8 +1,8 @@
import ZapController from 'lib/zap/controller'
import LndConfig from 'lib/lnd/config'
import Lightning from 'lib/lnd/lightning'
jest.mock('lib/lnd/lightning')
const Lightning = require('lib/lnd/lightning')
describe('ZapController', function() {
describe('Constructor', () => {

1666
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save