cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [2/4] cordova-lib git commit: Parsers: assign methods without overriding the prototype
Date Sun, 04 Jan 2015 01:53:30 GMT
Parsers: assign methods without overriding the prototype


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

Branch: refs/heads/master
Commit: dcd6a0c0a7152598bc10850ee8f1d39b0ab3d7c3
Parents: 9079bb8
Author: Marko Raatikka <marko.raatikka@gmail.com>
Authored: Thu Jan 1 21:58:23 2015 +0200
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Sat Jan 3 20:51:47 2015 -0500

----------------------------------------------------------------------
 .../cordova/metadata/amazon_fireos_parser.js    | 564 +++++++++----------
 .../src/cordova/metadata/android_parser.js      | 559 +++++++++---------
 .../src/cordova/metadata/blackberry10_parser.js | 164 +++---
 .../src/cordova/metadata/browser_parser.js      |  93 ++-
 .../src/cordova/metadata/firefoxos_parser.js    | 273 +++++----
 cordova-lib/src/cordova/metadata/ios_parser.js  | 373 ++++++------
 .../src/cordova/metadata/ubuntu_parser.js       | 219 ++++---
 .../src/cordova/metadata/windows_parser.js      | 401 ++++++-------
 cordova-lib/src/cordova/metadata/wp8_parser.js  | 331 +++++------
 9 files changed, 1488 insertions(+), 1489 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/dcd6a0c0/cordova-lib/src/cordova/metadata/amazon_fireos_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/amazon_fireos_parser.js b/cordova-lib/src/cordova/metadata/amazon_fireos_parser.js
index 5d26245..9a0af54 100644
--- a/cordova-lib/src/cordova/metadata/amazon_fireos_parser.js
+++ b/cordova-lib/src/cordova/metadata/amazon_fireos_parser.js
@@ -33,7 +33,7 @@ var fs            = require('fs'),
     CordovaError = require('../../CordovaError');
 
 
