Allow package.json to be located in subdirectories by processing paths
Description
Enable the NpmProvider to locate and process package.json files that are not in the root directory by correctly handling and resolving paths from the project root.
Possible Solution
npm_provider.py:
@property
def package_file(self) -> Path:
package_path = next(
(Path(p) for p in self.config.settings["version_files"] if p.endswith("package.json")),
None
)
if package_path is None:
raise FileNotFoundError("No package.json found in version_files")
return package_path
Additional context
No response
Additional context
No response
The possible solution LGTM. @woile @Lee-W wdyt?
What about the --config parameter?
Then user needs to type --config every time they run cz (iirc there is no corresponding configuration file option for --config)
I think that is bad user experience.
Not a JS developer. Is it a common practice in JS? If so, we should include it. If not, I think the user should customize the provider or we should allow it to be config through config file
iirc most of the time package.json is located at project root, but there may be exceptions
can't the problem be solved by just specifying version_files?
Is it a common practice in JS?
The same chances of finding a pyproject.toml in a different folder. Which IMO, would be in monorepos:
root-project/
├── project-a/
│ └── package.json
└── project-b/
└── pyproject.toml
Then user needs to type --config every time they run cz (iirc there is no corresponding configuration file option for --config)
My expectation is for users to run cz bump in the CI, not so much locally, the other commands shouldn't be affected by this.
That being said, --config would be part of the solution in this case. I think the solution is actually moving .cz.toml to the project where the package.json is and then using cz bump --config project/.cz.toml or cd project; cz bump.
The proposed solution doesn't cover the presence of N+1 package.json files, and increases complexity, how would we handle more than 1? Instead, for monorepos, we are using a cz.toml per sub-project.