You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2015/05/28 08:49:00 UTC

cordova-windows git commit: CB-8889 Persist app/package name and product ID during platform update. This closes #87

Repository: cordova-windows
Updated Branches:
  refs/heads/master 56adf7d5a -> 35a6cf908


CB-8889 Persist app/package name and product ID during platform update. This closes #87


Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/35a6cf90
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/35a6cf90
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/35a6cf90

Branch: refs/heads/master
Commit: 35a6cf908f5239c1c9ef81666e1dc2743ae820f9
Parents: 56adf7d
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Wed May 27 14:22:54 2015 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Thu May 28 09:46:46 2015 +0300

----------------------------------------------------------------------
 bin/lib/update.js | 42 ++++++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/35a6cf90/bin/lib/update.js
----------------------------------------------------------------------
diff --git a/bin/lib/update.js b/bin/lib/update.js
index 3f5a78c..95285ba 100644
--- a/bin/lib/update.js
+++ b/bin/lib/update.js
@@ -21,23 +21,35 @@ var Q      = require('Q'),
     fs     = require('fs'),
     path   = require('path'),
     shell   = require('shelljs'),
-    create = require('./create');
+    create = require('./create'),
+    ConfigParser = require('../../template/cordova/lib/ConfigParser');
 
 // returns package metadata from config.xml with fields 'namespace' and 'name'
 function extractMetadata(projectPath) {
-    if (!fs.existsSync(path.join(projectPath, 'config.xml'))){
+    var projectConfig = path.join(projectPath, 'config.xml');
+    if (!fs.existsSync(projectConfig)){
         return Q.reject('config.xml does not exist');
     }
 
-    var meta =  { // default values
-        namespace: 'io.cordova.hellocordova',
-        name: 'HelloCordova'
+    var config = new ConfigParser(projectConfig);
+    var meta =  {
+        packageName: config.packageName(),
+        name: config.name(),
+        guid: undefined
     };
 
-    // TODO: read real values from config.xml
-
-    // in case of Cordova CLI all values will be automatically updated by cli for you
-    // but the script could be used w/o CLI so we should correctly populate meta
+    // guid param is used only when adding a platform, and isn't saved anywhere.
+    // The only place, where it is being persisted - phone/win10 appxmanifest file,
+    // but since win10 introduced just recently, we're can't rely on its manifest
+    // for old platform versions.
+    var manifestPath = path.join(projectPath, 'package.phone.appxmanifest');
+    try {
+        var manifest = fs.readFileSync(manifestPath, 'utf-8');
+        var matches = /\bPhoneProductId="(.*?)"/gm.exec(manifest);
+        if (matches) {
+            meta.guid = matches[1];
+        }
+    } catch (e) { /*ignore IO errors */ }
 
     return Q.resolve(meta);
 }
@@ -59,11 +71,17 @@ module.exports.run = function (argv) {
             ' Please provide a path to the project you would like to update.');
     }
 
-    return extractMetadata(projectPath).then(function (metadata) {
+    return extractMetadata(projectPath)
+    .then(function (metadata) {
         shell.rm('-rf', projectPath);
 
         // setup args for create.run which requires process.argv-like array
-        var createArgs = argv.concat([metadata.namespace, metadata.name]);
+        var createArgs = argv.concat([metadata.packageName, metadata.name]);
+        if (metadata.guid) {
+            createArgs.push('--guid=' + metadata.guid);
+        }
+
         return create.run(createArgs);
     });
-};
\ No newline at end of file
+};
+


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