-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Relative paths in [nitpick.styles].includes remote style should be resolved against the remote URL #464
Comments
Hello again. Yes, these remote/local/merged configs have been a problem... I think this can be done, I don't know how easy it is. And this part of the Nitpick code is not actually pretty (it's super ugly in fact). |
I have an implementation for this now, but I'll need to clean it up a little, add a few more tests and update the documentation. I'm aiming for that to be done tomorrow. It does rip out the current "subsequent style entries are relative to the first URI" functionality I found in the code, because it conflicts with the design I set out in this FR and I found that behaviour to be confusing and counter to how URI resolving works in other contexts such as HTML. The implementation is otherwise relatively straightforward; after loading a style file the raw include values are normalised based against the current documentation URI. |
One thing to decide on: how to handle symlinks. The existing tests and implementation appear to assume that the real, absolute path on disk (all symlinks resolved) is the base for relative paths. A case could be made for the original path the be used however, as that can give you more flexibility with altering what is included based on where you put a symlink to a style file with I don't have a good use case ready for that scenario, however. It is also something that could be made configurable on a per file basis if the need arises in future. |
Yes, this was a bad design while I was trying to shorten the declaration of styles.
Sounds good. Just like HTML (as you mentioned above): a page with relative images inside it.
I didn't think of symlinks before because I didn't (don't) have any scenario either. I don't even consider it a breaking change because I don't think anyone is relying on symlinks. On a side note, I wish I could have some kind of telemetry to know which features are being used or not... 🤷🏻♂️ |
That’s tempting. The simpler implementation is to ignore symlinks :-) That said: I’m very happy with the current delegation pattern where the file fetcher is using the normalisation step to expand |
Works for me. 🙂 Let's postpone the decision for when someone has a use case for symlinks. 👍🏻 |
🎉 This issue has been resolved in version 0.32.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Problem
Defining a preset that reuses other rules is arduous because relative paths are not supported. E.g. hosting a series of nitpick rules at
https://coding-standards.example.com/python/*
and a preset that includes the rules athttps://coding-standards.example.com/presets/python.toml
requires that we repeat the base URL in every single entry:This makes it hard to re-home the files somewhere else and error prone. The problem is compounded when you use private github project URLs with a PAT and a tag reference; every link has to have the token reference and branch named:
If I want to test changes to the styles before publishing I can't, not without first having to rewrite every include to point to the staging version or local filesystem.
Possible solution
Include references should be resolved relative to a base URL for the style file. So a file located at
https://coding-standards.example.com/presets/python.toml
, with the contents:results in the paths being resolved as relative against the
https://coding-standards.example.com/presets/python.toml
base URL for that file. It would work exactly the same for a Github URL; the base would begh:https://$GITHUB_TOKEN@org/coding-standards@v1/presets/python.toml
in that case.This would also allow me to point nitpick to a local filesystem copy of my styles-under-development or hosted with a simple
python -m http.server
web server, for example, and all the includes would automatically be taken from the same location.The text was updated successfully, but these errors were encountered: