You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2014/09/16 00:59:52 UTC

[1/3] git commit: Removed unnecessary manifest creation from browser_parser

Repository: cordova-lib
Updated Branches:
  refs/heads/master 1fba040ac -> 405d0da0f


Removed unnecessary manifest creation from browser_parser


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

Branch: refs/heads/master
Commit: 37f8ef3e7f411908b15ea2acbc8ebd024b14cb66
Parents: 3aef160
Author: Suraj Pindoria <su...@yahoo.com>
Authored: Thu Sep 11 15:18:34 2014 -0700
Committer: Suraj Pindoria <su...@yahoo.com>
Committed: Thu Sep 11 15:18:34 2014 -0700

----------------------------------------------------------------------
 .../src/cordova/metadata/browser_parser.js      | 112 +------------------
 1 file changed, 1 insertion(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/37f8ef3e/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 25fc644..bb89b91 100644
--- a/cordova-lib/src/cordova/metadata/browser_parser.js
+++ b/cordova-lib/src/cordova/metadata/browser_parser.js
@@ -25,10 +25,8 @@
 var fs = require('fs'),
     path = require('path'),
     shell = require('shelljs'),
-    events = require('../../events'),
     util = require('../util'),
-    Q = require('q'),
-    ConfigParser = require('../../configparser/ConfigParser');
+    Q = require('q');
 
 module.exports = function browser_parser(project) {
     this.path = project;
@@ -38,114 +36,6 @@ module.exports = function browser_parser(project) {
 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 = {};
-
-        // 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.attrib['src'];
-        manifest.launch_path = path.join('/', contentSrc) || '/index.html';
-
-        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.attrib['href'];
-
-        if (authorUrl) {
-            manifest.developer.url = authorUrl;
-        }
-
-        var fullScreen = config.getPreference('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);
-            }
-        });
-
-        if (orientations && orientations.length) {
-            manifest.orientation = orientations;
-        }
-
-        var permissionNodes = config.doc.findall('permission');
-        var privileged = false;
-
-        if (permissionNodes.length) {
-            manifest.permissions = {};
-
-            permissionNodes.forEach(function(node) {
-                var permissionName = node.attrib['name'];
-
-                manifest.permissions[permissionName] = {
-                    description: node.attrib['description']
-                };
-
-                if (node.attrib['access']) {
-                    manifest.permissions[permissionName].access = node.attrib['access'];
-                }
-
-                if (node.attrib['privileged'] === 'true') {
-                    privileged = true;
-                }
-            });
-        }
-
-        if (privileged) {
-            manifest.type = 'privileged';
-        } else {
-            delete manifest.type;
-        }
-
-        var icons = config.getIcons('browser');
-        // 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);
-                        }
-                    } else {
-                        events.emit('warn', 'ignoring icon[' + i + '] no src attribute:' + JSON.stringify(icon));
-                    }
-                }
-            }
-        }
-
-        fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 4));
-
         return Q();
     },
 


[3/3] git commit: Merge branch 'browserPlatform' of https://github.com/surajpindoria/cordova-lib

Posted by an...@apache.org.
Merge branch 'browserPlatform' of https://github.com/surajpindoria/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/405d0da0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/405d0da0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/405d0da0

Branch: refs/heads/master
Commit: 405d0da0fc8ba1598192b7ef212854b9d7542bf8
Parents: 1fba040 ace7e33
Author: Anis Kadri <an...@apache.org>
Authored: Mon Sep 15 15:59:44 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Sep 15 15:59:44 2014 -0700

----------------------------------------------------------------------
 .../metadata/browser_parser.spec.js             |  88 +++++++++++++++
 .../src/cordova/metadata/browser_parser.js      | 112 +------------------
 2 files changed, 89 insertions(+), 111 deletions(-)
----------------------------------------------------------------------



[2/3] git commit: Added tests for browser platform

Posted by an...@apache.org.
Added tests for browser platform


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

Branch: refs/heads/master
Commit: ace7e33531e3dce2ac84038ca4c76fb4cfc4657f
Parents: 37f8ef3
Author: Suraj Pindoria <su...@yahoo.com>
Authored: Thu Sep 11 15:23:44 2014 -0700
Committer: Suraj Pindoria <su...@yahoo.com>
Committed: Thu Sep 11 15:23:44 2014 -0700

----------------------------------------------------------------------
 .../metadata/browser_parser.spec.js             | 88 ++++++++++++++++++++
 1 file changed, 88 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ace7e335/cordova-lib/spec-cordova/metadata/browser_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/browser_parser.spec.js b/cordova-lib/spec-cordova/metadata/browser_parser.spec.js
new file mode 100644
index 0000000..0da4f7f
--- /dev/null
+++ b/cordova-lib/spec-cordova/metadata/browser_parser.spec.js
@@ -0,0 +1,88 @@
+/**
+    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.
+*/
+
+var platforms = require('../../src/cordova/platforms'),
+    util = require('../../src/cordova/util'),
+    path = require('path'),
+    shell = require('shelljs'),
+    fs = require('fs');
+
+describe('browser project parser', function() {
+    var proj = path.join('some', 'path');
+    var exists;
+
+    beforeEach(function() {
+        exists = spyOn(fs, 'existsSync').andReturn(true);
+    });
+
+    describe('constructions', function() {
+        it('should create an instance with a path', function() {
+            expect(function() {
+                var p = new platforms.browser.parser(proj);
+                expect(p.path).toEqual(proj);
+            }).not.toThrow();
+        });
+    });
+
+    describe('instance', function() {
+        var p, cp, rm, mkdir, is_cordova;
+        var browser_proj = path.join(proj, 'platforms', 'browser');
+
+        beforeEach(function() {
+            p = new platforms.browser.parser(browser_proj);
+            cp = spyOn(shell, 'cp');
+            rm = spyOn(shell, 'rm');
+            mkdir = spyOn(shell, 'mkdir');
+            is_cordova = spyOn(util, 'isCordova').andReturn(proj);
+        });
+
+        describe('www_dir method', function() {
+            it('should return /www', function() {
+                expect(p.www_dir()).toEqual(path.join(browser_proj, 'www'));
+            });
+        });
+
+        describe('config_xml method', function() {
+            it('should return the location of config.xml', function() {
+                expect(p.config_xml()).toEqual(path.join(proj, 'platforms', 'browser', 'config.xml'));
+            });
+        });
+
+        describe('update_www method', function() {
+            it('should rm project-level www and cp in platform agnostic www', function() {
+                p.update_www();
+                expect(rm).toHaveBeenCalled();
+                expect(cp).toHaveBeenCalled();
+            });
+        });
+
+        describe('update_overrides method', function() {
+            it('should do nothing if merges directory does not exist', function() {
+                exists.andReturn(false);
+                p.update_overrides();
+                expect(cp).not.toHaveBeenCalled();
+            });
+
+            it('should copy merges path into www', function() {
+                p.update_overrides();
+                expect(cp).toHaveBeenCalledWith('-rf', path.join(proj, 'merges', 'browser', '*'), path.join(proj, 'platforms', 'browser', 'www'));
+            });
+        });
+    });
+});