cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [2/4] git commit: CB-7520 .appxbundle package format support
Date Thu, 18 Sep 2014 23:19:17 GMT
CB-7520 .appxbundle package format support


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

Branch: refs/heads/master
Commit: b2848a979944f29d0b3e6a2167a4b3b1257bb261
Parents: 44afcd3
Author: sgrebnov <v-segreb@microsoft.com>
Authored: Thu Sep 4 18:36:28 2014 +0400
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Thu Sep 11 11:44:11 2014 +0400

----------------------------------------------------------------------
 windows/template/cordova/lib/package.js | 56 ++++++++++++----------------
 windows/template/cordova/lib/run.js     |  2 +-
 2 files changed, 24 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/b2848a97/windows/template/cordova/lib/package.js
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/package.js b/windows/template/cordova/lib/package.js
index 95a15c2..6538fdd 100644
--- a/windows/template/cordova/lib/package.js
+++ b/windows/template/cordova/lib/package.js
@@ -41,53 +41,43 @@ module.exports.getPackage = function (projectType, buildtype, buildArch)
{
         return fs.statSync(pkgDir).isDirectory();
     });
 
-    // Retrieve package infos for all packages found
-    // that corresponds to package properties provided
-    return Q.all(pkgDirs.map(function (pkgDir) {
-        // get info about package
-        return module.exports.getInfo(pkgDir).then(function(pkgInfo) {
+    for (var dir in pkgDirs) {
+        var packageFiles = fs.readdirSync(pkgDirs[dir]).filter(function(e) {
+            return e.match('.*.(appx|appxbundle)$');
+        });
+
+        for (var pkgFile in packageFiles) {
+            var packageFile = path.join(pkgDirs[dir], packageFiles[pkgFile]);
+            var pkgInfo = module.exports.getPackageFileInfo(packageFile);
+
             if (pkgInfo && pkgInfo.type == projectType &&
                 pkgInfo.arch == buildArch && pkgInfo.buildtype == buildtype) {
                 // if package's properties are corresponds to properties provided
                 // resolve the promise with this package's info
                 return Q.resolve(pkgInfo);
             }
-            // else resove with no info
-            return Q.resolve();
-        });
-    })).then(function (packages) {
-        for (var idx in packages) {
-            // iterate through infos found and resolve with first
-            if (packages[idx]) {
-                return Q.resolve(packages[idx]);
-            }
         }
-        // else reject because seems that no corresponding packages found
-        return Q.reject('Package with specified parameters not found in AppPackages folder');
-    });
+    }
+    // reject because seems that no corresponding packages found
+    return Q.reject('Package with specified parameters not found in AppPackages folder');
 };
 
 // returns package info object or null if it is not valid package
-module.exports.getInfo = function (packagePath) {
-    if (!fs.statSync(packagePath).isDirectory()){
-        return Q.reject('Provided path is not a directory');
-    }
-    // This RE matches with package folder name like:
-    // CordovaApp.Phone_0.0.1.0_AnyCPU_Debug_Test
-    // Group:     ( 1 ) (  2  ) (  3 ) ( 4 )
-    var props = /.*\.(Phone|Windows|Windows80)_((?:\d\.)*\d)_(AnyCPU|x64|x86|ARM)(?:_(Debug))?_Test$/i.exec(path.basename(packagePath));
-    if (props){
-        // return package info object inside of promise
-        return Q.resolve({path: packagePath,
-            type      : props[1].toLowerCase(),
+module.exports.getPackageFileInfo = function (packageFile) {
+    var pkgName = path.basename(packageFile);
+    // CordovaApp.Windows_0.0.1.0_anycpu_debug.appx
+    // CordovaApp.Phone_0.0.1.0_x86_debug.appxbundle
+    var props = /.*\.(Phone|Windows|Windows80)_((?:\d\.)*\d)_(AnyCPU|x64|x86|ARM)(?:_(Debug))?.(appx|appxbundle)$/i.exec(pkgName);
+    if (props) {
+        return {type      : props[1].toLowerCase(),
             arch      : props[3].toLowerCase(),
             buildtype : props[4] ? props[4].toLowerCase() : "release",
             file      : props[1].toLowerCase() != "phone" ?
-                path.join(packagePath, 'Add-AppDevPackage.ps1') :
-                path.join(packagePath, path.basename(packagePath).replace(/_test$/i, '')
+ '.appx')
-        });
+                path.join(packageFile, '..', 'Add-AppDevPackage.ps1') :
+                packageFile
+        };
     }
-    return Q.reject('Can\'t fetch info for package at ' + packagePath);
+    return null;
 };
 
 // return package app ID fetched from appxmanifest

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/b2848a97/windows/template/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/run.js b/windows/template/cordova/lib/run.js
index 87fe36d..1bd1904 100644
--- a/windows/template/cordova/lib/run.js
+++ b/windows/template/cordova/lib/run.js
@@ -65,7 +65,7 @@ module.exports.run = function (argv) {
     return buildPackages.then(function () {
         return packages.getPackage(projectType, buildType, buildArchs[0]);
     }).then(function(pkg) {
-        console.log('\nDeploying ' + pkg.type + ' package to ' + deployTarget);
+        console.log('\nDeploying ' + pkg.type + ' package to ' + deployTarget + ':\n' + pkg.file);
         return pkg.type == "phone" ?
             packages.deployToPhone(pkg.file, deployTarget) :
             packages.deployToDesktop(pkg.file, deployTarget);


Mime
View raw message