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

auto update

parent abba79e9
......@@ -10,12 +10,12 @@ module.exports = (grunt) => {
break;
case 'win32':
grunt.loadNpmTasks('grunt-electron-installer');
release_task = ['electron:win32', 'create-windows-installer'];
release_task = ['electron:win32', 'copy:bundle', 'create-windows-installer'];
break;
}
grunt.initConfig({
clean: ["build2", "build3", "build4"],
clean: ["build2", "build3"],
copy: {
app: {
expand: true,
......@@ -33,6 +33,14 @@ module.exports = (grunt) => {
cwd: 'build1',
src: ['node_modules/**', 'bin/**'],
dest: 'build2'
},
'bundle': {
expand: true,
options: {
timestamp: true
},
src: ['build3/**', 'bundle/**'],
dest: 'build3-bundle'
}
},
......@@ -69,12 +77,28 @@ module.exports = (grunt) => {
noMsi: true
},
x64: {
appDirectory: 'build3/mycard-win32-x64',
appDirectory: 'build3-bundle/mycard-win32-x64',
outputDirectory: 'build4/win32-x64',
authors: 'MyCard',
exe: 'mycard.exe',
setupIcon: 'resources/win/icon.ico',
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: {
......
......@@ -11,6 +11,7 @@ const mkdirp = require('mkdirp');
const EventEmitter = require('events');
const eventemitter = new EventEmitter();
const autoUpdater = require('auto-updater');
const electron = require('electron');
const ipcMain = electron.ipcMain;
const app = electron.app;
......@@ -29,7 +30,7 @@ db.version = app.getVersion();
db.platform = process.platform;
db.default_apps_path = path.join(data_path, 'apps');
var bundle;
let bundle;
try {
bundle = require('./bundle.json')
} catch (error) {
......@@ -87,7 +88,7 @@ eventemitter.on('install', (app, 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);
fs.writeFile(path.join(local.path, 'system.conf'), ini.stringify(local.files['system.conf'].content, {whitespace: true}), (error)=> {
if (error) return console.log(error);
......@@ -109,6 +110,7 @@ eventemitter.on('action', function (app_id, action, options) {
window.restore()
}
})
})
});
......@@ -197,6 +199,22 @@ function start_server() {
}
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) {
......
......@@ -4,12 +4,12 @@ const electron = require('electron');
const app = electron.app; // Module to control application life.
const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
var handleStartupEvent = function () {
let handleStartupEvent = function () {
if (process.platform !== 'win32') {
return false;
}
var squirrelCommand = process.argv[1];
let squirrelCommand = process.argv[1];
switch (squirrelCommand) {
case '--squirrel-install':
case '--squirrel-updated':
......@@ -35,14 +35,8 @@ var handleStartupEvent = function () {
}
};
let key = new reg({
hive: reg.HKCU,
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'});
shortcuts.create(path.join(app.getPath('desktop'), 'MyCard.lnk'), process.execPath, done);
let key = new reg({hive: reg.HKCU, key: '\\Software\\Classes\\mycard'});
key.set('URL Protocol', reg.REG_SZ, '"' + process.execPath + '"', done);
key = new reg({hive: reg.HKCU, key: '\\Software\\Classes\\mycard\\shell\\open\\command'});
key.set('', reg.REG_SZ, '"' + process.execPath + '" "%i"', done);
......@@ -77,7 +71,7 @@ if (handleStartupEvent()) {
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.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
......@@ -93,7 +87,7 @@ if (shouldQuit) {
// 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;
let mainWindow = null;
// Quit when all windows are closed.
app.on('window-all-closed', function () {
......@@ -137,14 +131,14 @@ app.on('ready', function () {
mainWindow.webContents.on('dom-ready', ()=> {
if (local) {
mainWindow.webContents.executeJavaScript(`
var webview = document.getElementById('ygopro');
let webview = document.getElementById('ygopro');
webview.src = 'http://local.mycard.moe:3000/'
`)
}
if (dev) {
mainWindow.webContents.openDevTools();
mainWindow.webContents.executeJavaScript(`
var webview = document.getElementById('ygopro');
let webview = document.getElementById('ygopro');
webview.addEventListener("dom-ready", function() {
webview.openDevTools();
})
......@@ -164,7 +158,7 @@ app.on('ready', function () {
//debug
/*<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.openDevTools();
});*/
......
{
"name": "mycard",
"description": "a game platform",
"version": "2.0.2",
"version": "2.0.3",
"main": "main.js",
"license": "UNLICENSED",
"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