This commit is contained in:
crusader 2018-10-02 10:32:32 +09:00
parent b6657ac2a0
commit ea0af6c32b
14 changed files with 84 additions and 77 deletions

View File

@ -1,5 +1,5 @@
import * as Path from 'path'; import * as Path from 'path';
import fileUrl = require('file-url'); const fileUrl = require('file-url');
/** /**
* Resolve and encode the path information into a URL. * Resolve and encode the path information into a URL.

View File

@ -1,8 +1,6 @@
import * as Path from 'path'; import * as Path from 'path';
import * as Fs from 'fs'; import * as Fs from 'fs';
import * as sourceMapSupport from 'source-map-support';
const fileUriToPath: (uri: string) => string = require('file-uri-to-path');
const sourceMapSupport = require('source-map-support');
/** /**
* This array tells the source map logic which files that we can expect to * This array tells the source map logic which files that we can expect to
@ -16,6 +14,8 @@ const sourceMapSupport = require('source-map-support');
const knownFilesWithSourceMap = ['renderer.js', 'main.js']; const knownFilesWithSourceMap = ['renderer.js', 'main.js'];
function retrieveSourceMap(source: string) { function retrieveSourceMap(source: string) {
const fileUriToPath: (uri: string) => string = require('file-uri-to-path');
// This is a happy path in case we know for certain that we won't be // This is a happy path in case we know for certain that we won't be
// able to resolve a source map for the given location. // able to resolve a source map for the given location.
if (!knownFilesWithSourceMap.some(file => source.endsWith(file))) { if (!knownFilesWithSourceMap.some(file => source.endsWith(file))) {
@ -89,6 +89,7 @@ function prepareStackTrace(error: Error, frames: ReadonlyArray<any>) {
/** Enable source map support in the current process. */ /** Enable source map support in the current process. */
export function enableSourceMaps() { export function enableSourceMaps() {
sourceMapSupport.install({ sourceMapSupport.install({
environment: 'node', environment: 'node',
handleUncaughtExceptions: false, handleUncaughtExceptions: false,
@ -125,7 +126,7 @@ function sourceMappedStackTrace(error: Error): string | undefined {
// in our weak map. In order to get around that we'll eagerly access the // in our weak map. In order to get around that we'll eagerly access the
// stack, forcing our handler to run which should ensure that the native // stack, forcing our handler to run which should ensure that the native
// frames are stored in our weak map. // frames are stored in our weak map.
(error.stack || '').toString(); (error.stack || '').toString();
frames = stackFrameMap.get(error); frames = stackFrameMap.get(error);
} }

View File

@ -27,7 +27,7 @@
"tsConfig": "src/tsconfig.app.json", "tsConfig": "src/tsconfig.app.json",
"assets": [ "assets": [
"src/favicon.ico", "src/favicon.ico",
"src/assets" "src/assets/image"
], ],
"styles": [ "styles": [
"node_modules/primeicons/primeicons.css", "node_modules/primeicons/primeicons.css",

View File

@ -10,7 +10,6 @@ const channel = getReleaseChannel();
const s = JSON.stringify; const s = JSON.stringify;
function getReplacements() { function getReplacements() {
console.log(`channel: ${channel}`);
return { return {
__DARWIN__: process.platform === 'darwin', __DARWIN__: process.platform === 'darwin',
__WIN32__: process.platform === 'win32', __WIN32__: process.platform === 'win32',

View File

@ -1,22 +1,3 @@
#!/bin/bash #!/bin/bash
old_exec="/opt/Wire/wire"; setcap cap_net_raw,cap_net_admin=eip '/opt/${productFilename}/bin/probe'
# Warn if old package is still installed
if test -e "${old_exec}"; then
echo "WARNING: It seems that there are files from the old Wire package on"
echo "your machine. We highly recommend that you remove the old version"
echo "and then reinstall this package. You can remove the old package with"
echo "the following command:"
echo "sudo apt-get remove wire"
fi
# Clean up old invalid links
if [ -L '/usr/local/bin/wire' ] || [ -L '/usr/local/bin/<%= executable %>' ]; then
echo "Removing old invalid symlinks"
if [ -L '/usr/local/bin/wire' ] && [ "$(readlink '/usr/local/bin/wire')" = "${old_exec}" ]; then rm -f /usr/local/bin/wire; fi
if [ -L '/usr/local/bin/<%= executable %>' ] && [ "$(readlink '/usr/local/bin/<%= executable %>')" = '/opt/<% productFilename %>/<%= executable %>' ]; then rm -f '/usr/local/bin/<%= executable %>'; fi
fi
# Link to the binary
ln -sf '/opt/${productFilename}/${executable}' '/usr/bin/${executable}'

18
config/package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "overflow-network-scanner-app",
"version": "0.0.1",
"author": {
"name": "LOAFLE",
"email": "rnd@loafle.com",
"url": "https://www.loafle.com"
},
"homepage": "https://www.loafle.com",
"description": "Desktop App for overFlow Network Scanner",
"dependencies": {
"electron-devtools-installer": "^2.2.4",
"electron-window-state": "^5.0.1",
"file-url": "^2.0.2",
"rxjs": "^6.2.2",
"sqlite3": "^4.0.2"
}
}

View File

@ -1,5 +1,6 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ElectronConnectWebpackPlugin = require('electron-connect-webpack-plugin'); const ElectronConnectWebpackPlugin = require('electron-connect-webpack-plugin');
const nodeExternals = require('webpack-node-externals'); const nodeExternals = require('webpack-node-externals');
@ -57,6 +58,11 @@ module.exports = function () {
}; };
config.plugins = [ config.plugins = [
PROD ? new webpack.NoEmitOnErrorsPlugin() : null, PROD ? new webpack.NoEmitOnErrorsPlugin() : null,
PROD ? new CopyWebpackPlugin(
[
'config/package.json'
]
) : null,
new webpack.DefinePlugin( new webpack.DefinePlugin(
Object.assign({}, replacements, { Object.assign({}, replacements, {
__PROCESS_KIND__: JSON.stringify('main'), __PROCESS_KIND__: JSON.stringify('main'),

View File

@ -2,13 +2,21 @@
"appId": "com.loafle.overflow.scanner", "appId": "com.loafle.overflow.scanner",
"productName": "overFlow Network Scanner", "productName": "overFlow Network Scanner",
"copyright": "Copyright © 2016 LOAFLE", "copyright": "Copyright © 2016 LOAFLE",
"asar": false,
"compression": "normal",
"npmRebuild": false,
"npmSkipBuildFromSource": false,
"artifactName": "${name}-${version}-${os}-${arch}.${ext}",
"directories": { "directories": {
"app": "./build/dist",
"output": "./build/package" "output": "./build/package"
}, },
"files": [ "files": [
{ {
"filter": [ "filter": [
"**/*",
"!*.ts", "!*.ts",
"!*.scss",
"!*.code-workspace", "!*.code-workspace",
"!@overflow/", "!@overflow/",
"!build/", "!build/",
@ -27,50 +35,37 @@
"!tslint.json", "!tslint.json",
"!webpack.js", "!webpack.js",
"!yarn.lock" "!yarn.lock"
], ]
"from": "./build/dist", }
"to": "." ],
}, "extraFiles": [
"packages.json" {
"from": "config/_database.sqlite",
"to": "./bin/database.sqlite"
}
], ],
"asar": true,
"compression": "normal",
"npmRebuild": false,
"npmSkipBuildFromSource": false,
"artifactName": "${name}-${version}-${os}-${arch}.${ext}",
"linux": { "linux": {
"target": [ "target": [
{ {
"target": "deb", "target": "deb",
"arch": [ "arch": [
"x64", "x64"
"ia32"
] ]
} }
], ],
"executableName": "overFlow-Network-Scanner", "executableName": "overFlow-NetworkScanner",
"icon": "config/build/linux/icon/overflow.png", "icon": "config/build/linux/icon/overflow_512.png",
"synopsis": "overFlow Network Scanner", "synopsis": "overFlow Network Scanner",
"category": "Utility", "category": "Utility",
"extraFiles": [ "extraFiles": [
{ {
"from": "config/build/linux/bin/probe-${os}-${arch}", "from": "config/build/linux/bin/probe-${os}-${arch}",
"to": "./bin" "to": "./bin/probe"
} }
] ]
}, },
"deb": { "deb": {
"depends": [ "afterInstall": "config/build/linux/after-install.tpl"
"gconf2",
"gconf-service",
"libnotify4",
"libappindicator1",
"libxtst6",
"libnss3",
"libpcap"
],
"afterInstall": "config/build/linux/after-install.tpl",
"afterRemove": "config/build/linux/after-remove.tpl"
}, },
"mac": { "mac": {
"category": "public.app-category.utilities", "category": "public.app-category.utilities",

View File

@ -1,12 +1,13 @@
{ {
"name": "scanner-app", "name": "overflow-network-scanner-app",
"version": "0.0.0", "version": "0.0.1",
"author": { "author": {
"name": "LOAFLE", "name": "LOAFLE",
"email": "rnd@loafle.com", "email": "rnd@loafle.com",
"url": "https://www.loafle.com" "url": "https://www.loafle.com"
}, },
"homepage": "https://www.loafle.com", "homepage": "https://www.loafle.com",
"description": "Desktop App for overFlow Network Scanner",
"scripts": { "scripts": {
"postinstall": "yarn electron:builder:install-app-deps", "postinstall": "yarn electron:builder:install-app-deps",
"ng": "ng", "ng": "ng",
@ -59,9 +60,11 @@
"@types/jasmine": "~2.8.6", "@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",
"@types/node": "^8.10.4", "@types/node": "^8.10.4",
"@types/source-map-support": "^0.4.1",
"@types/sqlite3": "^3.1.3", "@types/sqlite3": "^3.1.3",
"awesome-typescript-loader": "^5.2.0", "awesome-typescript-loader": "^5.2.0",
"codelyzer": "~4.2.1", "codelyzer": "~4.2.1",
"copy-webpack-plugin": "^4.5.2",
"core-js": "^2.5.4", "core-js": "^2.5.4",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"d3": "^5.7.0", "d3": "^5.7.0",

View File

@ -74,7 +74,7 @@ export class AppWindow {
'build', 'build',
'linux', 'linux',
'icon', 'icon',
'overflow_512.png' 'overflow_512_shadow.png'
); );
} }

View File

@ -1,13 +1,14 @@
import { app, Menu, ipcMain, BrowserWindow, shell } from 'electron'; import { app, Menu, ipcMain, BrowserWindow, shell } from 'electron';
import * as fse from 'fs-extra'; import * as fse from 'fs-extra';
import * as path from 'path'; import * as path from 'path';
import * as ChildProcess from 'child_process';
import { shellNeedsPatching, updateEnvironmentForProcess } from '@overflow/core/shell'; import { shellNeedsPatching, updateEnvironmentForProcess } from '@overflow/core/shell';
import { parseAppURL } from '@overflow/core/parse-app-url'; import { parseAppURL } from '@overflow/core/parse-app-url';
import { // import {
enableSourceMaps, // enableSourceMaps,
withSourceMappedStack, // withSourceMappedStack,
} from '@overflow/core/source-map-support'; // } from '@overflow/core/source-map-support';
import { now } from '@overflow/core/now'; import { now } from '@overflow/core/now';
import { IMenuItem } from '@overflow/core/menu-item'; import { IMenuItem } from '@overflow/core/menu-item';
@ -23,7 +24,7 @@ import { IMenuItemState } from '../commons/model/menu-update';
import * as sqlite3 from 'sqlite3'; import * as sqlite3 from 'sqlite3';
enableSourceMaps(); // enableSourceMaps();
let mainWindow: AppWindow | null = null; let mainWindow: AppWindow | null = null;
@ -48,12 +49,12 @@ function handleUncaughtException(error: Error) {
// showUncaughtException(isLaunchError, error); // showUncaughtException(isLaunchError, error);
} }
process.on('uncaughtException', (error: Error) => { // process.on('uncaughtException', (error: Error) => {
error = withSourceMappedStack(error); // error = withSourceMappedStack(error);
// reportError(error); // // reportError(error);
handleUncaughtException(error); // handleUncaughtException(error);
}); // });
const handlingSquirrelEvent = false; const handlingSquirrelEvent = false;
// if (__WIN32__ && process.argv.length > 1) { // if (__WIN32__ && process.argv.length > 1) {
@ -181,7 +182,9 @@ app.on('ready', () => {
return; return;
} }
const dbPath = path.join(__dirname, '..', '..', '_database.sqlite'); const dbPath = __DEV__ ?
path.join(__dirname, '..', '..', 'config', '_database.sqlite')
: path.join(__dirname, '..', '..', 'bin', 'database.sqlite');
const db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => { const db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => {
if (err) { if (err) {
@ -190,6 +193,11 @@ app.on('ready', () => {
console.log('Connected to the database.'); console.log('Connected to the database.');
}); });
if (!__DEV__) {
const probePath = path.join(__dirname, '..', '..', 'bin', 'probe');
ChildProcess.spawn(probePath);
}
readyTime = now() - launchTime; readyTime = now() - launchTime;
// setAsDefaultProtocolClient('x-github-client'); // setAsDefaultProtocolClient('x-github-client');

View File

@ -574,6 +574,12 @@
version "2.53.43" version "2.53.43"
resolved "https://nexus.loafle.net/repository/npm-all/@types/selenium-webdriver/-/selenium-webdriver-2.53.43.tgz#2de3d718819bc20165754c4a59afb7e9833f6707" resolved "https://nexus.loafle.net/repository/npm-all/@types/selenium-webdriver/-/selenium-webdriver-2.53.43.tgz#2de3d718819bc20165754c4a59afb7e9833f6707"
"@types/source-map-support@^0.4.1":
version "0.4.1"
resolved "https://nexus.loafle.net/repository/npm-all/@types/source-map-support/-/source-map-support-0.4.1.tgz#ad77158e8c6695a16629ef82b9fb9dfe7c610ac0"
dependencies:
"@types/node" "*"
"@types/sqlite3@^3.1.3": "@types/sqlite3@^3.1.3":
version "3.1.3" version "3.1.3"
resolved "https://nexus.loafle.net/repository/npm-all/@types/sqlite3/-/sqlite3-3.1.3.tgz#580d547203b8ad6e11aa6a6769c8ca5d7e197d13" resolved "https://nexus.loafle.net/repository/npm-all/@types/sqlite3/-/sqlite3-3.1.3.tgz#580d547203b8ad6e11aa6a6769c8ca5d7e197d13"
@ -790,12 +796,6 @@ amdefine@>=0.0.4:
version "1.0.1" version "1.0.1"
resolved "https://nexus.loafle.net/repository/npm-all/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" resolved "https://nexus.loafle.net/repository/npm-all/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
angular-page-visibility@^6.1.3:
version "6.1.3"
resolved "https://nexus.loafle.net/repository/npm-all/angular-page-visibility/-/angular-page-visibility-6.1.3.tgz#d2cfaa5a73aec195f393be03cf9fc45f9b293e16"
dependencies:
tslib "^1.9.0"
ansi-align@^2.0.0: ansi-align@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://nexus.loafle.net/repository/npm-all/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f" resolved "https://nexus.loafle.net/repository/npm-all/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f"
@ -6504,10 +6504,6 @@ rx@^4.1.0:
version "4.1.0" version "4.1.0"
resolved "https://nexus.loafle.net/repository/npm-all/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" resolved "https://nexus.loafle.net/repository/npm-all/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782"
rxjs-compat@^6.3.3:
version "6.3.3"
resolved "https://nexus.loafle.net/repository/npm-all/rxjs-compat/-/rxjs-compat-6.3.3.tgz#2ab3b9ac0dac0c073749d55fef9c03ea1df2045c"
rxjs@^6.0.0, rxjs@^6.2.2: rxjs@^6.0.0, rxjs@^6.2.2:
version "6.3.3" version "6.3.3"
resolved "https://nexus.loafle.net/repository/npm-all/rxjs/-/rxjs-6.3.3.tgz#3c6a7fa420e844a81390fb1158a9ec614f4bad55" resolved "https://nexus.loafle.net/repository/npm-all/rxjs/-/rxjs-6.3.3.tgz#3c6a7fa420e844a81390fb1158a9ec614f4bad55"