Debian Codegraph @

Gruntfile.js

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 "use strict";
2
3 module.exports = function( grunt ) {
4
5 const { gzipSync } = require( "node:zlib" );
6
7 // files
8 const coreFiles = [
9 "widget.js",
10 "widgets/mouse.js",
11 "widgets/draggable.js",
12 "widgets/droppable.js",
13 "widgets/resizable.js",
14 "widgets/selectable.js",
15 "widgets/sortable.js",
16 "effect.js"
17 ];
18
19 const uiFiles = coreFiles.map( function( file ) {
20 return "ui/" + file;
21 } ).concat( expandFiles( "ui/**/*.js" ).filter( function( file ) {
22 return coreFiles.indexOf( file.substring( 3 ) ) === -1;
23 } ) );
24
25 const allI18nFiles = expandFiles( "ui/i18n/*.js" );
26
27 const cssFiles = [
28 "core",
29 "accordion",
30 "autocomplete",
31 "button",
32 "checkboxradio",
33 "controlgroup",
34 "datepicker",
35 "dialog",
36 "draggable",
37 "menu",
38 "progressbar",
39 "resizable",
40 "selectable",
41 "selectmenu",
42 "sortable",
43 "slider",
44 "spinner",
45 "tabs",
46 "tooltip",
47 "theme"
48 ].map( function( component ) {
49 return "themes/base/" + component + ".css";
50 } );
51
52 // minified files
53 const minify = {
54 main: {
55 options: {
56 banner: createBanner( uiFiles )
57 },
58 files: {
59 "dist/jquery-ui.min.js": "dist/jquery-ui.js"
60 }
61 },
62 i18n: {
63 options: {
64 banner: createBanner( allI18nFiles )
65 },
66 files: {
67 "dist/i18n/jquery-ui-i18n.min.js": "dist/i18n/jquery-ui-i18n.js"
68 }
69 }
70 };
71
72 const compareFiles = {
73 all: [
74 "dist/jquery-ui.js",
75 "dist/jquery-ui.min.js"
76 ],
77 options: {
78 compress: {
79 gz: function( contents ) {
80 return gzipSync( contents ).length;
81 }
82 },
83 cache: "build/.sizecache.json"
84 }
85 };
86
87 const htmllintBad = [
88 "demos/tabs/ajax/content*.html",
89 "demos/tooltip/ajax/content*.html",
90 "tests/unit/core/core.html",
91 "tests/unit/tabs/data/test.html"
92 ];
93
94 function mapMinFile( file ) {
95 return "dist/" + file.replace( /ui\//, "minified/" );
96 }
97
98 function expandFiles( files ) {
99 return grunt.util._.map( grunt.file.expandMapping( files ), "src" ).map( function( values ) {
100 return values[ 0 ];
101 } );
102 }
103
104 uiFiles.concat( allI18nFiles ).forEach( function( file ) {
105 minify[ file ] = {
106 options: {
107 banner: createBanner()
108 },
109 files: {}
110 };
111 minify[ file ].files[ mapMinFile( file ) ] = file;
112 } );
113
114 uiFiles.forEach( function( file ) {
115 compareFiles[ file ] = [ file, mapMinFile( file ) ];
116 } );
117
118 function stripDirectory( file ) {
119 return file.replace( /.+\/(.+?)>?$/, "$1" );
120 }
121
122 function createBanner( files ) {
123
124 // strip folders
125 const fileNames = files && files.map( stripDirectory );
126 return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
127 "<%= grunt.template.today('isoDate') %>\n" +
128 "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
129 ( files ? "* Includes: " + fileNames.join( ", " ) + "\n" : "" ) +
130 "* Copyright <%= pkg.author.name %>;" +
131 " Licensed <%= _.map(pkg.licenses, 'type').join(', ') %> */\n";
132 }
133
134 grunt.initConfig( {
135 pkg: grunt.file.readJSON( "package.json" ),
136 files: {
137 dist: "<%= pkg.name %>-<%= pkg.version %>"
138 },
139 compare_size: compareFiles,
140 concat: {
141 css: {
142 options: {
143 banner: createBanner( cssFiles ),
144 stripBanners: {
145 block: true
146 }
147 },
148 src: cssFiles,
149 dest: "dist/jquery-ui.css"
150 }
151 },
152 requirejs: {
153 js: {
154 options: {
155 baseUrl: "./",
156 paths: {
157 jquery: "./external/jquery/jquery",
158 external: "./external/"
159 },
160 preserveLicenseComments: false,
161 optimize: "none",
162 findNestedDependencies: true,
163 skipModuleInsertion: true,
164 exclude: [ "jquery" ],
165 include: expandFiles( [ "ui/**/*.js", "!ui/i18n/*" ] ),
166 out: "dist/jquery-ui.js",
167 wrap: {
168 start: createBanner( uiFiles )
169 }
170 }
171 }
172 },
173
174 minify,
175 htmllint: {
176 good: {
177 options: {
178 ignore: [
179 /The text content of element “script” was not in the required format: Expected space, tab, newline, or slash but found “.” instead/,
180 /This document appears to be written in .*. Consider using “lang=".*"” \(or variant\) instead/
181 ]
182 },
183 src: [
184 "{demos,tests}/**/*.html",
185 ...htmllintBad.map( pattern => `!${ pattern }` )
186 ]
187 },
188 bad: {
189 options: {
190 ignore: [
191 /Start tag seen without seeing a doctype first/,
192 /Element “head” is missing a required instance of child element “title”/,
193 /Element “object” is missing one or more of the following/,
194 /The “codebase” attribute on the “object” element is obsolete/,
195 /Consider adding a “lang” attribute to the “html” start tag/,
196 /This document appears to be written in .*. Consider (?:adding|using) “lang=".*"” \(or variant\)/
197 ]
198 },
199 src: htmllintBad
200 }
201 },
202 eslint: {
203 all: [
204 "ui/**/*.js",
205 "!ui/vendor/**/*.js",
206 "Gruntfile.js",
207 "dist/jquery-ui.js",
208 "dist/jquery-ui.min.js",
209 "build/**/*.js",
210 "tests/unit/**/*.js",
211 "tests/lib/**/*.js",
212 "!tests/lib/vendor/**/*.js",
213 "demos/**/*.js"
214 ]
215 },
216 csslint: {
217 base_theme: {
218 src: "themes/base/*.css",
219 options: {
220 csslintrc: ".csslintrc"
221 }
222 }
223 },
224
225 bowercopy: {
226 inlineVendors: {
227 options: {
228 clean: true,
229 destPrefix: "ui/vendor"
230 },
231 files: {
232 "jquery-color/jquery.color.js": "jquery-color/dist/jquery.color.js",
233 "jquery-color/LICENSE.txt": "jquery-color/LICENSE.txt"
234 }
235 },
236
237 all: {
238 options: {
239 clean: true,
240 ignore: [ "jquery" ],
241 destPrefix: "external"
242 },
243 files: {
244 "qunit/qunit.js": "qunit/qunit/qunit.js",
245 "qunit/qunit.css": "qunit/qunit/qunit.css",
246 "qunit/LICENSE.txt": "qunit/LICENSE.txt",
247
248 "requirejs/require.js": "requirejs/require.js",
249
250 "jquery-mousewheel/jquery.mousewheel.js": "jquery-mousewheel/jquery.mousewheel.js",
251 "jquery-mousewheel/LICENSE.txt": "jquery-mousewheel/LICENSE.txt",
252
253 "jquery-simulate/jquery.simulate.js": "jquery-simulate/jquery.simulate.js",
254 "jquery-simulate/LICENSE.txt": "jquery-simulate/LICENSE.txt",
255
256 "jquery/jquery.js": "jquery-3.x/dist/jquery.js",
257 "jquery/LICENSE.txt": "jquery-3.x/LICENSE.txt",
258
259 "jquery-1.12.4/jquery.js": "jquery-1.12.4/dist/jquery.js",
260 "jquery-1.12.4/LICENSE.txt": "jquery-1.12.4/LICENSE.txt",
261
262 "jquery-2.2.4/jquery.js": "jquery-2.2.4/dist/jquery.js",
263 "jquery-2.2.4/LICENSE.txt": "jquery-2.2.4/LICENSE.txt",
264
265 "jquery-3.0.0/jquery.js": "jquery-3.0.0/dist/jquery.js",
266 "jquery-3.0.0/LICENSE.txt": "jquery-3.0.0/LICENSE.txt",
267
268 "jquery-3.1.0/jquery.js": "jquery-3.1.0/dist/jquery.js",
269 "jquery-3.1.0/LICENSE.txt": "jquery-3.1.0/LICENSE.txt",
270
271 "jquery-3.1.1/jquery.js": "jquery-3.1.1/dist/jquery.js",
272 "jquery-3.1.1/LICENSE.txt": "jquery-3.1.1/LICENSE.txt",
273
274 "jquery-3.2.0/jquery.js": "jquery-3.2.0/dist/jquery.js",
275 "jquery-3.2.0/LICENSE.txt": "jquery-3.2.0/LICENSE.txt",
276
277 "jquery-3.2.1/jquery.js": "jquery-3.2.1/dist/jquery.js",
278 "jquery-3.2.1/LICENSE.txt": "jquery-3.2.1/LICENSE.txt",
279
280 "jquery-3.3.0/jquery.js": "jquery-3.3.0/dist/jquery.js",
281 "jquery-3.3.0/LICENSE.txt": "jquery-3.3.0/LICENSE.txt",
282
283 "jquery-3.3.1/jquery.js": "jquery-3.3.1/dist/jquery.js",
284 "jquery-3.3.1/LICENSE.txt": "jquery-3.3.1/LICENSE.txt",
285
286 "jquery-3.4.0/jquery.js": "jquery-3.4.0/dist/jquery.js",
287 "jquery-3.4.0/LICENSE.txt": "jquery-3.4.0/LICENSE.txt",
288
289 "jquery-3.4.1/jquery.js": "jquery-3.4.1/dist/jquery.js",
290 "jquery-3.4.1/LICENSE.txt": "jquery-3.4.1/LICENSE.txt",
291
292 "jquery-3.5.0/jquery.js": "jquery-3.5.0/dist/jquery.js",
293 "jquery-3.5.0/LICENSE.txt": "jquery-3.5.0/LICENSE.txt",
294
295 "jquery-3.5.1/jquery.js": "jquery-3.5.1/dist/jquery.js",
296 "jquery-3.5.1/LICENSE.txt": "jquery-3.5.1/LICENSE.txt",
297
298 "jquery-3.6.0/jquery.js": "jquery-3.6.0/dist/jquery.js",
299 "jquery-3.6.0/LICENSE.txt": "jquery-3.6.0/LICENSE.txt",
300
301 "jquery-3.6.1/jquery.js": "jquery-3.6.1/dist/jquery.js",
302 "jquery-3.6.1/LICENSE.txt": "jquery-3.6.1/LICENSE.txt",
303
304 "jquery-3.6.2/jquery.js": "jquery-3.6.2/dist/jquery.js",
305 "jquery-3.6.2/LICENSE.txt": "jquery-3.6.2/LICENSE.txt",
306
307 "jquery-3.6.3/jquery.js": "jquery-3.6.3/dist/jquery.js",
308 "jquery-3.6.3/LICENSE.txt": "jquery-3.6.3/LICENSE.txt",
309
310 "jquery-3.6.4/jquery.js": "jquery-3.6.4/dist/jquery.js",
311 "jquery-3.6.4/LICENSE.txt": "jquery-3.6.4/LICENSE.txt",
312
313 "jquery-3.7.0/jquery.js": "jquery-3.7.0/dist/jquery.js",
314 "jquery-3.7.0/LICENSE.txt": "jquery-3.7.0/LICENSE.txt",
315
316 "jquery-3.7.1/jquery.js": "jquery-3.7.1/dist/jquery.js",
317 "jquery-3.7.1/LICENSE.txt": "jquery-3.7.1/LICENSE.txt",
318
319 "jquery-4.0.0/jquery.js": "jquery-4.0.0/dist/jquery.js",
320 "jquery-4.0.0/LICENSE.txt": "jquery-4.0.0/LICENSE.txt",
321
322 "jquery-migrate-1.x/jquery-migrate.js":
323 "jquery-migrate-1.x/dist/jquery-migrate.js",
324 "jquery-migrate-1.x/LICENSE.txt": "jquery-migrate-1.x/LICENSE.txt",
325
326 "jquery-migrate-3.x/jquery-migrate.js":
327 "jquery-migrate-3.x/dist/jquery-migrate.js",
328 "jquery-migrate-3.x/LICENSE.txt": "jquery-migrate-3.x/LICENSE.txt",
329
330 "jquery-migrate-4.x/jquery-migrate.js":
331 "jquery-migrate-4.x/dist/jquery-migrate.js",
332 "jquery-migrate-4.x/LICENSE.txt": "jquery-migrate-4.x/LICENSE.txt"
333 }
334 }
335 },
336
337 authors: {
338 prior: [
339 "Paul Bakaus <[email protected]>",
340 "Richard Worth <[email protected]>",
341 "Yehuda Katz <[email protected]>",
342 "Sean Catchpole <[email protected]>",
343 "John Resig <[email protected]>",
344 "Tane Piper <[email protected]>",
345 "Dmitri Gaskin <[email protected]>",
346 "Klaus Hartl <[email protected]>",
347 "Stefan Petre <[email protected]>",
348 "Gilles van den Hoven <[email protected]>",
349 "Micheil Bryan Smith <[email protected]>",
350 "Jörn Zaefferer <[email protected]>",
351 "Marc Grabanski <[email protected]>",
352 "Keith Wood <[email protected]>",
353 "Brandon Aaron <[email protected]>",
354 "Scott González <[email protected]>",
355 "Eduardo Lundgren <[email protected]>",
356 "Aaron Eisenberger <[email protected]>",
357 "Joan Piedra <[email protected]>",
358 "Bruno Basto <[email protected]>",
359 "Remy Sharp <[email protected]>",
360 "Bohdan Ganicky <[email protected]>"
361 ]
362 }
363 } );
364
365 // grunt plugins
366 require( "load-grunt-tasks" )( grunt );
367
368 // local tasks
369 grunt.loadTasks( "build/tasks" );
370
371 grunt.registerTask( "update-authors", function() {
372 const getAuthors = require( "grunt-git-authors" ).getAuthors;
373 const done = this.async();
374
375 getAuthors( {
376 priorAuthors: grunt.config( "authors.prior" )
377 }, function( error, authors ) {
378 if ( error ) {
379 grunt.log.error( error );
380 return done( false );
381 }
382
383 authors = authors.map( function( author ) {
384 if ( author.match( /^Jacek Jędrzejewski </ ) ) {
385 return "Jacek Jędrzejewski (https://jacek.jedrzejewski.name)";
386 } else if ( author.match( /^Pawel Maruszczyk </ ) ) {
387 return "Pawel Maruszczyk (http://hrabstwo.net)";
388 } else {
389 return author;
390 }
391 } );
392
393 grunt.file.write( "AUTHORS.txt",
394 "Authors ordered by first contribution\n" +
395 "A list of current team members is available at https://jqueryui.com/about\n\n" +
396 authors.join( "\n" ) + "\n" );
397 done();
398 } );
399 } );
400
401 grunt.registerTask( "print_old_node_message", ( ...args ) => {
402 const task = args.join( ":" );
403 grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
404 } );
405
406 // Keep this task list in sync with the testing steps in our GitHub action test workflow file!
407 grunt.registerTask( "lint", [
408 "asciilint",
409 "eslint",
410 "csslint",
411 "htmllint"
412 ] );
413 grunt.registerTask( "build", [ "requirejs", "concat", "minify:main" ] );
414 grunt.registerTask( "default", [ "build", "lint" ] );
415 grunt.registerTask( "sizer", [ "requirejs:js", "minify:main", "compare_size:all" ] );
416 grunt.registerTask( "sizer_all", [ "requirejs:js", "minify", "compare_size" ] );
417
418 };