update bootstrap to 3.0.0-rc2
[bootswatch] / bower_components / bootstrap / Gruntfile.js
1 /* jshint node: true */
2
3 module.exports = function(grunt) {
4   "use strict";
5
6   // Project configuration.
7   grunt.initConfig({
8
9     // Metadata.
10     pkg: grunt.file.readJSON('package.json'),
11     banner: '/**\n' +
12               '* <%= pkg.name %>.js v<%= pkg.version %> by @fat and @mdo\n' +
13               '* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
14               '* <%= _.pluck(pkg.licenses, "url").join(", ") %>\n' +
15               '*/\n',
16     jqueryCheck: 'if (!jQuery) { throw new Error(\"Bootstrap requires jQuery\") }\n\n',
17
18     // Task configuration.
19     clean: {
20       dist: ['dist']
21     },
22
23     jshint: {
24       options: {
25         jshintrc: 'js/.jshintrc'
26       },
27       gruntfile: {
28         src: 'Gruntfile.js'
29       },
30       src: {
31         src: ['js/*.js']
32       },
33       test: {
34         src: ['js/tests/unit/*.js']
35       }
36     },
37
38     concat: {
39       options: {
40         banner: '<%= banner %><%= jqueryCheck %>',
41         stripBanners: false
42       },
43       bootstrap: {
44         src: [
45           'js/transition.js',
46           'js/alert.js',
47           'js/button.js',
48           'js/carousel.js',
49           'js/collapse.js',
50           'js/dropdown.js',
51           'js/modal.js',
52           'js/tooltip.js',
53           'js/popover.js',
54           'js/scrollspy.js',
55           'js/tab.js',
56           'js/affix.js'
57         ],
58         dest: 'dist/js/<%= pkg.name %>.js'
59       }
60     },
61
62     uglify: {
63       options: {
64         banner: '<%= banner %>'
65       },
66       bootstrap: {
67         src: ['<%= concat.bootstrap.dest %>'],
68         dest: 'dist/js/<%= pkg.name %>.min.js'
69       }
70     },
71
72     recess: {
73       options: {
74         compile: true
75       },
76       bootstrap: {
77         src: ['less/bootstrap.less'],
78         dest: 'dist/css/<%= pkg.name %>.css'
79       },
80       min: {
81         options: {
82           compress: true
83         },
84         src: ['less/bootstrap.less'],
85         dest: 'dist/css/<%= pkg.name %>.min.css'
86       }
87     },
88
89     qunit: {
90       options: {
91         inject: 'js/tests/unit/phantom.js'
92       },
93       files: ['js/tests/*.html']
94     },
95
96     connect: {
97       server: {
98         options: {
99           port: 3000,
100           base: '.'
101         }
102       }
103     },
104
105     jekyll: {
106       docs: {}
107     },
108
109     validation: {
110       options: {
111         reset: true,
112       },
113       files: {
114         src: ["_gh_pages/**/*.html"]
115       }
116     },
117
118     watch: {
119       src: {
120         files: '<%= jshint.src.src %>',
121         tasks: ['jshint:src', 'qunit']
122       },
123       test: {
124         files: '<%= jshint.test.src %>',
125         tasks: ['jshint:test', 'qunit']
126       },
127       recess: {
128         files: 'less/*.less',
129         tasks: ['recess']
130       }
131     }
132   });
133
134
135   // These plugins provide necessary tasks.
136   grunt.loadNpmTasks('grunt-contrib-clean');
137   grunt.loadNpmTasks('grunt-contrib-concat');
138   grunt.loadNpmTasks('grunt-contrib-connect');
139   grunt.loadNpmTasks('grunt-contrib-jshint');
140   grunt.loadNpmTasks('grunt-contrib-qunit');
141   grunt.loadNpmTasks('grunt-contrib-uglify');
142   grunt.loadNpmTasks('grunt-contrib-watch');
143   grunt.loadNpmTasks('grunt-html-validation');
144   grunt.loadNpmTasks('grunt-jekyll');
145   grunt.loadNpmTasks('grunt-recess');
146   grunt.loadNpmTasks('browserstack-runner');
147
148
149   // Docs HTML validation task
150   grunt.registerTask('validate-docs', ['jekyll', 'validation']);
151
152   // Test task.
153   var testSubtasks = ['jshint', 'qunit', 'validate-docs'];
154   // Only run BrowserStack tests under Travis
155   if (process.env.TRAVIS) {
156     // Only run BrowserStack tests if this is a mainline commit in twbs/bootstrap, or you have your own BrowserStack key
157     if ((process.env.TRAVIS_REPO_SLUG === 'twbs/bootstrap' && process.env.TRAVIS_PULL_REQUEST === 'false') || process.env.TWBS_HAVE_OWN_BROWSERSTACK_KEY) {
158       testSubtasks.push('browserstack_runner');
159     }
160   }
161   grunt.registerTask('test', testSubtasks);
162
163   // JS distribution task.
164   grunt.registerTask('dist-js', ['concat', 'uglify']);
165
166   // CSS distribution task.
167   grunt.registerTask('dist-css', ['recess']);
168
169   // Full distribution task.
170   grunt.registerTask('dist', ['clean', 'dist-css', 'dist-js']);
171
172   // Default task.
173   grunt.registerTask('default', ['test', 'dist']);
174
175   // task for building customizer
176   grunt.registerTask('build-customizer', 'Add scripts/less files to customizer.', function () {
177     var fs = require('fs')
178
179     function getFiles(type) {
180       var files = {}
181       fs.readdirSync(type)
182         .filter(function (path) {
183           return new RegExp('\\.' + type + '$').test(path)
184         })
185         .forEach(function (path) {
186           return files[path] = fs.readFileSync(type + '/' + path, 'utf8')
187         })
188       return 'var __' + type + ' = ' + JSON.stringify(files) + '\n'
189     }
190
191     var customize = fs.readFileSync('customize.html', 'utf-8')
192     var files = '<!-- generated -->\n<script id="files">\n' + getFiles('js') + getFiles('less') + '<\/script>\n<!-- /generated -->'
193     fs.writeFileSync('customize.html', customize.replace(/<!-- generated -->(.|[\n\r])*<!-- \/generated -->/, files))
194   });
195 };