From 62d72a16e8857907d35c5f7dc825abc480831ea1 Mon Sep 17 00:00:00 2001 From: Pavel Evstigneev Date: Sun, 22 Oct 2017 20:50:38 +0800 Subject: [PATCH] Small changes --- CONTRIBUTING.md | 4 +- app/views/panes/query.js | 4 +- app/window_handlers/history_window_loader.js | 2 +- app/window_handlers/snippets_window_loader.js | 2 +- index.js | 3 +- lib/error_reporter.js | 45 +++++++++++++++++-- package.json | 4 -- packager.js | 22 +++++++-- yarn.lock | 20 ++++----- 9 files changed, 75 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 72b08828..77d56e6e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,8 +27,8 @@ Electron packager or npm has a bug, it may include developer dependecies to rele # make sure you have ran "rake rebuild_ext" # delete "devDependencies" from package.json npm prune -npm install electron-packager@8.6.0 -sudo npm install -g electron@1.6.6 +npm install electron-packager@9.1.0 +sudo npm install -g electron@1.7.9 node packager.js rake build_dmg ``` diff --git a/app/views/panes/query.js b/app/views/panes/query.js index 868b4e2e..fee7f133 100644 --- a/app/views/panes/query.js +++ b/app/views/panes/query.js @@ -206,7 +206,9 @@ class Query extends Pane { ] }, (filename) => { console.log("selected", filename); - this.saveResultTo(filename); + if (filename) { + this.saveResultTo(filename); + } }); } diff --git a/app/window_handlers/history_window_loader.js b/app/window_handlers/history_window_loader.js index c41071a2..217a4324 100644 --- a/app/window_handlers/history_window_loader.js +++ b/app/window_handlers/history_window_loader.js @@ -8,7 +8,7 @@ require(__dirname + '/../lib/widgets/generic_table'); var RenderView = require(__dirname + '/../app/components/render_view'); require(__dirname + '/../lib/error_reporter'); -require('classy/object_extras').extendGlobal(); +require(__dirname + '/../lib/object_extras'); var remote = require('electron').remote; diff --git a/app/window_handlers/snippets_window_loader.js b/app/window_handlers/snippets_window_loader.js index 562c7154..b72d30e1 100644 --- a/app/window_handlers/snippets_window_loader.js +++ b/app/window_handlers/snippets_window_loader.js @@ -1,6 +1,6 @@ var jQuery = require(__dirname + '/../public/jquery.js'); require(__dirname + '/../lib/node_lib'); -require('classy/object_extras').extendGlobal(); +require(__dirname + '/../lib/object_extras'); require(__dirname + '/../lib/dominate'); require(__dirname + '/../lib/jquery.class'); diff --git a/index.js b/index.js index 68c8efe1..74a80809 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ global.errorReporter = require('./lib/error_reporter'); -require('classy/object_extras').extendGlobal(); +require('./lib/object_extras'); require('./lib/dominate'); require('./lib/jquery.class'); @@ -14,7 +14,6 @@ require('./lib/sql_importer'); require('./lib/pg_dump_runner'); require('./lib/sql_exporter'); require('./lib/pg_type_names'); -require('classy/object_ls'); require('./lib/sql_snippets'); require('./lib/resizable_columns'); diff --git a/lib/error_reporter.js b/lib/error_reporter.js index e2c141f2..66c9f9fa 100644 --- a/lib/error_reporter.js +++ b/lib/error_reporter.js @@ -1,4 +1,5 @@ global.log = require('../app/logger').make('info'); +var child_process = require('child_process'); var errorReporter = module.exports = function errorReporter(exception, showError = true) { setTimeout(function () { @@ -12,16 +13,52 @@ var errorReporter = module.exports = function errorReporter(exception, showError } catch (e) { log.info(e.message); } - return; + //return; } console.log("Sending error report"); console.error(exception); - log.info("Sending error report"); + log.info(`Sending error report ~ ${exception}`); var Raven = require('raven'); Raven.config('https://07fa68e1ac02484e9370fc9f0b77631f:2d27d42ff1514d4390500c8633a89442@sentry.io/143647', { - logger: 'default' + logger: 'default', + allowSecretKey: true, + transport: { + send(client, message, headers, eventId, cb) { + setTimeout(() => { + try { + var net = require('electron').remote.net; + var request = net.request({ + method: 'POST', + protocol: 'https:', + hostname: client.dsn.host, + path: client.dsn.path + 'api/' + client.dsn.project_id + '/store/', + headers: headers, + port: 443 + }); + + request.on('error', (error) => { + console.error(error); + }); + + request.on('abort', (error) => { + console.error('abort', error); + }); + + request.on('response', (res, a, b) => { + console.log('Error reported'); + }); + + request.end(message); + + window.ERR_REQ = request; + } catch (error) { + console.error(error); + } + }, 100); + } + } }).install(); var electron = require('electron'); @@ -59,7 +96,7 @@ var errorReporter = module.exports = function errorReporter(exception, showError }; if (process.platform == "darwin") { - var exec = global.node.child_process.exec; + var exec = child_process.exec; exec('sw_vers -productVersion', function (err, stdout, stderr) { extra.system = stdout; sender(); diff --git a/package.json b/package.json index 5d0b59ec..8341c3a4 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,6 @@ "test": "electron-mocha tests/", "integration_test": "mocha integration_tests/integration.js" }, - "engines": { - "node": "8.6.0" - }, "devDependencies": { "electron": "1.7.9", "electron-mocha": "^4.0.3", @@ -22,7 +19,6 @@ "spectron": "^3.7.2" }, "dependencies": { - "classy": "github:paxa/classy", "colors": "^1.1.2", "csv-stringify": "^2.0.0", "electron-window-state": "4.1.1", diff --git a/packager.js b/packager.js index 9b055d64..a0a3d03d 100644 --- a/packager.js +++ b/packager.js @@ -1,9 +1,11 @@ -var packager = require('electron-packager'); +var requireg = require('requireg') +var packager = requireg('electron-packager'); +var rebuild = requireg('electron-rebuild').rebuild; var packageJson = require('./package.json'); var child_process = require('child_process'); var opts = { - electronVersion: '1.6.2', + electronVersion: '1.7.9', dir: '.', arch: 'x64', platform: 'darwin', @@ -13,12 +15,24 @@ var opts = { buildVersion: packageJson.version, icon: 'build_files/icon.icns', name: packageJson.name, - prune: true, + //prune: true, overwrite: true, out: process.env.HOME + '/Postbird_release', protocol: 'postbird', extendInfo: 'build_files/Info.plist', - ignore: ['vendor/win32', 'build_files', 'tests', 'integration_tests', 'sugar', 'assets'] + ignore: [ + 'vendor/win32', 'vendor/datasets', 'build_files', 'tests', 'integration_tests', 'assets', + 'node_modules/pug/test', + 'node_modules/pug-lexer/test', + 'node_modules/pug-parser/test', + 'node_modules/pug-linker/test' + ], + asar: false, + afterCopy: [(buildPath, electronVersion, platform, arch, callback) => { + rebuild({ buildPath, electronVersion, arch }) + .then(() => callback()) + .catch((error) => callback(error)); + }] }; child_process.exec('git rev-list HEAD --count', (err, stdout, stderr) => { diff --git a/yarn.lock b/yarn.lock index f7f84e38..e8f82023 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3,8 +3,8 @@ "@types/node@^7.0.18": - version "7.0.43" - resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c" + version "7.0.46" + resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.46.tgz#c3dedd25558c676b3d6303e51799abb9c3f8f314" abbrev@1: version "1.1.1" @@ -324,10 +324,6 @@ chromium-pickle-js@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz#04a106672c18b085ab774d983dfa3ea138f22205" -"classy@github:paxa/classy": - version "0.0.2" - resolved "https://codeload.github.com/paxa/classy/tar.gz/187261e8cfb780018c56198a9cf6904d9a6f3325" - clean-css@^3.3.0: version "3.4.28" resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-3.4.28.tgz#bf1945e82fc808f55695e6ddeaec01400efd03ff" @@ -2015,8 +2011,8 @@ punycode@^1.4.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" q@^1.1.2, q@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1" + version "1.5.1" + resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" qs@~6.4.0: version "6.4.0" @@ -2041,8 +2037,8 @@ raven@2.2.1: uuid "3.0.0" rc@^1.1.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" + version "1.2.2" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.2.tgz#d8ce9cb57e8d64d9c7badd9876c7c34cbe3c7077" dependencies: deep-extend "~0.4.0" ini "~1.3.0" @@ -2248,8 +2244,8 @@ rx@^4.1.0: resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" rxjs@^5.1.1: - version "5.4.3" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.3.tgz#0758cddee6033d68e0fd53676f0f3596ce3d483f" + version "5.5.0" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.0.tgz#26d8f3866eb700e247e0728a147c3d628993d812" dependencies: symbol-observable "^1.0.1"