Debian Codegraph @

Gruntfile.js

raw symbols ◀ ▶ SCIP
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: "/usr/share/nodejs/jquery/dist/jquery",
158 external: "/usr/share/nodejs/"
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
176 authors: {
177 prior: [
178 "Paul Bakaus <[email protected]>",
179 "Richard Worth <[email protected]>",
180 "Yehuda Katz <[email protected]>",
181 "Sean Catchpole <[email protected]>",
182 "John Resig <[email protected]>",
183 "Tane Piper <[email protected]>",
184 "Dmitri Gaskin <[email protected]>",
185 "Klaus Hartl <[email protected]>",
186 "Stefan Petre <[email protected]>",
187 "Gilles van den Hoven <[email protected]>",
188 "Micheil Bryan Smith <[email protected]>",
189 "Jörn Zaefferer <[email protected]>",
190 "Marc Grabanski <[email protected]>",
191 "Keith Wood <[email protected]>",
192 "Brandon Aaron <[email protected]>",
193 "Scott González <[email protected]>",
194 "Eduardo Lundgren <[email protected]>",
195 "Aaron Eisenberger <[email protected]>",
196 "Joan Piedra <[email protected]>",
197 "Bruno Basto <[email protected]>",
198 "Remy Sharp <[email protected]>",
199 "Bohdan Ganicky <[email protected]>"
200 ]
201 }
202 } );
203
204 // grunt plugins
205 require( "load-grunt-tasks" )( grunt );
206
207 // local tasks
208 grunt.loadTasks( "build/tasks" );
209
210 grunt.registerTask( "update-authors", function() {
211 const getAuthors = require( "grunt-git-authors" ).getAuthors;
212 const done = this.async();
213
214 getAuthors( {
215 priorAuthors: grunt.config( "authors.prior" )
216 }, function( error, authors ) {
217 if ( error ) {
218 grunt.log.error( error );
219 return done( false );
220 }
221
222 authors = authors.map( function( author ) {
223 if ( author.match( /^Jacek Jędrzejewski </ ) ) {
224 return "Jacek Jędrzejewski (https://jacek.jedrzejewski.name)";
225 } else if ( author.match( /^Pawel Maruszczyk </ ) ) {
226 return "Pawel Maruszczyk (http://hrabstwo.net)";
227 } else {
228 return author;
229 }
230 } );
231
232 grunt.file.write( "AUTHORS.txt",
233 "Authors ordered by first contribution\n" +
234 "A list of current team members is available at https://jqueryui.com/about\n\n" +
235 authors.join( "\n" ) + "\n" );
236 done();
237 } );
238 } );
239
240 grunt.registerTask( "print_old_node_message", ( ...args ) => {
241 const task = args.join( ":" );
242 grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
243 } );
244
245 // Keep this task list in sync with the testing steps in our GitHub action test workflow file!
246
247 };