[ 
https://issues.apache.org/jira/browse/CB-6469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13973459#comment-13973459
 ] 

ASF GitHub Bot commented on CB-6469:
------------------------------------

Github user kamrik commented on a diff in the pull request:

    https://github.com/apache/cordova-cli/pull/165#discussion_r11755812
  
    --- Diff: src/save.js ---
    @@ -0,0 +1,71 @@
    +/**
    +    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 cordova_util     = require('./util'),
    +    ConfigParser     = require('./ConfigParser'),
    +    path             = require('path'),
    +    xml              =require('./xml-helpers')
    +    Q                = require('q'),
    +    events           = require('./events');
    +
    +;
    +
    +
    +module.exports = function save(target){
    +  var projectHome = cordova_util.cdProjectRoot();
    +  var configPath = cordova_util.projectConfig(projectHome);
    +  var configXml = new ConfigParser(configPath);
    +  var pluginsPath = path.join(projectHome, 'plugins');
    +  var plugins = cordova_util.findPlugins(pluginsPath);
    +
    +  return Q.all(plugins.map(function(plugin){
    +    var currentPluginPath = path.join(pluginsPath,plugin);
    +    var name = readPluginName(currentPluginPath);
    +    var id = plugin;
    +    var version = readPluginVersion(currentPluginPath);
    +    var features = configXml.doc.findall('feature');
    +      for(var i=0; i<features.length; i++){
    +        if(features[i].attrib.name === name){
    +          events.emit('results', 'An entry for "'+ plugin+ '" already 
exists');
    +          return Q();
    +        }
    +      }
    +    configXml.addFeature(name, JSON.parse('[{"name":"id", 
"value":"'+id+'"},{"name":"version", "value":"'+version+'"}]'));
    --- End diff --
    
    I might be missing something, but why JSON.parse() rather than just literal 
array of objects?


> Restore plugins from config.xml
> -------------------------------
>
>                 Key: CB-6469
>                 URL: https://issues.apache.org/jira/browse/CB-6469
>             Project: Apache Cordova
>          Issue Type: New Feature
>          Components: CLI
>    Affects Versions: 3.4.0
>            Reporter: Gorkem ERCAN
>            Assignee: Gorkem ERCAN
>
> CLI should be able to restore plugins that are listed on the top level 
> config.xml. 
> Essentially an entry like below, should cause the 
> org.apache.cordova.core.console plugin  version 0.2.8 to be installed from 
> registry. If version is omitted is should just use the latest available from 
> registry. 
> <feature name="Console">
>      <param name="id" value="org.apache.cordova.core.console" />
>     <param name="version" value="0.2.8" />
> </feature>
> Moreover we should add a save plugins command to save the currently installed 
> plugins to config.xml



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to