You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2017/01/20 22:57:49 UTC

cordova-coho git commit: added xml2js dependency. tweak updateRepoVersion to also update plugin.xml files. plugin releaser now updates versions in files.

Repository: cordova-coho
Updated Branches:
  refs/heads/plugins-releaser 4ce456b79 -> 1e5311f19


added xml2js dependency. tweak updateRepoVersion to also update plugin.xml files. plugin releaser now updates versions in files.


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

Branch: refs/heads/plugins-releaser
Commit: 1e5311f19216dd03a815dfdd3349078e3b1f29bf
Parents: 4ce456b
Author: filmaj <ma...@gmail.com>
Authored: Fri Jan 20 14:57:44 2017 -0800
Committer: filmaj <ma...@gmail.com>
Committed: Fri Jan 20 14:57:44 2017 -0800

----------------------------------------------------------------------
 package.json            |  3 ++-
 src/platform-release.js |  3 ++-
 src/plugin-release.js   | 17 +++++++++++++----
 src/repoutil.js         |  1 +
 src/versionutil.js      | 45 ++++++++++++++++++++++++++++++++++++++++++--
 5 files changed, 61 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/1e5311f1/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 1817043..bf48139 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,8 @@
     "semver": "^4.2.0",
     "shelljs": "0.1.4",
     "jira-client": "4.2.0",
