From 8a4d4986fbbfde71ce62631f0060d63a02338d46 Mon Sep 17 00:00:00 2001 From: yaniv kalfa Date: Mon, 3 Sep 2018 18:44:34 -0400 Subject: [PATCH] fixed permissions issues --- .../extraResources}/locales/en-US.json | 0 .../extraResources}/locales/es.json | 0 .../extraResources}/locales/ko.json | 0 .../extraResources}/locales/pt-BR.json | 0 .../extraResources}/locales/zh-CN.json | 0 app/utils/i18n.js | 4 +-- app/utils/settings.js | 4 +-- app/utils/wallet.js | 4 +-- internals/scripts/CheckWalletStateExist.js | 16 +++++++++- package.json | 4 +-- webpack.config.renderer.prod.js | 15 +++++++++- yarn.lock | 30 +++++++++++++++++++ 12 files changed, 66 insertions(+), 11 deletions(-) rename {extraResources => app/extraResources}/locales/en-US.json (100%) rename {extraResources => app/extraResources}/locales/es.json (100%) rename {extraResources => app/extraResources}/locales/ko.json (100%) rename {extraResources => app/extraResources}/locales/pt-BR.json (100%) rename {extraResources => app/extraResources}/locales/zh-CN.json (100%) diff --git a/extraResources/locales/en-US.json b/app/extraResources/locales/en-US.json similarity index 100% rename from extraResources/locales/en-US.json rename to app/extraResources/locales/en-US.json diff --git a/extraResources/locales/es.json b/app/extraResources/locales/es.json similarity index 100% rename from extraResources/locales/es.json rename to app/extraResources/locales/es.json diff --git a/extraResources/locales/ko.json b/app/extraResources/locales/ko.json similarity index 100% rename from extraResources/locales/ko.json rename to app/extraResources/locales/ko.json diff --git a/extraResources/locales/pt-BR.json b/app/extraResources/locales/pt-BR.json similarity index 100% rename from extraResources/locales/pt-BR.json rename to app/extraResources/locales/pt-BR.json diff --git a/extraResources/locales/zh-CN.json b/app/extraResources/locales/zh-CN.json similarity index 100% rename from extraResources/locales/zh-CN.json rename to app/extraResources/locales/zh-CN.json diff --git a/app/utils/i18n.js b/app/utils/i18n.js index 87d983ab..32905b1e 100644 --- a/app/utils/i18n.js +++ b/app/utils/i18n.js @@ -13,9 +13,9 @@ export function createIl8nInstance(locale) { debug: true, backend: { loadPath: () => { - const filename = `../extraResources/locales/{{lng}}.json`; + const filename = `extraResources/locales/{{lng}}.json`; if (process.env.NODE_ENV === 'production') { - return path.join(remote.app.getAppPath(), filename); + return path.join(remote.app.getAppPath(), 'dist',filename); } return path.join(__dirname, filename); } diff --git a/app/utils/settings.js b/app/utils/settings.js index 727e58de..bfb4e504 100644 --- a/app/utils/settings.js +++ b/app/utils/settings.js @@ -3,9 +3,9 @@ import path from 'path'; import fs from 'fs'; const fileName = 'walletSettings.json'; -let filePath = path.join(__dirname, '../extraResources/', fileName); +let filePath = path.join(__dirname, 'extraResources/', fileName); if (process.env.NODE_ENV === 'production') { - filePath = path.join(remote.app.getAppPath(), '../extraResources/', fileName); + filePath = path.join(remote.app.getAppPath(), 'dist', 'extraResources/', fileName); } export function getWalletSettings() { diff --git a/app/utils/wallet.js b/app/utils/wallet.js index 7ef5a892..93680426 100644 --- a/app/utils/wallet.js +++ b/app/utils/wallet.js @@ -6,9 +6,9 @@ import { TezosWallet } from 'conseiljs'; const { saveWallet, loadWallet } = TezosWallet; const fileName = 'walletState'; -let walletStatePath = path.join(__dirname, '../extraResources/', fileName); +let walletStatePath = path.join(__dirname, 'extraResources/', fileName); if (process.env.NODE_ENV === 'production') { - walletStatePath = path.join(remote.app.getAppPath(), '../extraResources/', fileName); + walletStatePath = path.join(remote.app.getAppPath(), 'dist', 'extraResources/', fileName); } export async function saveUpdatedWallet(identities, walletLocation, walletFileName, password) { diff --git a/internals/scripts/CheckWalletStateExist.js b/internals/scripts/CheckWalletStateExist.js index 3418048e..a8a97591 100644 --- a/internals/scripts/CheckWalletStateExist.js +++ b/internals/scripts/CheckWalletStateExist.js @@ -5,7 +5,7 @@ import fs from 'fs'; * Hacky solution to solve permission issues with linux * */ const fileName = 'walletState'; -const walletStatePath = path.join(__dirname, '../../extraResources/', fileName); +const walletStatePath = path.join(__dirname, '../../app/extraResources/', fileName); if (fs.existsSync(walletStatePath)) { fs.unlinkSync(walletStatePath); } @@ -15,3 +15,17 @@ fs.writeFileSync( Buffer.from(JSON.stringify({}), 'binary') ); fs.chmodSync(walletStatePath, 511); + +const walletSettings = 'walletSettings.json'; +const walletSettingsPath = path.join(__dirname, '../../app/extraResources/', walletSettings); +let walletSettingsContent = ''; +if (fs.existsSync(walletSettingsPath)) { + walletSettingsContent = fs.readFileSync(walletSettingsPath); + fs.unlinkSync(walletSettingsPath); +} + +fs.writeFileSync( + walletSettingsPath, + Buffer.from(walletSettingsContent) +); +fs.chmodSync(walletSettingsPath, 511); \ No newline at end of file diff --git a/package.json b/package.json index c9abcfd6..10753a96 100644 --- a/package.json +++ b/package.json @@ -44,9 +44,6 @@ "build": { "productName": "Tezori", "appId": "tech.cryptonomic.Tezori", - "extraResources": [ - "./extraResources/**/*" - ], "files": [ "dist/", "node_modules/", @@ -141,6 +138,7 @@ "babel-register": "^6.26.0", "chalk": "^2.4.1", "concurrently": "^3.5.1", + "copy-webpack-plugin": "^4.5.2", "cross-env": "^5.1.6", "cross-spawn": "^6.0.5", "css-loader": "^0.28.11", diff --git a/webpack.config.renderer.prod.js b/webpack.config.renderer.prod.js index f2fc5eaf..2b9fe3f8 100644 --- a/webpack.config.renderer.prod.js +++ b/webpack.config.renderer.prod.js @@ -10,6 +10,7 @@ import merge from 'webpack-merge'; import UglifyJSPlugin from 'uglifyjs-webpack-plugin'; import baseConfig from './webpack.config.base'; import CheckNodeEnv from './internals/scripts/CheckNodeEnv'; +import CopyWebpackPlugin from 'copy-webpack-plugin'; CheckNodeEnv('production'); @@ -179,6 +180,18 @@ export default merge.smart(baseConfig, { analyzerMode: process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled', openAnalyzer: process.env.OPEN_ANALYZER === 'true' - }) + }), + + new CopyWebpackPlugin( + [ + { + from: 'app/extraResources/', + to: 'extraResources', + toType: 'dir' + } + ], + {} + ) + ] }); diff --git a/yarn.lock b/yarn.lock index 896f83a1..5c4d30f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2837,6 +2837,19 @@ copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" +copy-webpack-plugin@^4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.5.2.tgz#d53444a8fea2912d806e78937390ddd7e632ee5c" + dependencies: + cacache "^10.0.4" + find-cache-dir "^1.0.0" + globby "^7.1.1" + is-glob "^4.0.0" + loader-utils "^1.1.0" + minimatch "^3.0.4" + p-limit "^1.0.0" + serialize-javascript "^1.4.0" + core-js@^1.0.0: version "1.2.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" @@ -5127,6 +5140,17 @@ globby@^6.0.0, globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" +globby@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/globby/-/globby-7.1.1.tgz#fb2ccff9401f8600945dfada97440cca972b8680" + dependencies: + array-union "^1.0.1" + dir-glob "^2.0.0" + glob "^7.1.2" + ignore "^3.3.5" + pify "^3.0.0" + slash "^1.0.0" + globby@^8.0.0, globby@^8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/globby/-/globby-8.0.1.tgz#b5ad48b8aa80b35b814fc1281ecc851f1d2b5b50" @@ -8338,6 +8362,12 @@ p-lazy@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-lazy/-/p-lazy-1.0.0.tgz#ec53c802f2ee3ac28f166cc82d0b2b02de27a835" +p-limit@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + dependencies: + p-try "^1.0.0" + p-limit@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.2.0.tgz#0e92b6bedcb59f022c13d0f1949dc82d15909f1c"