Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C934117727 for ; Tue, 10 Mar 2015 05:11:13 +0000 (UTC) Received: (qmail 44650 invoked by uid 500); 10 Mar 2015 05:11:13 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 44604 invoked by uid 500); 10 Mar 2015 05:11:13 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 44592 invoked by uid 99); 10 Mar 2015 05:11:13 -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; Tue, 10 Mar 2015 05:11:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 070C0E1833; Tue, 10 Mar 2015 05:11:12 +0000 (UTC) From: omefire To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-lib pull request: Deprecate the old feature syntax from co... Content-Type: text/plain Message-Id: <20150310051113.070C0E1833@git1-us-west.apache.org> Date: Tue, 10 Mar 2015 05:11:12 +0000 (UTC) Github user omefire commented on a diff in the pull request: https://github.com/apache/cordova-lib/pull/182#discussion_r26099181 --- Diff: cordova-lib/src/configparser/ConfigParser.js --- @@ -279,113 +269,108 @@ ConfigParser.prototype = { return scriptElements.filter(filterScriptByHookType); }, - + /** + * Returns a list of plugin (IDs) + * @return {string[]} Array of plugin IDs + */ + getPluginIdList: function () { + var plugins = this.doc.findall('plugin'); + var result = plugins.map(function(plugin){ + return plugin.attrib.name; + }); + var features = this.doc.findall('feature'); + features.forEach(function(element ){ + var idTag = element.find('./param[@name="id"]'); + if(idTag){ + result.push(idTag.attrib.value); + } + }); + return result; + }, /** - * Returns a list of features (IDs) - * @return {string[]} Array of feature IDs + * Adds a plugin element. Does not check for duplicates. + * @name addPlugin + * @function + * @param {object} attributes name, version and src are supported + * @param {Array} variables name, value */ - getFeatureIdList: function () { - var features = this.doc.findall('feature'), - feature, idTag, id, - result = []; - - // Check for valid features that have IDs set - for (var i = 0, l = features.length; i < l; ++i) { - feature = features[i]; - idTag = feature.find('./param[@name="id"]'); - if (null === idTag) { - // Invalid feature - continue; - } - id = idTag.attrib.value; - if (!!id) { - // Has id and id is non-empty - result.push(id); - } + addPlugin: function(attributes, variables){ + if ( !attributes && !attributes.name ) return; + var el = new et.Element('plugin'); + el.attrib.name =attributes.name; + if ( attributes.version) { + el.attrib.version =attributes.version; } - - return result; + if ( attributes.src){ + el.attrib.src = attributes.src; + } + if(variables){ + variables.forEach(function(variable){ + var v = new et.Element('variable'); + v.attrib.name=variable.name; + v.attrib.value=variable.value; + el.append(v); + }); + } + this.doc.getroot().append(el); }, - /** - * Gets feature info - * @param {string} id Feature id - * @returns {Feature} Feature object + * Retrives the plugin with the given id or null if not found. + * @name getPlugin + * @function + * @param {String} id + * @returns {object} plugin including any variables */ - getFeature: function(id) { - if (!id) { + getPlugin: function(id){ + if(!id){ return undefined; } - var feature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..'); - if (null === feature) { + var pluginElement = this.doc.find('./plugin/[@name="' + id + '"]'); + if (null === pluginElement) { + var legacyFeature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..'); + if(legacyFeature){ + var events = require('../events'); + events.emit('log', 'Found deprecated feature entry for ' + id +' in config.xml.'); --- End diff -- should this be a warning ? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org For additional commands, e-mail: dev-help@cordova.apache.org