From 7d0d63e5c374251742a7835710458f107f412389 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Thu, 4 Jun 2015 20:13:21 -0700 Subject: [PATCH 01/26] Update CONTRIBUTING.md --- CONTRIBUTING.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cf4dbb202e..e0b8dcc753 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,14 +18,21 @@ Before you fil an issue or a pull request, quickly read of the following tips on ### Prerequisites Most of the time, you'll have installed Kitematic before contibuting, but for the -sake of completeness, you can also install [Node.js](https://nodejs.org/) and the latest Xcode from the Apple App Store and then run from your Git clone. +sake of completeness, you can also install [Node.js 0.10.38](https://nodejs.org/dist/v0.10.38/). Running `npm start` will download and install the OS X Docker client, -[Docker machine](https://github.com/docker/machine), +[Docker Machine](https://github.com/docker/machine), [Docker Compose](https://github.com/docker/compose) the [Boot2Docker iso](https://github.com/boot2docker/boot2docker), [Electron](http://electron.atom.io/), and [VirtualBox](https://www.virtualbox.org/) if needed. +### Other Prerequisites (Mac) +- The latest Xcode from the Apple App Store. + +### Other Prerequisites (Windows) +- [Visual Studio 2013 Community](https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx) (or similar) +- [Python](https://www.python.org/downloads/release/python-2710/) + ### Getting Started - `npm install` From 42b6271a3429dd3faab03b1c8ecc1d5492c4dd47 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Thu, 4 Jun 2015 20:13:34 -0700 Subject: [PATCH 02/26] Update CONTRIBUTING.md --- CONTRIBUTING.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e0b8dcc753..4efcb24534 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,12 +20,6 @@ Before you fil an issue or a pull request, quickly read of the following tips on Most of the time, you'll have installed Kitematic before contibuting, but for the sake of completeness, you can also install [Node.js 0.10.38](https://nodejs.org/dist/v0.10.38/). -Running `npm start` will download and install the OS X Docker client, -[Docker Machine](https://github.com/docker/machine), [Docker Compose](https://github.com/docker/compose) -the [Boot2Docker iso](https://github.com/boot2docker/boot2docker), -[Electron](http://electron.atom.io/), and [VirtualBox](https://www.virtualbox.org/) -if needed. - ### Other Prerequisites (Mac) - The latest Xcode from the Apple App Store. @@ -35,6 +29,7 @@ if needed. ### Getting Started + - `npm install` To run the app in development: From 9628a00ab25c72880393903067e3b5d4b51bd5aa Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Thu, 4 Jun 2015 20:14:23 -0700 Subject: [PATCH 03/26] Update CONTRIBUTING.md --- CONTRIBUTING.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4efcb24534..8fc1617a3d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,13 +29,17 @@ sake of completeness, you can also install [Node.js 0.10.38](https://nodejs.org/ ### Getting Started - - `npm install` To run the app in development: - `npm start` +Running `npm start` will download and install the OS X Docker client, +[Docker Machine](https://github.com/docker/machine), [Docker Compose](https://github.com/docker/compose) +the [Boot2Docker iso](https://github.com/boot2docker/boot2docker), +[Electron](http://electron.atom.io/). + ### Building & Release - `npm run release` From 955a43a14dfb232701650c95ebf5094c6fc9709c Mon Sep 17 00:00:00 2001 From: Vojta Bartos Date: Fri, 5 Jun 2015 10:11:04 +0200 Subject: [PATCH 04/26] Fix bug where we want to set custom shell - at container details sub header - tried to access to array like object - added reduce function to make array object --- src/components/ContainerDetailsSubheader.react.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/ContainerDetailsSubheader.react.js b/src/components/ContainerDetailsSubheader.react.js index bc9d4a348d..c34ccd6de8 100644 --- a/src/components/ContainerDetailsSubheader.react.js +++ b/src/components/ContainerDetailsSubheader.react.js @@ -102,7 +102,11 @@ var ContainerDetailsSubheader = React.createClass({ if (!this.disableTerminal()) { metrics.track('Terminaled Into Container'); var container = this.props.container; - var shell = ContainerUtil.env(container).SHELL; + var shell = ContainerUtil.env(container).reduce((envs, env) => { + envs[env[0]] = env[1]; + return envs; + }, {}).SHELL; + if(typeof shell === 'undefined') { shell = 'sh'; } From 3cede9eb748fec69999af27246af3402db5eeab0 Mon Sep 17 00:00:00 2001 From: TeckniX Date: Fri, 5 Jun 2015 11:10:10 -0400 Subject: [PATCH 05/26] Moved Kitematic dir to Documents Signed-off-by: TeckniX --- src/components/ContainerHomeFolders.react.js | 2 +- src/utils/Util.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ContainerHomeFolders.react.js b/src/components/ContainerHomeFolders.react.js index 4f769ce766..cc62cd6a87 100644 --- a/src/components/ContainerHomeFolders.react.js +++ b/src/components/ContainerHomeFolders.react.js @@ -25,7 +25,7 @@ var ContainerHomeFolder = React.createClass({ }, (index) => { if (index === 0) { var volumes = _.clone(this.props.container.Volumes); - var newHostVolume = path.join(util.home(), 'Kitematic', this.props.container.Name, containerVolume); + var newHostVolume = path.join(util.home(), util.documents(), 'Kitematic', this.props.container.Name, containerVolume); volumes[containerVolume] = newHostVolume; var binds = _.pairs(volumes).map(function (pair) { if(util.isWindows()) { diff --git a/src/utils/Util.js b/src/utils/Util.js index 8d90f74166..60554439ab 100644 --- a/src/utils/Util.js +++ b/src/utils/Util.js @@ -39,6 +39,9 @@ module.exports = { home: function () { return process.env[this.isWindows() ? 'USERPROFILE' : 'HOME']; }, + documents: function () { + return this.isWindows() ? 'My\ Documents' : 'Documents'; + }, supportDir: function () { var dirs = ['Library', 'Application\ Support', 'Kitematic']; var acc = this.home(); From 4b708f2275ad48ed17c6d5c26e1a406fdfe0f07f Mon Sep 17 00:00:00 2001 From: Vojta Bartos Date: Fri, 5 Jun 2015 19:49:18 +0200 Subject: [PATCH 06/26] Making condition simple - removed checking for undefined, not necessary --- src/components/ContainerDetailsSubheader.react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ContainerDetailsSubheader.react.js b/src/components/ContainerDetailsSubheader.react.js index c34ccd6de8..72f2f9d1aa 100644 --- a/src/components/ContainerDetailsSubheader.react.js +++ b/src/components/ContainerDetailsSubheader.react.js @@ -107,7 +107,7 @@ var ContainerDetailsSubheader = React.createClass({ return envs; }, {}).SHELL; - if(typeof shell === 'undefined') { + if(!shell) { shell = 'sh'; } machine.ip().then(ip => { From 577858f9a1d6a636dba97816b171cfbce8a6af87 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Fri, 5 Jun 2015 10:56:38 -0700 Subject: [PATCH 07/26] Fixed docs to no longer mention copying binaries --- docs/index.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 0ddfc9f3b9..60a58533b2 100755 --- a/docs/index.md +++ b/docs/index.md @@ -28,10 +28,9 @@ container! ## Technical Details -Kitematic is a self-contained .app, with a two exceptions: +Kitematic is a self-contained .app, with an exception: - It will install VirtualBox if it's not already installed. -- It copies the `docker` and `docker-machine` binaries to `/usr/local/bin` for convenience. ### Why does Kitematic need my root password? From 1a88216e2e18ba2befa746ffc14fb931f16db011 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Fri, 5 Jun 2015 16:41:43 -0700 Subject: [PATCH 08/26] Windows fonts --- styles/variables.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/styles/variables.less b/styles/variables.less index 83e17a8c3b..dc0624f59e 100644 --- a/styles/variables.less +++ b/styles/variables.less @@ -22,5 +22,5 @@ @color-divider: @gray-lightest; @color-background: #FCFCFC; -@font-regular: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; -@font-code: Menlo; +@font-regular: "Helvetica Neue", Segoe UI, Arial, "Lucida Grande", sans-serif; +@font-code: Menlo, Consolas; From 103af8b53042b43091ce43dd42197e4982b256d7 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Fri, 5 Jun 2015 16:43:26 -0700 Subject: [PATCH 09/26] Fix windows volume mounting --- src/components/ContainerHomeFolders.react.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ContainerHomeFolders.react.js b/src/components/ContainerHomeFolders.react.js index 4f769ce766..88196f5022 100644 --- a/src/components/ContainerHomeFolders.react.js +++ b/src/components/ContainerHomeFolders.react.js @@ -63,8 +63,9 @@ var ContainerHomeFolder = React.createClass({ return false; } - var folders = _.map(this.props.container.Volumes, (val, key) => { - var firstFolder = key.split(path.sep)[1]; + console.log(this.props.container.Volumes); + var folders = _.map(_.omit(this.props.container.Volumes, (v, k) => k.indexOf('/Users/') !== -1), (val, key) => { + var firstFolder = key.split('/')[1]; return (
From bf7d3af40229472d2f98178f3eeae56127e9f6c4 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Fri, 5 Jun 2015 21:22:34 -0700 Subject: [PATCH 10/26] Fixed bug with API requests to 1.7 RC2 /containers/create endpoint --- src/utils/DockerUtil.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/DockerUtil.js b/src/utils/DockerUtil.js index 1109a381d1..a3b2424985 100644 --- a/src/utils/DockerUtil.js +++ b/src/utils/DockerUtil.js @@ -103,6 +103,8 @@ export default { containerData.Env = containerData.Config.Env; } + containerData.Volumes = _.mapObject(containerData.Volumes, () => {return {};}); + let existing = this.client.getContainer(name); existing.kill(() => { existing.remove(() => { @@ -203,7 +205,6 @@ export default { containerServerActions.error({name, error}); return; } - existingData.name = existingData.Name || name; if (existingData.Config && existingData.Config.Image) { existingData.Image = existingData.Config.Image; @@ -371,6 +372,7 @@ export default { // data is associated with one layer only (can be identified with id) stream.on('data', str => { + console.log(str); var data = JSON.parse(str); if (data.error) { From cc0bc719fa15cb1adfe8edeed880d2f204516be4 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Fri, 5 Jun 2015 21:23:14 -0700 Subject: [PATCH 11/26] Removing unnecessary print statement --- src/utils/DockerUtil.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/DockerUtil.js b/src/utils/DockerUtil.js index a3b2424985..46dceeb5a1 100644 --- a/src/utils/DockerUtil.js +++ b/src/utils/DockerUtil.js @@ -372,7 +372,6 @@ export default { // data is associated with one layer only (can be identified with id) stream.on('data', str => { - console.log(str); var data = JSON.parse(str); if (data.error) { From 72d4e21a34aeb53216308d6e4868dae96c46733e Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Fri, 5 Jun 2015 21:34:44 -0700 Subject: [PATCH 12/26] Fixed bug where packaging binaries would fail on release --- gulpfile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 09b70a92b9..6099fb736b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -207,7 +207,7 @@ gulp.task('download-docker', function (cb) { } else { request('https://get.docker.com/builds/Darwin/x86_64/docker-' + packagejson['docker-version']) .pipe(fs.createWriteStream('./resources/docker')).on('finish', function () { - fs.chmodSync('./resources/docker', 755); + fs.chmodSync('./resources/docker', 0755); cb(); }); } @@ -230,7 +230,7 @@ gulp.task('download-docker-machine', function (cb) { } else { request('https://github.com/docker/machine/releases/download/v' + packagejson['docker-machine-version'] + '/docker-machine_darwin-amd64') .pipe(fs.createWriteStream('./resources/docker-machine')).on('finish', function () { - fs.chmodSync('./resources/docker-machine', 755); + fs.chmodSync('./resources/docker-machine', 0755); cb(); }); } @@ -252,7 +252,7 @@ gulp.task('download-docker-compose', function (cb) { gutil.log(gutil.colors.green('Downloading Docker Compose')); request('https://github.com/docker/compose/releases/download/' + packagejson['docker-compose-version'] + '/docker-compose-Darwin-x86_64') .pipe(fs.createWriteStream('./resources/docker-compose')).on('finish', function () { - fs.chmodSync('./resources/docker-compose', 755); + fs.chmodSync('./resources/docker-compose', 0755); cb(); }); } From 95993a7ffbb26edec3456655aaf4667990eb9e84 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Mon, 8 Jun 2015 13:04:31 -0700 Subject: [PATCH 13/26] Fixed bug where error would not show if fetching recommended repos failed --- src/utils/RegHubUtil.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/RegHubUtil.js b/src/utils/RegHubUtil.js index 8bad189107..cf00640249 100644 --- a/src/utils/RegHubUtil.js +++ b/src/utils/RegHubUtil.js @@ -56,7 +56,7 @@ module.exports = { recommended: function () { request.get('https://kitematic.com/recommended.json', (error, response, body) => { if (error) { - repositoryServerActions.recommendedError({error}); + repositoryServerActions.error({error}); } let data = JSON.parse(body); From 4d5b9861dd1aef622d9b34adcbf6c4d908a31a5e Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Mon, 8 Jun 2015 15:33:46 -0700 Subject: [PATCH 14/26] Fixed bug where the VirtualBox shared folder would attempt to be created twice on Windows --- src/stores/SetupStore.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/stores/SetupStore.js b/src/stores/SetupStore.js index ddedcb3545..8d7151c1ce 100644 --- a/src/stores/SetupStore.js +++ b/src/stores/SetupStore.js @@ -66,16 +66,6 @@ var _steps = [{ yield machine.rm(); } yield machine.create(); - if(util.isWindows()) { - let home = util.home(); - let driveLetter = home.charAt(0); - let parts = home.split('\\').slice(0, -1); - let usersDirName = parts[parts.length-1]; - let usersDirPath = parts.join('\\'); - let shareName = driveLetter + '/' + usersDirName; - yield virtualBox.mountSharedDir(machine.name(), shareName, usersDirPath); - yield machine.start(); - } return; } From 85fc0a6edab173f17cc483bf9b010f4b6a515ab2 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Mon, 8 Jun 2015 15:34:54 -0700 Subject: [PATCH 15/26] Fixed bug where error dialog would appear if app was closed via taskbar --- src/browser.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/browser.js b/src/browser.js index b731e338ef..04e3918c71 100644 --- a/src/browser.js +++ b/src/browser.js @@ -52,7 +52,8 @@ app.on('ready', function () { }); app.on('before-quit', function () { - if (!updating) { + // TODO: make this work for right click + close + if (!updating && mainWindow.webContents) { mainWindow.webContents.send('application:quitting'); } }); From a3ca2217e126f7fad76f3fcc8bce2dd8cd926795 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Mon, 8 Jun 2015 19:36:59 -0700 Subject: [PATCH 16/26] Adding gruntfile for better compatibility with electron community --- Gruntfile.js | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 11 ++++ 2 files changed, 162 insertions(+) create mode 100644 Gruntfile.js diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000000..f52f310a8b --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,151 @@ +var path = require('path'); +var execFile = require('child_process').execFile; +var packagejson = require('./package.json'); + +var WINDOWS_DOCKER_URL = 'https://get.docker.com/builds/Windows/x86_64/docker-1.6.2.exe'; +var DARWIN_DOCKER_URL = 'https://get.docker.com/builds/Darwin/x86_64/docker-' + packagejson['docker-version']; +var WINDOWS_DOCKER_MACHINE_URL = 'https://github.com/docker/machine/releases/download/v' + packagejson['docker-machine-version'] + '/docker-machine_windows-amd64.exe'; +var DARWIN_DOCKER_MACHINE_URL = 'https://github.com/docker/machine/releases/download/v' + packagejson['docker-machine-version'] + '/docker-machine_darwin-amd64'; +var DARWIN_COMPOSE_URL = 'https://github.com/docker/compose/releases/download/' + packagejson['docker-compose-version'] + '/docker-compose-Darwin-x86_64'; +var BOOT2DOCKER_ISO_URL = 'https://github.com/boot2docker/boot2docker/releases/download/v' + packagejson['docker-version'] + '/boot2docker.iso'; + +module.exports = function (grunt) { + require('load-grunt-tasks')(grunt); + // var target = grunt.option('target') || 'development'; + + var version = function (str) { + var match = str.match(/(\d+\.\d+\.\d+)/); + return match ? match[1] : null; + }; + + grunt.registerMultiTask('download-binary', 'Downloads binary unless version up to date', function () { + var target = grunt.task.current.target; + var done = this.async(); + var config = grunt.config('download-binary')[target]; + execFile(config.binary, ['--version'], function (err, stdout) { + var currentVersion = version(stdout); + if (!currentVersion || currentVersion !== config.version) { + grunt.task.run('curl:' + target); + grunt.task.run('chmod'); + } + done(); + }); + }); + + + grunt.initConfig({ + // electron + 'download-electron': { + version: packagejson['electron-version'], + outputDir: 'cache' + }, + + // docker binaries + 'download-binary': { + docker: { + version: packagejson['docker-version'], + binary: path.join('resources', 'docker'), + download: 'curl:docker' + }, + 'docker-machine': { + version: packagejson['docker-machine-version'], + binary: path.join('resources', 'docker-machine'), + download: 'curl:docker-machine' + } + }, + + // images + copy: { + images: { + src: 'images/*', + dest: 'build/' + }, + html: { + src: 'index.html', + dest: 'build/' + }, + fonts: { + src: 'fonts/*', + dest: 'build/' + } + }, + + // download binaries + curl: { + docker: { + src: process.platform === 'win32' ? WINDOWS_DOCKER_URL : DARWIN_DOCKER_URL, + dest: process.platform === 'win32' ? path.join('resources', 'docker.exe') : path.join('resources', 'docker') + }, + 'docker-machine': { + src: process.platform === 'win32' ? WINDOWS_DOCKER_MACHINE_URL : DARWIN_DOCKER_MACHINE_URL, + dest: process.platform === 'win32' ? path.join('resources', 'docker-machine.exe') : path.join('resources', 'docker-machine') + }, + 'docker-compose': { + src: DARWIN_COMPOSE_URL, + dest: 'resources/docker-compose' + }, + 'boot2docker-iso': { + src: BOOT2DOCKER_ISO_URL, + dest: path.join('resources', 'boot2docker-' + packagejson['docker-version']) + } + }, + + chmod: { + binaries: { + options: { + mode: '755' + }, + src: ['resources/docker*'] + } + }, + + // styles + less: { + options: { + sourceMapFileInline: true + }, + files: { + 'build/main.css': 'styles/main.less' + } + }, + + // javascript + babel: { + options: { + sourceMap: 'inline', + blacklist: 'regenerator' + }, + dist: { + files: [{ + expand: true, + cwd: 'src/', + src: ['**/*.js'], + dest: 'build/', + }] + } + }, + + // electron + + // livereload + watch: { + options: { + livereload: true + }, + js: { + files: ['src/**/*.js'], + tasks: ['babel'] + }, + less: { + files: ['styles/**/*.less'], + tasks: ['less'] + }, + copy: { + files: ['images/*', 'index.html', 'fonts/*'], + tasks: ['copy'] + } + } + }); + + grunt.registerTask('default', ['download-electron', 'curl', 'babel', 'less', 'copy', 'watch', 'electron']); +}; diff --git a/package.json b/package.json index f33814e197..5db699fb12 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,16 @@ "devDependencies": { "babel": "^5.1.10", "babel-jest": "^5.2.0", + "grunt": "^0.4.5", + "grunt-babel": "^5.0.1", + "grunt-chmod": "^1.0.3", + "grunt-cli": "^0.1.13", + "grunt-contrib-copy": "^0.8.0", + "grunt-contrib-less": "^1.0.1", + "grunt-contrib-watch": "^0.6.1", + "grunt-curl": "^2.2.0", + "grunt-download-electron": "^2.1.1", + "grunt-electron-installer": "^0.33.0", "gulp": "^3.8.11", "gulp-babel": "^5.1.0", "gulp-changed": "^1.2.1", @@ -83,6 +93,7 @@ "gulp-util": "^3.0.4", "jest-cli": "^0.4.5", "jsxhint": "^0.14.0", + "load-grunt-tasks": "^3.2.0", "minimist": "^1.1.1", "react-tools": "^0.13.1", "run-sequence": "^1.0.2", From 140ae4671bb23b98a9ee430c6e0dc2d27771a842 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 17:16:00 -0700 Subject: [PATCH 17/26] Installer & dist for windows --- .gitignore | 1 + Gruntfile.js | 101 ++++++++++++++++++++++++++++++++++++---------- package.json | 22 +++------- src/browser.js | 45 +++++++++++++++++++-- src/utils/Util.js | 2 +- 5 files changed, 130 insertions(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index e51ebc5468..8fe91862fb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .swp build dist +installer node_modules coverage npm-debug.log diff --git a/Gruntfile.js b/Gruntfile.js index f52f310a8b..a990ace9f6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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/*', - dest: 'build/' + 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,8 +145,10 @@ module.exports = function (grunt) { options: { sourceMapFileInline: true }, - files: { - 'build/main.css': 'styles/main.less' + dist: { + files: { + 'build/main.css': 'styles/main.less' + } } }, @@ -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']); }; diff --git a/package.json b/package.json index 5db699fb12..fa9eb1f856 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/browser.js b/src/browser.js index 04e3918c71..5a4f8c844f 100644 --- a/src/browser.js +++ b/src/browser.js @@ -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) { diff --git a/src/utils/Util.js b/src/utils/Util.js index fd4524e4e5..c8609e95c9 100644 --- a/src/utils/Util.js +++ b/src/utils/Util.js @@ -56,7 +56,7 @@ module.exports = { .replace(/\/Users\/[^\/]*\//mg, '/Users//'); }, 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 = {}; From 5f8776c0eed6936c28c200e605ddbb8917c6d8d4 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 17:56:08 -0700 Subject: [PATCH 18/26] Adding mac os x --- Gruntfile.js | 72 +++++++++++++++++++++++++++++++--------------------- package.json | 1 + 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a990ace9f6..408d569df9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,7 @@ var path = require('path'); var execFile = require('child_process').execFile; var packagejson = require('./package.json'); +var electron = require('electron-prebuilt'); var WINDOWS_DOCKER_URL = 'https://get.docker.com/builds/Windows/x86_64/docker-1.6.2.exe'; var DARWIN_DOCKER_URL = 'https://get.docker.com/builds/Darwin/x86_64/docker-' + packagejson['docker-version']; @@ -36,9 +37,35 @@ module.exports = function (grunt) { grunt.initConfig({ // electron - 'download-electron': { - version: packagejson['electron-version'], - outputDir: 'cache' + electron: { + windows: { + options: { + name: 'Kitematic', + dir: 'build/', + out: 'dist/', + version: packagejson['electron-version'], + platform: 'win32', + arch: 'x64', + asar: true + } + }, + osx: { + options: { + name: 'Kitematic', + dir: 'build/', + out: 'dist/osx/', + version: packagejson['electron-version'], + platform: 'darwin', + arch: 'x64', + asar: true + } + } + }, + + 'create-windows-installer': { + appDirectory: 'dist/Kitematic-win32/', + outputDirectory: 'installer/', + authors: 'Docker Inc.' }, // docker binaries @@ -55,27 +82,6 @@ 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: { dev: { @@ -101,12 +107,20 @@ module.exports = function (grunt) { expand: true }] }, - release: { + windows: { + files: [{ + expand: true, + cwd: 'resources', + src: ['docker*', 'boot2docker.iso'], + dest: 'dist/Kitematic-win32/resources/resources/' + }] + }, + osx: { files: [{ expand: true, cwd: 'resources', src: ['**/*'], - dest: 'dist/Kitematic-win32/resources/resources/' + dest: 'dist/osx/Kitematic.app/resources/' }] } }, @@ -170,7 +184,7 @@ module.exports = function (grunt) { shell: { electron: { - command: path.join('cache', 'electron') + ' ' + 'build', + command: electron + ' ' + 'build', options: { async: true, execOptions: { @@ -205,6 +219,6 @@ module.exports = function (grunt) { } } }); - 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']); + grunt.registerTask('default', ['download-binary', 'babel', 'less', 'copy:dev', 'shell:electron', 'watchChokidar']); + grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron', 'copy:windows', 'copy:mac']); }; diff --git a/package.json b/package.json index fa9eb1f856..6cf571e0ed 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "devDependencies": { "babel": "^5.1.10", "babel-jest": "^5.2.0", + "electron-prebuilt": "^0.27.3", "grunt": "^0.4.5", "grunt-babel": "^5.0.1", "grunt-chmod": "^1.0.3", From 05e32dc3e584afe4a6b491298c892a68b2538422 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 17:57:17 -0700 Subject: [PATCH 19/26] Bump machine version to 0.3.0 rc2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f33814e197..88516fdf8d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ } ], "docker-version": "1.6.2", - "docker-machine-version": "0.3.0-rc1", + "docker-machine-version": "0.3.0-rc2", "docker-compose-version": "1.2.0", "electron-version": "0.27.2", "virtualbox-version": "4.3.28", From 7c67548fc611cf6b3951fb9abad94ffc6868d31a Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 20:26:05 -0700 Subject: [PATCH 20/26] Fix bug where SIGTERMing grunt would not stop Electron --- Gruntfile.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index 408d569df9..df3bcf78e6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -201,6 +201,9 @@ module.exports = function (grunt) { // livereload watchChokidar: { + options: { + spawn: false + }, livereload: { options: {livereload: true}, files: ['build/**/*'] @@ -221,4 +224,10 @@ module.exports = function (grunt) { }); grunt.registerTask('default', ['download-binary', 'babel', 'less', 'copy:dev', 'shell:electron', 'watchChokidar']); grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron', 'copy:windows', 'copy:mac']); + + process.on('SIGINT', function () { + console.log('INT'); + grunt.task.run(['shell:electron:kill']); + process.exit(1); + }); }; From 8f465c1a8cd34ee8e7bdd04711f8d899b984155c Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 20:35:46 -0700 Subject: [PATCH 21/26] Separate Mac OS X and Windows tasks --- Gruntfile.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index df3bcf78e6..f36212ea60 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -113,15 +113,21 @@ module.exports = function (grunt) { cwd: 'resources', src: ['docker*', 'boot2docker.iso'], dest: 'dist/Kitematic-win32/resources/resources/' - }] + }], + options: { + mode: true + } }, osx: { files: [{ expand: true, cwd: 'resources', src: ['**/*'], - dest: 'dist/osx/Kitematic.app/resources/' - }] + dest: 'dist/osx/Kitematic.app/Contents/Resources/resources/' + }], + options: { + mode: true + } } }, @@ -223,7 +229,12 @@ module.exports = function (grunt) { } }); grunt.registerTask('default', ['download-binary', 'babel', 'less', 'copy:dev', 'shell:electron', 'watchChokidar']); - grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron', 'copy:windows', 'copy:mac']); + + if (process.platform === 'win32') { + grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron:windows', 'copy:windows', 'copy:osx']); + } else { + grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron:osx', 'copy:osx']); + } process.on('SIGINT', function () { console.log('INT'); From 47beaee0c8e5c55291ce82168440c9e3f681b718 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 20:44:25 -0700 Subject: [PATCH 22/26] Removing unnecessary console log in Gruntfile --- Gruntfile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index f36212ea60..bcce7e9b86 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -237,7 +237,6 @@ module.exports = function (grunt) { } process.on('SIGINT', function () { - console.log('INT'); grunt.task.run(['shell:electron:kill']); process.exit(1); }); From 1552d099572afaecbef86aed5c70a71da5b75bff Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 20:49:26 -0700 Subject: [PATCH 23/26] Accounting for settings.json --- Gruntfile.js | 4 ++-- src/browser.js | 2 +- src/utils/MetricsUtil.js | 2 +- src/utils/Util.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index bcce7e9b86..8f829617f2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -88,7 +88,7 @@ module.exports = function (grunt) { files: [{ expand: true, cwd: '.', - src: ['package.json', 'index.html'], + src: ['package.json', 'settings.json', 'index.html'], dest: 'build/' }, { expand: true, @@ -111,7 +111,7 @@ module.exports = function (grunt) { files: [{ expand: true, cwd: 'resources', - src: ['docker*', 'boot2docker.iso'], + src: ['docker*'], dest: 'dist/Kitematic-win32/resources/resources/' }], options: { diff --git a/src/browser.js b/src/browser.js index 5a4f8c844f..cb8010dd1f 100644 --- a/src/browser.js +++ b/src/browser.js @@ -14,7 +14,7 @@ try { size = JSON.parse(fs.readFileSync(path.join(process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], 'Library', 'Application\ Support', 'Kitematic', 'size'))); } catch (err) {} try { - settingsjson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'settings.json'), 'utf8')); + settingsjson = JSON.parse(fs.readFileSync(path.join(__dirname, 'settings.json'), 'utf8')); } catch (err) {} var handleStartupEvent = function() { diff --git a/src/utils/MetricsUtil.js b/src/utils/MetricsUtil.js index e7083989fd..8b19edfbd0 100644 --- a/src/utils/MetricsUtil.js +++ b/src/utils/MetricsUtil.js @@ -7,7 +7,7 @@ var util = require('./Util'); var settings; try { - settings = JSON.parse(fs.readFileSync(path.join(__dirname, '../..', 'settings.json'), 'utf8')); + settings = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'settings.json'), 'utf8')); } catch (err) { settings = {}; } diff --git a/src/utils/Util.js b/src/utils/Util.js index c8609e95c9..0430d3de71 100644 --- a/src/utils/Util.js +++ b/src/utils/Util.js @@ -61,7 +61,7 @@ module.exports = { settingsjson: function () { var settingsjson = {}; try { - settingsjson = JSON.parse(fs.readFileSync(path.join(__dirname, '../..', 'settings.json'), 'utf8')); + settingsjson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'settings.json'), 'utf8')); } catch (err) {} return settingsjson; }, From 1263a8c4fead4c771692cb5c8220ea6d6b2b437e Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 21:54:11 -0700 Subject: [PATCH 24/26] Fix icon on mac os x --- Gruntfile.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 8f829617f2..4ae6c938f6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,6 +16,8 @@ module.exports = function (grunt) { var env = process.env; env.NODE_ENV = target; + console.log(process.cwd()); + var version = function (str) { var match = str.match(/(\d+\.\d+\.\d+)/); return match ? match[1] : null; @@ -57,7 +59,8 @@ module.exports = function (grunt) { version: packagejson['electron-version'], platform: 'darwin', arch: 'x64', - asar: true + asar: true, + 'app-bundle-id': 'com.kitematic.kitematic' } } }, @@ -124,6 +127,9 @@ module.exports = function (grunt) { cwd: 'resources', src: ['**/*'], dest: 'dist/osx/Kitematic.app/Contents/Resources/resources/' + }, { + src: 'util/kitematic.icns', + dest: 'dist/osx/Kitematic.app/Contents/Resources/atom.icns' }], options: { mode: true From c53400fb90587f12582515b767f7dd158114427a Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 22:27:27 -0700 Subject: [PATCH 25/26] Fix signing --- Gruntfile.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 4ae6c938f6..d9013a2d17 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,8 +16,6 @@ module.exports = function (grunt) { var env = process.env; env.NODE_ENV = target; - console.log(process.cwd()); - var version = function (str) { var match = str.match(/(\d+\.\d+\.\d+)/); return match ? match[1] : null; @@ -38,6 +36,10 @@ module.exports = function (grunt) { }); grunt.initConfig({ + IDENTITY: '"Developer ID Application: Docker Inc"', + OSX_OUT: './dist/osx', + OSX_FILENAME: path.join('<%= OSX_OUT %>', 'Kitematic.app'), + // electron electron: { windows: { @@ -55,7 +57,7 @@ module.exports = function (grunt) { options: { name: 'Kitematic', dir: 'build/', - out: 'dist/osx/', + out: '<%= OSX_OUT %>', version: packagejson['electron-version'], platform: 'darwin', arch: 'x64', @@ -126,10 +128,10 @@ module.exports = function (grunt) { expand: true, cwd: 'resources', src: ['**/*'], - dest: 'dist/osx/Kitematic.app/Contents/Resources/resources/' + dest: '<%= OSX_FILENAME %>/Contents/Resources/resources/' }, { src: 'util/kitematic.icns', - dest: 'dist/osx/Kitematic.app/Contents/Resources/atom.icns' + dest: '<%= OSX_FILENAME %>/Contents/Resources/atom.icns' }], options: { mode: true @@ -203,6 +205,17 @@ module.exports = function (grunt) { env: env } } + }, + sign: { + options: { + failOnError: false, + }, + command: [ + 'codesign --deep -v -f -s <%= IDENTITY %> <%= OSX_FILENAME %>/Contents/Frameworks/*', + 'codesign -v -f -s <%= IDENTITY %> <%= OSX_FILENAME %>', + 'codesign -vvv --display <%= OSX_FILENAME %>', + 'codesign -v --verify <%= OSX_FILENAME %>', + ].join(' && '), } }, @@ -239,7 +252,7 @@ module.exports = function (grunt) { if (process.platform === 'win32') { grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron:windows', 'copy:windows', 'copy:osx']); } else { - grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron:osx', 'copy:osx']); + grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron:osx', 'copy:osx', 'shell:sign']); } process.on('SIGINT', function () { From 5048d16e22d31d27f8a87b71b6f47fc10ef6df3b Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jun 2015 23:17:49 -0700 Subject: [PATCH 26/26] OS X zip --- Gruntfile.js | 30 ++++++++++++++++++++---------- package.json | 5 +++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index d9013a2d17..4dedaf9122 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,6 +13,7 @@ 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 beta = grunt.option('beta') || false; var env = process.env; env.NODE_ENV = target; @@ -35,16 +36,22 @@ module.exports = function (grunt) { }); }); + var APPNAME = beta ? 'Kitematic (Beta)' : 'Kitematic'; + var OSX_OUT = './dist/osx'; + var OSX_FILENAME = OSX_OUT + '/' + APPNAME + '.app'; + grunt.initConfig({ - IDENTITY: '"Developer ID Application: Docker Inc"', - OSX_OUT: './dist/osx', - OSX_FILENAME: path.join('<%= OSX_OUT %>', 'Kitematic.app'), + IDENTITY: 'Developer ID Application: Docker Inc', + APPNAME: APPNAME, + OSX_OUT: OSX_OUT, + OSX_FILENAME: OSX_FILENAME, + OSX_FILENAME_ESCAPED: OSX_FILENAME.replace(' ', '\\ ').replace('(','\\(').replace(')','\\)'), // electron electron: { windows: { options: { - name: 'Kitematic', + name: '<%= APPNAME %>', dir: 'build/', out: 'dist/', version: packagejson['electron-version'], @@ -55,7 +62,7 @@ module.exports = function (grunt) { }, osx: { options: { - name: 'Kitematic', + name: '<%= APPNAME %>', dir: 'build/', out: '<%= OSX_OUT %>', version: packagejson['electron-version'], @@ -211,11 +218,14 @@ module.exports = function (grunt) { failOnError: false, }, command: [ - 'codesign --deep -v -f -s <%= IDENTITY %> <%= OSX_FILENAME %>/Contents/Frameworks/*', - 'codesign -v -f -s <%= IDENTITY %> <%= OSX_FILENAME %>', - 'codesign -vvv --display <%= OSX_FILENAME %>', - 'codesign -v --verify <%= OSX_FILENAME %>', + 'codesign --deep -v -f -s "<%= IDENTITY %>" <%= OSX_FILENAME_ESCAPED %>/Contents/Frameworks/*', + 'codesign -v -f -s "<%= IDENTITY %>" <%= OSX_FILENAME_ESCAPED %>', + 'codesign -vvv --display <%= OSX_FILENAME_ESCAPED %>', + 'codesign -v --verify <%= OSX_FILENAME_ESCAPED %>', ].join(' && '), + }, + zip: { + command: 'ditto -c -k --sequesterRsrc --keepParent <%= OSX_FILENAME_ESCAPED %> <%= OSX_OUT %>/Kitematic-' + packagejson.version + '.zip', } }, @@ -252,7 +262,7 @@ module.exports = function (grunt) { if (process.platform === 'win32') { grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron:windows', 'copy:windows', 'copy:osx']); } else { - grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron:osx', 'copy:osx', 'shell:sign']); + grunt.registerTask('release', ['clean:dist', 'clean:build', 'download-binary', 'babel', 'less', 'copy:dev', 'electron:osx', 'copy:osx', 'shell:sign', 'shell:zip']); } process.on('SIGINT', function () { diff --git a/package.json b/package.json index 6cf571e0ed..a2a6aabdd5 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "start": "gulp", "test": "jest -c jest-unit.json", "integration": "jest -c jest-integration.json", - "release": "gulp release", - "release:beta": "gulp release --beta", + "release": "grunt release", + "release:beta": "grunt release --beta=true", "lint": "jsxhint src", "reset": "gulp reset" }, @@ -88,6 +88,7 @@ "minimist": "^1.1.1", "react-tools": "^0.13.1", "run-sequence": "^1.0.2", + "shell-escape": "^0.2.0", "source-map-support": "^0.2.10" } }