kitematic/Gruntfile.js

254 строки
6.6 KiB
JavaScript
Исходник Обычный вид История

var path = require('path');
var execFile = require('child_process').execFile;
var packagejson = require('./package.json');
2015-06-10 03:56:08 +03:00
var electron = require('electron-prebuilt');
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
2015-06-10 03:16:00 +03:00
var target = grunt.option('target') || 'development';
2015-06-10 09:17:49 +03:00
var beta = grunt.option('beta') || false;
2015-06-18 10:15:47 +03:00
var alpha = grunt.option('alpha') || false;
2015-06-10 03:16:00 +03:00
var env = process.env;
2015-06-12 09:32:13 +03:00
env.NODE_PATH = '..:' + env.NODE_PATH;
2015-06-10 03:16:00 +03:00
env.NODE_ENV = target;
2015-06-18 10:15:47 +03:00
var certificateFile = grunt.option('certificateFile');
var version = function (str) {
var match = str.match(/(\d+\.\d+\.\d+)/);
return match ? match[1] : null;
};
2015-06-18 10:15:47 +03:00
var BASENAME = 'Kitematic';
var OSX_APPNAME = BASENAME + ' (Beta)';
var WINDOWS_APPNAME = BASENAME + ' (Alpha)';
var OSX_OUT = './dist';
var OSX_OUT_X64 = OSX_OUT + '/' + OSX_APPNAME + '-darwin-x64';
var OSX_FILENAME = OSX_OUT_X64 + '/' + OSX_APPNAME + '.app';
2015-06-10 09:17:49 +03:00
grunt.initConfig({
2015-06-10 09:17:49 +03:00
IDENTITY: 'Developer ID Application: Docker Inc',
OSX_FILENAME: OSX_FILENAME,
OSX_FILENAME_ESCAPED: OSX_FILENAME.replace(/ /g, '\\ ').replace(/\(/g,'\\(').replace(/\)/g,'\\)'),
2015-06-10 08:27:27 +03:00
2015-06-10 03:16:00 +03:00
// electron
electron: {
windows: {
options: {
2015-06-18 21:38:34 +03:00
name: BASENAME,
2015-06-10 03:16:00 +03:00
dir: 'build/',
out: 'dist',
2015-06-10 03:16:00 +03:00
version: packagejson['electron-version'],
platform: 'win32',
arch: 'x64',
2015-06-12 09:32:13 +03:00
asar: true,
icon: 'util/kitematic.ico'
2015-06-10 03:16:00 +03:00
}
2015-06-10 03:56:08 +03:00
},
osx: {
options: {
name: OSX_APPNAME,
2015-06-10 03:56:08 +03:00
dir: 'build/',
out: 'dist',
2015-06-10 03:56:08 +03:00
version: packagejson['electron-version'],
platform: 'darwin',
arch: 'x64',
2015-06-10 07:54:11 +03:00
asar: true,
'app-bundle-id': 'com.kitematic.kitematic',
'app-version': packagejson.version
2015-06-10 03:56:08 +03:00
}
2015-06-10 03:16:00 +03:00
}
},
2015-06-16 08:06:47 +03:00
rcedit: {
exes: {
files: [{
expand: true,
cwd: 'dist/' + BASENAME + '-win32-x64',
2015-06-18 21:38:34 +03:00
src: [BASENAME + '.exe']
2015-06-16 08:06:47 +03:00
}],
options: {
2015-06-19 06:29:35 +03:00
icon: 'util/kitematic.ico',
2015-06-16 08:06:47 +03:00
'file-version': packagejson.version,
'product-version': packagejson.version,
'version-string': {
'CompanyName': 'Docker',
2015-06-16 08:06:47 +03:00
'ProductVersion': packagejson.version,
'ProductName': WINDOWS_APPNAME,
'FileDescription': WINDOWS_APPNAME,
2015-06-18 21:38:34 +03:00
'InternalName': BASENAME + '.exe',
'OriginalFilename': BASENAME + '.exe',
2015-06-16 08:06:47 +03:00
'LegalCopyright': 'Copyright 2015 Docker Inc. All rights reserved.'
}
}
}
},
// images
copy: {
2015-06-10 03:16:00 +03:00
dev: {
files: [{
expand: true,
cwd: '.',
2015-06-10 06:49:26 +03:00
src: ['package.json', 'settings.json', 'index.html'],
2015-06-10 03:16:00 +03:00
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
}]
},
2015-06-10 03:56:08 +03:00
windows: {
2015-06-10 03:16:00 +03:00
files: [{
expand: true,
cwd: 'resources',
src: ['ssh.exe', 'OPENSSH_LICENSE', 'msys-*'],
dest: 'dist/' + BASENAME + '-win32-x64/resources/resources'
2015-06-10 06:35:46 +03:00
}],
options: {
mode: true
}
2015-06-10 03:56:08 +03:00
},
osx: {
files: [{
expand: true,
cwd: 'resources',
src: ['terminal'],
2015-06-10 08:27:27 +03:00
dest: '<%= OSX_FILENAME %>/Contents/Resources/resources/'
2015-06-10 07:54:11 +03:00
}, {
src: 'util/kitematic.icns',
2015-06-10 08:27:27 +03:00
dest: '<%= OSX_FILENAME %>/Contents/Resources/atom.icns'
2015-06-10 06:35:46 +03:00
}],
options: {
mode: true
}
}
},
2015-06-12 09:32:13 +03:00
rename: {
installer: {
src: 'dist/Setup.exe',
dest: 'dist/' + BASENAME + 'Setup-' + packagejson.version + '-Windows-Alpha.exe'
2015-06-12 09:32:13 +03:00
}
},
// styles
less: {
options: {
sourceMapFileInline: true
},
2015-06-10 03:16:00 +03:00
dist: {
files: {
'build/main.css': 'styles/main.less'
}
}
},
// javascript
babel: {
options: {
sourceMap: 'inline',
2015-10-06 00:06:08 +03:00
blacklist: 'regenerator',
stage: 1,
optional: ['asyncToGenerator']
},
dist: {
files: [{
expand: true,
cwd: 'src/',
src: ['**/*.js'],
dest: 'build/',
}]
}
},
2015-06-10 03:16:00 +03:00
shell: {
electron: {
2015-06-10 03:56:08 +03:00
command: electron + ' ' + 'build',
2015-06-10 03:16:00 +03:00
options: {
async: true,
execOptions: {
env: env
}
}
2015-06-10 08:27:27 +03:00
},
sign: {
options: {
failOnError: false,
},
command: [
2015-06-10 09:17:49 +03:00
'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 %>'
2015-06-10 08:27:27 +03:00
].join(' && '),
2015-06-10 09:17:49 +03:00
},
zip: {
command: 'ditto -c -k --sequesterRsrc --keepParent <%= OSX_FILENAME_ESCAPED %> dist/' + BASENAME + '-' + packagejson.version + '-Mac.zip',
2015-06-10 03:16:00 +03:00
}
},
clean: {
2015-08-11 22:28:52 +03:00
release: ['build/', 'dist/'],
},
compress: {
windows: {
options: {
archive: './dist/' + BASENAME + '-' + packagejson.version + '-Windows-Alpha.zip',
2015-08-11 22:28:52 +03:00
mode: 'zip'
},
files: [{
expand: true,
dot: true,
cwd: './dist/Kitematic-win32-x64',
2015-08-11 22:28:52 +03:00
src: '**/*'
}]
},
2015-06-10 03:16:00 +03:00
},
// livereload
2015-06-10 03:16:00 +03:00
watchChokidar: {
options: {
2015-06-12 09:32:13 +03:00
spawn: true
},
2015-06-10 03:16:00 +03:00
livereload: {
options: {livereload: true},
files: ['build/**/*']
},
js: {
files: ['src/**/*.js'],
2015-06-12 09:32:13 +03:00
tasks: ['newer:babel']
},
less: {
files: ['styles/**/*.less'],
2015-06-16 20:07:56 +03:00
tasks: ['less']
},
copy: {
files: ['images/*', 'index.html', 'fonts/*'],
2015-06-12 09:32:13 +03:00
tasks: ['newer:copy:dev']
}
}
});
2015-06-10 06:35:46 +03:00
grunt.registerTask('default', ['newer:babel', 'less', 'newer:copy:dev', 'shell:electron', 'watchChokidar']);
grunt.registerTask('release', ['clean:release', 'babel', 'less', 'copy:dev', 'electron', 'copy:osx', 'shell:sign', 'shell:zip', 'copy:windows', 'rcedit:exes', 'compress']);
grunt.registerTask('release-mac', ['clean:release', 'babel', 'less', 'copy:dev', 'electron:osx', 'copy:osx', 'shell:sign', 'shell:zip']);
process.on('SIGINT', function () {
grunt.task.run(['shell:electron:kill']);
process.exit(1);
});
};