csantanapr / grunt-cordovacli

Wraps web app with Cordova CLI using GruntJS
Apache License 2.0
60 stars 31 forks source link

How to specify Cordova version? #4

Closed didlich closed 9 years ago

didlich commented 10 years ago

Hi, I'm using this plugin for some time and it is very useful in automation tasks.

One feature I'm missing is to set a specific cordova version which should be used by the plugin. It's important to assure the version is always the same if the tasks are running by an integration server.

Is there a way to set a specific version of cordova to be used?

didlich commented 10 years ago

it seems there are alredy general solutions for this problem, using google helps often

this is the solution:

create npm-shrinkwrap.json in the same directory as package.json with this content:

{
  "name": "appproject",
  "version": "0.0.0",
  "dependencies": {    
    "grunt-cordovacli": {
      "version": "0.4.0",
      "from": "grunt-cordovacli@0.4.0",
      "dependencies": {
        "cordova": {
          "version": "3.5.0-0.2.4",
          "from": "cordova@>=3.4"
        }
      }
    }
  }
}
csantanapr commented 10 years ago

Thanks @didlich for opening an issue and I'm glad that the plugin is helping you out

The plugin uses npm to handle the dependencies, and I don't want to hardcode a specific version into the the plugin's package.json

Using npm-shrinkwrap.json is consider a best practice when releasing an npm module to production and for testing purposes. People think they control the dependecies in their pacakge.json but don't realize that there is a deeper dependency graph that they don't control and could variable.

The Apache Cordova cli uses npm-shrinkwrap for the cordova cli. You can read more on it here: http://blog.nodejs.org/2012/02/27/managing-node-js-dependencies-with-shrinkwrap/

I will add npm-shrinkwrap info to the README to allow others to know how to close down to a specific version, but I will investigate other ways like using the global cordova vs the one install under the plugin.

thanks again