Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
integrated changes from #170
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisio committed Dec 27, 2016
1 parent 5584526 commit d333117
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@ dist
prod
mainBuilt.js
error.log
.idea
1 change: 1 addition & 0 deletions Gruntfile.js
@@ -1,4 +1,5 @@
const path = require('path');

module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
Expand Down
7 changes: 5 additions & 2 deletions build.sh
Expand Up @@ -119,7 +119,7 @@ case "$TRAVIS_OS_NAME" in
mkdir dist/win32

echo 'Running Electron Packager...'
electron-packager . OpenBazaar2 --asar=true --out=dist --protocol-name=OpenBazaar --version-string.ProductName=OpenBazaar --protocol=ob --platform=win32 --arch=ia32 --icon=imgs/windows-icon.ico --version=${ELECTRONVER} --overwrite
electron-packager . OpenBazaar2 --asar=true --out=dist --protocol-name=OpenBazaar --win32metadata.ProductName="OpenBazaar2" --win32metadata.CompanyName="OpenBazaar" --win32metadata.FileDescription='Decentralized p2p marketplace for Bitcoin' --win32metadata.OriginalFilename=OpenBazaar2.exe --protocol=ob --platform=win32 --arch=ia32 --icon=imgs/windows-icon.ico --version=${ELECTRONVER} --overwrite

echo 'Copying server binary into application folder...'
cp -rf temp/openbazaar-go-windows-4.0-386.exe dist/OpenBazaar2-win32-ia32/resources/
Expand All @@ -139,7 +139,10 @@ case "$TRAVIS_OS_NAME" in
mkdir dist/win64

echo 'Running Electron Packager...'
electron-packager . OpenBazaar2 --asar=true --out=dist --protocol-name=OpenBazaar --version-string.ProductName=OpenBazaar --protocol=ob --platform=win32 --arch=x64 --icon=imgs/windows-icon.ico --version=${ELECTRONVER} --overwrite
electron-packager . OpenBazaar2 --asar=true --out=dist --protocol-name=OpenBazaar --win32metadata.ProductName="OpenBazaar2" --win32metadata.CompanyName="OpenBazaar" --win32metadata.FileDescription='Decentralized p2p marketplace for Bitcoin' --win32metadata.OriginalFilename=OpenBazaar2.exe --protocol=ob --platform=win32 --arch=x64 --icon=imgs/windows-icon.ico --version=${ELECTRONVER} --overwrite

echo 'Copying server binary into application folder...'
cp -rf temp/openbazaar-go-windows-4.0-amd64.exe dist/OpenBazaar2-win32-x64/resources/

echo 'Copying server binary into application folder...'
cp -rf temp/openbazaar-go-windows-4.0-amd64.exe dist/OpenBazaar2-win32-x64/resources/
Expand Down
78 changes: 73 additions & 5 deletions main.js
@@ -1,6 +1,7 @@
import {
electron, app, BrowserWindow, ipcMain,
app, BrowserWindow, ipcMain,
Menu, Tray, session, crashReporter,
autoUpdater, shell,
} from 'electron';
import path from 'path';
import fs from 'fs';
Expand All @@ -14,6 +15,8 @@ import { bindLocalServerEvent } from './js/utils/mainProcLocalServerEvents';
let mainWindow;
let trayMenu;
let closeConfirmed = false;
const version = app.getVersion();
const feedURL = `https://updates2.openbazaar.org:5001/update/${process.platform}/${version}`;
global.serverLog = '';

const handleStartupEvent = function () {
Expand All @@ -31,7 +34,7 @@ const handleStartupEvent = function () {

function install(cb) {
const target = path.basename(process.execPath);
exeSquirrelCommand(['--createShortcut', target], cb);
exeSquirrelCommand(['--createShortcut', target, ' --shortcut-locations=Desktop,StartMenu'], cb);
}

function uninstall(cb) {
Expand Down Expand Up @@ -169,9 +172,26 @@ function createWindow() {
{
role: 'help',
submenu: [
// {
// label: 'Report Issue...',
// click() {
// // TODO: Open an issue tracking window
// },
// },
{
label: 'Learn More',
click() { electron.shell.openExternal('https://openbazaar.org'); },
label: 'Check for Updates...',
click() {
autoUpdater.checkForUpdates();
},
},
{
type: 'separator',
},
{
label: 'Documentation',
click() {
shell.openExternal('https://docs.openbazaar.org');
},
},
],
},
Expand Down Expand Up @@ -369,6 +389,55 @@ function createWindow() {
e.preventDefault();
}
});

/**
* For OS X users Squirrel manages the auto-updating code.
* If there is an update available then we will send an IPC message to the
* render process to notify the user. If the user wants to update
* the software then they will send an IPC message back to the main process and we will
* begin to download the file and update the software.
*/
if (process.platform === 'darwin') {
autoUpdater.on('error', (err, msg) => {
console.log(msg);
});

autoUpdater.on('update-not-available', (msg) => {
console.log(msg);
mainWindow.send('updateNotAvailable');
});

autoUpdater.on('update-available', () => {
mainWindow.send('updateAvailable');
});

autoUpdater.on('update-downloaded', (e, releaseNotes, releaseName,
releaseDate, updateUrl, quitAndUpdate) => {
// Old way of doing things
// mainWindow.webContents.executeJavaScript('$(".js-softwareUpdate")
// .removeClass("softwareUpdateHidden");');
console.log(quitAndUpdate);
mainWindow.send('updateReadyForInstall');
});

// Listen for installUpdate command to install the update
ipcMain.on('installUpdate', () => {
autoUpdater.quitAndInstall();
});

// Listen for checkForUpdate command to manually check for new versions
ipcMain.on('checkForUpdate', () => {
autoUpdater.checkForUpdates();
});

autoUpdater.setFeedURL(feedURL);

// Check for updates every hour
autoUpdater.checkForUpdates();
setInterval(() => {
autoUpdater.checkForUpdates();
}, 60 * 60 * 1000);
}
}

// This method will be called when Electron has finished
Expand Down Expand Up @@ -438,4 +507,3 @@ const log = msg => {

if (localServer) bindLocalServerEvent('log', (localServ, msg) => log(msg));
ipcMain.on('server-connect-log', (e, msg) => log(msg));

5 changes: 3 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "openbazaar-desktop",
"version": "2.0.0",
"description": "",
"description": "Decentralized p2p marketplace for Bitcoin",
"main": "bootstrapper.js",
"scripts": {
"start": "cross-env NODE_ENV=development npm-run-all sass:build process-index --parallel sass:watch index:watch browsersync start-app",
Expand All @@ -18,7 +18,8 @@
"process-index:build": "babel-node ./bin/processIndexForBuild.js",
"copy-js-subfolders": "copyfiles -u 1 'js/languages/**/*' 'js/templates/**/*' prod",
"babel": "babel js --out-dir prod; babel main.js --out-file mainBuilt.js",
"build": "npm-run-all sass:build --parallel babel process-index:build --sequential copy-js-subfolders"
"build": "npm-run-all sass:build --parallel babel process-index:build --sequential copy-js-subfolders",
"binaries": "./build.sh"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit d333117

Please sign in to comment.