-    "inquirer": "2.0.0"
+    "inquirer": "2.0.0",
+    "xml2js": "0.4.17"
   },
   "devDependencies": {
     "nsp": ">=2.0.1",

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/1e5311f1/src/platform-release.js
----------------------------------------------------------------------
diff --git a/src/platform-release.js b/src/platform-release.js
index e9cff9c..3ea90b1 100644
--- a/src/platform-release.js
+++ b/src/platform-release.js
@@ -69,7 +69,8 @@ function cpAndLog(src, dest) {
  * @return {String} version                Returns the calculated version
  *
  */
-
+// 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;
     var version = ver || undefined;

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/1e5311f1/src/plugin-release.js
----------------------------------------------------------------------
diff --git a/src/plugin-release.js b/src/plugin-release.js
index 571b9c7..cfa7f5e 100644
--- a/src/plugin-release.js
+++ b/src/plugin-release.js
@@ -29,10 +29,10 @@ var executil = require('./executil');
 var flagutil = require('./flagutil');
 var gitutil = require('./gitutil');
 var repoutil = require('./repoutil');
+var versionutil = require('./versionutil');
 var repoupdate = require('./repo-update');
 var repoclone = require('./repo-clone');
 var reporeset = require('./repo-reset');
-var versionutil = require('./versionutil');
 var jira_client = require('jira-client');
 var inquirer = require('inquirer');
 var print = apputil.print;
@@ -303,9 +303,16 @@ function *interactive_plugins_release() {
             //TODO:
             /* 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)
-             *   - each plugin needs a version bump.
-             *     - the plugin may already have an acceptably-bumped verison. perhaps grab latest-published version of plugin from npm and compare to version in source as a hint to RM
+             *   - 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...');
+            return co.wrap(function *() {
+                yield repoutil.forEachRepo(plugin_repos, function*(repo) {
+                    var current_version = yield versionutil.getRepoVersion(repo);
+                    var devless_version = versionutil.removeDev(current_version);
+                    yield versionutil.updateRepoVersion(repo, devless_version, {commitChanges:false});
+                });
+            })();
+            /*   - 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
              *     - what's the average case? just a patch bump? perhaps, for each plugin, show release notes and let RM override version beyond patch bump if RM believes it is necessary?
@@ -388,6 +395,8 @@ function cpAndLog(src, dest) {
  *
  */
 
+// 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;
     var version = ver || undefined;

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/1e5311f1/src/repoutil.js
----------------------------------------------------------------------
diff --git a/src/repoutil.js b/src/repoutil.js
index 1db6758..83e72a2 100644
--- a/src/repoutil.js
+++ b/src/repoutil.js
@@ -422,6 +422,7 @@ var repoGroups = {
     'all': allRepos,
     'platform': platformRepos,
     'platforms': platformRepos,
+    'plugin': pluginRepos,
     'plugins': pluginRepos,
     'tools': toolRepos,
     'active-platform': platformRepos.filter(function(r) { return !r.inactive }),

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/1e5311f1/src/versionutil.js
----------------------------------------------------------------------
diff --git a/src/versionutil.js b/src/versionutil.js
index a4b895c..b91f9e4 100644
--- a/src/versionutil.js
+++ b/src/versionutil.js
@@ -20,12 +20,25 @@ under the License.
 var fs = require('fs');
 var path = require('path');
 var shelljs = require('shelljs');
+var xml2js = require('xml2js');
 var apputil = require('./apputil');
 var executil = require('./executil');
 var flagutil = require('./flagutil');
 var gitutil = require('./gitutil');
 var repoutil = require('./repoutil');
 
+function *getRepoVersion(repo) {
+    var version;
+    yield repoutil.forEachRepo([repo], function*() {
+        var platformPackage = path.join(process.cwd(), 'package.json');
+        var platformPackageJson = require(platformPackage);
+        version = platformPackageJson.version;
+    });
+    return version;
+}
+
+exports.getRepoVersion = getRepoVersion;
+
 function removeDev(version) {
     var newVersion = version.replace('-dev', '');
     return newVersion;
@@ -58,8 +71,9 @@ function updatePlatformsConfig(newValues) {
 exports.updatePlatformsConfig = updatePlatformsConfig;
 
 /**
- * Updates VERSION file, version executable script and package.json using specified
- *   version. Also commits change made to the repo if opposite is not specified.
+ * Updates VERSION file, version executable script, package.json and
+ * plugin.xml(s) using specified version. Also commits change made to the repo
+ * if opposite is not specified.
  *
  * @param {Object}  repo    Repo to update version for
  * @param {String}  version A semver-compatible version to write to repo's files
@@ -69,6 +83,8 @@ exports.updatePlatformsConfig = updatePlatformsConfig;
  */
 exports.updateRepoVersion = function *updateRepoVersion(repo, version, opts) {
     // Update the VERSION files.
+    // TODO: why do we read files asynchronously in this function, but write
+    // and check for existence synchronously?
     var versionFilePaths = repo.versionFilePaths || ['VERSION'];
     var isPlatformRepo = !!repoutil.isInRepoGroup(repo, 'platform');
     if (isPlatformRepo && fs.existsSync(versionFilePaths[0])) {
@@ -115,6 +131,31 @@ exports.updateRepoVersion = function *updateRepoVersion(repo, version, opts) {
         console.warn('No package.json file exists in repo ' + repo.repoName);
     }
 
+    // Update the plugin.xml(s)
+    var isPluginRepo = !!repoutil.isInRepoGroup(repo, 'plugins');
+    if (isPluginRepo) {
+        var xmlFilePaths = repo.xmlFilePaths || ['plugin.xml', 'tests/plugin.xml'];
+        xmlFilePaths.forEach(function(xmlFile) {
+            if (fs.existsSync(xmlFile)) {
+                fs.readFile(xmlFile, {encoding: 'utf-8'}, function (err, data) {
+                    if (err) throw err;
+                    xml2js.parseString(data, function(err, xml) {
+                        if (err) throw err;
+                        xml.plugin['$'].version = version;
+                        var xmlWriter = new xml2js.Builder();
+                        var xmlOutput = xmlWriter.buildObject(xml);
+                        fs.writeFileSync(xmlFile, xmlOutput + '\n');
+                    });
+                });
+            } else {
+                console.warn('No ' + xmlFile + ' file exists in repo ' + repo.repoName);
+            }
+        });
+        if (!(yield gitutil.pendingChangesExist())) {
+            apputil.print(xmlFilePaths + ' were already up-to-date.');
+        }
+    }
+
     var commitChanges = !!(opts ? opts.commitChanges : true);
     if (commitChanges && (yield gitutil.pendingChangesExist())) {
         yield executil.execHelper(executil.ARGS('git commit -am', 'Set VERSION to ' + version + ' (via coho)'));


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