fabiospampinato / bump

Bump updates the project's version, updates/creates the changelog, makes the bump commit, tags the bump commit and makes the release to GitHub. Opinionated but configurable.
MIT License
411 stars 13 forks source link

Dry-run mode #34

Open lolo101 opened 7 months ago

lolo101 commented 7 months ago

Hi !

It would be nice to have a dry-run mode to test various options before actually running the command and throwing stuff to the npm registry

fabiospampinato commented 7 months ago

Would this be any more useful than the already present --no-scripts flag?

lolo101 commented 7 months ago

IDK :slightly_smiling_face:

I cannot find any documentation about this flag in the readme or the CLI help What does it do?

fabiospampinato commented 7 months ago

I should update the screenshot in the readme, it basically just turns off all pre and post scripts.

lolo101 commented 7 months ago

I don't think I'm using it correctly :smile:

$ npx bump --no-scripts

 test-project:
 v0.1.0 => v--no-scripts
 ↑ bum bum bumped!

The package.json is updated to version "--no-scripts"

fabiospampinato commented 7 months ago

what do you get with a npx bump --version?

lolo101 commented 7 months ago

OMG, I'm so sorry I think I have another executable named "bump".

When I use the fully qualified name of the package I get the following:

$ npx @fabiospampinato/bump --version
3.2.2

However, I think there is some issue here :

$ npx @fabiospampinato/bump major --no-scripts
TypeError: unmatched.replaceAll is not a function or its return value is not iterable
    at getStringTruncatedWidth (file:///home/loic/.npm/_npx/a9f0ddfae1f1b021/node_modules/fast-string-truncated-width/dist/index.js:42:42)
    at truncate (file:///home/loic/.npm/_npx/a9f0ddfae1f1b021/node_modules/ansi-truncate/dist/index.js:10:44)
    at truncate (file:///home/loic/.npm/_npx/a9f0ddfae1f1b021/node_modules/tiny-truncate/dist/index.js:6:12)
    at writeLine (file:///home/loic/.npm/_npx/a9f0ddfae1f1b021/node_modules/tiny-spinner/dist/utils.js:5:12)
    at Spinner.stop (file:///home/loic/.npm/_npx/a9f0ddfae1f1b021/node_modules/tiny-spinner/dist/index.js:46:13)
    at Spinner.error (file:///home/loic/.npm/_npx/a9f0ddfae1f1b021/node_modules/tiny-spinner/dist/index.js:37:25)
    at command (file:///home/loic/.npm/_npx/a9f0ddfae1f1b021/node_modules/@fabiospampinato/bump/dist/commands/command.js:19:17)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Note: the package.json has been updated as expected

BTW with a dry run, I would expect the package.json to be left unmodified

fabiospampinato commented 7 months ago

Oh right this package is namespaced unfortunately.

It looks like there is a bug somewhere 🤔

BTW with a dry run, I would expect the package.json to be left unmodified

What would you expect a dry run mode to actually do?

lolo101 commented 7 months ago

I'd expect the dry run to do nothing at all, but print a detailed log of what it would do. Just like if it would be an actual run. So I can tell if I misconfigured something, if the version is not the one I expect, or if the access to the npm repository is misconfigured, and so on

lolo101 commented 7 months ago

For instance, you can check the dry-run mode of release-it

https://github.com/release-it/release-it/blob/main/docs/dry-runs.md

fabiospampinato commented 7 months ago

It makes sense, but assuming the bug you reported is fixed, wouldn't it be more or less the same as doing a bump --no-scripts, looking at the changes in git, and then discarding all local changes in git? Like I understand that having a --dry-run command could be a bit more convenient, but it would also the program more complicated for maybe not enough benefit 🤔

lolo101 commented 7 months ago

Yes good point :slightly_smiling_face:

I'll try this and let you know, thank you for taking the time to take a look at this request anyway :wink:

fabiospampinato commented 7 months ago

Possibly a better suggestion, but you can just run bump version && bump changelog for example to skip making the commit and tagging it, which make resetting the changes a bit more annoying.

fabiospampinato commented 7 months ago

By the way are you using a version older than v15 of Node? The error you are seeing about String.prototype.replaceAll not being available seems to indicate that.

lolo101 commented 7 months ago

All right I'm going to try that idea :slightly_smiling_face:

Yes well seen :slightly_smiling_face: fnm defaults to version 14:

$ fnm list  
* v14.20.1 default
* v16.20.2
* v18.19.0
* system

I change that!