From 9695d30e5f7a9cbaad1999c64f7c7e077cd636e0 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 10 Apr 2018 16:04:52 +0200 Subject: [PATCH] [package.json] added 'electron-packager' to build sources + 'electron-installer-debian' for .deb files + added electron.js to load index.html + added electron.json to describe our app --- .gitignore | 5 ++++- electron.js | 43 ++++++++++++++++++++++++++++++++++++++++++ electron.json | 19 +++++++++++++++++++ package.json | 16 +++++++++++++--- public_html/index.html | 35 ---------------------------------- 5 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 electron.js create mode 100644 electron.json delete mode 100644 public_html/index.html diff --git a/.gitignore b/.gitignore index 61816df..8b0db88 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ /public_html/* !/public_htm/.htaccess /package-lock.json -.cache \ No newline at end of file +.cache +/releases +/packages +/electron-build \ No newline at end of file diff --git a/electron.js b/electron.js new file mode 100644 index 0000000..f6bf18c --- /dev/null +++ b/electron.js @@ -0,0 +1,43 @@ +const electron = require('electron'); +const app = electron.app; // Module to control application life. +const BrowserWindow = electron.BrowserWindow; // Module to create native browser window. +const path = require('path'); +const url = require('url'); + +// 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. +var mainWindow = null; + +// Quit when all windows are closed. +app.on('window-all-closed', function() { + // On OS X it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q + if (process.platform != 'darwin') { + app.quit(); + } +}); + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +app.on('ready', function() { + // Create the browser window. + mainWindow = new BrowserWindow({width: 800, height: 600}); + + // and load the index.html of the app. + // mainWindow.loadURL('file://' + __dirname + '/index.html'); + mainWindow.loadURL( url.format({ + pathname: path.join(__dirname, 'index.html'), + protocol: 'file:', + slashes: true + }) ); + // mainWindow.loadURL('http://douscord/'); + + // Emitted when the window is closed. + mainWindow.on('closed', function(){ + // Dereference the window object, usually you would store windows + // in an array if your app supports multi windows, this is the time + // when you should delete the corresponding element. + mainWindow = null; + }); + +}); \ No newline at end of file diff --git a/electron.json b/electron.json new file mode 100644 index 0000000..87e9801 --- /dev/null +++ b/electron.json @@ -0,0 +1,19 @@ +{ + "name": "douscord", + "description": "Douscord non-copyright respectful copy", + "version": "1.0.0", + "author": "xdrm-brackets SeekDaSky ", + "license": "MIT", + "private": true, + "dependencies": { + "vue": "^2.5.9", + "vue-router": "^2.5.3" + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not ie <= 8" + ], + "devDependencies": { + } +} diff --git a/package.json b/package.json index 692d78e..0c7ca76 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "ptut-vhost", + "name": "douscord", "description": "PTUT", "version": "1.0.0", "author": "xdrm-brackets SeekDaSky ", @@ -7,12 +7,20 @@ "private": true, "scripts": { "clean": "rm ./public_html/*.html; rm ./public_html/*.js; rm ./public_html/*.css; rm ./public_html/*svg; rm ./public_html/*.map; exit 0", + "clean:all": "npm run clean; npm run clean:electron; npm run clean:release; npm run clean:package; exit 0", "clean:electron": "rm -r ./electron-build; exit 0", + "clean:release": "rm -r ./releases; exit 0", + "clean:package": "rm -r ./package; exit 0", "dev": "parcel watch ./parcel/index.html --out-dir ./public_html --no-hmr", "build:alternative": "cross-env NODE_ENV=production parcel watch ./parcel/index.html --out-dir ./public_html --no-hmr", "build": "parcel build ./parcel/index.html --public-url ./ --out-dir ./public_html --no-source-maps --no-minify", - "build:electron": "parcel build ./parcel/index.html --public-url ./ --out-dir ./electron-build --no-source-maps --no-minify --target=electron", - "electron": "electron ./electron-build/index.html" + "build:electron": "parcel build ./parcel/index.html --public-url ./ --out-dir ./electron-build --no-source-maps --no-minify --target=electron; npm run build:electron:setup", + "build:electron:setup": "npm run build:electron:setup-config; npm run build:electron:setup-index;", + "build:electron:setup-config": "cp ./electron.json ./electron-build/package.json; npm --prefix ./electron-build install", + "build:electron:setup-index": "cp ./electron.js ./electron-build/index.js", + "electron": "electron ./electron-build", + "package": "npm run build:electron; electron-packager ./electron-build douscord --asar --platform linux --arch x64 --out ./releases --overwrite;", + "package:deb": "electron-installer-debian --src ./releases/douscord-linux-x64 --dest ./packages --arch x64" }, "dependencies": { "vue": "^2.5.9", @@ -32,6 +40,8 @@ "babel-preset-stage-3": "^6.24.1", "cross-env": "^5.0.5", "electron": "^1.8.4", + "electron-installer-debian": "^0.8.1", + "electron-packager": "^12.0.0", "node-sass": "^4.8.3", "parcel-bundler": "^1.7.0", "vue-template-compiler": "^2.5.16" diff --git a/public_html/index.html b/public_html/index.html deleted file mode 100644 index 87affc5..0000000 --- a/public_html/index.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - Douscord - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - \ No newline at end of file