-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1e932fb
Showing
6 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
dist/ | ||
yarn.lock | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org/> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// This is free and unencumbered software released into the public domain. | ||
// See LICENSE for details | ||
|
||
const {app, BrowserWindow, Menu, protocol, ipcMain} = require('electron'); | ||
const log = require('electron-log'); | ||
const {autoUpdater} = require("electron-updater"); | ||
|
||
//------------------------------------------------------------------- | ||
// Logging | ||
// | ||
// THIS SECTION IS NOT REQUIRED | ||
// | ||
// This logging setup is not required for auto-updates to work, | ||
// but it sure makes debugging easier :) | ||
//------------------------------------------------------------------- | ||
autoUpdater.logger = log; | ||
autoUpdater.logger.transports.file.level = 'info'; | ||
log.info('App starting...'); | ||
|
||
//------------------------------------------------------------------- | ||
// Define the menu | ||
// | ||
// THIS SECTION IS NOT REQUIRED | ||
//------------------------------------------------------------------- | ||
let template = [] | ||
if (process.platform === 'darwin') { | ||
// OS X | ||
const name = app.getName(); | ||
template.unshift({ | ||
label: name, | ||
submenu: [ | ||
{ | ||
label: 'About ' + name, | ||
role: 'about' | ||
}, | ||
{ | ||
label: 'Quit', | ||
accelerator: 'Command+Q', | ||
click() { app.quit(); } | ||
}, | ||
] | ||
}) | ||
} | ||
|
||
|
||
//------------------------------------------------------------------- | ||
// Open a window that displays the version | ||
// | ||
// THIS SECTION IS NOT REQUIRED | ||
// | ||
// This isn't required for auto-updates to work, but it's easier | ||
// for the app to show a window than to have to click "About" to see | ||
// that updates are working. | ||
//------------------------------------------------------------------- | ||
let win; | ||
|
||
function sendStatusToWindow(text) { | ||
log.info(text); | ||
win.webContents.send('message', text); | ||
} | ||
function createDefaultWindow() { | ||
win = new BrowserWindow(); | ||
win.webContents.openDevTools(); | ||
win.on('closed', () => { | ||
win = null; | ||
}); | ||
win.loadURL(`file://${__dirname}/version.html#v${app.getVersion()}`); | ||
return win; | ||
} | ||
autoUpdater.on('checking-for-update', () => { | ||
sendStatusToWindow('Checking for update...'); | ||
}) | ||
autoUpdater.on('update-available', (info) => { | ||
sendStatusToWindow('Update available.'); | ||
}) | ||
autoUpdater.on('update-not-available', (info) => { | ||
sendStatusToWindow('Update not available.'); | ||
}) | ||
autoUpdater.on('error', (err) => { | ||
sendStatusToWindow('Error in auto-updater. ' + err); | ||
}) | ||
autoUpdater.on('download-progress', (progressObj) => { | ||
let log_message = "Download speed: " + progressObj.bytesPerSecond; | ||
log_message = log_message + ' - Downloaded ' + progressObj.percent + '%'; | ||
log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')'; | ||
sendStatusToWindow(log_message); | ||
}) | ||
autoUpdater.on('update-downloaded', (info) => { | ||
sendStatusToWindow('Update downloaded'); | ||
}); | ||
app.on('ready', function() { | ||
// Create the Menu | ||
const menu = Menu.buildFromTemplate(template); | ||
Menu.setApplicationMenu(menu); | ||
|
||
createDefaultWindow(); | ||
}); | ||
app.on('window-all-closed', () => { | ||
app.quit(); | ||
}); | ||
|
||
// | ||
// CHOOSE one of the following options for Auto updates | ||
// | ||
|
||
//------------------------------------------------------------------- | ||
// Auto updates - Option 1 - Simplest version | ||
// | ||
// This will immediately download an update, then install when the | ||
// app quits. | ||
//------------------------------------------------------------------- | ||
app.on('ready', function() { | ||
autoUpdater.checkForUpdatesAndNotify(); | ||
}); | ||
|
||
//------------------------------------------------------------------- | ||
// Auto updates - Option 2 - More control | ||
// | ||
// For details about these events, see the Wiki: | ||
// https://github.com/electron-userland/electron-builder/wiki/Auto-Update#events | ||
// | ||
// The app doesn't need to listen to any events except `update-downloaded` | ||
// | ||
// Uncomment any of the below events to listen for them. Also, | ||
// look in the previous section to see them being used. | ||
//------------------------------------------------------------------- | ||
// app.on('ready', function() { | ||
// autoUpdater.checkForUpdates(); | ||
// }); | ||
// autoUpdater.on('checking-for-update', () => { | ||
// }) | ||
// autoUpdater.on('update-available', (info) => { | ||
// }) | ||
// autoUpdater.on('update-not-available', (info) => { | ||
// }) | ||
// autoUpdater.on('error', (err) => { | ||
// }) | ||
// autoUpdater.on('download-progress', (progressObj) => { | ||
// }) | ||
// autoUpdater.on('update-downloaded', (info) => { | ||
// autoUpdater.quitAndInstall(); | ||
// }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "sequencediagrams-electron", | ||
"displayName": "Sequence Diagrams", | ||
"version": "0.0.1", | ||
"main": "main.js", | ||
"description": "Sequcnce diagrams applicaton created on electron", | ||
"author": "Nagaraju Kotcharlakota", | ||
"scripts": { | ||
"publish": "build -p always", | ||
"pack": "electron-builder --dir", | ||
"dist": "electron-builder" | ||
}, | ||
"devDependencies": { | ||
"electron": "^2.0.4", | ||
"electron-builder": "^20.19.2" | ||
}, | ||
"dependencies": { | ||
"electron-log": "^2.2.16", | ||
"electron-updater": "^2.23.3" | ||
}, | ||
"build": { | ||
"appId": "com.github.klvnraju.sequencediagramselectronapp", | ||
"win": { | ||
"target": "nsis", | ||
"icon": "build/main-icon.ico" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Electron Updater Example</title> | ||
</head> | ||
|
||
<body> | ||
Current version: | ||
<span id="version">vX.Y.Z</span> | ||
<div id="messages"></div> | ||
<script> | ||
// Display the current version | ||
let version = window.location.hash.substring(1); | ||
document.getElementById('version').innerText = version; | ||
// Listen for messages | ||
const { ipcRenderer } = require('electron'); | ||
ipcRenderer.on('message', function (event, text) { | ||
var container = document.getElementById('messages'); | ||
var message = document.createElement('div'); | ||
message.innerHTML = text; | ||
container.appendChild(message); | ||
}) | ||
</script> | ||
</body> | ||
|
||
</html> |