http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/nightly.js ---------------------------------------------------------------------- diff --git a/src/nightly.js b/src/nightly.js index b15f5ee..b43cc81 100644 --- a/src/nightly.js +++ b/src/nightly.js @@ -30,7 +30,7 @@ var fs = require('fs'); var path = require('path'); var repoclone = require('./repo-clone'); -module.exports = function*(argv) { +module.exports = function * (argv) { /** Specifies the default repos to build nightlies for */ var DEFAULT_NIGHTLY_REPOS = ['cli', 'lib', 'fetch', 'common', 'create', 'coho']; @@ -44,12 +44,12 @@ module.exports = function*(argv) { ) .options('pretend', { desc: 'Don\'t actually publish to npm, just print what would be run.', - type:'boolean' + type: 'boolean' }) - .default({ r: DEFAULT_NIGHTLY_REPOS}) + .default({ r: DEFAULT_NIGHTLY_REPOS }) .argv; - if(argv.h) { + if (argv.h) { optimist.showHelp(); process.exit(1); } @@ -64,7 +64,7 @@ module.exports = function*(argv) { // Update version in package.json and other respective files for every repo // and update dependencies to use nightly versions of packages to be released - yield repoutil.forEachRepo(reposToBuild, function*(repo) { + yield repoutil.forEachRepo(reposToBuild, function * (repo) { apputil.print('Updating ' + repo.id + ' version to ' + VERSIONS[repo.id]); yield versionutil.updateRepoVersion(repo, VERSIONS[repo.id], { commitChanges: false }); updateRepoDependencies(repo, VERSIONS); @@ -81,21 +81,21 @@ module.exports = function*(argv) { options.pretend = argv.pretend; options.r = reposToBuild.map(function (repo) { return repo.id; }); - //publish to npm under nightly tag + // publish to npm under nightly tag yield npmpublish.publishTag(options); }; -function* prepareRepos(repoNames) { +function * prepareRepos (repoNames) { // Clone and update required repos apputil.print('Cloning and updating required repositories...'); var reposToClone = flagutil.computeReposFromFlag(['tools'].concat(repoNames)); - yield repoclone.cloneRepos(reposToClone, /*silent=*/true); - yield repoupdate.updateRepos(reposToClone, /*silent=*/true); + yield repoclone.cloneRepos(reposToClone, /* silent= */true); + yield repoupdate.updateRepos(reposToClone, /* silent= */true); // Remove local changes and sync up with remote master apputil.print('Resetting repositories to "master" branches...'); var reposToUpdate = flagutil.computeReposFromFlag(repoNames); - yield repoutil.forEachRepo(reposToUpdate, function*() { + yield repoutil.forEachRepo(reposToUpdate, function * () { yield gitutil.gitClean(); yield gitutil.resetFromOrigin(); }); @@ -106,7 +106,7 @@ function* prepareRepos(repoNames) { * @param {Object} repo Current repo which dependencies need to be updated * @param {Object<String, String>} dependencies Map of package's id's and nightly versions */ -function updateRepoDependencies(repo, dependencies) { +function updateRepoDependencies (repo, dependencies) { var packageJSONPath = path.join(process.cwd(), 'package.json'); var packageJSON = JSON.parse(fs.readFileSync(packageJSONPath)); @@ -132,7 +132,7 @@ function updateRepoDependencies(repo, dependencies) { * @param SHA {String} String to use to generate nightly version * @returns {String} A newly generated nightly suffix */ -function getNightlySuffix(SHA) { +function getNightlySuffix (SHA) { var currentDate = new Date(); var nightlySuffix = '-nightly.' + currentDate.getUTCFullYear() + '.' + (currentDate.getUTCMonth() + 1) + '.' + currentDate.getUTCDate() + @@ -147,7 +147,7 @@ function getNightlySuffix(SHA) { * @param {Object[]} repos An array of cordova repos * @returns {Object} Mapped object */ -function* retrieveVersions(repos) { +function * retrieveVersions (repos) { var SHAJSON = yield retrieveSha(repos); return Object.keys(SHAJSON).reduce(function (result, repoId) {
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/npm-link.js ---------------------------------------------------------------------- diff --git a/src/npm-link.js b/src/npm-link.js index 539a5f1..d56f0e9 100644 --- a/src/npm-link.js +++ b/src/npm-link.js @@ -25,19 +25,19 @@ var flagutil = require('./flagutil'); var packman = 'npm'; -function *createLink(argv) { +function * createLink (argv) { var opt = flagutil.registerHelpFlag(optimist); argv = opt .usage('Does an npm-link of the modules that we publish. Ensures we are testing live versions of our own dependencies instead of the last published version.\n' + '\n' + 'Usage: $0 npm-link' + - 'Example usage: $0 npm-link --use-yarn\n' + 'Example usage: $0 npm-link --use-yarn\n' ) .options('use-yarn', { desc: 'Use the yarn package manager instead of npm', type: 'bool', default: false - }) + }) .argv; if (argv.h) { @@ -52,76 +52,76 @@ function *createLink(argv) { console.log('Using npm'); } - function npmLinkIn(linkedModule, installingModule) { - cdInto(installingModule); + function npmLinkIn (linkedModule, installingModule) { + cdInto(installingModule); // 'npm link' will automatically unbuild a non-linked module if it is present, // so don't need to explicitly 'rm -r' it first. - shelljs.exec(packman + " link " + linkedModule); - cdOutOf(); + shelljs.exec(packman + ' link ' + linkedModule); + cdOutOf(); } - function npmLinkOut(moduleName) { + function npmLinkOut (moduleName) { cdInto(moduleName); - shelljs.exec(packman + " link"); + shelljs.exec(packman + ' link'); cdOutOf(); } - console.log("npm-linking dependent modules"); + console.log('npm-linking dependent modules'); // Do npm-link - npmLinkOut("cordova-cli"); - npmLinkOut("cordova-common"); - npmLinkOut("cordova-create"); - npmLinkOut("cordova-fetch"); - npmLinkOut("cordova-js"); - npmLinkOut("cordova-lib"); - npmLinkOut("cordova-plugman"); - npmLinkOut("cordova-serve"); + npmLinkOut('cordova-cli'); + npmLinkOut('cordova-common'); + npmLinkOut('cordova-create'); + npmLinkOut('cordova-fetch'); + npmLinkOut('cordova-js'); + npmLinkOut('cordova-lib'); + npmLinkOut('cordova-plugman'); + npmLinkOut('cordova-serve'); // Do npm-link <module> in cordova-fetch - npmLinkIn("cordova-common", "cordova-fetch"); - + npmLinkIn('cordova-common', 'cordova-fetch'); + // Do npm-link <module> in cordova-create - npmLinkIn("cordova-common", "cordova-create"); - npmLinkIn("cordova-fetch", "cordova-create"); - + npmLinkIn('cordova-common', 'cordova-create'); + npmLinkIn('cordova-fetch', 'cordova-create'); + // Do npm-link <module> in cordova-lib - npmLinkIn("cordova-common", "cordova-lib"); - npmLinkIn("cordova-create", "cordova-lib"); - npmLinkIn("cordova-fetch", "cordova-lib"); - npmLinkIn("cordova-js", "cordova-lib"); - npmLinkIn("cordova-serve", "cordova-lib"); + npmLinkIn('cordova-common', 'cordova-lib'); + npmLinkIn('cordova-create', 'cordova-lib'); + npmLinkIn('cordova-fetch', 'cordova-lib'); + npmLinkIn('cordova-js', 'cordova-lib'); + npmLinkIn('cordova-serve', 'cordova-lib'); // Do npm-link <module> in cordova-cli - npmLinkIn("cordova-common", "cordova-cli"); - npmLinkIn("cordova-create", "cordova-cli"); - npmLinkIn("cordova-fetch", "cordova-cli"); - npmLinkIn("cordova-js", "cordova-cli"); - npmLinkIn("cordova-lib", "cordova-cli"); - npmLinkIn("cordova-serve", "cordova-cli"); + npmLinkIn('cordova-common', 'cordova-cli'); + npmLinkIn('cordova-create', 'cordova-cli'); + npmLinkIn('cordova-fetch', 'cordova-cli'); + npmLinkIn('cordova-js', 'cordova-cli'); + npmLinkIn('cordova-lib', 'cordova-cli'); + npmLinkIn('cordova-serve', 'cordova-cli'); // Do npm-link <module> in cordova-plugman - npmLinkIn("cordova-common", "cordova-plugman"); - npmLinkIn("cordova-create", "cordova-plugman"); - npmLinkIn("cordova-fetch", "cordova-plugman"); - npmLinkIn("cordova-js", "cordova-plugman"); - npmLinkIn("cordova-lib", "cordova-plugman"); - npmLinkIn("cordova-serve", "cordova-plugman"); + npmLinkIn('cordova-common', 'cordova-plugman'); + npmLinkIn('cordova-create', 'cordova-plugman'); + npmLinkIn('cordova-fetch', 'cordova-plugman'); + npmLinkIn('cordova-js', 'cordova-plugman'); + npmLinkIn('cordova-lib', 'cordova-plugman'); + npmLinkIn('cordova-serve', 'cordova-plugman'); } module.exports = createLink; -function cdInto(moduleName) { +function cdInto (moduleName) { shelljs.pushd(moduleName); } -function cdOutOf() { +function cdOutOf () { shelljs.popd(); } function verifyLink (linkedModule, installedModule) { cdInto(installedModule); - var linkedPath = path.join(shelljs.pwd(), "node_modules", linkedModule); + var linkedPath = path.join(shelljs.pwd(), 'node_modules', linkedModule); if (!fs.existsSync(linkedPath)) { return false; } http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/npm-publish.js ---------------------------------------------------------------------- diff --git a/src/npm-publish.js b/src/npm-publish.js index 7267bcb..f377d6b 100644 --- a/src/npm-publish.js +++ b/src/npm-publish.js @@ -18,30 +18,28 @@ under the License. */ var optimist = require('optimist'); -var apputil = require('./apputil'); var flagutil = require('./flagutil'); var repoutil = require('./repoutil'); var executil = require('./executil'); -var print = apputil.print; -function *publishTag(options) { +function * publishTag (options) { var opt = flagutil.registerHelpFlag(optimist); - //argv was passed through another function, set defaults to appease demand. - if(options) { + // argv was passed through another function, set defaults to appease demand. + if (options) { opt = opt .options('tag', { - default:options.tag + default: options.tag }) - .options('r', { - default:options.r + .options('r', { + default: options.r }) .options('pretend', { - default:options.pretend - }) + default: options.pretend + }); } - argv = opt + argv = opt // eslint-disable-line no-undef .usage('Publishes current version of a repo to a specified npm tag. \n' + 'Usage: $0 npm-publish --tag rc -r cli -r lib') .options('tag', { @@ -51,69 +49,69 @@ function *publishTag(options) { .options('r', { alias: 'repos', desc: 'Which repo(s) to publish', - demand:true + demand: true }) .options('pretend', { desc: 'Don\'t actually run commands, just print what would be run.', - type:'boolean' + type: 'boolean' }) .argv; - if(argv.h) { - optimist.showHelp(); + if (argv.h) { // eslint-disable-line no-undef + optimist.showHelp(); // eslint-disable-line no-undef process.exit(1); } - var repos = flagutil.computeReposFromFlag(argv.r, { includeModules: true }); + var repos = flagutil.computeReposFromFlag(argv.r, { includeModules: true }); // eslint-disable-line no-undef - //npm publish --tag argv.tag - yield repoutil.forEachRepo(repos, function*(repo) { - yield executil.execOrPretend(executil.ARGS('npm publish --tag ' + argv.tag), argv.pretend); + // npm publish --tag argv.tag + yield repoutil.forEachRepo(repos, function * (repo) { + yield executil.execOrPretend(executil.ARGS('npm publish --tag ' + argv.tag), argv.pretend); // eslint-disable-line no-undef }); } module.exports.publishTag = publishTag; -//Gets last nightly tag and unpublishes it -function *unpublishNightly(options) { +// Gets last nightly tag and unpublishes it +function * unpublishNightly (options) { var opt = flagutil.registerHelpFlag(optimist); - if(options) { + if (options) { opt = opt .options('pretend', { - default:options.pretend + default: options.pretend }) .options('r', { - default:options.r - }) + default: options.r + }); } var argv = opt - .usage("Unpublishes the nightly version for the cli & lib from npm \n" + - "Usage: $0 npm-unpublish-nightly") - .options("pretend", { + .usage('Unpublishes the nightly version for the cli & lib from npm \n' + + 'Usage: $0 npm-unpublish-nightly') + .options('pretend', { desc: "Don't actually run commands, just print what would be run", - type: "boolean" + type: 'boolean' }) .options('r', { - desc: "Which repo(s) to unpublish", + desc: 'Which repo(s) to unpublish', demand: true }) .argv; - if(argv.h) { + if (argv.h) { optimist.showHelp(); process.exit(1); } var repos = flagutil.computeReposFromFlag(argv.r); - yield repoutil.forEachRepo(repos, function*(repo) { + yield repoutil.forEachRepo(repos, function * (repo) { var packageId = repo.packageName || repo.repoName; var oldNightlyVersion = yield executil.execHelper(executil.ARGS('npm view ' + packageId + ' dist-tags.nightly')); if (oldNightlyVersion && oldNightlyVersion !== 'undefined') { - yield executil.execOrPretend(executil.ARGS('npm unpublish '+ packageId + '@' + oldNightlyVersion), argv.pretend); + yield executil.execOrPretend(executil.ARGS('npm unpublish ' + packageId + '@' + oldNightlyVersion), argv.pretend); } }); } http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/platform-release.js ---------------------------------------------------------------------- diff --git a/src/platform-release.js b/src/platform-release.js index 123aeb1..9982c32 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -31,7 +31,7 @@ var repoupdate = require('./repo-update'); var versionutil = require('./versionutil'); var print = apputil.print; -function createPlatformDevVersion(version) { +function createPlatformDevVersion (version) { // e.g. "3.1.0" -> "3.2.0-dev". // e.g. "3.1.2-0.8.0-rc2" -> "3.2.0-0.8.0-dev". version = version.replace(/-rc.*$/, ''); @@ -43,7 +43,7 @@ function createPlatformDevVersion(version) { return parts.join('.') + '-dev'; } -function cpAndLog(src, dest) { +function cpAndLog (src, dest) { print('Coping File:', src, '->', dest); // Throws upon failure. shelljs.cp('-f', src, dest); @@ -52,7 +52,7 @@ function cpAndLog(src, dest) { } } -/* +/* * A function that handles version if it is defined or undefined * * @param {String} repo current repo @@ -64,17 +64,17 @@ function cpAndLog(src, dest) { */ // TODO: if using this method to only retrieve repo version, use the new // versionutil.getRepoVersion method. -function *handleVersion(repo,ver,validate) { - var platform = repo.id; +function * handleVersion (repo, ver, validate) { + var platform = repo.id; // eslint-disable-line no-unused-vars var version = ver || undefined; if (version === undefined) { - yield repoutil.forEachRepo([repo], function*() { + yield repoutil.forEachRepo([repo], function * () { // Grabbing version from platformPackageJson var platformPackage = path.join(process.cwd(), 'package.json'); var platformPackageJson = require(platformPackage); - if(validate === true) { - version = flagutil.validateVersionString(platformPackageJson.version); + if (validate === true) { + version = flagutil.validateVersionString(platformPackageJson.version); } else { version = platformPackageJson.version; } @@ -83,13 +83,14 @@ function *handleVersion(repo,ver,validate) { return version; } -function configureReleaseCommandFlags(opt) { - var opt = flagutil.registerRepoFlag(opt) +function configureReleaseCommandFlags (opt) { + var opt = flagutil.registerRepoFlag(opt); // eslint-disable-line no-redeclare opt = opt .options('version', { desc: 'The version to use for the branch. Must match the pattern #.#.#[-rc#]' - }); + }); opt = flagutil.registerHelpFlag(opt); + /* eslint-disable no-undef */ argv = opt.argv; if (argv.h) { @@ -99,25 +100,25 @@ function configureReleaseCommandFlags(opt) { return argv; } - +/* eslint-enable no-undef */ var hasBuiltJs = ''; -//Adds the version to CDVAvailability.h for iOS -function *updateCDVAvailabilityFile(version) { - var iosFile = path.join(process.cwd(), 'CordovaLib', 'Classes', 'Public','CDVAvailability.h'); +// Adds the version to CDVAvailability.h for iOS +function * updateCDVAvailabilityFile (version) { + var iosFile = path.join(process.cwd(), 'CordovaLib', 'Classes', 'Public', 'CDVAvailability.h'); var iosFileContents = fs.readFileSync(iosFile, 'utf8'); iosFileContents = iosFileContents.split('\n'); var lineNumberToInsertLine = iosFileContents.indexOf('/* coho:next-version,insert-before */'); var lineNumberToReplaceLine = iosFileContents.indexOf(' /* coho:next-version-min-required,replace-after */') + 2; - + var versionNumberUnderscores = version.split('.').join('_'); var versionNumberZeroes = version.split('.').join('0'); var lineToAdd = util.format('#define __CORDOVA_%s %s', versionNumberUnderscores, versionNumberZeroes); var lineToReplace = util.format(' #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_%s', versionNumberUnderscores); - if(iosFileContents[lineNumberToInsertLine - 1] === lineToAdd) { + if (iosFileContents[lineNumberToInsertLine - 1] === lineToAdd) { print('Version already exists in CDVAvailability.h'); lineNumberToReplaceLine = lineNumberToReplaceLine - 1; } else { @@ -129,46 +130,46 @@ function *updateCDVAvailabilityFile(version) { fs.writeFileSync(iosFile, iosFileContents.join('\n')); } -function *updateJsSnapshot(repo, version, commit) { - function *ensureJsIsBuilt() { +function * updateJsSnapshot (repo, version, commit) { + function * ensureJsIsBuilt () { var cordovaJsRepo = repoutil.getRepoById('js'); if (repo.id === 'blackberry') { repo.id = 'blackberry10'; } - if (hasBuiltJs != version) { - yield repoutil.forEachRepo([cordovaJsRepo], function*() { - yield gitutil.stashAndPop(cordovaJsRepo, function*() { - //git fetch and update master for cordovajs + if (hasBuiltJs !== version) { + yield repoutil.forEachRepo([cordovaJsRepo], function * () { + yield gitutil.stashAndPop(cordovaJsRepo, function * () { + // git fetch and update master for cordovajs yield repoupdate.updateRepos([cordovaJsRepo], ['master'], false); yield gitutil.gitCheckout('master'); - yield executil.execHelper(executil.ARGS('grunt compile:' +repo.id + ' --platformVersion='+version), false, true); + yield executil.execHelper(executil.ARGS('grunt compile:' + repo.id + ' --platformVersion=' + version), false, true); hasBuiltJs = version; }); }); } } - if (repoutil.repoGroups.platform.indexOf(repo) == -1) { + if (repoutil.repoGroups.platform.indexOf(repo) === -1) { return; } if (repo.cordovaJsPaths) { yield ensureJsIsBuilt(); - repo.cordovaJsPaths.forEach(function(jsPath) { + repo.cordovaJsPaths.forEach(function (jsPath) { var src = path.join('..', 'cordova-js', 'pkg', repo.cordovaJsSrcName || ('cordova.' + repo.id + '.js')); cpAndLog(src, jsPath); }); - if(commit === true) { + if (commit === true) { if (yield gitutil.pendingChangesExist()) { yield executil.execHelper(executil.ARGS('git commit -am', 'Update JS snapshot to version ' + version + ' (via coho)')); - } - } - } else if (repoutil.repoGroups.all.indexOf(repo) != -1) { + } + } + } else if (repoutil.repoGroups.all.indexOf(repo) !== -1) { print('*** DO NOT KNOW HOW TO UPDATE cordova.js FOR THIS REPO ***'); } } -exports.createAndCopyCordovaJSCommand = function*() { +exports.createAndCopyCordovaJSCommand = function * () { var argv = configureReleaseCommandFlags(optimist .usage('Generates and copies an updated cordova.js to the specified platform. It does the following:\n' + ' 1. Generates a new cordova.js.\n' + @@ -178,13 +179,13 @@ exports.createAndCopyCordovaJSCommand = function*() { ); var repos = flagutil.computeReposFromFlag(argv.r); - yield repoutil.forEachRepo(repos, function*(repo) { + yield repoutil.forEachRepo(repos, function * (repo) { var version = yield handleVersion(repo, argv.version, false); - yield updateJsSnapshot(repo,version, false); + yield updateJsSnapshot(repo, version, false); }); -} - -exports.prepareReleaseBranchCommand = function*() { +}; + +exports.prepareReleaseBranchCommand = function * () { var argv = configureReleaseCommandFlags(optimist .usage('Prepares release branches but does not create tags. This includes:\n' + ' 1. Creating the branch if it doesn\'t already exist\n' + @@ -205,19 +206,19 @@ exports.prepareReleaseBranchCommand = function*() { // First - perform precondition checks. yield repoupdate.updateRepos(repos, [], true); - yield repoutil.forEachRepo(repos, function*(repo) { + yield repoutil.forEachRepo(repos, function * (repo) { var platform = repo.id; - var version = yield handleVersion(repo, argv.version,true); + var version = yield handleVersion(repo, argv.version, true); var branchName = versionutil.getReleaseBranchNameFromVersion(version); - yield gitutil.stashAndPop(repo, function*() { + yield gitutil.stashAndPop(repo, function * () { // git fetch + update master yield repoupdate.updateRepos([repo], ['master'], false); if (platform === 'ios') { // Updates version in CDVAvailability.h file yield updateCDVAvailabilityFile(version); // Git commit changes - if(yield gitutil.pendingChangesExist()) { + if (yield gitutil.pendingChangesExist()) { yield executil.execHelper(executil.ARGS('git commit -am', 'Added ' + version + ' to CDVAvailability.h (via coho).')); } } @@ -233,7 +234,7 @@ exports.prepareReleaseBranchCommand = function*() { yield gitutil.gitCheckout('master'); yield executil.execHelper(executil.ARGS('git checkout -b ' + branchName)); } - + yield updateJsSnapshot(repo, version, true); print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + branchName + '".'); yield versionutil.updateRepoVersion(repo, version); @@ -247,21 +248,21 @@ exports.prepareReleaseBranchCommand = function*() { }); }); executil.reportGitPushResult(repos, ['master', branchName]); -} +}; -function *tagJs(repo, version, pretend) { +function * tagJs (repo, version, pretend) { - function *execOrPretend(cmd) { + function * execOrPretend (cmd) { if (pretend) { print('PRETENDING TO RUN: ' + cmd.join(' ')); } else { yield executil.execHelper(cmd); } } - //tag cordova.js platform-version + // tag cordova.js platform-version var cordovaJsRepo = repoutil.getRepoById('js'); - yield repoutil.forEachRepo([cordovaJsRepo], function*() { - yield gitutil.stashAndPop(cordovaJsRepo, function*() { + yield repoutil.forEachRepo([cordovaJsRepo], function * () { + yield gitutil.stashAndPop(cordovaJsRepo, function * () { // git fetch yield repoupdate.updateRepos([cordovaJsRepo], ['master'], false); @@ -276,15 +277,15 @@ function *tagJs(repo, version, pretend) { }); } -exports.tagReleaseBranchCommand = function*(argv) { - var argv = configureReleaseCommandFlags(optimist +exports.tagReleaseBranchCommand = function * (argv) { + var argv = configureReleaseCommandFlags(optimist // eslint-disable-line .usage('Tags a release branches.\n' + '\n' + 'Usage: $0 tag-release --version=2.8.0-rc1 -r platform') .options('pretend', { desc: 'Don\'t actually run git commands, just print out what would be run.', type: 'boolean' - }) + }) ); var repos = flagutil.computeReposFromFlag(argv.r); var version = flagutil.validateVersionString(argv.version); @@ -294,15 +295,15 @@ exports.tagReleaseBranchCommand = function*(argv) { // First - perform precondition checks. yield repoupdate.updateRepos(repos, [], true); - function *execOrPretend(cmd) { + function * execOrPretend (cmd) { if (pretend) { print('PRETENDING TO RUN: ' + cmd.join(' ')); } else { yield executil.execHelper(cmd); } } - yield repoutil.forEachRepo(repos, function*(repo) { - yield gitutil.stashAndPop(repo, function*() { + yield repoutil.forEachRepo(repos, function * (repo) { + yield gitutil.stashAndPop(repo, function * () { // git fetch. yield repoupdate.updateRepos([repo], [], false); @@ -318,7 +319,7 @@ exports.tagReleaseBranchCommand = function*(argv) { // Create/update the tag. var tagName = yield gitutil.retrieveCurrentTagName(); - if (tagName != version) { + if (tagName !== version) { if (yield gitutil.tagExists(version)) { yield execOrPretend(executil.ARGS('git tag ' + version + ' --force')); } else { @@ -335,4 +336,4 @@ exports.tagReleaseBranchCommand = function*(argv) { print(''); print('All work complete.'); -} +}; http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/plugin-release.js ---------------------------------------------------------------------- diff --git a/src/plugin-release.js b/src/plugin-release.js index 1a5bc16..355ce31 100644 --- a/src/plugin-release.js +++ b/src/plugin-release.js @@ -22,8 +22,6 @@ var Q = require('q'); var glob = require('glob'); var path = require('path'); var fs = require('fs'); -var util = require('util'); -var optimist = require('optimist'); var shelljs = require('shelljs'); var apputil = require('./apputil'); var audit_license = require('./audit-license-headers'); @@ -41,8 +39,6 @@ var reporeset = require('./repo-reset'); var jira_client = require('jira-client'); var inquirer = require('inquirer'); var semver = require('semver'); -var linkify = require('jira-linkify'); -var print = apputil.print; /* * Pseudo code for plugin automation: @@ -53,7 +49,9 @@ var you; // store label for the user here var jira_user; // store ref to jira project user var cordova_project; // store ref to jira project for Cordova var plugins_release_issue; // store ref to jira issue tracking release. +/* eslint-disable no-unused-vars */ var jira_issue_types; // store ref to all issue types supported by our JIRA instance +/* eslint-enable no-unused-vars */ var all_plugins_component; // store the specific component associated to the plugin issue. var jira_task_issue; // store ref to the "task" issue type var plugin_base; // parent directory holding all cordova plugins @@ -70,26 +68,26 @@ var svn_password; // password for apache svn var updated_repos; // sentinel variable for if we did repo updates var created_distdev_dir; // sentinel var for if a new dir was created in cordova-dist-dev -function *updateDesiredRepos(repos) { +function * updateDesiredRepos (repos) { if (!updated_repos) { updated_repos = true; - yield repoclone.cloneRepos(repos, /*silent*/true, null); + yield repoclone.cloneRepos(repos, /* silent */true, null); yield reporeset.resetRepos(repos, ['master']); - yield repoupdate.updateRepos(repos, ['master'], /*noFetch*/false); - yield repoclone.cloneRepos(svn_repos, /*silent*/true, null); + yield repoupdate.updateRepos(repos, ['master'], /* noFetch */false); + yield repoclone.cloneRepos(svn_repos, /* silent */true, null); yield findChangesInPluginRepos(repos); } } -function *findChangesInPluginRepos(repos) { - yield repoutil.forEachRepo(repos, function*(repo) { - if (repo.repoName == 'cordova-plugins') return; +function * findChangesInPluginRepos (repos) { + yield repoutil.forEachRepo(repos, function * (repo) { + if (repo.repoName === 'cordova-plugins') return; var last_release = (yield gitutil.findMostRecentTag())[0]; plugin_data[repo.repoName] = { last_release: last_release }; var changes = yield gitutil.summaryOfChanges(last_release); - changes = changes.split('\n').filter(function(line) { - return (line.toLowerCase().indexOf('incremented plugin version') == -1); + changes = changes.split('\n').filter(function (line) { + return (line.toLowerCase().indexOf('incremented plugin version') === -1); }); if (changes.length > 0) { plugin_data[repo.repoName].needs_release = true; @@ -102,18 +100,18 @@ function *findChangesInPluginRepos(repos) { }); } -function manualPluginSelection() { +function manualPluginSelection () { return inquirer.prompt({ type: 'checkbox', name: 'plugins_list', message: 'Select the plugins you want to release:', - choices: plugin_repos.map(function(p) { return p.repoName; }).filter(function(p) { return p != 'cordova-plugins'; }) - }).then(function(answer) { + choices: plugin_repos.map(function (p) { return p.repoName; }).filter(function (p) { return p !== 'cordova-plugins'; }) + }).then(function (answer) { return answer.plugins_list; }); } -function *interactive_plugins_release() { +function * interactive_plugins_release () { console.log('Hi! So you want to do a plugins release, do you?'); // sanity check for tooling that will be needed during releaser. if (!shelljs.which('gpg')) { @@ -127,12 +125,12 @@ function *interactive_plugins_release() { console.error('I did not find `svn` on your PATH!'); process.exit(1); } - return Q.fcall(function() { + return Q.fcall(function () { if (process.env.JIRA_USER && process.env.JIRA_PASSWORD) { return { username: process.env.JIRA_USER, password: process.env.JIRA_PASSWORD - } + }; } else { console.log('Let\'s start with your JIRA credentials - this system will be interacting with Apache\'s JIRA instance (issues.apache.org) often.'); console.log('(Note that you can export environment variables `JIRA_USER` and `JIRA_PASSWORD` so I won\'t ask you next time.)'); @@ -140,57 +138,57 @@ function *interactive_plugins_release() { type: 'input', name: 'username', message: 'Please enter your JIRA username' - },{ + }, { type: 'password', name: 'password', message: 'Please enter your JIRA password' - }]) + }]); } - }).then(function(answers) { + }).then(function (answers) { var username = answers.username; you = username; var password = answers.password; - jira = new jira_client({ - protocol: 'https', - host: 'issues.apache.org', - base: 'jira', - apiVersion: '2', - strictSSL: true, - username: username, - password: password + jira = new jira_client({ // eslint-disable-line new-cap + protocol: 'https', + host: 'issues.apache.org', + base: 'jira', + apiVersion: '2', + strictSSL: true, + username: username, + password: password }); return jira.getCurrentUser(); - }).then(function(user) { + }).then(function (user) { jira_user = user; you = user.displayName || you; // either use JIRA display name, or username console.log('Hey', you, '!'); console.log('Welcome. Let me pull some data from JIRA first...'); return jira.listProjects(); - }).then(function(projects) { + }).then(function (projects) { // Find the Apache Cordova (CB) project in Apache's JIRA for (var i = 0; i < projects.length; i++) { var project = projects[i]; - if (project.key == 'CB') { + if (project.key === 'CB') { cordova_project = project; break; } } return jira.listComponents('CB'); - }).then(function(components) { + }).then(function (components) { // Find the ALlPlugins component in Cordova'a JIRA components for (var i = 0; i < components.length; i++) { var component = components[i]; - if (component.name == 'AllPlugins') { + if (component.name === 'AllPlugins') { all_plugins_component = component; break; } } return jira.listIssueTypes(); - }).then(function(issue_types) { + }).then(function (issue_types) { jira_issue_types = issue_types; for (var i = 0; i < issue_types.length; i++) { var it = issue_types[i]; - if (it.name == 'Task') { + if (it.name === 'Task') { jira_task_issue = it; } } @@ -201,7 +199,7 @@ function *interactive_plugins_release() { type: 'confirm', name: 'gpg', message: 'Are your GPG keys in place?' - }).then(function(answer) { + }).then(function (answer) { if (answer.gpg) { console.log('Great! Let\'s keep going.'); return inquirer.prompt({ @@ -214,7 +212,7 @@ function *interactive_plugins_release() { console.warn('Follow the instructions here, then come back and try again: ' + create_archive.GPG_DOCS); process.exit(2); } - }).then(function(answer) { + }).then(function (answer) { /* 3. Y/N did you start a "[DISCUSS] Plugins release" thread on the mailing list? * - Bonus: Can we parse the mailing list for this? */ @@ -229,7 +227,7 @@ function *interactive_plugins_release() { console.error('You definitely need to have a discussion about the plugins release on the mailing list first. Go do that!'); process.exit(3); } - }).then(function(answer) { + }).then(function (answer) { /* 4. Ask for JIRA issue, or, Create JIRA issue; check docs/plugins-release-process.md for details * - lets refer to this JIRA issue as $JIRA from here on out. * - TODO: BONUS: COMMENT to this JIRA issue for each "top-level" step below that is completed. @@ -239,12 +237,12 @@ function *interactive_plugins_release() { type: 'input', name: 'jira', message: 'What is the JIRA issue number for your plugins release? Please provide only the numerical part of the issue key (i.e. CB-XXXXX)' - }).then(function(answers) { + }).then(function (answers) { var cb_issue = 'CB-' + answers.jira; console.log('Looking for ' + cb_issue + '...'); - return jira.findIssue(cb_issue).then(function(issue) { + return jira.findIssue(cb_issue).then(function (issue) { return issue; - }, function(err) { + }, function (err) { // eslint-disable-line handle-callback-err console.error('Error finding issue ' + cb_issue + '!'); process.exit(4); }); @@ -253,36 +251,36 @@ function *interactive_plugins_release() { console.warn('OK, no problem. I will create one for you now! Hang tight...'); var date = (new Date()).toDateString(); var new_issue = { - "fields": { - "project": { - "id": cordova_project.id + 'fields': { + 'project': { + 'id': cordova_project.id }, - "summary": "Plugins Release, " + date, - "description": "Following steps at https://github.com/apache/cordova-coho/blob/master/docs/plugins-release-process.md\nGenerated automatically using cordova-coho.", - "assignee": { - "name": jira_user.name + 'summary': 'Plugins Release, ' + date, + 'description': 'Following steps at https://github.com/apache/cordova-coho/blob/master/docs/plugins-release-process.md\nGenerated automatically using cordova-coho.', + 'assignee': { + 'name': jira_user.name }, - "issuetype": { - "id": jira_task_issue.id + 'issuetype': { + 'id': jira_task_issue.id }, - "components": [ + 'components': [ { - "id": all_plugins_component.id + 'id': all_plugins_component.id } ] } - } - return jira.addNewIssue(new_issue).then(function(issue) { + }; + return jira.addNewIssue(new_issue).then(function (issue) { return issue; - }, function(err) { + }, function (err) { console.error('There was a problem creating the JIRA issue!', err); process.exit(5); }); } - }).then(function(jira_issue) { + }).then(function (jira_issue) { console.log('Sweet, our Plugins Release JIRA issue is ' + jira_issue.key + ' (https://issues.apache.org/jira/browse/' + jira_issue.key + ')!'); plugins_release_issue = jira_issue; - }).then(function() { + }).then(function () { /* 5: update the repos. ask the RM if they want to create a new set of repos, or use an existing directory */ return inquirer.prompt([{ type: 'confirm', @@ -292,7 +290,7 @@ function *interactive_plugins_release() { type: 'input', name: 'cwd', default: apputil.getBaseDir(), - message: function(answers) { + message: function (answers) { if (answers.use_existing_plugins) { return 'We need to update the plugin and apache SVN repositories. Enter the directory containing all of your Apache Cordova source code repositories (absolute or relative paths work here)'; } else { @@ -306,29 +304,29 @@ function *interactive_plugins_release() { }, { type: 'confirm', name: 'ok', - message: function(answers) { + message: function (answers) { return 'WARNING! Are you sure the following directory is where you want the plugin repositories we will be working with to be located? We will be cloning/updating repos here: ' + path.resolve(path.normalize(answers.cwd)); } }]); - }).then(function(answers) { + }).then(function (answers) { if (answers.ok) { plugin_base = path.resolve(path.normalize(answers.cwd)); shelljs.mkdir('-p', plugin_base); process.chdir(plugin_base); - plugin_repos = flagutil.computeReposFromFlag('plugins', {includeSvn:true}); - dist_svn = flagutil.computeReposFromFlag('dist', {includeSvn:true}); - dist_dev_svn = flagutil.computeReposFromFlag('dist/dev', {includeSvn:true}); + plugin_repos = flagutil.computeReposFromFlag('plugins', {includeSvn: true}); + dist_svn = flagutil.computeReposFromFlag('dist', {includeSvn: true}); + dist_dev_svn = flagutil.computeReposFromFlag('dist/dev', {includeSvn: true}); svn_repos = dist_svn.concat(dist_dev_svn); dist_svn = dist_svn[0]; dist_dev_svn = dist_dev_svn[0]; if (answers.auto_detect) { - return co.wrap(function *() { + return co.wrap(function * () { yield updateDesiredRepos(plugin_repos); return inquirer.prompt({ type: 'confirm', name: 'plugins_ok', - message: 'I\'ve detected ' + plugins_to_release.length + ' plugin' + (plugins_to_release.length==1?'':'s') + ' to release: ' + plugins_to_release.join(', ') + '\nThat means we\'re skipping ' + plugins_ommitted.length + ' plugin' + (plugins_ommitted.length==1?'':'s') + ': ' + plugins_ommitted.join(', ') + '\nDo you want to proceed with the release process around the specified plugins above (and ommitting the ones specified as well)?' - }).then(function(answers) { + message: 'I\'ve detected ' + plugins_to_release.length + ' plugin' + (plugins_to_release.length === 1 ? '' : 's') + ' to release: ' + plugins_to_release.join(', ') + '\nThat means we\'re skipping ' + plugins_ommitted.length + ' plugin' + (plugins_ommitted.length === 1 ? '' : 's') + ': ' + plugins_ommitted.join(', ') + '\nDo you want to proceed with the release process around the specified plugins above (and ommitting the ones specified as well)?' + }).then(function (answers) { if (answers.plugins_ok) { return plugins_to_release; } else { @@ -344,37 +342,37 @@ function *interactive_plugins_release() { console.warn('Womp womp, try again? Probably this flow should be better eh?'); process.exit(6); } - }).then(function(plugins_list) { + }).then(function (plugins_list) { // at this point we either have a verified, or manually-specified, list of plugins to release. plugins_to_release = plugins_list; // modify the coho-formatted list of plugin repos to filter out to only the plugins we want to release. - plugin_repos = plugin_repos.filter(function(plugin) { + plugin_repos = plugin_repos.filter(function (plugin) { return plugins_to_release.indexOf(plugin.repoName) > -1; }); - return co.wrap(function *() { + return co.wrap(function * () { yield updateDesiredRepos(plugin_repos); // and remove all the data we collected for plugins we no longer care about. var data_keys = Object.keys(plugin_data); - data_keys.forEach(function(key) { - if (plugins_to_release.indexOf(key) == -1) { + data_keys.forEach(function (key) { + if (plugins_to_release.indexOf(key) === -1) { delete plugin_data[key]; } }); - /* 7. ensure license headers are present everywhere.*/ + /* 7. ensure license headers are present everywhere. */ console.log('Checking license headers for specified plugin repos...'); var unknown_licenses = []; - yield audit_license.scrubRepos(plugin_repos, /*silent*/true, /*allowError*/false, function(repo, stdout) { - var unknown = stdout.split('\n').filter(function(line) { + yield audit_license.scrubRepos(plugin_repos, /* silent */true, /* allowError */false, function (repo, stdout) { + var unknown = stdout.split('\n').filter(function (line) { return line.indexOf('Unknown Licenses') > -1; })[0]; - if (unknown[0] != '0') { + if (unknown[0] !== '0') { // There are some unknown licenses! - unknown_licenses.push({repo:repo.repoName,unknown:unknown}); + unknown_licenses.push({repo: repo.repoName, unknown: unknown}); } }); return yield Promise.resolve(unknown_licenses); })(); - }).then(function(unknowns) { + }).then(function (unknowns) { if (unknowns.length) { console.warn('We identified some unknown licenses in plugin repos!'); console.warn(unknowns); @@ -382,7 +380,7 @@ function *interactive_plugins_release() { type: 'confirm', name: 'proceed', message: 'Do you want to proceed even though there are license problems?' - }).then(function(answer) { + }).then(function (answer) { if (!answer.proceed) { console.error('License audit failed - good idea to abort. Fix it up and come back!'); process.exit(7); @@ -391,42 +389,42 @@ function *interactive_plugins_release() { } else { console.log('No license issues found - continuing.'); } - }).then(function() { + }).then(function () { return inquirer.prompt({ type: 'confirm', name: 'proceed', message: 'We are now ready to start making changes to the selected plugin repo, which will make changes to the master and release branches. Shall we proceed?' - }).then(function(answers) { + }).then(function (answers) { if (!answers.proceed) { console.error('Bailing!'); process.exit(99); } }); - }).then(function() { + }).then(function () { // TODO: step 8 apparently is "rarely" done based on fil's experience running through the plugin release steps manually. // soooo.... what do? /* 8. ensure all dependencies and subdependencies have apache-compatible licenses. * 9. update plugin versions + release notes. - * - for each plugin, remove the `-dev` suffix in plugin.xml, package.json, and plugin.xml of `tests/` subdirectory (if exists)*/ + * - for each plugin, remove the `-dev` suffix in plugin.xml, package.json, and plugin.xml of `tests/` subdirectory (if exists) */ console.log('Removing the "-dev" suffix from versions in the master branch...'); - return co.wrap(function *() { - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + return co.wrap(function * () { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { yield gitutil.gitCheckout('master'); var current_version = yield versionutil.getRepoVersion(repo); console.log(repo.repoName, '\'s current version is', current_version); var devless_version = versionutil.removeDev(current_version); plugin_data[repo.repoName].current_release = devless_version; - yield versionutil.updateRepoVersion(repo, devless_version, {commitChanges:false}); + yield versionutil.updateRepoVersion(repo, devless_version, {commitChanges: false}); }); })(); - }).then(function() { + }).then(function () { /* - each plugin may need a version bump. * - how to determine if patch, minor or major? show changes to each plugin and then prompt Release Manager for a decision? * - reuse coho 'update release notes' command */ - return co.wrap(function *() { + return co.wrap(function * () { var plugs = Object.keys(plugin_data); var release_note_prompts = []; - yield plugs.map(function*(plugin) { + yield plugs.map(function * (plugin) { var data = plugin_data[plugin]; var changes = data.changes; var final_notes = yield update_release_notes.createNotes(plugin, data.current_release, changes); @@ -440,7 +438,7 @@ function *interactive_plugins_release() { release_note_prompts.push({ type: 'input', name: plugin + '-version', - message: function(answers) { + message: function (answers) { var new_changes = answers[plugin]; var first_heading = new_changes.indexOf('###'); var second_heading = new_changes.indexOf('###', first_heading + 3); @@ -450,7 +448,7 @@ function *interactive_plugins_release() { return 'Please enter a semver-compatible version number for this release of ' + plugin + ', based on the changes below:\n' + change_summary; }, default: data.current_release, - validate: function(input) { + validate: function (input) { if (semver.valid(input)) { return true; } else { @@ -461,17 +459,17 @@ function *interactive_plugins_release() { }); return inquirer.prompt(release_note_prompts); })(); - }).then(function(release_notes) { - return co.wrap(function *() { + }).then(function (release_notes) { + return co.wrap(function * () { console.log('Writing out new release notes and plugin versions (if applicable)...'); - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; - if (plugin_data[plugin_name].current_release != release_notes[plugin_name + '-version']) { + if (plugin_data[plugin_name].current_release !== release_notes[plugin_name + '-version']) { // If, after release notes review, RM decided on a different version... // Overwrite plugin version var previous_assumed_version = plugin_data[plugin_name].current_release; plugin_data[plugin_name].current_release = release_notes[plugin_name + '-version']; - yield versionutil.updateRepoVersion(repo, plugin_data[plugin_name].current_release, {commitChanges:false}); + yield versionutil.updateRepoVersion(repo, plugin_data[plugin_name].current_release, {commitChanges: false}); // also overwrite the version originally specified in the release notes file, since we changed it now! var rn = release_notes[plugin_name]; var new_rn = rn.replace(new RegExp('### ' + previous_assumed_version, 'g'), '### ' + plugin_data[plugin_name].current_release); @@ -479,7 +477,7 @@ function *interactive_plugins_release() { } fs.writeFileSync(update_release_notes.FILE, release_notes[plugin_name], {encoding: 'utf8'}); /* - commit changes to versions and release notes together with description '$JIRA Updated version and release notes for release $v' - * - tag each plugin repo with $v*/ + * - tag each plugin repo with $v */ if (yield gitutil.pendingChangesExist()) { yield gitutil.commitChanges(plugins_release_issue.key + ' Updated version and RELEASENOTES.md for release ' + plugin_data[plugin_name].current_release + ' (via coho)'); yield gitutil.tagRepo(plugin_data[plugin_name].current_release); @@ -488,11 +486,11 @@ function *interactive_plugins_release() { } }); })(); - }).then(function() { + }).then(function () { /* 10. Create release branch. Check if release branch, which would be named in the form "major.minor.x" (i.e. 2.3.x) already exists */ - return co.wrap(function *() { + return co.wrap(function * () { var repos_with_existing_release_branch = []; - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; var plugin_version = plugin_data[plugin_name].current_release; var release_branch_name = versionutil.getReleaseBranchNameFromVersion(plugin_version); @@ -501,7 +499,7 @@ function *interactive_plugins_release() { // also store HEAD of release branch, so later on we can show a diff of the branch before pushing plugin_data[plugin_name].previous_release_branch_head = gitutil.hashForRef(release_branch_name); console.log('Release branch', release_branch_name, 'already exists, time to update it. We will be making changes to this existing branch.'); - yield repoupdate.updateRepos([repo], [release_branch_name], /*noFetch*/false); + yield repoupdate.updateRepos([repo], [release_branch_name], /* noFetch */false); } else { yield gitutil.createNewBranch(release_branch_name); console.log('Created branch', release_branch_name, 'in repo', plugin_name); @@ -509,15 +507,15 @@ function *interactive_plugins_release() { }); return repos_with_existing_release_branch; })(); - }).then(function(repos_with_existing_release_branch) { + }).then(function (repos_with_existing_release_branch) { // Here we are passed an array of repos that already had release branches created prior to starting the release process. // Our mission in this clause, should we choose to accept it, is to merge master back into the branch. But, this can be dangerous! // Ask the RM if they want us to handle the merge automatically. // If the RM says no, we will prompt them to handle it manually later. var prompts = []; - repos_with_existing_release_branch.forEach(function(repo) { + repos_with_existing_release_branch.forEach(function (repo) { var plugin_name = repo.repoName; - var rb = versionutil.getReleaseBranchNameFromVersion(plugin_data[plugin_name].current_release) + var rb = versionutil.getReleaseBranchNameFromVersion(plugin_data[plugin_name].current_release); prompts.push({ type: 'confirm', name: 'rb_automerge_proceed_' + plugin_name, @@ -525,19 +523,19 @@ function *interactive_plugins_release() { }); }); return inquirer.prompt(prompts); - }).then(function(answers) { - return co.wrap(function *() { + }).then(function (answers) { + return co.wrap(function * () { var prompts = []; - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; if (answers['rb_automerge_proceed_' + plugin_name]) { // Auto-merge master into the release branch. var rb = versionutil.getReleaseBranchNameFromVersion(plugin_data[plugin_name].current_release); console.log('Checking out "' + rb + '" branch of', plugin_name, 'and merging master in...'); - yield executil.execHelper(executil.ARGS('git merge -s recursive -X theirs', 'master'), false, false, function() { + yield executil.execHelper(executil.ARGS('git merge -s recursive -X theirs', 'master'), false, false, function () { console.log('Merge was fine, continuing.'); - }, function(e) { - //yield gitutil.merge('master', function() { console.log('merge was fine, continuing.'); }, function(e) { + }, function (e) { + // yield gitutil.merge('master', function() { console.log('merge was fine, continuing.'); }, function(e) { plugins_to_merge_manually.push(plugin_name); }); } else { @@ -546,11 +544,11 @@ function *interactive_plugins_release() { }); return inquirer.prompt(prompts); })(); - }).then(function() { + }).then(function () { // prompt the RM about the plugins with manual merging work needed here. var prompts = []; - plugins_to_merge_manually.forEach(function(plugin_name) { - var rb = versionutil.getReleaseBranchNameFromVersion(plugin_data[plugin_name].current_release) + plugins_to_merge_manually.forEach(function (plugin_name) { + var rb = versionutil.getReleaseBranchNameFromVersion(plugin_data[plugin_name].current_release); prompts.push({ type: 'confirm', name: 'rb_manualmerge_proceed_' + plugin_name, @@ -558,32 +556,32 @@ function *interactive_plugins_release() { }); }); return inquirer.prompt(prompts); - }).then(function() { - /* 11. Increment plugin versions back on the master branch to include -dev*/ + }).then(function () { + /* 11. Increment plugin versions back on the master branch to include -dev */ // Also increment the patch version // So, check out master branch and do the thing. - return co.wrap(function *() { - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + return co.wrap(function * () { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; var newest_version = semver.inc(plugin_data[plugin_name].current_release, 'patch') + '-dev'; console.log('Checking out master branch of', plugin_name, 'and setting version to', newest_version, ', then committing that change to master branch...'); yield gitutil.gitCheckout('master'); // store previous master HEAD, for later comparison/showing of diff plugin_data[plugin_name].previous_master_head = gitutil.hashForRef('master'); - yield versionutil.updateRepoVersion(repo, newest_version, {commitChanges:true}); + yield versionutil.updateRepoVersion(repo, newest_version, {commitChanges: true}); }); })(); - }).then(function() { + }).then(function () { /* 12. Push tags, release branch, and master branch changes. * start with pushing tag, then compile diffs for master branch push and ask user if they approve before pushing master */ - return co.wrap(function *() { + return co.wrap(function * () { var master_prompts = []; - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; var tag = plugin_data[plugin_name].current_release; console.log(plugin_name, ': pushing tag ', tag); yield gitutil.pushToOrigin(tag); - /* - show diff of last master commit for user confirmation*/ + /* - show diff of last master commit for user confirmation */ var diff = yield gitutil.diff(plugin_data[plugin_name].previous_master_head, 'master'); master_prompts.push({ type: 'confirm', @@ -593,10 +591,10 @@ function *interactive_plugins_release() { }); return inquirer.prompt(master_prompts); })(); - }).then(function(answers) { - /*check confirmations and exit if RM bailed*/ - return co.wrap(function *() { - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + }).then(function (answers) { + /* check confirmations and exit if RM bailed */ + return co.wrap(function * () { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; if (!answers['master_' + plugin_name]) { console.error('Aborting as master branch changes for ' + plugin_name + ' were not approved!'); @@ -604,21 +602,21 @@ function *interactive_plugins_release() { } }); })(); - }).then(function() { + }).then(function () { // at this point RM is cool pushing master branch changes up. - return co.wrap(function *() { - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + return co.wrap(function * () { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { // at this point still have master branch checked out yield gitutil.pushToOrigin('master'); }); })(); - }).then(function() { + }).then(function () { /* - show diff of release branch: * - if release branch did not exist before, show diff (simple, just master..branch), confirm, then push - * - if release branch did exist before, show diff (last branch commit..HEAD), confirm, then push*/ - return co.wrap(function *() { + * - if release branch did exist before, show diff (last branch commit..HEAD), confirm, then push */ + return co.wrap(function * () { var rb_prompts = []; - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; var plugin_version = plugin_data[plugin_name].current_release; var release_branch_name = versionutil.getReleaseBranchNameFromVersion(plugin_version); @@ -634,7 +632,7 @@ function *interactive_plugins_release() { }); } else { // release branch did NOT exist previously, this is a new release branch. - var diff = yield gitutil.diff('master', release_branch_name); + var diff = yield gitutil.diff('master', release_branch_name); // eslint-disable-line no-redeclare rb_prompts.push({ type: 'confirm', name: 'rb_' + plugin_name, @@ -644,10 +642,10 @@ function *interactive_plugins_release() { }); return inquirer.prompt(rb_prompts); })(); - }).then(function(answers) { - /*check confirmations and exit if RM bailed*/ - return co.wrap(function *() { - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + }).then(function (answers) { + /* check confirmations and exit if RM bailed */ + return co.wrap(function * () { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; if (!answers['rb_' + plugin_name]) { console.error('Aborting as release branch changes for ' + plugin_name + ' were not approved!'); @@ -655,10 +653,10 @@ function *interactive_plugins_release() { } }); })(); - }).then(function() { + }).then(function () { // at this point RM is cool pushing master branch changes up. - return co.wrap(function *() { - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + return co.wrap(function * () { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; var plugin_version = plugin_data[plugin_name].current_release; var release_branch_name = versionutil.getReleaseBranchNameFromVersion(plugin_version); @@ -666,10 +664,10 @@ function *interactive_plugins_release() { yield gitutil.pushToOrigin(release_branch_name); }); })(); - }).then(function() { + }).then(function () { // 13. Publish to apache svn: // - first update dist-dev repo - return co.wrap(function *() { + return co.wrap(function * () { var orig_dir = process.cwd(); var dist_dev_repo = path.join(plugin_base, dist_dev_svn.repoName); process.chdir(dist_dev_repo); @@ -677,26 +675,26 @@ function *interactive_plugins_release() { yield svnutil.update(); process.chdir(orig_dir); })(); - }).then(function() { + }).then(function () { // - create-archive -r $ACTIVE --dest cordova-dist-dev/$JIRA - return co.wrap(function *() { + return co.wrap(function * () { // location to store the archives in. var dist_dev_dir = path.join(plugin_base, dist_dev_svn.repoName, plugins_release_issue.key); if (!(fs.existsSync(dist_dev_dir))) { shelljs.mkdir('-p', dist_dev_dir); created_distdev_dir = true; } - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { var plugin_name = repo.repoName; var tag = plugin_data[plugin_name].current_release; yield gitutil.gitCheckout(tag); - var archive = yield create_archive.createArchive(repo, tag, dist_dev_dir, true/*sign*/); + var archive = yield create_archive.createArchive(repo, tag, dist_dev_dir, true/* sign */); // - verify-archive cordova-dist-dev/$JIRA/*.tgz yield create_archive.verifyArchive(archive); yield gitutil.gitCheckout('master'); }); })(); - }).then(function() { + }).then(function () { if (process.env.SVN_USER && process.env.SVN_PASSWORD) { return { username: process.env.SVN_USER, @@ -709,17 +707,17 @@ function *interactive_plugins_release() { type: 'input', name: 'username', message: 'Please enter your svn username' - },{ + }, { type: 'password', name: 'password', message: 'Please enter your svn password' }]); } - }).then(function(answers) { + }).then(function (answers) { svn_user = answers.username; svn_password = answers.password; // - upload by running `svn` add and commit commands. - return co.wrap(function *() { + return co.wrap(function * () { var orig_dir = process.cwd(); var dist_dev_repo = path.join(plugin_base, dist_dev_svn.repoName); if (created_distdev_dir) { @@ -732,7 +730,7 @@ function *interactive_plugins_release() { // if it already existed, then we need to painstakingly add // each individual archive file cause svn is cool var archives_for_plugins = []; - yield repoutil.forEachRepo(plugin_repos, function*(repo) { + yield repoutil.forEachRepo(plugin_repos, function * (repo) { process.chdir(dist_dev_repo); var plugin_name = repo.repoName; var tag = plugin_data[plugin_name].current_release; @@ -749,17 +747,17 @@ function *interactive_plugins_release() { process.chdir(orig_dir); })(); - }).then(function() { + }).then(function () { console.log('Nicely done! Last few things you should do:'); /* 14. Dump instructions only? Prepare blog post - perhaps can dump out release notes-based blog content. - * - TODO: this apparently ends up as a .md file in cordova-docs. perhaps can dump this as a shell of a file into the cordova-docs repo? maybe even auto-branch the docs repo in prep for a PR?*/ + * - TODO: this apparently ends up as a .md file in cordova-docs. perhaps can dump this as a shell of a file into the cordova-docs repo? maybe even auto-branch the docs repo in prep for a PR? */ console.log('1. Prepare a blog post: https://github.com/apache/cordova-coho/blob/master/docs/plugins-release-process.md#prepare-blog-post'); console.log('2. Start a vote thread! https://github.com/apache/cordova-coho/blob/master/docs/plugins-release-process.md#start-vote-thread'); console.log('3. You should test these plugins out! Check out cordova-mobile-spec, and in particular, the `createmobilespec` script that comes with it - it\'s a quick way to create a test project with all plugins included.'); process.exit(0); }); - }, function(auth_err) { - var keys = Object.keys(auth_err); + }, function (auth_err) { + var keys = Object.keys(auth_err); // eslint-disable-line no-unused-vars console.error('ERROR! There was a problem connecting to JIRA, received a', auth_err.statusCode, 'status code.'); process.exit(1); }); @@ -792,16 +790,16 @@ module.exports.interactive = interactive_plugins_release; // TODO: if using this function only to retrieve repo version, use the new // versionutil.getRepoVersion method instead. -function *handleVersion(repo, ver, validate) { - var platform = repo.id; +function * handleVersion (repo, ver, validate) { // eslint-disable-line no-unused-vars + var platform = repo.id; // eslint-disable-line no-unused-vars var version = ver || undefined; if (version === undefined) { - yield repoutil.forEachRepo([repo], function*() { + yield repoutil.forEachRepo([repo], function * () { // Grabbing version from platformPackageJson var platformPackage = path.join(process.cwd(), 'package.json'); var platformPackageJson = require(platformPackage); - if(validate === true) { + if (validate === true) { version = flagutil.validateVersionString(platformPackageJson.version); } else { version = platformPackageJson.version; @@ -810,4 +808,3 @@ function *handleVersion(repo, ver, validate) { } return version; } - http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/print-tags.js ---------------------------------------------------------------------- diff --git a/src/print-tags.js b/src/print-tags.js index 9796e64..ec08b34 100644 --- a/src/print-tags.js +++ b/src/print-tags.js @@ -23,7 +23,7 @@ var flagutil = require('./flagutil'); var gitutil = require('./gitutil'); var repoutil = require('./repoutil'); -module.exports = function*(argv) { +module.exports = function * (argv) { var opt = flagutil.registerRepoFlag(optimist); opt = flagutil.registerHelpFlag(opt); argv = opt @@ -40,8 +40,8 @@ module.exports = function*(argv) { var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true}); var tag; - yield repoutil.forEachRepo(repos, function*(repo) { - if (argv.tag){ + yield repoutil.forEachRepo(repos, function * (repo) { + if (argv.tag) { tag = argv.tag; } else { tag = (yield gitutil.findMostRecentTag(repo.versionPrefix))[0]; @@ -54,4 +54,3 @@ module.exports = function*(argv) { console.log(' ' + repo.repoName + ': ' + tag.replace(/^r/, '') + ' (' + ref.slice(0, 10) + ')'); }); }; - http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/repo-clone.js ---------------------------------------------------------------------- diff --git a/src/repo-clone.js b/src/repo-clone.js index e665b4b..04e0957 100644 --- a/src/repo-clone.js +++ b/src/repo-clone.js @@ -24,16 +24,16 @@ var executil = require('./executil'); var flagutil = require('./flagutil'); var print = apputil.print; -module.exports = function*(argv) { - var opt = flagutil.registerRepoFlag(optimist) +module.exports = function * (argv) { + var opt = flagutil.registerRepoFlag(optimist); opt = flagutil.registerHelpFlag(opt); opt = flagutil.registerDepthFlag(opt); - var argv = opt + var argv = opt // eslint-disable-line no-redeclare .usage('Clones git repositories as siblings of cordova-coho (unless --no-chdir or --global is used). If the repositories are already cloned, then this is a no-op.\n\n' + 'Usage: $0 repo-clone [--depth 1] --repo=name [-r repos]') .argv; - if (argv.h || argv.r == 'auto') { + if (argv.h || argv.r === 'auto') { optimist.showHelp(); process.exit(1); } @@ -42,9 +42,9 @@ module.exports = function*(argv) { var repos = flagutil.computeReposFromFlag(argv.r, {includeSvn: true}); yield cloneRepos(repos, false, depth); -} +}; -function createRepoUrl(repo) { +function createRepoUrl (repo) { if (repo.github) { return 'https://github.com/apache/' + repo.repoName + '.git'; } else { @@ -52,16 +52,16 @@ function createRepoUrl(repo) { } } -function *cloneRepos(repos, quiet, depth) { - var failures = []; +function * cloneRepos (repos, quiet, depth) { + var failures = []; // eslint-disable-line no-unused-vars var numSkipped = 0; var clonePromises = []; for (var i = 0; i < repos.length; ++i) { var repo = repos[i]; if (fs.existsSync(repo.repoName)) { - if(!quiet) print('Repo already cloned: ' + repo.repoName); - numSkipped +=1 ; + if (!quiet) print('Repo already cloned: ' + repo.repoName); + numSkipped += 1; } else if (repo.svn) { clonePromises.push(executil.execHelper(executil.ARGS('svn checkout ' + repo.svn + ' ' + repo.repoName + ' ' + '--trust-server-cert --non-interactive'))); } else { @@ -81,4 +81,3 @@ function *cloneRepos(repos, quiet, depth) { } } module.exports.cloneRepos = cloneRepos; - http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/repo-push.js ---------------------------------------------------------------------- diff --git a/src/repo-push.js b/src/repo-push.js index 0441e85..01eef8e 100644 --- a/src/repo-push.js +++ b/src/repo-push.js @@ -26,16 +26,16 @@ var repoutil = require('./repoutil'); var repoupdate = require('./repo-update'); var print = apputil.print; -module.exports = function*(argv) { - var opt = flagutil.registerRepoFlag(optimist) - var opt = optimist +module.exports = function * (argv) { + var opt = flagutil.registerRepoFlag(optimist); + var opt = optimist // eslint-disable-line .options('b', { alias: 'branch', desc: 'The name of the branch to push. Can be specified multiple times to specify multiple branches.', default: ['master'] - }); + }); opt = flagutil.registerHelpFlag(opt); - var argv = opt + var argv = opt // eslint-disable-line .usage('Pushes changes to the remote repository.\n' + '\n' + 'Usage: $0 repo-push -r auto -b master -b 2.9.x') @@ -48,7 +48,7 @@ module.exports = function*(argv) { var branches = Array.isArray(argv.b) ? argv.b : [argv.b]; var repos = flagutil.computeReposFromFlag(argv.r); - yield repoutil.forEachRepo(repos, function*(repo) { + yield repoutil.forEachRepo(repos, function * (repo) { // Update first. yield repoupdate.updateRepos([repo], branches, false); for (var i = 0; i < branches.length; ++i) { @@ -72,5 +72,4 @@ module.exports = function*(argv) { } } }); -} - +}; http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/repo-reset.js ---------------------------------------------------------------------- diff --git a/src/repo-reset.js b/src/repo-reset.js index 0d54f76..5b67bee 100644 --- a/src/repo-reset.js +++ b/src/repo-reset.js @@ -26,16 +26,16 @@ var repoutil = require('./repoutil'); var repoupdate = require('./repo-update'); var print = apputil.print; -module.exports = function*(argv) { - var opt = flagutil.registerRepoFlag(optimist) - var opt = optimist +module.exports = function * (argv) { + var opt = flagutil.registerRepoFlag(optimist); + var opt = optimist // eslint-disable-line no-redeclare .options('b', { alias: 'branch', desc: 'The name of the branch to reset. Can be specified multiple times to specify multiple branches.', default: 'master' - }); + }); opt = flagutil.registerHelpFlag(opt); - var argv = opt + var argv = opt // eslint-disable-line no-redeclare .usage('Resets repository branches to match their upstream state.\n' + 'Performs the following commands on each:\n' + ' git commit (commit any pending changes)\n' + @@ -50,21 +50,21 @@ module.exports = function*(argv) { optimist.showHelp(); process.exit(1); } - if (argv.r == 'auto') { + if (argv.r === 'auto') { apputil.fatal('"-r auto" is not allowed for repo-reset. Please enumerate repos explicitly'); } var branches = Array.isArray(argv.b) ? argv.b : [argv.b]; var repos = flagutil.computeReposFromFlag(argv.r); yield module.exports.resetRepos(repos, branches); -} +}; -module.exports.resetRepos = function*(repos, branches) { - yield repoutil.forEachRepo(repos, function*(repo) { +module.exports.resetRepos = function * (repos, branches) { + yield repoutil.forEachRepo(repos, function * (repo) { // Determine remote name. yield repoupdate.updateRepos([repo], [], true); var branchName = yield gitutil.retrieveCurrentBranchName(); - if (branches.indexOf(branchName) == -1) { - yield gitutil.stashAndPop(repo, function*() { + if (branches.indexOf(branchName) === -1) { + yield gitutil.stashAndPop(repo, function * () { yield cleanRepo(repo, branches); }); } else { @@ -73,7 +73,7 @@ module.exports.resetRepos = function*(repos, branches) { }); }; -function *cleanRepo(repo, branches) { +function * cleanRepo (repo, branches) { for (var i = 0; i < branches.length; ++i) { var branchName = branches[i]; if (!(yield gitutil.localBranchExists(branchName))) { @@ -96,7 +96,7 @@ function *cleanRepo(repo, branches) { print(repo.repoName + ' on branch ' + branchName + ': No local commits to reset.'); } } else { - if ((yield gitutil.retrieveCurrentBranchName()) == branchName) { + if ((yield gitutil.retrieveCurrentBranchName()) === branchName) { yield gitutil.gitCheckout('master'); } print(repo.repoName + ' deleting local-only branch ' + branchName + '.'); http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/34ae0bbb/src/repo-status.js ---------------------------------------------------------------------- diff --git a/src/repo-status.js b/src/repo-status.js index a11e1e8..690d4a7 100644 --- a/src/repo-status.js +++ b/src/repo-status.js @@ -17,7 +17,6 @@ specific language governing permissions and limitations under the License. */ -var fs = require('fs'); var optimist = require('optimist'); var apputil = require('./apputil'); var executil = require('./executil'); @@ -27,22 +26,22 @@ var repoutil = require('./repoutil'); var repoupdate = require('./repo-update'); var print = apputil.print; -module.exports = function*(argv) { - var opt = flagutil.registerRepoFlag(optimist) - var opt = optimist +module.exports = function * (argv) { + var opt = flagutil.registerRepoFlag(optimist); + var opt = optimist // eslint-disable-line no-redeclare .options('b', { alias: 'branch', desc: 'The name of the branch to report on. Can be specified multiple times to specify multiple branches. The local version of the branch is compared with the origin\'s version unless --b2 is specified.' - }) + }) .options('branch2', { desc: 'The name of the branch to diff against. This is origin/$branch by default.' - }) + }) .options('diff', { desc: 'Show a diff of the changes.', default: false - }) + }); opt = flagutil.registerHelpFlag(opt); - var argv = opt + var argv = opt // eslint-disable-line no-redeclare .usage('Reports what changes exist locally that are not yet pushed.\n' + '\n' + 'Example usage: $0 repo-status -r auto -b master -b 2.9.x\n' + @@ -57,18 +56,18 @@ module.exports = function*(argv) { var branches2 = branches && argv.branch2 && (Array.isArray(argv.branch2) ? argv.branch2 : [argv.branch2]); var repos = flagutil.computeReposFromFlag(argv.r); - if (branches2 && branches && branches.length != branches2.length) { + if (branches2 && branches && branches.length !== branches2.length) { apputil.fatal('Must specify the same number of --branch and --branch2 flags'); } - yield repoutil.forEachRepo(repos, function*(repo) { + yield repoutil.forEachRepo(repos, function * (repo) { if (repo.svn) { print('repo-status not implemented for svn repos'); return; } // Determine remote name. yield repoupdate.updateRepos([repo], [], true); - var actualBranches = branches ? branches : ['master']; + var actualBranches = branches || ['master']; for (var i = 0; i < actualBranches.length; ++i) { var branchName = actualBranches[i]; if (!(yield gitutil.localBranchExists(branchName))) { @@ -88,8 +87,8 @@ module.exports = function*(argv) { } }); if (argv.diff) { - yield repoutil.forEachRepo(repos, function*(repo) { - var actualBranches = branches ? branches : ['master']; + yield repoutil.forEachRepo(repos, function * (repo) { + var actualBranches = branches || ['master']; for (var i = 0; i < actualBranches.length; ++i) { var branchName = actualBranches[i]; if (!(yield gitutil.localBranchExists(branchName))) { @@ -107,5 +106,4 @@ module.exports = function*(argv) { } }); } -} - +}; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
