Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7213218A15 for ; Sat, 31 Oct 2015 02:50:30 +0000 (UTC) Received: (qmail 6439 invoked by uid 500); 31 Oct 2015 02:50:30 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 6303 invoked by uid 500); 31 Oct 2015 02:50:30 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 6263 invoked by uid 99); 31 Oct 2015 02:50:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Oct 2015 02:50:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6E7CDE095C; Sat, 31 Oct 2015 02:50:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: steven@apache.org To: commits@cordova.apache.org Date: Sat, 31 Oct 2015 02:50:29 -0000 Message-Id: <15b6ac8d9bdd49b7b99419e88f3d31b2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/4] android commit: updated node_modules Repository: cordova-android Updated Branches: refs/heads/master 3abd12aee -> 4f7721b40 http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f7721b4/node_modules/cordova-common/src/PluginInfo/PluginInfo.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/src/PluginInfo/PluginInfo.js b/node_modules/cordova-common/src/PluginInfo/PluginInfo.js index 32b3386..073f3f9 100644 --- a/node_modules/cordova-common/src/PluginInfo/PluginInfo.js +++ b/node_modules/cordova-common/src/PluginInfo/PluginInfo.js @@ -1,416 +1,416 @@ -/** - 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 sub:true, laxcomma:true, laxbreak:true */ - -/* -A class for holidng the information currently stored in plugin.xml -It should also be able to answer questions like whether the plugin -is compatible with a given engine version. - -TODO (kamrik): refactor this to not use sync functions and return promises. -*/ - - -var path = require('path') - , fs = require('fs') - , xml_helpers = require('../util/xml-helpers') - , CordovaError = require('../CordovaError/CordovaError') - ; - -function PluginInfo(dirname) { - var self = this; - - // METHODS - // Defined inside the constructor to avoid the "this" binding problems. - - // tag - // Example: - // Used to require a variable to be specified via --variable when installing the plugin. - self.getPreferences = getPreferences; - function getPreferences(platform) { - var arprefs = _getTags(self._et, 'preference', platform, _parsePreference); - - var prefs= {}; - for(var i in arprefs) - { - var pref=arprefs[i]; - prefs[pref.preference]=pref.default; - } - // returns { key : default | null} - return prefs; - } - - function _parsePreference(prefTag) { - var name = prefTag.attrib.name.toUpperCase(); - var def = prefTag.attrib.default || null; - return {preference: name, default: def}; - } - - // - self.getAssets = getAssets; - function getAssets(platform) { - var assets = _getTags(self._et, 'asset', platform, _parseAsset); - return assets; - } - - function _parseAsset(tag) { - var src = tag.attrib.src; - var target = tag.attrib.target; - - if ( !src || !target) { - var msg = - 'Malformed tag. Both "src" and "target" attributes' - + 'must be specified in\n' - + self.filepath - ; - throw new Error(msg); - } - - var asset = { - itemType: 'asset', - src: src, - target: target - }; - return asset; - } - - - // - // Example: - // - self.getDependencies = getDependencies; - function getDependencies(platform) { - var deps = _getTags( - self._et, - 'dependency', - platform, - _parseDependency - ); - return deps; - } - - function _parseDependency(tag) { - var dep = - { id : tag.attrib.id - , url : tag.attrib.url || '' - , subdir : tag.attrib.subdir || '' - , commit : tag.attrib.commit - }; - - dep.git_ref = dep.commit; - - if ( !dep.id ) { - var msg = - ' tag is missing id attribute in ' - + self.filepath - ; - throw new CordovaError(msg); - } - return dep; - } - - - // tag - self.getConfigFiles = getConfigFiles; - function getConfigFiles(platform) { - var configFiles = _getTags(self._et, 'config-file', platform, _parseConfigFile); - return configFiles; - } - - function _parseConfigFile(tag) { - var configFile = - { target : tag.attrib['target'] - , parent : tag.attrib['parent'] - , after : tag.attrib['after'] - , xmls : tag.getchildren() - // To support demuxing via versions - , versions : tag.attrib['versions'] - , deviceTarget: tag.attrib['device-target'] - }; - return configFile; - } - - // tags, both global and within a - // TODO (kamrik): Do we ever use under ? Example wanted. - self.getInfo = getInfo; - function getInfo(platform) { - var infos = _getTags( - self._et, - 'info', - platform, - function(elem) { return elem.text; } - ); - // Filter out any undefined or empty strings. - infos = infos.filter(Boolean); - return infos; - } - - // - // Examples: - // - // - self.getSourceFiles = getSourceFiles; - function getSourceFiles(platform) { - var sourceFiles = _getTagsInPlatform(self._et, 'source-file', platform, _parseSourceFile); - return sourceFiles; - } - - function _parseSourceFile(tag) { - return { - itemType: 'source-file', - src: tag.attrib.src, - framework: isStrTrue(tag.attrib.framework), - weak: isStrTrue(tag.attrib.weak), - compilerFlags: tag.attrib['compiler-flags'], - targetDir: tag.attrib['target-dir'] - }; - } - - // - // Example: - // - self.getHeaderFiles = getHeaderFiles; - function getHeaderFiles(platform) { - var headerFiles = _getTagsInPlatform(self._et, 'header-file', platform, function(tag) { - return { - itemType: 'header-file', - src: tag.attrib.src, - targetDir: tag.attrib['target-dir'] - }; - }); - return headerFiles; - } - - // - // Example: - // - self.getResourceFiles = getResourceFiles; - function getResourceFiles(platform) { - var resourceFiles = _getTagsInPlatform(self._et, 'resource-file', platform, function(tag) { - return { - itemType: 'resource-file', - src: tag.attrib.src, - target: tag.attrib.target, - versions: tag.attrib.versions, - deviceTarget: tag.attrib['device-target'], - arch: tag.attrib.arch - }; - }); - return resourceFiles; - } - - // - // Example: - // - self.getLibFiles = getLibFiles; - function getLibFiles(platform) { - var libFiles = _getTagsInPlatform(self._et, 'lib-file', platform, function(tag) { - return { - itemType: 'lib-file', - src: tag.attrib.src, - arch: tag.attrib.arch, - Include: tag.attrib.Include, - versions: tag.attrib.versions, - deviceTarget: tag.attrib['device-target'] || tag.attrib.target - }; - }); - return libFiles; - } - - // - // Example: - // - self.getHookScripts = getHookScripts; - function getHookScripts(hook, platforms) { - var scriptElements = self._et.findall('./hook'); - - if(platforms) { - platforms.forEach(function (platform) { - scriptElements = scriptElements.concat(self._et.findall('./platform[@name="' + platform + '"]/hook')); - }); - } - - function filterScriptByHookType(el) { - return el.attrib.src && el.attrib.type && el.attrib.type.toLowerCase() === hook; - } - - return scriptElements.filter(filterScriptByHookType); - } - - self.getJsModules = getJsModules; - function getJsModules(platform) { - var modules = _getTags(self._et, 'js-module', platform, _parseJsModule); - return modules; - } - - function _parseJsModule(tag) { - var ret = { - itemType: 'js-module', - name: tag.attrib.name, - src: tag.attrib.src, - clobbers: tag.findall('clobbers').map(function(tag) { return { target: tag.attrib.target }; }), - merges: tag.findall('merges').map(function(tag) { return { target: tag.attrib.target }; }), - runs: tag.findall('runs').length > 0 - }; - - return ret; - } - - self.getEngines = function() { - return self._et.findall('engines/engine').map(function(n) { - return { - name: n.attrib.name, - version: n.attrib.version, - platform: n.attrib.platform, - scriptSrc: n.attrib.scriptSrc - }; - }); - }; - - self.getPlatforms = function() { - return self._et.findall('platform').map(function(n) { - return { name: n.attrib.name }; - }); - }; - - self.getPlatformsArray = function() { - return self._et.findall('platform').map(function(n) { - return n.attrib.name; - }); - }; - self.getFrameworks = function(platform) { - return _getTags(self._et, 'framework', platform, function(el) { - var ret = { - itemType: 'framework', - type: el.attrib.type, - parent: el.attrib.parent, - custom: isStrTrue(el.attrib.custom), - src: el.attrib.src, - weak: isStrTrue(el.attrib.weak), - versions: el.attrib.versions, - targetDir: el.attrib['target-dir'], - deviceTarget: el.attrib['device-target'] || el.attrib.target, - arch: el.attrib.arch - }; - return ret; - }); - }; - - self.getFilesAndFrameworks = getFilesAndFrameworks; - function getFilesAndFrameworks(platform) { - // Please avoid changing the order of the calls below, files will be - // installed in this order. - var items = [].concat( - self.getSourceFiles(platform), - self.getHeaderFiles(platform), - self.getResourceFiles(platform), - self.getFrameworks(platform), - self.getLibFiles(platform) - ); - return items; - } - ///// End of PluginInfo methods ///// - - - ///// PluginInfo Constructor logic ///// - self.filepath = path.join(dirname, 'plugin.xml'); - if (!fs.existsSync(self.filepath)) { - throw new CordovaError('Cannot find plugin.xml for plugin \'' + path.basename(dirname) + '\'. Please try adding it again.'); - } - - self.dir = dirname; - var et = self._et = xml_helpers.parseElementtreeSync(self.filepath); - var pelem = et.getroot(); - self.id = pelem.attrib.id; - self.version = pelem.attrib.version; - - // Optional fields - self.name = pelem.findtext('name'); - self.description = pelem.findtext('description'); - self.license = pelem.findtext('license'); - self.repo = pelem.findtext('repo'); - self.issue = pelem.findtext('issue'); - self.keywords = pelem.findtext('keywords'); - self.info = pelem.findtext('info'); - if (self.keywords) { - self.keywords = self.keywords.split(',').map( function(s) { return s.trim(); } ); - } - self.getKeywordsAndPlatforms = function () { - var ret = self.keywords || []; - return ret.concat('ecosystem:cordova').concat(addCordova(self.getPlatformsArray())); - }; -} // End of PluginInfo constructor. - -// Helper function used to prefix every element of an array with cordova- -// Useful when we want to modify platforms to be cordova-platform -function addCordova(someArray) { - var newArray = someArray.map(function(element) { - return 'cordova-' + element; - }); - return newArray; -} - -// Helper function used by most of the getSomething methods of PluginInfo. -// Get all elements of a given name. Both in root and in platform sections -// for the given platform. If transform is given and is a function, it is -// applied to each element. -function _getTags(pelem, tag, platform, transform) { - var platformTag = pelem.find('./platform[@name="' + platform + '"]'); - if (platform == 'windows' && !platformTag) { - platformTag = pelem.find('platform[@name="' + 'windows8' + '"]'); - } - var tagsInRoot = pelem.findall(tag); - tagsInRoot = tagsInRoot || []; - var tagsInPlatform = platformTag ? platformTag.findall(tag) : []; - var tags = tagsInRoot.concat(tagsInPlatform); - if ( typeof transform === 'function' ) { - tags = tags.map(transform); - } - return tags; -} - -// Same as _getTags() but only looks inside a platfrom section. -function _getTagsInPlatform(pelem, tag, platform, transform) { - var platformTag = pelem.find('./platform[@name="' + platform + '"]'); - if (platform == 'windows' && !platformTag) { - platformTag = pelem.find('platform[@name="' + 'windows8' + '"]'); - } - var tags = platformTag ? platformTag.findall(tag) : []; - if ( typeof transform === 'function' ) { - tags = tags.map(transform); - } - return tags; -} - -// Check if x is a string 'true'. -function isStrTrue(x) { - return String(x).toLowerCase() == 'true'; -} - -module.exports = PluginInfo; -// Backwards compat: -PluginInfo.PluginInfo = PluginInfo; -PluginInfo.loadPluginsDir = function(dir) { - var PluginInfoProvider = require('./PluginInfoProvider'); - return new PluginInfoProvider().getAllWithinSearchPath(dir); -}; +/** + 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 sub:true, laxcomma:true, laxbreak:true */ + +/* +A class for holidng the information currently stored in plugin.xml +It should also be able to answer questions like whether the plugin +is compatible with a given engine version. + +TODO (kamrik): refactor this to not use sync functions and return promises. +*/ + + +var path = require('path') + , fs = require('fs') + , xml_helpers = require('../util/xml-helpers') + , CordovaError = require('../CordovaError/CordovaError') + ; + +function PluginInfo(dirname) { + var self = this; + + // METHODS + // Defined inside the constructor to avoid the "this" binding problems. + + // tag + // Example: + // Used to require a variable to be specified via --variable when installing the plugin. + self.getPreferences = getPreferences; + function getPreferences(platform) { + var arprefs = _getTags(self._et, 'preference', platform, _parsePreference); + + var prefs= {}; + for(var i in arprefs) + { + var pref=arprefs[i]; + prefs[pref.preference]=pref.default; + } + // returns { key : default | null} + return prefs; + } + + function _parsePreference(prefTag) { + var name = prefTag.attrib.name.toUpperCase(); + var def = prefTag.attrib.default || null; + return {preference: name, default: def}; + } + + // + self.getAssets = getAssets; + function getAssets(platform) { + var assets = _getTags(self._et, 'asset', platform, _parseAsset); + return assets; + } + + function _parseAsset(tag) { + var src = tag.attrib.src; + var target = tag.attrib.target; + + if ( !src || !target) { + var msg = + 'Malformed tag. Both "src" and "target" attributes' + + 'must be specified in\n' + + self.filepath + ; + throw new Error(msg); + } + + var asset = { + itemType: 'asset', + src: src, + target: target + }; + return asset; + } + + + // + // Example: + // + self.getDependencies = getDependencies; + function getDependencies(platform) { + var deps = _getTags( + self._et, + 'dependency', + platform, + _parseDependency + ); + return deps; + } + + function _parseDependency(tag) { + var dep = + { id : tag.attrib.id + , url : tag.attrib.url || '' + , subdir : tag.attrib.subdir || '' + , commit : tag.attrib.commit + }; + + dep.git_ref = dep.commit; + + if ( !dep.id ) { + var msg = + ' tag is missing id attribute in ' + + self.filepath + ; + throw new CordovaError(msg); + } + return dep; + } + + + // tag + self.getConfigFiles = getConfigFiles; + function getConfigFiles(platform) { + var configFiles = _getTags(self._et, 'config-file', platform, _parseConfigFile); + return configFiles; + } + + function _parseConfigFile(tag) { + var configFile = + { target : tag.attrib['target'] + , parent : tag.attrib['parent'] + , after : tag.attrib['after'] + , xmls : tag.getchildren() + // To support demuxing via versions + , versions : tag.attrib['versions'] + , deviceTarget: tag.attrib['device-target'] + }; + return configFile; + } + + // tags, both global and within a + // TODO (kamrik): Do we ever use under ? Example wanted. + self.getInfo = getInfo; + function getInfo(platform) { + var infos = _getTags( + self._et, + 'info', + platform, + function(elem) { return elem.text; } + ); + // Filter out any undefined or empty strings. + infos = infos.filter(Boolean); + return infos; + } + + // + // Examples: + // + // + self.getSourceFiles = getSourceFiles; + function getSourceFiles(platform) { + var sourceFiles = _getTagsInPlatform(self._et, 'source-file', platform, _parseSourceFile); + return sourceFiles; + } + + function _parseSourceFile(tag) { + return { + itemType: 'source-file', + src: tag.attrib.src, + framework: isStrTrue(tag.attrib.framework), + weak: isStrTrue(tag.attrib.weak), + compilerFlags: tag.attrib['compiler-flags'], + targetDir: tag.attrib['target-dir'] + }; + } + + // + // Example: + // + self.getHeaderFiles = getHeaderFiles; + function getHeaderFiles(platform) { + var headerFiles = _getTagsInPlatform(self._et, 'header-file', platform, function(tag) { + return { + itemType: 'header-file', + src: tag.attrib.src, + targetDir: tag.attrib['target-dir'] + }; + }); + return headerFiles; + } + + // + // Example: + // + self.getResourceFiles = getResourceFiles; + function getResourceFiles(platform) { + var resourceFiles = _getTagsInPlatform(self._et, 'resource-file', platform, function(tag) { + return { + itemType: 'resource-file', + src: tag.attrib.src, + target: tag.attrib.target, + versions: tag.attrib.versions, + deviceTarget: tag.attrib['device-target'], + arch: tag.attrib.arch + }; + }); + return resourceFiles; + } + + // + // Example: + // + self.getLibFiles = getLibFiles; + function getLibFiles(platform) { + var libFiles = _getTagsInPlatform(self._et, 'lib-file', platform, function(tag) { + return { + itemType: 'lib-file', + src: tag.attrib.src, + arch: tag.attrib.arch, + Include: tag.attrib.Include, + versions: tag.attrib.versions, + deviceTarget: tag.attrib['device-target'] || tag.attrib.target + }; + }); + return libFiles; + } + + // + // Example: + // + self.getHookScripts = getHookScripts; + function getHookScripts(hook, platforms) { + var scriptElements = self._et.findall('./hook'); + + if(platforms) { + platforms.forEach(function (platform) { + scriptElements = scriptElements.concat(self._et.findall('./platform[@name="' + platform + '"]/hook')); + }); + } + + function filterScriptByHookType(el) { + return el.attrib.src && el.attrib.type && el.attrib.type.toLowerCase() === hook; + } + + return scriptElements.filter(filterScriptByHookType); + } + + self.getJsModules = getJsModules; + function getJsModules(platform) { + var modules = _getTags(self._et, 'js-module', platform, _parseJsModule); + return modules; + } + + function _parseJsModule(tag) { + var ret = { + itemType: 'js-module', + name: tag.attrib.name, + src: tag.attrib.src, + clobbers: tag.findall('clobbers').map(function(tag) { return { target: tag.attrib.target }; }), + merges: tag.findall('merges').map(function(tag) { return { target: tag.attrib.target }; }), + runs: tag.findall('runs').length > 0 + }; + + return ret; + } + + self.getEngines = function() { + return self._et.findall('engines/engine').map(function(n) { + return { + name: n.attrib.name, + version: n.attrib.version, + platform: n.attrib.platform, + scriptSrc: n.attrib.scriptSrc + }; + }); + }; + + self.getPlatforms = function() { + return self._et.findall('platform').map(function(n) { + return { name: n.attrib.name }; + }); + }; + + self.getPlatformsArray = function() { + return self._et.findall('platform').map(function(n) { + return n.attrib.name; + }); + }; + self.getFrameworks = function(platform) { + return _getTags(self._et, 'framework', platform, function(el) { + var ret = { + itemType: 'framework', + type: el.attrib.type, + parent: el.attrib.parent, + custom: isStrTrue(el.attrib.custom), + src: el.attrib.src, + weak: isStrTrue(el.attrib.weak), + versions: el.attrib.versions, + targetDir: el.attrib['target-dir'], + deviceTarget: el.attrib['device-target'] || el.attrib.target, + arch: el.attrib.arch + }; + return ret; + }); + }; + + self.getFilesAndFrameworks = getFilesAndFrameworks; + function getFilesAndFrameworks(platform) { + // Please avoid changing the order of the calls below, files will be + // installed in this order. + var items = [].concat( + self.getSourceFiles(platform), + self.getHeaderFiles(platform), + self.getResourceFiles(platform), + self.getFrameworks(platform), + self.getLibFiles(platform) + ); + return items; + } + ///// End of PluginInfo methods ///// + + + ///// PluginInfo Constructor logic ///// + self.filepath = path.join(dirname, 'plugin.xml'); + if (!fs.existsSync(self.filepath)) { + throw new CordovaError('Cannot find plugin.xml for plugin \'' + path.basename(dirname) + '\'. Please try adding it again.'); + } + + self.dir = dirname; + var et = self._et = xml_helpers.parseElementtreeSync(self.filepath); + var pelem = et.getroot(); + self.id = pelem.attrib.id; + self.version = pelem.attrib.version; + + // Optional fields + self.name = pelem.findtext('name'); + self.description = pelem.findtext('description'); + self.license = pelem.findtext('license'); + self.repo = pelem.findtext('repo'); + self.issue = pelem.findtext('issue'); + self.keywords = pelem.findtext('keywords'); + self.info = pelem.findtext('info'); + if (self.keywords) { + self.keywords = self.keywords.split(',').map( function(s) { return s.trim(); } ); + } + self.getKeywordsAndPlatforms = function () { + var ret = self.keywords || []; + return ret.concat('ecosystem:cordova').concat(addCordova(self.getPlatformsArray())); + }; +} // End of PluginInfo constructor. + +// Helper function used to prefix every element of an array with cordova- +// Useful when we want to modify platforms to be cordova-platform +function addCordova(someArray) { + var newArray = someArray.map(function(element) { + return 'cordova-' + element; + }); + return newArray; +} + +// Helper function used by most of the getSomething methods of PluginInfo. +// Get all elements of a given name. Both in root and in platform sections +// for the given platform. If transform is given and is a function, it is +// applied to each element. +function _getTags(pelem, tag, platform, transform) { + var platformTag = pelem.find('./platform[@name="' + platform + '"]'); + if (platform == 'windows' && !platformTag) { + platformTag = pelem.find('platform[@name="' + 'windows8' + '"]'); + } + var tagsInRoot = pelem.findall(tag); + tagsInRoot = tagsInRoot || []; + var tagsInPlatform = platformTag ? platformTag.findall(tag) : []; + var tags = tagsInRoot.concat(tagsInPlatform); + if ( typeof transform === 'function' ) { + tags = tags.map(transform); + } + return tags; +} + +// Same as _getTags() but only looks inside a platfrom section. +function _getTagsInPlatform(pelem, tag, platform, transform) { + var platformTag = pelem.find('./platform[@name="' + platform + '"]'); + if (platform == 'windows' && !platformTag) { + platformTag = pelem.find('platform[@name="' + 'windows8' + '"]'); + } + var tags = platformTag ? platformTag.findall(tag) : []; + if ( typeof transform === 'function' ) { + tags = tags.map(transform); + } + return tags; +} + +// Check if x is a string 'true'. +function isStrTrue(x) { + return String(x).toLowerCase() == 'true'; +} + +module.exports = PluginInfo; +// Backwards compat: +PluginInfo.PluginInfo = PluginInfo; +PluginInfo.loadPluginsDir = function(dir) { + var PluginInfoProvider = require('./PluginInfoProvider'); + return new PluginInfoProvider().getAllWithinSearchPath(dir); +}; http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f7721b4/node_modules/cordova-common/src/PluginInfo/PluginInfoProvider.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/src/PluginInfo/PluginInfoProvider.js b/node_modules/cordova-common/src/PluginInfo/PluginInfoProvider.js index 8b04377..6240119 100644 --- a/node_modules/cordova-common/src/PluginInfo/PluginInfoProvider.js +++ b/node_modules/cordova-common/src/PluginInfo/PluginInfoProvider.js @@ -1,82 +1,82 @@ -/** - 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 sub:true, laxcomma:true, laxbreak:true */ - -var fs = require('fs'); -var path = require('path'); -var PluginInfo = require('./PluginInfo'); -var events = require('../events'); - -function PluginInfoProvider() { - this._cache = {}; - this._getAllCache = {}; -} - -PluginInfoProvider.prototype.get = function(dirName) { - var absPath = path.resolve(dirName); - if (!this._cache[absPath]) { - this._cache[absPath] = new PluginInfo(dirName); - } - return this._cache[absPath]; -}; - -// Normally you don't need to put() entries, but it's used -// when copying plugins, and in unit tests. -PluginInfoProvider.prototype.put = function(pluginInfo) { - var absPath = path.resolve(pluginInfo.dir); - this._cache[absPath] = pluginInfo; -}; - -// Used for plugin search path processing. -// Given a dir containing multiple plugins, create a PluginInfo object for -// each of them and return as array. -// Should load them all in parallel and return a promise, but not yet. -PluginInfoProvider.prototype.getAllWithinSearchPath = function(dirName) { - var absPath = path.resolve(dirName); - if (!this._getAllCache[absPath]) { - this._getAllCache[absPath] = getAllHelper(absPath, this); - } - return this._getAllCache[absPath]; -}; - -function getAllHelper(absPath, provider) { - if (!fs.existsSync(absPath)){ - return []; - } - // If dir itself is a plugin, return it in an array with one element. - if (fs.existsSync(path.join(absPath, 'plugin.xml'))) { - return [provider.get(absPath)]; - } - var subdirs = fs.readdirSync(absPath); - var plugins = []; - subdirs.forEach(function(subdir) { - var d = path.join(absPath, subdir); - if (fs.existsSync(path.join(d, 'plugin.xml'))) { - try { - plugins.push(provider.get(d)); - } catch (e) { - events.emit('warn', 'Error parsing ' + path.join(d, 'plugin.xml.\n' + e.stack)); - } - } - }); - return plugins; -} - -module.exports = PluginInfoProvider; +/** + 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 sub:true, laxcomma:true, laxbreak:true */ + +var fs = require('fs'); +var path = require('path'); +var PluginInfo = require('./PluginInfo'); +var events = require('../events'); + +function PluginInfoProvider() { + this._cache = {}; + this._getAllCache = {}; +} + +PluginInfoProvider.prototype.get = function(dirName) { + var absPath = path.resolve(dirName); + if (!this._cache[absPath]) { + this._cache[absPath] = new PluginInfo(dirName); + } + return this._cache[absPath]; +}; + +// Normally you don't need to put() entries, but it's used +// when copying plugins, and in unit tests. +PluginInfoProvider.prototype.put = function(pluginInfo) { + var absPath = path.resolve(pluginInfo.dir); + this._cache[absPath] = pluginInfo; +}; + +// Used for plugin search path processing. +// Given a dir containing multiple plugins, create a PluginInfo object for +// each of them and return as array. +// Should load them all in parallel and return a promise, but not yet. +PluginInfoProvider.prototype.getAllWithinSearchPath = function(dirName) { + var absPath = path.resolve(dirName); + if (!this._getAllCache[absPath]) { + this._getAllCache[absPath] = getAllHelper(absPath, this); + } + return this._getAllCache[absPath]; +}; + +function getAllHelper(absPath, provider) { + if (!fs.existsSync(absPath)){ + return []; + } + // If dir itself is a plugin, return it in an array with one element. + if (fs.existsSync(path.join(absPath, 'plugin.xml'))) { + return [provider.get(absPath)]; + } + var subdirs = fs.readdirSync(absPath); + var plugins = []; + subdirs.forEach(function(subdir) { + var d = path.join(absPath, subdir); + if (fs.existsSync(path.join(d, 'plugin.xml'))) { + try { + plugins.push(provider.get(d)); + } catch (e) { + events.emit('warn', 'Error parsing ' + path.join(d, 'plugin.xml.\n' + e.stack)); + } + } + }); + return plugins; +} + +module.exports = PluginInfoProvider; http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f7721b4/node_modules/cordova-common/src/events.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/src/events.js b/node_modules/cordova-common/src/events.js index 4f6ccf6..a6ec340 100644 --- a/node_modules/cordova-common/src/events.js +++ b/node_modules/cordova-common/src/events.js @@ -1,19 +1,19 @@ -/** - 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. -*/ -module.exports = new (require('events').EventEmitter)(); +/** + 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. +*/ +module.exports = new (require('events').EventEmitter)(); http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f7721b4/node_modules/cordova-common/src/superspawn.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/src/superspawn.js b/node_modules/cordova-common/src/superspawn.js index 0d8eaa1..b4129ec 100644 --- a/node_modules/cordova-common/src/superspawn.js +++ b/node_modules/cordova-common/src/superspawn.js @@ -1,154 +1,154 @@ -/** - 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 child_process = require('child_process'); -var fs = require('fs'); -var path = require('path'); -var _ = require('underscore'); -var Q = require('q'); -var shell = require('shelljs'); -var events = require('./events'); -var iswin32 = process.platform == 'win32'; - -// On Windows, spawn() for batch files requires absolute path & having the extension. -function resolveWindowsExe(cmd) { - var winExtensions = ['.exe', '.cmd', '.bat', '.js', '.vbs']; - function isValidExe(c) { - return winExtensions.indexOf(path.extname(c)) !== -1 && fs.existsSync(c); - } - if (isValidExe(cmd)) { - return cmd; - } - cmd = shell.which(cmd) || cmd; - if (!isValidExe(cmd)) { - winExtensions.some(function(ext) { - if (fs.existsSync(cmd + ext)) { - cmd = cmd + ext; - return true; - } - }); - } - return cmd; -} - -function maybeQuote(a) { - if (/^[^"].*[ &].*[^"]/.test(a)) return '"' + a + '"'; - return a; -} - -// opts: -// printCommand: Whether to log the command (default: false) -// stdio: 'default' is to capture output and returning it as a string to success (same as exec) -// 'ignore' means don't bother capturing it -// 'inherit' means pipe the input & output. This is required for anything that prompts. -// env: Map of extra environment variables. -// cwd: Working directory for the command. -// chmod: If truthy, will attempt to set the execute bit before executing on non-Windows platforms. -// Returns a promise that succeeds only for return code = 0. -exports.spawn = function(cmd, args, opts) { - args = args || []; - opts = opts || {}; - var spawnOpts = {}; - var d = Q.defer(); - - if (iswin32) { - cmd = resolveWindowsExe(cmd); - // If we couldn't find the file, likely we'll end up failing, - // but for things like "del", cmd will do the trick. - if (path.extname(cmd) != '.exe') { - var cmdArgs = '"' + [cmd].concat(args).map(maybeQuote).join(' ') + '"'; - // We need to use /s to ensure that spaces are parsed properly with cmd spawned content - args = [['/s', '/c', cmdArgs].join(' ')]; - cmd = 'cmd'; - spawnOpts.windowsVerbatimArguments = true; - } else if (!fs.existsSync(cmd)) { - // We need to use /s to ensure that spaces are parsed properly with cmd spawned content - args = ['/s', '/c', cmd].concat(args).map(maybeQuote); - } - } - - if (opts.stdio == 'ignore') { - spawnOpts.stdio = 'ignore'; - } else if (opts.stdio == 'inherit') { - spawnOpts.stdio = 'inherit'; - } - if (opts.cwd) { - spawnOpts.cwd = opts.cwd; - } - if (opts.env) { - spawnOpts.env = _.extend(_.extend({}, process.env), opts.env); - } - if (opts.chmod && !iswin32) { - try { - // This fails when module is installed in a system directory (e.g. via sudo npm install) - fs.chmodSync(cmd, '755'); - } catch (e) { - // If the perms weren't set right, then this will come as an error upon execution. - } - } - - events.emit(opts.printCommand ? 'log' : 'verbose', 'Running command: ' + maybeQuote(cmd) + ' ' + args.map(maybeQuote).join(' ')); - - var child = child_process.spawn(cmd, args, spawnOpts); - var capturedOut = ''; - var capturedErr = ''; - - if (child.stdout) { - child.stdout.setEncoding('utf8'); - child.stdout.on('data', function(data) { - capturedOut += data; - }); - - child.stderr.setEncoding('utf8'); - child.stderr.on('data', function(data) { - capturedErr += data; - }); - } - - child.on('close', whenDone); - child.on('error', whenDone); - function whenDone(arg) { - child.removeListener('close', whenDone); - child.removeListener('error', whenDone); - var code = typeof arg == 'number' ? arg : arg && arg.code; - - events.emit('verbose', 'Command finished with error code ' + code + ': ' + cmd + ' ' + args); - if (code === 0) { - d.resolve(capturedOut.trim()); - } else { - var errMsg = cmd + ': Command failed with exit code ' + code; - if (capturedErr) { - errMsg += ' Error output:\n' + capturedErr.trim(); - } - var err = new Error(errMsg); - err.code = code; - d.reject(err); - } - } - - return d.promise; -}; - -exports.maybeSpawn = function(cmd, args, opts) { - if (fs.existsSync(cmd)) { - return exports.spawn(cmd, args, opts); - } - return Q(null); -}; - +/** + 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 child_process = require('child_process'); +var fs = require('fs'); +var path = require('path'); +var _ = require('underscore'); +var Q = require('q'); +var shell = require('shelljs'); +var events = require('./events'); +var iswin32 = process.platform == 'win32'; + +// On Windows, spawn() for batch files requires absolute path & having the extension. +function resolveWindowsExe(cmd) { + var winExtensions = ['.exe', '.cmd', '.bat', '.js', '.vbs']; + function isValidExe(c) { + return winExtensions.indexOf(path.extname(c)) !== -1 && fs.existsSync(c); + } + if (isValidExe(cmd)) { + return cmd; + } + cmd = shell.which(cmd) || cmd; + if (!isValidExe(cmd)) { + winExtensions.some(function(ext) { + if (fs.existsSync(cmd + ext)) { + cmd = cmd + ext; + return true; + } + }); + } + return cmd; +} + +function maybeQuote(a) { + if (/^[^"].*[ &].*[^"]/.test(a)) return '"' + a + '"'; + return a; +} + +// opts: +// printCommand: Whether to log the command (default: false) +// stdio: 'default' is to capture output and returning it as a string to success (same as exec) +// 'ignore' means don't bother capturing it +// 'inherit' means pipe the input & output. This is required for anything that prompts. +// env: Map of extra environment variables. +// cwd: Working directory for the command. +// chmod: If truthy, will attempt to set the execute bit before executing on non-Windows platforms. +// Returns a promise that succeeds only for return code = 0. +exports.spawn = function(cmd, args, opts) { + args = args || []; + opts = opts || {}; + var spawnOpts = {}; + var d = Q.defer(); + + if (iswin32) { + cmd = resolveWindowsExe(cmd); + // If we couldn't find the file, likely we'll end up failing, + // but for things like "del", cmd will do the trick. + if (path.extname(cmd) != '.exe') { + var cmdArgs = '"' + [cmd].concat(args).map(maybeQuote).join(' ') + '"'; + // We need to use /s to ensure that spaces are parsed properly with cmd spawned content + args = [['/s', '/c', cmdArgs].join(' ')]; + cmd = 'cmd'; + spawnOpts.windowsVerbatimArguments = true; + } else if (!fs.existsSync(cmd)) { + // We need to use /s to ensure that spaces are parsed properly with cmd spawned content + args = ['/s', '/c', cmd].concat(args).map(maybeQuote); + } + } + + if (opts.stdio == 'ignore') { + spawnOpts.stdio = 'ignore'; + } else if (opts.stdio == 'inherit') { + spawnOpts.stdio = 'inherit'; + } + if (opts.cwd) { + spawnOpts.cwd = opts.cwd; + } + if (opts.env) { + spawnOpts.env = _.extend(_.extend({}, process.env), opts.env); + } + if (opts.chmod && !iswin32) { + try { + // This fails when module is installed in a system directory (e.g. via sudo npm install) + fs.chmodSync(cmd, '755'); + } catch (e) { + // If the perms weren't set right, then this will come as an error upon execution. + } + } + + events.emit(opts.printCommand ? 'log' : 'verbose', 'Running command: ' + maybeQuote(cmd) + ' ' + args.map(maybeQuote).join(' ')); + + var child = child_process.spawn(cmd, args, spawnOpts); + var capturedOut = ''; + var capturedErr = ''; + + if (child.stdout) { + child.stdout.setEncoding('utf8'); + child.stdout.on('data', function(data) { + capturedOut += data; + }); + + child.stderr.setEncoding('utf8'); + child.stderr.on('data', function(data) { + capturedErr += data; + }); + } + + child.on('close', whenDone); + child.on('error', whenDone); + function whenDone(arg) { + child.removeListener('close', whenDone); + child.removeListener('error', whenDone); + var code = typeof arg == 'number' ? arg : arg && arg.code; + + events.emit('verbose', 'Command finished with error code ' + code + ': ' + cmd + ' ' + args); + if (code === 0) { + d.resolve(capturedOut.trim()); + } else { + var errMsg = cmd + ': Command failed with exit code ' + code; + if (capturedErr) { + errMsg += ' Error output:\n' + capturedErr.trim(); + } + var err = new Error(errMsg); + err.code = code; + d.reject(err); + } + } + + return d.promise; +}; + +exports.maybeSpawn = function(cmd, args, opts) { + if (fs.existsSync(cmd)) { + return exports.spawn(cmd, args, opts); + } + return Q(null); +}; + http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f7721b4/node_modules/cordova-common/src/util/plist-helpers.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/src/util/plist-helpers.js b/node_modules/cordova-common/src/util/plist-helpers.js index 1230c67..9dee5c6 100644 --- a/node_modules/cordova-common/src/util/plist-helpers.js +++ b/node_modules/cordova-common/src/util/plist-helpers.js @@ -1,101 +1,101 @@ -/* - * - * Copyright 2013 Brett Rudd - * - * 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. - * -*/ - -// contains PLIST utility functions -var __ = require('underscore'); -var plist = require('plist'); - -// adds node to doc at selector -module.exports.graftPLIST = graftPLIST; -function graftPLIST(doc, xml, selector) { - var obj = plist.parse(''+xml+''); - - var node = doc[selector]; - if (node && Array.isArray(node) && Array.isArray(obj)){ - node = node.concat(obj); - for (var i =0;i. If we have two dicts we merge them instead of - // overriding the old one. See CB-6472 - if (node && __.isObject(node) && __.isObject(obj) && !__.isDate(node) && !__.isDate(obj)){//arrays checked above - __.extend(obj,node); - } - doc[selector] = obj; - } - - return true; -} - -// removes node from doc at selector -module.exports.prunePLIST = prunePLIST; -function prunePLIST(doc, xml, selector) { - var obj = plist.parse(''+xml+''); - - pruneOBJECT(doc, selector, obj); - - return true; -} - -function pruneOBJECT(doc, selector, fragment) { - if (Array.isArray(fragment) && Array.isArray(doc[selector])) { - var empty = true; - for (var i in fragment) { - for (var j in doc[selector]) { - empty = pruneOBJECT(doc[selector], j, fragment[i]) && empty; - } - } - if (empty) - { - delete doc[selector]; - return true; - } - } - else if (nodeEqual(doc[selector], fragment)) { - delete doc[selector]; - return true; - } - - return false; -} - -function nodeEqual(node1, node2) { - if (typeof node1 != typeof node2) - return false; - else if (typeof node1 == 'string') { - node2 = escapeRE(node2).replace(new RegExp('\\$[a-zA-Z0-9-_]+','gm'),'(.*?)'); - return new RegExp('^' + node2 + '$').test(node1); - } - else { - for (var key in node2) { - if (!nodeEqual(node1[key], node2[key])) return false; - } - return true; - } -} - -// escape string for use in regex -function escapeRE(str) { - return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '$&'); -} +/* + * + * Copyright 2013 Brett Rudd + * + * 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. + * +*/ + +// contains PLIST utility functions +var __ = require('underscore'); +var plist = require('plist'); + +// adds node to doc at selector +module.exports.graftPLIST = graftPLIST; +function graftPLIST(doc, xml, selector) { + var obj = plist.parse(''+xml+''); + + var node = doc[selector]; + if (node && Array.isArray(node) && Array.isArray(obj)){ + node = node.concat(obj); + for (var i =0;i. If we have two dicts we merge them instead of + // overriding the old one. See CB-6472 + if (node && __.isObject(node) && __.isObject(obj) && !__.isDate(node) && !__.isDate(obj)){//arrays checked above + __.extend(obj,node); + } + doc[selector] = obj; + } + + return true; +} + +// removes node from doc at selector +module.exports.prunePLIST = prunePLIST; +function prunePLIST(doc, xml, selector) { + var obj = plist.parse(''+xml+''); + + pruneOBJECT(doc, selector, obj); + + return true; +} + +function pruneOBJECT(doc, selector, fragment) { + if (Array.isArray(fragment) && Array.isArray(doc[selector])) { + var empty = true; + for (var i in fragment) { + for (var j in doc[selector]) { + empty = pruneOBJECT(doc[selector], j, fragment[i]) && empty; + } + } + if (empty) + { + delete doc[selector]; + return true; + } + } + else if (nodeEqual(doc[selector], fragment)) { + delete doc[selector]; + return true; + } + + return false; +} + +function nodeEqual(node1, node2) { + if (typeof node1 != typeof node2) + return false; + else if (typeof node1 == 'string') { + node2 = escapeRE(node2).replace(new RegExp('\\$[a-zA-Z0-9-_]+','gm'),'(.*?)'); + return new RegExp('^' + node2 + '$').test(node1); + } + else { + for (var key in node2) { + if (!nodeEqual(node1[key], node2[key])) return false; + } + return true; + } +} + +// escape string for use in regex +function escapeRE(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '$&'); +} http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f7721b4/node_modules/cordova-common/src/util/xml-helpers.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/src/util/xml-helpers.js b/node_modules/cordova-common/src/util/xml-helpers.js index 90cb9b8..8b02989 100644 --- a/node_modules/cordova-common/src/util/xml-helpers.js +++ b/node_modules/cordova-common/src/util/xml-helpers.js @@ -1,266 +1,266 @@ -/* - * - * Copyright 2013 Anis Kadri - * - * 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 sub:true, laxcomma:true */ - -/** - * contains XML utility functions, some of which are specific to elementtree - */ - -var fs = require('fs') - , path = require('path') - , _ = require('underscore') - , et = require('elementtree') - ; - -module.exports = { - // compare two et.XML nodes, see if they match - // compares tagName, text, attributes and children (recursively) - equalNodes: function(one, two) { - if (one.tag != two.tag) { - return false; - } else if (one.text.trim() != two.text.trim()) { - return false; - } else if (one._children.length != two._children.length) { - return false; - } - - var oneAttribKeys = Object.keys(one.attrib), - twoAttribKeys = Object.keys(two.attrib), - i = 0, attribName; - - if (oneAttribKeys.length != twoAttribKeys.length) { - return false; - } - - for (i; i < oneAttribKeys.length; i++) { - attribName = oneAttribKeys[i]; - - if (one.attrib[attribName] != two.attrib[attribName]) { - return false; - } - } - - for (i; i < one._children.length; i++) { - if (!module.exports.equalNodes(one._children[i], two._children[i])) { - return false; - } - } - - return true; - }, - - // adds node to doc at selector, creating parent if it doesn't exist - graftXML: function(doc, nodes, selector, after) { - var parent = resolveParent(doc, selector); - if (!parent) { - //Try to create the parent recursively if necessary - try { - var parentToCreate = et.XML('<' + path.basename(selector) + '>'), - parentSelector = path.dirname(selector); - - this.graftXML(doc, [parentToCreate], parentSelector); - } catch (e) { - return false; - } - parent = resolveParent(doc, selector); - if (!parent) return false; - } - - nodes.forEach(function (node) { - // check if child is unique first - if (uniqueChild(node, parent)) { - var children = parent.getchildren(); - var insertIdx = after ? findInsertIdx(children, after) : children.length; - - //TODO: replace with parent.insert after the bug in ElementTree is fixed - parent.getchildren().splice(insertIdx, 0, node); - } - }); - - return true; - }, - - // removes node from doc at selector - pruneXML: function(doc, nodes, selector) { - var parent = resolveParent(doc, selector); - if (!parent) return false; - - nodes.forEach(function (node) { - var matchingKid = null; - if ((matchingKid = findChild(node, parent)) !== null) { - // stupid elementtree takes an index argument it doesn't use - // and does not conform to the python lib - parent.remove(matchingKid); - } - }); - - return true; - }, - - parseElementtreeSync: function (filename) { - var contents = fs.readFileSync(filename, 'utf-8'); - if(contents) { - //Windows is the BOM. Skip the Byte Order Mark. - contents = contents.substring(contents.indexOf('<')); - } - return new et.ElementTree(et.XML(contents)); - } -}; - -function findChild(node, parent) { - var matchingKids = parent.findall(node.tag) - , i, j; - - for (i = 0, j = matchingKids.length ; i < j ; i++) { - if (module.exports.equalNodes(node, matchingKids[i])) { - return matchingKids[i]; - } - } - return null; -} - -function uniqueChild(node, parent) { - var matchingKids = parent.findall(node.tag) - , i = 0; - - if (matchingKids.length === 0) { - return true; - } else { - for (i; i < matchingKids.length; i++) { - if (module.exports.equalNodes(node, matchingKids[i])) { - return false; - } - } - return true; - } -} - -var ROOT = /^\/([^\/]*)/, - ABSOLUTE = /^\/([^\/]*)\/(.*)/; - -function resolveParent(doc, selector) { - var parent, tagName, subSelector; - - // handle absolute selector (which elementtree doesn't like) - if (ROOT.test(selector)) { - tagName = selector.match(ROOT)[1]; - // test for wildcard "any-tag" root selector - if (tagName == '*' || tagName === doc._root.tag) { - parent = doc._root; - - // could be an absolute path, but not selecting the root - if (ABSOLUTE.test(selector)) { - subSelector = selector.match(ABSOLUTE)[2]; - parent = parent.find(subSelector); - } - } else { - return false; - } - } else { - parent = doc.find(selector); - } - return parent; -} - -// Find the index at which to insert an entry. After is a ;-separated priority list -// of tags after which the insertion should be made. E.g. If we need to -// insert an element C, and the rule is that the order of children has to be -// As, Bs, Cs. After will be equal to "C;B;A". -function findInsertIdx(children, after) { - var childrenTags = children.map(function(child) { return child.tag; }); - var afters = after.split(';'); - var afterIndexes = afters.map(function(current) { return childrenTags.lastIndexOf(current); }); - var foundIndex = _.find(afterIndexes, function(index) { return index != -1; }); - - //add to the beginning if no matching nodes are found - return typeof foundIndex === 'undefined' ? 0 : foundIndex+1; -} - -var BLACKLIST = ['platform', 'feature','plugin','engine']; -var SINGLETONS = ['content', 'author']; -function mergeXml(src, dest, platform, clobber) { - // Do nothing for blacklisted tags. - if (BLACKLIST.indexOf(src.tag) != -1) return; - - //Handle attributes - Object.getOwnPropertyNames(src.attrib).forEach(function (attribute) { - if (clobber || !dest.attrib[attribute]) { - dest.attrib[attribute] = src.attrib[attribute]; - } - }); - //Handle text - if (src.text && (clobber || !dest.text)) { - dest.text = src.text; - } - //Handle platform - if (platform) { - src.findall('platform[@name="' + platform + '"]').forEach(function (platformElement) { - platformElement.getchildren().forEach(mergeChild); - }); - } - - //Handle children - src.getchildren().forEach(mergeChild); - - function mergeChild (srcChild) { - var srcTag = srcChild.tag, - destChild = new et.Element(srcTag), - foundChild, - query = srcTag + '', - shouldMerge = true; - - if (BLACKLIST.indexOf(srcTag) === -1) { - if (SINGLETONS.indexOf(srcTag) !== -1) { - foundChild = dest.find(query); - if (foundChild) { - destChild = foundChild; - dest.remove(destChild); - } - } else { - //Check for an exact match and if you find one don't add - Object.getOwnPropertyNames(srcChild.attrib).forEach(function (attribute) { - query += '[@' + attribute + '="' + srcChild.attrib[attribute] + '"]'; - }); - var foundChildren = dest.findall(query); - for(var i = 0; i < foundChildren.length; i++) { - foundChild = foundChildren[i]; - if (foundChild && textMatch(srcChild, foundChild) && (Object.keys(srcChild.attrib).length==Object.keys(foundChild.attrib).length)) { - destChild = foundChild; - dest.remove(destChild); - shouldMerge = false; - break; - } - } - } - - mergeXml(srcChild, destChild, platform, clobber && shouldMerge); - dest.append(destChild); - } - } -} - -// Expose for testing. -module.exports.mergeXml = mergeXml; - -function textMatch(elm1, elm2) { - var text1 = elm1.text ? elm1.text.replace(/\s+/, '') : '', - text2 = elm2.text ? elm2.text.replace(/\s+/, '') : ''; - return (text1 === '' || text1 === text2); -} +/* + * + * Copyright 2013 Anis Kadri + * + * 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 sub:true, laxcomma:true */ + +/** + * contains XML utility functions, some of which are specific to elementtree + */ + +var fs = require('fs') + , path = require('path') + , _ = require('underscore') + , et = require('elementtree') + ; + +module.exports = { + // compare two et.XML nodes, see if they match + // compares tagName, text, attributes and children (recursively) + equalNodes: function(one, two) { + if (one.tag != two.tag) { + return false; + } else if (one.text.trim() != two.text.trim()) { + return false; + } else if (one._children.length != two._children.length) { + return false; + } + + var oneAttribKeys = Object.keys(one.attrib), + twoAttribKeys = Object.keys(two.attrib), + i = 0, attribName; + + if (oneAttribKeys.length != twoAttribKeys.length) { + return false; + } + + for (i; i < oneAttribKeys.length; i++) { + attribName = oneAttribKeys[i]; + + if (one.attrib[attribName] != two.attrib[attribName]) { + return false; + } + } + + for (i; i < one._children.length; i++) { + if (!module.exports.equalNodes(one._children[i], two._children[i])) { + return false; + } + } + + return true; + }, + + // adds node to doc at selector, creating parent if it doesn't exist + graftXML: function(doc, nodes, selector, after) { + var parent = resolveParent(doc, selector); + if (!parent) { + //Try to create the parent recursively if necessary + try { + var parentToCreate = et.XML('<' + path.basename(selector) + '>'), + parentSelector = path.dirname(selector); + + this.graftXML(doc, [parentToCreate], parentSelector); + } catch (e) { + return false; + } + parent = resolveParent(doc, selector); + if (!parent) return false; + } + + nodes.forEach(function (node) { + // check if child is unique first + if (uniqueChild(node, parent)) { + var children = parent.getchildren(); + var insertIdx = after ? findInsertIdx(children, after) : children.length; + + //TODO: replace with parent.insert after the bug in ElementTree is fixed + parent.getchildren().splice(insertIdx, 0, node); + } + }); + + return true; + }, + + // removes node from doc at selector + pruneXML: function(doc, nodes, selector) { + var parent = resolveParent(doc, selector); + if (!parent) return false; + + nodes.forEach(function (node) { + var matchingKid = null; + if ((matchingKid = findChild(node, parent)) !== null) { + // stupid elementtree takes an index argument it doesn't use + // and does not conform to the python lib + parent.remove(matchingKid); + } + }); + + return true; + }, + + parseElementtreeSync: function (filename) { + var contents = fs.readFileSync(filename, 'utf-8'); + if(contents) { + //Windows is the BOM. Skip the Byte Order Mark. + contents = contents.substring(contents.indexOf('<')); + } + return new et.ElementTree(et.XML(contents)); + } +}; + +function findChild(node, parent) { + var matchingKids = parent.findall(node.tag) + , i, j; + + for (i = 0, j = matchingKids.length ; i < j ; i++) { + if (module.exports.equalNodes(node, matchingKids[i])) { + return matchingKids[i]; + } + } + return null; +} + +function uniqueChild(node, parent) { + var matchingKids = parent.findall(node.tag) + , i = 0; + + if (matchingKids.length === 0) { + return true; + } else { + for (i; i < matchingKids.length; i++) { + if (module.exports.equalNodes(node, matchingKids[i])) { + return false; + } + } + return true; + } +} + +var ROOT = /^\/([^\/]*)/, + ABSOLUTE = /^\/([^\/]*)\/(.*)/; + +function resolveParent(doc, selector) { + var parent, tagName, subSelector; + + // handle absolute selector (which elementtree doesn't like) + if (ROOT.test(selector)) { + tagName = selector.match(ROOT)[1]; + // test for wildcard "any-tag" root selector + if (tagName == '*' || tagName === doc._root.tag) { + parent = doc._root; + + // could be an absolute path, but not selecting the root + if (ABSOLUTE.test(selector)) { + subSelector = selector.match(ABSOLUTE)[2]; + parent = parent.find(subSelector); + } + } else { + return false; + } + } else { + parent = doc.find(selector); + } + return parent; +} + +// Find the index at which to insert an entry. After is a ;-separated priority list +// of tags after which the insertion should be made. E.g. If we need to +// insert an element C, and the rule is that the order of children has to be +// As, Bs, Cs. After will be equal to "C;B;A". +function findInsertIdx(children, after) { + var childrenTags = children.map(function(child) { return child.tag; }); + var afters = after.split(';'); + var afterIndexes = afters.map(function(current) { return childrenTags.lastIndexOf(current); }); + var foundIndex = _.find(afterIndexes, function(index) { return index != -1; }); + + //add to the beginning if no matching nodes are found + return typeof foundIndex === 'undefined' ? 0 : foundIndex+1; +} + +var BLACKLIST = ['platform', 'feature','plugin','engine']; +var SINGLETONS = ['content', 'author']; +function mergeXml(src, dest, platform, clobber) { + // Do nothing for blacklisted tags. + if (BLACKLIST.indexOf(src.tag) != -1) return; + + //Handle attributes + Object.getOwnPropertyNames(src.attrib).forEach(function (attribute) { + if (clobber || !dest.attrib[attribute]) { + dest.attrib[attribute] = src.attrib[attribute]; + } + }); + //Handle text + if (src.text && (clobber || !dest.text)) { + dest.text = src.text; + } + //Handle platform + if (platform) { + src.findall('platform[@name="' + platform + '"]').forEach(function (platformElement) { + platformElement.getchildren().forEach(mergeChild); + }); + } + + //Handle children + src.getchildren().forEach(mergeChild); + + function mergeChild (srcChild) { + var srcTag = srcChild.tag, + destChild = new et.Element(srcTag), + foundChild, + query = srcTag + '', + shouldMerge = true; + + if (BLACKLIST.indexOf(srcTag) === -1) { + if (SINGLETONS.indexOf(srcTag) !== -1) { + foundChild = dest.find(query); + if (foundChild) { + destChild = foundChild; + dest.remove(destChild); + } + } else { + //Check for an exact match and if you find one don't add + Object.getOwnPropertyNames(srcChild.attrib).forEach(function (attribute) { + query += '[@' + attribute + '="' + srcChild.attrib[attribute] + '"]'; + }); + var foundChildren = dest.findall(query); + for(var i = 0; i < foundChildren.length; i++) { + foundChild = foundChildren[i]; + if (foundChild && textMatch(srcChild, foundChild) && (Object.keys(srcChild.attrib).length==Object.keys(foundChild.attrib).length)) { + destChild = foundChild; + dest.remove(destChild); + shouldMerge = false; + break; + } + } + } + + mergeXml(srcChild, destChild, platform, clobber && shouldMerge); + dest.append(destChild); + } + } +} + +// Expose for testing. +module.exports.mergeXml = mergeXml; + +function textMatch(elm1, elm2) { + var text1 = elm1.text ? elm1.text.replace(/\s+/, '') : '', + text2 = elm2.text ? elm2.text.replace(/\s+/, '') : ''; + return (text1 === '' || text1 === text2); +} http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f7721b4/node_modules/nopt/bin/nopt.js ---------------------------------------------------------------------- diff --git a/node_modules/nopt/bin/nopt.js b/node_modules/nopt/bin/nopt.js old mode 100644 new mode 100755 http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f7721b4/node_modules/shelljs/bin/shjs ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/bin/shjs b/node_modules/shelljs/bin/shjs old mode 100644 new mode 100755 http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f7721b4/package.json ---------------------------------------------------------------------- diff --git a/package.json b/package.json index 38671ce..7c24643 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,9 @@ "jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint spec" }, "author": "Apache Software Foundation", - "license": "Apache version 2.0", + "license": "Apache-2.0", "dependencies": { - "cordova-common": "^0.1.0", + "cordova-common": "~1.0.0", "elementtree": "^0.1.6", "nopt": "^3.0.1", "properties-parser": "^0.2.3", --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org