"use strict"; module.exports = function( grunt ) { const { gzipSync } = require( "node:zlib" ); // files const coreFiles = [ "widget.js", "widgets/mouse.js", "widgets/draggable.js", "widgets/droppable.js", "widgets/resizable.js", "widgets/selectable.js", "widgets/sortable.js", "effect.js" ]; const uiFiles = coreFiles.map( function( file ) { return "ui/" + file; } ).concat( expandFiles( "ui/**/*.js" ).filter( function( file ) { return coreFiles.indexOf( file.substring( 3 ) ) === -1; } ) ); const allI18nFiles = expandFiles( "ui/i18n/*.js" ); const cssFiles = [ "core", "accordion", "autocomplete", "button", "checkboxradio", "controlgroup", "datepicker", "dialog", "draggable", "menu", "progressbar", "resizable", "selectable", "selectmenu", "sortable", "slider", "spinner", "tabs", "tooltip", "theme" ].map( function( component ) { return "themes/base/" + component + ".css"; } ); // minified files const minify = { main: { options: { banner: createBanner( uiFiles ) }, files: { "dist/jquery-ui.min.js": "dist/jquery-ui.js" } }, i18n: { options: { banner: createBanner( allI18nFiles ) }, files: { "dist/i18n/jquery-ui-i18n.min.js": "dist/i18n/jquery-ui-i18n.js" } } }; const compareFiles = { all: [ "dist/jquery-ui.js", "dist/jquery-ui.min.js" ], options: { compress: { gz: function( contents ) { return gzipSync( contents ).length; } }, cache: "build/.sizecache.json" } }; const htmllintBad = [ "demos/tabs/ajax/content*.html", "demos/tooltip/ajax/content*.html", "tests/unit/core/core.html", "tests/unit/tabs/data/test.html" ]; function mapMinFile( file ) { return "dist/" + file.replace( /ui\//, "minified/" ); } function expandFiles( files ) { return grunt.util._.map( grunt.file.expandMapping( files ), "src" ).map( function( values ) { return values[ 0 ]; } ); } uiFiles.concat( allI18nFiles ).forEach( function( file ) { minify[ file ] = { options: { banner: createBanner() }, files: {} }; minify[ file ].files[ mapMinFile( file ) ] = file; } ); uiFiles.forEach( function( file ) { compareFiles[ file ] = [ file, mapMinFile( file ) ]; } ); function stripDirectory( file ) { return file.replace( /.+\/(.+?)>?$/, "$1" ); } function createBanner( files ) { // strip folders const fileNames = files && files.map( stripDirectory ); return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + "<%= grunt.template.today('isoDate') %>\n" + "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" + ( files ? "* Includes: " + fileNames.join( ", " ) + "\n" : "" ) + "* Copyright <%= pkg.author.name %>;" + " Licensed <%= _.map(pkg.licenses, 'type').join(', ') %> */\n"; } grunt.initConfig( { pkg: grunt.file.readJSON( "package.json" ), files: { dist: "<%= pkg.name %>-<%= pkg.version %>" }, compare_size: compareFiles, concat: { css: { options: { banner: createBanner( cssFiles ), stripBanners: { block: true } }, src: cssFiles, dest: "dist/jquery-ui.css" } }, requirejs: { js: { options: { baseUrl: "./", paths: { jquery: "/usr/share/nodejs/jquery/dist/jquery", external: "/usr/share/nodejs/" }, preserveLicenseComments: false, optimize: "none", findNestedDependencies: true, skipModuleInsertion: true, exclude: [ "jquery" ], include: expandFiles( [ "ui/**/*.js", "!ui/i18n/*" ] ), out: "dist/jquery-ui.js", wrap: { start: createBanner( uiFiles ) } } } }, minify, authors: { prior: [ "Paul Bakaus ", "Richard Worth ", "Yehuda Katz ", "Sean Catchpole ", "John Resig ", "Tane Piper ", "Dmitri Gaskin ", "Klaus Hartl ", "Stefan Petre ", "Gilles van den Hoven ", "Micheil Bryan Smith ", "Jörn Zaefferer ", "Marc Grabanski ", "Keith Wood ", "Brandon Aaron ", "Scott González ", "Eduardo Lundgren ", "Aaron Eisenberger ", "Joan Piedra ", "Bruno Basto ", "Remy Sharp ", "Bohdan Ganicky " ] } } ); // grunt plugins require( "load-grunt-tasks" )( grunt ); // local tasks grunt.loadTasks( "build/tasks" ); grunt.registerTask( "update-authors", function() { const getAuthors = require( "grunt-git-authors" ).getAuthors; const done = this.async(); getAuthors( { priorAuthors: grunt.config( "authors.prior" ) }, function( error, authors ) { if ( error ) { grunt.log.error( error ); return done( false ); } authors = authors.map( function( author ) { if ( author.match( /^Jacek Jędrzejewski { const task = args.join( ":" ); grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." ); } ); // Keep this task list in sync with the testing steps in our GitHub action test workflow file! };