From aee3f6f4d12480dd8cb7e1d42f5cf89fe88f638d Mon Sep 17 00:00:00 2001 From: Reyad Attiyat Date: Fri, 14 Apr 2017 17:47:55 -0500 Subject: [PATCH] Chore: Cleanup Makefile --- Makefile.js | 134 ++-------------------------------------------------- 1 file changed, 3 insertions(+), 131 deletions(-) diff --git a/Makefile.js b/Makefile.js index bf04bc5..823c651 100644 --- a/Makefile.js +++ b/Makefile.js @@ -4,7 +4,7 @@ * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ -/* global cat, cp, echo, exec, exit, find, mkdir, mv, rm, target, test */ +/* global echo, exit, find, target */ "use strict"; @@ -16,9 +16,7 @@ require("shelljs/make"); var checker = require("npm-license"), - dateformat = require("dateformat"), - nodeCLI = require("shelljs-nodecli"), - semver = require("semver"); + nodeCLI = require("shelljs-nodecli"); //------------------------------------------------------------------------------ // Settings @@ -33,8 +31,6 @@ var OPEN_SOURCE_LICENSES = [ //------------------------------------------------------------------------------ var NODE_MODULES = "./node_modules/", - TEMP_DIR = "./tmp/", - BUILD_DIR = "./build/", // Utilities - intentional extra space at the end of each string MOCHA = NODE_MODULES + "mocha/bin/_mocha ", @@ -42,7 +38,7 @@ var NODE_MODULES = "./node_modules/", // Files MAKEFILE = "./Makefile.js", /* eslint-disable no-use-before-define */ - JS_FILES = find("lib/").filter(fileType("js")).join(" ") + " espree.js", + JS_FILES = find("lib/").filter(fileType("js")).join(" ") + " parser.js", TEST_FILES = find("tests/lib/").filter(fileType("js")).join(" "); /* eslint-enable no-use-before-define */ @@ -62,64 +58,6 @@ function fileType(extension) { }; } -/** - * Executes a command and returns the output instead of printing it to stdout. - * @param {string} cmd The command string to execute. - * @returns {string} The result of the executed command. - */ -function execSilent(cmd) { - return exec(cmd, { silent: true }).output; -} - -/** - * Creates a release version tag and pushes to origin. - * @param {string} type The type of release to do (patch, minor, major) - * @returns {void} - */ -function release(type) { - var newVersion; - - target.test(); - newVersion = execSilent("npm version " + type).trim(); - target.changelog(); - - // add changelog to commit - exec("git add CHANGELOG.md"); - exec("git commit --amend --no-edit"); - - // replace existing tag - exec("git tag -f " + newVersion); - - // push all the things - exec("git push origin master --tags"); - exec("npm publish"); -} - - -/** - * Splits a command result to separate lines. - * @param {string} result The command result string. - * @returns {array} The separated lines. - */ -function splitCommandResultToLines(result) { - return result.trim().split("\n"); -} - -/** - * Returns a list of sorted, valid semtantic-verisioning git tags - * @returns {string[]} The version tags - */ -function getVersionTags() { - var tags = splitCommandResultToLines(exec("git tag", { silent: true }).output); - - return tags.reduce(function(list, tag) { - if (semver.valid(tag)) { - list.push(tag); - } - return list; - }, []).sort(semver.compare); -} - //------------------------------------------------------------------------------ // Tasks //------------------------------------------------------------------------------ @@ -180,60 +118,6 @@ target.docs = function() { echo("Documentation has been output to /jsdoc"); }; -target.browserify = function() { - - // 1. create temp and build directory - if (!test("-d", TEMP_DIR)) { - mkdir(TEMP_DIR); - mkdir(TEMP_DIR + "/lib"); - } - - if (!test("-d", BUILD_DIR)) { - mkdir(BUILD_DIR); - } - - // 2. copy files into temp directory - cp("-r", "lib/*", TEMP_DIR + "/lib"); - cp("espree.js", TEMP_DIR); - cp("package.json", TEMP_DIR); - - - // 3. browserify the temp directory - nodeCLI.exec("browserify", TEMP_DIR + "espree.js", "-o", BUILD_DIR + "espree.js", "-s espree"); - - // 4. remove temp directory - rm("-r", TEMP_DIR); -}; - -target.changelog = function() { - - // get most recent two tags - var tags = getVersionTags(), - rangeTags = tags.slice(tags.length - 2), - now = new Date(), - timestamp = dateformat(now, "mmmm d, yyyy"); - - // output header - (rangeTags[1] + " - " + timestamp + "\n").to("CHANGELOG.tmp"); - - // get log statements - var logs = exec("git log --pretty=format:\"* %s (%an)\" " + rangeTags.join(".."), {silent: true}).output.split(/\n/g); - logs = logs.filter(function(line) { - return line.indexOf("Merge pull request") === -1 && line.indexOf("Merge branch") === -1; - }); - logs.push(""); // to create empty lines - logs.unshift(""); - - // output log statements - logs.join("\n").toEnd("CHANGELOG.tmp"); - - // switch-o change-o - cat("CHANGELOG.tmp", "CHANGELOG.md").to("CHANGELOG.md.tmp"); - rm("CHANGELOG.tmp"); - rm("CHANGELOG.md"); - mv("CHANGELOG.md.tmp", "CHANGELOG.md"); -}; - target.checkLicenses = function() { /** @@ -283,15 +167,3 @@ target.checkLicenses = function() { } }); }; - -target.patch = function() { - release("patch"); -}; - -target.minor = function() { - release("minor"); -}; - -target.major = function() { - release("major"); -};