keeweb/Gruntfile.js

797 lines
28 KiB
JavaScript
Raw Normal View History

2016-07-17 13:30:38 +02:00
/* eslint-env node */
2017-01-31 07:50:28 +01:00
const fs = require('fs');
const path = require('path');
2015-10-17 23:49:24 +02:00
2017-01-31 07:50:28 +01:00
const StringReplacePlugin = require('string-replace-webpack-plugin');
const StatsPlugin = require('stats-webpack-plugin');
2015-10-17 23:49:24 +02:00
module.exports = function(grunt) {
require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);
2015-11-07 08:55:45 +01:00
grunt.loadTasks('grunt/tasks');
2015-10-17 23:49:24 +02:00
2017-01-31 07:50:28 +01:00
const webpack = require('webpack');
const pkg = require('./package.json');
const dt = new Date().toISOString().replace(/T.*/, '');
2017-06-05 16:33:29 +02:00
const minElectronVersionForUpdate = '1.7.0';
2017-02-04 17:30:39 +01:00
const zipCommentPlaceholderPart = 'zip_comment_placeholder_that_will_be_replaced_with_hash';
const zipCommentPlaceholder = zipCommentPlaceholderPart + '.'.repeat(512 - zipCommentPlaceholderPart.length);
2017-01-31 07:50:28 +01:00
const electronVersion = pkg.devDependencies['electron'].replace(/^\D/, '');
2017-02-04 17:30:39 +01:00
const year = new Date().getFullYear();
2015-10-17 23:49:24 +02:00
function replaceFont(css) {
2016-07-17 13:30:38 +02:00
css.walkAtRules('font-face', rule => {
2017-01-31 07:50:28 +01:00
const fontFamily = rule.nodes.filter(n => n.prop === 'font-family')[0];
2015-10-17 23:49:24 +02:00
if (!fontFamily) {
throw 'Bad font rule: ' + rule.toString();
}
2017-01-31 07:50:28 +01:00
const value = fontFamily.value.replace(/["']/g, '');
const fontFiles = {
2015-10-17 23:49:24 +02:00
FontAwesome: 'fontawesome-webfont.woff'
};
2017-01-31 07:50:28 +01:00
const fontFile = fontFiles[value];
2015-10-17 23:49:24 +02:00
if (!fontFile) {
throw 'Unsupported font ' + value + ': ' + rule.toString();
}
2017-01-31 07:50:28 +01:00
const data = fs.readFileSync('tmp/fonts/' + fontFile, 'base64');
const src = 'url(data:application/font-woff;charset=utf-8;base64,{data}) format(\'woff\')'
2015-10-17 23:49:24 +02:00
.replace('{data}', data);
2016-07-17 13:30:38 +02:00
rule.nodes = rule.nodes.filter(n => n.prop !== 'src');
2015-10-17 23:49:24 +02:00
rule.append({ prop: 'src', value: src });
});
}
2017-01-31 07:50:28 +01:00
const webpackConfig = {
2016-07-16 13:36:15 +02:00
entry: {
app: 'app',
2017-04-16 17:00:35 +02:00
vendor: ['jquery', 'underscore', 'backbone', 'kdbxweb', 'baron', 'pikaday', 'filesaver', 'qrcode',
2017-02-04 14:17:33 +01:00
'argon2-asm', 'argon2-wasm', 'argon2']
2016-07-16 13:36:15 +02:00
},
output: {
2017-01-30 22:55:26 +01:00
path: path.resolve('.', 'tmp/js'),
2016-07-16 13:36:15 +02:00
filename: 'app.js'
},
stats: {
colors: false,
modules: true,
reasons: true
},
progress: false,
failOnError: true,
resolve: {
2017-01-30 22:55:26 +01:00
modules: [path.join(__dirname, 'app/scripts'), path.join(__dirname, 'bower_components')],
2016-07-16 13:36:15 +02:00
alias: {
backbone: 'backbone/backbone-min.js',
underscore: 'underscore/underscore-min.js',
_: 'underscore/underscore-min.js',
jquery: 'jquery/dist/jquery.min.js',
2017-01-30 22:55:26 +01:00
hbs: path.resolve(__dirname, 'node_modules', 'handlebars/runtime.js'),
2016-07-16 13:36:15 +02:00
kdbxweb: 'kdbxweb/dist/kdbxweb.js',
baron: 'baron/baron.min.js',
pikaday: 'pikaday/pikaday.js',
filesaver: 'FileSaver.js/FileSaver.min.js',
qrcode: 'jsqrcode/dist/qrcode.min.js',
2017-02-04 14:17:33 +01:00
'argon2-asm': 'argon2-browser/docs/dist/argon2-asm.min.js',
'argon2-wasm': 'argon2-browser/docs/dist/argon2.wasm',
'argon2': 'argon2-browser/docs/dist/argon2.min.js',
2016-07-16 13:36:15 +02:00
templates: path.join(__dirname, 'app/templates')
}
},
module: {
loaders: [
{ test: /\.hbs$/, loader: StringReplacePlugin.replace('handlebars-loader', { replacements: [{
pattern: /\r?\n\s*/g,
replacement: function() { return '\n'; }
}]})},
2017-01-28 23:13:39 +01:00
{ test: /runtime-info\.js$/, loader: StringReplacePlugin.replace({ replacements: [
2016-07-16 13:36:15 +02:00
{ pattern: /@@VERSION/g, replacement: function() { return pkg.version; } },
{ pattern: /@@DATE/g, replacement: function() { return dt; } },
{ pattern: /@@COMMIT/g, replacement: function() { return grunt.config.get('gitinfo.local.branch.current.shortSHA'); } }
]})},
2017-01-30 22:55:26 +01:00
{ test: /baron(\.min)?\.js$/, loader: 'exports-loader?baron; delete window.baron;' },
{ test: /pikaday\.js$/, loader: 'uglify-loader' },
2016-07-16 13:36:15 +02:00
{ test: /handlebars/, loader: 'strip-sourcemap-loader' },
2017-01-30 22:55:26 +01:00
{ test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: 'babel-loader',
2016-07-16 13:36:15 +02:00
query: { presets: ['es2015'], cacheDirectory: true }
2016-08-21 23:12:49 +02:00
},
2017-01-30 22:55:26 +01:00
{ test: /\.json$/, loader: 'json-loader' },
2017-02-04 14:17:33 +01:00
{ test: /argon2-asm\.min\.js$/, loader: 'raw-loader' },
{ test: /argon2\.wasm$/, loader: 'base64-loader' },
2017-04-27 12:02:41 +02:00
{ test: /argon2\.min\.js/, loader: 'raw-loader' },
{ test: /\.scss$/, loader: 'raw-loader' }
2016-07-16 13:36:15 +02:00
]
},
plugins: [
2017-01-30 22:55:26 +01:00
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', minChunks: Infinity, filename: 'vendor.js' }),
2017-02-04 17:30:39 +01:00
new webpack.BannerPlugin('keeweb v' + pkg.version + ', (c) ' + year + ' ' + pkg.author.name +
2016-07-16 13:36:15 +02:00
', opensource.org/licenses/' + pkg.license),
new webpack.ProvidePlugin({ _: 'underscore', $: 'jquery' }),
new webpack.IgnorePlugin(/^(moment)$/),
2016-09-23 21:12:02 +02:00
new StringReplacePlugin(),
new StatsPlugin('stats.json', { chunkModules: true })
2016-07-16 13:36:15 +02:00
],
node: {
console: false,
process: false,
2017-01-29 23:28:04 +01:00
crypto: false,
2016-07-16 13:36:15 +02:00
Buffer: false,
__filename: false,
2017-01-30 21:26:31 +01:00
__dirname: false,
2017-01-30 22:55:26 +01:00
fs: false,
2017-01-30 23:02:24 +01:00
setImmediate: false,
path: false
2016-07-16 13:36:15 +02:00
},
externals: {
2017-01-29 23:28:04 +01:00
xmldom: 'null',
2017-01-30 21:26:31 +01:00
crypto: 'null',
2017-01-30 23:02:24 +01:00
fs: 'null',
path: 'null'
2016-07-16 13:36:15 +02:00
}
};
2015-10-17 23:49:24 +02:00
grunt.initConfig({
2015-11-07 08:55:45 +01:00
gitinfo: {
branch: {
current: {
SHA: 'Current HEAD SHA',
shortSHA: 'Current HEAD short SHA',
name: 'Current branch name',
lastCommitTime: 'Last commit time'
}
}
},
2015-10-17 23:49:24 +02:00
'bower-install-simple': {
install: {
}
},
clean: {
2015-11-07 08:55:45 +01:00
dist: ['dist', 'tmp'],
2017-02-05 11:08:26 +01:00
desktop: ['tmp/desktop', 'dist/desktop'],
cordova: ['tmp/cordova', 'dist/cordova']
2015-10-17 23:49:24 +02:00
},
copy: {
html: {
src: 'app/index.html',
dest: 'tmp/index.html',
nonull: true
},
favicon: {
src: 'app/favicon.png',
dest: 'tmp/favicon.png',
nonull: true
},
2017-11-11 19:40:07 +01:00
icons: {
cwd: 'app/icons/',
src: ['*.png', '*.svg'],
dest: 'tmp/icons/',
expand: true,
nonull: true
},
'dist-icons': {
cwd: 'app/icons/',
src: ['*.png', '*.svg'],
dest: 'dist/icons/',
expand: true,
2016-02-07 14:08:37 +01:00
nonull: true
},
2015-10-17 23:49:24 +02:00
fonts: {
src: 'bower_components/font-awesome/fonts/fontawesome-webfont.*',
dest: 'tmp/fonts/',
nonull: true,
expand: true,
flatten: true
2015-11-07 08:55:45 +01:00
},
2016-07-16 18:39:52 +02:00
'desktop-app-content': {
2017-01-28 23:13:39 +01:00
cwd: 'desktop/',
2017-06-11 11:37:09 +02:00
src: ['**', '!package-lock.json'],
2015-11-14 09:39:22 +01:00
dest: 'tmp/desktop/app/',
expand: true,
nonull: true
},
2017-05-27 23:25:38 +02:00
'desktop-update': {
cwd: 'tmp/desktop/app/',
2017-06-11 11:37:09 +02:00
src: ['**', '!package-lock.json'],
2017-05-27 23:25:38 +02:00
dest: 'tmp/desktop/update/',
expand: true,
nonull: true
},
'desktop-update-helper': {
src: ['helper/darwin/KeeWebHelper', 'helper/win32/KeeWebHelper.exe'],
dest: 'tmp/desktop/update/',
nonull: true
},
2016-07-16 18:39:52 +02:00
'desktop-windows-helper-ia32': {
2016-08-09 04:59:44 +02:00
src: 'helper/win32/KeeWebHelper.exe',
2016-08-08 21:53:59 +02:00
dest: 'tmp/desktop/KeeWeb-win32-ia32/resources/app/',
2015-11-07 08:55:45 +01:00
nonull: true
2016-03-01 20:06:23 +01:00
},
2016-07-16 18:39:52 +02:00
'desktop-windows-helper-x64': {
2016-08-09 04:59:44 +02:00
src: 'helper/win32/KeeWebHelper.exe',
2016-08-08 21:53:59 +02:00
dest: 'tmp/desktop/KeeWeb-win32-x64/resources/app/',
nonull: true
},
'desktop-darwin-helper-x64': {
2016-08-09 04:59:44 +02:00
src: 'helper/darwin/KeeWebHelper',
2016-08-12 20:11:46 +02:00
dest: 'tmp/desktop/KeeWeb-darwin-x64/KeeWeb.app/Contents/Resources/app/',
2016-08-12 20:21:32 +02:00
nonull: true,
2016-08-12 20:30:47 +02:00
options: { mode: '0755' }
2016-07-21 22:54:03 +02:00
},
'desktop-darwin-installer': {
cwd: 'package/osx/KeeWeb Installer.app',
dest: 'tmp/desktop/KeeWeb-darwin-x64/KeeWeb.app/Contents/Helpers/KeeWeb Installer.app',
src: '**',
expand: true,
nonull: true,
options: { mode: true }
},
2016-07-22 21:13:39 +02:00
'desktop-win32-dist-x64': {
src: 'tmp/desktop/KeeWeb.win.x64.exe',
dest: `dist/desktop/KeeWeb-${pkg.version}.win.x64.exe`,
nonull: true
},
'desktop-win32-dist-ia32': {
src: 'tmp/desktop/KeeWeb.win.ia32.exe',
dest: `dist/desktop/KeeWeb-${pkg.version}.win.ia32.exe`,
2016-07-21 22:54:03 +02:00
nonull: true
2015-10-17 23:49:24 +02:00
}
},
2016-07-17 13:30:38 +02:00
eslint: {
app: ['app/scripts/**/*.js'],
2017-01-28 23:13:39 +01:00
desktop: ['desktop/**/*.js', '!desktop/node_modules/**'],
2016-07-17 13:30:38 +02:00
grunt: ['Gruntfile.js', 'grunt/**/*.js']
2015-10-17 23:49:24 +02:00
},
sass: {
options: {
sourceMap: false,
includePaths: ['./bower_components']
},
dist: {
files: {
'tmp/css/main.css': 'app/styles/main.scss'
}
}
},
postcss: {
options: {
processors: [
replaceFont,
require('cssnano')({discardComments: {removeAll: true}})
]
},
dist: {
src: 'tmp/css/main.css',
dest: 'tmp/css/main.css'
}
},
inline: {
app: {
src: 'tmp/index.html',
dest: 'tmp/app.html'
}
},
htmlmin: {
options: {
removeComments: true,
collapseWhitespace: true
},
app: {
files: {
2015-10-17 23:53:17 +02:00
'dist/index.html': 'tmp/app.html'
2015-10-17 23:49:24 +02:00
}
}
},
2015-10-21 23:02:17 +02:00
'string-replace': {
manifest: {
options: {
2015-11-14 09:39:22 +01:00
replacements: [
2016-01-17 21:34:40 +01:00
{ pattern: '# YYYY-MM-DD:v0.0.0', replacement: '# ' + dt + ':v' + pkg.version },
2016-02-03 21:44:18 +01:00
{ pattern: '# updmin:v0.0.0', replacement: '# updmin:v' + minElectronVersionForUpdate }
2015-11-14 09:39:22 +01:00
]
2015-10-21 23:02:17 +02:00
},
files: { 'dist/manifest.appcache': 'app/manifest.appcache' }
2015-11-14 09:39:22 +01:00
},
2016-07-16 18:39:52 +02:00
'manifest-html': {
2015-12-06 21:32:41 +01:00
options: { replacements: [{ pattern: '<html', replacement: '<html manifest="manifest.appcache"' }] },
files: { 'dist/index.html': 'dist/index.html' }
},
2016-07-16 18:39:52 +02:00
'desktop-html': {
2015-11-14 09:39:22 +01:00
options: { replacements: [{ pattern: ' manifest="manifest.appcache"', replacement: '' }] },
files: { 'tmp/desktop/app/index.html': 'dist/index.html' }
2017-02-05 11:08:26 +01:00
},
'desktop-public-key': {
options: { replacements: [{ pattern: '\'PUBLIC_KEY_CONTENT\'', replacement:
2017-06-05 13:55:31 +02:00
'`' + fs.readFileSync('app/resources/public-key.pem', {encoding: 'utf8'}).trim() + '`' }] },
files: { 'tmp/desktop/app/main.js': 'desktop/main.js' }
},
2017-02-05 11:08:26 +01:00
'cordova-html': {
options: { replacements: [{ pattern: '<script', replacement: '<script src="cordova.js"></script><script' }] },
files: { 'tmp/cordova/app/index.html': 'dist/index.html' }
2015-10-21 23:02:17 +02:00
}
},
2015-10-17 23:49:24 +02:00
webpack: {
2016-07-16 13:36:15 +02:00
js: webpackConfig
},
'webpack-dev-server': {
options: {
webpack: webpackConfig,
publicPath: '/tmp/js',
progress: false
},
2015-10-17 23:49:24 +02:00
js: {
2017-01-30 22:55:26 +01:00
keepalive: true,
2016-07-16 13:36:15 +02:00
webpack: {
devtool: 'source-map'
2016-04-23 17:01:56 +02:00
},
2016-07-16 13:36:15 +02:00
port: 8085
2015-10-17 23:49:24 +02:00
}
},
uglify: {
options: {
preserveComments: false
},
app: {
files: { 'tmp/js/app.js': ['tmp/js/app.js'] }
},
vendor: {
options: {
mangle: false,
compress: false
},
files: { 'tmp/js/vendor.js': ['tmp/js/vendor.js'] }
}
},
watch: {
options: {
interrupt: true,
debounceDelay: 500
},
styles: {
files: 'app/styles/**/*.scss',
tasks: ['sass']
},
indexhtml: {
files: 'app/index.html',
tasks: ['copy:html']
}
2015-11-07 08:55:45 +01:00
},
electron: {
options: {
name: 'KeeWeb',
2015-11-14 09:39:22 +01:00
dir: 'tmp/desktop/app',
2015-11-07 08:55:45 +01:00
out: 'tmp/desktop',
2017-02-03 23:01:49 +01:00
electronVersion: electronVersion,
2015-11-07 08:55:45 +01:00
overwrite: true,
2017-12-02 15:34:36 +01:00
'appCopyright': `Copyright © ${year} Antelle`,
'appVersion': pkg.version,
'buildVersion': '<%= gitinfo.local.branch.current.shortSHA %>'
2015-11-07 08:55:45 +01:00
},
2016-07-16 18:39:52 +02:00
linux: {
2015-11-07 08:55:45 +01:00
options: {
platform: 'linux',
2016-07-16 18:39:52 +02:00
arch: ['x64', 'ia32'],
2016-07-16 18:49:19 +02:00
icon: 'graphics/icon.ico'
2015-11-07 08:55:45 +01:00
}
},
2016-07-16 18:39:52 +02:00
darwin: {
2016-03-01 20:06:23 +01:00
options: {
2016-07-16 18:39:52 +02:00
platform: 'darwin',
arch: ['x64'],
icon: 'graphics/icon.icns',
2017-12-02 15:34:36 +01:00
'appBundleId': 'net.antelle.keeweb',
'appCategoryType': 'public.app-category.productivity',
'extendInfo': 'package/osx/extend.plist'
2016-03-01 20:06:23 +01:00
}
2015-11-07 08:55:45 +01:00
},
2016-07-16 18:39:52 +02:00
win32: {
2015-11-07 08:55:45 +01:00
options: {
2016-07-16 18:39:52 +02:00
platform: 'win32',
arch: ['ia32', 'x64'],
2016-07-16 18:49:19 +02:00
icon: 'graphics/icon.ico',
2017-12-02 15:39:11 +01:00
'buildVersion': pkg.version,
2016-07-16 19:09:06 +02:00
'version-string': {
'CompanyName': 'KeeWeb',
2016-07-16 19:09:55 +02:00
'FileDescription': pkg.description,
2016-07-16 19:09:06 +02:00
'OriginalFilename': 'KeeWeb.exe',
'ProductName': 'KeeWeb',
'InternalName': 'KeeWeb'
}
2015-11-07 08:55:45 +01:00
}
}
},
2017-04-27 21:28:28 +02:00
codesign: {
app: {
options: {
identity: 'app',
deep: true
},
src: ['tmp/desktop/KeeWeb-darwin-x64/KeeWeb.app']
},
dmg: {
options: {
identity: 'app'
},
src: [`dist/desktop/KeeWeb-${pkg.version}.mac.dmg`]
}
},
2015-11-07 08:55:45 +01:00
compress: {
2016-07-16 18:39:52 +02:00
options: {
level: 6
},
'desktop-update': {
options: { archive: 'dist/desktop/UpdateDesktop.zip', comment: zipCommentPlaceholder },
2016-09-01 19:24:11 +02:00
files: [
2017-05-27 23:25:38 +02:00
{ cwd: 'tmp/desktop/update', src: '**', expand: true, nonull: true }
2016-09-01 19:24:11 +02:00
]
2016-07-16 18:39:52 +02:00
},
'win32-x64': {
2016-07-22 21:13:39 +02:00
options: { archive: `dist/desktop/KeeWeb-${pkg.version}.win.x64.zip` },
2016-07-16 18:39:52 +02:00
files: [{ cwd: 'tmp/desktop/KeeWeb-win32-x64', src: '**', expand: true }]
},
'win32-ia32': {
2016-07-22 21:13:39 +02:00
options: { archive: `dist/desktop/KeeWeb-${pkg.version}.win.ia32.zip` },
2016-07-16 18:39:52 +02:00
files: [{ cwd: 'tmp/desktop/KeeWeb-win32-ia32', src: '**', expand: true }]
},
'linux-x64': {
2016-07-22 21:13:39 +02:00
options: { archive: `dist/desktop/KeeWeb-${pkg.version}.linux.x64.zip` },
2015-11-07 08:55:45 +01:00
files: [{ cwd: 'tmp/desktop/KeeWeb-linux-x64', src: '**', expand: true }]
2015-11-14 12:09:36 +01:00
},
2016-07-16 18:39:52 +02:00
'linux-ia32': {
2016-07-22 21:13:39 +02:00
options: { archive: `dist/desktop/KeeWeb-${pkg.version}.linux.ia32.zip` },
2016-03-01 20:06:23 +01:00
files: [{ cwd: 'tmp/desktop/KeeWeb-linux-ia32', src: '**', expand: true }]
2016-07-16 18:39:52 +02:00
}
},
appdmg: {
options: {
title: 'KeeWeb',
icon: 'graphics/icon.icns',
background: 'graphics/background.png',
'background-color': '#E0E6F9',
'icon-size': 80,
window: { size: { width: 658, height: 498 } },
contents: [
{ x: 438, y: 344, type: 'link', path: '/Applications' },
{ x: 192, y: 344, type: 'file', path: 'tmp/desktop/KeeWeb-darwin-x64/KeeWeb.app' }
]
2016-03-01 20:06:23 +01:00
},
2016-07-16 18:39:52 +02:00
app: {
2016-07-22 21:13:39 +02:00
dest: `dist/desktop/KeeWeb-${pkg.version}.mac.dmg`
2015-11-07 08:55:45 +01:00
}
2015-11-14 16:47:51 +01:00
},
2016-07-16 20:35:16 +02:00
nsis: {
options: {
vars: {
version: pkg.version,
rev: function() { return grunt.config.get('gitinfo.local.branch.current.shortSHA'); },
homepage: pkg.homepage
}
},
'win32-x64': {
options: {
2016-07-22 21:13:39 +02:00
installScript: 'package/nsis/main.nsi',
2016-07-17 11:13:14 +02:00
arch: 'x64',
2016-07-21 22:54:03 +02:00
output: 'tmp/desktop/KeeWeb.win.x64.exe'
2016-07-16 20:35:16 +02:00
}
},
2016-07-22 21:13:39 +02:00
'win32-un-x64': {
options: {
installScript: 'package/nsis/main-un.nsi',
arch: 'x64',
output: 'tmp/desktop/KeeWeb-win32-x64/uninst.exe'
}
},
2016-07-16 20:35:16 +02:00
'win32-ia32': {
options: {
2016-07-22 21:13:39 +02:00
installScript: 'package/nsis/main.nsi',
2016-07-17 11:13:14 +02:00
arch: 'ia32',
2016-07-21 22:54:03 +02:00
output: 'tmp/desktop/KeeWeb.win.ia32.exe'
2016-07-16 20:35:16 +02:00
}
2016-07-22 21:13:39 +02:00
},
'win32-un-ia32': {
options: {
installScript: 'package/nsis/main-un.nsi',
arch: 'ia32',
output: 'tmp/desktop/KeeWeb-win32-ia32/uninst.exe'
}
2016-07-16 20:35:16 +02:00
}
},
2016-04-02 13:21:07 +02:00
deb: {
2017-05-12 20:58:53 +02:00
options: {
tmpPath: 'tmp/desktop/',
package: {
name: 'keeweb-desktop',
version: pkg.version,
description: pkg.description,
author: pkg.author,
homepage: pkg.homepage,
rev: function() { return grunt.config.get('gitinfo.local.branch.current.shortSHA'); }
}
},
2016-07-16 18:39:52 +02:00
'linux-x64': {
2016-04-02 13:21:07 +02:00
options: {
info: {
arch: 'amd64',
2017-05-20 20:13:18 +02:00
pkgName: `KeeWeb-${pkg.version}.linux.x64.deb`,
targetDir: 'dist/desktop',
appName: 'KeeWeb',
depends: 'libappindicator1, libgconf2-4',
scripts: {
postinst: 'package/deb/scripts/postinst'
}
2016-04-02 13:21:07 +02:00
}
},
files: [
2017-05-12 20:58:53 +02:00
{ cwd: 'package/deb/usr', src: '**', dest: '/usr', expand: true, nonull: true },
{ cwd: 'tmp/desktop/KeeWeb-linux-x64/', src: '**', dest: '/opt/keeweb-desktop', expand: true, nonull: true },
{ src: 'graphics/128x128.png', dest: '/usr/share/icons/hicolor/128x128/apps/keeweb.png', nonull: true }
]
},
'linux-ia32': {
options: {
info: {
arch: 'i386',
2017-05-20 20:13:18 +02:00
pkgName: `KeeWeb-${pkg.version}.linux.ia32.deb`,
targetDir: 'dist/desktop',
appName: 'KeeWeb',
depends: 'libappindicator1, libgconf2-4',
scripts: {
postinst: 'package/deb/scripts/postinst'
}
2017-05-12 20:58:53 +02:00
}
},
files: [
{ cwd: 'package/deb/usr', src: '**', dest: '/usr', expand: true, nonull: true },
{ cwd: 'tmp/desktop/KeeWeb-linux-ia32/', src: '**', dest: '/opt/keeweb-desktop', expand: true, nonull: true },
{ src: 'graphics/128x128.png', dest: '/usr/share/icons/hicolor/128x128/apps/keeweb.png', nonull: true }
]
2016-04-02 13:21:07 +02:00
}
},
2016-03-05 12:16:12 +01:00
'sign-archive': {
2016-07-16 18:39:52 +02:00
'desktop-update': {
2016-03-05 12:16:12 +01:00
options: {
file: 'dist/desktop/UpdateDesktop.zip',
2017-06-11 11:37:09 +02:00
signature: zipCommentPlaceholder
2016-03-05 12:16:12 +01:00
}
}
},
2017-05-27 23:25:38 +02:00
'sign-desktop-files': {
'desktop-update': {
options: {
2017-06-11 11:37:09 +02:00
path: 'tmp/desktop/update'
2017-05-27 23:25:38 +02:00
}
}
},
2015-11-14 16:47:51 +01:00
'validate-desktop-update': {
desktop: {
options: {
file: 'dist/desktop/UpdateDesktop.zip',
2016-09-01 19:24:11 +02:00
expected: [
2016-09-01 20:08:35 +02:00
'main.js', 'app.js', 'index.html', 'package.json', 'icon.png',
2016-09-01 19:24:11 +02:00
'node_modules/node-stream-zip/node_stream_zip.js',
'helper/darwin/KeeWebHelper',
'helper/win32/KeeWebHelper.exe'
],
2017-05-27 23:25:38 +02:00
expectedCount: 16,
2016-03-05 12:45:37 +01:00
publicKey: 'app/resources/public-key.pem'
2015-11-14 16:47:51 +01:00
}
}
2016-04-02 22:44:53 +02:00
},
'sign-html': {
'app': {
options: {
file: 'dist/index.html',
2017-06-11 11:37:09 +02:00
skip: grunt.option('skip-sign')
2016-04-02 22:44:53 +02:00
}
}
2016-07-16 13:36:15 +02:00
},
2016-07-20 19:05:39 +02:00
'sign-exe': {
2016-07-21 22:54:03 +02:00
options: {
2017-07-04 22:34:19 +02:00
spc: 'keys/keeweb.spc',
2017-07-04 23:32:32 +02:00
key: '01',
2017-06-11 23:29:43 +02:00
algo: 'sha256',
2017-07-04 23:05:05 +02:00
url: pkg.homepage
2016-07-21 22:54:03 +02:00
},
2016-07-22 21:13:39 +02:00
'win32-build-x64': {
options: {
files: {
'tmp/desktop/KeeWeb-win32-x64/KeeWeb.exe': 'KeeWeb',
'tmp/desktop/KeeWeb-win32-x64/ffmpeg.dll': '',
'tmp/desktop/KeeWeb-win32-x64/libEGL.dll': 'ANGLE libEGL Dynamic Link Library',
'tmp/desktop/KeeWeb-win32-x64/libGLESv2.dll': 'ANGLE libGLESv2 Dynamic Link Library',
'tmp/desktop/KeeWeb-win32-x64/node.dll': 'Node.js'
}
}
},
'win32-build-ia32': {
options: {
files: {
'tmp/desktop/KeeWeb-win32-ia32/KeeWeb.exe': 'KeeWeb',
'tmp/desktop/KeeWeb-win32-ia32/ffmpeg.dll': '',
'tmp/desktop/KeeWeb-win32-ia32/libEGL.dll': 'ANGLE libEGL Dynamic Link Library',
'tmp/desktop/KeeWeb-win32-ia32/libGLESv2.dll': 'ANGLE libGLESv2 Dynamic Link Library',
'tmp/desktop/KeeWeb-win32-ia32/node.dll': 'Node.js'
}
}
},
'win32-uninst-x64': {
options: {
files: {
'tmp/desktop/KeeWeb-win32-x64/uninst.exe': 'KeeWeb Uninstaller'
}
}
},
'win32-uninst-ia32': {
options: {
files: {
'tmp/desktop/KeeWeb-win32-ia32/uninst.exe': 'KeeWeb Uninstaller'
}
}
},
2016-07-21 22:54:03 +02:00
'win32-installer-x64': {
options: {
2016-07-22 21:13:39 +02:00
files: {
'tmp/desktop/KeeWeb.win.x64.exe': 'KeeWeb Setup'
}
2016-07-21 22:54:03 +02:00
}
},
'win32-installer-ia32': {
2016-07-20 19:05:39 +02:00
options: {
2016-07-22 21:13:39 +02:00
files: {
'tmp/desktop/KeeWeb.win.ia32.exe': 'KeeWeb Setup'
}
2016-07-20 19:05:39 +02:00
}
}
2016-07-20 19:32:21 +02:00
},
2016-07-16 13:36:15 +02:00
'concurrent': {
options: {
2016-07-17 13:30:38 +02:00
logConcurrentOutput: true
2016-07-16 13:36:15 +02:00
},
'dev-server': [
2016-07-17 15:44:13 +02:00
'watch:styles',
2016-07-16 13:36:15 +02:00
'webpack-dev-server'
]
2017-05-12 20:37:27 +02:00
},
'sign-dist': {
'dist': {
options: {
2017-06-11 11:37:09 +02:00
sign: 'dist/desktop/Verify.sign.sha256'
2017-05-12 20:37:27 +02:00
},
files: {
'dist/desktop/Verify.sha256': ['dist/desktop/KeeWeb-*', 'dist/desktop/UpdateDesktop.zip']
}
}
2015-10-17 23:49:24 +02:00
}
});
2016-07-16 18:39:52 +02:00
// compound builder tasks
grunt.registerTask('build-web-app', [
2015-11-14 09:39:22 +01:00
'gitinfo',
2015-10-17 23:49:24 +02:00
'bower-install-simple',
'clean',
2016-07-17 13:30:38 +02:00
'eslint',
2015-10-17 23:49:24 +02:00
'copy:html',
'copy:favicon',
2017-11-11 19:40:07 +01:00
'copy:icons',
2015-10-17 23:49:24 +02:00
'copy:fonts',
'webpack',
'uglify',
'sass',
'postcss',
'inline',
2015-10-21 23:02:17 +02:00
'htmlmin',
2016-07-16 18:39:52 +02:00
'string-replace:manifest-html',
2016-04-02 22:44:53 +02:00
'string-replace:manifest',
2017-11-11 19:40:07 +01:00
'copy:dist-icons',
2016-04-02 22:44:53 +02:00
'sign-html'
2015-10-17 23:49:24 +02:00
]);
2015-11-07 08:55:45 +01:00
2016-07-16 18:39:52 +02:00
grunt.registerTask('build-desktop-app-content', [
'copy:desktop-app-content',
'string-replace:desktop-public-key',
2016-07-17 13:30:38 +02:00
'string-replace:desktop-html'
2016-07-16 13:36:15 +02:00
]);
2016-07-16 18:39:52 +02:00
grunt.registerTask('build-desktop-update', [
2017-05-27 23:25:38 +02:00
'copy:desktop-update',
'copy:desktop-update-helper',
'sign-desktop-files:desktop-update',
2016-07-16 18:39:52 +02:00
'compress:desktop-update',
'sign-archive:desktop-update',
2016-07-17 13:30:38 +02:00
'validate-desktop-update'
2016-07-16 18:39:52 +02:00
]);
grunt.registerTask('build-desktop-executables', [
2015-11-07 08:55:45 +01:00
'electron',
2016-07-22 21:13:39 +02:00
'sign-exe:win32-build-x64',
'sign-exe:win32-build-ia32',
2016-08-08 21:53:59 +02:00
'copy:desktop-darwin-helper-x64',
'copy:desktop-darwin-installer',
2016-07-16 18:39:52 +02:00
'copy:desktop-windows-helper-ia32',
2017-05-21 10:00:40 +02:00
'copy:desktop-windows-helper-x64',
'codesign:app'
2016-07-16 18:39:52 +02:00
]);
grunt.registerTask('build-desktop-archives', [
'compress:win32-x64',
'compress:win32-ia32',
'compress:linux-x64',
2016-07-17 13:30:38 +02:00
'compress:linux-ia32'
2016-07-16 18:39:52 +02:00
]);
grunt.registerTask('build-desktop-dist-darwin', [
2017-04-27 21:28:28 +02:00
'appdmg',
'codesign:dmg'
2016-07-16 18:39:52 +02:00
]);
grunt.registerTask('build-desktop-dist-win32', [
2016-07-22 21:13:39 +02:00
'nsis:win32-un-x64',
'nsis:win32-un-ia32',
'sign-exe:win32-uninst-x64',
'sign-exe:win32-uninst-ia32',
2016-07-16 20:35:16 +02:00
'nsis:win32-x64',
2016-07-21 22:54:03 +02:00
'nsis:win32-ia32',
'sign-exe:win32-installer-x64',
'sign-exe:win32-installer-ia32',
2016-07-22 21:13:39 +02:00
'copy:desktop-win32-dist-x64',
'copy:desktop-win32-dist-ia32'
2016-07-16 18:39:52 +02:00
]);
grunt.registerTask('build-desktop-dist-linux', [
2017-05-12 20:58:53 +02:00
'deb:linux-x64',
'deb:linux-ia32'
2016-07-16 18:39:52 +02:00
]);
grunt.registerTask('build-desktop-dist', [
'build-desktop-dist-darwin',
'build-desktop-dist-win32',
'build-desktop-dist-linux'
]);
grunt.registerTask('build-desktop', [
'gitinfo',
'clean:desktop',
'build-desktop-app-content',
'build-desktop-update',
'build-desktop-executables',
'build-desktop-archives',
2017-05-12 20:37:27 +02:00
'build-desktop-dist',
'sign-dist'
2016-07-16 18:39:52 +02:00
]);
2017-02-05 11:08:26 +01:00
grunt.registerTask('build-cordova-app-content', [
'string-replace:cordova-html'
]);
grunt.registerTask('build-cordova', [
'gitinfo',
'clean:cordova',
'build-cordova-app-content'
]);
2016-07-16 18:39:52 +02:00
// entry point tasks
grunt.registerTask('default', 'Default: build web app', [
'build-web-app'
]);
2016-09-18 12:30:09 +02:00
grunt.registerTask('dev', 'Build project and start web server and watcher', [
'build-web-app',
'devsrv'
]);
grunt.registerTask('devsrv', 'Start web server and watcher', [
2016-07-16 18:39:52 +02:00
'concurrent:dev-server'
2015-11-07 08:55:45 +01:00
]);
2016-07-16 13:36:15 +02:00
2016-07-16 18:39:52 +02:00
grunt.registerTask('desktop', 'Build web and desktop apps for all platforms', [
2016-07-16 13:36:15 +02:00
'default',
'build-desktop'
]);
2017-02-05 11:08:26 +01:00
grunt.registerTask('cordova', 'Build cordova app', [
'default',
'build-cordova'
]);
2015-10-17 23:49:24 +02:00
};