Skip to content

Commit

Permalink
Refactor the project
Browse files Browse the repository at this point in the history
* switch from JSHint to ESLint
* get rid of Grunt
* update most dependencies
* assume Node.js >=10, test on it instead of 0.10

Closes gh-101
  • Loading branch information
mgol authored Oct 10, 2019
1 parent a9823df commit 1ef3335
Show file tree
Hide file tree
Showing 140 changed files with 6,668 additions and 4,902 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__release/**
18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"root": true,

"extends": "jquery",

"parserOptions": {
"ecmaVersion": 2018
},

"env": {
"es6": true,
"node": true
},

"rules": {
"strict": [ "error", "global" ]
}
}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
node_modules/grunt
node_modules/grunt-contrib-jshint
test-*.sh
package-lock.json
16 changes: 0 additions & 16 deletions .jshintrc

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
language: node_js
node_js:
- "0.10"
before_script:
- npm install -g grunt-cli
- "10"
16 changes: 0 additions & 16 deletions Gruntfile.js

This file was deleted.

24 changes: 13 additions & 11 deletions lib/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
"use strict";

var fs = require( "fs" ),
path = require( "path" ),
semver = require( "semver" ),
which = require( "which" );

module.exports = function( Release ) {

Release.define({
Release.define( {
isTest: true,

_showUsage: function() {
console.log( fs.readFileSync( path.resolve( __dirname, "../docs/usage.txt" ), "utf8" ) );
},

_checkExecutables: function() {
[ "git", "npm", "grunt", "curl" ].forEach(function( command ) {
[ "git", "npm", "curl" ].forEach( function( command ) {
try {
which.sync( command );
} catch( e ) {
} catch ( e ) {
Release.abort( "Missing required executable: " + command );
}
});
} );
},

_parseArguments: function() {
Release.args = {};

process.argv.forEach(function( arg ) {
process.argv.forEach( function( arg ) {
var name, value,
matches = /--([^=]+)(=(.+))?/.exec( arg );

if ( matches ) {
name = matches[ 1 ].replace( /-([a-z])/gi, function( all, letter ) {
name = matches[ 1 ].replace( /-([a-z])/gi, function( _all, letter ) {
return letter.toUpperCase();
});
} );
value = matches[ 3 ] || true;
Release.args[ name ] = value;
}
});
} );

Release._parseRemote();
Release.branch = Release.args.branch || "master";
Expand All @@ -45,13 +47,13 @@ Release.define({
Release.isTest = true;
}

if ( Release.preRelease && !semver.valid( Release.preRelease) ) {
if ( Release.preRelease && !semver.valid( Release.preRelease ) ) {
Release.abort( "Invalid --pre-release argument, not valid semver: " +
Release.preRelease );
}

console.log();
console.log( "\tRelease type: " + (Release.preRelease ? "pre-release" : "stable") );
console.log( "\tRelease type: " + ( Release.preRelease ? "pre-release" : "stable" ) );
console.log( "\tRemote: " + Release.remote );
console.log( "\tBranch: " + Release.branch );
console.log();
Expand Down Expand Up @@ -98,6 +100,6 @@ Release.define({
console.log( "Creating directory..." );
fs.mkdirSync( Release.dir.base );
}
});
} );

};
15 changes: 9 additions & 6 deletions lib/cdn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var shell = require( "shelljs" ),
fs = require( "fs" ),
chalk = require( "chalk" );
Expand Down Expand Up @@ -29,7 +31,7 @@ module.exports = function( Release ) {
return jqueryCdn + "/" + project + "/" + Release.newVersion;
}

Release.define({
Release.define( {
cdnPublish: "dist/cdn",
_cloneCdnRepo: function() {
var local = Release.dir.base + "/codeorigin.jquery.com",
Expand All @@ -54,21 +56,22 @@ module.exports = function( Release ) {
commitMessage = npmPackage + ": Added version " + Release.newVersion;

Release.chdir( Release.dir.base );
console.log( "Copying files from " + chalk.cyan( releaseCdn ) + " to " + chalk.cyan( targetCdn ) + "." );
console.log( "Copying files from " + chalk.cyan( releaseCdn ) +
" to " + chalk.cyan( targetCdn ) + "." );
shell.mkdir( "-p", targetCdn );
shell.cp( "-r", releaseCdn + "/*", targetCdn );

console.log( "Adding files..." );
Release.chdir( targetCdn );
Release.exec( "git add ." , "Error adding files." );
Release.exec( "git commit -m \"" + commitMessage + "\"" , "Error commiting files." );
Release.exec( "git add .", "Error adding files." );
Release.exec( "git commit -m \"" + commitMessage + "\"", "Error commiting files." );
},

_pushToCdn: function() {
Release.chdir( projectCdn() );
Release.exec( "git push" + (Release.isTest ? " --dry-run" : ""),
Release.exec( "git push" + ( Release.isTest ? " --dry-run" : "" ),
"Error pushing to CDN." );
console.log();
}
});
} );
};
18 changes: 10 additions & 8 deletions lib/changelog.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"use strict";

var fs = require( "fs" ),
changelogplease = require( "changelogplease" ),
chalk = require( "chalk" );

module.exports = function( Release ) {

Release.define({
Release.define( {
_generateChangelog: function( callback ) {
Release._generateCommitChangelog(function( commitChangelog ) {
Release._generateIssueChangelog(function( issueChangelog ) {
Release._generateCommitChangelog( function( commitChangelog ) {
Release._generateIssueChangelog( function( issueChangelog ) {
var changelogPath = Release.dir.base + "/changelog",
changelog = Release.changelogShell() +
commitChangelog +
Expand All @@ -19,8 +21,8 @@ Release.define({
console.log( "Stored changelog in " + chalk.cyan( changelogPath ) + "." );

callback();
});
});
} );
} );
},

changelogShell: function() {
Expand All @@ -34,7 +36,7 @@ Release.define({
_generateCommitChangelog: function( callback ) {
console.log( "Adding commits..." );

changelogplease({
changelogplease( {
ticketUrl: Release._ticketUrl() + "{id}",
commitUrl: Release._repositoryUrl() + "/commit/{id}",
repo: Release.dir.repo,
Expand All @@ -45,14 +47,14 @@ Release.define({
}

callback( log );
});
} );
},

_generateIssueChangelog: function( callback ) {
return Release.issueTracker === "trac" ?
Release._generateTracChangelog( callback ) :
Release._generateGithubChangelog( callback );
}
});
} );

};
24 changes: 13 additions & 11 deletions lib/contributors.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
"use strict";

var fs = require( "fs" ),
chalk = require( "chalk" );

module.exports = function( Release ) {

function unique( arr ) {
var obj = {};
arr.forEach(function( item ) {
arr.forEach( function( item ) {
obj[ item ] = 1;
});
} );
return Object.keys( obj );
}

Release.define({
Release.define( {
_gatherContributors: function( callback ) {
var contributorsPath = Release.dir.base + "/contributors.txt";

console.log( "Adding reporters and commenters from issues..." );
Release._gatherIssueContributors(function( contributors ) {
Release._gatherIssueContributors( function( contributors ) {
console.log( "Adding committers and authors..." );
Release.chdir( Release.dir.repo );
contributors = contributors.concat( Release.gitLog( "%aN%n%cN" ) );

console.log( "Sorting contributors..." );
contributors = unique( contributors ).sort(function( a, b ) {
contributors = unique( contributors ).sort( function( a, b ) {
return a.toLowerCase() < b.toLowerCase() ? -1 : 1;
});
} );

console.log( "Adding people thanked in commits..." );
contributors = contributors.concat(
Release.gitLog( "%b%n%s" ).filter(function( line ) {
return (/thank/i).test( line );
}));
Release.gitLog( "%b%n%s" ).filter( function( line ) {
return ( /thank/i ).test( line );
} ) );

fs.writeFileSync( contributorsPath, contributors.join( "\n" ) );
console.log( "Stored contributors in " + chalk.cyan( contributorsPath ) + "." );

callback();
});
} );
},

_gatherIssueContributors: function( callback ) {
return Release.issueTracker === "trac" ?
Release._gatherTracContributors( callback ) :
Release._gatherGithubIssueContributors( callback );
}
});
} );

};
8 changes: 5 additions & 3 deletions lib/git.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"use strict";

module.exports = function( Release ) {

Release.define({
Release.define( {
gitLog: function( format ) {
var commitRange = Release.prevVersion + ".." + Release.newVersion,
gitLog = "git log --format=\"" + format + "\" " + commitRange,
result = Release.exec({
result = Release.exec( {
command: gitLog,
silent: true
}, "Error getting git log, command was: " + gitLog );
Expand All @@ -16,6 +18,6 @@ Release.define({

return result;
}
});
} );

};
Loading

0 comments on commit 1ef3335

Please sign in to comment.