feat(cli): add `deno bump-version` subcommand
Adds a deno bump-version subcommand similar to npm version
- Ideally,
deno initshould be updated to include a default value for theversionfield indeno.json. - Right now the implementation uses the first
versionfield it finds in eitherdeno.json(c)orpackage.json, but perhaps we would instead prefer to check both files explicitly in case there are discrepancies. - TODO: Implement tests
Closes #30358
Hey @JLCarveth we'll try to give you initial review this week. Is there anything that is blocking you at the moment?
Hey @JLCarveth we'll try to give you initial review this week. Is there anything that is blocking you at the moment?
Should I look into setting a default value for the version field in deno init?
@JLCarveth I'm not sure - deno init --lib already creates a structure with deno.json that has a version set - I think we're covered here.
@JLCarveth we just discussed this during the CLI meeting - overall this looks good, but we have a couple comments:
- we're not sure about the name of the subcommand - we might want to use a verb here, like
deno increase-versionordeno bump-version - the Git integration seems extracurricular and maybe could be skipped (unless there's a strong prior art that it should be there?)
The Git integration was based on the npm behaviour: https://docs.npmjs.com/cli/v8/commands/npm-version#git-tag-version
If the team would prefer a simpler integration it could be removed
After thinking on it further, I agree that the git integration is not necessary. Adds more maintenance burden when a simple bash function can handle the git stuff. I'll remove that tomorrow
@JLCarveth sounds good, can you also rename the subcommand to bump-version please?
@JLCarveth I think we're ready to land this one - I'm thinking we could do it this week, without waiting for another minor release - how about we land this one as "unstable"? If so, let's add a small banner anytime this command is run that says: Warning deno bump-version is experimental as subject to change.
Walkthrough
Adds a new bump-version CLI subcommand and related types (VersionFlags, VersionIncrement) and a DenoSubcommand::BumpVersion variant. Implements tools::bump_version::bump_version_command to locate deno.json or package.json, read and parse the current version, compute increments (major, minor, patch, pre* variants), update the config in place, and log results. Exposes cli/tools::bump_version module. Adds integration tests covering increments, file selection, no-config failure, and no-increment behavior.
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 37.04% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly and concisely describes the main feature: adding a deno bump-version subcommand, which aligns perfectly with the changeset's core objective. |
| Description check | ✅ Passed | The description explains the feature, mentions the related issue #30358, and notes implementation considerations about version field location and the TODO for tests. |
| Linked Issues check | ✅ Passed | The PR fully addresses issue #30358 by implementing a deno bump-version subcommand supporting semantic version bumping with Major/Minor/Patch/Prerelease strategies, file I/O, and error handling. |
| Out of Scope Changes check | ✅ Passed | All changes are directly scoped to implementing the bump-version feature: CLI args, subcommand dispatch, the command implementation, module exports, and integration tests. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.