Skip to content

Commit

Permalink
Upgrade: eslint-release@1.0.0 (refs #10631) (#10991)
Browse files Browse the repository at this point in the history
This upgrades `eslint-release` to 1.0.0. The new version of `eslint-release` has a separate "generate" and "publish" phase, to allow for a 2FA code to be supplied in between. As a side-effect, it's now possible to manually test most aspects of the release process (by running `npm run generate-release`) without actually publishing a release somewhere. In lieu of unit tests, this should make it easier to test changes to the release process, like this one.
  • Loading branch information
not-an-aardvark authored and kaicataldo committed Oct 19, 2018
1 parent 57ef0fd commit 2f87bb3
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -15,3 +15,4 @@ versions.json
/packages/**/node_modules
/.vscode
.sublimelinterrc
.eslint-release-info.json
96 changes: 51 additions & 45 deletions Makefile.js
Expand Up @@ -150,10 +150,11 @@ function execSilent(cmd) {
/**
* Generates a release blog post for eslint.org
* @param {Object} releaseInfo The release metadata.
* @param {string} [prereleaseMajorVersion] If this is a prerelease, the next major version after this prerelease
* @returns {void}
* @private
*/
function generateBlogPost(releaseInfo) {
function generateBlogPost(releaseInfo, prereleaseMajorVersion) {
const ruleList = ls("lib/rules")

// Strip the .js extension
Expand All @@ -166,7 +167,7 @@ function generateBlogPost(releaseInfo) {
*/
.sort((ruleA, ruleB) => ruleB.length - ruleA.length);

const renderContext = Object.assign({ prereleaseMajorVersion: null, ruleList }, releaseInfo);
const renderContext = Object.assign({ prereleaseMajorVersion, ruleList }, releaseInfo);

const output = ejs.render(cat("./templates/blogpost.md.ejs"), renderContext),
now = new Date(),
Expand Down Expand Up @@ -250,11 +251,12 @@ function generateRuleIndexPage(basedir) {
}

/**
* Commits the changes in the site and publishes them to GitHub.
* @param {string} [tag] The string to tag the commit with.
* Creates a git commit and tag in an adjacent `eslint.github.io` repository, without pushing it to
* the remote. This assumes that the repository has already been modified somehow (e.g. by adding a blogpost).
* @param {string} [tag] The string to tag the commit with
* @returns {void}
*/
function publishSite(tag) {
function commitSiteToGit(tag) {
const currentDir = pwd();

cd(SITE_DIR);
Expand All @@ -266,39 +268,53 @@ function publishSite(tag) {
}

exec("git fetch origin && git rebase origin/master");
exec("git push origin master --tags");
cd(currentDir);
}

/**
* Creates a release version tag and pushes to origin.
* @param {boolean} [ciRelease] Set to true to indicate this is a CI release.
* Publishes the changes in an adjacent `eslint.github.io` repository to the remote. The
* site should already have local commits (e.g. from running `commitSiteToGit`).
* @returns {void}
*/
function release(ciRelease) {
function publishSite() {
const currentDir = pwd();

cd(SITE_DIR);
exec("git push origin master --tags");
cd(currentDir);
}

const releaseInfo = ReleaseOps.release(null, ciRelease);
/**
* Updates the changelog, bumps the version number in package.json, creates a local git commit and tag,
* and generates the site in an adjacent `eslint.github.io` folder.
* @returns {void}
*/
function generateRelease() {
ReleaseOps.generateRelease();
const releaseInfo = JSON.parse(cat(".eslint-release-info.json"));

echo("Generating site");
target.gensite();
generateBlogPost(releaseInfo);
publishSite(`v${releaseInfo.version}`);
echo("Site has been published");

echo("Publishing to GitHub");
ReleaseOps.publishReleaseToGitHub(releaseInfo);
commitSiteToGit(`v${releaseInfo.version}`);
}

/**
* Creates a prerelease version tag and pushes to origin.
* Updates the changelog, bumps the version number in package.json, creates a local git commit and tag,
* and generates the site in an adjacent `eslint.github.io` folder.
* @param {string} prereleaseId The prerelease identifier (alpha, beta, etc.)
* @returns {void}
*/
function prerelease(prereleaseId) {

const releaseInfo = ReleaseOps.release(prereleaseId);
function generatePrerelease(prereleaseId) {
ReleaseOps.generateRelease(prereleaseId);
const releaseInfo = JSON.parse(cat(".eslint-release-info.json"));
const nextMajor = semver.inc(releaseInfo.version, "major");

echo("Generating site");

// always write docs into the next major directory (so 2.0.0-alpha.0 writes to 2.0.0)
target.gensite(nextMajor);

/*
* Premajor release should have identical "next major version".
* Preminor and prepatch release will not.
Expand All @@ -313,21 +329,23 @@ function prerelease(prereleaseId) {
* Blog post generation logic needs to be aware of this (as well as
* know what the next major version is actually supposed to be).
*/
releaseInfo.prereleaseMajorVersion = nextMajor;
generateBlogPost(releaseInfo, nextMajor);
} else {
generateBlogPost(releaseInfo);
}

echo("Generating site");

// always write docs into the next major directory (so 2.0.0-alpha.0 writes to 2.0.0)
target.gensite(nextMajor);
generateBlogPost(releaseInfo);
publishSite(`v${releaseInfo.version}`);
echo("Site has been published");

echo("Publishing to GitHub");
ReleaseOps.publishReleaseToGitHub(releaseInfo);
commitSiteToGit(`v${releaseInfo.version}`);
}

/**
* Publishes a generated release to npm and GitHub, and pushes changes to the adjacent `eslint.github.io` repo
* to remote repo.
* @returns {void}
*/
function publishRelease() {
ReleaseOps.publishRelease();
publishSite();
}

/**
* Splits a command result to separate lines.
Expand Down Expand Up @@ -1129,18 +1147,6 @@ target.perf = function() {
});
};

target.release = function() {
release();
};

target.ciRelease = function() {
release(true);
};

target.publishsite = function() {
publishSite();
};

target.prerelease = function(args) {
prerelease(args[0]);
};
target.generateRelease = generateRelease;
target.generatePrerelease = ([prereleaseType]) => generatePrerelease(prereleaseType);
target.publishRelease = publishRelease;
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -11,11 +11,11 @@
"test": "node Makefile.js test",
"lint": "node Makefile.js lint",
"fuzz": "node Makefile.js fuzz",
"release": "node Makefile.js release",
"ci-release": "node Makefile.js ciRelease",
"alpharelease": "node Makefile.js prerelease -- alpha",
"betarelease": "node Makefile.js prerelease -- beta",
"rcrelease": "node Makefile.js prerelease -- rc",
"generate-release": "node Makefile.js generateRelease",
"generate-alpharelease": "node Makefile.js generatePrerelease -- alpha",
"generate-betarelease": "node Makefile.js generatePrerelease -- beta",
"generate-rcrelease": "node Makefile.js generatePrerelease -- rc",
"publish-release": "node Makefile.js publishRelease",
"docs": "node Makefile.js docs",
"gensite": "node Makefile.js gensite",
"browserify": "node Makefile.js browserify",
Expand Down Expand Up @@ -90,7 +90,7 @@
"eslint-plugin-eslint-plugin": "^1.2.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-rulesdir": "^0.1.0",
"eslint-release": "^0.11.1",
"eslint-release": "^1.0.0",
"eslint-rule-composer": "^0.3.0",
"eslump": "^1.6.2",
"esprima": "^4.0.1",
Expand Down

0 comments on commit 2f87bb3

Please sign in to comment.