Skip to content

Allow matching a range of occurrences #659

Open
@RiemannSurface

Description

@RiemannSurface

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions