🎄 Sync 2026-11-14 17:29:54

This commit is contained in:
github-actions[bot] committed 2026-11-14 17:29:54 +08:00
1 parent 00efd4e7cf
commit 4e24fe7535
123 files changed
+26051

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""Concatenate styles/NN-*.css into htdocs/luci-static/carbon/carbon.css.
python3 -I scripts/build-css.py write carbon.css
python3 -I scripts/build-css.py --check CI: fail if carbon.css is stale
carbon.css is committed so every install path (SDK, installer, .ipk, demo)
ships one stylesheet request without a build step. Edit the files in styles/.
"""
from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parent.parent
SOURCES = ROOT / 'styles'
TARGET = ROOT / 'htdocs' / 'luci-static' / 'carbon' / 'carbon.css'
BANNER = '/* Generated by scripts/build-css.py from styles/*.css. Do not edit. */\n\n'
def build():
files = sorted(SOURCES.glob('[0-9][0-9]-*.css'))
if not files or files[0].name != '00-header.css':
raise SystemExit('styles/00-header.css must exist and sort first')
parts = [f.read_text(encoding='utf-8') for f in files]
return parts[0] + BANNER + ''.join(parts[1:])
def main(check):
text = build()
current = TARGET.read_text(encoding='utf-8') if TARGET.exists() else None
if check:
if current != text:
print('carbon.css is stale: run python3 -I scripts/build-css.py', file=sys.stderr)
return 1
return 0
if current != text:
TARGET.write_text(text, encoding='utf-8')
print('wrote', TARGET.relative_to(ROOT))
return 0
if __name__ == '__main__':
sys.exit(main('--check' in sys.argv))