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
manage other file type in version_file
#825
Comments
Hoy can either build your own provider: Or a good way to start is to use the version files setting: |
As I was mentioning in my issue my problem is simply managing other file types. I'm well aware of the As .json is a common file type and not so unusual in python packages I was proposing to extend the current scope of version_files for all commitizen users. If it's a wanting feature I'm happy (as usual) to propose a PR. If for some technical/design reason, you don't want to include it, no problem. |
Sorry, I think I don't get it, would you mind elaborating with some examples? |
sure: the build of an ipywidget lib requires to build both a python lib and some javascript package that will be send to jupyter tool to inject JS/css compiled stuff to the interface. In our case we have 3 json file that should be wired to the version number like this package.json file: {
"name": "jupyter-vuetify",
"version": "1.8.10",
"description": "Jupyter widgets based on vuetify UI components",
"license": "MIT",
"author": "Mario Buikhuizen, Maarten Breddels",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com/widgetti/ipyvuetify.git"
},
//...
} That would make our lives much easier if we could set up in the |
version_files = [
"package.json:version"
] where |
Unfortunately as of now it's one line at a time, so more complex regex are not possible. IIRC we had multi line support but we had troubles with it and went back to per-line. Maybe @Lee-W remembers more |
I see why this approach is perfectly fine with unstructured files like .py or .txt but I think it could be improved for configuration files. What prevents any of the tools available in my .toml to have a "version" key ? same for .json. What if the current behaviour remain the default one and for the said dict-like config file you search for keys to replace the value ? |
In principle, you can achieve that with a custom "version provider" specifically design for your application. Version providers are plugins, that can be implemented as new python packages. You just have to register them in See this upcoming fix for the npm provider, which modifies multiple files: You could extend the existing You can see how to create one here: Alternatively, because providers can access the config of commitizen, you could implement a [tool.commitizen]
# ... some other stuff
version_provider = "config" # existing commitizen setting
config_version_source="pyproject.toml>tool.poetry.version" # new setting which you would use for configversionprovider
config_version_updates=[ # new setting which you would use for configversionprovider
"foo/package.json>name.version",
"bar/chart/Chart.yaml>name.version",
] What do you think of this approach? |
I'll try to implement it and come back to you if I manage to make somthing work ;-) |
Yes, you're right. I think that's all the context I have as well. Looking forward to seeing whether we can add it back without issue in the future |
Description
I'm working on a widget lib called ipyvuetify and I would like to use commitizen to help us manage the releases. Problem as the ipywidget libs are at the frontiere between pure python and javascript we do embed to version number in other file type than .py, specifically .json
Possible Solution
would it be possible to add support for .json file. It would use the same pattern as the one use in .py files:
would look into a pakage.json file and replace the ipyvuetify.version key.
The text was updated successfully, but these errors were encountered: