-
Notifications
You must be signed in to change notification settings - Fork 10
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
chore: convert json scenarios to toml format #211
base: main
Are you sure you want to change the base?
Conversation
Here's the basic script I used, so we can regen if needed. For prettier I used the prettier-plugin-toml as a separate follow up command. json_scenarios_to_toml.py
import json
import re
from pathlib import Path
import toml
scenarios_path = Path(__file__).parent / "scenarios"
for path in scenarios_path.glob("*.json"):
with path.open("r") as f:
json_scenarios = json.load(f)
for json_scenario in json_scenarios:
# Use the name key as the filename
file_path = (
path.parent
/ re.sub(r"[\s-]+", "_", path.stem.lower())
/ f"{json_scenario['name']}.toml"
)
file_path.parent.mkdir(parents=True, exist_ok=True)
toml_data = {
"name": json_scenario["name"],
"description": json_scenario["description"],
"root": json_scenario["root"],
"packages": json_scenario["packages"],
"expected": json_scenario["expected"],
}
with file_path.open("w", encoding="utf-8") as toml_file:
toml.dump(toml_data, toml_file)
print(f"Created: {file_path}") |
These are so much nicer to read. |
satisfiable = false | ||
explanation = "Only the `2.x` versions of `a` are available since `a==1.0.0` and `a==3.0.0` require incompatible versions of `b`, but all available versions of `c` exclude that range of `a` so resolution fails." | ||
|
||
[packages.a.versions."1.0.0"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use nesting for package versions? Is that easier to read?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pre-existing fork/*.toml
seem to also use this syntax, we can attempt to change it across though.
e.g. fork/filter-sibling-dependencies.toml
[packages.a.versions."4.3.0"]
[packages.a.versions."4.4.0"]
[packages.b.versions."1.0.0"]
requires = ["d==1.0.0"]
[packages.c.versions."1.0.0"]
requires = ["d==2.0.0"]
[packages.d.versions."1.0.0"]
[packages.d.versions."2.0.0"]
Exciting! Thanks! |
Separately from this PR, do we want to add prettier to this repo? |
Closes #177 , #18