Bower: `bower version` doesn't update bower.json in 1.8.0

Created on 9 Nov 2016  Â·  5Comments  Â·  Source: bower/bower

Output of bower -v && npm -v && node -v:

bower: 1.8.0
npm: 3.10.7
node: v6.6.0

Additional environment details (proxy, private registry, etc.):

Steps to reproduce the issue:

  1. Be in a repository that is a bower component
  2. Run bower version major/minor/patch

Describe the results you received:
Git tag is updated as expected to correct version

Describe the results you expected:
Git tag is updated.
bower.json is updated

Additional information:
I see that https://github.com/bower/bower/pull/2232 (Make bower version behavior consistent with spec) now calculates version based on git tags to which I have no objection. However, this PR also removed updating the bower.json file. This breaks bower for users not running 1.8.0 since bower.json and git tags will be inconsistent.

From looking at the commit, these two lines should perhaps have been left intact?
https://github.com/bower/bower/pull/2142/commits/3fbca6d271bf503de53921e5342ebc0c8b5b9e62#diff-83bf2b02cc098876be2d25091d8f66cbL33
https://github.com/bower/bower/pull/2142/commits/3fbca6d271bf503de53921e5342ebc0c8b5b9e62#diff-83bf2b02cc098876be2d25091d8f66cbL35
(that is, "old" line 33 and 35 before the commit https://github.com/bower/bower/pull/2142/commits/3fbca6d271bf503de53921e5342ebc0c8b5b9e62)

My suggestion is to still use the git tag for calculating the new version and create a new git tag, but still also update the bower.json file to keep bower non-breaking for pre-1.8.0 users.

Most helpful comment

The idea to remove "version" field from bower.json in favor of git tags is a really good idea. BUT, It should have been released as a Major version because it's a breaking and dangerous change. Or at least you should warn users about the fact that version field is deprecated and the use of "bower version" won't update anything...

All 5 comments

This is correct behavior. Bower completely ignores version in bower.json, even prior 1.8.0

Please remove "version" field from bower.json

Cheers, thanks for clarification.

@sheerun Kept on thinking about this as we use bower quite heavily at work to work with web components shared between different projects.

So, this change means that if user A works on a bower component with version 1.0.0 and, using bower 1.8.0, runs bower version minor and checks it in and publishes, it will publish the component as 1.1.0 and create a git tag, but not update the bower.json file.

Later, person B, using bower 1.7.9 works on the same component and now git tags say latest is 1.1.0 but bower.json says 1.0.0. After working on the component person B runs bower version minor.

→ bower version minor
bower 128           Command failed: git tag v1.1.0 -am v1.1.0 fatal: tag 'v1.1.0' already exists

Seems like this could create some confusion? Perhaps this change should have been put in a major update to bower?

The solution is again to remove version from bower.json, isn't it?

The idea to remove "version" field from bower.json in favor of git tags is a really good idea. BUT, It should have been released as a Major version because it's a breaking and dangerous change. Or at least you should warn users about the fact that version field is deprecated and the use of "bower version" won't update anything...

Was this page helpful?
0 / 5 - 0 ratings