Skip to content

Commit

Permalink
Merge branch 'jquery:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
uplusware authored Dec 9, 2023
2 parents 328bd27 + 2de8604 commit 15f4870
Show file tree
Hide file tree
Showing 101 changed files with 63,960 additions and 5,441 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/**/*
external/**/*
tests/lib/vendor/**/*
ui/vendor/**/*
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@ name: Grunt tests

on: [push, pull_request]

permissions:
contents: read

jobs:
grunt:
name: Grunt based tests with Node.js ${{ matrix.node-version }}

runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x]
# Node.js 10 is required by jQuery infra
node-version: [10.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
echo "dir=\"$(npm config get cache)\"" >> $GITHUB_OUTPUT
- name: Cache npm dependencies
uses: actions/cache@v3
Expand Down
266 changes: 149 additions & 117 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,98 @@

module.exports = function( grunt ) {

var
glob = require( "glob" ),

// files
coreFiles = [
"core.js",
"widget.js",
"widgets/mouse.js",
"widgets/draggable.js",
"widgets/droppable.js",
"widgets/resizable.js",
"widgets/selectable.js",
"widgets/sortable.js",
"effect.js"
],

uiFiles = coreFiles.map( function( file ) {
return "ui/" + file;
} ).concat( expandFiles( "ui/**/*.js" ).filter( function( file ) {
return coreFiles.indexOf( file.substring( 3 ) ) === -1;
} ) ),

allI18nFiles = expandFiles( "ui/i18n/*.js" ),

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
minify = {
// files
const coreFiles = [
"core.js",
"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 = {
options: {
preserveComments: false
},
main: {
options: {
preserveComments: false
},
main: {
options: {
banner: createBanner( uiFiles )
},
files: {
"dist/jquery-ui.min.js": "dist/jquery-ui.js"
}
banner: createBanner( uiFiles )
},
i18n: {
options: {
banner: createBanner( allI18nFiles )
},
files: {
"dist/i18n/jquery-ui-i18n.min.js": "dist/i18n/jquery-ui-i18n.js"
}
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"
}
}
};

compareFiles = {
all: [
"dist/jquery-ui.js",
"dist/jquery-ui.min.js"
]
},
component = grunt.option( "component" ) || "**",

htmllintBad = [
"demos/tabs/ajax/content*.html",
"demos/tooltip/ajax/content*.html",
"tests/unit/core/core.html",
"tests/unit/tabs/data/test.html"
];
const compareFiles = {
all: [
"dist/jquery-ui.js",
"dist/jquery-ui.min.js"
]
};
const component = grunt.option( "component" ) || "**";

const htmllintBad = [
"demos/tabs/ajax/content*.html",
"demos/tooltip/ajax/content*.html",
"tests/unit/core/core.html",
"tests/unit/tabs/data/test.html"
];

const nodeV16OrNewer = !/^v1[0-5]\./.test( process.version );

// Support: Node.js <16
// Skip running tasks that dropped support for Node.js 10-15
// in this Node version.
function runIfNewNode( task ) {
return nodeV16OrNewer ? task : "print_old_node_message:" + task;
}

function mapMinFile( file ) {
return "dist/" + file.replace( /ui\//, "minified/" );
Expand Down Expand Up @@ -115,20 +121,14 @@ uiFiles.forEach( function( file ) {
compareFiles[ file ] = [ file, mapMinFile( file ) ];
} );

// grunt plugins
require( "load-grunt-tasks" )( grunt );

// local testswarm and build tasks
grunt.loadTasks( "build/tasks" );

function stripDirectory( file ) {
return file.replace( /.+\/(.+?)>?$/, "$1" );
}

function createBanner( files ) {

// strip folders
var fileNames = files && files.map( stripDirectory );
const fileNames = files && files.map( stripDirectory );
return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
"<%= grunt.template.today('isoDate') %>\n" +
"<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
Expand Down Expand Up @@ -182,11 +182,14 @@ grunt.initConfig( {
good: {
options: {
ignore: [
/The text content of element “script” was not in the required format: Expected space, tab, newline, or slash but found “.” instead/
] },
src: glob.sync( "{demos,tests}/**/*.html", {
ignore: htmllintBad
} )
/The text content of element “script” was not in the required format: Expected space, tab, newline, or slash but found “.” instead/,
/This document appears to be written in .*. Consider using “lang=".*"” \(or variant\) instead/
]
},
src: [
"{demos,tests}/**/*.html",
...htmllintBad.map( pattern => `!${ pattern }` )
]
},
bad: {
options: {
Expand All @@ -196,7 +199,7 @@ grunt.initConfig( {
/Element “object” is missing one or more of the following/,
/The “codebase” attribute on the “object” element is obsolete/,
/Consider adding a “lang” attribute to the “html” start tag/,
/This document appears to be written in .*. Consider adding “lang=".*"” \(or variant\) to the “html” start tag/
/This document appears to be written in .*. Consider (?:adding|using) “lang=".*"” \(or variant\)/
]
},
src: htmllintBad
Expand All @@ -208,15 +211,18 @@ grunt.initConfig( {
} ),
options: {
puppeteer: {
ignoreDefaultArgs: true,
args: [
"--headless",
"--disable-web-security",
"--allow-file-access-from-files"
]
},
inject: [
require.resolve( "grunt-contrib-qunit/chrome/bridge" )
require.resolve(
"./tests/lib/grunt-contrib-qunit-bridges/bridge-wrapper.js.intro"
),
require.resolve( "grunt-contrib-qunit/chrome/bridge" ),
require.resolve(
"./tests/lib/grunt-contrib-qunit-bridges/bridge-wrapper.js.outro"
)
],
page: {
viewportSize: { width: 700, height: 500 }
Expand Down Expand Up @@ -266,18 +272,6 @@ grunt.initConfig( {
"qunit/qunit.css": "qunit/qunit/qunit.css",
"qunit/LICENSE.txt": "qunit/LICENSE.txt",

"qunit-assert-classes/qunit-assert-classes.js":
"qunit-assert-classes/qunit-assert-classes.js",
"qunit-assert-classes/LICENSE.txt": "qunit-assert-classes/LICENSE",

"qunit-assert-close/qunit-assert-close.js":
"qunit-assert-close/qunit-assert-close.js",
"qunit-assert-close/MIT-LICENSE.txt": "qunit-assert-close/MIT-LICENSE.txt",

"qunit-composite/qunit-composite.js": "qunit-composite/qunit-composite.js",
"qunit-composite/qunit-composite.css": "qunit-composite/qunit-composite.css",
"qunit-composite/LICENSE.txt": "qunit-composite/LICENSE.txt",

"requirejs/require.js": "requirejs/require.js",

"jquery-mousewheel/jquery.mousewheel.js": "jquery-mousewheel/jquery.mousewheel.js",
Expand Down Expand Up @@ -421,13 +415,28 @@ grunt.initConfig( {
"jquery-3.6.0/jquery.js": "jquery-3.6.0/dist/jquery.js",
"jquery-3.6.0/LICENSE.txt": "jquery-3.6.0/LICENSE.txt",

"jquery-3.6.1/jquery.js": "jquery-3.6.1/dist/jquery.js",
"jquery-3.6.1/LICENSE.txt": "jquery-3.6.1/LICENSE.txt",

"jquery-3.6.2/jquery.js": "jquery-3.6.2/dist/jquery.js",
"jquery-3.6.2/LICENSE.txt": "jquery-3.6.2/LICENSE.txt",

"jquery-3.6.3/jquery.js": "jquery-3.6.3/dist/jquery.js",
"jquery-3.6.3/LICENSE.txt": "jquery-3.6.3/LICENSE.txt",

"jquery-3.6.4/jquery.js": "jquery-3.6.4/dist/jquery.js",
"jquery-3.6.4/LICENSE.txt": "jquery-3.6.4/LICENSE.txt",

"jquery-3.7.0/jquery.js": "jquery-3.7.0/dist/jquery.js",
"jquery-3.7.0/LICENSE.txt": "jquery-3.7.0/LICENSE.txt",

"jquery-migrate-1.4.1/jquery-migrate.js":
"jquery-migrate-1.4.1/dist/jquery-migrate.js",
"jquery-migrate-1.4.1/LICENSE.txt": "jquery-migrate-1.4.1/LICENSE.txt",

"jquery-migrate-3.3.2/jquery-migrate.js":
"jquery-migrate-3.3.2/dist/jquery-migrate.js",
"jquery-migrate-3.3.2/LICENSE.txt": "jquery-migrate-3.3.2/LICENSE.txt"
"jquery-migrate-3.4.1/jquery-migrate.js":
"jquery-migrate-3.4.1/dist/jquery-migrate.js",
"jquery-migrate-3.4.1/LICENSE.txt": "jquery-migrate-3.4.1/LICENSE.txt"
}
}
},
Expand Down Expand Up @@ -460,9 +469,22 @@ grunt.initConfig( {
}
} );

// grunt plugins
require( "load-grunt-tasks" )( grunt, {
pattern: nodeV16OrNewer ? [ "grunt-*" ] : [
"grunt-*",
"!grunt-contrib-qunit",
"!grunt-eslint",
"!grunt-html"
]
} );

// local testswarm and build tasks
grunt.loadTasks( "build/tasks" );

grunt.registerTask( "update-authors", function() {
var getAuthors = require( "grunt-git-authors" ).getAuthors,
done = this.async();
const getAuthors = require( "grunt-git-authors" ).getAuthors;
const done = this.async();

getAuthors( {
priorAuthors: grunt.config( "authors.prior" )
Expand Down Expand Up @@ -490,11 +512,21 @@ grunt.registerTask( "update-authors", function() {
} );
} );

grunt.registerTask( "print_old_node_message", ( ...args ) => {
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!
grunt.registerTask( "default", [ "lint", "requirejs", "test" ] );
grunt.registerTask( "jenkins", [ "default", "concat" ] );
grunt.registerTask( "lint", [ "asciilint", "eslint", "csslint", "htmllint" ] );
grunt.registerTask( "test", [ "qunit" ] );
grunt.registerTask( "lint", [
"asciilint",
runIfNewNode( "eslint" ),
"csslint",
runIfNewNode( "htmllint" )
] );
grunt.registerTask( "test", [ runIfNewNode( "qunit" ) ] );
grunt.registerTask( "sizer", [ "requirejs:js", "uglify:main", "compare_size:all" ] );
grunt.registerTask( "sizer_all", [ "requirejs:js", "uglify", "compare_size" ] );

Expand Down
Loading

0 comments on commit 15f4870

Please sign in to comment.