cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omefire <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: Deprecate the old feature syntax from co...
Date Tue, 10 Mar 2015 05:11:12 GMT
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


Mime
View raw message