You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/06/21 02:44:13 UTC

[1/2] git commit: CB-6976 Add support for Windows Universal apps (Windows 8.1 and WP 8.1)

Repository: cordova-lib
Updated Branches:
  refs/heads/master 67d9679c0 -> e6923ac01


CB-6976 Add support for Windows Universal apps (Windows 8.1 and WP 8.1)


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

Branch: refs/heads/master
Commit: 7ed25a53a793a2af3ff3bc51799ef65fa302a643
Parents: d23aee3
Author: sgrebnov <v-...@microsoft.com>
Authored: Fri Jun 20 16:53:45 2014 +0400
Committer: sgrebnov <v-...@microsoft.com>
Committed: Fri Jun 20 16:53:45 2014 +0400

----------------------------------------------------------------------
 .../spec-plugman/platforms/windows8.spec.js     |   2 +-
 cordova-lib/src/cordova/lazy_load.js            |   4 +
 .../src/cordova/metadata/windows8_parser.js     | 321 ------------------
 .../src/cordova/metadata/windows_parser.js      | 338 +++++++++++++++++++
 cordova-lib/src/cordova/platform.js             |  12 +
 cordova-lib/src/cordova/platforms.js            |  15 +-
 cordova-lib/src/cordova/prepare.js              |   7 +
 cordova-lib/src/plugman/install.js              |   5 +
 cordova-lib/src/plugman/platforms.js            |   3 +-
 cordova-lib/src/plugman/platforms/windows.js    | 146 ++++++++
 cordova-lib/src/plugman/platforms/windows8.js   | 136 --------
 cordova-lib/src/plugman/prepare.js              |  15 +-
 cordova-lib/src/plugman/uninstall.js            |   5 +
 cordova-lib/src/plugman/util/config-changes.js  |  25 ++
 cordova-lib/src/util/windows/jsproj.js          |  15 +-
 15 files changed, 579 insertions(+), 470 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/spec-plugman/platforms/windows8.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/windows8.spec.js b/cordova-lib/spec-plugman/platforms/windows8.spec.js
index 6683f74..ee68bd8 100644
--- a/cordova-lib/spec-plugman/platforms/windows8.spec.js
+++ b/cordova-lib/spec-plugman/platforms/windows8.spec.js
@@ -16,7 +16,7 @@
     specific language governing permissions and limitations
     under the License.
 */
-var windows8 = require('../../src/plugman/platforms/windows8'),
+var windows8 = require('../../src/plugman/platforms/windows'),
     common  = require('../../src/plugman/platforms/common'),
     install = require('../../src/plugman/install'),
     path    = require('path'),

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/cordova/lazy_load.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/lazy_load.js b/cordova-lib/src/cordova/lazy_load.js
index c157cc2..984d745 100644
--- a/cordova-lib/src/cordova/lazy_load.js
+++ b/cordova-lib/src/cordova/lazy_load.js
@@ -75,6 +75,10 @@ function cordova_git(platform) {
     }
 
     var url = platforms[platform].url + ';a=snapshot;h=' + platforms[platform].version + ';sf=tgz';
