You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by audreyso <gi...@git.apache.org> on 2017/07/13 16:00:28 UTC

[GitHub] cordova-lib pull request #574: CB-12838 : prevented sorting and alphabetizin...

GitHub user audreyso opened a pull request:

    https://github.com/apache/cordova-lib/pull/574

    CB-12838 : prevented sorting and alphabetizing platforms and plugins i…

    …n pkgJson and config
    
    <!--
    Please make sure the checklist boxes are all checked before submitting the PR. The checklist
    is intended as a quick reference, for complete details please see our Contributor Guidelines:
    
    http://cordova.apache.org/contribute/contribute_guidelines.html
    
    Thanks!
    -->
    
    ### Platforms affected
    
    
    ### What does this PR do?
    
    Prevents modifying/alphabetizing platforms and plugins in config
    
    ### What testing has been done on this change?
    
    
    ### Checklist
    - [X] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
    - [X] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
    - [X] Added automated test coverage as appropriate for this change.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/audreyso/cordova-lib CB-12838

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-lib/pull/574.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #574
    
----
commit 083deef9ce70afe8455a36f49ddccf0b093558f8
Author: Audrey So <au...@apache.org>
Date:   2017-07-12T00:21:41Z

    CB-12838 : prevented sorting and aphabetizing platforms and plugins in pkgjson and config

----


---
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


[GitHub] cordova-lib pull request #574: CB-12838 : prevented sorting and alphabetizin...

