You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/11/22 00:37:50 UTC

cordova-coho git commit: added npm unpublish step to nightly

Repository: cordova-coho
Updated Branches:
  refs/heads/master e9f37cbe9 -> 3b6c5ba41


added npm unpublish step to nightly


Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/3b6c5ba4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/3b6c5ba4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/3b6c5ba4

Branch: refs/heads/master
Commit: 3b6c5ba411882a170a8909c24412a027ab619fca
Parents: e9f37cb
Author: Steve Gill <st...@gmail.com>
Authored: Fri Nov 21 15:37:38 2014 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Nov 21 15:37:38 2014 -0800

----------------------------------------------------------------------
 src/main.js        |  4 ++++
 src/nightly.js     | 13 +++++++++++-
 src/npm-publish.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 68 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/3b6c5ba4/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index 2be5540..76401b7 100644
--- a/src/main.js
+++ b/src/main.js
@@ -137,6 +137,10 @@ module.exports = function() {
             name: 'npm-publish-tag',
             desc: 'Publishes current version of repo to specified tag',
             entryPoint: lazyRequire('./npm-publish', 'publishTag')
+        }, {
+            name: 'npm-unpublish-nightly',
+            desc: 'Unpublishes last nightly versions for cli and lib',
+            entryPoint: lazyRequire('./npm-publish', 'unpublishNightly')
         }
     ];
     var commandMap = {};

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/3b6c5ba4/src/nightly.js
----------------------------------------------------------------------
diff --git a/src/nightly.js b/src/nightly.js
index 392cbe1..334f549 100644
--- a/src/nightly.js
+++ b/src/nightly.js
@@ -51,6 +51,11 @@ module.exports = function*(argv) {
         optimist.showHelp();
         process.exit(1);
     }
+    
+    //Grab currently published nightly version so we can unpublish it later
+    //Assumes lib and cli have same version
+    var oldNightlyVersion = yield executil.execHelper(executil.ARGS('npm view cordova dist-tags.nightly'));
+    console.log(oldNightlyVersion);
 
     //Update Repos
     yield repoupdate.updateRepos(repos);
@@ -111,12 +116,18 @@ module.exports = function*(argv) {
     //run CLI + cordova-lib tests
     yield runTests(cli, cordovaLib);
 
-    //publish to npm under nightly tag
+    //create options object
     var options = {};
     options.tag = 'nightly';
     options.r = ['lib', 'cli'];
     options.pretend = argv.pretend;
+
+    //publish to npm under nightly tag
     yield npmpublish.publishTag(options);
+
+    //unpublish old nightly
+    options.version = oldNightlyVersion;
+    yield npmpublish.unpublish(options);
 }
 
 //updates platforms.js with the SHA

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/3b6c5ba4/src/npm-publish.js
----------------------------------------------------------------------
diff --git a/src/npm-publish.js b/src/npm-publish.js
index 2f3a777..abd7dd3 100644
--- a/src/npm-publish.js
+++ b/src/npm-publish.js
@@ -24,7 +24,7 @@ var repoutil = require('./repoutil');
 var executil = require('./executil');
 var print = apputil.print;
 
-exports.publishTag = function*(options) {
+function *publishTag(options) {
     var opt = flagutil.registerHelpFlag(optimist);
 
     //argv was passed through another function, set defaults to appease demand.
@@ -69,12 +69,61 @@ exports.publishTag = function*(options) {
     //npm publish --tag argv.tag
     yield repoutil.forEachRepo(repos, function*(repo) {
         yield executil.execOrPretend(executil.ARGS('npm publish --tag ' + argv.tag), argv.pretend);
-        //yield executil.execOrPretend(executil.ARGS('ls'), argv.pretend);
     });
 }
 
+module.exports.publishTag = publishTag;
+
 //TODO: Does npm tag cordova-js*.tgz latest
-exports.setLatest = function *(argv) {
+exports.setLatest = function*(argv) {
 
 
 }
+
+//Gets last nightly tag and unpublishes it
+function *unpublish(options) {
+    var opt = flagutil.registerHelpFlag(optimist);
+
+    if(options) {
+        opt = opt
+            .options('pretend', {
+                default:options.pretend
+            })
+            .options('r', {
+                default:options.r
+            })
+            .options('version', {
+                default:options.version
+            })
+    }
+
+    argv = opt
+        .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"
+        })
+        .options('r', {
+            desc: "Which repo(s) to publish",
+            demand: true
+        })
+        .options('version', {
+            desc: "Which version to unpublish",
+            demand: true
+        })
+        .argv;
+
+    if(argv.h) {
+        optimist.showHelp();
+        process.exit(1);
+    }
+
+    var repos = flagutil.computeReposFromFlag(argv.r);
+
+    yield repoutil.forEachRepo(repos, function*(repo) {
+        yield executil.execOrPretend(executil.ARGS('npm unpublish '+ repo.id + '@' + argv.version), argv.pretend);
+    })
+}
+
+module.exports.unpublish = unpublish;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org