+    var url = platforms[platform].url + ';a=snapshot;h=' + platforms[platform].version + ';sf=tgz';
+    if (platform == 'windows' || platform == 'windows8') {
+        url = platforms[platform].url; // TODO tmp hack for win81. Must be removed.
+    }
     return module.exports.custom(url, 'cordova', platform, platforms[platform].version);
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/cordova/metadata/windows8_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/windows8_parser.js b/cordova-lib/src/cordova/metadata/windows8_parser.js
deleted file mode 100644
index b68c934..0000000
--- a/cordova-lib/src/cordova/metadata/windows8_parser.js
+++ /dev/null
@@ -1,321 +0,0 @@
-/**
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-*/
-
-/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
-          indent:4, unused:vars, latedef:nofunc, sub:true
-*/
-
-var fs            = require('fs'),
-    path          = require('path'),
-    util          = require('../util'),
-    events        = require('../../events'),
-    shell         = require('shelljs'),
-    Q             = require('q'),
-    child_process = require('child_process'),
-    ConfigParser  = require('../../configparser/ConfigParser'),
-    CordovaError  = require('../../CordovaError'),
-    xml           = require('../../util/xml-helpers'),
-    config        = require('../config'),
-    hooker        = require('../hooker'),
-    jsproj        = require('../../util/windows/jsproj');
-
-module.exports = function windows8_parser(project) {
-    try {
-        // TODO : Check that it's not a windows8 project?
-        var jsproj_file   = fs.readdirSync(project).filter(function(e) { return e.match(/\.jsproj$/i); })[0];
-        if (!jsproj_file) throw new CordovaError('No .jsproj file in "'+project+'"');
-        this.windows8_proj_dir = project;
-        this.jsproj_path  = path.join(this.windows8_proj_dir, jsproj_file);
-        this.sln_path     = path.join(this.windows8_proj_dir, jsproj_file.replace(/\.jsproj/, '.sln'));
-    } catch(e) {
-        throw new CordovaError('The provided path "' + project + '" is not a Windows 8 project. ' + e);
-    }
-    this.manifest_path  = path.join(this.windows8_proj_dir, 'package.appxmanifest');
-};
-
-// Returns a promise
-module.exports.check_requirements = function(project_root) {
-    events.emit('log', 'Checking windows8 requirements...');
-    var lib_path = path.join(util.libDirectory, 'windows8', 'cordova',
-                    require('../platforms').windows8.version, 'windows8');
-
-    var custom_path = config.has_custom_path(project_root, 'windows8');
-    if (custom_path) {
-        lib_path = path.join(custom_path, 'windows8');
-    }
-    var command = '"' + path.join(lib_path, 'bin', 'check_reqs') + '"';
-    events.emit('verbose', 'Running "' + command + '" (output to follow)');
-    var d = Q.defer();
-
-    child_process.exec(command, function(err, output, stderr) {
-        events.emit('verbose', output);
-        if (err) {
-            d.reject(new CordovaError('Requirements check failed: ' + output + stderr));
-        } else {
-            d.resolve();
-        }
-    });
-    return d.promise;
-};
-
-module.exports.prototype = {
-
-    update_from_config:function(config) {
-
-        //check config parser
-        if (config instanceof ConfigParser) {
-        } else throw new Error('update_from_config requires a ConfigParser object');
-
-        //Get manifest file
-        var manifest = xml.parseElementtreeSync(this.manifest_path);
-
-        var version = this.fixConfigVersion(config.version());
-        var name = config.name();
-        var pkgName = config.packageName();
-        var author = config.author();
-
-        var identityNode = manifest.find('.//Identity');
-        if(identityNode) {
-            // Update app name in identity
-            var appIdName = identityNode['attrib']['Name'];
-            if (appIdName != pkgName) {
-                identityNode['attrib']['Name'] = pkgName;
-            }
-
-            // Update app version
-            var appVersion = identityNode['attrib']['Version'];
-            if(appVersion != version) {
-                identityNode['attrib']['Version'] = version;
-            }
-        }
-
-        // Update name (windows8 has it in the Application[@Id] and Application.VisualElements[@DisplayName])
-        var app = manifest.find('.//Application');
-        if(app) {
-
-            var appId = app['attrib']['Id'];
-
-            if (appId != pkgName) {
-                app['attrib']['Id'] = pkgName;
-            }
-
-            var visualElems = manifest.find('.//VisualElements') || manifest.find('.//m2:VisualElements');
-
-            if(visualElems) {
-                var displayName = visualElems['attrib']['DisplayName'];
-                if(displayName != name) {
-                    visualElems['attrib']['DisplayName'] = name;
-                }
-            }
-            else {
-                throw new Error('update_from_config expected a valid package.appxmanifest' +
-                                ' with a <VisualElements> node');
-            }
-        }
-        else {
-            throw new Error('update_from_config expected a valid package.appxmanifest' +
-                            ' with a <Application> node');
-        }
-
-        // Update properties
-        var properties = manifest.find('.//Properties');
-        if (properties && properties.find) {
-            var displayNameElement = properties.find('.//DisplayName');
-            if (displayNameElement && displayNameElement.text != name) {
-                displayNameElement.text = name;
-            }
-
-            var publisherNameElement = properties.find('.//PublisherDisplayName');
-            if (publisherNameElement && publisherNameElement.text != author) {
-                publisherNameElement.text = author;
-            }
-        }
-
-        // sort Capability elements as per CB-5350 Windows8 build fails due to invalid 'Capabilities' definition
-        // to sort elements we remove them and then add again in the appropriate order
-        var capabilitiesRoot = manifest.find('.//Capabilities'),
-            capabilities = capabilitiesRoot._children || [];
-
-        capabilities.forEach(function(elem){
-            capabilitiesRoot.remove(0, elem);
-        });
-        capabilities.sort(function(a, b) {
-            return (a.tag > b.tag)? 1: -1;
-        });
-        capabilities.forEach(function(elem){
-            capabilitiesRoot.append(elem);
-        });
-
-        //Write out manifest
-        fs.writeFileSync(this.manifest_path, manifest.write({indent: 4}), 'utf-8');
-
-        // Update icons
-        var icons = config.getIcons('windows8');
-        var platformRoot = this.windows8_proj_dir;
-        var appRoot = util.isCordova(platformRoot);
-
-        // Icons, that should be added to platform
-        var platformIcons = [
-            {dest: 'images/logo.png', width: 150, height: 150},
-            {dest: 'images/smalllogo.png', width: 30, height: 30},
-            {dest: 'images/storelogo.png', width: 50, height: 50},
-        ];
-
-        platformIcons.forEach(function (item) {
-            var icon = icons.getIconBySize(item.width, item.height) || icons.getDefault();
-            if (icon){
-                var src = path.join(appRoot, icon.src),
-                    dest = path.join(platformRoot, item.dest);
-                events.emit('verbose', 'Copying icon from ' + src + ' to ' + dest);
-                shell.cp('-f', src, dest);
-            }
-        });
-
-    },
-    // Returns the platform-specific www directory.
-    www_dir:function() {
-        return path.join(this.windows8_proj_dir, 'www');
-    },
-    config_xml:function() {
-        return path.join(this.windows8_proj_dir,'config.xml');
-    },
-    // copy files from merges directory to actual www dir
-    copy_merges:function(merges_sub_path) {
-        var merges_path = path.join(util.appDir(util.isCordova(this.windows8_proj_dir)), 'merges', merges_sub_path);
-        if (fs.existsSync(merges_path)) {
-            var overrides = path.join(merges_path, '*');
-            shell.cp('-rf', overrides, this.www_dir());
-        }
-    },
-
-    // Used for creating platform_www in projects created by older versions.
-    cordovajs_path:function(libDir) {
-        var jsPath = path.join(libDir, 'template', 'www', 'cordova.js');
-        return path.resolve(jsPath);
-    },
-
-    // Replace the www dir with contents of platform_www and app www and updates the csproj file.
-    update_www:function() {
-        var projectRoot = util.isCordova(this.windows8_proj_dir);
-        var app_www = util.projectWww(projectRoot);
-        var platform_www = path.join(this.windows8_proj_dir, 'platform_www');
-
-        // Clear the www dir
-        shell.rm('-rf', this.www_dir());
-        shell.mkdir(this.www_dir());
-        // Copy over all app www assets
-        shell.cp('-rf', path.join(app_www, '*'), this.www_dir());
-
-        // Copy all files from merges directory.
-        this.copy_merges('windows8');
-
-        // Copy over stock platform www assets (cordova.js)
-        shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
-    },
-
-    // updates the jsproj file to explicitly list all www content.
-    update_jsproj:function() {
-        var projFile = new jsproj(this.jsproj_path);
-
-        // remove any previous references to the www files
-        projFile.removeSourceFile(new RegExp('www\\\\*', 'i'));
-
-        // now add all www references back in from the root www folder
-        var www_files = this.folder_contents('www', this.www_dir());
-        for(var file in www_files) {
-            projFile.addSourceFile(www_files[file]);
-        }
-        // save file
-        projFile.write();
-    },
-    // Returns an array of all the files in the given directory with relative paths
-    // - name     : the name of the top level directory (i.e all files will start with this in their path)
-    // - dir     : the directory whos contents will be listed under 'name' directory
-    folder_contents:function(name, dir) {
-        var results = [];
-        var folder_dir = fs.readdirSync(dir);
-        for(var item in folder_dir) {
-            var stat = fs.statSync(path.join(dir, folder_dir[item]));
-            // Add all subfolder item paths if it's not a .svn dir.
-            if( stat.isDirectory() && (folder_dir[item] !== '.svn') ) {
-                var sub_dir = this.folder_contents(path.join(name, folder_dir[item]), path.join(dir, folder_dir[item]));
-                for(var sub_item in sub_dir) {
-                    results.push(sub_dir[sub_item]);
-                }
-            } else if(stat.isFile()) {
-                results.push(path.join(name, folder_dir[item]));
-            }
-            // else { it is a FIFO, or a Socket, Symbolic Link or something ... }
-        }
-        return results;
-    },
-
-    // calls the nessesary functions to update the windows8 project
-    update_project:function(cfg) {
-        //console.log("Updating windows8 project...");
-
-        try {
-            this.update_from_config(cfg);
-        } catch(e) {
-            return Q.reject(e);
-        }
-
-        var that = this;
-        var projectRoot = util.isCordova(process.cwd());
-
-        var hooks = new hooker(projectRoot);
-        return hooks.fire('pre_package', { wwwPath:this.www_dir(), platforms: ['windows8'] })
-        .then(function() {
-            // overrides (merges) are handled in update_www()
-            that.update_jsproj();
-            that.add_bom();
-            util.deleteSvnFolders(that.www_dir());
-        });
-    },
-
-    // Adjust version number as per CB-5337 Windows8 build fails due to invalid app version
-    fixConfigVersion: function (version) {
-        if(version && version.match(/\.\d/g)) {
-            var numVersionComponents = version.match(/\.\d/g).length + 1;
-            while (numVersionComponents++ < 4) {
-                version += '.0';
-            }
-        }
-        return version;
-    },
-
-    // CB-5421 Add BOM to all html, js, css files to ensure app can pass Windows Store Certification
-    add_bom: function () {
-        var www = this.www_dir();
-        var files = shell.ls('-R', www);
-
-        files.forEach(function (file) {
-            if (!file.match(/\.(js|html|css|json)/)) {
-                return;
-            }
-
-            var filePath = path.join(www, file);
-            var content = fs.readFileSync(filePath);
-
-            if (content[0] !== 0xEF && content[1] !== 0xBE && content[2] !== 0xBB) {
-                fs.writeFileSync(filePath, '\ufeff' + content);
-            }
-        });
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/cordova/metadata/windows_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/windows_parser.js b/cordova-lib/src/cordova/metadata/windows_parser.js
new file mode 100644
index 0000000..9907c9a
--- /dev/null
+++ b/cordova-lib/src/cordova/metadata/windows_parser.js
@@ -0,0 +1,338 @@
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc, sub:true
+*/
+
+var fs            = require('fs'),
+    path          = require('path'),
+    util          = require('../util'),
+    events        = require('../../events'),
+    shell         = require('shelljs'),
+    Q             = require('q'),
+    child_process = require('child_process'),
+    ConfigParser  = require('../../configparser/ConfigParser'),
+    CordovaError  = require('../../CordovaError'),
+    xml           = require('../../util/xml-helpers'),
+    config        = require('../config'),
+    hooker        = require('../hooker'),
+    jsproj        = require('../../util/windows/jsproj');
+
+module.exports = function windows_parser(project) {
+    try {
+        this.isOldProjectTemplate = false;
+        // Check that it's a universal windows store project
+        var projFile = fs.readdirSync(project).filter(function(e) { return e.match(/\.projitems$/i); })[0];
+        if (!projFile) {
+            this.isOldProjectTemplate = true;
+            projFile = fs.readdirSync(project).filter(function(e) { return e.match(/\.jsproj$/i); })[0];
+        }
+        if (!projFile) {
+            throw new CordovaError('No project file in "'+project+'"');
+        }
+        this.projDir = project;
+        this.projFilePath = path.join(this.projDir, projFile);
+
+        if (this.isOldProjectTemplate) {
+            this.manifestPath = path.join(this.projDir, 'package.appxmanifest');
+        }
+
+    } catch(e) {
+        throw new CordovaError('The provided path "' + project + '" is not a Windows project. ' + e);
+    }
+};
+
+// Returns a promise
+module.exports.check_requirements = function(project_root) {
+    events.emit('log', 'Checking windows requirements...');
+    var lib_path = path.join(util.libDirectory, 'windows', 'cordova',
+                    require('../platforms').windows.version, 'windows');
+
+    var custom_path = config.has_custom_path(project_root, 'windows8') ||
+        config.has_custom_path(project_root, 'windows');
+    if (custom_path) {
+        lib_path = path.join(custom_path, "windows");
+    }
+    var command = '"' + path.join(lib_path, 'bin', 'check_reqs') + '"';
+    events.emit('verbose', 'Running "' + command + '" (output to follow)');
+    var d = Q.defer();
+
+    child_process.exec(command, function(err, output, stderr) {
+        events.emit('verbose', output);
+        if (err) {
+            d.reject(new CordovaError('Requirements check failed: ' + output + stderr));
+        } else {
+            d.resolve();
+        }
+    });
+    return d.promise;
+};
+
+module.exports.prototype = {
+
+    update_from_config:function(config) {
+
+        //check config parser
+        if (config instanceof ConfigParser) {
+        } else throw new Error('update_from_config requires a ConfigParser object');
+
+        if (!this.isOldProjectTemplate) {
+            return;
+        }
+
+        // code below is required for compatibility reason. New template version is not required this anymore.
+
+        //Get manifest file
+        var manifest = xml.parseElementtreeSync(this.manifestPath);
+
+        var version = this.fixConfigVersion(config.version());
+        var name = config.name();
+        var pkgName = config.packageName();
+        var author = config.author();
+
+        var identityNode = manifest.find('.//Identity');
+        if(identityNode) {
+            // Update app name in identity
+            var appIdName = identityNode['attrib']['Name'];
+            if (appIdName != pkgName) {
+                identityNode['attrib']['Name'] = pkgName;
+            }
+
+            // Update app version
+            var appVersion = identityNode['attrib']['Version'];
+            if(appVersion != version) {
+                identityNode['attrib']['Version'] = version;
+            }
+        }
+
+        // Update name (windows8 has it in the Application[@Id] and Application.VisualElements[@DisplayName])
+        var app = manifest.find('.//Application');
+        if(app) {
+
+            var appId = app['attrib']['Id'];
+
+            if (appId != pkgName) {
+                app['attrib']['Id'] = pkgName;
+            }
+
+            var visualElems = manifest.find('.//VisualElements') || manifest.find('.//m2:VisualElements');
+
+            if(visualElems) {
+                var displayName = visualElems['attrib']['DisplayName'];
+                if(displayName != name) {
+                    visualElems['attrib']['DisplayName'] = name;
+                }
+            }
+            else {
+                throw new Error('update_from_config expected a valid package.appxmanifest' +
+                                ' with a <VisualElements> node');
+            }
+        }
+        else {
+            throw new Error('update_from_config expected a valid package.appxmanifest' +
+                            ' with a <Application> node');
+        }
+
+        // Update properties
+        var properties = manifest.find('.//Properties');
+        if (properties && properties.find) {
+            var displayNameElement = properties.find('.//DisplayName');
+            if (displayNameElement && displayNameElement.text != name) {
+                displayNameElement.text = name;
+            }
+
+            var publisherNameElement = properties.find('.//PublisherDisplayName');
+            if (publisherNameElement && publisherNameElement.text != author) {
+                publisherNameElement.text = author;
+            }
+        }
+
+        // sort Capability elements as per CB-5350 Windows8 build fails due to invalid 'Capabilities' definition
+        // to sort elements we remove them and then add again in the appropriate order
+        var capabilitiesRoot = manifest.find('.//Capabilities'),
+            capabilities = capabilitiesRoot._children || [];
+
+        capabilities.forEach(function(elem){
+            capabilitiesRoot.remove(0, elem);
+        });
+        capabilities.sort(function(a, b) {
+            return (a.tag > b.tag)? 1: -1;
+        });
+        capabilities.forEach(function(elem){
+            capabilitiesRoot.append(elem);
+        });
+
+        //Write out manifest
+        fs.writeFileSync(this.manifestPath, manifest.write({indent: 4}), 'utf-8');
+
+        // Update icons
+        var icons = config.getIcons('windows8');
+        var platformRoot = this.projDir;
+        var appRoot = util.isCordova(platformRoot);
+
+        // Icons, that should be added to platform
+        var platformIcons = [
+            {dest: 'images/logo.png', width: 150, height: 150},
+            {dest: 'images/smalllogo.png', width: 30, height: 30},
+            {dest: 'images/storelogo.png', width: 50, height: 50},
+        ];
+
+        platformIcons.forEach(function (item) {
+            var icon = icons.getIconBySize(item.width, item.height) || icons.getDefault();
+            if (icon){
+                var src = path.join(appRoot, icon.src),
+                    dest = path.join(platformRoot, item.dest);
+                events.emit('verbose', 'Copying icon from ' + src + ' to ' + dest);
+                shell.cp('-f', src, dest);
+            }
+        });
+    },
+
+    // Returns the platform-specific www directory.
+    www_dir:function() {
+        return path.join(this.projDir, 'www');
+    },
+    config_xml:function() {
+        return path.join(this.projDir,'config.xml');
+    },
+    // copy files from merges directory to actual www dir
+    copy_merges:function(merges_sub_path) {
+        var merges_path = path.join(util.appDir(util.isCordova(this.projDir)), 'merges', merges_sub_path);
+        if (fs.existsSync(merges_path)) {
+            var overrides = path.join(merges_path, '*');
+            shell.cp('-rf', overrides, this.www_dir());
+        }
+    },
+
+    // Used for creating platform_www in projects created by older versions.
+    cordovajs_path:function(libDir) {
+        var jsPath = path.join(libDir, 'template', 'www', 'cordova.js');
+        return path.resolve(jsPath);
+    },
+
+    // Replace the www dir with contents of platform_www and app www and updates the csproj file.
+    update_www:function() {
+        var projectRoot = util.isCordova(this.projDir);
+        var app_www = util.projectWww(projectRoot);
+        var platform_www = path.join(this.projDir, 'platform_www');
+
+        // Clear the www dir
+        shell.rm('-rf', this.www_dir());
+        shell.mkdir(this.www_dir());
+        // Copy over all app www assets
+        shell.cp('-rf', path.join(app_www, '*'), this.www_dir());
+
+        // Copy all files from merges directory.
+        this.copy_merges('windows8');
+
+        // Copy over stock platform www assets (cordova.js)
+        shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+    },
+
+    // Returns an array of all the files in the given directory with relative paths
+    // - name     : the name of the top level directory (i.e all files will start with this in their path)
+    // - dir     : the directory whos contents will be listed under 'name' directory
+    folder_contents:function(name, dir) {
+        var results = [];
+        var folder_dir = fs.readdirSync(dir);
+        for(var item in folder_dir) {
+            var stat = fs.statSync(path.join(dir, folder_dir[item]));
+            // Add all subfolder item paths if it's not a .svn dir.
+            if( stat.isDirectory() && (folder_dir[item] !== '.svn') ) {
+                var sub_dir = this.folder_contents(path.join(name, folder_dir[item]), path.join(dir, folder_dir[item]));
+                for(var sub_item in sub_dir) {
+                    results.push(sub_dir[sub_item]);
+                }
+            } else if(stat.isFile()) {
+                results.push(path.join(name, folder_dir[item]));
+            }
+            // else { it is a FIFO, or a Socket, Symbolic Link or something ... }
+        }
+        return results;
+    },
+
+    // updates the jsproj file to explicitly list all www content.
+    update_jsproj:function() {
+        var projFile = new jsproj(this.projFilePath);
+        // remove any previous references to the www files
+        projFile.removeSourceFile(/^(\$\(MSBuildThisFileDirectory\))?www\\/i);
+
+        // now add all www references back in from the root www folder
+        var www_files = this.folder_contents('www', this.www_dir());
+        for(file in www_files) {
+            projFile.addSourceFile(www_files[file]);
+        }
+        // save file
+        projFile.write();
+    },
+
+    // calls the nessesary functions to update the windows8 project
+    update_project:function(cfg) {
+        // console.log("Updating windows8 project...");
+
+        try {
+            this.update_from_config(cfg);
+        } catch(e) {
+            return Q.reject(e);
+        }
+
+        var that = this;
+        var projectRoot = util.isCordova(process.cwd());
+
+        var hooks = new hooker(projectRoot);
+        return hooks.fire('pre_package', { wwwPath:this.www_dir(), platforms: ['windows8'] })
+        .then(function() {
+            // overrides (merges) are handled in update_www()
+            that.update_jsproj();
+            that.add_bom();
+            util.deleteSvnFolders(that.www_dir());
+        });
+    },
+
+    // Adjust version number as per CB-5337 Windows8 build fails due to invalid app version
+    fixConfigVersion: function (version) {
+        if(version && version.match(/\.\d/g)) {
+            var numVersionComponents = version.match(/\.\d/g).length + 1;
+            while (numVersionComponents++ < 4) {
+                version += '.0';
+            }
+        }
+        return version;
+    },
+
+    // CB-5421 Add BOM to all html, js, css files to ensure app can pass Windows Store Certification
+    add_bom: function () {
+        var www = this.www_dir();
+        var files = shell.ls('-R', www);
+
+        files.forEach(function (file) {
+            if (!file.match(/\.(js|html|css|json)/)) {
+                return;
+            }
+
+            var filePath = path.join(www, file);
+            var content = fs.readFileSync(filePath);
+
+            if (content[0] !== 0xEF && content[1] !== 0xBE && content[2] !== 0xBB) {
+                fs.writeFileSync(filePath, '\ufeff' + content);
+            }
+        });
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index eefba91..db20853 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -166,6 +166,13 @@ function update(hooks, projectRoot, targets, opts) {
               cordova_util.binname + ' platform list`.';
         return Q.reject(new CordovaError(msg));
     }
+    // CB-6976 Windows Universal Apps. Special case to upgrade from windows8 to windows platform 
+    if (plat == 'windows8' && !fs.existsSync(path.join(projectRoot, 'platforms', 'windows'))) {
+        var platformPathWindows = path.join(projectRoot, 'platforms', 'windows');
+        fs.renameSync(platformPath, platformPathWindows)
+        plat = 'windows';
+        platformPath = platformPathWindows;
+    }
 
     // First, lazy_load the latest version.
     return hooks.fire('before_platform_update', opts)
@@ -344,6 +351,11 @@ function platform(command, targets, opts) {
 
     switch(command) {
         case 'add':
+            // CB-6976 Windows Universal Apps. windows8 is now alias for windows
+            var idxWindows8 = targets.indexOf('windows8');
+            if (idxWindows8 >=0) {
+                targets[idxWindows8] = 'windows';
+            }
             return add(hooks, projectRoot, targets, opts);
         case 'rm':
         case 'remove':

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/cordova/platforms.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platforms.js b/cordova-lib/src/cordova/platforms.js
index 5ada624..6570266 100644
--- a/cordova-lib/src/cordova/platforms.js
+++ b/cordova-lib/src/cordova/platforms.js
@@ -69,10 +69,17 @@ module.exports = {
     },
     'windows8':{
         hostos : ['win32'],
-        parser: './metadata/windows8_parser',
-        url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git',
-        version: '3.5.0',
-        subdirectory: 'windows8'
+        parser: './metadata/windows_parser',
+        url    : 'http://github.com/MSOpenTech/cordova-windows/archive/win81.tar.gz',
+        version: '3.6.0',
+        subdirectory: 'windows'
+    },
+    'windows':{
+        hostos : ['win32'],
+        parser: './metadata/windows_parser',
+        url    : 'http://github.com/MSOpenTech/cordova-windows/archive/win81.tar.gz',
+        version: '3.6.0',
+        subdirectory: 'windows'
     }
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/cordova/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/prepare.js b/cordova-lib/src/cordova/prepare.js
index be48c51..0615c97 100644
--- a/cordova-lib/src/cordova/prepare.js
+++ b/cordova-lib/src/cordova/prepare.js
@@ -111,6 +111,13 @@ exports = module.exports = function prepare(options) {
                 // Update platform config.xml based on top level config.xml
                 var platform_cfg = new ConfigParser(parser.config_xml());
                 exports._mergeXml(cfg.doc.getroot(), platform_cfg.doc.getroot(), platform, true);
+
+                // CB-6976 Windows Universal Apps. For smooth transition and to prevent mass api failures
+                // we allow using windows8 tag for new windows platform
+                if (platform == 'windows') {
+                    exports._mergeXml(cfg.doc.getroot(), platform_cfg.doc.getroot(), 'windows8', true);
+                }
+
                 platform_cfg.write();
 
                 return parser.update_project(cfg);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index 8e6205f..e17f941 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -510,6 +510,11 @@ function handleInstall(actions, pluginInfo, platform, project_dir, plugins_dir,
     var handler = platform_modules[platform];
 
     var platformTag = pluginInfo._et.find('./platform[@name="'+platform+'"]');
+    // CB-6976 Windows Universal Apps. For smooth transition and to prevent mass api failures
+    // we allow using windows8 tag for new windows platform
+    if (platform == 'windows' && !platformTag) {
+        platformTag = pluginInfo._et.find('platform[@name="' + 'windows8' + '"]');
+    }
     if ( pluginInfo.hasPlatformSection(platform) ) {
         var sourceFiles = platformTag.findall('./source-file'),
             headerFiles = platformTag.findall('./header-file'),

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/plugman/platforms.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms.js b/cordova-lib/src/plugman/platforms.js
index 4ebdc49..e7cd427 100644
--- a/cordova-lib/src/plugman/platforms.js
+++ b/cordova-lib/src/plugman/platforms.js
@@ -27,7 +27,8 @@ module.exports = {
     'ios': require('./platforms/ios'),
     'blackberry10': require('./platforms/blackberry10'),
     'wp8': require('./platforms/wp8'),
-    'windows8' : require('./platforms/windows8'),
+    'windows8' : require('./platforms/windows'),
+    'windows' : require('./platforms/windows'),
     'firefoxos': require('./platforms/firefoxos'),
     'ubuntu': require('./platforms/ubuntu'),
     'tizen': require('./platforms/tizen')

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/plugman/platforms/windows.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/windows.js b/cordova-lib/src/plugman/platforms/windows.js
new file mode 100644
index 0000000..21cdfd0
--- /dev/null
+++ b/cordova-lib/src/plugman/platforms/windows.js
@@ -0,0 +1,146 @@
+/*
+ *
+ * Copyright 2013 Jesse MacFadyen
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc,
+          laxcomma:true, sub:true
+*/
+
+var common = require('./common'),
+    path = require('path'),
+    glob = require('glob'),
+    jsproj = require('../../util/windows/jsproj'),
+    events = require('../../events'),
+    xml_helpers = require('../../util/xml-helpers');
+
+module.exports = {
+    platformName:"windows",
+    InvalidProjectPathError:'does not appear to be a Windows 8 or Unified Windows Store project (no .projitems|jsproj file)',
+    www_dir:function(project_dir) {
+        return path.join(project_dir, 'www');
+    },
+    package_name:function(project_dir) {
+        // CB-6976 Windows Universal Apps. To make platform backward compatible
+        // with old template we look for package.appxmanifest file as well.
+        var manifestPath = fs.existsSync(path.join(project_dir, 'package.store.appxmanifest')) ?
+            path.join(project_dir, 'package.store.appxmanifest') :
+            path.join(project_dir, 'package.appxmanifest');
+
+        var manifest = xml_helpers.parseElementtreeSync(manifestPath);
+        return manifest.find("Properties/DisplayName").text;
+    },
+    parseProjectFile:function(project_dir) {
+        var project_files = glob.sync('*.projitems', { cwd:project_dir });
+        if (project_files.length === 0) {
+            // Windows8.1: for smooth transition and to prevent
+            // plugin handling failures we search for old *.jsproj also.
+            project_files = glob.sync('*.jsproj', { cwd:project_dir });
+            if (project_files.length === 0) {
+                throw new Error(this.InvalidProjectPathError);
+            }
+        }
+        return new jsproj(path.join(project_dir, project_files[0]));
+    },
+    'source-file': {
+        install:function(source_el, plugin_dir, project_dir, plugin_id, project_file) {
+            var targetDir = source_el.attrib['target-dir'] || '';
+            var dest = path.join('www', 'plugins', plugin_id, targetDir, path.basename(source_el.attrib['src']));
+
+            common.copyNewFile(plugin_dir, source_el.attrib['src'], project_dir, dest);
+            // add reference to this file to jsproj.
+            project_file.addSourceFile(dest);
+        },
+        uninstall:function(source_el, project_dir, plugin_id, project_file) {
+            var dest = path.join('www', 'plugins', plugin_id,
+                                 source_el.attrib['target-dir'] ? source_el.attrib['target-dir'] : '',
+                                 path.basename(source_el.attrib['src']));
+            common.removeFile(project_dir, dest);
+            // remove reference to this file from csproj.
+            project_file.removeSourceFile(dest);
+        }
+    },
+    'header-file': {
+        install:function(source_el, plugin_dir, project_dir, plugin_id) {
+            events.emit('verbose', 'header-fileinstall is not supported for Windows 8');
+        },
+        uninstall:function(source_el, project_dir, plugin_id) {
+            events.emit('verbose', 'header-file.uninstall is not supported for Windows 8');
+        }
+    },
+    'resource-file':{
+        install:function(el, plugin_dir, project_dir, plugin_id, project_file) {
+            events.emit('verbose', 'resource-file is not supported for Windows 8');
+        },
+        uninstall:function(el, project_dir, plugin_id, project_file) {
+        }
+    },
+    'lib-file': {
+        install:function(el, plugin_dir, project_dir, plugin_id, project_file) {
+            var inc  = el.attrib['Include'];
+            project_file.addSDKRef(inc);
+        },
+        uninstall:function(el, project_dir, plugin_id, project_file) {
+            events.emit('verbose', 'windows8 lib-file uninstall :: ' + plugin_id);
+            var inc = el.attrib['Include'];
+            project_file.removeSDKRef(inc);
+        }
+    },
+    'framework': {
+        install:function(el, plugin_dir, project_dir, plugin_id, project_file) {
+            events.emit('verbose', 'windows8 framework install :: ' + plugin_id);
+
+            var src = el.attrib['src'];
+            var dest = src; // if !isCustom, we will just add a reference to the file in place
+            // technically it is not possible to get here without isCustom == true -jm
+            // var isCustom = el.attrib.custom == 'true';
+            var type = el.attrib['type'];
+
+            if(type == 'projectReference') {
+                project_file.addProjectReference(path.join(plugin_dir,src));
+            }
+            else {
+                // if(isCustom) {}
+                dest = path.join('plugins', plugin_id, path.basename(src));
+                common.copyFile(plugin_dir, src, project_dir, dest);
+                project_file.addReference(dest, src);
+            }
+
+        },
+        uninstall:function(el, project_dir, plugin_id, project_file) {
+            events.emit('verbose', 'windows8 framework uninstall :: ' + plugin_id  );
+
+            var src = el.attrib['src'];
+            // technically it is not possible to get here without isCustom == true -jm
+            // var isCustom = el.attrib.custom == 'true';
+            var type = el.attrib['type'];
+            // unfortunately we have to generate the plugin_dir path because it is not passed to uninstall
+            var plugin_dir = path.join(project_dir, 'cordova/plugins', plugin_id,src);
+
+            if(type == 'projectReference') {
+                project_file.removeProjectReference(plugin_dir);
+            }
+            else {
+                // if(isCustom) {  }
+                var targetPath = path.join('plugins', plugin_id);
+                common.removeFile(project_dir, targetPath);
+                project_file.removeReference(src);
+            }
+        }
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/plugman/platforms/windows8.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/windows8.js b/cordova-lib/src/plugman/platforms/windows8.js
deleted file mode 100644
index 29b433c..0000000
--- a/cordova-lib/src/plugman/platforms/windows8.js
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *
- * Copyright 2013 Jesse MacFadyen
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
-          indent:4, unused:vars, latedef:nofunc,
-          laxcomma:true, sub:true
-*/
-
-var common = require('./common'),
-    path = require('path'),
-    glob = require('glob'),
-    jsproj = require('../../util/windows/jsproj'),
-    events = require('../../events'),
-    xml_helpers = require('../../util/xml-helpers');
-
-module.exports = {
-    platformName: 'windows8',
-    InvalidProjectPathError: 'does not appear to be a Windows Store JS project (no .jsproj file)',
-    www_dir: function(project_dir) {
-        return path.join(project_dir, 'www');
-    },
-    package_name: function(project_dir) {
-        var manifest = xml_helpers.parseElementtreeSync(path.join(project_dir, 'package.appxmanifest'));
-        return manifest.find('Properties/DisplayName').text;
-    },
-    parseProjectFile: function(project_dir) {
-        var project_files = glob.sync('*.jsproj', { cwd:project_dir });
-        if (project_files.length === 0) {
-            throw new Error(this.InvalidProjectPathError);
-        }
-        return new jsproj(path.join(project_dir, project_files[0]));
-    },
-    'source-file': {
-        install:function(source_el, plugin_dir, project_dir, plugin_id, project_file) {
-            var targetDir = source_el.attrib['target-dir'] || '';
-            var dest = path.join('www', 'plugins', plugin_id, targetDir, path.basename(source_el.attrib['src']));
-
-            common.copyNewFile(plugin_dir, source_el.attrib['src'], project_dir, dest);
-            // add reference to this file to jsproj.
-            project_file.addSourceFile(dest);
-        },
-        uninstall:function(source_el, project_dir, plugin_id, project_file) {
-            var dest = path.join('www', 'plugins', plugin_id,
-                                 source_el.attrib['target-dir'] ? source_el.attrib['target-dir'] : '',
-                                 path.basename(source_el.attrib['src']));
-            common.removeFile(project_dir, dest);
-            // remove reference to this file from csproj.
-            project_file.removeSourceFile(dest);
-        }
-    },
-    'header-file': {
-        install:function(source_el, plugin_dir, project_dir, plugin_id) {
-            events.emit('verbose', 'header-fileinstall is not supported for Windows 8');
-        },
-        uninstall:function(source_el, project_dir, plugin_id) {
-            events.emit('verbose', 'header-file.uninstall is not supported for Windows 8');
-        }
-    },
-    'resource-file':{
-        install:function(el, plugin_dir, project_dir, plugin_id, project_file) {
-            events.emit('verbose', 'resource-file is not supported for Windows 8');
-        },
-        uninstall:function(el, project_dir, plugin_id, project_file) {
-        }
-    },
-    'lib-file': {
-        install:function(el, plugin_dir, project_dir, plugin_id, project_file) {
-            var inc  = el.attrib['Include'];
-            project_file.addSDKRef(inc);
-        },
-        uninstall:function(el, project_dir, plugin_id, project_file) {
-            events.emit('verbose', 'windows8 lib-file uninstall :: ' + plugin_id);
-            var inc = el.attrib['Include'];
-            project_file.removeSDKRef(inc);
-        }
-    },
-    'framework': {
-        install:function(el, plugin_dir, project_dir, plugin_id, project_file) {
-            events.emit('verbose', 'windows8 framework install :: ' + plugin_id);
-
-            var src = el.attrib['src'];
-            var dest = src; // if !isCustom, we will just add a reference to the file in place
-            // technically it is not possible to get here without isCustom == true -jm
-            // var isCustom = el.attrib.custom == 'true';
-            var type = el.attrib['type'];
-
-            if(type == 'projectReference') {
-                project_file.addProjectReference(path.join(plugin_dir,src));
-            }
-            else {
-                // if(isCustom) {}
-                dest = path.join('plugins', plugin_id, path.basename(src));
-                common.copyFile(plugin_dir, src, project_dir, dest);
-                project_file.addReference(dest,src);
-            }
-
-        },
-        uninstall:function(el, project_dir, plugin_id, project_file) {
-            events.emit('verbose', 'windows8 framework uninstall :: ' + plugin_id  );
-
-            var src = el.attrib['src'];
-            // technically it is not possible to get here without isCustom == true -jm
-            // var isCustom = el.attrib.custom == 'true';
-            var type = el.attrib['type'];
-            // unfortunately we have to generate the plugin_dir path because it is not passed to uninstall
-            var plugin_dir = path.join(project_dir, 'cordova/plugins', plugin_id,src);
-
-            if(type == 'projectReference') {
-                project_file.removeProjectReference(plugin_dir);
-            }
-            else {
-                // if(isCustom) {  }
-                var targetPath = path.join('plugins', plugin_id);
-                common.removeFile(project_dir, targetPath);
-                project_file.removeReference(src);
-            }
-        }
-
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/plugman/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/prepare.js b/cordova-lib/src/plugman/prepare.js
index 374e2b5..961141e 100644
--- a/cordova-lib/src/plugman/prepare.js
+++ b/cordova-lib/src/plugman/prepare.js
@@ -27,7 +27,7 @@ var platform_modules = require('./platforms'),
     config_changes  = require('./util/config-changes'),
     xml_helpers     = require('../util/xml-helpers'),
     wp8             = require('./platforms/wp8'),
-    windows8        = require('./platforms/windows8'),
+    windows        = require('./platforms/windows'),
     common          = require('./platforms/common'),
     fs              = require('fs'),
     shell           = require('shelljs'),
@@ -76,11 +76,11 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
     // for windows phone and windows8 platforms we need to add all www resources to the .csproj(.jsproj) file
     // first we need to remove them all to prevent duplicates
     var projFile;
-    if (platform == 'wp8' || platform == 'windows8') {
+    if (platform == 'wp8' || platform == 'windows8' || platform == 'windows') {
         projFile = (platform == 'wp8') ? wp8.parseProjectFile(project_dir) :
-            windows8.parseProjectFile(project_dir);
+            windows.parseProjectFile(project_dir);
         // remove reference to cordova_plugins.js and all files inside plugins folder
-        projFile.removeSourceFile(new RegExp("^www\\\\(cordova_plugins.js|plugins\\\\)", "i"));
+        projFile.removeSourceFile(/^(\$\(MSBuildThisFileDirectory\))?www\\(cordova_plugins.js|plugins\\)/i);
     }
 
     platform_json = config_changes.get_platform_json(plugins_dir, platform);
@@ -112,6 +112,11 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
         var jsModules = xml.findall('./js-module');
         var assets = xml.findall('asset');
         var platformTag = xml.find(util.format('./platform[@name="%s"]', platform));
+        // CB-6976 Windows Universal Apps. For smooth transition and to prevent mass api failures
+        // we allow using windows8 tag for new windows platform
+        if (platform == 'windows' && !platformTag) {
+            platformTag = xml.find('platform[@name="' + 'windows8' + '"]');
+        }
 
         if (platformTag) {
             assets = assets.concat(platformTag.findall('./asset'));
@@ -191,7 +196,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
     events.emit('verbose', 'Writing out cordova_plugins.js...');
     fs.writeFileSync(path.join(wwwDir, 'cordova_plugins.js'), final_contents, 'utf-8');
 
-    if(platform == 'wp8' || platform == 'windows8') {
+    if(platform == 'wp8' || platform == 'windows8' || platform == 'windows') {
         projFile.addSourceFile(path.join('www', 'cordova_plugins.js'));
         projFile.write();
     }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/uninstall.js b/cordova-lib/src/plugman/uninstall.js
index 69c70fc..2256c94 100644
--- a/cordova-lib/src/plugman/uninstall.js
+++ b/cordova-lib/src/plugman/uninstall.js
@@ -242,6 +242,11 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir, w
     var platform_modules = require('./platforms');
     var handler = platform_modules[platform];
     var platformTag = plugin_et.find('./platform[@name="'+platform+'"]');
+    // CB-6976 Windows Universal Apps. For smooth transition and to prevent mass api failures
+    // we allow using windows8 tag for new windows platform
+    if (platform == 'windows' && !platformTag) {
+         platformTag = plugin_et.find('platform[@name="' + 'windows8' + '"]');
+    }
     www_dir = www_dir || handler.www_dir(project_dir);
     events.emit('log', 'Uninstalling ' + plugin_id + ' from ' + platform);
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/plugman/util/config-changes.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/config-changes.js b/cordova-lib/src/plugman/util/config-changes.js
index 4acead9..fad523e 100644
--- a/cordova-lib/src/plugman/util/config-changes.js
+++ b/cordova-lib/src/plugman/util/config-changes.js
@@ -192,6 +192,16 @@ function remove_plugin_changes(plugin_name, plugin_id, is_top_level) {
             );
             continue;
         }
+        // CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
+        if (self.platform == 'windows' && file == 'package.appxmanifest' &&
+        	!fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
+        	// New windows template separate manifest files for Windows8, Windows8.1 and WP8.1
+            var substs = ["package.phone.appxmanifest", "package.store.appxmanifest", "package.store80.appxmanifest"];
+            for (var subst in substs) {
+                events.emit('verbose', 'Applying munge to ' + substs[subst]);
+                self.apply_file_munge(substs[subst], munge.files[file], true);
+            }
+        }
         self.apply_file_munge(file, munge.files[file], /* remove = */ true);
     }
 
@@ -242,6 +252,15 @@ function add_plugin_changes(plugin_id, plugin_vars, is_top_level, should_increme
             );
             continue;
         }
+        // CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
+        if (self.platform == 'windows' && file == 'package.appxmanifest' &&
+        	!fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
+            var substs = ["package.phone.appxmanifest", "package.store.appxmanifest", "package.store80.appxmanifest"];
+            for (var subst in substs) {
+                events.emit('verbose', 'Applying munge to ' + substs[subst]);
+                self.apply_file_munge(substs[subst], munge.files[file]);
+            }
+        }
         self.apply_file_munge(file, munge.files[file]);
     }
 
@@ -299,6 +318,12 @@ function generate_plugin_config_munge(plugin_dir, vars) {
     var plugin_xml = plugin_config.data;
 
     var platformTag = plugin_xml.find('platform[@name="' + self.platform + '"]');
+    // CB-6976 Windows Universal Apps. For smooth transition and to prevent mass api failures
+    // we allow using windows8 tag for new windows platform
+    if (self.platform == 'windows' && !platformTag) {
+         platformTag = plugin_xml.find('platform[@name="' + 'windows8' + '"]');
+     }
+
     var changes = [];
     // add platform-agnostic config changes
     changes = changes.concat(plugin_xml.findall('config-file'));

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7ed25a53/cordova-lib/src/util/windows/jsproj.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/util/windows/jsproj.js b/cordova-lib/src/util/windows/jsproj.js
index 6cac1cf..538e44b 100644
--- a/cordova-lib/src/util/windows/jsproj.js
+++ b/cordova-lib/src/util/windows/jsproj.js
@@ -41,9 +41,14 @@ var WinCplusplusProjectTypeGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";  //
 
 
 function jsproj(location) {
+    if (!location) {
+        throw new Error('Project file location can\'t be null or empty' );
+    }
     events.emit('verbose','creating jsproj from project at : ' + location);
     this.location = location;
     this.xml = xml_helpers.parseElementtreeSync(location);
+    // Detect universal Windows app project template
+    this.isUniversalWindowsApp = location.match(/\.(projitems|shproj)$/i);
     return this;
 }
 
@@ -77,6 +82,8 @@ jsproj.prototype = {
 
         events.emit('verbose','addReference::' + relPath);
 
+        relPath = this.isUniversalWindowsApp ? '$(MSBuildThisFileDirectory)' + relPath : relPath;
+
         var item = new et.Element('ItemGroup');
         var extName = path.extname(relPath);
 
@@ -103,6 +110,8 @@ jsproj.prototype = {
     removeReference:function(relPath) {
         events.emit('verbose','removeReference::' + relPath);
 
+        relPath = this.isUniversalWindowsApp ? '$(MSBuildThisFileDirectory)' + relPath : relPath;
+
         var extName = path.extname(relPath);
         var includeText = path.basename(relPath,extName);
         // <ItemGroup>
@@ -117,6 +126,8 @@ jsproj.prototype = {
     addSourceFile:function(relative_path) {
 
         relative_path = relative_path.split('/').join('\\');
+        relative_path = this.isUniversalWindowsApp ? '$(MSBuildThisFileDirectory)' + relative_path : relative_path;
+
         // make ItemGroup to hold file.
         var item = new et.Element('ItemGroup');
 
@@ -129,10 +140,10 @@ jsproj.prototype = {
 
     removeSourceFile: function(relative_path) {
         var isRegexp = relative_path instanceof RegExp;
-
         if (!isRegexp) {
             // path.normalize(relative_path);// ??
             relative_path = relative_path.split('/').join('\\');
+            relative_path = this.isUniversalWindowsApp ? '$(MSBuildThisFileDirectory)' + relative_path : relative_path;
         }
 
         var root = this.xml.getroot();
@@ -148,7 +159,7 @@ jsproj.prototype = {
             // nothing to remove, skip..
             if (filesToRemove.length < 1) return;
 
-            filesToRemove.forEach(function(file){
+            filesToRemove.forEach(function(file) {
                 // remove file reference
                 group.remove(0, file);
             });


[2/2] git commit: Merge branch 'win81' of https://github.com/MSOpenTech/cordova-lib

Posted by pu...@apache.org.
Merge branch 'win81' of https://github.com/MSOpenTech/cordova-lib


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

Branch: refs/heads/master
Commit: e6923ac01bff8720af963cb122261df97d14168f
Parents: 67d9679 7ed25a5
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Jun 20 17:42:54 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Jun 20 17:42:54 2014 -0700

----------------------------------------------------------------------
 .../spec-plugman/platforms/windows8.spec.js     |   2 +-
 cordova-lib/src/cordova/lazy_load.js            |   4 +
 .../src/cordova/metadata/windows8_parser.js     | 321 ------------------
 .../src/cordova/metadata/windows_parser.js      | 338 +++++++++++++++++++
 cordova-lib/src/cordova/platform.js             |  12 +
 cordova-lib/src/cordova/platforms.js            |  15 +-
 cordova-lib/src/cordova/prepare.js              |   7 +
 cordova-lib/src/plugman/install.js              |   5 +
 cordova-lib/src/plugman/platforms.js            |   3 +-
 cordova-lib/src/plugman/platforms/windows.js    | 146 ++++++++
 cordova-lib/src/plugman/platforms/windows8.js   | 136 --------
 cordova-lib/src/plugman/prepare.js              |  15 +-
 cordova-lib/src/plugman/uninstall.js            |   5 +
 cordova-lib/src/plugman/util/config-changes.js  |  25 ++
 cordova-lib/src/util/windows/jsproj.js          |  15 +-
 15 files changed, 579 insertions(+), 470 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e6923ac0/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e6923ac0/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------