-module.exports = function android_parser(project) {
+function amazon_fireos_parser(project) {
     if (!fs.existsSync(path.join(project, 'AndroidManifest.xml'))) {
         throw new CordovaError('The provided path "' + project + '" is not an Android project.');
     }
@@ -41,312 +41,312 @@ module.exports = function android_parser(project) {
     this.strings = path.join(this.path, 'res', 'values', 'strings.xml');
     this.manifest = path.join(this.path, 'AndroidManifest.xml');
     this.android_config = path.join(this.path, 'res', 'xml', 'config.xml');
+}
+
+module.exports = amazon_fireos_parser;
+
+amazon_fireos_parser.prototype.findOrientationPreference = function(config) {
+    var ret = config.getPreference('orientation');
+    if (ret && ret != 'default' && ret != 'portrait' && ret != 'landscape') {
+        events.emit('warn', 'Unknown value for orientation preference: ' + ret);
+        ret = null;
+    }
+
+    return ret;
 };
 
-module.exports.prototype = {
-    findOrientationPreference: function(config) {
-        var ret = config.getPreference('orientation');
-        if (ret && ret != 'default' && ret != 'portrait' && ret != 'landscape') {
-            events.emit('warn', 'Unknown value for orientation preference: ' + ret);
-            ret = null;
-        }
+amazon_fireos_parser.prototype.findAndroidLaunchModePreference = function(config) {
+    var launchMode = config.getPreference('AndroidLaunchMode');
+    if (!launchMode) {
+        // Return a default value
+        return 'singleTop';
+    }
+
+    var expectedValues = ['standard', 'singleTop', 'singleTask', 'singleInstance'];
+    var valid = expectedValues.indexOf(launchMode) !== -1;
+    if (!valid) {
+        events.emit('warn', 'Unrecognized value for AndroidLaunchMode preference: ' + launchMode);
+        events.emit('warn', '  Expected values are: ' + expectedValues.join(', '));
+        // Note: warn, but leave the launch mode as developer wanted, in case the list of options changes in the future
+    }
 
-        return ret;
-    },
+    return launchMode;
+};
 
-    findAndroidLaunchModePreference: function(config) {
-        var launchMode = config.getPreference('AndroidLaunchMode');
-        if (!launchMode) {
-            // Return a default value
-            return 'singleTop';
-        }
-    
-        var expectedValues = ['standard', 'singleTop', 'singleTask', 'singleInstance'];
-        var valid = expectedValues.indexOf(launchMode) !== -1;
-        if (!valid) {
-            events.emit('warn', 'Unrecognized value for AndroidLaunchMode preference: ' + launchMode);
-            events.emit('warn', '  Expected values are: ' + expectedValues.join(', '));
-            // Note: warn, but leave the launch mode as developer wanted, in case the list of options changes in the future
-        }
-    
-        return launchMode;
-    },
-    
-    // remove the default resource name from all drawable folders
-    // return the array of the densities in this project
-    deleteDefaultResource:function (name) {
-        var densities = [];
-        var res = path.join(this.path, 'res');
-        var dirs = fs.readdirSync(res);
-
-        for (var i = 0; i < dirs.length; i++) {
-            var filename = dirs[i];
-            if (filename.indexOf('drawable-') === 0) {
-                var density = filename.substr(9);
-                densities.push(density);
-                var template = path.join(res, filename, name);
-                try {
-                    fs.unlinkSync(template);
-                    events.emit('verbose', 'deleted: ' + template);
-                } catch (e) {
-                    // ignored. template screen does probably not exist
-                }
+// remove the default resource name from all drawable folders
+// return the array of the densities in this project
+amazon_fireos_parser.prototype.deleteDefaultResource = function (name) {
+    var densities = [];
+    var res = path.join(this.path, 'res');
+    var dirs = fs.readdirSync(res);
+
+    for (var i = 0; i < dirs.length; i++) {
+        var filename = dirs[i];
+        if (filename.indexOf('drawable-') === 0) {
+            var density = filename.substr(9);
+            densities.push(density);
+            var template = path.join(res, filename, name);
+            try {
+                fs.unlinkSync(template);
+                events.emit('verbose', 'deleted: ' + template);
+            } catch (e) {
+                // ignored. template screen does probably not exist
             }
         }
-        return densities;
-    },
+    }
+    return densities;
+};
 
-    copyImage: function(src, density, name) {
-        var destFolder = path.join(this.path, 'res', (density ? 'drawable-': 'drawable') + density);
-        var destFilePath = path.join(destFolder, name);
+amazon_fireos_parser.prototype.copyImage = function(src, density, name) {
+    var destFolder = path.join(this.path, 'res', (density ? 'drawable-': 'drawable') + density);
+    var destFilePath = path.join(destFolder, name);
 
-        // default template does not have default asset for this density
-        if (!fs.existsSync(destFolder)) {
-            fs.mkdirSync(destFolder);
+    // default template does not have default asset for this density
+    if (!fs.existsSync(destFolder)) {
+        fs.mkdirSync(destFolder);
+    }
+    events.emit('verbose', 'copying image from ' + src + ' to ' + destFilePath);
+    shell.cp('-f', src, destFilePath);
+};
+
+amazon_fireos_parser.prototype.handleSplashes = function (config) {
+    var resources = config.getSplashScreens('android');
+    var destfilepath;
+    // if there are "splash" elements in config.xml
+    if (resources.length > 0) {
+        var densities = this.deleteDefaultResource('screen.png');
+        events.emit('verbose', 'splash screens: ' + JSON.stringify(resources));
+        var res = path.join(this.path, 'res');
+
+        if (resources.defaultResource) {
+            destfilepath = path.join(res, 'drawable', 'screen.png');
+            events.emit('verbose', 'copying splash icon from ' + resources.defaultResource.src + ' to ' + destfilepath);
+            shell.cp('-f', resources.defaultResource.src, destfilepath);
         }
-        events.emit('verbose', 'copying image from ' + src + ' to ' + destFilePath);
-        shell.cp('-f', src, destFilePath);
-    },
-
-    handleSplashes:function (config) {
-        var resources = config.getSplashScreens('android');
-        var destfilepath;
-        // if there are "splash" elements in config.xml
-        if (resources.length > 0) {
-            var densities = this.deleteDefaultResource('screen.png');
-            events.emit('verbose', 'splash screens: ' + JSON.stringify(resources));
-            var res = path.join(this.path, 'res');
-
-            if (resources.defaultResource) {
-                destfilepath = path.join(res, 'drawable', 'screen.png');
-                events.emit('verbose', 'copying splash icon from ' + resources.defaultResource.src + ' to ' + destfilepath);
-                shell.cp('-f', resources.defaultResource.src, destfilepath);
-            }
-            for (var i = 0; i < densities.length; i++) {
-                var density = densities[i];
-                var resource = resources.getByDensity(density);
-                if (resource) {
-                    // copy splash screens.
-                    destfilepath = path.join(res, 'drawable-' + density, 'screen.png');
-                    events.emit('verbose', 'copying splash icon from ' + resource.src + ' to ' + destfilepath);
-                    shell.cp('-f', resource.src, destfilepath);
-                }
+        for (var i = 0; i < densities.length; i++) {
+            var density = densities[i];
+            var resource = resources.getByDensity(density);
+            if (resource) {
+                // copy splash screens.
+                destfilepath = path.join(res, 'drawable-' + density, 'screen.png');
+                events.emit('verbose', 'copying splash icon from ' + resource.src + ' to ' + destfilepath);
+                shell.cp('-f', resource.src, destfilepath);
             }
         }
-    },
+    }
+};
 
-    handleIcons: function(config) {
-        var icons = config.getIcons('android');
+amazon_fireos_parser.prototype.handleIcons = function(config) {
+    var icons = config.getIcons('android');
 
-        // if there are icon elements in config.xml
-        if (icons.length === 0) {
-            events.emit('verbose', 'This app does not have launcher icons defined');
-            return;
-        }
+    // if there are icon elements in config.xml
+    if (icons.length === 0) {
+        events.emit('verbose', 'This app does not have launcher icons defined');
+        return;
+    }
 
-        this.deleteDefaultResource('icon.png');
-
-        var android_icons = {};
-        var default_icon;
-        // http://developer.android.com/design/style/iconography.html
-        var sizeToDensityMap = {
-            36: 'ldpi',
-            48: 'mdpi',
-            72: 'hdpi',
-            96: 'xhdpi',
-            144: 'xxhdpi',
-            192: 'xxxhdpi'
-        };
-        // find the best matching icon for a given density or size
-        // @output android_icons
-        var parseIcon = function(icon, icon_size) {
-            // do I have a platform icon for that density already
-            var density = icon.density || sizeToDensityMap[icon_size];
-            if (!density) {
-                // invalid icon defition ( or unsupported size)
-                return;
-            }
-            var previous = android_icons[density];
-            if (previous && previous.platform) {
-                return;
-            }
-            android_icons[density] = icon;
-        };
-
-        // iterate over all icon elements to find the default icon and call parseIcon
-        for (var i=0; i<icons.length; i++) {
-            var icon = icons[i];
-            var size = icon.width;
-            if (!size) {
-                size = icon.height;
-            }
-            if (!size && !icon.density) {
-                if (default_icon) {
-                    events.emit('verbose', 'more than one default icon: ' + JSON.stringify(icon));
-                } else {
-                    default_icon = icon;
-                }
-            } else {
-                parseIcon(icon, size);
-            }
+    this.deleteDefaultResource('icon.png');
+
+    var android_icons = {};
+    var default_icon;
+    // http://developer.android.com/design/style/iconography.html
+    var sizeToDensityMap = {
+        36: 'ldpi',
+        48: 'mdpi',
+        72: 'hdpi',
+        96: 'xhdpi',
+        144: 'xxhdpi',
+        192: 'xxxhdpi'
+    };
+    // find the best matching icon for a given density or size
+    // @output android_icons
+    var parseIcon = function(icon, icon_size) {
+        // do I have a platform icon for that density already
+        var density = icon.density || sizeToDensityMap[icon_size];
+        if (!density) {
+            // invalid icon defition ( or unsupported size)
+            return;
         }
-        var projectRoot = util.isCordova(this.path);
-        // copy the default icon to the drawable folder
-        if (default_icon) {
-            this.copyImage(path.join(projectRoot, default_icon.src), '', 'icon.png');
+        var previous = android_icons[density];
+        if (previous && previous.platform) {
+            return;
         }
-
-        for (var density in android_icons) {
-            this.copyImage(path.join(projectRoot, android_icons[density].src), density, 'icon.png');
+        android_icons[density] = icon;
+    };
+
+    // iterate over all icon elements to find the default icon and call parseIcon
+    for (var i=0; i<icons.length; i++) {
+        var icon = icons[i];
+        var size = icon.width;
+        if (!size) {
+            size = icon.height;
         }
-    },
-    
-    update_from_config:function(config) {
-        // TODO: share code for this func with Android. Or fix it and remove
-        // the below JSHint hacks line.
-        // jshint unused:false, indent:false, undef:true, loopfunc:true, shadow:true
-        if (config instanceof ConfigParser) {
-        } else throw new Error('update_from_config requires a ConfigParser object');
-
-        // Update app name by editing res/values/strings.xml
-        var name = config.name();
-        var strings = xml.parseElementtreeSync(this.strings);
-        strings.find('string[@name="app_name"]').text = name;
-        fs.writeFileSync(this.strings, strings.write({indent: 4}), 'utf-8');
-        events.emit('verbose', 'Wrote out Android application name to "' + name + '"');
-
-        this.handleSplashes(config);
-        this.handleIcons(config);
-        
-        var manifest = xml.parseElementtreeSync(this.manifest);
-        // Update the version by changing the AndroidManifest android:versionName
-        var version = config.version();
-        var versionCode = config.android_versionCode() || default_versionCode(version);
-        manifest.getroot().attrib['android:versionName'] = version;
-        manifest.getroot().attrib['android:versionCode'] = versionCode;
-
-        // Update package name by changing the AndroidManifest id and moving the entry class around to the proper package directory
-        var pkg = config.android_packageName() || config.packageName();
-        pkg = pkg.replace(/-/g, '_'); // Java packages cannot support dashes
-        var orig_pkg = manifest.getroot().attrib.package;
-        manifest.getroot().attrib.package = pkg;
-
-        var act = manifest.getroot().find('./application/activity');
-
-         // Set the orientation in the AndroidManifest
-        var orientationPref = this.findOrientationPreference(config);
-        if (orientationPref) {
-            switch (orientationPref) {
-                case 'default':
-                    delete act.attrib['android:screenOrientation'];
-                    break;
-                case 'portrait':
-                    act.attrib['android:screenOrientation'] = 'portrait';
-                    break;
-                case 'landscape':
-                    act.attrib['android:screenOrientation'] = 'landscape';
+        if (!size && !icon.density) {
+            if (default_icon) {
+                events.emit('verbose', 'more than one default icon: ' + JSON.stringify(icon));
+            } else {
+                default_icon = icon;
             }
+        } else {
+            parseIcon(icon, size);
         }
+    }
+    var projectRoot = util.isCordova(this.path);
+    // copy the default icon to the drawable folder
+    if (default_icon) {
+        this.copyImage(path.join(projectRoot, default_icon.src), '', 'icon.png');
+    }
 
-        // Set android:launchMode in AndroidManifest
-        var androidLaunchModePref = this.findAndroidLaunchModePreference(config);
-        if (androidLaunchModePref) {
-            act.attrib['android:launchMode'] = androidLaunchModePref;
-        } else { // User has (explicitly) set an invalid value for AndroidLaunchMode preference
-            delete act.attrib['android:launchMode']; // use Android default value (standard)
-        }
+    for (var density in android_icons) {
+        this.copyImage(path.join(projectRoot, android_icons[density].src), density, 'icon.png');
+    }
+};
 
-	// Set min/max/target SDK version
-        //<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" ... />
-        var usesSdk = manifest.getroot().find('./uses-sdk');
-        ['minSdkVersion', 'maxSdkVersion', 'targetSdkVersion'].forEach(function(sdkPrefName) {
-            var sdkPrefValue = config.getPreference('android-' + sdkPrefName, 'android');
-            if (!sdkPrefValue) return;
-            
-            if (!usesSdk) { // if there is no required uses-sdk element, we should create it first
-                usesSdk = new et.Element('uses-sdk');
-                manifest.getroot().append(usesSdk);
-            }
-            usesSdk.attrib['android:' + sdkPrefName] = sdkPrefValue;
-        });
-
-        // Write out AndroidManifest.xml
-        fs.writeFileSync(this.manifest, manifest.write({indent: 4}), 'utf-8');
-
-        var orig_pkgDir = path.join(this.path, 'src', path.join.apply(null, orig_pkg.split('.')));
-        var java_files = fs.readdirSync(orig_pkgDir).filter(function(f) {
-          return f.indexOf('.svn') == -1 && f.indexOf('.java') >= 0 && fs.readFileSync(path.join(orig_pkgDir, f), 'utf-8').match(/extends\s+CordovaActivity/);
-        });
-        if (java_files.length === 0) {
-          throw new Error('No Java files found which extend CordovaActivity.');
-        } else if(java_files.length > 1) {
-          events.emit('log', 'Multiple candidate Java files (.java files which extend CordovaActivity) found. Guessing at the first one, ' + java_files[0]);
+amazon_fireos_parser.prototype.update_from_config = function(config) {
+    // TODO: share code for this func with Android. Or fix it and remove
+    // the below JSHint hacks line.
+    // jshint unused:false, indent:false, undef:true, loopfunc:true, shadow:true
+    if (config instanceof ConfigParser) {
+    } else throw new Error('update_from_config requires a ConfigParser object');
+
+    // Update app name by editing res/values/strings.xml
+    var name = config.name();
+    var strings = xml.parseElementtreeSync(this.strings);
+    strings.find('string[@name="app_name"]').text = name;
+    fs.writeFileSync(this.strings, strings.write({indent: 4}), 'utf-8');
+    events.emit('verbose', 'Wrote out Android application name to "' + name + '"');
+
+    this.handleSplashes(config);
+    this.handleIcons(config);
+
+    var manifest = xml.parseElementtreeSync(this.manifest);
+    // Update the version by changing the AndroidManifest android:versionName
+    var version = config.version();
+    var versionCode = config.android_versionCode() || default_versionCode(version);
+    manifest.getroot().attrib['android:versionName'] = version;
+    manifest.getroot().attrib['android:versionCode'] = versionCode;
+
+    // Update package name by changing the AndroidManifest id and moving the entry class around to the proper package directory
+    var pkg = config.android_packageName() || config.packageName();
+    pkg = pkg.replace(/-/g, '_'); // Java packages cannot support dashes
+    var orig_pkg = manifest.getroot().attrib.package;
+    manifest.getroot().attrib.package = pkg;
+
+    var act = manifest.getroot().find('./application/activity');
+
+     // Set the orientation in the AndroidManifest
+    var orientationPref = this.findOrientationPreference(config);
+    if (orientationPref) {
+        switch (orientationPref) {
+            case 'default':
+                delete act.attrib['android:screenOrientation'];
+                break;
+            case 'portrait':
+                act.attrib['android:screenOrientation'] = 'portrait';
+                break;
+            case 'landscape':
+                act.attrib['android:screenOrientation'] = 'landscape';
         }
+    }
 
-        var orig_java_class = java_files[0];
-        var pkgDir = path.join(this.path, 'src', path.join.apply(null, pkg.split('.')));
-        shell.mkdir('-p', pkgDir);
-        var orig_javs = path.join(orig_pkgDir, orig_java_class);
-        var new_javs = path.join(pkgDir, orig_java_class);
-        var javs_contents = fs.readFileSync(orig_javs, 'utf-8');
-        javs_contents = javs_contents.replace(/package [\w\.]*;/, 'package ' + pkg + ';');
-        events.emit('verbose', 'Wrote out Android package name to "' + pkg + '"');
-        fs.writeFileSync(new_javs, javs_contents, 'utf-8');
-    },
-
-    // Returns the platform-specific www directory.
-    www_dir:function() {
-        return path.join(this.path, 'assets', 'www');
-    },
-
-    config_xml:function(){
-        return this.android_config;
-    },
-
-     // Used for creating platform_www in projects created by older versions.
-    cordovajs_path:function(libDir) {
-        var jsPath = path.join(libDir, 'framework', 'assets', 'www', 'cordova.js');
-        return path.resolve(jsPath);
-    },
-
-    // Replace the www dir with contents of platform_www and app www.
-    update_www:function() {
-        var projectRoot = util.isCordova(this.path);
-        var app_www = util.projectWww(projectRoot);
-        var platform_www = path.join(this.path, '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 over stock platform www assets (cordova.js)
-        shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
-    },
-
-    // update the overrides folder into the www folder
-    update_overrides:function() {
-        var projectRoot = util.isCordova(this.path);
-        var merges_path = path.join(util.appDir(projectRoot), 'merges', 'amazon-fireos');
-        if (fs.existsSync(merges_path)) {
-            var overrides = path.join(merges_path, '*');
-            shell.cp('-rf', overrides, this.www_dir());
-        }
-    },
-
-    // Returns a promise.
-    update_project:function(cfg) {
-        var platformWww = path.join(this.path, 'assets');
-        try {
-            this.update_from_config(cfg);
-        } catch(e) {
-            return Q.reject(e);
+    // Set android:launchMode in AndroidManifest
+    var androidLaunchModePref = this.findAndroidLaunchModePreference(config);
+    if (androidLaunchModePref) {
+        act.attrib['android:launchMode'] = androidLaunchModePref;
+    } else { // User has (explicitly) set an invalid value for AndroidLaunchMode preference
+        delete act.attrib['android:launchMode']; // use Android default value (standard)
+    }
+
+    // Set min/max/target SDK version
+    //<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" ... />
+    var usesSdk = manifest.getroot().find('./uses-sdk');
+    ['minSdkVersion', 'maxSdkVersion', 'targetSdkVersion'].forEach(function(sdkPrefName) {
+        var sdkPrefValue = config.getPreference('android-' + sdkPrefName, 'android');
+        if (!sdkPrefValue) return;
+
+        if (!usesSdk) { // if there is no required uses-sdk element, we should create it first
+            usesSdk = new et.Element('uses-sdk');
+            manifest.getroot().append(usesSdk);
         }
-        this.update_overrides();
-        // delete any .svn folders copied over
-        util.deleteSvnFolders(platformWww);
-        return Q();
+        usesSdk.attrib['android:' + sdkPrefName] = sdkPrefValue;
+    });
+
+    // Write out AndroidManifest.xml
+    fs.writeFileSync(this.manifest, manifest.write({indent: 4}), 'utf-8');
+
+    var orig_pkgDir = path.join(this.path, 'src', path.join.apply(null, orig_pkg.split('.')));
+    var java_files = fs.readdirSync(orig_pkgDir).filter(function(f) {
+      return f.indexOf('.svn') == -1 && f.indexOf('.java') >= 0 && fs.readFileSync(path.join(orig_pkgDir, f), 'utf-8').match(/extends\s+CordovaActivity/);
+    });
+    if (java_files.length === 0) {
+      throw new Error('No Java files found which extend CordovaActivity.');
+    } else if(java_files.length > 1) {
+      events.emit('log', 'Multiple candidate Java files (.java files which extend CordovaActivity) found. Guessing at the first one, ' + java_files[0]);
+    }
+
+    var orig_java_class = java_files[0];
+    var pkgDir = path.join(this.path, 'src', path.join.apply(null, pkg.split('.')));
+    shell.mkdir('-p', pkgDir);
+    var orig_javs = path.join(orig_pkgDir, orig_java_class);
+    var new_javs = path.join(pkgDir, orig_java_class);
+    var javs_contents = fs.readFileSync(orig_javs, 'utf-8');
+    javs_contents = javs_contents.replace(/package [\w\.]*;/, 'package ' + pkg + ';');
+    events.emit('verbose', 'Wrote out Android package name to "' + pkg + '"');
+    fs.writeFileSync(new_javs, javs_contents, 'utf-8');
+};
+
+// Returns the platform-specific www directory.
+amazon_fireos_parser.prototype.www_dir = function() {
+    return path.join(this.path, 'assets', 'www');
+};
+
+amazon_fireos_parser.prototype.config_xml = function(){
+    return this.android_config;
+};
+
+// Used for creating platform_www in projects created by older versions.
+amazon_fireos_parser.prototype.cordovajs_path = function(libDir) {
+    var jsPath = path.join(libDir, 'framework', 'assets', 'www', 'cordova.js');
+    return path.resolve(jsPath);
+};
+
+// Replace the www dir with contents of platform_www and app www.
+amazon_fireos_parser.prototype.update_www = function() {
+    var projectRoot = util.isCordova(this.path);
+    var app_www = util.projectWww(projectRoot);
+    var platform_www = path.join(this.path, '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 over stock platform www assets (cordova.js)
+    shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+};
+
+// update the overrides folder into the www folder
+amazon_fireos_parser.prototype.update_overrides = function() {
+    var projectRoot = util.isCordova(this.path);
+    var merges_path = path.join(util.appDir(projectRoot), 'merges', 'amazon-fireos');
+    if (fs.existsSync(merges_path)) {
+        var overrides = path.join(merges_path, '*');
+        shell.cp('-rf', overrides, this.www_dir());
+    }
+};
+
+// Returns a promise.
+amazon_fireos_parser.prototype.update_project = function(cfg) {
+    var platformWww = path.join(this.path, 'assets');
+    try {
+        this.update_from_config(cfg);
+    } catch(e) {
+        return Q.reject(e);
     }
+    this.update_overrides();
+    // delete any .svn folders copied over
+    util.deleteSvnFolders(platformWww);
+    return Q();
 };
 
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/dcd6a0c0/cordova-lib/src/cordova/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/android_parser.js b/cordova-lib/src/cordova/metadata/android_parser.js
index 71e61f2..d9f33b3 100644
--- a/cordova-lib/src/cordova/metadata/android_parser.js
+++ b/cordova-lib/src/cordova/metadata/android_parser.js
@@ -33,7 +33,7 @@ var fs            = require('fs'),
     CordovaError  = require('../../CordovaError');
 
 
-module.exports = function android_parser(project) {
+function android_parser(project) {
     if (!fs.existsSync(path.join(project, 'AndroidManifest.xml'))) {
         throw new CordovaError('The provided path "' + project + '" is not an Android project.');
     }
@@ -41,314 +41,313 @@ module.exports = function android_parser(project) {
     this.strings = path.join(this.path, 'res', 'values', 'strings.xml');
     this.manifest = path.join(this.path, 'AndroidManifest.xml');
     this.android_config = path.join(this.path, 'res', 'xml', 'config.xml');
-};
+}
 
-module.exports.prototype = {
-    findOrientationPreference: function(config) {
-        var ret = config.getPreference('orientation');
-        if (ret && ret != 'default' && ret != 'portrait' && ret != 'landscape') {
-            events.emit('warn', 'Unknown value for orientation preference: ' + ret);
-            ret = null;
-        }
+module.exports = android_parser;
 
-        return ret;
-    },
+android_parser.prototype.findOrientationPreference = function(config) {
+    var ret = config.getPreference('orientation');
+    if (ret && ret != 'default' && ret != 'portrait' && ret != 'landscape') {
+        events.emit('warn', 'Unknown value for orientation preference: ' + ret);
+        ret = null;
+    }
 
-    findAndroidLaunchModePreference: function(config) {
-        var launchMode = config.getPreference('AndroidLaunchMode');
-        if (!launchMode) {
-            // Return a default value
-            return 'singleTop';
-        }
+    return ret;
+};
 
-        var expectedValues = ['standard', 'singleTop', 'singleTask', 'singleInstance'];
-        var valid = expectedValues.indexOf(launchMode) !== -1;
-        if (!valid) {
-            events.emit('warn', 'Unrecognized value for AndroidLaunchMode preference: ' + launchMode);
-            events.emit('warn', '  Expected values are: ' + expectedValues.join(', '));
-            // Note: warn, but leave the launch mode as developer wanted, in case the list of options changes in the future
-        }
+android_parser.prototype.findAndroidLaunchModePreference = function(config) {
+    var launchMode = config.getPreference('AndroidLaunchMode');
+    if (!launchMode) {
+        // Return a default value
+        return 'singleTop';
+    }
 
-        return launchMode;
-    },
-
-    // remove the default resource name from all drawable folders
-    // return the array of the densities in this project
-    deleteDefaultResource:function(name) {
-        var densities = [];
-        var res = path.join(this.path, 'res');
-        var dirs = fs.readdirSync(res);
-
-        for (var i=0; i<dirs.length; i++) {
-            var filename = dirs[i];
-            if (filename.indexOf('drawable-') === 0) {
-                var density = filename.substr(9);
-                densities.push(density);
-                var template = path.join(res, filename, name);
-                try {
-                    fs.unlinkSync(template);
-                    events.emit('verbose', 'deleted: ' + template);
-                } catch(e) {
-                    // ignored. template screen does probably not exist
-                }
-            }
-        }
-        return densities;
-    },
+    var expectedValues = ['standard', 'singleTop', 'singleTask', 'singleInstance'];
+    var valid = expectedValues.indexOf(launchMode) !== -1;
+    if (!valid) {
+        events.emit('warn', 'Unrecognized value for AndroidLaunchMode preference: ' + launchMode);
+        events.emit('warn', '  Expected values are: ' + expectedValues.join(', '));
+        // Note: warn, but leave the launch mode as developer wanted, in case the list of options changes in the future
+    }
 
-    copyImage: function(src, density, name) {
-        var destFolder = path.join(this.path, 'res', (density ? 'drawable-': 'drawable') + density);
-        var destFilePath = path.join(destFolder, name);
+    return launchMode;
+};
 
-        // default template does not have default asset for this density
-        if (!fs.existsSync(destFolder)) {
-            fs.mkdirSync(destFolder);
-        }
-        events.emit('verbose', 'copying image from ' + src + ' to ' + destFilePath);
-        shell.cp('-f', src, destFilePath);
-    },
-
-    handleSplashes:function(config) {
-        var resources = config.getSplashScreens('android');
-        var me = this;
-        // if there are "splash" elements in config.xml
-        if (resources.length > 0) {
-            this.deleteDefaultResource('screen.png');
-            events.emit('verbose', 'splash screens: ' + JSON.stringify(resources));
-
-            var projectRoot = util.isCordova(this.path);
-
-            if (resources.defaultResource) {
-                me.copyImage(path.join(projectRoot, resources.defaultResource.src), '', 'screen.png');
+// remove the default resource name from all drawable folders
+// return the array of the densities in this project
+android_parser.prototype.deleteDefaultResource = function(name) {
+    var densities = [];
+    var res = path.join(this.path, 'res');
+    var dirs = fs.readdirSync(res);
+
+    for (var i=0; i<dirs.length; i++) {
+        var filename = dirs[i];
+        if (filename.indexOf('drawable-') === 0) {
+            var density = filename.substr(9);
+            densities.push(density);
+            var template = path.join(res, filename, name);
+            try {
+                fs.unlinkSync(template);
+                events.emit('verbose', 'deleted: ' + template);
+            } catch(e) {
+                // ignored. template screen does probably not exist
             }
-            resources.forEach(function (resource) {
-                if (!resource.density) {
-                    return;
-                }
-                var screenname = 'screen.png';
-                if (resource.src.match(/\.9\.png$/)) {
-                    screenname = 'screen.9.png';
-                }
-
-                me.copyImage(path.join(projectRoot, resource.src), resource.density, screenname);
-            });
         }
-    },
+    }
+    return densities;
+};
 
-    handleIcons: function(config) {
-        var icons = config.getIcons('android');
+android_parser.prototype.copyImage = function(src, density, name) {
+    var destFolder = path.join(this.path, 'res', (density ? 'drawable-': 'drawable') + density);
+    var destFilePath = path.join(destFolder, name);
 
-        // if there are icon elements in config.xml
-        if (icons.length === 0) {
-            events.emit('verbose', 'This app does not have launcher icons defined');
-            return;
-        }
+    // default template does not have default asset for this density
+    if (!fs.existsSync(destFolder)) {
+        fs.mkdirSync(destFolder);
+    }
+    events.emit('verbose', 'copying image from ' + src + ' to ' + destFilePath);
+    shell.cp('-f', src, destFilePath);
+};
 
-        this.deleteDefaultResource('icon.png');
-
-        var android_icons = {};
-        var default_icon;
-        // http://developer.android.com/design/style/iconography.html
-        var sizeToDensityMap = {
-            36: 'ldpi',
-            48: 'mdpi',
-            72: 'hdpi',
-            96: 'xhdpi',
-            144: 'xxhdpi',
-            192: 'xxxhdpi'
-        };
-        // find the best matching icon for a given density or size
-        // @output android_icons
-        var parseIcon = function(icon, icon_size) {
-            // do I have a platform icon for that density already
-            var density = icon.density || sizeToDensityMap[icon_size];
-            if (!density) {
-                // invalid icon defition ( or unsupported size)
-                return;
-            }
-            var previous = android_icons[density];
-            if (previous && previous.platform) {
+android_parser.prototype.handleSplashes = function(config) {
+    var resources = config.getSplashScreens('android');
+    var me = this;
+    // if there are "splash" elements in config.xml
+    if (resources.length > 0) {
+        this.deleteDefaultResource('screen.png');
+        events.emit('verbose', 'splash screens: ' + JSON.stringify(resources));
+
+        var projectRoot = util.isCordova(this.path);
+
+        if (resources.defaultResource) {
+            me.copyImage(path.join(projectRoot, resources.defaultResource.src), '', 'screen.png');
+        }
+        resources.forEach(function (resource) {
+            if (!resource.density) {
                 return;
             }
-            android_icons[density] = icon;
-        };
-
-        // iterate over all icon elements to find the default icon and call parseIcon
-        for (var i=0; i<icons.length; i++) {
-            var icon = icons[i];
-            var size = icon.width;
-            if (!size) {
-                size = icon.height;
-            }
-            if (!size && !icon.density) {
-                if (default_icon) {
-                    events.emit('verbose', 'more than one default icon: ' + JSON.stringify(icon));
-                } else {
-                    default_icon = icon;
-                }
-            } else {
-                parseIcon(icon, size);
+            var screenname = 'screen.png';
+            if (resource.src.match(/\.9\.png$/)) {
+                screenname = 'screen.9.png';
             }
+
+            me.copyImage(path.join(projectRoot, resource.src), resource.density, screenname);
+        });
+    }
+};
+
+android_parser.prototype.handleIcons = function(config) {
+    var icons = config.getIcons('android');
+
+    // if there are icon elements in config.xml
+    if (icons.length === 0) {
+        events.emit('verbose', 'This app does not have launcher icons defined');
+        return;
+    }
+
+    this.deleteDefaultResource('icon.png');
+
+    var android_icons = {};
+    var default_icon;
+    // http://developer.android.com/design/style/iconography.html
+    var sizeToDensityMap = {
+        36: 'ldpi',
+        48: 'mdpi',
+        72: 'hdpi',
+        96: 'xhdpi',
+        144: 'xxhdpi',
+        192: 'xxxhdpi'
+    };
+    // find the best matching icon for a given density or size
+    // @output android_icons
+    var parseIcon = function(icon, icon_size) {
+        // do I have a platform icon for that density already
+        var density = icon.density || sizeToDensityMap[icon_size];
+        if (!density) {
+            // invalid icon defition ( or unsupported size)
+            return;
         }
-        var projectRoot = util.isCordova(this.path);
-        // copy the default icon to the drawable folder
-        if (default_icon) {
-            this.copyImage(path.join(projectRoot, default_icon.src), '', 'icon.png');
+        var previous = android_icons[density];
+        if (previous && previous.platform) {
+            return;
         }
-
-         for (var density in android_icons) {
-            this.copyImage(path.join(projectRoot, android_icons[density].src), density, 'icon.png');
-         }
-    },
-
-    update_from_config:function(config) {
-        // TODO: share code for this func with Android. Or fix it and remove
-        // the below JSHint hacks line.
-        // jshint unused:false, indent:false, undef:true, loopfunc:true, shadow:true, quotmark:false
-        if (config instanceof ConfigParser) {
-        } else throw new Error('update_from_config requires a ConfigParser object');
-
-        // Update app name by editing res/values/strings.xml
-        var name = config.name();
-        var strings = xml.parseElementtreeSync(this.strings);
-        strings.find('string[@name="app_name"]').text = name;
-        fs.writeFileSync(this.strings, strings.write({indent: 4}), 'utf-8');
-        events.emit('verbose', 'Wrote out Android application name to "' + name + '"');
-
-        this.handleSplashes(config);
-        this.handleIcons(config);
-
-        var manifest = xml.parseElementtreeSync(this.manifest);
-        // Update the version by changing the AndroidManifest android:versionName
-        var version = config.version();
-        var versionCode = config.android_versionCode() || default_versionCode(version);
-        manifest.getroot().attrib["android:versionName"] = version;
-        manifest.getroot().attrib["android:versionCode"] = versionCode;
-
-        // Update package name by changing the AndroidManifest id and moving the entry class around to the proper package directory
-        var pkg = config.android_packageName() || config.packageName();
-        pkg = pkg.replace(/-/g, '_'); // Java packages cannot support dashes
-        var orig_pkg = manifest.getroot().attrib.package;
-        manifest.getroot().attrib.package = pkg;
-
-        var act = manifest.getroot().find('./application/activity');
-
-        // Set the orientation in the AndroidManifest
-        var orientationPref = this.findOrientationPreference(config);
-        if (orientationPref) {
-            switch (orientationPref) {
-                case 'default':
-                    delete act.attrib["android:screenOrientation"];
-                    break;
-                case 'portrait':
-                    act.attrib["android:screenOrientation"] = 'portrait';
-                    break;
-                case 'landscape':
-                    act.attrib["android:screenOrientation"] = 'landscape';
+        android_icons[density] = icon;
+    };
+
+    // iterate over all icon elements to find the default icon and call parseIcon
+    for (var i=0; i<icons.length; i++) {
+        var icon = icons[i];
+        var size = icon.width;
+        if (!size) {
+            size = icon.height;
+        }
+        if (!size && !icon.density) {
+            if (default_icon) {
+                events.emit('verbose', 'more than one default icon: ' + JSON.stringify(icon));
+            } else {
+                default_icon = icon;
             }
+        } else {
+            parseIcon(icon, size);
         }
+    }
+    var projectRoot = util.isCordova(this.path);
+    // copy the default icon to the drawable folder
+    if (default_icon) {
+        this.copyImage(path.join(projectRoot, default_icon.src), '', 'icon.png');
+    }
 
-        // Set android:launchMode in AndroidManifest
-        var androidLaunchModePref = this.findAndroidLaunchModePreference(config);
-        if (androidLaunchModePref) {
-            act.attrib["android:launchMode"] = androidLaunchModePref;
-        } else { // User has (explicitly) set an invalid value for AndroidLaunchMode preference
-            delete act.attrib["android:launchMode"]; // use Android default value (standard)
+     for (var density in android_icons) {
+        this.copyImage(path.join(projectRoot, android_icons[density].src), density, 'icon.png');
+     }
+};
+
+android_parser.prototype.update_from_config = function(config) {
+    // TODO: share code for this func with Android. Or fix it and remove
+    // the below JSHint hacks line.
+    // jshint unused:false, indent:false, undef:true, loopfunc:true, shadow:true, quotmark:false
+    if (config instanceof ConfigParser) {
+    } else throw new Error('update_from_config requires a ConfigParser object');
+
+    // Update app name by editing res/values/strings.xml
+    var name = config.name();
+    var strings = xml.parseElementtreeSync(this.strings);
+    strings.find('string[@name="app_name"]').text = name;
+    fs.writeFileSync(this.strings, strings.write({indent: 4}), 'utf-8');
+    events.emit('verbose', 'Wrote out Android application name to "' + name + '"');
+
+    this.handleSplashes(config);
+    this.handleIcons(config);
+
+    var manifest = xml.parseElementtreeSync(this.manifest);
+    // Update the version by changing the AndroidManifest android:versionName
+    var version = config.version();
+    var versionCode = config.android_versionCode() || default_versionCode(version);
+    manifest.getroot().attrib["android:versionName"] = version;
+    manifest.getroot().attrib["android:versionCode"] = versionCode;
+
+    // Update package name by changing the AndroidManifest id and moving the entry class around to the proper package directory
+    var pkg = config.android_packageName() || config.packageName();
+    pkg = pkg.replace(/-/g, '_'); // Java packages cannot support dashes
+    var orig_pkg = manifest.getroot().attrib.package;
+    manifest.getroot().attrib.package = pkg;
+
+    var act = manifest.getroot().find('./application/activity');
+
+    // Set the orientation in the AndroidManifest
+    var orientationPref = this.findOrientationPreference(config);
+    if (orientationPref) {
+        switch (orientationPref) {
+            case 'default':
+                delete act.attrib["android:screenOrientation"];
+                break;
+            case 'portrait':
+                act.attrib["android:screenOrientation"] = 'portrait';
+                break;
+            case 'landscape':
+                act.attrib["android:screenOrientation"] = 'landscape';
         }
+    }
 
-        // Set min/max/target SDK version 
-        //<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" ... />
-        var usesSdk = manifest.getroot().find('./uses-sdk');
-        ['minSdkVersion', 'maxSdkVersion', 'targetSdkVersion'].forEach(function(sdkPrefName) {
-            var sdkPrefValue = config.getPreference('android-' + sdkPrefName, 'android');
-            if (!sdkPrefValue) return;
-            
-            if (!usesSdk) { // if there is no required uses-sdk element, we should create it first
-                usesSdk = new et.Element('uses-sdk');
-                manifest.getroot().append(usesSdk);
-            }
-            usesSdk.attrib['android:' + sdkPrefName] = sdkPrefValue;
-        });
+    // Set android:launchMode in AndroidManifest
+    var androidLaunchModePref = this.findAndroidLaunchModePreference(config);
+    if (androidLaunchModePref) {
+        act.attrib["android:launchMode"] = androidLaunchModePref;
+    } else { // User has (explicitly) set an invalid value for AndroidLaunchMode preference
+        delete act.attrib["android:launchMode"]; // use Android default value (standard)
+    }
 
-        // Write out AndroidManifest.xml
-        fs.writeFileSync(this.manifest, manifest.write({indent: 4}), 'utf-8');
+    // Set min/max/target SDK version
+    //<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" ... />
+    var usesSdk = manifest.getroot().find('./uses-sdk');
+    ['minSdkVersion', 'maxSdkVersion', 'targetSdkVersion'].forEach(function(sdkPrefName) {
+        var sdkPrefValue = config.getPreference('android-' + sdkPrefName, 'android');
+        if (!sdkPrefValue) return;
 
-        var orig_pkgDir = path.join(this.path, 'src', path.join.apply(null, orig_pkg.split('.')));
-        var java_files = fs.readdirSync(orig_pkgDir).filter(function(f) {
-          return f.indexOf('.svn') == -1 && f.indexOf('.java') >= 0 && fs.readFileSync(path.join(orig_pkgDir, f), 'utf-8').match(/extends\s+CordovaActivity/);
-        });
-        if (java_files.length === 0) {
-          throw new Error('No Java files found which extend CordovaActivity.');
-        } else if(java_files.length > 1) {
-          events.emit('log', 'Multiple candidate Java files (.java files which extend CordovaActivity) found. Guessing at the first one, ' + java_files[0]);
+        if (!usesSdk) { // if there is no required uses-sdk element, we should create it first
+            usesSdk = new et.Element('uses-sdk');
+            manifest.getroot().append(usesSdk);
         }
+        usesSdk.attrib['android:' + sdkPrefName] = sdkPrefValue;
+    });
+
+    // Write out AndroidManifest.xml
+    fs.writeFileSync(this.manifest, manifest.write({indent: 4}), 'utf-8');
+
+    var orig_pkgDir = path.join(this.path, 'src', path.join.apply(null, orig_pkg.split('.')));
+    var java_files = fs.readdirSync(orig_pkgDir).filter(function(f) {
+      return f.indexOf('.svn') == -1 && f.indexOf('.java') >= 0 && fs.readFileSync(path.join(orig_pkgDir, f), 'utf-8').match(/extends\s+CordovaActivity/);
+    });
+    if (java_files.length === 0) {
+      throw new Error('No Java files found which extend CordovaActivity.');
+    } else if(java_files.length > 1) {
+      events.emit('log', 'Multiple candidate Java files (.java files which extend CordovaActivity) found. Guessing at the first one, ' + java_files[0]);
+    }
 
-        var orig_java_class = java_files[0];
-        var pkgDir = path.join(this.path, 'src', path.join.apply(null, pkg.split('.')));
-        shell.mkdir('-p', pkgDir);
-        var orig_javs = path.join(orig_pkgDir, orig_java_class);
-        var new_javs = path.join(pkgDir, orig_java_class);
-        var javs_contents = fs.readFileSync(orig_javs, 'utf-8');
-        javs_contents = javs_contents.replace(/package [\w\.]*;/, 'package ' + pkg + ';');
-        events.emit('verbose', 'Wrote out Android package name to "' + pkg + '"');
-        fs.writeFileSync(new_javs, javs_contents, 'utf-8');
-    },
-
-    // Returns the platform-specific www directory.
-    www_dir:function() {
-        return path.join(this.path, 'assets', 'www');
-    },
-
-    config_xml:function(){
-        return this.android_config;
-    },
-
-    // Used for creating platform_www in projects created by older versions.
-    cordovajs_path:function(libDir) {
-        var jsPath = path.join(libDir, 'framework', 'assets', 'www', 'cordova.js');
-        return path.resolve(jsPath);
-    },
-
-    // Replace the www dir with contents of platform_www and app www.
-    update_www:function() {
-        var projectRoot = util.isCordova(this.path);
-        var app_www = util.projectWww(projectRoot);
-        var platform_www = path.join(this.path, '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 over stock platform www assets (cordova.js)
-        shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
-    },
-
-    // update the overrides folder into the www folder
-    update_overrides:function() {
-        var projectRoot = util.isCordova(this.path);
-        var merges_path = path.join(util.appDir(projectRoot), 'merges', 'android');
-        if (fs.existsSync(merges_path)) {
-            var overrides = path.join(merges_path, '*');
-            shell.cp('-rf', overrides, this.www_dir());
-        }
-    },
-
-    // Returns a promise.
-    update_project:function(cfg) {
-        var platformWww = path.join(this.path, 'assets');
-        try {
-            this.update_from_config(cfg);
-            this.update_overrides();
-        } catch(e) {
-            return Q.reject(e);
-        }
-        // delete any .svn folders copied over
-        util.deleteSvnFolders(platformWww);
-        return Q();
+    var orig_java_class = java_files[0];
+    var pkgDir = path.join(this.path, 'src', path.join.apply(null, pkg.split('.')));
+    shell.mkdir('-p', pkgDir);
+    var orig_javs = path.join(orig_pkgDir, orig_java_class);
+    var new_javs = path.join(pkgDir, orig_java_class);
+    var javs_contents = fs.readFileSync(orig_javs, 'utf-8');
+    javs_contents = javs_contents.replace(/package [\w\.]*;/, 'package ' + pkg + ';');
+    events.emit('verbose', 'Wrote out Android package name to "' + pkg + '"');
+    fs.writeFileSync(new_javs, javs_contents, 'utf-8');
+};
+
+// Returns the platform-specific www directory.
+android_parser.prototype.www_dir = function() {
+    return path.join(this.path, 'assets', 'www');
+};
+
+android_parser.prototype.config_xml = function(){
+    return this.android_config;
+};
+
+// Used for creating platform_www in projects created by older versions.
+android_parser.prototype.cordovajs_path = function(libDir) {
+    var jsPath = path.join(libDir, 'framework', 'assets', 'www', 'cordova.js');
+    return path.resolve(jsPath);
+};
+
+// Replace the www dir with contents of platform_www and app www.
+android_parser.prototype.update_www = function() {
+    var projectRoot = util.isCordova(this.path);
+    var app_www = util.projectWww(projectRoot);
+    var platform_www = path.join(this.path, '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 over stock platform www assets (cordova.js)
+    shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+};
+
+// update the overrides folder into the www folder
+android_parser.prototype.update_overrides = function() {
+    var projectRoot = util.isCordova(this.path);
+    var merges_path = path.join(util.appDir(projectRoot), 'merges', 'android');
+    if (fs.existsSync(merges_path)) {
+        var overrides = path.join(merges_path, '*');
+        shell.cp('-rf', overrides, this.www_dir());
     }
 };
 
+// Returns a promise.
+android_parser.prototype.update_project = function(cfg) {
+    var platformWww = path.join(this.path, 'assets');
+    try {
+        this.update_from_config(cfg);
+        this.update_overrides();
+    } catch(e) {
+        return Q.reject(e);
+    }
+    // delete any .svn folders copied over
+    util.deleteSvnFolders(platformWww);
+    return Q();
+};
 
 // Consturct the default value for versionCode as
 // PATCH + MINOR * 100 + MAJOR * 10000

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/dcd6a0c0/cordova-lib/src/cordova/metadata/blackberry10_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/blackberry10_parser.js b/cordova-lib/src/cordova/metadata/blackberry10_parser.js
index 31493a4..1bd1e8f 100644
--- a/cordova-lib/src/cordova/metadata/blackberry10_parser.js
+++ b/cordova-lib/src/cordova/metadata/blackberry10_parser.js
@@ -30,99 +30,99 @@ var fs            = require('fs'),
     CordovaError  = require('../../CordovaError'),
     events        = require('../../events');
 
-module.exports = function blackberry_parser(project) {
+function blackberry_parser(project) {
     if (!fs.existsSync(path.join(project, 'www'))) {
         throw new CordovaError('The provided path "' + project + '" is not a Cordova BlackBerry10 project.');
     }
     this.path = project;
     this.config_path = path.join(this.path, 'www', 'config.xml');
     this.xml = new ConfigParser(this.config_path);
-};
+}
 
-module.exports.prototype = {
-    update_from_config:function(config) {
-        var projectRoot = util.isCordova(this.path),
-            resDir = path.join(this.path, 'platform_www', 'res'),
-            icons,
-            i;
+module.exports = blackberry_parser;
 
-        if (!config instanceof ConfigParser) {
-            throw new Error('update_from_config requires a ConfigParser object');
-        }
+blackberry_parser.prototype.update_from_config = function(config) {
+    var projectRoot = util.isCordova(this.path),
+        resDir = path.join(this.path, 'platform_www', 'res'),
+        icons,
+        i;
+
+    if (!config instanceof ConfigParser) {
+        throw new Error('update_from_config requires a ConfigParser object');
+    }
+
+    shell.rm('-rf', resDir);
+    shell.mkdir(resDir);
+
+    icons = config.getIcons('blackberry10');
+    if (icons) {
+        for (i = 0; i < icons.length; i++) {
+            var src = path.join(projectRoot, icons[i].src),
+                dest = path.join(this.path, 'platform_www', icons[i].src),
+                destFolder = path.join(dest, '..');
 
-        shell.rm('-rf', resDir);
-        shell.mkdir(resDir);
-
-        icons = config.getIcons('blackberry10');
-        if (icons) {
-            for (i = 0; i < icons.length; i++) {
-                var src = path.join(projectRoot, icons[i].src),
-                    dest = path.join(this.path, 'platform_www', icons[i].src),
-                    destFolder = path.join(dest, '..');
-
-                if (!fs.existsSync(destFolder)) {
-                    shell.mkdir(destFolder); // make sure target dir exists
-                }
-                events.emit('verbose', 'Copying icon from ' + src + ' to ' + dest);
-                shell.cp('-f', src, dest);
+            if (!fs.existsSync(destFolder)) {
+                shell.mkdir(destFolder); // make sure target dir exists
             }
+            events.emit('verbose', 'Copying icon from ' + src + ' to ' + dest);
+            shell.cp('-f', src, dest);
         }
-    },
+    }
+};
 
-    // Returns a promise.
-    update_project:function(cfg) {
-        var self = this;
+// Returns a promise.
+blackberry_parser.prototype.update_project = function(cfg) {
+    var self = this;
 
-        try {
-            self.update_from_config(cfg);
-        } catch(e) {
-            return Q.reject(e);
-        }
-        self.update_overrides();
-        util.deleteSvnFolders(this.www_dir());
-        return Q();
-    },
-
-    // Returns the platform-specific www directory.
-    www_dir:function() {
-        return path.join(this.path, 'www');
-    },
-
-    config_xml:function(){
-        return this.config_path;
-    },
-
-    // Used for creating platform_www in projects created by older versions.
-    cordovajs_path:function(libDir) {
-        var jsPath = path.join(libDir, 'javascript', 'cordova.blackberry10.js');
-        return path.resolve(jsPath);
-    },
-
-    // Replace the www dir with contents of platform_www and app www.
-    update_www:function() {
-        var projectRoot = util.isCordova(this.path);
-        var app_www = util.projectWww(projectRoot);
-        var platform_www = path.join(this.path, 'platform_www');
-        var platform_cfg_backup = new ConfigParser(this.config_path);
-
-        // 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 over stock platform www assets (cordova.js)
-        shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
-        //Re-Write config.xml
-        platform_cfg_backup.write();
-    },
-
-    // update the overrides folder into the www folder
-    update_overrides:function() {
-        var projectRoot = util.isCordova(this.path);
-        var merges_path = path.join(util.appDir(projectRoot), 'merges', 'blackberry10');
-        if (fs.existsSync(merges_path)) {
-            var overrides = path.join(merges_path, '*');
-            shell.cp('-rf', overrides, this.www_dir());
-        }
-    },
+    try {
+        self.update_from_config(cfg);
+    } catch(e) {
+        return Q.reject(e);
+    }
+    self.update_overrides();
+    util.deleteSvnFolders(this.www_dir());
+    return Q();
+};
+
+// Returns the platform-specific www directory.
+blackberry_parser.prototype.www_dir = function() {
+    return path.join(this.path, 'www');
+};
+
+blackberry_parser.prototype.config_xml = function(){
+    return this.config_path;
+};
+
+// Used for creating platform_www in projects created by older versions.
+blackberry_parser.prototype.cordovajs_path = function(libDir) {
+    var jsPath = path.join(libDir, 'javascript', 'cordova.blackberry10.js');
+    return path.resolve(jsPath);
+};
+
+// Replace the www dir with contents of platform_www and app www.
+blackberry_parser.prototype.update_www = function() {
+    var projectRoot = util.isCordova(this.path);
+    var app_www = util.projectWww(projectRoot);
+    var platform_www = path.join(this.path, 'platform_www');
+    var platform_cfg_backup = new ConfigParser(this.config_path);
+
+    // 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 over stock platform www assets (cordova.js)
+    shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+    //Re-Write config.xml
+    platform_cfg_backup.write();
+};
+
+// update the overrides folder into the www folder
+blackberry_parser.prototype.update_overrides = function() {
+    var projectRoot = util.isCordova(this.path);
+    var merges_path = path.join(util.appDir(projectRoot), 'merges', 'blackberry10');
+    if (fs.existsSync(merges_path)) {
+        var overrides = path.join(merges_path, '*');
+        shell.cp('-rf', overrides, this.www_dir());
+    }
 };

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/dcd6a0c0/cordova-lib/src/cordova/metadata/browser_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/browser_parser.js b/cordova-lib/src/cordova/metadata/browser_parser.js
index bb89b91..23e3dfe 100644
--- a/cordova-lib/src/cordova/metadata/browser_parser.js
+++ b/cordova-lib/src/cordova/metadata/browser_parser.js
@@ -28,61 +28,60 @@ var fs = require('fs'),
     util = require('../util'),
     Q = require('q');
 
-module.exports = function browser_parser(project) {
+function browser_parser(project) {
     this.path = project;
-};
+}
 
+module.exports = browser_parser;
 
-module.exports.prototype = {
-    // Returns a promise.
-    update_from_config: function() {
-        return Q();
-    },
+// Returns a promise.
+browser_parser.prototype.update_from_config = function() {
+    return Q();
+};
 
-    www_dir: function() {
-        return path.join(this.path, 'www');
-    },
+browser_parser.prototype.www_dir = function() {
+    return path.join(this.path, 'www');
+};
 
-    // Used for creating platform_www in projects created by older versions.
-    cordovajs_path:function(libDir) {
-        var jsPath = path.join(libDir, 'cordova-lib', 'cordova.js');
-        return path.resolve(jsPath);
-    },
+// Used for creating platform_www in projects created by older versions.
+browser_parser.prototype.cordovajs_path = function(libDir) {
+    var jsPath = path.join(libDir, 'cordova-lib', 'cordova.js');
+    return path.resolve(jsPath);
+};
 
-    // Replace the www dir with contents of platform_www and app www.
-    update_www:function() {
-        var projectRoot = util.isCordova(this.path);
-        var app_www = util.projectWww(projectRoot);
-        var platform_www = path.join(this.path, 'platform_www');
+// Replace the www dir with contents of platform_www and app www.
+browser_parser.prototype.update_www = function() {
+    var projectRoot = util.isCordova(this.path);
+    var app_www = util.projectWww(projectRoot);
+    var platform_www = path.join(this.path, '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 over stock platform www assets (cordova.js)
-        shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
-    },
+    // 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 over stock platform www assets (cordova.js)
+    shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+};
 
-    update_overrides: function() {
-        var projectRoot = util.isCordova(this.path);
-        var mergesPath = path.join(util.appDir(projectRoot), 'merges', 'browser');
-        if(fs.existsSync(mergesPath)) {
-            var overrides = path.join(mergesPath, '*');
-            shell.cp('-rf', overrides, this.www_dir());
-        }
-    },
+browser_parser.prototype.update_overrides = function() {
+    var projectRoot = util.isCordova(this.path);
+    var mergesPath = path.join(util.appDir(projectRoot), 'merges', 'browser');
+    if(fs.existsSync(mergesPath)) {
+        var overrides = path.join(mergesPath, '*');
+        shell.cp('-rf', overrides, this.www_dir());
+    }
+};
 
-    config_xml:function(){
-        return path.join(this.path, 'config.xml');
-    },
+browser_parser.prototype.config_xml = function(){
+    return path.join(this.path, 'config.xml');
+};
 
-    // Returns a promise.
-    update_project: function(cfg) {
-        return this.update_from_config()
-            .then(function(){
-                this.update_overrides();
-                util.deleteSvnFolders(this.www_dir());
-            }.bind(this));
-    }
+// Returns a promise.
+browser_parser.prototype.update_project = function(cfg) {
+    return this.update_from_config()
+        .then(function(){
+            this.update_overrides();
+            util.deleteSvnFolders(this.www_dir());
+        }.bind(this));
 };

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/dcd6a0c0/cordova-lib/src/cordova/metadata/firefoxos_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/firefoxos_parser.js b/cordova-lib/src/cordova/metadata/firefoxos_parser.js
index b4e435e..f58e654 100644
--- a/cordova-lib/src/cordova/metadata/firefoxos_parser.js
+++ b/cordova-lib/src/cordova/metadata/firefoxos_parser.js
@@ -30,169 +30,168 @@ var fs = require('fs'),
     Q = require('q'),
     ConfigParser = require('../../configparser/ConfigParser');
 
-module.exports = function firefoxos_parser(project) {
+function firefoxos_parser(project) {
     this.path = project;
-};
+}
 
+module.exports = firefoxos_parser;
 
-module.exports.prototype = {
-    // Returns a promise.
-    update_from_config: function() {
-        var config = new ConfigParser(this.config_xml());
-        var manifestPath = path.join(this.www_dir(), 'manifest.webapp');
-        var manifest = {};
+// Returns a promise.
+firefoxos_parser.prototype.update_from_config = function() {
+    var config = new ConfigParser(this.config_xml());
+    var manifestPath = path.join(this.www_dir(), 'manifest.webapp');
+    var manifest = {};
 
-        // Load existing manifest
-        if (fs.existsSync(manifestPath)) {
-            manifest = JSON.parse(fs.readFileSync(manifestPath));
-        }
+    // Load existing manifest
+    if (fs.existsSync(manifestPath)) {
+        manifest = JSON.parse(fs.readFileSync(manifestPath));
+    }
 
-        // overwrite properties existing in config.xml
-        var contentNode = config.doc.find('content');
-        var contentSrc = contentNode && contentNode.attrib['src'] || 'index.html';
-        manifest.launch_path = '/' + contentSrc;
+    // overwrite properties existing in config.xml
+    var contentNode = config.doc.find('content');
+    var contentSrc = contentNode && contentNode.attrib['src'] || 'index.html';
+    manifest.launch_path = '/' + contentSrc;
 
-        manifest.installs_allowed_from = manifest.installs_allowed_from || ['*'];
-        manifest.version = config.version();
-        manifest.name = config.name();
-        manifest.description = config.description();
-        manifest.developer = {
-            name: config.author()
-        };
+    manifest.installs_allowed_from = manifest.installs_allowed_from || ['*'];
+    manifest.version = config.version();
+    manifest.name = config.name();
+    manifest.description = config.description();
+    manifest.developer = {
+        name: config.author()
+    };
 
-        var authorNode = config.doc.find('author');
-        var authorUrl = authorNode && authorNode.attrib['href'];
+    var authorNode = config.doc.find('author');
+    var authorUrl = authorNode && authorNode.attrib['href'];
 
-        if (authorUrl) {
-            manifest.developer.url = authorUrl;
-        }
+    if (authorUrl) {
+        manifest.developer.url = authorUrl;
+    }
 
-        var fullScreen = config.getPreference('fullscreen');
+    var fullScreen = config.getPreference('fullscreen');
 
-        if (fullScreen) {
-            manifest.fullscreen = fullScreen;
+    if (fullScreen) {
+        manifest.fullscreen = fullScreen;
+    }
+
+    var orientations = [];
+    var preferenceNodes = config.doc.findall('preference');
+    preferenceNodes.forEach(function (preference) {
+        if (preference.attrib.name.toLowerCase() === 'orientation') {
+            orientations.push(preference.attrib.value);
         }
+    });
 
-        var orientations = [];
-        var preferenceNodes = config.doc.findall('preference');
-        preferenceNodes.forEach(function (preference) {
-            if (preference.attrib.name.toLowerCase() === 'orientation') {
-                orientations.push(preference.attrib.value);
-            }
-        });
+    if (orientations && orientations.length) {
+        manifest.orientation = orientations;
+    }
 
-        if (orientations && orientations.length) {
-            manifest.orientation = orientations;
-        }
+    var permissionNodes = config.doc.findall('permission');
+    var privileged = false;
 
-        var permissionNodes = config.doc.findall('permission');
-        var privileged = false;
+    if (permissionNodes.length) {
+        manifest.permissions = {};
 
-        if (permissionNodes.length) {
-            manifest.permissions = {};
+        permissionNodes.forEach(function(node) {
+            var permissionName = node.attrib['name'];
 
-            permissionNodes.forEach(function(node) {
-                var permissionName = node.attrib['name'];
+            manifest.permissions[permissionName] = {
+                description: node.attrib['description']
+            };
 
-                manifest.permissions[permissionName] = {
-                    description: node.attrib['description']
-                };
+            if (node.attrib['access']) {
+                manifest.permissions[permissionName].access = node.attrib['access'];
+            }
 
-                if (node.attrib['access']) {
-                    manifest.permissions[permissionName].access = node.attrib['access'];
-                }
+            if (node.attrib['privileged'] === 'true') {
+                privileged = true;
+            }
+        });
+    }
 
-                if (node.attrib['privileged'] === 'true') {
-                    privileged = true;
-                }
-            });
-        }
+    if (privileged) {
+        manifest.type = 'privileged';
+    } else {
+        delete manifest.type;
+    }
 
-        if (privileged) {
-            manifest.type = 'privileged';
-        } else {
-            delete manifest.type;
-        }
+    var icons = config.getIcons('firefoxos');
+    // if there are icon elements in config.xml
+    if (icons) {
+        manifest.icons = {};
+        for (var i = 0; i < icons.length; i++) {
+            var icon = icons[i];
+            var size = icon.width;
+            var sizeInt = parseInt(size);
+
+            events.emit('verbose', 'icon[' + i + ']:' + JSON.stringify(icon));
+
+            if (size && !isNaN(sizeInt)) {
+                if (icon.src) {
+                    var destfilepath = path.join(this.www_dir(), 'icon', 'icon-' + size + '.png');
 
-        var icons = config.getIcons('firefoxos');
-        // if there are icon elements in config.xml
-        if (icons) {
-            manifest.icons = {};
-            for (var i = 0; i < icons.length; i++) {
-                var icon = icons[i];
-                var size = icon.width;
-                var sizeInt = parseInt(size);
-
-                events.emit('verbose', 'icon[' + i + ']:' + JSON.stringify(icon));
-
-                if (size && !isNaN(sizeInt)) {
-                    if (icon.src) {
-                        var destfilepath = path.join(this.www_dir(), 'icon', 'icon-' + size + '.png');
-
-                        manifest.icons[sizeInt] = '/icon/icon-' + size + '.png';
-
-                        if (!fs.existsSync(icon.src)) {
-                            events.emit('verbose', 'ignoring icon[' + i + '] icon. File ' + icon.src + ' not found.');
-                        } else {
-                            events.emit('verbose', 'Copying icon from ' + icon.src + ' to ' + destfilepath);
-                            shell.cp('-f', icon.src, destfilepath);
-                        }
+                    manifest.icons[sizeInt] = '/icon/icon-' + size + '.png';
+
+                    if (!fs.existsSync(icon.src)) {
+                        events.emit('verbose', 'ignoring icon[' + i + '] icon. File ' + icon.src + ' not found.');
                     } else {
-                        events.emit('warn', 'ignoring icon[' + i + '] no src attribute:' + JSON.stringify(icon));
+                        events.emit('verbose', 'Copying icon from ' + icon.src + ' to ' + destfilepath);
+                        shell.cp('-f', icon.src, destfilepath);
                     }
+                } else {
+                    events.emit('warn', 'ignoring icon[' + i + '] no src attribute:' + JSON.stringify(icon));
                 }
             }
         }
+    }
 
-        fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 4));
-
-        return Q();
-    },
-
-    www_dir: function() {
-        return path.join(this.path, 'www');
-    },
-
-    // Used for creating platform_www in projects created by older versions.
-    cordovajs_path:function(libDir) {
-        var jsPath = path.join(libDir, 'cordova-lib', 'cordova.js');
-        return path.resolve(jsPath);
-    },
-
-    // Replace the www dir with contents of platform_www and app www.
-    update_www:function() {
-        var projectRoot = util.isCordova(this.path);
-        var app_www = util.projectWww(projectRoot);
-        var platform_www = path.join(this.path, '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 over stock platform www assets (cordova.js)
-        shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
-    },
-
-    update_overrides: function() {
-        var projectRoot = util.isCordova(this.path);
-        var mergesPath = path.join(util.appDir(projectRoot), 'merges', 'firefoxos');
-        if(fs.existsSync(mergesPath)) {
-            var overrides = path.join(mergesPath, '*');
-            shell.cp('-rf', overrides, this.www_dir());
-        }
-    },
-
-    config_xml:function(){
-        return path.join(this.path, 'config.xml');
-    },
-
-    // Returns a promise.
-    update_project: function(cfg) {
-        return this.update_from_config()
-            .then(function(){
-                this.update_overrides();
-                util.deleteSvnFolders(this.www_dir());
-            }.bind(this));
+    fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 4));
+
+    return Q();
+};
+
+firefoxos_parser.prototype.www_dir = function() {
+    return path.join(this.path, 'www');
+};
+
+// Used for creating platform_www in projects created by older versions.
+firefoxos_parser.prototype.cordovajs_path = function(libDir) {
+    var jsPath = path.join(libDir, 'cordova-lib', 'cordova.js');
+    return path.resolve(jsPath);
+};
+
+// Replace the www dir with contents of platform_www and app www.
+firefoxos_parser.prototype.update_www = function() {
+    var projectRoot = util.isCordova(this.path);
+    var app_www = util.projectWww(projectRoot);
+    var platform_www = path.join(this.path, '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 over stock platform www assets (cordova.js)
+    shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+};
+
+firefoxos_parser.prototype.update_overrides = function() {
+    var projectRoot = util.isCordova(this.path);
+    var mergesPath = path.join(util.appDir(projectRoot), 'merges', 'firefoxos');
+    if(fs.existsSync(mergesPath)) {
+        var overrides = path.join(mergesPath, '*');
+        shell.cp('-rf', overrides, this.www_dir());
     }
 };
+
+firefoxos_parser.prototype.config_xml = function(){
+    return path.join(this.path, 'config.xml');
+};
+
+// Returns a promise.
+firefoxos_parser.prototype.update_project = function(cfg) {
+    return this.update_from_config()
+        .then(function(){
+            this.update_overrides();
+            util.deleteSvnFolders(this.www_dir());
+        }.bind(this));
+};


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


Mime
View raw message