Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: eslint/eslint-release
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3d99f992d220ef23c00317d6eb56f29e28a61cd4
Choose a base ref
...
head repository: eslint/eslint-release
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ddc45780ef75014e44979489246f45b8ff4beece
Choose a head ref
  • 6 commits
  • 11 files changed
  • 5 contributors

Commits on Jun 22, 2019

  1. Verified

    This commit was signed with the committer’s verified signature.
    minborg Per-Ake Minborg
    Copy the full SHA
    8cde736 View commit details

Commits on Aug 12, 2019

  1. Upgrade: github-api@3.2.2 (#35)

    it fixes 1 vulnerability, reported by `npm audit`
    aladdin-add authored and platinumazure committed Aug 12, 2019
    Copy the full SHA
    13d962b View commit details

Commits on May 8, 2020

  1. Update: Major version changelogs include all prereleases (#37)

    * Update: Major version changelogs include all prereleases
    
    For a new stable release following a prerelease sequence, the changelog
    will include the commits for all of the prereleases going back to the
    last stable release. For example, given the following release sequence:
    
    - 6.7.8
    - 6.8.0
    - 7.0.0-alpha.0
    - 7.0.0-alpha.1
    - 7.0.0
    
    The `7.0.0` changelog will include all changes since 6.8.0, whereas the
    `7.0.0-alpha.1` changelog will include only changes since
    `7.0.0-alpha.0`.
    
    If we prefer to include all changes going back to the previous stable
    release even for prerelease changelogs, that's an easy change and
    actually simplifies the logic a bit.
    
    * Update comment about version tags
    btmills authored May 8, 2020
    Copy the full SHA
    3d05dc5 View commit details
  2. Fix: use global-import shelljs (#38)

    * Fix: use global-import shelljs
    
    * Add comment
    Kai Cataldo authored May 8, 2020
    Copy the full SHA
    d6439b3 View commit details
  3. Build: changelog update for 2.0.0

    ESLint Jenkins committed May 8, 2020
    Copy the full SHA
    420577e View commit details
  4. 2.0.0

    ESLint Jenkins committed May 8, 2020
    Copy the full SHA
    ddc4578 View commit details
Showing with 280 additions and 169 deletions.
  1. +2 −0 .eslintrc.yml
  2. +3 −4 .travis.yml
  3. +6 −0 CHANGELOG.md
  4. +3 −3 bin/eslint-generate-prerelease.js
  5. +1 −1 bin/eslint-generate-release.js
  6. +1 −1 bin/eslint-publish-release.js
  7. +111 −73 lib/release-ops.js
  8. +10 −13 lib/shell-ops.js
  9. +12 −11 package.json
  10. +92 −29 tests/lib/release-ops.js
  11. +39 −34 tests/lib/shell-ops.js
2 changes: 2 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env:
node: true
extends: "eslint-config-eslint"
rules:
no-console: 0
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: node_js
node_js:
- "4"
- "5"
- "6"
- "7"
- "8"
- "10"
- "12"
sudo: false
script: "npm test"
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v2.0.0 - May 8, 2020

* [`d6439b3`](https://github.com/eslint/eslint-release/commit/d6439b3bf4f2b6582253315a0f3e1c50401343f0) Fix: use global-import shelljs (#38) (Kai Cataldo)
* [`3d05dc5`](https://github.com/eslint/eslint-release/commit/3d05dc5a07238b4134172a512b3929369ea011f8) Update: Major version changelogs include all prereleases (#37) (Brandon Mills)
* [`13d962b`](https://github.com/eslint/eslint-release/commit/13d962b18ecabdab58a278133ce4ad0b95a0dbc5) Upgrade: github-api@3.2.2 (#35) (薛定谔的猫)
* [`8cde736`](https://github.com/eslint/eslint-release/commit/8cde736c5cdb4e9fe9cbc593e1d8f956633cfd8b) Breaking: require node >= 8.0 & upgrade eslint-config-eslint (#34) (薛定谔的猫)
v1.2.0 - November 9, 2018

* [`1f776d1`](https://github.com/eslint/eslint-release/commit/1f776d1b18bd8e0f03692fb2398b959d69171cd8) Update: avoid printing TOTP to output when publishing (#31) (Teddy Katz)
6 changes: 3 additions & 3 deletions bin/eslint-generate-prerelease.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
// Requirements
//------------------------------------------------------------------------------

var ReleaseOps = require("../lib/release-ops");
const ReleaseOps = require("../lib/release-ops");

//------------------------------------------------------------------------------
// Execution
@@ -23,13 +23,13 @@ var ReleaseOps = require("../lib/release-ops");
* Usage:
* $ eslint-generate-prerelease beta
*/
var args = process.argv.slice(2),
const args = process.argv.slice(2),
prereleaseId = (args.length ? args[0] : null);

// there must be a prerelease ID
if (!prereleaseId) {
console.log("Missing prerelease identifier (alpha, beta, rc, etc.).");
process.exit(1); // eslint-disable-line no-process-exit
process.exit(1); // eslint-disable-line no-process-exit
}

ReleaseOps.generateRelease(prereleaseId);
2 changes: 1 addition & 1 deletion bin/eslint-generate-release.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
// Requirements
//------------------------------------------------------------------------------

var ReleaseOps = require("../lib/release-ops");
const ReleaseOps = require("../lib/release-ops");

//------------------------------------------------------------------------------
// Execution
2 changes: 1 addition & 1 deletion bin/eslint-publish-release.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
// Requirements
//------------------------------------------------------------------------------

var ReleaseOps = require("../lib/release-ops");
const ReleaseOps = require("../lib/release-ops");

//------------------------------------------------------------------------------
// Execution
184 changes: 111 additions & 73 deletions lib/release-ops.js

Large diffs are not rendered by default.

23 changes: 10 additions & 13 deletions lib/shell-ops.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
// Requirements
//------------------------------------------------------------------------------

var path = require("path"),
const path = require("path"),
childProcess = require("child_process");

//------------------------------------------------------------------------------
@@ -28,15 +28,11 @@ module.exports = {
* @param {Object} [defaultEnv] The default environment object (mostly used for testing).
* @returns {Object} a modified environment object.
*/
getModifiedEnv: function(platform, defaultEnv) {

platform = platform || process.platform;
defaultEnv = defaultEnv || process.env;

var env = {},
getModifiedEnv(platform = process.platform, defaultEnv = process.env) {
const env = {},
pathSeparator = platform === "win32" ? ";" : ":";

Object.keys(defaultEnv).forEach(function(key) {
Object.keys(defaultEnv).forEach(key => {
env[key] = defaultEnv[key];
});

@@ -53,7 +49,7 @@ module.exports = {
* @returns {string} The result of the executed command.
* @private
*/
execSilent: function(cmd) {
execSilent(cmd) {
try {
return childProcess.execSync(cmd, {
cwd: process.cwd(),
@@ -73,9 +69,10 @@ module.exports = {
* @throws {Error} If the command exits with a nonzero exit code.
* @private
*/
exec: function(cmd) {
console.log("+ " + cmd.replace(/--otp=\d+/g, "--otp=(redacted)"));
var result = this.execSilent(cmd);
exec(cmd) {
console.log(`+ ${cmd.replace(/--otp=\d+/g, "--otp=(redacted)")}`);
const result = this.execSilent(cmd);

console.log(result);
},

@@ -85,7 +82,7 @@ module.exports = {
* @param {int} code The exit code.
* @returns {void}
*/
exit: function(code) {
exit(code) {
process.exit(code); // eslint-disable-line no-process-exit
}
};
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "eslint-release",
"version": "1.2.0",
"version": "2.0.0",
"description": "ESLint Release Tools",
"main": "./lib/release-ops",
"engines": {
"node": ">=0.12"
"node": ">=8.0.0"
},
"bin": {
"eslint-generate-release": "./bin/eslint-generate-release.js",
@@ -38,18 +38,19 @@
},
"homepage": "https://github.com/eslint/eslint-release#readme",
"devDependencies": {
"chai": "^3.4.1",
"eslint": "2.4.0",
"eslint-config-eslint": "^3.0.0",
"leche": "^2.1.1",
"mocha": "^2.3.4",
"chai": "^4.2.0",
"eslint": "^5.16.0",
"eslint-config-eslint": "^5.0.1",
"eslint-plugin-node": "^9.1.0",
"leche": "^2.3.0",
"mocha": "^6.1.4",
"sinon": "^1.17.2"
},
"dependencies": {
"dateformat": "^1.0.12",
"github-api": "2.3.0",
"dateformat": "^3.0.3",
"github-api": "^3.2.2",
"linefix": "^0.1.1",
"semver": "^5.1.0",
"shelljs": "^0.5.3"
"semver": "^6.1.1",
"shelljs": "^0.8.3"
}
}
121 changes: 92 additions & 29 deletions tests/lib/release-ops.js
Original file line number Diff line number Diff line change
@@ -11,17 +11,17 @@
// Requirements
//------------------------------------------------------------------------------

var assert = require("chai").assert,
const assert = require("chai").assert,
leche = require("leche"),
ReleaseOps = require("../../lib/release-ops");

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

describe("ReleaseOps", function() {
describe("ReleaseOps", () => {

describe("getPrereleaseVersion()", function() {
describe("getPrereleaseVersion()", () => {

leche.withData([
["1.0.0", "alpha", "major", "2.0.0-alpha.0"],
@@ -34,28 +34,61 @@ describe("ReleaseOps", function() {

["2.0.0-alpha.1", "beta", "patch", "2.0.0-beta.0"]

], function(version, prereleaseId, releaseType, expected) {
], (version, prereleaseId, releaseType, expected) => {

it("should return the correct next version", function() {
var result = ReleaseOps.getPrereleaseVersion(version, prereleaseId, releaseType);
assert.equal(result, expected);
it("should return the correct next version", () => {
const result = ReleaseOps.getPrereleaseVersion(version, prereleaseId, releaseType);

assert.strictEqual(result, expected);
});

});

});

describe("calculateReleaseFromGitLogs()", function() {
describe("getChangelogCommitRange", () => {

it("returns an empty string when there are no prior releases", () => {
const tags = [];
const range = ReleaseOps.getChangelogCommitRange(tags);

assert.strictEqual(range, "");
});

it("finds the most recent tag for normal releases", () => {
const tags = ["1.0.0", "1.0.1"];
const range = ReleaseOps.getChangelogCommitRange(tags);

assert.strictEqual(range, "1.0.1..HEAD");
});

it("finds the most recent tag for prereleases", () => {
const tags = ["1.0.0", "1.0.1", "2.0.0-alpha.0", "2.0.0-alpha.1"];
const range = ReleaseOps.getChangelogCommitRange(tags, "beta");

assert.strictEqual(range, "2.0.0-alpha.1..HEAD");
});

it("finds the last stable tag for a new stable following prereleases", () => {
const tags = ["1.0.0", "1.0.1", "2.0.0-alpha.0", "2.0.0-rc.0"];
const range = ReleaseOps.getChangelogCommitRange(tags);

assert.strictEqual(range, "1.0.1..HEAD");
});

});

describe("calculateReleaseFromGitLogs()", () => {

it("should create a patch release when only bug fixes are present", function() {
var logs = [
it("should create a patch release when only bug fixes are present", () => {
const logs = [
"* 5b4812a956935358bf6e48f4d75a9bc998b3fe41 Fix: Something (Foo Bar)",
"* 00a3526f3a6560e4f91d390725b9a70f5d974f89 Docs: Something else (foobar)",
"* 24b2fdb310b89d7aad134df7e8863a5e055ac63f Fix: Something else (Foo B. Baz)"
],
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs);

assert.deepEqual(releaseInfo, {
assert.deepStrictEqual(releaseInfo, {
version: "1.0.1",
type: "patch",
changelog: {
@@ -75,16 +108,16 @@ describe("ReleaseOps", function() {
});
});

it("should create a minor release when enhancements are present", function() {
var logs = [
it("should create a minor release when enhancements are present", () => {
const logs = [
"* 34d6f550b2c87e61a70cb201abd3eadebb370453 Fix: Something (Author Name)",
"* 5c5c361cc338d284cac6d170ab7e105e213e1307 Docs: Something else (authorname)",
"* bcdc618488d12184e32a7ba170b443450c3e9e48 Fix: Something else (First Last)",
"* 7e4ffad5c91e4f8a99a95955ec65c5dbe9ae1758 Update: Foo (dotstar)"
],
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs);

assert.deepEqual(releaseInfo, {
assert.deepStrictEqual(releaseInfo, {
version: "1.1.0",
type: "minor",
changelog: {
@@ -108,8 +141,8 @@ describe("ReleaseOps", function() {
});
});

it("should create a major release when breaking changes are present", function() {
var logs = [
it("should create a major release when breaking changes are present", () => {
const logs = [
"* 34d6f550b2c87e61a70cb201abd3eadebb370453 Fix: Something (githubhandle)",
"* 5c5c361cc338d284cac6d170ab7e105e213e1307 Docs: Something else (Committer Name)",
"* bcdc618488d12184e32a7ba170b443450c3e9e48 Fix: Something else (Abc D. Efg)",
@@ -118,7 +151,7 @@ describe("ReleaseOps", function() {
],
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs);

assert.deepEqual(releaseInfo, {
assert.deepStrictEqual(releaseInfo, {
version: "2.0.0",
type: "major",
changelog: {
@@ -146,8 +179,8 @@ describe("ReleaseOps", function() {
});
});

it("should disregard reverted commits", function() {
var logs = [
it("should disregard reverted commits", () => {
const logs = [
"* 34d6f550b2c87e61a70cb201abd3eadebb370453 Docs: Update something in the docs (githubhandle)",
"This is the body.",
"It has multiple lines.",
@@ -166,7 +199,7 @@ describe("ReleaseOps", function() {
],
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs);

assert.deepEqual(releaseInfo, {
assert.deepStrictEqual(releaseInfo, {
version: "1.0.1",
type: "patch",
changelog: {
@@ -185,8 +218,8 @@ describe("ReleaseOps", function() {
});
});

it("should create a prerelease when passed a prereleaseId", function() {
var logs = [
it("should create a prerelease when passed a prereleaseId", () => {
const logs = [
"* fbe463916e0b49bc55f37363bf577ee20e0b3da6 Fix: Something (githubhandle)",
"* 7de216285f4d2e96508e6faefd9d8357baaaaec0 Docs: Something else (Committer Name)",
"* cd06fd502d106d10821227fd2d2ff77f7332c100 Fix: Something else (Abc D. Efg)",
@@ -195,7 +228,7 @@ describe("ReleaseOps", function() {
],
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs, "alpha");

assert.deepEqual(releaseInfo, {
assert.deepStrictEqual(releaseInfo, {
version: "2.0.0-alpha.0",
type: "major",
changelog: {
@@ -223,15 +256,15 @@ describe("ReleaseOps", function() {
});
});

it("should create a prerelease when passed a prereleaseId and prerelease version", function() {
var logs = [
it("should create a prerelease when passed a prereleaseId and prerelease version", () => {
const logs = [
"* eda81fc28943d51377851295c5c09682496fb9ac Fix: Something (githubhandle)",
"* 0c07d6ac037076557e34d569cd0290e529b3318a Docs: Something else (Committer Name)",
"* 196d32dbfb7cb37b886e7c4ba0adff499c6b26ac Fix: Something else (Abc D. Efg)"
],
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("2.0.0-alpha.0", logs, "alpha");

assert.deepEqual(releaseInfo, {
assert.deepStrictEqual(releaseInfo, {
version: "2.0.0-alpha.1",
type: "patch",
changelog: {
@@ -251,15 +284,45 @@ describe("ReleaseOps", function() {
});
});

it("should gracefully handle unformatted commit messages", function() {
var logs = [
it("should create the next stable release following a prerelease", () => {
const logs = [
"* 7e8a43b2b6350e13a61858f33b4099c964cdd758 Breaking: Remove API (githubhandle)",
"* 0c07d6ac037076557e34d569cd0290e529b3318a Docs: Something else (Committer Name)",
"* 196d32dbfb7cb37b886e7c4ba0adff499c6b26ac Fix: Something else (Abc D. Efg)"
],
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("2.0.0-rc.0", logs);

assert.deepStrictEqual(releaseInfo, {
version: "2.0.0",
type: "major",
changelog: {
fix: [
"* [`196d32d`](https://github.com/eslint/eslint-release/commit/196d32dbfb7cb37b886e7c4ba0adff499c6b26ac) Fix: Something else (Abc D. Efg)"
],
docs: [
"* [`0c07d6a`](https://github.com/eslint/eslint-release/commit/0c07d6ac037076557e34d569cd0290e529b3318a) Docs: Something else (Committer Name)"
],
breaking: [
"* [`7e8a43b`](https://github.com/eslint/eslint-release/commit/7e8a43b2b6350e13a61858f33b4099c964cdd758) Breaking: Remove API (githubhandle)"
]
},
rawChangelog: [
"* [`7e8a43b`](https://github.com/eslint/eslint-release/commit/7e8a43b2b6350e13a61858f33b4099c964cdd758) Breaking: Remove API (githubhandle)",
"* [`0c07d6a`](https://github.com/eslint/eslint-release/commit/0c07d6ac037076557e34d569cd0290e529b3318a) Docs: Something else (Committer Name)",
"* [`196d32d`](https://github.com/eslint/eslint-release/commit/196d32dbfb7cb37b886e7c4ba0adff499c6b26ac) Fix: Something else (Abc D. Efg)"
].join("\n")
});
});

it("should gracefully handle unformatted commit messages", () => {
const logs = [
"* 70222e95932d3a391ac5717252e13b478d686ba9 0.4.0-alpha.4 (Nicholas C. Zakas)",
"* d52a55e0572fbef1b702abfeefab9f53ff36d121 Build: package.json and changelog update for 0.4.0-alpha.4 (Nicholas C. Zakas)",
"* 1934e59323448afd864acc1db712ef8ef730af1a Fix: Changelog output (Nicholas C. Zakas)"
],
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("0.4.0-alpha.4", logs, "alpha");

assert.deepEqual(releaseInfo, {
assert.deepStrictEqual(releaseInfo, {
version: "0.4.0-alpha.5",
type: "patch",
changelog: {
73 changes: 39 additions & 34 deletions tests/lib/shell-ops.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
// Requirements
//------------------------------------------------------------------------------

var assert = require("chai").assert,
const assert = require("chai").assert,
sinon = require("sinon"),
path = require("path"),
leche = require("leche"),
@@ -21,49 +21,51 @@ var assert = require("chai").assert,
// Tests
//------------------------------------------------------------------------------

describe("ShellOps", function() {
describe("ShellOps", () => {

var PATH = process.env.PATH,
const PATH = process.env.PATH,
NODE_MODULES_PATH = path.resolve("./node_modules/.bin");

describe("getModifiedEnv()", function() {
describe("getModifiedEnv()", () => {

it("should modify path correctly when on Windows", function() {
var env = ShellOps.getModifiedEnv("win32");
assert.equal(env.PATH, NODE_MODULES_PATH + ";" + PATH);
it("should modify path correctly when on Windows", () => {
const env = ShellOps.getModifiedEnv("win32");

assert.strictEqual(env.PATH, `${NODE_MODULES_PATH};${PATH}`);
});

leche.withData([
"darwin",
"freebsd",
"linux",
"sunos"
], function(platform) {
it("should modify path correctly when on Unix OS", function() {
var env = ShellOps.getModifiedEnv(platform);
assert.equal(env.PATH, NODE_MODULES_PATH + ":" + PATH);
], platform => {
it("should modify path correctly when on Unix OS", () => {
const env = ShellOps.getModifiedEnv(platform);

assert.strictEqual(env.PATH, `${NODE_MODULES_PATH}:${PATH}`);
});
});

});

describe("execSilent()", function() {
describe("execSilent()", () => {

var childProcess = require("child_process");
const childProcess = require("child_process");

var CMD = "foo bar baz",
ENV = ShellOps.getModifiedEnv(),
sandbox;
const CMD = "foo bar baz",
ENV = ShellOps.getModifiedEnv();
let sandbox;

beforeEach(function() {
beforeEach(() => {
sandbox = sinon.sandbox.create();
});

afterEach(function() {
afterEach(() => {
sandbox.verifyAndRestore();
});

it("should call execSync with cwd and modified environment", function() {
it("should call execSync with cwd and modified environment", () => {

sandbox.mock(childProcess)
.expects("execSync")
@@ -76,17 +78,19 @@ describe("ShellOps", function() {
ShellOps.execSilent(CMD);
});

it("should call execSync and pass through the return value", function() {
it("should call execSync and pass through the return value", () => {

sandbox.stub(childProcess, "execSync").returns("hi");

var result = ShellOps.execSilent(CMD);
assert.equal(result, "hi");
const result = ShellOps.execSilent(CMD);

assert.strictEqual(result, "hi");
});

it("should call exit with an exit code when execSync throws an error", function() {
it("should call exit with an exit code when execSync throws an error", () => {

const err = new Error("Boo!");

var err = new Error("Boo!");
err.output = [null, "Hi"];
err.status = 2;

@@ -97,23 +101,23 @@ describe("ShellOps", function() {

});

describe("exec()", function() {
describe("exec()", () => {

var childProcess = require("child_process");
const childProcess = require("child_process");

var CMD = "foo bar baz",
ENV = ShellOps.getModifiedEnv(),
sandbox;
const CMD = "foo bar baz",
ENV = ShellOps.getModifiedEnv();
let sandbox;

beforeEach(function() {
beforeEach(() => {
sandbox = sinon.sandbox.create();
});

afterEach(function() {
afterEach(() => {
sandbox.verifyAndRestore();
});

it("should call execSync with cwd and modified environment", function() {
it("should call execSync with cwd and modified environment", () => {

sandbox.mock(childProcess)
.expects("execSync")
@@ -126,9 +130,10 @@ describe("ShellOps", function() {
ShellOps.exec(CMD);
});

it("should exit with an exit code when execSync throws an error", function() {
it("should exit with an exit code when execSync throws an error", () => {

const err = new Error("Boo!");

var err = new Error("Boo!");
err.output = [null, "Hi"];
err.status = 2;