Commit e9ecac62 authored by 神楽坂玲奈's avatar 神楽坂玲奈

package

parent 057b4c34
*.tar.xz *.tar.xz
/node_modules/ /node_modules/
/build1/
/build2/
/build3/
/build4/
/nbproject/ /nbproject/
/.idea/ /.idea/
.DS_Store .DS_Store
......
...@@ -6,11 +6,11 @@ module.exports = (grunt) => { ...@@ -6,11 +6,11 @@ module.exports = (grunt) => {
switch (process.platform) { switch (process.platform) {
case 'darwin': case 'darwin':
grunt.loadNpmTasks('grunt-appdmg'); grunt.loadNpmTasks('grunt-appdmg');
release_task = 'appdmg'; release_task = ['electron:darwin', 'appdmg'];
break; break;
case 'win32': case 'win32':
grunt.loadNpmTasks('grunt-electron-installer'); grunt.loadNpmTasks('grunt-electron-installer');
release_task = 'create-windows-installer'; release_task = ['electron:win32', 'create-windows-installer'];
break; break;
} }
...@@ -37,14 +37,24 @@ module.exports = (grunt) => { ...@@ -37,14 +37,24 @@ module.exports = (grunt) => {
}, },
electron: { electron: {
win32build: { darwin: {
options: {
name: 'mycard',
dir: 'build2',
out: 'build3',
platform: 'darwin',
arch: 'all',
icon: 'resources/darwin/icon.icns'
}
},
win32: {
options: { options: {
name: 'mycard', name: 'mycard',
dir: 'build2', dir: 'build2',
out: 'build3', out: 'build3',
platform: 'win32', platform: 'win32',
arch: 'all', arch: 'all',
icon: 'resources/win/icon.ico' icon: 'resources/win32/icon.ico'
} }
} }
}, },
...@@ -58,13 +68,37 @@ module.exports = (grunt) => { ...@@ -58,13 +68,37 @@ module.exports = (grunt) => {
setupIcon: 'resources/win/icon.ico', setupIcon: 'resources/win/icon.ico',
noMsi: true noMsi: true
} }
},
appdmg: {
options: {
title: 'MyCard',
icon: 'resources/darwin/icon.icns',
background: 'resources/darwin/TestBkg.png',
'icon-size': 80,
contents: [
{
x: 448,
y: 344,
type: 'link',
path: '/Applications'
}, {
x: 192,
y: 344,
type: 'file',
path: 'build3/mycard-darwin-x64/mycard.app'
}
]
},
target: {
dest: 'build4/darwin/mycard.dmg'
}
} }
}); });
grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-electron'); grunt.loadNpmTasks('grunt-electron');
grunt.registerTask('build', ['clean', 'copy', 'electron']); grunt.registerTask('build', ['clean', 'copy']);
grunt.registerTask('release', ['build', release_task]); grunt.registerTask('release', ['build'].concat(release_task));
grunt.registerTask('default', ['release']); grunt.registerTask('default', ['release']);
}; };
\ No newline at end of file
# build ## Build
### Windows
```bash
npm install --prefix build1 --production glob ini mkdirp ws winreg windows-shortcuts npm install --prefix build1 --production glob ini mkdirp ws winreg windows-shortcuts
robocopy resources\win build1\bin\ *.exe *.dll robocopy resources\win32 build1\bin\ *.exe *.dll
grunt
```
### OSX
```bash
npm install --prefix build1 --production glob ini mkdirp ws
grunt
```
\ No newline at end of file
...@@ -133,11 +133,11 @@ eventemitter.on('write', (app_id, file, data, merge) => { ...@@ -133,11 +133,11 @@ eventemitter.on('write', (app_id, file, data, merge) => {
let pending = 1; let pending = 1;
for (let app_id in db.local) { for (let app_id in db.local) {
if(db.local[app_id].status == 'installing'){ if (db.local[app_id].status == 'installing') {
let options = db.local[app_id]; let options = db.local[app_id];
delete db.local[app_id]; delete db.local[app_id];
eventemitter.emit('install', db.apps[app_id], options); eventemitter.emit('install', db.apps[app_id], options);
}else{ } else {
pending++; pending++;
load(db.apps[app_id], db.local[app_id], done); load(db.apps[app_id], db.local[app_id], done);
} }
...@@ -187,6 +187,7 @@ function load(app, local, callback) { ...@@ -187,6 +187,7 @@ function load(app, local, callback) {
let pending = 1; let pending = 1;
let done = ()=> { let done = ()=> {
pending--; pending--;
//console.log(pending);
if (pending == 0) { if (pending == 0) {
callback(); callback();
} }
...@@ -199,19 +200,71 @@ function load(app, local, callback) { ...@@ -199,19 +200,71 @@ function load(app, local, callback) {
if (error)return done(); if (error)return done();
for (let file of files) { for (let file of files) {
if (app.files[pattern].content == 'ini') { if (app.files[pattern].content == 'ini') {
pending++;
//console.log('ini pending');
fs.readFile(path.join(local.path, file), 'utf8', (error, content)=> { fs.readFile(path.join(local.path, file), 'utf8', (error, content)=> {
if (error)return done(); if (error)return done();
local.files[file] = {content: ini.parse(content)}; local.files[file] = {content: ini.parse(content)};
if (file == 'system.conf') {
pending += 2;
//console.log('fonts pending + 2');
let textfonts;
switch (process.platform) {
case 'darwin':
textfonts = ['/System/Library/Fonts/PingFang.ttc'];
break;
case 'win32':
textfonts = [path.join(process.env.SystemRoot, 'fonts/msyh.ttc'), path.join(process.env.SystemRoot, 'fonts/msyh.ttf'), path.join(process.env.SystemRoot, 'fonts/simsun.ttc')]
break;
}
first_exists([path.resolve(local.path, local.files[file].content.textfont.split(' ')[0])].concat(textfonts), (textfont)=> {
if (textfont) {
local.files[file].content.textfont = path.relative(local.path, textfont) + ' 14';
}
//console.log('textfonts done');
done()
});
let numfonts;
switch (process.platform) {
case 'darwin':
numfonts = ['/System/Library/Fonts/HelveticaNeue.dfont'];
break;
case 'win32':
numfonts = [path.join(process.env.SystemRoot, 'fonts/arialbd.ttf')];
break;
}
first_exists([path.resolve(local.path, local.files[file].content.numfont)].concat(numfonts), (numfont)=> {
if (numfont) {
local.files[file].content.numfont = path.relative(local.path, numfont);
}
//console.log('numfonts done');
done()
});
}
done() done()
}) })
} else { }
else {
local.files[file] = {}; local.files[file] = {};
done()
} }
} }
done()
}) })
} }
} }
done() done()
} }
function first_exists(files, callback, index) {
if (!index) index = 0;
if (index >= files.length) return callback();
let file = files[index];
fs.access(file, (error)=> {
if (error) {
first_exists(files, callback, index + 1);
} else {
callback(file)
}
})
}
\ No newline at end of file
...@@ -99,9 +99,9 @@ var mainWindow = null; ...@@ -99,9 +99,9 @@ var mainWindow = null;
app.on('window-all-closed', function () { app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar // On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q // to stay active until the user quits explicitly with Cmd + Q
if (process.platform != 'darwin') { //if (process.platform != 'darwin') {
app.quit(); app.quit();
} //}
}); });
// This method will be called when Electron has finished // This method will be called when Electron has finished
...@@ -120,17 +120,36 @@ app.on('ready', function () { ...@@ -120,17 +120,36 @@ app.on('ready', function () {
mainWindow.loadURL('file://' + __dirname + '/index.html#ygopro'); mainWindow.loadURL('file://' + __dirname + '/index.html#ygopro');
//debug //debug
if (process.execPath.indexOf('electron') != -1) { let dev = false;
let local = false;
for (let arg of process.argv) {
switch (arg) {
case '--dev':
dev = true;
break;
case '--local':
local = true;
break;
}
}
if (local || dev) {
// Open the DevTools. // Open the DevTools.
mainWindow.webContents.openDevTools();
mainWindow.webContents.on('dom-ready', ()=> { mainWindow.webContents.on('dom-ready', ()=> {
mainWindow.webContents.executeJavaScript(` if (local) {
var webview = document.getElementById('ygopro') mainWindow.webContents.executeJavaScript(`
webview.src = 'http://local.mycard.moe:3000/' var webview = document.getElementById('ygopro');
webview.addEventListener("dom-ready", function () { webview.src = 'http://local.mycard.moe:3000/'
webview.openDevTools(); `)
}); }
`) if (dev) {
mainWindow.webContents.openDevTools();
mainWindow.webContents.executeJavaScript(`
var webview = document.getElementById('ygopro');
webview.addEventListener("dom-ready", function() {
webview.openDevTools();
})
`)
}
}) })
} }
......
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
How to use this icon:
Step 1: Copy the icon to the clipboard
a) Click on this file from the Finder
b) Choose 'Get Info' from the 'File' menu.
c) In the info window that pops up, click on the icon
d) Choose 'Copy' from the 'Edit' menu.
e) Close the info window
Step 2: Paste the icon to the desired item
a) Go to the item in the Finder that you want a custom icon
b) Click the item (file, folder, disk, etc)
b) Choose 'Get Info' from the 'File' menu.
c) In the info window that pops up, click on the icon
d) Choose 'Paste' from the 'Edit' menu.
e) Close the info window
Step 3:
Enjoy your newly customized icon!
For more thorough directions, see Apple's website at:
http://www.apple.com/support/mac101/customize/6/
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