forked from angular/batarang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
110 lines (95 loc) · 2.97 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
var markdown = require('marked'),
semver = require('semver');
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('manifest.json'),
changelog: {
options: {
dest: 'CHANGELOG.md',
versionFile: 'manifest.json'
}
},
bump: {
options: {
file: 'manifest.json'
}
},
markdown: {
all: {
file: 'README.md',
dest: 'panes/help.html'
}
},
release: {
options: {
commitMessage: 'v<%= version %>',
tagName: 'v<%= version %>',
bump: false, // we have out own bump
npm: false,
file: 'manifest.json'
}
},
stage: {
files: ['CHANGELOG.md', 'pane/help.html']
},
zip: {
release: {
src: [
'css/*.css',
'img/**',
'js/**',
'panes/*.html',
'panel.html',
'LICENSE',
'manifest.json',
'background.html',
'devtoolsBackground.html'
],
dest: 'batarang-release-' + Date.now() + '.zip'
}
}
});
grunt.registerTask('bump', 'bump manifest version', function (type) {
var options = this.options({
file: grunt.config('pkgFile') || 'package.json'
});
function setup(file, type){
var pkg = grunt.file.readJSON(file);
var newVersion = pkg.version = semver.inc(pkg.version, type || 'patch');
return {file: file, pkg: pkg, newVersion: newVersion};
}
var config = setup(options.file, type);
grunt.file.write(config.file, JSON.stringify(config.pkg, null, ' ') + '\n');
grunt.log.ok('Version bumped to ' + config.newVersion);
});
grunt.registerMultiTask('markdown', 'compiles markdown README into html for the help pane', function() {
var md = grunt.file.read(this.data.file);
// pull out the install instructions, etc
var marker = '<!-- HELP TAB -->';
md = md.substr(md.indexOf(marker) + marker.length);
// fix image paths
md = md.replace(/https:\/\/github.com\/angular\/angularjs-batarang\/raw\/master\/img\//g, '/img/');
var html = markdown(md);
grunt.file.write(this.data.dest, html);
});
grunt.registerTask('stage', 'git add files before running the release task', function() {
grunt.util.spawn({
cmd: process.platform === 'win32' ?
'git.cmd' : 'git',
args: ['add'].append(this.data.files)
}, grunt.task.current.async());
});
grunt.registerTask('url', 'open the url for the chrome app dashboard', function() {
var url = 'https://chrome.google.com/webstore/developer/dashboard';
console.log('Publish to: ' + url);
grunt.util.spawn({
cmd: process.platform === 'win32' ?
'explorer' : 'open',
args: [ url ]
}, grunt.task.current.async());
});
grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-conventional-changelog');
grunt.registerTask('default', ['bump', 'markdown', 'changelog', 'release', 'zip']);
};