scratch – Blame information for rev 134

Subversion Repositories:
Rev:
Rev Author Line No. Line
134 office 1 module.exports = function (grunt) {
2  
3 var semver = require('semver'),
4 f = require('util').format;
5  
6 grunt.initConfig({
7 pkg: grunt.file.readJSON('package.json'),
8 version: '<%= pkg.version %>',
9  
10 banner: [
11 '/*!',
12 ' * bootstrap-tokenfield <%= version %>',
13 ' * https://github.com/sliptree/bootstrap-tokenfield',
14 ' * Copyright 2013-2014 Sliptree and other contributors; Licensed MIT',
15 ' */\n\n'
16 ].join('\n'),
17  
18 copy: {
19 dist: {
20 files: {
21 'dist/<%= pkg.name %>.js': 'js/<%= pkg.name %>.js'
22 }
23 },
24 assets: {
25 files: [{
26 expand: true,
27 flatten: true,
28 src: [
29 'bower_components/bootstrap/js/affix.js',
30 'bower_components/bootstrap/js/scrollspy.js',
31 'bower_components/typeahead.js/dist/typeahead.bundle.min.js'
32 ],
33 dest: 'docs-assets/js/'
34 }]
35 }
36 },
37  
38 uglify: {
39 options: {
40 banner: '<%= banner %>'
41 },
42 dist: {
43 files: {
44 'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.js'
45 }
46 },
47 docs: {
48 files: {
49 'docs-assets/js/docs.min.js': 'docs-assets/js/docs.js'
50 }
51 }
52 },
53  
54 less: {
55 compile: {
56 files: {
57 'dist/css/<%= pkg.name %>.css': 'less/<%= pkg.name %>.less',
58 'dist/css/tokenfield-typeahead.css': 'less/tokenfield-typeahead.less'
59 }
60 },
61 minify: {
62 options: {
63 cleancss: true,
64 report: 'min'
65 },
66 files: {
67 'dist/css/<%= pkg.name %>.min.css': 'dist/css/<%= pkg.name %>.css',
68 'dist/css/tokenfield-typeahead.min.css': 'dist/css/tokenfield-typeahead.css'
69 }
70 }
71 },
72  
73 jekyll: {
74 docs: {}
75 },
76  
77 watch: {
78 copy: {
79 files: 'js/**/*',
80 tasks: ['copy']
81 },
82 less: {
83 files: 'less/**/*',
84 tasks: ['less']
85 },
86 jekyll: {
87 files: ['dist/**/*', 'index.html', 'docs-assets/**/*'],
88 tasks: ['uglify:docs', 'jekyll']
89 },
90 livereload: {
91 options: { livereload: true },
92 files: ['dist/**/*'],
93 }
94 },
95  
96 exec: {
97 git_is_clean: {
98 cmd: 'test -z "$(git status --porcelain)"'
99 },
100 git_on_master: {
101 cmd: 'test $(git symbolic-ref --short -q HEAD) = master'
102 },
103 git_add: {
104 cmd: 'git add .'
105 },
106 git_commit: {
107 cmd: function(m) { return f('git commit -m "%s"', m); }
108 },
109 git_tag: {
110 cmd: function(v) { return f('git tag v%s -am "%s"', v, v); }
111 },
112 git_push: {
113 cmd: 'git push && git push --tags'
114 },
115 update_docs: {
116 cmd: [
117 'git checkout gh-pages',
118 'git reset master --hard',
119 'sed -i.bak \'s/%VERSION%/v<%= version %>/\' index.html',
120 'rm -rf index.html.bak',
121 'git add index.html',
122 'git commit -m "Update docs to <%= version %>"',
123 'git checkout master'
124 ].join(' && ')
125 },
126 npm_publish: {
127 cmd: 'npm publish'
128 }
129 }
130  
131 });
132  
133 grunt.loadNpmTasks('grunt-contrib-copy');
134 grunt.loadNpmTasks('grunt-contrib-uglify');
135 grunt.loadNpmTasks('grunt-contrib-less');
136 grunt.loadNpmTasks('grunt-contrib-watch');
137 grunt.loadNpmTasks('grunt-jekyll');
138 grunt.loadNpmTasks('grunt-sed');
139 grunt.loadNpmTasks('grunt-exec');
140  
141 grunt.registerTask('manifests', 'Update manifests.', function(version) {
142 var _ = grunt.util._,
143 pkg = grunt.file.readJSON('package.json'),
144 bower = grunt.file.readJSON('bower.json'),
145 jqueryPlugin = grunt.file.readJSON('bootstrap-tokenfield.jquery.json');
146  
147 bower = JSON.stringify(_.extend(bower, {
148 name: pkg.name,
149 version: version
150 }), null, 2);
151  
152 jqueryPlugin = JSON.stringify(_.extend(jqueryPlugin, {
153 name: pkg.name,
154 title: pkg.name,
155 version: version,
156 author: pkg.author,
157 description: pkg.description,
158 keywords: pkg.keywords,
159 homepage: pkg.homepage,
160 bugs: pkg.bugs,
161 maintainers: pkg.contributors
162 }), null, 2);
163  
164 pkg = JSON.stringify(_.extend(pkg, {
165 version: version
166 }), null, 2);
167  
168 grunt.file.write('package.json', pkg);
169 grunt.file.write('bower.json', bower);
170 grunt.file.write('bootstrap-tokenfield.jquery.json', jqueryPlugin);
171 });
172  
173 grunt.registerTask('release', 'Ship it.', function(version) {
174 var curVersion = grunt.config.get('version');
175  
176 version = semver.inc(curVersion, version) || version;
177  
178 if (!semver.valid(version) || semver.lte(version, curVersion)) {
179 grunt.fatal('invalid version dummy');
180 }
181  
182 grunt.config.set('version', version);
183  
184 grunt.task.run([
185 'exec:git_on_master',
186 'exec:git_is_clean',
187 'manifests:' + version,
188 'build',
189 'exec:git_add',
190 'exec:git_commit:' + version,
191 'exec:git_tag:' + version,
192 'exec:update_docs'
193 //'exec:git_push',
194 //'exec:npm_publish',
195 ]);
196 });
197  
198 // Build task
199 grunt.registerTask('build', ['copy', 'uglify', 'less']);
200 }