remove unused build-responsive.less
[bootswatch] / bower_components / bootstrap / Gruntfile.js
1 /* jshint node: true */
2
3 module.exports = function(grunt) {
4   "use strict";
5
6   RegExp.quote = require('regexp-quote')
7   var btoa = require('btoa')
8   // Project configuration.
9   grunt.initConfig({
10
11     // Metadata.
12     pkg: grunt.file.readJSON('package.json'),
13     banner: '/*!\n' +
14               ' * Bootstrap v<%= pkg.version %> by @fat and @mdo\n' +
15               ' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
16               ' * Licensed under <%= _.pluck(pkg.licenses, "url").join(", ") %>\n' +
17               ' *\n' +
18               ' * Designed and built with all the love in the world by @mdo and @fat.\n' +
19               ' */\n\n',
20     jqueryCheck: 'if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery") }\n\n',
21
22     // Task configuration.
23     clean: {
24       dist: ['dist']
25     },
26
27     jshint: {
28       options: {
29         jshintrc: 'js/.jshintrc'
30       },
31       gruntfile: {
32         src: 'Gruntfile.js'
33       },
34       src: {
35         src: ['js/*.js']
36       },
37       test: {
38         src: ['js/tests/unit/*.js']
39       }
40     },
41
42     concat: {
43       options: {
44         banner: '<%= banner %><%= jqueryCheck %>',
45         stripBanners: false
46       },
47       bootstrap: {
48         src: [
49           'js/transition.js',
50           'js/alert.js',
51           'js/button.js',
52           'js/carousel.js',
53           'js/collapse.js',
54           'js/dropdown.js',
55           'js/modal.js',
56           'js/tooltip.js',
57           'js/popover.js',
58           'js/scrollspy.js',
59           'js/tab.js',
60           'js/affix.js'
61         ],
62         dest: 'dist/js/<%= pkg.name %>.js'
63       }
64     },
65
66     uglify: {
67       options: {
68         banner: '<%= banner %>',
69         report: 'min'
70       },
71       bootstrap: {
72         src: ['<%= concat.bootstrap.dest %>'],
73         dest: 'dist/js/<%= pkg.name %>.min.js'
74       }
75     },
76
77     recess: {
78       options: {
79         compile: true,
80         banner: '<%= banner %>'
81       },
82       bootstrap: {
83         src: ['less/bootstrap.less'],
84         dest: 'dist/css/<%= pkg.name %>.css'
85       },
86       min: {
87         options: {
88           compress: true
89         },
90         src: ['less/bootstrap.less'],
91         dest: 'dist/css/<%= pkg.name %>.min.css'
92       },
93       theme: {
94         src: ['less/theme.less'],
95         dest: 'dist/css/<%= pkg.name %>-theme.css'
96       },
97       theme_min: {
98         options: {
99           compress: true
100         },
101         src: ['less/theme.less'],
102         dest: 'dist/css/<%= pkg.name %>-theme.min.css'
103       }
104     },
105
106     copy: {
107       fonts: {
108         expand: true,
109         src: ["fonts/*"],
110         dest: 'dist/'
111       }
112     },
113
114     qunit: {
115       options: {
116         inject: 'js/tests/unit/phantom.js'
117       },
118       files: ['js/tests/*.html']
119     },
120
121     connect: {
122       server: {
123         options: {
124           port: 3000,
125           base: '.'
126         }
127       }
128     },
129
130     jekyll: {
131       docs: {}
132     },
133
134     validation: {
135       options: {
136         reset: true,
137         relaxerror: [
138             "Bad value X-UA-Compatible for attribute http-equiv on element meta.",
139             "Element img is missing required attribute src."
140         ]
141       },
142       files: {
143         src: ["_gh_pages/**/*.html"]
144       }
145     },
146
147     watch: {
148       src: {
149         files: '<%= jshint.src.src %>',
150         tasks: ['jshint:src', 'qunit']
151       },
152       test: {
153         files: '<%= jshint.test.src %>',
154         tasks: ['jshint:test', 'qunit']
155       },
156       recess: {
157         files: 'less/*.less',
158         tasks: ['recess']
159       }
160     },
161
162     sed: {
163       versionNumber: {
164         pattern: (function () {
165           var old = grunt.option('oldver')
166           return old ? RegExp.quote(old) : old
167         })(),
168         replacement: grunt.option('newver'),
169         recursive: true
170       }
171     }
172   });
173
174
175   // These plugins provide necessary tasks.
176   grunt.loadNpmTasks('browserstack-runner');
177   grunt.loadNpmTasks('grunt-contrib-clean');
178   grunt.loadNpmTasks('grunt-contrib-concat');
179   grunt.loadNpmTasks('grunt-contrib-connect');
180   grunt.loadNpmTasks('grunt-contrib-copy');
181   grunt.loadNpmTasks('grunt-contrib-jshint');
182   grunt.loadNpmTasks('grunt-contrib-qunit');
183   grunt.loadNpmTasks('grunt-contrib-uglify');
184   grunt.loadNpmTasks('grunt-contrib-watch');
185   grunt.loadNpmTasks('grunt-html-validation');
186   grunt.loadNpmTasks('grunt-jekyll');
187   grunt.loadNpmTasks('grunt-recess');
188   grunt.loadNpmTasks('grunt-sed');
189
190   // Docs HTML validation task
191   grunt.registerTask('validate-html', ['jekyll', 'validation']);
192
193   // Test task.
194   var testSubtasks = ['dist-css', 'jshint', 'qunit', 'validate-html'];
195   // Only run BrowserStack tests under Travis
196   if (process.env.TRAVIS) {
197     // Only run BrowserStack tests if this is a mainline commit in twbs/bootstrap, or you have your own BrowserStack key
198     if ((process.env.TRAVIS_REPO_SLUG === 'twbs/bootstrap' && process.env.TRAVIS_PULL_REQUEST === 'false') || process.env.TWBS_HAVE_OWN_BROWSERSTACK_KEY) {
199       testSubtasks.push('browserstack_runner');
200     }
201   }
202   grunt.registerTask('test', testSubtasks);
203
204   // JS distribution task.
205   grunt.registerTask('dist-js', ['concat', 'uglify']);
206
207   // CSS distribution task.
208   grunt.registerTask('dist-css', ['recess']);
209
210   // Fonts distribution task.
211   grunt.registerTask('dist-fonts', ['copy']);
212
213   // Full distribution task.
214   grunt.registerTask('dist', ['clean', 'dist-css', 'dist-fonts', 'dist-js']);
215
216   // Default task.
217   grunt.registerTask('default', ['test', 'dist', 'build-customizer']);
218
219   // Version numbering task.
220   // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
221   // This can be overzealous, so its changes should always be manually reviewed!
222   grunt.registerTask('change-version-number', ['sed']);
223
224   // task for building customizer
225   grunt.registerTask('build-customizer', 'Add scripts/less files to customizer.', function () {
226     var fs = require('fs')
227
228     function getFiles(type) {
229       var files = {}
230       fs.readdirSync(type)
231         .filter(function (path) {
232           return type == 'fonts' ? true : new RegExp('\\.' + type + '$').test(path)
233         })
234         .forEach(function (path) {
235           var fullPath = type + '/' + path
236           return files[path] = (type == 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8'))
237         })
238       return 'var __' + type + ' = ' + JSON.stringify(files) + '\n'
239     }
240
241     var files = getFiles('js') + getFiles('less') + getFiles('fonts')
242     fs.writeFileSync('docs-assets/js/raw-files.js', files)
243   });
244 };