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

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

GitHub user TimBarham opened a pull request:

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

    CB-9559 Adding a plugin with caret in version results in an error

    When Cordova used `npm 1.3.x` internally, we had to process "caret 
versions" since `npm 1.3.x` didn't understand them. As part of that, we'd turn 
the caret version into a fully defined version range, which contained a space, 
and `npm 1.3.x` required that we wrap such a range in quotes.
    
    This logic broke when we upgraded to `npm 2.10.x` - it no longer requires 
the quotes in this scenario, and in fact fails if we include them. However, we 
also no longer need to do this processing (since `npm 2.10.x` understands caret 
versions), so we can just remove that code altogether.

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

    $ git pull https://github.com/MSOpenTech/cordova-lib CB-9559

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

    https://github.com/apache/cordova-lib/pull/291.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 #291
    
----
commit 7db936a9502c2e5de7288e68792e5eba90074a43
Author: Tim Barham <[email protected]>
Date:   2015-08-28T03:39:19Z

    CB-9559 Adding a plugin with caret in version results in an error
    
    When Cordova used npm 1.3.x internally, we had to process "caret versions" 
since npm 1.3.x didn't understand them. As part of that, we'd turn the caret 
version into a fully defined version range, which contained a space, and npm 
1.3.x required that we wrap such a range in quotes.
    
    This logic broke when we upgraded to npm 2.10.x - it no longer requires the 
quotes in this scenario, and in fact fails if we include them. However, we also 
no longer need to do this processing (since npm 2.10.x understands caret 
versions), so we can just remove that code altogether.

----


> Adding a plugin with caret in version results in an error
> ---------------------------------------------------------
>
>                 Key: CB-9559
>                 URL: https://issues.apache.org/jira/browse/CB-9559
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaLib
>    Affects Versions: 5.2.0
>         Environment: OS X 10.10.5 
> cordova-cli 5.2.0
>            Reporter: Shazron Abdullah
>            Assignee: Tim Barham
>            Priority: Critical
>
> *Repro:*
> {code}
> cordova plugin add cordova-plugin-battery-status@^1.0.0
> Fetching plugin "cordova-plugin-battery-status@^1.0.0" via npm
> Failed to fetch plugin cordova-plugin-battery-status@^1.0.0 via registry.
> Probably this is either a connection problem, or plugin spec is incorrect.
> Check your connection and plugin name/version/URL.
> Error: No compatible version found: cordova-plugin-battery-status@'">=1.0.0 
> <2.0.0"'
> Valid install targets:
> ["0.2.1","0.2.3","0.2.4","0.2.5","0.2.6","0.2.7","0.2.9","0.2.10","0.2.11","0.2.12","1.0.0","1.1.0"]
> {code}
> *Expected:*
> The plugin can be installed
> *Actual:*
> The plugin cannot be installed.
> Note in the error log, the version is expanded from:
> {code}
>  @^1.0.0
> {code}
> to:
> {code}
> @">=1.0.0 <2.0.0"
> {code}
> But, it appears the double quotes around the expanded version in the error 
> log are *wrapped with single quotes* now, resulting in the error.
> The version is expanded using this *processPluginVersion* function:
> https://github.com/apache/cordova-lib/blob/3e34b557c8bb6876022f0a4186b81d4ff8e5da75/cordova-lib/src/plugman/registry/registry.js#L282
> From this commit:
> https://github.com/apache/cordova-lib/commit/024b970b26d3d8b7f9a6b2f0eab2325d7716deef
> The fix appears to be not calling the function *processPluginVersion* and 
> passing it to *npm cache add* as is:
> https://github.com/apache/cordova-lib/blob/3e34b557c8bb6876022f0a4186b81d4ff8e5da75/cordova-lib/src/plugman/registry/registry.js#L270
> The purpose of this function is because we are using an older version of npm 
> that may not understand carets. Is this still truly the case? If not, we 
> could get rid of this function -- while still keeping CB-9147 fixed/resolved



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to