Installer & dist for windows

This commit is contained in:
Jeffrey Morgan 2015-06-09 17:16:00 -07:00
parent a3ca2217e1
commit 140ae4671b
5 changed files with 130 additions and 41 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
.swp
build
dist
installer
node_modules
coverage
npm-debug.log

View File

@ -11,7 +11,9 @@ var BOOT2DOCKER_ISO_URL = 'https://github.com/boot2docker/boot2docker/releases/d
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
// var target = grunt.option('target') || 'development';
var target = grunt.option('target') || 'development';
var env = process.env;
env.NODE_ENV = target;
var version = function (str) {
var match = str.match(/(\d+\.\d+\.\d+)/);
@ -24,7 +26,7 @@ module.exports = function (grunt) {
var config = grunt.config('download-binary')[target];
execFile(config.binary, ['--version'], function (err, stdout) {
var currentVersion = version(stdout);
if (!currentVersion || currentVersion !== config.version) {
if (!currentVersion || currentVersion !== version(config.version)) {
grunt.task.run('curl:' + target);
grunt.task.run('chmod');
}
@ -32,7 +34,6 @@ module.exports = function (grunt) {
});
});
grunt.initConfig({
// electron
'download-electron': {
@ -54,19 +55,59 @@ module.exports = function (grunt) {
}
},
// electron
electron: {
windows: {
options: {
name: 'Kitematic',
dir: 'build/',
out: 'dist/',
version: packagejson['electron-version'],
platform: 'win32',
arch: 'x64',
asar: true
}
}
},
'create-windows-installer': {
appDirectory: 'dist/Kitematic-win32/',
outputDirectory: 'installer/',
authors: 'Docker Inc.'
},
// images
copy: {
images: {
src: 'images/*',
dev: {
files: [{
expand: true,
cwd: '.',
src: ['package.json', 'index.html'],
dest: 'build/'
}, {
expand: true,
cwd: 'images/',
src: ['**/*'],
dest: 'build/'
}, {
expand: true,
cwd: 'fonts/',
src: ['**/*'],
dest: 'build/'
}, {
cwd: 'node_modules/',
src: Object.keys(packagejson.dependencies).map(function (dep) { return dep + '/**/*';}),
dest: 'build/node_modules/',
expand: true
}]
},
html: {
src: 'index.html',
dest: 'build/'
},
fonts: {
src: 'fonts/*',
dest: 'build/'
release: {
files: [{
expand: true,
cwd: 'resources',
src: ['**/*'],
dest: 'dist/Kitematic-win32/resources/resources/'
}]
}
},
@ -104,9 +145,11 @@ module.exports = function (grunt) {
options: {
sourceMapFileInline: true
},
dist: {
files: {
'build/main.css': 'styles/main.less'
}
}
},
// javascript
@ -125,12 +168,28 @@ module.exports = function (grunt) {
}
},
// electron
shell: {
electron: {
command: path.join('cache', 'electron') + ' ' + 'build',
options: {
async: true,
execOptions: {
env: env
}
}
}
},
clean: {
dist: ['dist/'],
build: ['build/']
},
// livereload
watch: {
options: {
livereload: true
watchChokidar: {
livereload: {
options: {livereload: true},
files: ['build/**/*']
},
js: {
files: ['src/**/*.js'],
@ -146,6 +205,6 @@ module.exports = function (grunt) {
}
}
});
grunt.registerTask('default', ['download-electron', 'curl', 'babel', 'less', 'copy', 'watch', 'electron']);
grunt.registerTask('default', ['download-electron', 'download-binary', 'babel', 'less', 'copy:dev', 'shell:electron', 'watchChokidar']);
grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron', 'copy:release']);
};

View File

@ -4,7 +4,7 @@
"author": "Kitematic",
"description": "Simple Docker Container management for Mac OS X.",
"homepage": "https://kitematic.com/",
"main": "build/browser.js",
"main": "browser.js",
"repository": {
"type": "git",
"url": "git@github.com:kitematic/kitematic.git"
@ -71,26 +71,16 @@
"grunt-babel": "^5.0.1",
"grunt-chmod": "^1.0.3",
"grunt-cli": "^0.1.13",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-less": "^1.0.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-contrib-watch-chokidar": "^1.0.0",
"grunt-curl": "^2.2.0",
"grunt-download-electron": "^2.1.1",
"grunt-electron": "^1.0.0",
"grunt-electron-installer": "^0.33.0",
"gulp": "^3.8.11",
"gulp-babel": "^5.1.0",
"gulp-changed": "^1.2.1",
"gulp-concat": "^2.5.2",
"gulp-cssmin": "^0.1.6",
"gulp-download-electron": "^0.0.5",
"gulp-if": "^1.2.5",
"gulp-insert": "^0.4.0",
"gulp-less": "^3.0.2",
"gulp-livereload": "^3.8.0",
"gulp-plumber": "^1.0.0",
"gulp-shell": "^0.4.1",
"gulp-sourcemaps": "^1.5.2",
"gulp-util": "^3.0.4",
"grunt-shell": "^1.1.2",
"grunt-shell-spawn": "^0.3.8",
"jest-cli": "^0.4.5",
"jsxhint": "^0.14.0",
"load-grunt-tasks": "^3.2.0",

View File

@ -5,9 +5,8 @@ var fs = require('fs');
var ipc = require('ipc');
var path = require('path');
process.env.NODE_PATH = path.join(__dirname, '/../node_modules');
process.env.NODE_PATH = path.join(__dirname, 'node_modules');
process.env.RESOURCES_PATH = path.join(__dirname, '/../resources');
process.chdir(path.join(__dirname, '..'));
process.env.PATH = '/usr/local/bin:' + process.env.PATH;
var size = {}, settingsjson = {};
@ -18,6 +17,46 @@ try {
settingsjson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'settings.json'), 'utf8'));
} catch (err) {}
var handleStartupEvent = function() {
if (process.platform !== 'win32') {
return false;
}
var squirrelCommand = process.argv[1];
switch (squirrelCommand) {
case '--squirrel-install':
case '--squirrel-updated':
// Optionally do things such as:
//
// - Install desktop and start menu shortcuts
// - Add your .exe to the PATH
// - Write to the registry for things like file associations and
// explorer context menus
// Always quit when done
app.quit();
return true;
case '--squirrel-uninstall':
// Undo anything you did in the --squirrel-install and
// --squirrel-updated handlers
// Always quit when done
app.quit();
return true;
case '--squirrel-obsolete':
// This is called on the outgoing version of your app before
// we update to the new version - it's the opposite of
// --squirrel-updated
app.quit();
return true;
}
};
handleStartupEvent();
var openURL = null;
app.on('open-url', function (event, url) {
event.preventDefault();
@ -36,7 +75,7 @@ app.on('ready', function () {
show: false,
});
mainWindow.loadUrl(path.normalize('file://' + path.join(__dirname, '..', 'build/index.html')));
mainWindow.loadUrl(path.normalize('file://' + path.join(__dirname, 'index.html')));
app.on('activate-with-no-open-windows', function () {
if (mainWindow) {

View File

@ -56,7 +56,7 @@ module.exports = {
.replace(/\/Users\/[^\/]*\//mg, '/Users/<redacted>/');
},
packagejson: function () {
return JSON.parse(fs.readFileSync(path.join(__dirname, '../..', 'package.json'), 'utf8'));
return JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
},
settingsjson: function () {
var settingsjson = {};