phonegap / phonegap-cli

PhoneGap and PhoneGap/Build command-line interface
Apache License 2.0
489 stars 157 forks source link

Versioning & npm #545

Closed MethodGrab closed 8 years ago

MethodGrab commented 8 years ago

Node: 0.12.7 npm: 2.13.0

The problem When installing phonegap-cli from npm with the command npm install -g phonegap, as specified in the docs, a very old version is installed (0.9.4).

This is a problem for many reasons but the first one I encountered was the demo app created with phonegap create ./my-app tried to load the old phonegap.js which didnt exist instead of the newer cordova.js. This meant the demo app didn't work, which was confusing for someone new to phonegap like myself!

The reason npm considers versions with dashes as pre-releases and doesn't install pre-releases unless explicitly requested. The latest version of phonegap-cli on npm is 5.1.1-0.29.0 so by default npm installs the last release considered stable by sever which is 0.9.4

The solution Either adopt semver as your versioning standard if you plan on continuing to use npm to distribute the cli, or update the docs to suggest installing with npm install -g phonegap@latest which will pull the latest "pre-release" build.

/ping: @Annonomus-Penguin, https://github.com/phonegap/phonegap-cli/issues/541 & https://github.com/npm/npm/issues/8672


Update: This seems to be related to https://github.com/npm/npm/issues/8696, if you run npm install -g phonegap on node@0.10.36 / npm@1.4.28 it installs phonegap@5.1.1-0.29.0 as expected.

mathvav commented 8 years ago

Thanks for the @latest trick. They could add that to the documentation, but it seems like NPM automatically adds npm install [package] to the sidebar.

mwbrooks commented 8 years ago

Hi @MethodGrab,

Thanks for the detailed breakdown. We adopted this approach a few years ago in order to describe the version of Cordova used by the PhoneGap CLI, since the two are tightly related. Only recently has it started to breakdown, since npm now respects pre-release versions.

I would prefer to continue to describe the version of Cordova in the PhoneGap CLI version. It makes documentation referring and debugging a lot easier for developers.

I'm thinking of using semver rule #10:

Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Build metadata SHOULD be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85.

In our case, we would publish something like:

phonegap@x.y.z+cordova.X.Y.Z

Do you think this approach would be effective? Do you see any issues with it?

Thanks! Michael

macdonst commented 8 years ago

That looks good to me.

mwbrooks commented 8 years ago

Alright guys, I gave it a try.

The commit 7be2c6d set the version to 5.1.1+cordova.5.1.1. I chose 5.1.1 because it carries on the versioning followed by Apache Cordova.

Upside:

Downside:

mwbrooks commented 8 years ago

I'm going to close this issue, since no one else is reporting the problem.

Thanks again @MethodGrab for catching this and outlining the root problem!

MethodGrab commented 8 years ago

Thanks for fixing this, it now installs the latest version correctly! :+1:

austinarchibald commented 8 years ago

I'm getting error on my mac even with @latest. Cannot get it to install at all. Maybe I'll try the gui which had an update last week.

npm WARN engine xmlbuilder@2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"0.12.4","npm":"3.3.3"})
/usr/local/bin/phonegap -> /usr/local/lib/node_modules/phonegap/bin/phonegap.js

> ws@0.4.31 install /usr/local/lib/node_modules/phonegap/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o

Edit: sudo npm install --verbose -g phonegap@latest worked for me

mwbrooks commented 8 years ago

Hi @austinarchibald,

We're seeing a lot of people having installation issues due to some recent node.js, npm, or nvm changes.

I'm glad to see that the @latest worked for you. I just published another update (5.3.4) that should help resolve some of the deeper issues.

Cheers, Michael

austinarchibald commented 8 years ago

Thanks @mwbrooks.

mwbrooks commented 8 years ago

@austinarchibald glad it helped! I think your question is best asked on the PhoneGap Google Groups since it's quite a common scenario.