diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000000..4dd12450459 --- /dev/null +++ b/.babelrc @@ -0,0 +1,13 @@ +{ + "plugins": [ + [ + "module-resolver", + { + "root": ["./app"], + "alias": { + "^@zap/(.+)": "./\\1" + } + } + ] + ] +} diff --git a/.eslintrc.js b/.eslintrc.js index 0177e72e261..36d77bff8cd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -99,12 +99,13 @@ module.exports = { ], settings: { 'import/resolver': { - node: { - moduleDirectory: ['app', 'node_modules', 'app/node_modules'], - }, - webpack: { - config: path.resolve(__dirname, 'webpack', 'webpack.config.eslint.js'), - }, + 'babel-module': {}, + }, + node: { + moduleDirectory: ['app', 'node_modules', 'app/node_modules'], + }, + webpack: { + config: path.resolve(__dirname, 'webpack', 'webpack.config.eslint.js'), }, }, } diff --git a/.flowconfig b/.flowconfig index 00c1287373d..480834a6d0e 100644 --- a/.flowconfig +++ b/.flowconfig @@ -31,10 +31,10 @@ module.name_mapper.extension='svg' -> '/flow/WebpackAsset.js.flow' # Example: components/Foo -> `/app/components/Foo` module.name_mapper='^components/\(.*\)$' -> '/app/components/\1' module.name_mapper='^containers/\(.*\)$' -> '/app/containers/\1' -module.name_mapper='^icons/\(.*\)$' -> '/app/icons/\1' -module.name_mapper='^lib/\(.*\)$' -> '/app/lib/\1' module.name_mapper='^reducers/\(.*\)$' -> '/app/reducers/\1' module.name_mapper='^store/\(.*\)$' -> '/app/store/\1' module.name_mapper='^themes/\(.*\)$' -> '/app/themes/\1' module.name_mapper='^hocs/\(.*\)$' -> '/app/hocs/\1' module.name_mapper='^hooks/\(.*\)$' -> '/app/hooks/\1' + +module.name_mapper='^@zap/\(.*\)$' -> '/\1' diff --git a/.storybook/config.js b/.storybook/config.js index 04ae32038d8..044f98b3361 100644 --- a/.storybook/config.js +++ b/.storybook/config.js @@ -11,7 +11,7 @@ import { linkTo } from '@storybook/addon-links' import { setIntlConfig, withIntl } from 'storybook-addon-intl' import StoryRouter from 'storybook-react-router' import { dark, light } from 'themes' -import { getDefaultLocale, locales } from 'lib/i18n' +import { getDefaultLocale, locales } from '@zap/i18n' import { BackgroundPrimary, GlobalStyle } from 'components/UI' const BackgroundPrimaryWithTheme = withTheme(({ theme, ...rest }) => ( @@ -24,16 +24,16 @@ const BackgroundPrimaryWithTheme = withTheme(({ theme, ...rest }) => ( )) // Register supported locales. -import '../app/lib/i18n/locale' +import '@zap/i18n/locale' // Get translations. -import translations from '../app/lib/i18n/translation' +import translations from '@zap/i18n/translation' // Set intl configuration setIntlConfig({ locales: locales, defaultLocale: getDefaultLocale(), - getMessages: locale => translations[locale] + getMessages: locale => translations[locale], }) // Info @@ -42,10 +42,10 @@ addDecorator( styles: { button: { base: { - background: dark.colors.lightningOrange - } - } - } + background: dark.colors.lightningOrange, + }, + }, + }, }) ) @@ -67,8 +67,8 @@ addParameters({ name: 'Zap', url: 'https://ln-zap.github.io/zap-desktop', theme: themes.dark, - hierarchySeparator: /\./ - } + hierarchySeparator: /\./, + }, }) // Zap Global style. @@ -90,8 +90,8 @@ setDefaults({ showSource: false, allowSourceToggling: false, showPropTables: false, - allowPropTablesToggling: true - } + allowPropTablesToggling: true, + }, }) // automatically import all files ending in *.stories.js diff --git a/.testcafe-electron-rc b/.testcafe-electron-rc index 917dab2c668..2bf4a41ed2f 100644 --- a/.testcafe-electron-rc +++ b/.testcafe-electron-rc @@ -1,4 +1,4 @@ { - "mainWindowUrl": "./app/dist/index.html", - "appPath": "./app" + "mainWindowUrl": "./dist/index.html", + "appPath": "." } diff --git a/app/.eslintrc b/app/.eslintrc deleted file mode 100644 index 90d8894e282..00000000000 --- a/app/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "rules": {} -} diff --git a/app/components/Activity/TransactionModal/TransactionModal.js b/app/components/Activity/TransactionModal/TransactionModal.js index 3acd01f126d..b5674d4b925 100644 --- a/app/components/Activity/TransactionModal/TransactionModal.js +++ b/app/components/Activity/TransactionModal/TransactionModal.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types' import get from 'lodash.get' import { FormattedDate, FormattedTime, FormattedMessage, FormattedNumber } from 'react-intl' import { Flex } from 'rebass' -import { blockExplorer } from 'lib/utils' +import { blockExplorer } from '@zap/utils' import { Bar, DataRow, Header, Link, Panel, Span, Text } from 'components/UI' import { CryptoSelector, CryptoValue, FiatSelector, FiatValue } from 'containers/UI' import { Truncate } from 'components/Util' diff --git a/app/components/Channels/ChannelCreateForm.js b/app/components/Channels/ChannelCreateForm.js index e17b1351137..424a6425e93 100644 --- a/app/components/Channels/ChannelCreateForm.js +++ b/app/components/Channels/ChannelCreateForm.js @@ -4,7 +4,7 @@ import { FormattedMessage, injectIntl, intlShape } from 'react-intl' import { Keyframes } from 'react-spring' import get from 'lodash.get' import { Box, Flex } from 'rebass' -import { convert } from 'lib/utils/btc' +import { convert } from '@zap/utils/btc' import { Bar, Button, diff --git a/app/components/Channels/ChannelData.js b/app/components/Channels/ChannelData.js index d9fc34119ed..3a09275d084 100644 --- a/app/components/Channels/ChannelData.js +++ b/app/components/Channels/ChannelData.js @@ -4,7 +4,7 @@ import { FormattedDate, FormattedTime, FormattedMessage } from 'react-intl' import styled from 'styled-components' import { opacity } from 'styled-system' import { Box as BaseBox } from 'rebass' -import { blockExplorer } from 'lib/utils' +import { blockExplorer } from '@zap/utils' import { Bar, DataRow, Link } from 'components/UI' import { Truncate } from 'components/Util' import { CryptoValue } from 'containers/UI' diff --git a/app/components/GlobalNotification/GlobalNotification.js b/app/components/GlobalNotification/GlobalNotification.js index f7b748bcb08..3c2054216ce 100644 --- a/app/components/GlobalNotification/GlobalNotification.js +++ b/app/components/GlobalNotification/GlobalNotification.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types' import { animated, Transition } from 'react-spring' import styled from 'styled-components' import { Box } from 'rebass' -import errorToUserFriendly from 'lib/utils/userFriendlyErrors' +import errorToUserFriendly from '@zap/utils/userFriendlyErrors' import { Notification } from 'components/UI' const Wrapper = styled(Box)` diff --git a/app/components/Home/WalletLauncher.js b/app/components/Home/WalletLauncher.js index 473036076a0..713561e2992 100644 --- a/app/components/Home/WalletLauncher.js +++ b/app/components/Home/WalletLauncher.js @@ -6,8 +6,8 @@ import { withRouter } from 'react-router-dom' import { Box, Flex } from 'rebass' import styled from 'styled-components' import parse from 'lndconnect/parse' -import { isValidBtcPayConfig, isEmbeddedLndConnectURI } from 'lib/utils/connectionString' -import parseConnectionString from 'lib/utils/btcpayserver' +import { isValidBtcPayConfig, isEmbeddedLndConnectURI } from '@zap/utils/connectionString' +import parseConnectionString from '@zap/utils/btcpayserver' import { Bar, Button, Heading, Text, ActionBar, Form } from 'components/UI' import WalletSettingsFormLocal from './WalletSettingsFormLocal' import WalletSettingsFormRemote from './WalletSettingsFormRemote' diff --git a/app/components/Onboarding/Steps/ConnectionConfirm.js b/app/components/Onboarding/Steps/ConnectionConfirm.js index d3421d90576..3ed54a1409c 100644 --- a/app/components/Onboarding/Steps/ConnectionConfirm.js +++ b/app/components/Onboarding/Steps/ConnectionConfirm.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types' import { FormattedMessage } from 'react-intl' import encode from 'lndconnect/encode' import decode from 'lndconnect/decode' -import parseConnectionString from 'lib/utils/btcpayserver' +import parseConnectionString from '@zap/utils/btcpayserver' import { Bar, Form, Header, Span, Text } from 'components/UI' import messages from './messages' diff --git a/app/components/Pay/Pay.js b/app/components/Pay/Pay.js index 2633d281974..7e29e638e27 100644 --- a/app/components/Pay/Pay.js +++ b/app/components/Pay/Pay.js @@ -3,9 +3,9 @@ import PropTypes from 'prop-types' import { Box } from 'rebass' import { animated, Keyframes, Transition } from 'react-spring' import { FormattedMessage, injectIntl, intlShape } from 'react-intl' -import { decodePayReq, getMinFee, getMaxFee, isOnchain, isLn } from 'lib/utils/crypto' +import { decodePayReq, getMinFee, getMaxFee, isOnchain, isLn } from '@zap/utils/crypto' import get from 'lodash.get' -import { convert } from 'lib/utils/btc' +import { convert } from '@zap/utils/btc' import { Bar, Form, diff --git a/app/components/Pay/PaySummaryLightning.js b/app/components/Pay/PaySummaryLightning.js index 92c56ad7c12..e293f126118 100644 --- a/app/components/Pay/PaySummaryLightning.js +++ b/app/components/Pay/PaySummaryLightning.js @@ -2,8 +2,8 @@ import React from 'react' import PropTypes from 'prop-types' import { Box, Flex } from 'rebass' import { FormattedMessage } from 'react-intl' -import { convert } from 'lib/utils/btc' -import { decodePayReq, getNodeAlias } from 'lib/utils/crypto' +import { convert } from '@zap/utils/btc' +import { decodePayReq, getNodeAlias } from '@zap/utils/crypto' import BigArrowRight from 'components/Icon/BigArrowRight' import { Bar, DataRow, Spinner, Text } from 'components/UI' import { CryptoSelector, CryptoValue, FiatValue } from 'containers/UI' diff --git a/app/components/Request/RequestSummary.js b/app/components/Request/RequestSummary.js index 0149aa9a507..808eb3fc593 100644 --- a/app/components/Request/RequestSummary.js +++ b/app/components/Request/RequestSummary.js @@ -8,7 +8,7 @@ import { intlShape, injectIntl, } from 'react-intl' -import { decodePayReq } from 'lib/utils/crypto' +import { decodePayReq } from '@zap/utils/crypto' import copy from 'copy-to-clipboard' import { Bar, DataRow, Button, QRCode, Text } from 'components/UI' import { CryptoSelector, CryptoValue, FiatSelector, FiatValue } from 'containers/UI' diff --git a/app/components/Settings/Locale/Locale.js b/app/components/Settings/Locale/Locale.js index c369ab3d2d4..5f944119978 100644 --- a/app/components/Settings/Locale/Locale.js +++ b/app/components/Settings/Locale/Locale.js @@ -1,6 +1,6 @@ import React from 'react' import PropTypes from 'prop-types' -import { getLanguageName } from 'lib/i18n' +import { getLanguageName } from '@zap/i18n' import { MenuContainer, Menu, MenuItem } from 'components/UI/Dropdown' import { FormattedMessage } from 'react-intl' import messages from './messages' diff --git a/app/components/UI/ActionButton.js b/app/components/UI/ActionButton.js index 2b883bda297..0f4231d0c4a 100644 --- a/app/components/UI/ActionButton.js +++ b/app/components/UI/ActionButton.js @@ -1,7 +1,7 @@ import React, { useState, useEffect, useRef } from 'react' import PropTypes from 'prop-types' import styled from 'styled-components' -import delay from 'lib/utils/delay' +import delay from '@zap/utils/delay' import Button from './Button' import Spinner from './Spinner' diff --git a/app/components/UI/CryptoAmountInput.js b/app/components/UI/CryptoAmountInput.js index c7a1d8a52e5..500060595da 100644 --- a/app/components/UI/CryptoAmountInput.js +++ b/app/components/UI/CryptoAmountInput.js @@ -4,8 +4,8 @@ import React from 'react' import PropTypes from 'prop-types' import { asField } from 'informed' import * as yup from 'yup' -import { convert } from 'lib/utils/btc' -import { formatValue, parseNumber } from 'lib/utils/crypto' +import { convert } from '@zap/utils/btc' +import { formatValue, parseNumber } from '@zap/utils/crypto' import { withNumberInputMask } from 'hocs' import Input from './Input' diff --git a/app/components/UI/CurrencyFieldGroup.js b/app/components/UI/CurrencyFieldGroup.js index 69e498bd8e6..e5cf5ae1eaf 100644 --- a/app/components/UI/CurrencyFieldGroup.js +++ b/app/components/UI/CurrencyFieldGroup.js @@ -2,7 +2,7 @@ import React from 'react' import PropTypes from 'prop-types' import { Box, Flex } from 'rebass' import { FormattedMessage } from 'react-intl' -import { convert } from 'lib/utils/btc' +import { convert } from '@zap/utils/btc' import CryptoAmountInput from './CryptoAmountInput' import Dropdown from './Dropdown' import FiatAmountInput from './FiatAmountInput' diff --git a/app/components/UI/FiatAmountInput.js b/app/components/UI/FiatAmountInput.js index 69dfa3ec164..46c16b6f07b 100644 --- a/app/components/UI/FiatAmountInput.js +++ b/app/components/UI/FiatAmountInput.js @@ -4,8 +4,8 @@ import React from 'react' import PropTypes from 'prop-types' import { asField } from 'informed' import * as yup from 'yup' -import { convert } from 'lib/utils/btc' -import { formatValue, parseNumber } from 'lib/utils/crypto' +import { convert } from '@zap/utils/btc' +import { formatValue, parseNumber } from '@zap/utils/crypto' import { withNumberInputMask } from 'hocs' import Input from './Input' diff --git a/app/components/UI/LightningInvoiceInput.js b/app/components/UI/LightningInvoiceInput.js index 49005da22f4..c01acbf8a8b 100644 --- a/app/components/UI/LightningInvoiceInput.js +++ b/app/components/UI/LightningInvoiceInput.js @@ -2,7 +2,7 @@ import React from 'react' import PropTypes from 'prop-types' import { FormattedMessage, intlShape, injectIntl } from 'react-intl' import { asField } from 'informed' -import { isOnchain, isLn } from 'lib/utils/crypto' +import { isOnchain, isLn } from '@zap/utils/crypto' import TextArea from './TextArea' import Message from './Message' import messages from './messages' diff --git a/app/components/UI/LndConnectionStringEditor.js b/app/components/UI/LndConnectionStringEditor.js index b190d864c9e..39ddc59af08 100644 --- a/app/components/UI/LndConnectionStringEditor.js +++ b/app/components/UI/LndConnectionStringEditor.js @@ -3,7 +3,10 @@ import PropTypes from 'prop-types' import { Box, Flex } from 'rebass' import { withFormApi } from 'informed' import Padlock from 'components/Icon/Padlock' -import { LndConnectionStringInput, Toggle, Span, Label } from '.' +import LndConnectionStringInput from './LndConnectionStringInput' +import Toggle from './Toggle' +import Span from './Span' +import Label from './Label' function LndConnectionStringEditor({ formApi, field, hideStringMessage, ...rest }) { const isDisabled = formApi.getValue('hideLndConnectUri') diff --git a/app/components/UI/LndConnectionStringInput.js b/app/components/UI/LndConnectionStringInput.js index 714e1f419b4..e3f6fb8a532 100644 --- a/app/components/UI/LndConnectionStringInput.js +++ b/app/components/UI/LndConnectionStringInput.js @@ -1,7 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { intlShape, injectIntl } from 'react-intl' -import { isValidLndConnectUri, isValidBtcPayConfig } from 'lib/utils/connectionString' +import { isValidLndConnectUri, isValidBtcPayConfig } from '@zap/utils/connectionString' import TextArea from './TextArea' import messages from './messages' diff --git a/app/components/UI/Value.js b/app/components/UI/Value.js index 8e219c48543..dfafa51f8c3 100644 --- a/app/components/UI/Value.js +++ b/app/components/UI/Value.js @@ -1,7 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { FormattedNumber } from 'react-intl' -import { convert } from 'lib/utils/btc' +import { convert } from '@zap/utils/btc' const forcePositiveNumber = amount => (amount >= 0 ? amount * 1 : amount * -1) diff --git a/app/hocs/withNumberInputMask.js b/app/hocs/withNumberInputMask.js index 6b02901b0b8..1beb2efab46 100644 --- a/app/hocs/withNumberInputMask.js +++ b/app/hocs/withNumberInputMask.js @@ -1,6 +1,6 @@ import React from 'react' import PropTypes from 'prop-types' -import getDisplayName from 'lib/utils/getDisplayName' +import getDisplayName from '@zap/utils/getDisplayName' /** * A HOC that will add validation of a `required` property to a field. diff --git a/app/hocs/withRequiredValidation.js b/app/hocs/withRequiredValidation.js index 2a06ff549d2..f869f10cb42 100644 --- a/app/hocs/withRequiredValidation.js +++ b/app/hocs/withRequiredValidation.js @@ -1,7 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import * as yup from 'yup' -import getDisplayName from 'lib/utils/getDisplayName' +import getDisplayName from '@zap/utils/getDisplayName' /** * A HOC that will add validation of a `required` property to a field. diff --git a/app/index.js b/app/index.js index 62e13dc698b..8a0e4481cbc 100644 --- a/app/index.js +++ b/app/index.js @@ -2,16 +2,12 @@ import React from 'react' import ReactDOM from 'react-dom' import { Provider } from 'react-intl-redux' import jstz from 'jstimezonedetect' +import '@zap/i18n/locale' +import translations from '@zap/i18n/translation' +import { getDefaultLocale } from '@zap/i18n' import { configureStore, history } from './store/configureStore' -import { getDefaultLocale } from './lib/i18n' import Root from './containers/Root' -// Register supported locales. -import './lib/i18n/locale' - -// Get translations. -import translations from './lib/i18n/translation' - // Default the locale to English. const defaultLocale = getDefaultLocale() diff --git a/app/lib/i18n/translation.js b/app/lib/i18n/translation.js deleted file mode 100644 index 564595a0fea..00000000000 --- a/app/lib/i18n/translation.js +++ /dev/null @@ -1,45 +0,0 @@ -// Load translation data. -import bgTranslationMessages from '../../../translations/bg-BG.json' -import csTranslationMessages from '../../../translations/cs-CZ.json' -import deTranslationMessages from '../../../translations/de-DE.json' -import elTranslationMessages from '../../../translations/el-GR.json' -import enTranslationMessages from '../../../translations/en.json' -import esTranslationMessages from '../../../translations/es-ES.json' -import frTranslationMessages from '../../../translations/fr-FR.json' -import gaTranslationMessages from '../../../translations/ga-IE.json' -import hrTranslationMessages from '../../../translations/hr-HR.json' -import jaTranslationMessages from '../../../translations/ja-JP.json' -import nlTranslationMessages from '../../../translations/nl-NL.json' -import ptTranslationMessages from '../../../translations/pt-BR.json' -import roTranslationMessages from '../../../translations/ro-RO.json' -import ruTranslationMessages from '../../../translations/ru-RU.json' -import svTranslationMessages from '../../../translations/sv-SE.json' -import trTranslationMessages from '../../../translations/tr-TR.json' -import ukTranslationMessages from '../../../translations/uk-UA.json' -import zhCNTranslationMessages from '../../../translations/zh-CN.json' -import zhTWTranslationMessages from '../../../translations/zh-TW.json' - -// Collate all translations. -const translations = { - en: enTranslationMessages, - bg: bgTranslationMessages, - 'zh-CN': zhCNTranslationMessages, - 'zh-TW': zhTWTranslationMessages, - hr: hrTranslationMessages, - cs: csTranslationMessages, - nl: nlTranslationMessages, - fr: frTranslationMessages, - ga: gaTranslationMessages, - de: deTranslationMessages, - el: elTranslationMessages, - ja: jaTranslationMessages, - pt: ptTranslationMessages, - ro: roTranslationMessages, - ru: ruTranslationMessages, - es: esTranslationMessages, - sv: svTranslationMessages, - tr: trTranslationMessages, - uk: ukTranslationMessages, -} - -export default translations diff --git a/app/package.json b/app/package.json deleted file mode 100644 index 79742af1a21..00000000000 --- a/app/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "zap-desktop", - "productName": "Zap", - "version": "0.4.0-beta", - "description": "desktop application for the lightning network", - "main": "./dist/main.prod.js", - "author": { - "name": "Jack Mallers", - "email": "jimmymowschess@gmail.com", - "url": "https://github.com/LN-Zap/zap-desktop" - }, - "scripts": { - "postinstall": "npm rebuild --runtime=electron --target=4.0.0 --disturl=https://atom.io/download/electron" - }, - "license": "MIT", - "dependencies": {} -} diff --git a/app/reducers/activity.js b/app/reducers/activity.js index 6465ba4f814..cab36a12e9c 100644 --- a/app/reducers/activity.js +++ b/app/reducers/activity.js @@ -1,5 +1,5 @@ import { createSelector } from 'reselect' -import { decodePayReq } from 'lib/utils/crypto' +import { decodePayReq } from '@zap/utils/crypto' import { openModal, closeModal } from './modal' import { fetchDescribeNetwork } from './network' diff --git a/app/reducers/channels.js b/app/reducers/channels.js index 343c6205b0e..86a0734b1a5 100644 --- a/app/reducers/channels.js +++ b/app/reducers/channels.js @@ -1,7 +1,7 @@ import { createSelector } from 'reselect' import throttle from 'lodash.throttle' import { send } from 'redux-electron-ipc' -import { requestSuggestedNodes } from 'lib/utils/api' +import { requestSuggestedNodes } from '@zap/utils/api' import { updateNotification, showWarning, showError } from './notification' import { fetchBalance } from './balance' import { walletSelectors } from './wallet' diff --git a/app/reducers/info.js b/app/reducers/info.js index 89715a2ea8c..00acc7e02a6 100644 --- a/app/reducers/info.js +++ b/app/reducers/info.js @@ -1,7 +1,7 @@ import { createSelector } from 'reselect' import { send } from 'redux-electron-ipc' import get from 'lodash.get' -import { networks } from 'lib/utils/crypto' +import { networks } from '@zap/utils/crypto' import { walletAddress } from './address' import { putWallet, walletSelectors } from './wallet' diff --git a/app/reducers/invoice.js b/app/reducers/invoice.js index fe65610d6db..f57cf8bbca8 100644 --- a/app/reducers/invoice.js +++ b/app/reducers/invoice.js @@ -1,7 +1,7 @@ import { createSelector } from 'reselect' import { send } from 'redux-electron-ipc' -import { showSystemNotification } from 'lib/utils/notifications' -import { btc } from 'lib/utils' +import { showSystemNotification } from '@zap/utils/notifications' +import { btc } from '@zap/utils' import { fetchBalance } from './balance' import { fetchChannels } from './channels' import { showError } from './notification' diff --git a/app/reducers/lnd.js b/app/reducers/lnd.js index 26c360544cf..07f0188a999 100644 --- a/app/reducers/lnd.js +++ b/app/reducers/lnd.js @@ -1,6 +1,6 @@ import { send } from 'redux-electron-ipc' import { createSelector } from 'reselect' -import { showSystemNotification } from 'lib/utils/notifications' +import { showSystemNotification } from '@zap/utils/notifications' import { fetchBalance } from './balance' import { fetchInfo, setHasSynced } from './info' import { putWallet, setActiveWallet, walletSelectors } from './wallet' diff --git a/app/reducers/locale.js b/app/reducers/locale.js index d3449c860af..afe873d6094 100644 --- a/app/reducers/locale.js +++ b/app/reducers/locale.js @@ -1,6 +1,6 @@ import { send } from 'redux-electron-ipc' import { updateIntl } from 'react-intl-redux' -import translations from 'lib/i18n/translation' +import translations from '@zap/i18n/translation' import { setFiatTicker } from './ticker' import { putSetting } from './settings' diff --git a/app/reducers/modal.js b/app/reducers/modal.js index c4de1d0c73b..a642b1b724d 100644 --- a/app/reducers/modal.js +++ b/app/reducers/modal.js @@ -1,4 +1,4 @@ -import genId from 'lib/utils/genId' +import genId from '@zap/utils/genId' // ------------------------------------ // Initial State diff --git a/app/reducers/notification.js b/app/reducers/notification.js index 5e4405e8fdb..ba77c7561d3 100644 --- a/app/reducers/notification.js +++ b/app/reducers/notification.js @@ -1,5 +1,5 @@ -import delay from 'lib/utils/delay' -import genId from 'lib/utils/genId' +import delay from '@zap/utils/delay' +import genId from '@zap/utils/genId' import matches from 'lodash.matches' // ------------------------------------ diff --git a/app/reducers/onboarding.js b/app/reducers/onboarding.js index 0fb5ff33ef9..6065718df80 100644 --- a/app/reducers/onboarding.js +++ b/app/reducers/onboarding.js @@ -1,4 +1,4 @@ -import delay from 'lib/utils/delay' +import delay from '@zap/utils/delay' import { setLoading } from './app' import { walletSelectors } from './wallet' diff --git a/app/reducers/pay.js b/app/reducers/pay.js index 9c1771ec551..0f6b943013b 100644 --- a/app/reducers/pay.js +++ b/app/reducers/pay.js @@ -1,6 +1,6 @@ import { send } from 'redux-electron-ipc' import get from 'lodash.get' -import { requestFees } from 'lib/utils/api' +import { requestFees } from '@zap/utils/api' // ------------------------------------ // Constants diff --git a/app/reducers/payment.js b/app/reducers/payment.js index b0a3246be26..442c74b0c17 100644 --- a/app/reducers/payment.js +++ b/app/reducers/payment.js @@ -1,8 +1,8 @@ import { createSelector } from 'reselect' import { send } from 'redux-electron-ipc' -import errorToUserFriendly from 'lib/utils/userFriendlyErrors' -import { decodePayReq } from 'lib/utils/crypto' -import delay from 'lib/utils/delay' +import errorToUserFriendly from '@zap/utils/userFriendlyErrors' +import { decodePayReq } from '@zap/utils/crypto' +import delay from '@zap/utils/delay' import { fetchBalance } from './balance' import { fetchChannels } from './channels' import { showError } from './notification' diff --git a/app/reducers/ticker.js b/app/reducers/ticker.js index 1edea355442..790e2e788b2 100644 --- a/app/reducers/ticker.js +++ b/app/reducers/ticker.js @@ -1,7 +1,7 @@ import { createSelector } from 'reselect' import get from 'lodash.get' -import { requestTickers } from 'lib/utils/api' -import { currencies, getDefaultCurrency } from 'lib/i18n' +import { requestTickers } from '@zap/utils/api' +import { currencies, getDefaultCurrency } from '@zap/i18n' import { infoSelectors } from './info' import { putSetting } from './settings' diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index 665ba2b0776..6f53ae82a01 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -1,9 +1,9 @@ import { createSelector } from 'reselect' import { send } from 'redux-electron-ipc' -import { showSystemNotification } from 'lib/utils/notifications' -import { convert } from 'lib/utils/btc' -import delay from 'lib/utils/delay' -import errorToUserFriendly from 'lib/utils/userFriendlyErrors' +import { showSystemNotification } from '@zap/utils/notifications' +import { convert } from '@zap/utils/btc' +import delay from '@zap/utils/delay' +import errorToUserFriendly from '@zap/utils/userFriendlyErrors' import { newAddress } from './address' import { fetchBalance } from './balance' import { fetchChannels, channelsSelectors, getChannelData } from './channels' diff --git a/app/store/configureStore.dev.js b/app/store/configureStore.dev.js index 73b4bacc62b..a3cf36291d8 100644 --- a/app/store/configureStore.dev.js +++ b/app/store/configureStore.dev.js @@ -3,8 +3,8 @@ import thunk from 'redux-thunk' import { createMemoryHistory } from 'history' import { routerActions, routerMiddleware } from 'connected-react-router' import { createLogger } from 'redux-logger' -import createRootReducer from '../reducers' -import ipc from '../reducers/ipc' +import createRootReducer from 'reducers' +import ipc from 'reducers/ipc' export const history = createMemoryHistory() @@ -93,7 +93,7 @@ export const configureStore = initialState => { const store = createStore(createRootReducer(history), initialState, enhancer) if (module.hot) { - module.hot.accept('../reducers', () => { + module.hot.accept('reducers', () => { store.replaceReducer(createRootReducer(history)) }) } diff --git a/app/store/configureStore.prod.js b/app/store/configureStore.prod.js index df1ed4c5cbf..7fec7f16d37 100644 --- a/app/store/configureStore.prod.js +++ b/app/store/configureStore.prod.js @@ -2,8 +2,8 @@ import { createStore, applyMiddleware, compose } from 'redux' import thunk from 'redux-thunk' import { createMemoryHistory } from 'history' import { routerMiddleware } from 'connected-react-router' -import createRootReducer from '../reducers' -import ipc from '../reducers/ipc' +import createRootReducer from 'reducers' +import ipc from 'reducers/ipc' export const history = createMemoryHistory({ basename: window.location.pathname }) diff --git a/app/store/db.js b/app/store/db.js index 69f74009bc2..deacaf7fc3c 100644 --- a/app/store/db.js +++ b/app/store/db.js @@ -1,7 +1,7 @@ import Dexie from 'dexie' import decode from 'lndconnect/decode' import encode from 'lndconnect/encode' -import parseConnectionString from '../lib/utils/btcpayserver' +import parseConnectionString from '@zap/utils/btcpayserver' export const getDb = name => { // Define the database. diff --git a/app/yarn.lock b/app/yarn.lock deleted file mode 100644 index fb57ccd13af..00000000000 --- a/app/yarn.lock +++ /dev/null @@ -1,4 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - diff --git a/babel.config.js b/babel.config.js index 122842d1361..032f6874bd7 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,4 +1,11 @@ module.exports = { + babelrcRoots: [ + // Keep the root as a root + '.', + + // Also consider app as "root" and load it's .babelrc files. + './app/*', + ], presets: [ [ '@babel/preset-env', diff --git a/config/default.js b/config/default.js index 6990f1d8a46..f9b43260889 100644 --- a/config/default.js +++ b/config/default.js @@ -1,4 +1,4 @@ -const { getPackageDetails, isStableVersion } = require('../app/lib/utils') +const { getPackageDetails, isStableVersion } = require('@zap/utils') // The current stable base version. // If the current version is in the same range asd this, the default database domain will be used. diff --git a/app/lib/zap/about/index.js b/electron/about/index.js similarity index 100% rename from app/lib/zap/about/index.js rename to electron/about/index.js diff --git a/app/lib/zap/about/preload.js b/electron/about/preload.js similarity index 100% rename from app/lib/zap/about/preload.js rename to electron/about/preload.js diff --git a/app/lib/zap/about/public/about.html b/electron/about/public/about.html similarity index 100% rename from app/lib/zap/about/public/about.html rename to electron/about/public/about.html diff --git a/app/lib/zap/about/public/renderer.js b/electron/about/public/renderer.js similarity index 100% rename from app/lib/zap/about/public/renderer.js rename to electron/about/public/renderer.js diff --git a/app/lib/zap/about/public/styles/ui.css b/electron/about/public/styles/ui.css similarity index 100% rename from app/lib/zap/about/public/styles/ui.css rename to electron/about/public/styles/ui.css diff --git a/app/lib/zap/controller.js b/electron/controller.js similarity index 97% rename from app/lib/zap/controller.js rename to electron/controller.js index ee8048f9f62..52f3d96acce 100644 --- a/app/lib/zap/controller.js +++ b/electron/controller.js @@ -1,14 +1,14 @@ // @flow import { app, ipcMain, dialog, BrowserWindow } from 'electron' import StateMachine from 'javascript-state-machine' -import { mainLog } from '../utils/log' -import delay from '../utils/delay' -import truncate from '../utils/truncate' -import sanitize from '../utils/sanitize' -import LndConfig, { type LndConfigOptions } from '../lnd/config' -import Lightning from '../lnd/lightning' -import Neutrino from '../lnd/neutrino' -import WalletUnlocker from '../lnd/walletUnlocker' +import { mainLog } from '@zap/utils/log' +import delay from '@zap/utils/delay' +import truncate from '@zap/utils/truncate' +import sanitize from '@zap/utils/sanitize' +import LndConfig, { type LndConfigOptions } from '@zap/lnd/config' +import Lightning from '@zap/lnd/lightning' +import Neutrino from '@zap/lnd/neutrino' +import WalletUnlocker from '@zap/lnd/walletUnlocker' const LND_GRPC_HOST_ERROR = 'LND_GRPC_HOST_ERROR' const LND_GRPC_CERT_ERROR = 'LND_GRPC_CERT_ERROR' diff --git a/app/main.js b/electron/main.js similarity index 97% rename from app/main.js rename to electron/main.js index 0cc29c2b364..1e30355904d 100644 --- a/app/main.js +++ b/electron/main.js @@ -16,13 +16,13 @@ import path from 'path' import os from 'os' import fs from 'fs' import bip21 from 'bip21' -import { mainLog } from './lib/utils/log' -import ZapMenuBuilder from './lib/zap/menuBuilder' -import ZapController from './lib/zap/controller' -import ZapUpdater from './lib/zap/updater' -import ZapMigrator from './lib/zap/migrator' -import themes from './themes' -import { getDbName } from './lib/utils/db' +import { mainLog } from '@zap/utils/log' +import themes from '@zap/app/themes' +import { getDbName } from '@zap/utils/db' +import ZapMenuBuilder from './menuBuilder' +import ZapController from './controller' +import ZapUpdater from './updater' +import ZapMigrator from './migrator' // When we run in production mode, this file is processd with webpack and our config is made available in the // global CONFIG object. If this is not set then we must be running in development mode (where this file is loaded @@ -252,7 +252,7 @@ app.on('ready', async () => { webPreferences: { nodeIntegration: false, preload: process.env.HOT - ? path.resolve(__dirname, 'dist', 'preload.dev.js') + ? path.resolve(__dirname, '..', 'dist', 'preload.dev.js') : path.resolve(__dirname, 'preload.prod.js'), }, }) diff --git a/app/lib/zap/menuBuilder.js b/electron/menuBuilder.js similarity index 96% rename from app/lib/zap/menuBuilder.js rename to electron/menuBuilder.js index 38444494a50..9beab60ab18 100644 --- a/app/lib/zap/menuBuilder.js +++ b/electron/menuBuilder.js @@ -1,11 +1,10 @@ // @flow import os from 'os' import { app, Menu, shell, BrowserWindow, ipcMain } from 'electron' +import { appRootPath } from '@zap/lnd/util' +import { getLanguageName, locales } from '@zap/i18n' +import { getPackageDetails } from '@zap/utils' import openAboutWindow from './about' -import { getLanguageName, locales } from '../i18n' -import { getPackageDetails } from '../utils' - -import { appRootPath } from '../lnd/util' const path = require('path') @@ -17,12 +16,12 @@ const buildAboutMenu = () => { openAboutWindow( { icon_path: path.resolve(appRootPath(), 'resources', 'icon.png'), - open_devtools: process.env.NODE_ENV !== 'production', + open_devtools: process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD, product_name: `${productName} ${version}`, }, `file://${path.resolve( - process.env.HOT ? 'app' : app.getAppPath(), - 'lib/zap/about/public/', + process.env.HOT ? '' : app.getAppPath(), + 'electron/about/public/', 'about.html' )}` ) diff --git a/app/lib/zap/migrations/purge-local-wallets.js b/electron/migrations/purge-local-wallets.js similarity index 74% rename from app/lib/zap/migrations/purge-local-wallets.js rename to electron/migrations/purge-local-wallets.js index 6e70e007f77..aa7531b4d4c 100644 --- a/app/lib/zap/migrations/purge-local-wallets.js +++ b/electron/migrations/purge-local-wallets.js @@ -1,4 +1,4 @@ -import { purgeAllLocalWallets } from '../../utils/localWallets' +import { purgeAllLocalWallets } from '@zap/utils/localWallets' /** * Migration script to purge all local wallets, causing a resync of the blockchain data. diff --git a/app/lib/zap/migrator.js b/electron/migrator.js similarity index 100% rename from app/lib/zap/migrator.js rename to electron/migrator.js diff --git a/app/preload.js b/electron/preload.js similarity index 94% rename from app/preload.js rename to electron/preload.js index f92bbd89620..5fff71d28af 100644 --- a/app/preload.js +++ b/electron/preload.js @@ -10,11 +10,11 @@ import assert from 'assert' import url from 'url' import untildify from 'untildify' import rimraf from 'rimraf' -import isSubDir from './lib/utils/isSubDir' -import { getAllLocalWallets } from './lib/utils/localWallets' -import { validateHost } from './lib/utils/validateHost' -import { getDb } from './store/db' -import { getDbName } from './lib/utils/db' +import { getDb } from '@zap/app/store/db' +import isSubDir from '@zap/utils/isSubDir' +import { getAllLocalWallets } from '@zap/utils/localWallets' +import { validateHost } from '@zap/utils/validateHost' +import { getDbName } from '@zap/utils/db' const fsReadFile = promisify(fs.readFile) const fsRimraf = promisify(rimraf) diff --git a/app/lib/zap/updater.js b/electron/updater.js similarity index 94% rename from app/lib/zap/updater.js rename to electron/updater.js index 277eeb0864a..4856a26e95a 100644 --- a/app/lib/zap/updater.js +++ b/electron/updater.js @@ -1,8 +1,8 @@ import { dialog } from 'electron' import { autoUpdater } from 'electron-updater' import isDev from 'electron-is-dev' -import { updaterLog } from '../utils/log' -import delay from '../utils/delay' +import { updaterLog } from '@zap/utils/log' +import delay from '@zap/utils/delay' autoUpdater.logger = updaterLog diff --git a/app/lib/i18n/index.js b/i18n/index.js similarity index 100% rename from app/lib/i18n/index.js rename to i18n/index.js diff --git a/app/lib/i18n/locale.js b/i18n/locale.js similarity index 100% rename from app/lib/i18n/locale.js rename to i18n/locale.js diff --git a/i18n/translation.js b/i18n/translation.js new file mode 100644 index 00000000000..73274da1951 --- /dev/null +++ b/i18n/translation.js @@ -0,0 +1,45 @@ +// Load translation data. +import bgTranslationMessages from '@zap/translations/bg-BG.json' +import csTranslationMessages from '@zap/translations/cs-CZ.json' +import deTranslationMessages from '@zap/translations/de-DE.json' +import elTranslationMessages from '@zap/translations/el-GR.json' +import enTranslationMessages from '@zap/translations/en.json' +import esTranslationMessages from '@zap/translations/es-ES.json' +import frTranslationMessages from '@zap/translations/fr-FR.json' +import gaTranslationMessages from '@zap/translations/ga-IE.json' +import hrTranslationMessages from '@zap/translations/hr-HR.json' +import jaTranslationMessages from '@zap/translations/ja-JP.json' +import nlTranslationMessages from '@zap/translations/nl-NL.json' +import ptTranslationMessages from '@zap/translations/pt-BR.json' +import roTranslationMessages from '@zap/translations/ro-RO.json' +import ruTranslationMessages from '@zap/translations/ru-RU.json' +import svTranslationMessages from '@zap/translations/sv-SE.json' +import trTranslationMessages from '@zap/translations/tr-TR.json' +import ukTranslationMessages from '@zap/translations/uk-UA.json' +import zhCNTranslationMessages from '@zap/translations/zh-CN.json' +import zhTWTranslationMessages from '@zap/translations/zh-TW.json' + +// Collate all translations. +const translations = { + en: enTranslationMessages, + bg: bgTranslationMessages, + 'zh-CN': zhCNTranslationMessages, + 'zh-TW': zhTWTranslationMessages, + hr: hrTranslationMessages, + cs: csTranslationMessages, + nl: nlTranslationMessages, + fr: frTranslationMessages, + ga: gaTranslationMessages, + de: deTranslationMessages, + el: elTranslationMessages, + ja: jaTranslationMessages, + pt: ptTranslationMessages, + ro: roTranslationMessages, + ru: ruTranslationMessages, + es: esTranslationMessages, + sv: svTranslationMessages, + tr: trTranslationMessages, + uk: ukTranslationMessages, +} + +export default translations diff --git a/app/lib/lnd/config.js b/lnd/config.js similarity index 99% rename from app/lib/lnd/config.js rename to lnd/config.js index bcce5a590a4..c5a331a55ed 100644 --- a/app/lib/lnd/config.js +++ b/lnd/config.js @@ -10,7 +10,7 @@ import lndconnect from 'lndconnect' import fs from 'fs' import util from 'util' import pick from 'lodash.pick' -import { mainLog } from '../utils/log' +import { mainLog } from '@zap/utils/log' import { binaryPath } from './util' // When we run in production mode, this file is processd with webpack and our config is made available in the diff --git a/app/lib/lnd/lightning.js b/lnd/lightning.js similarity index 98% rename from app/lib/lnd/lightning.js rename to lnd/lightning.js index ab3d4a02714..21258eab747 100644 --- a/app/lib/lnd/lightning.js +++ b/lnd/lightning.js @@ -6,6 +6,9 @@ import { load } from '@grpc/proto-loader' import lndgrpc from 'lnd-grpc' import { BrowserWindow } from 'electron' import StateMachine from 'javascript-state-machine' +import { promisifiedCall } from '@zap/utils' +import { validateHost } from '@zap/utils/validateHost' +import { mainLog } from '@zap/utils/log' import LndConfig from './config' import { grpcOptions, @@ -15,10 +18,7 @@ import { createMacaroonCreds, waitForFile, } from './util' -import { promisifiedCall } from '../utils' -import { validateHost } from '../utils/validateHost' import methods from './methods' -import { mainLog } from '../utils/log' import subscribeToTransactions from './subscribe/transactions' import subscribeToInvoices from './subscribe/invoices' import subscribeToChannelGraph from './subscribe/channelgraph' diff --git a/app/lib/lnd/methods/channelController.js b/lnd/methods/channelController.js similarity index 98% rename from app/lib/lnd/methods/channelController.js rename to lnd/methods/channelController.js index 964ae0e4f1b..a97541cae8d 100644 --- a/app/lib/lnd/methods/channelController.js +++ b/lnd/methods/channelController.js @@ -1,6 +1,6 @@ +import { promisifiedCall } from '@zap/utils' import { listPeers, connectPeer } from './peersController' import pushopenchannel from '../push/openchannel' -import { promisifiedCall } from '../../utils' function ensurePeerConnected(lnd, pubkey, host) { return listPeers(lnd).then(({ peers }) => { diff --git a/app/lib/lnd/methods/index.js b/lnd/methods/index.js similarity index 100% rename from app/lib/lnd/methods/index.js rename to lnd/methods/index.js diff --git a/app/lib/lnd/methods/invoicesController.js b/lnd/methods/invoicesController.js similarity index 97% rename from app/lib/lnd/methods/invoicesController.js rename to lnd/methods/invoicesController.js index 0a849144c2e..e6959c679b4 100644 --- a/app/lib/lnd/methods/invoicesController.js +++ b/lnd/methods/invoicesController.js @@ -1,5 +1,5 @@ +import { promisifiedCall } from '@zap/utils' import pushinvoices from '../push/subscribeinvoice' -import { promisifiedCall } from '../../utils' // When we run in production mode, this file is processd with webpack and our config is made available in the // global CONFIG object. If this is not set then we must be running in development mode (where this file is loaded diff --git a/app/lib/lnd/methods/networkController.js b/lnd/methods/networkController.js similarity index 97% rename from app/lib/lnd/methods/networkController.js rename to lnd/methods/networkController.js index e63da8f94e1..45bef8fffe2 100644 --- a/app/lib/lnd/methods/networkController.js +++ b/lnd/methods/networkController.js @@ -1,4 +1,4 @@ -import { promisifiedCall } from '../../utils' +import { promisifiedCall } from '@zap/utils' /** * [info description] * @param {[type]} lnd [description] diff --git a/app/lib/lnd/methods/paymentsController.js b/lnd/methods/paymentsController.js similarity index 96% rename from app/lib/lnd/methods/paymentsController.js rename to lnd/methods/paymentsController.js index 1a84eb30136..30d445f5bc7 100644 --- a/app/lib/lnd/methods/paymentsController.js +++ b/lnd/methods/paymentsController.js @@ -1,5 +1,5 @@ +import { promisifiedCall } from '@zap/utils' import pushpayment from '../push/sendpayment' -import { promisifiedCall } from '../../utils' /** * Dispatches a bi-directional streaming RPC for sending payments through the Lightning Network. diff --git a/app/lib/lnd/methods/peersController.js b/lnd/methods/peersController.js similarity index 95% rename from app/lib/lnd/methods/peersController.js rename to lnd/methods/peersController.js index 91c908b08a6..b6bb3a508c1 100644 --- a/app/lib/lnd/methods/peersController.js +++ b/lnd/methods/peersController.js @@ -1,4 +1,4 @@ -import { promisifiedCall } from '../../utils' +import { promisifiedCall } from '@zap/utils' /** * Attempts to establish a connection to a remote peer * @param {[type]} lnd [description] diff --git a/app/lib/lnd/methods/walletController.js b/lnd/methods/walletController.js similarity index 98% rename from app/lib/lnd/methods/walletController.js rename to lnd/methods/walletController.js index 346f1f86fff..044add479c1 100644 --- a/app/lib/lnd/methods/walletController.js +++ b/lnd/methods/walletController.js @@ -1,4 +1,4 @@ -import { promisifiedCall } from '../../utils' +import { promisifiedCall } from '@zap/utils' /** * Returns the sum of all confirmed unspent outputs under control by the wallet diff --git a/app/lib/lnd/neutrino.js b/lnd/neutrino.js similarity index 99% rename from app/lib/lnd/neutrino.js rename to lnd/neutrino.js index 933fa022d57..76f90d102dc 100644 --- a/app/lib/lnd/neutrino.js +++ b/lnd/neutrino.js @@ -3,7 +3,7 @@ import split2 from 'split2' import { spawn } from 'child_process' import EventEmitter from 'events' -import { mainLog, lndLog, lndLogGetLevel } from '../utils/log' +import { mainLog, lndLog, lndLogGetLevel } from '@zap/utils/log' import { fetchBlockHeight } from './util' import LndConfig from './config' diff --git a/app/lib/lnd/push/closechannel.js b/lnd/push/closechannel.js similarity index 100% rename from app/lib/lnd/push/closechannel.js rename to lnd/push/closechannel.js diff --git a/app/lib/lnd/push/openchannel.js b/lnd/push/openchannel.js similarity index 96% rename from app/lib/lnd/push/openchannel.js rename to lnd/push/openchannel.js index 4a1f75b2742..84b0a115218 100644 --- a/app/lib/lnd/push/openchannel.js +++ b/lnd/push/openchannel.js @@ -1,4 +1,4 @@ -import { mainLog } from '../../utils/log' +import { mainLog } from '@zap/utils/log' const parsePayload = payload => ({ ...payload, diff --git a/app/lib/lnd/push/sendpayment.js b/lnd/push/sendpayment.js similarity index 95% rename from app/lib/lnd/push/sendpayment.js rename to lnd/push/sendpayment.js index 3c42090feb5..f1266f9caee 100644 --- a/app/lib/lnd/push/sendpayment.js +++ b/lnd/push/sendpayment.js @@ -1,5 +1,5 @@ -import { mainLog } from '../../utils/log' -import { decodePayReq } from '../../utils/crypto' +import { mainLog } from '@zap/utils/log' +import { decodePayReq } from '@zap/utils/crypto' export default function pushpayment(lnd, event, payload) { return new Promise((resolve, reject) => { diff --git a/app/lib/lnd/push/subscribeinvoice.js b/lnd/push/subscribeinvoice.js similarity index 100% rename from app/lib/lnd/push/subscribeinvoice.js rename to lnd/push/subscribeinvoice.js diff --git a/app/lib/lnd/subscribe/channelgraph.js b/lnd/subscribe/channelgraph.js similarity index 94% rename from app/lib/lnd/subscribe/channelgraph.js rename to lnd/subscribe/channelgraph.js index b629cf117a9..6e591337459 100644 --- a/app/lib/lnd/subscribe/channelgraph.js +++ b/lnd/subscribe/channelgraph.js @@ -1,5 +1,5 @@ import { status } from '@grpc/grpc-js' -import { mainLog } from '../../utils/log' +import { mainLog } from '@zap/utils/log' export default function subscribeToChannelGraph() { const call = this.service.subscribeChannelGraph({}) diff --git a/app/lib/lnd/subscribe/invoices.js b/lnd/subscribe/invoices.js similarity index 92% rename from app/lib/lnd/subscribe/invoices.js rename to lnd/subscribe/invoices.js index 481529c76f3..8d1975c4552 100644 --- a/app/lib/lnd/subscribe/invoices.js +++ b/lnd/subscribe/invoices.js @@ -1,5 +1,5 @@ import { status } from '@grpc/grpc-js' -import { mainLog } from '../../utils/log' +import { mainLog } from '@zap/utils/log' export default function subscribeToInvoices() { const call = this.service.subscribeInvoices({}) diff --git a/app/lib/lnd/subscribe/transactions.js b/lnd/subscribe/transactions.js similarity index 93% rename from app/lib/lnd/subscribe/transactions.js rename to lnd/subscribe/transactions.js index 31a8003c4b0..c56b666c584 100644 --- a/app/lib/lnd/subscribe/transactions.js +++ b/lnd/subscribe/transactions.js @@ -1,5 +1,5 @@ import { status } from '@grpc/grpc-js' -import { mainLog } from '../../utils/log' +import { mainLog } from '@zap/utils/log' export default function subscribeToTransactions() { const call = this.service.subscribeTransactions({}) diff --git a/app/lib/lnd/util.js b/lnd/util.js similarity index 99% rename from app/lib/lnd/util.js rename to lnd/util.js index fb0fbc478ca..d17877b85c7 100644 --- a/app/lib/lnd/util.js +++ b/lnd/util.js @@ -8,7 +8,7 @@ import isDev from 'electron-is-dev' import { credentials, Metadata } from '@grpc/grpc-js' import get from 'lodash.get' import lndconnect from 'lndconnect' -import { mainLog } from '../utils/log' +import { mainLog } from '@zap/utils/log' const readFile = promisify(fs.readFile) const stat = promisify(fs.stat) diff --git a/app/lib/lnd/walletUnlocker.js b/lnd/walletUnlocker.js similarity index 97% rename from app/lib/lnd/walletUnlocker.js rename to lnd/walletUnlocker.js index 5571d40f76f..682fc4afaf6 100644 --- a/app/lib/lnd/walletUnlocker.js +++ b/lnd/walletUnlocker.js @@ -5,11 +5,11 @@ import { loadPackageDefinition } from '@grpc/grpc-js' import { load } from '@grpc/proto-loader' import lndgrpc from 'lnd-grpc' import StateMachine from 'javascript-state-machine' +import { validateHost } from '@zap/utils/validateHost' +import { mainLog } from '@zap/utils/log' import LndConfig from './config' import { grpcOptions, lndGpcProtoPath, getDeadline, createSslCreds } from './util' -import { validateHost } from '../utils/validateHost' import methods from './walletUnlockerMethods' -import { mainLog } from '../utils/log' /** * Creates an LND grpc client lightning service. diff --git a/app/lib/lnd/walletUnlockerMethods/index.js b/lnd/walletUnlockerMethods/index.js similarity index 100% rename from app/lib/lnd/walletUnlockerMethods/index.js rename to lnd/walletUnlockerMethods/index.js diff --git a/package.json b/package.json index 2b8f5a351c2..e378e0ed27b 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "release": "npm run package -- --publish onTagOrDraft", "postinstall": "concurrently --raw \"npm:flow-typed\" \"npm:build-dll\" \"build install-app-deps\"", "prestart": "cross-env NODE_CONFIG_ENV=production npm run build", - "start": "cross-env NODE_ENV=production electron ./app", - "start-main-dev": "electron -r @babel/register ./app/main.js", + "start": "cross-env NODE_ENV=production electron .", + "start-main-dev": "electron -r @babel/register ./electron/main.js", "start-renderer-dev": "webpack-dev-server -r @babel/register --config webpack/webpack.config.renderer.dev.js --progress", "storybook": "cross-env NODE_ENV=storybook start-storybook -p 6006", "storybook:build": "cross-env NODE_ENV=storybook build-storybook", @@ -60,7 +60,7 @@ }, "sideEffects": false, "browserslist": [ - "electron 3.0" + "electron 4.0" ], "engines": { "node": ">=8.11.2", @@ -78,7 +78,7 @@ "files": [ "dist/", "package.json", - "lib/zap/about/" + "electron/about/" ], "directories": { "buildResources": "resources", @@ -243,6 +243,7 @@ "babel-eslint": "10.0.1", "babel-jest": "24.5.0", "babel-loader": "8.0.5", + "babel-plugin-module-resolver": "3.2.0", "babel-plugin-react-intl": "3.0.1", "babel-plugin-react-intl-auto": "1.7.0", "babel-plugin-styled-components": "1.8.0", @@ -256,6 +257,7 @@ "cross-env": "5.2.0", "cross-spawn": "6.0.5", "csp-html-webpack-plugin": "3.0.1", + "electron": "4.1.1", "electron-builder": "20.39.0", "electron-devtools-installer": "2.2.4", "electron-updater": "4.0.6", @@ -266,6 +268,7 @@ "eslint-config-airbnb": "17.1.0", "eslint-config-prettier": "4.1.0", "eslint-formatter-pretty": "2.1.1", + "eslint-import-resolver-babel-module": "5.0.1", "eslint-import-resolver-webpack": "0.11.0", "eslint-plugin-compat": "3.0.1", "eslint-plugin-flowtype": "3.4.2", @@ -335,7 +338,6 @@ "debug-logger": "0.4.1", "dexie": "2.0.4", "downshift": "3.2.7", - "electron": "4.1.0", "electron-is-dev": "1.0.1", "get-port": "4.2.0", "history": "4.7.2", @@ -381,8 +383,5 @@ "window-or-global": "1.0.1", "yup": "0.26.10" }, - "main": "webpack/webpack.config.base.js", - "directories": { - "test": "test" - } + "main": "./dist/main.prod.js" } diff --git a/stories/Provider.js b/stories/Provider.js index 6a78293eadf..96516fc242a 100644 --- a/stories/Provider.js +++ b/stories/Provider.js @@ -1,14 +1,14 @@ import React from 'react' import PropTypes from 'prop-types' -import 'lib/i18n/locale' -import translations from 'lib/i18n/translation' +import '@zap/i18n/locale' +import translations from '@zap/i18n/translation' import EventEmitter from 'events' import { Provider as ReduxProvider } from 'react-intl-redux' import jstz from 'jstimezonedetect' -import { configureStore } from 'store/configureStore' -import { getDefaultLocale } from 'lib/i18n' -import { getDb } from 'store/db' -import { getDbName } from 'lib/utils/db' +import { configureStore } from '@zap/app/store/configureStore' +import { getDefaultLocale } from '@zap/i18n' +import { getDb } from '@zap/app/store/db' +import { getDbName } from '@zap/utils/db' export const db = getDb(getDbName(CONFIG)) db.open() diff --git a/stories/containers/home.stories.js b/stories/containers/home.stories.js index df877b8f924..d24214ce054 100644 --- a/stories/containers/home.stories.js +++ b/stories/containers/home.stories.js @@ -4,7 +4,7 @@ import { action } from '@storybook/addon-actions' import { linkTo } from '@storybook/addon-links' import { boolean } from '@storybook/addon-knobs' import StoryRouter from 'storybook-react-router' -import delay from 'lib/utils/delay' +import delay from '@zap/utils/delay' import Home from 'components/Home' import { Provider, store } from '../Provider' import { Window } from '../helpers' diff --git a/stories/containers/onboarding.stories.js b/stories/containers/onboarding.stories.js index a52d9121851..b2510cde02f 100644 --- a/stories/containers/onboarding.stories.js +++ b/stories/containers/onboarding.stories.js @@ -3,7 +3,7 @@ import { storiesOf } from '@storybook/react' import { action } from '@storybook/addon-actions' import { linkTo } from '@storybook/addon-links' import { State, Store } from '@sambego/storybook-state' -import delay from 'lib/utils/delay' +import delay from '@zap/utils/delay' import { Modal } from 'components/UI' import { Onboarding } from 'components/Onboarding' import { Window } from '../helpers' diff --git a/stories/containers/request.stories.js b/stories/containers/request.stories.js index 3a41f020936..b42d9aabfe1 100644 --- a/stories/containers/request.stories.js +++ b/stories/containers/request.stories.js @@ -5,7 +5,7 @@ import { storiesOf } from '@storybook/react' import { action } from '@storybook/addon-actions' import { text } from '@storybook/addon-knobs' import lightningPayReq from 'bolt11' -import { convert } from 'lib/utils/btc' +import { convert } from '@zap/utils/btc' import { Modal } from 'components/UI' import { Request } from 'components/Request' import { tickerSelectors } from 'reducers/ticker' diff --git a/stories/containers/request/request.component.stories.js b/stories/containers/request/request.component.stories.js index 95af2821abe..6b92f601848 100644 --- a/stories/containers/request/request.component.stories.js +++ b/stories/containers/request/request.component.stories.js @@ -5,7 +5,7 @@ import { storiesOf } from '@storybook/react' import { action } from '@storybook/addon-actions' import { text } from '@storybook/addon-knobs' import lightningPayReq from 'bolt11' -import { convert } from 'lib/utils/btc' +import { convert } from '@zap/utils/btc' import { RequestSummary } from 'components/Request' import { Provider } from '../../Provider' diff --git a/stories/helpers.js b/stories/helpers.js index 62901f093ab..724e11e76c6 100644 --- a/stories/helpers.js +++ b/stories/helpers.js @@ -1,7 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { Box, Flex } from 'rebass' -import { Bar, Heading, Page } from 'components/UI' +import { Bar, Heading, Page } from '@zap/app/components/UI' import lightningPayReq from 'bolt11' export const Window = props => diff --git a/test/e2e/utils/helpers.js b/test/e2e/utils/helpers.js index 3ace6f9ab6f..83ad6fd8722 100644 --- a/test/e2e/utils/helpers.js +++ b/test/e2e/utils/helpers.js @@ -3,7 +3,7 @@ import path from 'path' import rimraf from 'rimraf' // Get the path to the index page. -export const getBaseUrl = () => '../../app/dist/index.html' +export const getBaseUrl = () => '../../dist/index.html' // Get the current page title. export const getPageTitle = ClientFunction(() => document.title) diff --git a/test/unit/__helpers__/intl-enzyme-test-helper.js b/test/unit/__helpers__/intl-enzyme-test-helper.js index 620134159d3..8fc2ecc18a7 100644 --- a/test/unit/__helpers__/intl-enzyme-test-helper.js +++ b/test/unit/__helpers__/intl-enzyme-test-helper.js @@ -12,7 +12,7 @@ import { IntlProvider, intlShape } from 'react-intl' import { mount, shallow } from 'enzyme' // Ppass default messages to the IntlProvider. -const messages = require('../../../translations/en.json') +import messages from '@zap/translations/en.json' // Create the IntlProvider to retrieve context for wrapping around. const intlProvider = new IntlProvider({ locale: 'en', messages }, {}) diff --git a/test/unit/lnd/lightning.spec.js b/test/unit/lnd/lightning.spec.js index eb9b2a47277..ed07abc7ffc 100644 --- a/test/unit/lnd/lightning.spec.js +++ b/test/unit/lnd/lightning.spec.js @@ -1,9 +1,9 @@ import { BrowserWindow } from 'electron' -import Lightning from 'lib/lnd/lightning' +import Lightning from '@zap/lnd/lightning' -jest.mock('lib/lnd/subscribe/transactions') -jest.mock('lib/lnd/subscribe/invoices') -jest.mock('lib/lnd/subscribe/channelgraph') +jest.mock('@zap/lnd/subscribe/transactions') +jest.mock('@zap/lnd/subscribe/invoices') +jest.mock('@zap/lnd/subscribe/channelgraph') describe('Lightning', function() { describe('Constructor', () => { diff --git a/test/unit/lnd/lnd-config.spec.js b/test/unit/lnd/lnd-config.spec.js index 3d8c231a383..bca97a10e4b 100644 --- a/test/unit/lnd/lnd-config.spec.js +++ b/test/unit/lnd/lnd-config.spec.js @@ -1,11 +1,11 @@ // @flow import { join } from 'path' -import LndConfig from 'lib/lnd/config' +import LndConfig from '@zap/lnd/config' -jest.mock('lib/lnd/util', () => { +jest.mock('../../../lnd/util', () => { return { - ...jest.requireActual('lib/lnd/util'), + ...jest.requireActual('../../../lnd/util'), binaryName: 'binaryName', binaryPath: () => 'binaryPath', } diff --git a/test/unit/lnd/neutrino.spec.js b/test/unit/lnd/neutrino.spec.js index a26bf9dc023..ba816dbda67 100644 --- a/test/unit/lnd/neutrino.spec.js +++ b/test/unit/lnd/neutrino.spec.js @@ -1,7 +1,7 @@ // @flow -import Neutrino from 'lib/lnd/neutrino' -import LndConfig from 'lib/lnd/config' +import Neutrino from '@zap/lnd/neutrino' +import LndConfig from '@zap/lnd/config' import mockSpawn from 'mock-spawn' jest.mock('child_process', () => { diff --git a/test/unit/utils/btc.spec.js b/test/unit/utils/btc.spec.js index 0e34a5c80e0..2377deaac81 100644 --- a/test/unit/utils/btc.spec.js +++ b/test/unit/utils/btc.spec.js @@ -17,7 +17,7 @@ import { millisatoshisToBtc, millisatoshisToFiat, convert, -} from 'lib/utils/btc' +} from '@zap/utils/btc' describe('btc.btcToBits', () => { it('should return 1 when 100 satoshis are passed in', () => { diff --git a/test/unit/utils/crypto.spec.js b/test/unit/utils/crypto.spec.js index f1c27898b53..e66bfd81d06 100644 --- a/test/unit/utils/crypto.spec.js +++ b/test/unit/utils/crypto.spec.js @@ -1,5 +1,5 @@ /* eslint-disable max-len */ -import { formatValue, isLn, isOnchain } from 'lib/utils/crypto' +import { formatValue, isLn, isOnchain } from '@zap/utils/crypto' const VALID_BITCOIN_MAINNET_LN = 'lnbc10u1pduey89pp57gt0mqvh9gv4m5kkxmy9a0a46ha5jlzr3mcfcz2fx8tzu63vpjksdq8w3jhxaqcqzystfg0drarrx89nvpegwykvfr4fypvwz2d9ktcr6tj5s08f0nn8gdjnv74y9amksk3rjw7englhjrsev70k77vwf603qh2pr4tnqeue6qp5n92gy' diff --git a/test/unit/utils/isStableVersion.spec.js b/test/unit/utils/isStableVersion.spec.js index 0faf20d0285..53ff1c4d74e 100644 --- a/test/unit/utils/isStableVersion.spec.js +++ b/test/unit/utils/isStableVersion.spec.js @@ -1,4 +1,4 @@ -import { isStableVersion } from 'lib/utils' +import { isStableVersion } from '@zap/utils' const STABLE_VERSION = '0.3.x' diff --git a/test/unit/utils/isSubDir.spec.js b/test/unit/utils/isSubDir.spec.js index 1462538315c..97487f19fa7 100644 --- a/test/unit/utils/isSubDir.spec.js +++ b/test/unit/utils/isSubDir.spec.js @@ -1,4 +1,4 @@ -import { isSubDir } from 'lib/utils' +import { isSubDir } from '@zap/utils' import os from 'os' describe('isSubDir', () => { diff --git a/test/unit/utils/userFriendlyErrors.spec.js b/test/unit/utils/userFriendlyErrors.spec.js index 62339378f38..f53461ed848 100644 --- a/test/unit/utils/userFriendlyErrors.spec.js +++ b/test/unit/utils/userFriendlyErrors.spec.js @@ -1,4 +1,4 @@ -import errorToUserFriendly from 'lib/utils/userFriendlyErrors' +import errorToUserFriendly from '@zap/utils/userFriendlyErrors' describe('userFriendlyErrors', () => { describe('errorToUserFriendly', () => { diff --git a/test/unit/utils/validateHost.spec.js b/test/unit/utils/validateHost.spec.js index 004eb1c4ef6..2d929c22a6e 100644 --- a/test/unit/utils/validateHost.spec.js +++ b/test/unit/utils/validateHost.spec.js @@ -1,4 +1,4 @@ -import { validateHost } from 'lib/utils/validateHost' +import { validateHost } from '@zap/utils/validateHost' jest.mock('dns') diff --git a/test/unit/zap/controller.spec.js b/test/unit/zap/controller.spec.js index 65b77008d05..dded18e940a 100644 --- a/test/unit/zap/controller.spec.js +++ b/test/unit/zap/controller.spec.js @@ -1,7 +1,7 @@ -import ZapController from 'lib/zap/controller' -import Lightning from 'lib/lnd/lightning' +import ZapController from '@zap/electron/controller' +import Lightning from '@zap/lnd/lightning' -jest.mock('lib/lnd/lightning') +jest.mock('@zap/lnd/lightning') describe('ZapController', function() { describe('Constructor', () => { diff --git a/app/lib/utils/api.js b/utils/api.js similarity index 100% rename from app/lib/utils/api.js rename to utils/api.js diff --git a/app/lib/utils/blockExplorer.js b/utils/blockExplorer.js similarity index 100% rename from app/lib/utils/blockExplorer.js rename to utils/blockExplorer.js diff --git a/app/lib/utils/btc.js b/utils/btc.js similarity index 100% rename from app/lib/utils/btc.js rename to utils/btc.js diff --git a/app/lib/utils/btcpayserver.js b/utils/btcpayserver.js similarity index 100% rename from app/lib/utils/btcpayserver.js rename to utils/btcpayserver.js diff --git a/app/lib/utils/connectionString.js b/utils/connectionString.js similarity index 96% rename from app/lib/utils/connectionString.js rename to utils/connectionString.js index d82c01aac2e..64e793f206a 100644 --- a/app/lib/utils/connectionString.js +++ b/utils/connectionString.js @@ -1,8 +1,8 @@ import decode from 'lndconnect/decode' import parse from 'lndconnect/parse' import get from 'lodash.get' +import { isBase64url } from '@zap/utils' -import { isBase64url } from '.' /** * Check for a valid lndconnect uri. * @param {String} value String to validate. diff --git a/app/lib/utils/crypto.js b/utils/crypto.js similarity index 100% rename from app/lib/utils/crypto.js rename to utils/crypto.js diff --git a/app/lib/utils/db.js b/utils/db.js similarity index 100% rename from app/lib/utils/db.js rename to utils/db.js diff --git a/app/lib/utils/delay.js b/utils/delay.js similarity index 100% rename from app/lib/utils/delay.js rename to utils/delay.js diff --git a/app/lib/utils/fileExists.js b/utils/fileExists.js similarity index 100% rename from app/lib/utils/fileExists.js rename to utils/fileExists.js diff --git a/app/lib/utils/genId.js b/utils/genId.js similarity index 100% rename from app/lib/utils/genId.js rename to utils/genId.js diff --git a/app/lib/utils/getDisplayName.js b/utils/getDisplayName.js similarity index 100% rename from app/lib/utils/getDisplayName.js rename to utils/getDisplayName.js diff --git a/app/lib/utils/getPackageDetails.js b/utils/getPackageDetails.js similarity index 60% rename from app/lib/utils/getPackageDetails.js rename to utils/getPackageDetails.js index 7a3af3a70b3..32f600e6b58 100644 --- a/app/lib/utils/getPackageDetails.js +++ b/utils/getPackageDetails.js @@ -1,5 +1,5 @@ function getPackageDetails() { - const { productName, version } = require('../../package.json') + const { productName, version } = require('../package.json') return { productName, version } } diff --git a/app/lib/utils/index.js b/utils/index.js similarity index 100% rename from app/lib/utils/index.js rename to utils/index.js diff --git a/app/lib/utils/isBase64url.js b/utils/isBase64url.js similarity index 100% rename from app/lib/utils/isBase64url.js rename to utils/isBase64url.js diff --git a/app/lib/utils/isStableVersion.js b/utils/isStableVersion.js similarity index 100% rename from app/lib/utils/isStableVersion.js rename to utils/isStableVersion.js diff --git a/app/lib/utils/isSubDir.js b/utils/isSubDir.js similarity index 100% rename from app/lib/utils/isSubDir.js rename to utils/isSubDir.js diff --git a/app/lib/utils/localWallets.js b/utils/localWallets.js similarity index 100% rename from app/lib/utils/localWallets.js rename to utils/localWallets.js diff --git a/app/lib/utils/log.js b/utils/log.js similarity index 100% rename from app/lib/utils/log.js rename to utils/log.js diff --git a/app/lib/utils/notifications.js b/utils/notifications.js similarity index 100% rename from app/lib/utils/notifications.js rename to utils/notifications.js diff --git a/app/lib/utils/promiseTimeout.js b/utils/promiseTimeout.js similarity index 100% rename from app/lib/utils/promiseTimeout.js rename to utils/promiseTimeout.js diff --git a/app/lib/utils/promisifiedCall.js b/utils/promisifiedCall.js similarity index 100% rename from app/lib/utils/promisifiedCall.js rename to utils/promisifiedCall.js diff --git a/app/lib/utils/sanitize.js b/utils/sanitize.js similarity index 100% rename from app/lib/utils/sanitize.js rename to utils/sanitize.js diff --git a/app/lib/utils/truncate.js b/utils/truncate.js similarity index 100% rename from app/lib/utils/truncate.js rename to utils/truncate.js diff --git a/app/lib/utils/userFriendlyErrors.js b/utils/userFriendlyErrors.js similarity index 100% rename from app/lib/utils/userFriendlyErrors.js rename to utils/userFriendlyErrors.js diff --git a/app/lib/utils/validateHost.js b/utils/validateHost.js similarity index 100% rename from app/lib/utils/validateHost.js rename to utils/validateHost.js diff --git a/webpack/webpack.config.base.js b/webpack/webpack.config.base.js index 28e7c14f6a1..d26da5324aa 100644 --- a/webpack/webpack.config.base.js +++ b/webpack/webpack.config.base.js @@ -20,6 +20,7 @@ export default { use: { loader: 'babel-loader', options: { + rootMode: 'upward', cacheDirectory: true, }, }, diff --git a/webpack/webpack.config.main.prod.js b/webpack/webpack.config.main.prod.js index f166a83e3ca..78c2d8c06d1 100644 --- a/webpack/webpack.config.main.prod.js +++ b/webpack/webpack.config.main.prod.js @@ -18,11 +18,11 @@ export default merge.smart(baseConfig, { externals: ['config'], entry: { - main: path.join(rootDir, 'app', 'main'), + main: path.join(rootDir, 'electron', 'main'), }, output: { - path: path.join(rootDir, 'app', 'dist'), + path: path.join(rootDir, 'dist'), filename: '[name].prod.js', }, diff --git a/webpack/webpack.config.preload.dev.js b/webpack/webpack.config.preload.dev.js index 91e2e9cc2a0..60057eecae4 100644 --- a/webpack/webpack.config.preload.dev.js +++ b/webpack/webpack.config.preload.dev.js @@ -16,11 +16,11 @@ export default merge.smart(baseConfig, { mode: 'development', entry: { - preload: path.join(rootDir, 'app', 'preload'), + preload: path.join(rootDir, 'electron', 'preload'), }, output: { - path: path.join(rootDir, 'app', 'dist'), + path: path.join(rootDir, 'dist'), filename: '[name].dev.js', }, diff --git a/webpack/webpack.config.preload.prod.js b/webpack/webpack.config.preload.prod.js index 486408387dc..f0b618f7884 100644 --- a/webpack/webpack.config.preload.prod.js +++ b/webpack/webpack.config.preload.prod.js @@ -16,11 +16,11 @@ export default merge.smart(baseConfig, { mode: 'production', entry: { - preload: path.join(rootDir, 'app', 'preload'), + preload: path.join(rootDir, 'electron', 'preload'), }, output: { - path: path.join(rootDir, 'app', 'dist'), + path: path.join(rootDir, 'dist'), filename: '[name].prod.js', }, diff --git a/webpack/webpack.config.renderer.dev.dll.js b/webpack/webpack.config.renderer.dev.dll.js index f7a018677f6..8e7f5702703 100644 --- a/webpack/webpack.config.renderer.dev.dll.js +++ b/webpack/webpack.config.renderer.dev.dll.js @@ -45,10 +45,6 @@ export default merge.smart(baseConfig, { ], }, - resolve: { - modules: ['app'], - }, - entry: { renderer: Object.keys(dependencies), }, @@ -69,7 +65,7 @@ export default merge.smart(baseConfig, { new webpack.LoaderOptionsPlugin({ debug: true, options: { - context: path.join(rootDir, 'app'), + context: path.join(rootDir), output: { path: path.join(rootDir, 'dll'), }, diff --git a/webpack/webpack.config.renderer.dev.js b/webpack/webpack.config.renderer.dev.js index c30481c3198..ab5093d203d 100644 --- a/webpack/webpack.config.renderer.dev.js +++ b/webpack/webpack.config.renderer.dev.js @@ -15,8 +15,8 @@ import { spawn, execSync } from 'child_process' import HtmlWebpackPlugin from 'html-webpack-plugin' import AddAssetHtmlPlugin from 'add-asset-html-webpack-plugin' import CspHtmlWebpackPlugin from 'csp-html-webpack-plugin' +import { mainLog } from '@zap/utils/log' import baseConfig, { rootDir } from './webpack.config.base' -import { mainLog } from '../app/lib/utils/log' const port = process.env.PORT || 1212 const publicPath = `http://localhost:${port}/dist` diff --git a/webpack/webpack.config.renderer.prod.js b/webpack/webpack.config.renderer.prod.js index 62df67e8df5..b19ae0851f4 100644 --- a/webpack/webpack.config.renderer.prod.js +++ b/webpack/webpack.config.renderer.prod.js @@ -11,7 +11,7 @@ import CleanWebpackPlugin from 'clean-webpack-plugin' import CopyWebpackPlugin from 'copy-webpack-plugin' import merge from 'webpack-merge' import baseConfig, { rootDir } from './webpack.config.base' -import { dependencies as externals } from '../app/package.json' +import { dependencies as externals } from '../package.json' export default merge.smart(baseConfig, { devtool: 'source-map', @@ -27,7 +27,7 @@ export default merge.smart(baseConfig, { }, output: { - path: path.join(rootDir, 'app', 'dist'), + path: path.join(rootDir, 'dist'), filename: '[name].prod.js', }, @@ -46,7 +46,7 @@ export default merge.smart(baseConfig, { }, plugins: [ - new CleanWebpackPlugin([path.resolve('app', 'dist')], { + new CleanWebpackPlugin([path.resolve('dist')], { root: path.resolve(rootDir), }), @@ -60,7 +60,7 @@ export default merge.smart(baseConfig, { new CopyWebpackPlugin([ path.join('app', 'empty.html'), - { from: path.join('app/lib/zap/about', 'preload.js'), to: 'about_preload.prod.js' }, + { from: path.join('electron/about', 'preload.js'), to: 'about_preload.prod.js' }, ]), new CspHtmlWebpackPlugin({ diff --git a/yarn.lock b/yarn.lock index e191fb40416..99bff15344c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2494,11 +2494,16 @@ resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.0.tgz#719551d2352d301ac8b81db732acb6bdc28dbdef" integrity sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q== -"@types/node@*", "@types/node@^10.1.0", "@types/node@^10.12.18": +"@types/node@*", "@types/node@^10.1.0": version "10.12.18" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67" integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ== +"@types/node@^10.12.18": + version "10.14.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.4.tgz#1c586b991457cbb58fef51bc4e0cfcfa347714b5" + integrity sha512-DT25xX/YgyPKiHFOpNuANIQIVvYEwCWXgK2jYYwqgaMrYE6+tq+DtmMwlD3drl6DJbUwtlIDnn0d7tIn/EbXBg== + "@types/node@^10.12.19": version "10.12.26" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.26.tgz#2dec19f1f7981c95cb54bab8f618ecb5dc983d0e" @@ -3762,6 +3767,17 @@ babel-plugin-minify-type-constructors@^0.4.3: dependencies: babel-helper-is-void-0 "^0.4.3" +babel-plugin-module-resolver@3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/babel-plugin-module-resolver/-/babel-plugin-module-resolver-3.2.0.tgz#ddfa5e301e3b9aa12d852a9979f18b37881ff5a7" + integrity sha512-tjR0GvSndzPew/Iayf4uICWZqjBwnlMWjSx6brryfQ81F9rxBVqwDJtFCV8oOs0+vJeefK9TmdZtkIFdFe1UnA== + dependencies: + find-babel-config "^1.1.0" + glob "^7.1.2" + pkg-up "^2.0.0" + reselect "^3.0.1" + resolve "^1.4.0" + babel-plugin-named-asset-import@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/babel-plugin-named-asset-import/-/babel-plugin-named-asset-import-0.3.1.tgz#5ec13ec446d0a1e5bb6c57a1f94c9cdedb0c50d6" @@ -6970,10 +6986,10 @@ electron-updater@4.0.6: semver "^5.6.0" source-map-support "^0.5.9" -electron@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/electron/-/electron-4.1.0.tgz#ecba9c83de271e8ba7637332ece9ed023c6ea3f0" - integrity sha512-q/yTi9dT5UEFK/s+vOQaHNkTHWiRK9kEBYVJt34nmWc9piW42hXT+nhKUEHHhccMPr3q18gG0iPZqeR+LG76ow== +electron@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/electron/-/electron-4.1.1.tgz#dc9343ba829cabbf01364761e72796f766704184" + integrity sha512-ABIEXTw55eiCW30a6F8fWLHL0QeH+yK3JgZpvTZZWLnkO5/SmG38avMxRhKOUQstRpYb+EEpE8IAM2DVOaTvtw== dependencies: "@types/node" "^10.12.18" electron-download "^4.1.0" @@ -7271,6 +7287,14 @@ eslint-formatter-pretty@2.1.1: string-width "^2.0.0" supports-hyperlinks "^1.0.1" +eslint-import-resolver-babel-module@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-babel-module/-/eslint-import-resolver-babel-module-5.0.1.tgz#02e36fbefa7aaf8ff0d298ed2651ea48ad26dd1e" + integrity sha512-q1IDVrpXAKz90t4x/S9RUeQgSK5wfH1AF/tR3iUAmLeCiAEVep/tNtX9EhQjut8DLgloUfUHoJWd8QCAJXhv+A== + dependencies: + pkg-up "^2.0.0" + resolve "^1.10.0" + eslint-import-resolver-node@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a" @@ -8039,6 +8063,14 @@ finalhandler@1.1.1: statuses "~1.4.0" unpipe "~1.0.0" +find-babel-config@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/find-babel-config/-/find-babel-config-1.2.0.tgz#a9b7b317eb5b9860cda9d54740a8c8337a2283a2" + integrity sha512-jB2CHJeqy6a820ssiqwrKMeyC6nNdmrcgkKWJWmpoxpE8RKciYJXCcXRq1h2AzCo5I5BJeN2tkGEO3hLTuePRA== + dependencies: + json5 "^0.5.1" + path-exists "^3.0.0" + find-cache-dir@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f" @@ -12814,7 +12846,7 @@ pkg-dir@^3.0.0: dependencies: find-up "^3.0.0" -pkg-up@2.0.0: +pkg-up@2.0.0, pkg-up@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f" integrity sha1-yBmscoBZpGHKscOImivjxJoATX8= @@ -14559,6 +14591,11 @@ reselect@4.0.0: resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7" integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA== +reselect@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/reselect/-/reselect-3.0.1.tgz#efdaa98ea7451324d092b2b2163a6a1d7a9a2147" + integrity sha1-79qpjqdFEyTQkrKyFjpqHXqaIUc= + resize-observer-polyfill@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"