Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow matching a range of occurrences #659

Open
RiemannSurface opened this issue Jan 24, 2023 · 1 comment
Open

Allow matching a range of occurrences #659

RiemannSurface opened this issue Jan 24, 2023 · 1 comment
Labels
type: feature A new enhacement proposal

Comments

@RiemannSurface
Copy link

Description

I would like to bump the version in a package-lock.json. Currently I cannot figure out how to do this safely. A typical package-lock.json has the format:

{
  "name": "my-service",
  "version": "1.2.3",
  "packages": {
    "node_modules/another/project": {
      "version": "1.2.3",
      ...
    }
}

As per the documentation, I would like to increase the "version" inside the package.lock using the following .cz.yaml config:

commitizen:
  version: 1.2.3
  version_files:
  - package-lock.json:version

The issue is that this will update ANY package that happens to have the version 1.2.3 or even 1.2.39, because they all match the word "version". In this example node_modules/another/project would also be updated

I have tried searching for a solution for this but cannot find anything in the docs for version_files. Can you please suggest how this can be done?

Possible Solution

Alternatively, to get round this, you could specify a slice (possibly using python's slice syntax) which would modify only a range of occurrences out of all the possible matches. For example

commitizen:
  version: 1.2.3
  version_files:
  - package-lock.json:version[:2]

This would would update the first 2 occurrences but would stop there.

If there is another solution that already exists please let me know

Additional context

No response

Additional context

No response

@RiemannSurface RiemannSurface added the type: feature A new enhacement proposal label Jan 24, 2023
@RiemannSurface RiemannSurface changed the title <One feature request per issue> Allow matching a range of occurrences Jan 24, 2023
@Lee-W
Copy link
Member

Lee-W commented Feb 11, 2023

Yep, I think it's something we've not yet supported. Currently, we split files by line and try to match the regular expression here. My idea is to support matching the multi-line regular expression. Feel free to send us a PR if you're interested in it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A new enhacement proposal
Projects
None yet
Development

No branches or pull requests

2 participants