Skip to content

Commit af79c99

Browse files
authored
Build: migrate grunt authors to a custom script
- the new script pulls all authors from the Sizzle repo - added temporary grunt task for releases Close gh-5395
1 parent 88690eb commit af79c99

File tree

5 files changed

+146
-26
lines changed

5 files changed

+146
-26
lines changed

AUTHORS.txt

+31-15
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Michael Bensoussan <[email protected]>
3131
Louis-Rémi Babé <[email protected]>
3232
Robert Katić <[email protected]>
3333
Damian Janowski <[email protected]>
34-
Anton Kovalyov <[email protected]>
3534
Dušan B. Jovanovic <[email protected]>
3635
Earle Castledine <[email protected]>
3736
Rich Dougherty <[email protected]>
@@ -69,11 +68,11 @@ temp01 <[email protected]>
6968
Colin Snover <[email protected]>
7069
Jared Grippe <[email protected]>
7170
Ryan W Tenney <[email protected]>
72-
Alex Sexton <[email protected]>
7371
7472
Ron Otten <[email protected]>
7573
Jephte Clain <[email protected]>
7674
Anton Matzneller <[email protected]>
75+
Alex Sexton <[email protected]>
7776
Dan Heberden <[email protected]>
7877
Henri Wiechers <[email protected]>
7978
Russell Holbrook <[email protected]>
@@ -87,9 +86,10 @@ Sylvester Keil <[email protected]>
8786
Brandon Sterne <[email protected]>
8887
Mathias Bynens <[email protected]>
8988
Lee Carpenter <[email protected]>
90-
Timmy Willison <4timmywil@gmail.com>
89+
Timmy Willison <[email protected].com>
9190
Corey Frang <[email protected]>
9291
Digitalxero <digitalxero>
92+
Anton Kovalyov <[email protected]>
9393
David Murdoch <[email protected]>
9494
Josh Varner <[email protected]>
9595
Charles McNulty <[email protected]>
@@ -111,7 +111,7 @@ Mike Sherov <[email protected]>
111111
Greg Hazel <[email protected]>
112112
Schalk Neethling <[email protected]>
113113
Denis Knauf <[email protected]>
114-
Timo Tijhof <krinklemail@gmail.com>
114+
Timo Tijhof <krinkle@fastmail.com>
115115
Steen Nielsen <[email protected]>
116116
Anton Ryzhov <[email protected]>
117117
Shi Chuan <[email protected]>
@@ -151,7 +151,6 @@ Chris Faulkner <[email protected]>
151151
Marcel Greter <[email protected]>
152152
Elijah Manor <[email protected]>
153153
Daniel Chatfield <[email protected]>
154-
Daniel Gálvez <[email protected]>
155154
Nikita Govorov <[email protected]>
156155
Wesley Walser <[email protected]>
157156
Mike Pennisi <[email protected]>
@@ -162,9 +161,7 @@ Dave Riddle <[email protected]>
162161
Callum Macrae <[email protected]>
163162
Jonathan Sampson <[email protected]>
164163
Benjamin Truyman <[email protected]>
165-
Jay Merrifield <[email protected]>
166164
James Huston <[email protected]>
167-
Sai Lung Wong <[email protected]>
168165
Erick Ruiz de Chávez <[email protected]>
169166
David Bonner <[email protected]>
170167
Allen J Schmidt Jr <[email protected]>
@@ -174,8 +171,11 @@ Ismail Khair <[email protected]>
174171
Carl Danley <[email protected]>
175172
Mike Petrovich <[email protected]>
176173
Greg Lavallee <[email protected]>
174+
Daniel Gálvez <[email protected]>
175+
Sai Lung Wong <[email protected]>
177176
Tom H Fuertes <[email protected]>
178177
Roland Eckl <[email protected]>
178+
Jay Merrifield <[email protected]>
179179
Yiming He <[email protected]>
180180
David Fox <[email protected]>
181181
Bennett Sorbo <[email protected]>
@@ -192,17 +192,16 @@ Diego Tres <[email protected]>
192192
Jean Boussier <[email protected]>
193193
Andrew Plummer <[email protected]>
194194
Mark Raddatz <[email protected]>
195-
Pascal Borreli <[email protected]>
196195
Isaac Z. Schlueter <[email protected]>
197196
Karl Sieburg <[email protected]>
197+
Pascal Borreli <[email protected]>
198198
Nguyen Phuc Lam <[email protected]>
199199
Dmitry Gusev <[email protected]>
200200
Steven Benner <[email protected]>
201201
Li Xudong <[email protected]>
202202
Michał Gołębiowski-Owczarek <[email protected]>
203203
Renato Oliveira dos Santos <[email protected]>
204204
Frederic Junod <[email protected]>
205-
Tom H Fuertes <[email protected]>
206205
Mitch Foley <[email protected]>
207206
208207
Kyle Robinson Young <[email protected]>
@@ -250,7 +249,6 @@ Dan Hart <[email protected]>
250249
Nazar Mokrynskyi <[email protected]>
251250
Benjamin Tan <[email protected]>
252251
Amit Merchant <[email protected]>
253-
Jason Bedard <[email protected]>
254252
Veaceslav Grimalschi <[email protected]>
255253
Richard McDaniel <[email protected]>
256254
Arthur Verschaeve <[email protected]>
@@ -273,12 +271,12 @@ Jon Hester <[email protected]>
273271
Colin Frick <[email protected]>
274272
Winston Howes <[email protected]>
275273
Alexander O'Mara <[email protected]>
276-
Chris Rebert <[email protected]>
277274
Bastian Buchholz <[email protected]>
278275
Mu Haibao <[email protected]>
279276
Calvin Metcalf <[email protected]>
280277
Arthur Stolyar <[email protected]>
281278
Gabriel Schulhof <[email protected]>
279+
Chris Rebert <[email protected]>
282280
Gilad Peleg <[email protected]>
283281
Julian Alexander Murillo <[email protected]>
284282
Kevin Kirsche <[email protected]>
@@ -297,15 +295,14 @@ Christian Grete <[email protected]>
297295
Tom von Clef <[email protected]>
298296
Liza Ramo <[email protected]>
299297
Joelle Fleurantin <[email protected]>
300-
Steve Mao <[email protected]>
301298
Jon Dufresne <[email protected]>
302299
Jae Sung Park <[email protected]>
303300
Josh Soref <[email protected]>
304-
Saptak Sengupta <[email protected]>
305301
Henry Wong <[email protected]>
306302
307303
Martijn W. van der Lee <[email protected]>
308304
Devin Wilson <[email protected]>
305+
Steve Mao <[email protected]>
309306
Damian Senn <[email protected]>
310307
Zack Hall <[email protected]>
311308
Vitaliy Terziev <[email protected]>
@@ -336,6 +333,7 @@ Jordan Beland <[email protected]>
336333
Henry Zhu <[email protected]>
337334
Nilton Cesar <[email protected]>
338335
basil.belokon <[email protected]>
336+
Saptak Sengupta <[email protected]>
339337
Andrey Meshkov <[email protected]>
340338
341339
Luis Emilio Velasco Sanchez <[email protected]>
@@ -344,14 +342,32 @@ Bert Zhang <[email protected]>
344342
Sébastien Règne <[email protected]>
345343
346344
Siddharth Dungarwal <[email protected]>
347-
348345
Andrei Fangli <[email protected]>
349346
Marja Hölttä <[email protected]>
347+
350348
351349
350+
Sean Robinson <[email protected]>
352351
Wonseop Kim <[email protected]>
353352
Pat O'Callaghan <[email protected]>
354353
JuanMa Ruiz <[email protected]>
355354
Ahmed.S.ElAfifi <[email protected]>
356-
Sean Robinson <[email protected]>
357355
Christian Oliff <[email protected]>
356+
Christian Wenz <[email protected]>
357+
358+
Ed Sanders <[email protected]>
359+
Pierre Grimaud <[email protected]>
360+
Beatriz Rezener <[email protected]>
361+
Necmettin Karakaya <[email protected]>
362+
Wonhyoung Park <[email protected]>
363+
Dallas Fraser <[email protected]>
364+
365+
366+
367+
Bruno PIERRE <[email protected]>
368+
Simon Legner <[email protected]>
369+
Baoshuo Ren <[email protected]>
370+
Anders Kaseorg <[email protected]>
371+
372+
Gabriela Gutierrez <[email protected]>
373+
Dimitri Papadopoulos Orfanos <[email protected]>