Posted by stevengill <gi...@git.apache.org>.
Github user stevengill commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/574#discussion_r132781446
  
    --- Diff: src/cordova/restore-util.js ---
    @@ -341,19 +340,29 @@ function installPluginsFromConfigXML (args) {
                 fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
             }
         }
    -    // Write config.xml (only if plugins exist in package.json).
    +    // Write to config.xml (only if it is different from package.json in content)
         comboPluginIdArray.forEach(function (plugID) {
    +        var configXMLPlugin = cfg.getPlugin(plugID);
             if (pluginIdConfig.indexOf(plugID) < 0) {
                 pluginIdConfig.push(plugID);
    -        }
    -        cfg.removePlugin(plugID);
    -        if (mergedPluginSpecs[plugID]) {
    +            if (mergedPluginSpecs[plugID]) {
    +                cfg.removePlugin(plugID);
    +                cfg.addPlugin({name: plugID, spec: mergedPluginSpecs[plugID]}, comboObject[plugID]);
    +                modifiedConfigXML = true;
    +            } else {
    +                cfg.removePlugin(plugID);
    +                cfg.addPlugin({name: plugID}, comboObject[plugID]);
    +                modifiedConfigXML = true;
    +            }
    +
    +        // Write only if the plugin variables or specs are different from pkgJson
    +        } else if (((pluginIdConfig.indexOf(plugID) > 0) && (mergedPluginSpecs[plugID]) &&
    +            ((configXMLPlugin.variables !== comboObject[plugID]))) ||
    +            ((mergedPluginSpecs[plugID] !== configXMLPlugin.spec) ||
    --- End diff --
    
    so to confirm, either `((pluginIdConfig.indexOf(plugID) > 0) && (mergedPluginSpecs[plugID]) &&(configXMLPlugin.variables !== comboObject[plugID]))` or `((mergedPluginSpecs[plugID] !== configXMLPlugin.spec) || (configXMLPlugin.variables !== comboObject[plugID]))` need to be true


---
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


[GitHub] cordova-lib issue #574: CB-12838 : prevented sorting and alphabetizing platf...

Posted by audreyso <gi...@git.apache.org>.
Github user audreyso commented on the issue:

    https://github.com/apache/cordova-lib/pull/574
  
    Thanks @stevengill ! I will merge it in today!


---
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


[GitHub] cordova-lib issue #574: CB-12838 : prevented sorting and alphabetizing platf...

Posted by stevengill <gi...@git.apache.org>.
Github user stevengill commented on the issue:

    https://github.com/apache/cordova-lib/pull/574
  
    LGTM


---
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


[GitHub] cordova-lib pull request #574: CB-12838 : prevented sorting and alphabetizin...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cordova-lib/pull/574


---
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


[GitHub] cordova-lib pull request #574: CB-12838 : prevented sorting and alphabetizin...

Posted by audreyso <gi...@git.apache.org>.
Github user audreyso commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/574#discussion_r132795105
  
    --- Diff: src/cordova/restore-util.js ---
    @@ -341,19 +340,29 @@ function installPluginsFromConfigXML (args) {
                 fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
             }
         }
    -    // Write config.xml (only if plugins exist in package.json).
    +    // Write to config.xml (only if it is different from package.json in content)
         comboPluginIdArray.forEach(function (plugID) {
    +        var configXMLPlugin = cfg.getPlugin(plugID);
             if (pluginIdConfig.indexOf(plugID) < 0) {
                 pluginIdConfig.push(plugID);
    -        }
    -        cfg.removePlugin(plugID);
    -        if (mergedPluginSpecs[plugID]) {
    +            if (mergedPluginSpecs[plugID]) {
    +                cfg.removePlugin(plugID);
    +                cfg.addPlugin({name: plugID, spec: mergedPluginSpecs[plugID]}, comboObject[plugID]);
    +                modifiedConfigXML = true;
    +            } else {
    +                cfg.removePlugin(plugID);
    +                cfg.addPlugin({name: plugID}, comboObject[plugID]);
    +                modifiedConfigXML = true;
    +            }
    +
    +        // Write only if the plugin variables or specs are different from pkgJson
    +        } else if (((pluginIdConfig.indexOf(plugID) > 0) && (mergedPluginSpecs[plugID]) &&
    +            ((configXMLPlugin.variables !== comboObject[plugID]))) ||
    +            ((mergedPluginSpecs[plugID] !== configXMLPlugin.spec) ||
    --- End diff --
    
    Yes, exactly! Also rebased and updated based on feedback. Let me know if there's anything else!


---
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


[GitHub] cordova-lib pull request #574: CB-12838 : prevented sorting and alphabetizin...

Posted by stevengill <gi...@git.apache.org>.
Github user stevengill commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/574#discussion_r132780476
  
    --- Diff: src/cordova/restore-util.js ---
    @@ -341,19 +340,29 @@ function installPluginsFromConfigXML (args) {
                 fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
             }
         }
    -    // Write config.xml (only if plugins exist in package.json).
    +    // Write to config.xml (only if it is different from package.json in content)
         comboPluginIdArray.forEach(function (plugID) {
    +        var configXMLPlugin = cfg.getPlugin(plugID);
             if (pluginIdConfig.indexOf(plugID) < 0) {
                 pluginIdConfig.push(plugID);
    -        }
    -        cfg.removePlugin(plugID);
    -        if (mergedPluginSpecs[plugID]) {
    +            if (mergedPluginSpecs[plugID]) {
    +                cfg.removePlugin(plugID);
    +                cfg.addPlugin({name: plugID, spec: mergedPluginSpecs[plugID]}, comboObject[plugID]);
    +                modifiedConfigXML = true;
    +            } else {
    +                cfg.removePlugin(plugID);
    +                cfg.addPlugin({name: plugID}, comboObject[plugID]);
    +                modifiedConfigXML = true;
    +            }
    +
    +        // Write only if the plugin variables or specs are different from pkgJson
    +        } else if (((pluginIdConfig.indexOf(plugID) > 0) && (mergedPluginSpecs[plugID]) &&
    --- End diff --
    
    so this if statement, `(pluginIdConfig.indexOf(plugID) > 0)`, what if `plugID` is in the 0th index? I think you want `>=`


---
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


[GitHub] cordova-lib pull request #574: CB-12838 : prevented sorting and alphabetizin...

Posted by stevengill <gi...@git.apache.org>.
Github user stevengill commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/574#discussion_r132780726
  
    --- Diff: src/cordova/restore-util.js ---
    @@ -341,19 +340,29 @@ function installPluginsFromConfigXML (args) {
                 fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
             }
         }
    -    // Write config.xml (only if plugins exist in package.json).
    +    // Write to config.xml (only if it is different from package.json in content)
         comboPluginIdArray.forEach(function (plugID) {
    +        var configXMLPlugin = cfg.getPlugin(plugID);
             if (pluginIdConfig.indexOf(plugID) < 0) {
                 pluginIdConfig.push(plugID);
    -        }
    -        cfg.removePlugin(plugID);
    -        if (mergedPluginSpecs[plugID]) {
    +            if (mergedPluginSpecs[plugID]) {
    +                cfg.removePlugin(plugID);
    +                cfg.addPlugin({name: plugID, spec: mergedPluginSpecs[plugID]}, comboObject[plugID]);
    +                modifiedConfigXML = true;
    +            } else {
    +                cfg.removePlugin(plugID);
    +                cfg.addPlugin({name: plugID}, comboObject[plugID]);
    +                modifiedConfigXML = true;
    +            }
    +
    +        // Write only if the plugin variables or specs are different from pkgJson
    +        } else if (((pluginIdConfig.indexOf(plugID) > 0) && (mergedPluginSpecs[plugID]) &&
    +            ((configXMLPlugin.variables !== comboObject[plugID]))) ||
    --- End diff --
    
    I think you have an extra bracket around this one


---
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