Skip to content

Commit edad60d

Browse files
committed
Merge branch 'feature/sync-dart-sass'
2 parents 41368a7 + c37e200 commit edad60d

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'Sync version text of Dart Sass'
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'aqua.yaml'
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/cache@v4
14+
with:
15+
path: ~/.local/share/aquaproj-aqua
16+
key: v2-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('aqua.yaml')}}
17+
restore-keys: |
18+
v2-aqua-installer-${{runner.os}}-${{runner.arch}}-
19+
- uses: aquaproj/aqua-installer@9ebf656952a20c45a5d66606f083ff34f58b8ce0 # v4.0.0
20+
with:
21+
aqua_version: v2.51.2
22+
- name: 'Configure dependencies'
23+
run: |
24+
uv sync --frozen --all-extras
25+
- name: 'Try sync'
26+
run: |
27+
uv run tools/sync-current-sass.py
28+
- uses: 'actions-js/push@v1'
29+
with:
30+
message: 'feat: Sync version text of Dart Sass'
31+
branch: ${{ github.ref_name }}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ dev = [
4848
"esbonio>=0.16.5",
4949
"hatchling>=1.27.0",
5050
"pytest>=8.3.5",
51+
"pyyaml>=6.0.2",
5152
"ruff>=0.11.2",
5253
"ty>=0.0.0a10",
5354
]

tools/sync-current-sass.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
import re
3+
from pathlib import Path
4+
5+
import yaml
6+
7+
from sass_embedded import _const as const
8+
9+
root = Path(__file__).parents[1]
10+
11+
TARGETS = {
12+
root / "src/sass_embedded/_const.py": [
13+
{
14+
"match": r'DART_SASS_VERSION = ".+"',
15+
"replace": r'DART_SASS_VERSION = "{version}"',
16+
}
17+
]
18+
}
19+
20+
21+
def pick_sass_version(aqua: dict):
22+
for pkg in aqua["packages"]:
23+
if pkg["name"].startswith("sass/dart-sass@"):
24+
return pkg["name"].split("@")[1]
25+
raise Exception("Package is not found")
26+
27+
28+
def update_sources(version: str):
29+
for src, rules in TARGETS.items():
30+
lines = src.read_text().split("\n")
31+
new_lines = []
32+
for idx, line in enumerate(lines):
33+
if not line:
34+
new_lines.append(line)
35+
continue
36+
for rule in rules:
37+
if not re.fullmatch(rule["match"], line):
38+
continue
39+
line = rule["replace"].format(version=version)
40+
else:
41+
new_lines.append(line)
42+
src.write_text("\n".join(new_lines))
43+
44+
45+
def main():
46+
aqua_yaml_path = root / "aqua.yaml"
47+
aqua = yaml.safe_load(aqua_yaml_path.read_text())
48+
sass_version = pick_sass_version(aqua)
49+
print(f"- Current version: {const.DART_SASS_VERSION}")
50+
print(f"- Loaded version: {sass_version}")
51+
if sass_version == const.DART_SASS_VERSION:
52+
return 0
53+
print("Detect newer Dart Sass.")
54+
update_sources(sass_version)
55+
pass
56+
57+
58+
if __name__ == "__main__":
59+
main()

uv.lock

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)