Gruntfile.cjs

+8
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ module.exports = function( grunt ) {
209209
grunt.log.writeln( "Node.js 17 or newer detected, skipping jsdom tests..." );
210210
} );
211211

212+
grunt.registerTask( "authors", async function() {
213+
const done = this.async();
214+
const { getAuthors } = require( "./build/release/authors.js" );
215+
const authors = await getAuthors();
216+
console.log( authors.join( "\n" ) );
217+
done();
218+
} );
219+
212220
grunt.registerTask( "test:jsdom", [
213221

214222
// Support: Node.js 17+

build/release/authors.js

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"use strict";
2+
3+
const fs = require( "node:fs" );
4+
const util = require( "node:util" );
5+
const exec = util.promisify( require( "node:child_process" ).exec );
6+
const rnewline = /\r?\n/;
7+
const rdate = /^\[(\d+)\] /;
8+
9+
const ignore = [
10+
/dependabot\[bot\]/
11+
];
12+
13+
function compareAuthors( a, b ) {
14+
const aName = a.replace( rdate, "" ).replace( / <.*>/, "" );
15+
const bName = b.replace( rdate, "" ).replace( / <.*>/, "" );
16+
return aName === bName;
17+
}
18+
19+
function uniq( arr ) {
20+
const unique = [];
21+
for ( const item of arr ) {
22+
if ( ignore.some( re => re.test( item ) ) ) {
23+
continue;
24+
}
25+
if ( item && !unique.find( ( e ) => compareAuthors( e, item ) ) ) {
26+
unique.push( item );
27+
}
28+
}
29+
return unique;
30+
}
31+
32+
function cleanupSizzle() {
33+
console.log( "Cleaning up..." );
34+
return exec( "npx rimraf .sizzle" );
35+
}
36+
37+
function cloneSizzle() {
38+
console.log( "Cloning Sizzle..." );
39+
return exec( "git clone https://github.com/jquery/sizzle .sizzle" );
40+
}
41+
42+
async function getLastAuthor() {
43+
const authorsTxt = await fs.promises.readFile( "AUTHORS.txt", "utf8" );
44+
return authorsTxt.trim().split( rnewline ).pop();
45+
}
46+
47+
async function logAuthors( preCommand ) {
48+
let command = "git log --pretty=format:\"[%at] %aN <%aE>\"";
49+
if ( preCommand ) {
50+
command = `${ preCommand } && ${ command }`;
51+
}
52+
const { stdout } = await exec( command );
53+
return uniq( stdout.trim().split( rnewline ).reverse() );
54+
}
55+
56+
async function getSizzleAuthors() {
57+
await cloneSizzle();
58+
const authors = await logAuthors( "cd .sizzle" );
59+
await cleanupSizzle();
60+
return authors;
61+
}
62+
63+
function sortAuthors( a, b ) {
64+
const [ , aDate ] = rdate.exec( a );
65+
const [ , bDate ] = rdate.exec( b );
66+
return Number( aDate ) - Number( bDate );
67+
}
68+
69+
function formatAuthor( author ) {
70+
return author.replace( rdate, "" );
71+
}
72+
73+
async function getAuthors() {
74+
console.log( "Getting authors..." );
75+
const authors = await logAuthors();
76+
const sizzleAuthors = await getSizzleAuthors();
77+
return uniq( authors.concat( sizzleAuthors ) ).sort( sortAuthors ).map( formatAuthor );
78+
}
79+
80+
async function checkAuthors() {
81+
const authors = await getAuthors();
82+
const lastAuthor = await getLastAuthor();
83+
84+
if ( authors[ authors.length - 1 ] !== lastAuthor ) {
85+
console.log( "AUTHORS.txt: ", lastAuthor );
86+
console.log( "Last 20 in git: ", authors.slice( -20 ) );
87+
throw new Error( "Last author in AUTHORS.txt does not match last git author" );
88+
}
89+
console.log( "AUTHORS.txt is up to date" );
90+
}
91+
92+
async function updateAuthors() {
93+
const authors = await getAuthors();
94+
95+
const authorsTxt = "Authors ordered by first contribution.\n\n" + authors.join( "\n" ) + "\n";
96+
await fs.promises.writeFile( "AUTHORS.txt", authorsTxt );
97+
98+
console.log( "AUTHORS.txt updated" );
99+
}
100+
101+
module.exports = {
102+
checkAuthors,
103+
getAuthors,
104+
updateAuthors
105+
};

package-lock.json

-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
},
4040
"main": "dist/jquery.js",
4141
"scripts": {
42+
"authors:check": "node -e \"require('./build/release/authors.js').checkAuthors()\"",
43+
"authors:update": "node -e \"require('./build/release/authors.js').updateAuthors()\"",
4244
"babel:tests": "babel test/data/core/jquery-iterability-transpiled-es6.js --out-file test/data/core/jquery-iterability-transpiled.js",
4345
"build": "node ./build/command.js",
4446
"build:all": "node -e \"require('./build/tasks/build.js').buildDefaultFiles()\"",
@@ -101,7 +103,6 @@
101103
"globals": "13.20.0",
102104
"grunt": "1.5.3",
103105
"grunt-cli": "1.4.3",
104-
"grunt-git-authors": "3.2.0",
105106
"grunt-karma": "4.0.2",
106107
"husky": "8.0.3",
107108
"jsdom": "19.0.0",

0 commit comments

Comments
 (0)