Commit 0c5f8e33 authored by 神楽坂玲奈's avatar 神楽坂玲奈

auto update

parent abba79e9
...@@ -10,12 +10,12 @@ module.exports = (grunt) => { ...@@ -10,12 +10,12 @@ module.exports = (grunt) => {
break; break;
case 'win32': case 'win32':
grunt.loadNpmTasks('grunt-electron-installer'); grunt.loadNpmTasks('grunt-electron-installer');
release_task = ['electron:win32', 'create-windows-installer']; release_task = ['electron:win32', 'copy:bundle', 'create-windows-installer'];
break; break;
} }
grunt.initConfig({ grunt.initConfig({
clean: ["build2", "build3", "build4"], clean: ["build2", "build3"],
copy: { copy: {
app: { app: {
expand: true, expand: true,
...@@ -33,6 +33,14 @@ module.exports = (grunt) => { ...@@ -33,6 +33,14 @@ module.exports = (grunt) => {
cwd: 'build1', cwd: 'build1',
src: ['node_modules/**', 'bin/**'], src: ['node_modules/**', 'bin/**'],
dest: 'build2' dest: 'build2'
},
'bundle': {
expand: true,
options: {
timestamp: true
},
src: ['build3/**', 'bundle/**'],
dest: 'build3-bundle'
} }
}, },
...@@ -69,12 +77,28 @@ module.exports = (grunt) => { ...@@ -69,12 +77,28 @@ module.exports = (grunt) => {
noMsi: true noMsi: true
}, },
x64: { x64: {
appDirectory: 'build3/mycard-win32-x64', appDirectory: 'build3-bundle/mycard-win32-x64',
outputDirectory: 'build4/win32-x64', outputDirectory: 'build4/win32-x64',
authors: 'MyCard', authors: 'MyCard',
exe: 'mycard.exe', exe: 'mycard.exe',
setupIcon: 'resources/win/icon.ico', setupIcon: 'resources/win/icon.ico',
noMsi: true noMsi: true
},
'bundle-ia32': {
appDirectory: 'build3-bundle/mycard-win32-ia32',
outputDirectory: 'build4-bundle/win32-ia32',
authors: 'MyCard',
exe: 'mycard.exe',
setupIcon: 'resources/win/icon.ico',
noMsi: true
},
'bundle-x64':{
appDirectory: 'build3-bundle/mycard-win32-x64',
outputDirectory: 'build4-bundle/win32-x64',
authors: 'MyCard',
exe: 'mycard.exe',
setupIcon: 'resources/win/icon.ico',
noMsi: true
} }
}, },
appdmg: { appdmg: {
......
...@@ -11,6 +11,7 @@ const mkdirp = require('mkdirp'); ...@@ -11,6 +11,7 @@ const mkdirp = require('mkdirp');
const EventEmitter = require('events'); const EventEmitter = require('events');
const eventemitter = new EventEmitter(); const eventemitter = new EventEmitter();
const autoUpdater = require('auto-updater');
const electron = require('electron'); const electron = require('electron');
const ipcMain = electron.ipcMain; const ipcMain = electron.ipcMain;
const app = electron.app; const app = electron.app;
...@@ -29,7 +30,7 @@ db.version = app.getVersion(); ...@@ -29,7 +30,7 @@ db.version = app.getVersion();
db.platform = process.platform; db.platform = process.platform;
db.default_apps_path = path.join(data_path, 'apps'); db.default_apps_path = path.join(data_path, 'apps');
var bundle; let bundle;
try { try {
bundle = require('./bundle.json') bundle = require('./bundle.json')
} catch (error) { } catch (error) {
...@@ -87,7 +88,7 @@ eventemitter.on('install', (app, options) => { ...@@ -87,7 +88,7 @@ eventemitter.on('install', (app, options) => {
}); });
eventemitter.on('action', function (app_id, action, options) { eventemitter.on('action', function (app_id, action, options) {
var local = db.local[app_id]; let local = db.local[app_id];
Object.assign(local.files['system.conf'].content, options); Object.assign(local.files['system.conf'].content, options);
fs.writeFile(path.join(local.path, 'system.conf'), ini.stringify(local.files['system.conf'].content, {whitespace: true}), (error)=> { fs.writeFile(path.join(local.path, 'system.conf'), ini.stringify(local.files['system.conf'].content, {whitespace: true}), (error)=> {
if (error) return console.log(error); if (error) return console.log(error);
...@@ -109,6 +110,7 @@ eventemitter.on('action', function (app_id, action, options) { ...@@ -109,6 +110,7 @@ eventemitter.on('action', function (app_id, action, options) {
window.restore() window.restore()
} }
}) })
}) })
}); });
...@@ -197,6 +199,22 @@ function start_server() { ...@@ -197,6 +199,22 @@ function start_server() {
} }
save_db(); save_db();
}); });
autoUpdater.setFeedURL('https://mycard.moe/update');
autoUpdater.checkForUpdates();
/*autoUpdater.on('checking-for-update', ()=>{
console.log('checking-for-update')
});
autoUpdater.on('update-available', ()=>{
console.log('update-available')
});
autoUpdater.on('update-not-available', ()=>{
console.log('update-not-available')
});*/
autoUpdater.on('update-downloaded', ()=>{
autoUpdater.quitAndInstall()
})
} }
function load(app, local, callback) { function load(app, local, callback) {
......
...@@ -4,12 +4,12 @@ const electron = require('electron'); ...@@ -4,12 +4,12 @@ const electron = require('electron');
const app = electron.app; // Module to control application life. const app = electron.app; // Module to control application life.
const BrowserWindow = electron.BrowserWindow; // Module to create native browser window. const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
var handleStartupEvent = function () { let handleStartupEvent = function () {
if (process.platform !== 'win32') { if (process.platform !== 'win32') {
return false; return false;
} }
var squirrelCommand = process.argv[1]; let squirrelCommand = process.argv[1];
switch (squirrelCommand) { switch (squirrelCommand) {
case '--squirrel-install': case '--squirrel-install':
case '--squirrel-updated': case '--squirrel-updated':
...@@ -35,14 +35,8 @@ var handleStartupEvent = function () { ...@@ -35,14 +35,8 @@ var handleStartupEvent = function () {
} }
}; };
let key = new reg({ shortcuts.create(path.join(app.getPath('desktop'), 'MyCard.lnk'), process.execPath, done);
hive: reg.HKCU, let key = new reg({hive: reg.HKCU, key: '\\Software\\Classes\\mycard'});
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders'
});
key.get('Desktop', (error, item)=> {
shortcuts.create(path.join(item.value, 'mycard.lnk'), process.execPath, done)
});
key = new reg({hive: reg.HKCU, key: '\\Software\\Classes\\mycard'});
key.set('URL Protocol', reg.REG_SZ, '"' + process.execPath + '"', done); key.set('URL Protocol', reg.REG_SZ, '"' + process.execPath + '"', done);
key = new reg({hive: reg.HKCU, key: '\\Software\\Classes\\mycard\\shell\\open\\command'}); key = new reg({hive: reg.HKCU, key: '\\Software\\Classes\\mycard\\shell\\open\\command'});
key.set('', reg.REG_SZ, '"' + process.execPath + '" "%i"', done); key.set('', reg.REG_SZ, '"' + process.execPath + '" "%i"', done);
...@@ -77,7 +71,7 @@ if (handleStartupEvent()) { ...@@ -77,7 +71,7 @@ if (handleStartupEvent()) {
return; return;
} }
var shouldQuit = app.makeSingleInstance(function (commandLine, workingDirectory) { let shouldQuit = app.makeSingleInstance(function (commandLine, workingDirectory) {
// Someone tried to run a second instance, we should focus our window. // Someone tried to run a second instance, we should focus our window.
if (mainWindow) { if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore(); if (mainWindow.isMinimized()) mainWindow.restore();
...@@ -93,7 +87,7 @@ if (shouldQuit) { ...@@ -93,7 +87,7 @@ if (shouldQuit) {
// Keep a global reference of the window object, if you don't, the window will // 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. // be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null; let mainWindow = null;
// Quit when all windows are closed. // Quit when all windows are closed.
app.on('window-all-closed', function () { app.on('window-all-closed', function () {
...@@ -137,14 +131,14 @@ app.on('ready', function () { ...@@ -137,14 +131,14 @@ app.on('ready', function () {
mainWindow.webContents.on('dom-ready', ()=> { mainWindow.webContents.on('dom-ready', ()=> {
if (local) { if (local) {
mainWindow.webContents.executeJavaScript(` mainWindow.webContents.executeJavaScript(`
var webview = document.getElementById('ygopro'); let webview = document.getElementById('ygopro');
webview.src = 'http://local.mycard.moe:3000/' webview.src = 'http://local.mycard.moe:3000/'
`) `)
} }
if (dev) { if (dev) {
mainWindow.webContents.openDevTools(); mainWindow.webContents.openDevTools();
mainWindow.webContents.executeJavaScript(` mainWindow.webContents.executeJavaScript(`
var webview = document.getElementById('ygopro'); let webview = document.getElementById('ygopro');
webview.addEventListener("dom-ready", function() { webview.addEventListener("dom-ready", function() {
webview.openDevTools(); webview.openDevTools();
}) })
...@@ -164,7 +158,7 @@ app.on('ready', function () { ...@@ -164,7 +158,7 @@ app.on('ready', function () {
//debug //debug
/*<webview id="ygopro" src="http://local.mycard.moe:3000/"></webview> /*<webview id="ygopro" src="http://local.mycard.moe:3000/"></webview>
var webview = document.getElementById(hash); let webview = document.getElementById(hash);
webview.addEventListener("dom-ready", function () { webview.addEventListener("dom-ready", function () {
webview.openDevTools(); webview.openDevTools();
});*/ });*/
......
{ {
"name": "mycard", "name": "mycard",
"description": "a game platform", "description": "a game platform",
"version": "2.0.2", "version": "2.0.3",
"main": "main.js", "main": "main.js",
"license": "UNLICENSED", "license": "UNLICENSED",
"repository": "github:mycard/mycard", "repository": "github:mycard/mycard",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment