From fb17d1b3f92408ce17a780cc4a2550d27a24b973 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 6 Jun 2018 17:01:39 -0400 Subject: [PATCH] Ugly progress commit --- Makefile | 3 --- package.json | 11 +++++--- rollup.config.js | 5 ---- rollup.dev.js | 7 ++--- rollup.prod.js | 4 +++ src/Routes.js | 5 ++-- src/constants/build.js | 4 +++ src/constants/index.js | 2 +- src/constants/redux-actions.js | 2 -- src/electron/app.js | 37 ++++++++++++++++---------- src/index.js | 1 + yarn.lock | 47 +++++++++++++++++++++++++++++++++- 12 files changed, 94 insertions(+), 34 deletions(-) create mode 100644 src/constants/build.js delete mode 100644 src/constants/redux-actions.js diff --git a/Makefile b/Makefile index f920ece..107934a 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,4 @@ lint: node_modules node_modules: yarn --ignore-engines -react-start: node_modules - yarn inferno-start - .PHONY: all clean electron-start fix lint react-start diff --git a/package.json b/package.json index 65d93c1..f488c7b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "private": true, "build": { "appId": "net.timshomepage.film-exif", - "asar": false, + "asar": true, "copyright": "Copyright © year ${author}", "files": [ "src/**/*", @@ -20,6 +20,7 @@ } }, "dependencies": { + "better-sqlite3": "^4.1.1", "electron-log": "^2.2.14", "esm": "^3.0.40", "exiftool-vendored": "^4.25.0", @@ -42,6 +43,7 @@ "bootstrap": "^4", "electron": "^2.0.2", "electron-builder": "^20.15.1", + "electron-devtools-installer": "^2.2.4", "eslint": "^4.19.1", "eslint-config-happiness": "^10.2.1", "eslint-config-inferno-app": "^6.2.0", @@ -53,6 +55,7 @@ "eslint-plugin-promise": "^3.8.0", "eslint-plugin-standard": "^3.0.1", "husky": "^0.14.3", + "inferno-devtools": "^5.0.6", "jest": "^23.0.1", "jquery": "^3.3.1", "raf": "^3.4.0", @@ -70,18 +73,18 @@ "rollup-plugin-uglify": "^4.0.0", "rollup-plugin-visualizer": "^0.6.0" }, + "homepage": "/", "scripts": { "build": "set NODE_ENV=production && rollup --config rollup.prod.js", "dist": "yarn run build && build", - "electron-start": "node src/electron/wait-inferno", + "electron-start": "set NODE_ENV=development && node src/electron/wait-inferno", "electron": "electron .", "fix": "eslint --fix src/**/*.js", - "inferno-start": "rollup --config rollup.dev.js --watch", + "inferno-start": "set NODE_ENV=development && rollup --config rollup.dev.js --watch", "lint": "eslint src/**/*.js", "pack": "build --dir", "postinstall": "electron-builder install-app-deps", "precommit": "yarn lint", - "react-start": "npm run inferno-start", "test": "node scripts/test.js --env=jsdom" }, "main": "src/electron/index.js", diff --git a/rollup.config.js b/rollup.config.js index f49c4db..8ce809c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,7 +1,6 @@ import babel from 'rollup-plugin-babel'; import copy from 'rollup-plugin-copy'; import commonjs from 'rollup-plugin-commonjs'; -import replace from 'rollup-plugin-replace'; import resolve from 'rollup-plugin-node-resolve'; export default { @@ -17,10 +16,6 @@ export default { 'public/favicon.ico': 'build/favicon.ico', 'public/css/bootstrap.css': 'build/css/bootstrap.css', 'public/css/app.css': 'build/css/app.css', - verbose: true, - }), - replace({ - 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), }), resolve({ jsnext: true, diff --git a/rollup.dev.js b/rollup.dev.js index 77c835b..34513d5 100644 --- a/rollup.dev.js +++ b/rollup.dev.js @@ -3,18 +3,19 @@ import baseConfig from './rollup.config'; import alias from 'rollup-plugin-alias'; import filesize from 'rollup-plugin-filesize'; import livereload from 'rollup-plugin-livereload'; +import replace from 'rollup-plugin-replace'; import serve from 'rollup-plugin-serve'; import visualizer from 'rollup-plugin-visualizer'; -// Force the appropriate environment -process.env.NODE_ENV = 'development'; - export default { ...baseConfig, plugins: [ alias({ 'inferno': `${__dirname}/node_modules/inferno/dist/index.dev.esm.js`, }), + replace({ + 'process.env.NODE_ENV': "'development'", + }), ...baseConfig.plugins, filesize(), serve({ diff --git a/rollup.prod.js b/rollup.prod.js index 092073e..4dda7c6 100644 --- a/rollup.prod.js +++ b/rollup.prod.js @@ -1,10 +1,14 @@ import baseConfig from './rollup.config'; import filesize from 'rollup-plugin-filesize'; +import replace from 'rollup-plugin-replace'; import { terser } from 'rollup-plugin-terser'; export default { ...baseConfig, plugins: [ + replace({ + 'process.env.NODE_ENV': "'production'", + }), ...baseConfig.plugins, terser(), filesize(), diff --git a/src/Routes.js b/src/Routes.js index 87b863d..fc7b8d2 100644 --- a/src/Routes.js +++ b/src/Routes.js @@ -1,4 +1,4 @@ -import { Route, Switch } from 'inferno-router'; +import { Redirect, Route, Switch } from 'inferno-router'; import { CameraAddView, @@ -9,7 +9,8 @@ import { export const Routes = () => ( - + } /> + diff --git a/src/constants/build.js b/src/constants/build.js new file mode 100644 index 0000000..ef07e6d --- /dev/null +++ b/src/constants/build.js @@ -0,0 +1,4 @@ +const packageJson = require('../../package.json'); + +export const BUILD_ENV = process.env.NODE_ENV; +export const BUILD_VERSION = packageJson.version; diff --git a/src/constants/index.js b/src/constants/index.js index 42eaf89..555cb3e 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -1 +1 @@ -export * from '//constants/redux-actions'; +export * from './build'; diff --git a/src/constants/redux-actions.js b/src/constants/redux-actions.js deleted file mode 100644 index 1dfde13..0000000 --- a/src/constants/redux-actions.js +++ /dev/null @@ -1,2 +0,0 @@ -export const OPEN_FILES = 'OPEN_FILES'; -export const OPEN_FOLDER = 'OPEN_FOLDER'; diff --git a/src/electron/app.js b/src/electron/app.js index f4f104a..212e391 100644 --- a/src/electron/app.js +++ b/src/electron/app.js @@ -1,4 +1,5 @@ import {app, BrowserWindow} from 'electron'; +import installExtension, { REACT_DEVELOPER_TOOLS } from 'electron-devtools-installer'; import log from 'electron-log'; import path from 'path'; import url from 'url'; @@ -6,18 +7,35 @@ import url from 'url'; log.transports.file.level = false; log.transports.console.level = 'info'; +const DEV_MODE = process.env.NODE_ENV === 'development'; + // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow; const createWindow = () => { // Create the browser window. - mainWindow = new BrowserWindow({ - webPreferences: { - contextIsolation: true, - nodeIntegration: false, - }, - }); + if (DEV_MODE) { + mainWindow = new BrowserWindow(); + } else { + mainWindow = new BrowserWindow({ + webPreferences: { + contextIsolation: true, + nodeIntegration: false, + }, + }); + } + + // Open the DevTools. + if (DEV_MODE) { + installExtension(REACT_DEVELOPER_TOOLS) + .then((extensionName) => console.log(`Added Extension: ${extensionName}`)) + .catch((err) => console.log('An error occurred: ', err)); + + mainWindow.webContents.openDevTools({ + mode: 'bottom', + }); + } // load the index.html of the app. const startUrl = process.env.ELECTRON_START_URL || url.format({ @@ -27,13 +45,6 @@ const createWindow = () => { }); mainWindow.loadURL(startUrl); - // Open the DevTools. - if (process.env.NODE_ENV !== 'production') { - mainWindow.webContents.openDevTools({ - mode: 'bottom', - }); - } - // Emitted when the window is closed. mainWindow.on('closed', () => { // Dereference the window object, usually you would store windows diff --git a/src/index.js b/src/index.js index 163b60d..71e8e52 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ import { render } from 'inferno'; +import 'inferno-devtools'; import { App } from '//App'; render(, document.getElementById('app')); diff --git a/yarn.lock b/yarn.lock index 5f1d3a2..8e46452 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6,6 +6,10 @@ version "4.0.2" resolved "https://registry.npmjs.org/7zip-bin/-/7zip-bin-4.0.2.tgz#6abbdc22f33cab742053777a26db2e25ca527179" +"7zip@0.0.6": + version "0.0.6" + resolved "https://registry.npmjs.org/7zip/-/7zip-0.0.6.tgz#9cafb171af82329490353b4816f03347aa150a30" + "@babel/code-frame@7.0.0-beta.44": version "7.0.0-beta.44" resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9" @@ -1535,10 +1539,22 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +better-sqlite3@^4.1.1: + version "4.1.1" + resolved "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-4.1.1.tgz#090a82bcebbd77f003dcf1b07a6ce1b65ec5c2fe" + dependencies: + bindings "^1.3.0" + integer "^1.0.3" + lzz-gyp "^0.4.3" + binary-extensions@^1.0.0: version "1.11.0" resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205" +bindings@^1.3.0: + version "1.3.0" + resolved "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7" + bluebird-lst@^1.0.5: version "1.0.5" resolved "https://registry.npmjs.org/bluebird-lst/-/bluebird-lst-1.0.5.tgz#bebc83026b7e92a72871a3dc599e219cbfb002a9" @@ -2014,6 +2030,10 @@ cross-spawn@^5.0.1, cross-spawn@^5.1.0: shebang-command "^1.2.0" which "^1.2.9" +cross-unzip@0.0.2: + version "0.0.2" + resolved "https://registry.npmjs.org/cross-unzip/-/cross-unzip-0.0.2.tgz#5183bc47a09559befcf98cc4657964999359372f" + crypto-random-string@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" @@ -2306,6 +2326,15 @@ electron-builder@^20.15.1: update-notifier "^2.5.0" yargs "^11.0.0" +electron-devtools-installer@^2.2.4: + version "2.2.4" + resolved "https://registry.npmjs.org/electron-devtools-installer/-/electron-devtools-installer-2.2.4.tgz#261a50337e37121d338b966f07922eb4939a8763" + dependencies: + "7zip" "0.0.6" + cross-unzip "0.0.2" + rimraf "^2.5.2" + semver "^5.3.0" + electron-download-tf@4.3.4: version "4.3.4" resolved "https://registry.npmjs.org/electron-download-tf/-/electron-download-tf-4.3.4.tgz#b03740b2885aa2ad3f8784fae74df427f66d5165" @@ -3374,6 +3403,10 @@ inferno-dev-utils@^5.3.0: strip-ansi "4.0.0" text-table "0.2.0" +inferno-devtools@^5.0.6: + version "5.0.6" + resolved "https://registry.npmjs.org/inferno-devtools/-/inferno-devtools-5.0.6.tgz#4fb856aa01c9eb0889dd39b518c68d3f4e1bb79c" + inferno-error-overlay@^4.3.0: version "4.3.0" resolved "https://registry.npmjs.org/inferno-error-overlay/-/inferno-error-overlay-4.3.0.tgz#11d9fc2603b79aaa10b50c5106d089a5783c5571" @@ -3483,6 +3516,12 @@ inquirer@^3.0.6: strip-ansi "^4.0.0" through "^2.3.6" +integer@^1.0.3: + version "1.0.3" + resolved "https://registry.npmjs.org/integer/-/integer-1.0.3.tgz#6e6403896de6781c50974c5adf9eea9bb0ce6acb" + dependencies: + bindings "^1.3.0" + invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2: version "2.2.4" resolved "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" @@ -4397,6 +4436,12 @@ lru-cache@^4.0.1: pseudomap "^1.0.2" yallist "^2.1.2" +lzz-gyp@^0.4.3: + version "0.4.3" + resolved "https://registry.npmjs.org/lzz-gyp/-/lzz-gyp-0.4.3.tgz#a7dff682c5be969aaf6c3ba7ae11eb0196ca160b" + dependencies: + which "^1.3.0" + magic-string@^0.22.4: version "0.22.5" resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz#8e9cf5afddf44385c1da5bc2a6a0dbd10b03657e" @@ -5500,7 +5545,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.1: +rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1: version "2.6.2" resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: