22
33module . exports = function ( grunt ) {
44
5- var
6- glob = require ( "glob" ) ,
7-
8- // files
9- coreFiles = [
10- "core.js" ,
11- "widget.js" ,
12- "widgets/mouse.js" ,
13- "widgets/draggable.js" ,
14- "widgets/droppable.js" ,
15- "widgets/resizable.js" ,
16- "widgets/selectable.js" ,
17- "widgets/sortable.js" ,
18- "effect.js"
19- ] ,
20-
21- uiFiles = coreFiles . map ( function ( file ) {
22- return "ui/" + file ;
23- } ) . concat ( expandFiles ( "ui/**/*.js" ) . filter ( function ( file ) {
24- return coreFiles . indexOf ( file . substring ( 3 ) ) === - 1 ;
25- } ) ) ,
26-
27- allI18nFiles = expandFiles ( "ui/i18n/*.js" ) ,
28-
29- cssFiles = [
30- "core" ,
31- "accordion" ,
32- "autocomplete" ,
33- "button" ,
34- "checkboxradio" ,
35- "controlgroup" ,
36- "datepicker" ,
37- "dialog" ,
38- "draggable" ,
39- "menu" ,
40- "progressbar" ,
41- "resizable" ,
42- "selectable" ,
43- "selectmenu" ,
44- "sortable" ,
45- "slider" ,
46- "spinner" ,
47- "tabs" ,
48- "tooltip" ,
49- "theme"
50- ] . map ( function ( component ) {
51- return "themes/base/" + component + ".css" ;
52- } ) ,
53-
54- // minified files
55- minify = {
5+ // files
6+ const coreFiles = [
7+ "core.js" ,
8+ "widget.js" ,
9+ "widgets/mouse.js" ,
10+ "widgets/draggable.js" ,
11+ "widgets/droppable.js" ,
12+ "widgets/resizable.js" ,
13+ "widgets/selectable.js" ,
14+ "widgets/sortable.js" ,
15+ "effect.js"
16+ ] ;
17+
18+ const uiFiles = coreFiles . map ( function ( file ) {
19+ return "ui/" + file ;
20+ } ) . concat ( expandFiles ( "ui/**/*.js" ) . filter ( function ( file ) {
21+ return coreFiles . indexOf ( file . substring ( 3 ) ) === - 1 ;
22+ } ) ) ;
23+
24+ const allI18nFiles = expandFiles ( "ui/i18n/*.js" ) ;
25+
26+ const cssFiles = [
27+ "core" ,
28+ "accordion" ,
29+ "autocomplete" ,
30+ "button" ,
31+ "checkboxradio" ,
32+ "controlgroup" ,
33+ "datepicker" ,
34+ "dialog" ,
35+ "draggable" ,
36+ "menu" ,
37+ "progressbar" ,
38+ "resizable" ,
39+ "selectable" ,
40+ "selectmenu" ,
41+ "sortable" ,
42+ "slider" ,
43+ "spinner" ,
44+ "tabs" ,
45+ "tooltip" ,
46+ "theme"
47+ ] . map ( function ( component ) {
48+ return "themes/base/" + component + ".css" ;
49+ } ) ;
50+
51+ // minified files
52+ const minify = {
53+ options : {
54+ preserveComments : false
55+ } ,
56+ main : {
5657 options : {
57- preserveComments : false
58- } ,
59- main : {
60- options : {
61- banner : createBanner ( uiFiles )
62- } ,
63- files : {
64- "dist/jquery-ui.min.js" : "dist/jquery-ui.js"
65- }
58+ banner : createBanner ( uiFiles )
6659 } ,
67- i18n : {
68- options : {
69- banner : createBanner ( allI18nFiles )
70- } ,
71- files : {
72- "dist/i18n/jquery-ui-i18n.min.js" : "dist/i18n/jquery-ui-i18n.js"
73- }
60+ files : {
61+ "dist/jquery-ui.min.js" : "dist/jquery-ui.js"
7462 }
7563 } ,
64+ i18n : {
65+ options : {
66+ banner : createBanner ( allI18nFiles )
67+ } ,
68+ files : {
69+ "dist/i18n/jquery-ui-i18n.min.js" : "dist/i18n/jquery-ui-i18n.js"
70+ }
71+ }
72+ } ;
7673
77- compareFiles = {
78- all : [
79- "dist/jquery-ui.js" ,
80- "dist/jquery-ui.min.js"
81- ]
82- } ,
83- component = grunt . option ( "component" ) || "**" ,
84-
85- htmllintBad = [
86- "demos/tabs/ajax/content*.html" ,
87- "demos/tooltip/ajax/content*.html" ,
88- "tests/unit/core/core.html" ,
89- "tests/unit/tabs/data/test.html"
90- ] ;
74+ const compareFiles = {
75+ all : [
76+ "dist/jquery-ui.js" ,
77+ "dist/jquery-ui.min.js"
78+ ]
79+ } ;
80+ const component = grunt . option ( "component" ) || "**" ;
81+
82+ const htmllintBad = [
83+ "demos/tabs/ajax/content*.html" ,
84+ "demos/tooltip/ajax/content*.html" ,
85+ "tests/unit/core/core.html" ,
86+ "tests/unit/tabs/data/test.html"
87+ ] ;
88+
89+ const nodeV16OrNewer = ! / ^ v 1 [ 0 - 5 ] \. / . test ( process . version ) ;
90+
91+ // Support: Node.js <16
92+ // Skip running tasks that dropped support for Node.js 10-15
93+ // in this Node version.
94+ function runIfNewNode ( task ) {
95+ return nodeV16OrNewer ? task : "print_old_node_message:" + task ;
96+ }
9197
9298function mapMinFile ( file ) {
9399 return "dist/" + file . replace ( / u i \/ / , "minified/" ) ;
@@ -115,20 +121,14 @@ uiFiles.forEach( function( file ) {
115121 compareFiles [ file ] = [ file , mapMinFile ( file ) ] ;
116122} ) ;
117123
118- // grunt plugins
119- require ( "load-grunt-tasks" ) ( grunt ) ;
120-
121- // local testswarm and build tasks
122- grunt . loadTasks ( "build/tasks" ) ;
123-
124124function stripDirectory ( file ) {
125125 return file . replace ( / .+ \/ ( .+ ?) > ? $ / , "$1" ) ;
126126}
127127
128128function createBanner ( files ) {
129129
130130 // strip folders
131- var fileNames = files && files . map ( stripDirectory ) ;
131+ const fileNames = files && files . map ( stripDirectory ) ;
132132 return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
133133 "<%= grunt.template.today('isoDate') %>\n" +
134134 "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
@@ -182,11 +182,14 @@ grunt.initConfig( {
182182 good : {
183183 options : {
184184 ignore : [
185- / T h e t e x t c o n t e n t o f e l e m e n t “ s c r i p t ” w a s n o t i n t h e r e q u i r e d f o r m a t : E x p e c t e d s p a c e , t a b , n e w l i n e , o r s l a s h b u t f o u n d “ .” i n s t e a d /
186- ] } ,
187- src : glob . sync ( "{demos,tests}/**/*.html" , {
188- ignore : htmllintBad
189- } )
185+ / T h e t e x t c o n t e n t o f e l e m e n t “ s c r i p t ” w a s n o t i n t h e r e q u i r e d f o r m a t : E x p e c t e d s p a c e , t a b , n e w l i n e , o r s l a s h b u t f o u n d “ .” i n s t e a d / ,
186+ / T h i s d o c u m e n t a p p e a r s t o b e w r i t t e n i n .* . C o n s i d e r u s i n g “ l a n g = " .* " ” \( o r v a r i a n t \) i n s t e a d /
187+ ]
188+ } ,
189+ src : [
190+ "{demos,tests}/**/*.html" ,
191+ ...htmllintBad . map ( pattern => `!${ pattern } ` )
192+ ]
190193 } ,
191194 bad : {
192195 options : {
@@ -196,7 +199,7 @@ grunt.initConfig( {
196199 / E l e m e n t “ o b j e c t ” i s m i s s i n g o n e o r m o r e o f t h e f o l l o w i n g / ,
197200 / T h e “ c o d e b a s e ” a t t r i b u t e o n t h e “ o b j e c t ” e l e m e n t i s o b s o l e t e / ,
198201 / C o n s i d e r a d d i n g a “ l a n g ” a t t r i b u t e t o t h e “ h t m l ” s t a r t t a g / ,
199- / T h i s d o c u m e n t a p p e a r s t o b e w r i t t e n i n .* . C o n s i d e r a d d i n g “ l a n g = " .* " ” \( o r v a r i a n t \) t o t h e “ h t m l ” s t a r t t a g /
202+ / T h i s d o c u m e n t a p p e a r s t o b e w r i t t e n i n .* . C o n s i d e r (?: a d d i n g | u s i n g ) “ l a n g = " .* " ” \( o r v a r i a n t \) /
200203 ]
201204 } ,
202205 src : htmllintBad
@@ -208,15 +211,18 @@ grunt.initConfig( {
208211 } ) ,
209212 options : {
210213 puppeteer : {
211- ignoreDefaultArgs : true ,
212214 args : [
213- "--headless" ,
214- "--disable-web-security" ,
215215 "--allow-file-access-from-files"
216216 ]
217217 } ,
218218 inject : [
219- require . resolve ( "grunt-contrib-qunit/chrome/bridge" )
219+ require . resolve (
220+ "./tests/lib/grunt-contrib-qunit-bridges/bridge-wrapper.js.intro"
221+ ) ,
222+ require . resolve ( "grunt-contrib-qunit/chrome/bridge" ) ,
223+ require . resolve (
224+ "./tests/lib/grunt-contrib-qunit-bridges/bridge-wrapper.js.outro"
225+ )
220226 ] ,
221227 page : {
222228 viewportSize : { width : 700 , height : 500 }
@@ -266,18 +272,6 @@ grunt.initConfig( {
266272 "qunit/qunit.css" : "qunit/qunit/qunit.css" ,
267273 "qunit/LICENSE.txt" : "qunit/LICENSE.txt" ,
268274
269- "qunit-assert-classes/qunit-assert-classes.js" :
270- "qunit-assert-classes/qunit-assert-classes.js" ,
271- "qunit-assert-classes/LICENSE.txt" : "qunit-assert-classes/LICENSE" ,
272-
273- "qunit-assert-close/qunit-assert-close.js" :
274- "qunit-assert-close/qunit-assert-close.js" ,
275- "qunit-assert-close/MIT-LICENSE.txt" : "qunit-assert-close/MIT-LICENSE.txt" ,
276-
277- "qunit-composite/qunit-composite.js" : "qunit-composite/qunit-composite.js" ,
278- "qunit-composite/qunit-composite.css" : "qunit-composite/qunit-composite.css" ,
279- "qunit-composite/LICENSE.txt" : "qunit-composite/LICENSE.txt" ,
280-
281275 "requirejs/require.js" : "requirejs/require.js" ,
282276
283277 "jquery-mousewheel/jquery.mousewheel.js" : "jquery-mousewheel/jquery.mousewheel.js" ,
@@ -421,13 +415,28 @@ grunt.initConfig( {
421415 "jquery-3.6.0/jquery.js" : "jquery-3.6.0/dist/jquery.js" ,
422416 "jquery-3.6.0/LICENSE.txt" : "jquery-3.6.0/LICENSE.txt" ,
423417
418+ "jquery-3.6.1/jquery.js" : "jquery-3.6.1/dist/jquery.js" ,
419+ "jquery-3.6.1/LICENSE.txt" : "jquery-3.6.1/LICENSE.txt" ,
420+
421+ "jquery-3.6.2/jquery.js" : "jquery-3.6.2/dist/jquery.js" ,
422+ "jquery-3.6.2/LICENSE.txt" : "jquery-3.6.2/LICENSE.txt" ,
423+
424+ "jquery-3.6.3/jquery.js" : "jquery-3.6.3/dist/jquery.js" ,
425+ "jquery-3.6.3/LICENSE.txt" : "jquery-3.6.3/LICENSE.txt" ,
426+
427+ "jquery-3.6.4/jquery.js" : "jquery-3.6.4/dist/jquery.js" ,
428+ "jquery-3.6.4/LICENSE.txt" : "jquery-3.6.4/LICENSE.txt" ,
429+
430+ "jquery-3.7.0/jquery.js" : "jquery-3.7.0/dist/jquery.js" ,
431+ "jquery-3.7.0/LICENSE.txt" : "jquery-3.7.0/LICENSE.txt" ,
432+
424433 "jquery-migrate-1.4.1/jquery-migrate.js" :
425434 "jquery-migrate-1.4.1/dist/jquery-migrate.js" ,
426435 "jquery-migrate-1.4.1/LICENSE.txt" : "jquery-migrate-1.4.1/LICENSE.txt" ,
427436
428- "jquery-migrate-3.3.2 /jquery-migrate.js" :
429- "jquery-migrate-3.3.2 /dist/jquery-migrate.js" ,
430- "jquery-migrate-3.3.2 /LICENSE.txt" : "jquery-migrate-3.3.2 /LICENSE.txt"
437+ "jquery-migrate-3.4.1 /jquery-migrate.js" :
438+ "jquery-migrate-3.4.1 /dist/jquery-migrate.js" ,
439+ "jquery-migrate-3.4.1 /LICENSE.txt" : "jquery-migrate-3.4.1 /LICENSE.txt"
431440 }
432441 }
433442 } ,
@@ -460,9 +469,22 @@ grunt.initConfig( {
460469 }
461470} ) ;
462471
472+ // grunt plugins
473+ require ( "load-grunt-tasks" ) ( grunt , {
474+ pattern : nodeV16OrNewer ? [ "grunt-*" ] : [
475+ "grunt-*" ,
476+ "!grunt-contrib-qunit" ,
477+ "!grunt-eslint" ,
478+ "!grunt-html"
479+ ]
480+ } ) ;
481+
482+ // local testswarm and build tasks
483+ grunt . loadTasks ( "build/tasks" ) ;
484+
463485grunt . registerTask ( "update-authors" , function ( ) {
464- var getAuthors = require ( "grunt-git-authors" ) . getAuthors ,
465- done = this . async ( ) ;
486+ const getAuthors = require ( "grunt-git-authors" ) . getAuthors ;
487+ const done = this . async ( ) ;
466488
467489 getAuthors ( {
468490 priorAuthors : grunt . config ( "authors.prior" )
@@ -490,11 +512,21 @@ grunt.registerTask( "update-authors", function() {
490512 } ) ;
491513} ) ;
492514
515+ grunt . registerTask ( "print_old_node_message" , ( ...args ) => {
516+ const task = args . join ( ":" ) ;
517+ grunt . log . writeln ( "Old Node.js detected, running the task \"" + task + "\" skipped..." ) ;
518+ } ) ;
519+
493520// Keep this task list in sync with the testing steps in our GitHub action test workflow file!
494521grunt . registerTask ( "default" , [ "lint" , "requirejs" , "test" ] ) ;
495522grunt . registerTask ( "jenkins" , [ "default" , "concat" ] ) ;
496- grunt . registerTask ( "lint" , [ "asciilint" , "eslint" , "csslint" , "htmllint" ] ) ;
497- grunt . registerTask ( "test" , [ "qunit" ] ) ;
523+ grunt . registerTask ( "lint" , [
524+ "asciilint" ,
525+ runIfNewNode ( "eslint" ) ,
526+ "csslint" ,
527+ runIfNewNode ( "htmllint" )
528+ ] ) ;
529+ grunt . registerTask ( "test" , [ runIfNewNode ( "qunit" ) ] ) ;
498530grunt . registerTask ( "sizer" , [ "requirejs:js" , "uglify:main" , "compare_size:all" ] ) ;
499531grunt . registerTask ( "sizer_all" , [ "requirejs:js" , "uglify" , "compare_size" ] ) ;
500532
0 commit comments