Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E1EE7188E6 for ; Thu, 28 May 2015 06:49:00 +0000 (UTC) Received: (qmail 63893 invoked by uid 500); 28 May 2015 06:49:00 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 63869 invoked by uid 500); 28 May 2015 06:49:00 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 63860 invoked by uid 99); 28 May 2015 06:49:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 May 2015 06:49:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 81F95DFFA9; Thu, 28 May 2015 06:49:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: an-selm@apache.org To: commits@cordova.apache.org Message-Id: <3f57eb9a6ae44656a82ab47cebd2c0d4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cordova-windows git commit: CB-8889 Persist app/package name and product ID during platform update. This closes #87 Date: Thu, 28 May 2015 06:49:00 +0000 (UTC) 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 Authored: Wed May 27 14:22:54 2015 +0300 Committer: Vladimir Kotikov 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