📦 deps(thirdparty): update snapshots
This commit is contained in:
@@ -48,6 +48,10 @@ Component (component-specific)
|
||||
--button-bg: var(--color-primary);
|
||||
```
|
||||
|
||||
## Script Paths
|
||||
|
||||
Script paths in this skill and its `references/` are relative to the directory that contains this SKILL.md, not to the project: `scripts/<file>` is this skill's own `scripts/` folder, and `../<skill>/scripts/<file>` is a sibling sub-skill installed alongside it. Build the full path from that directory (Claude Code reports it as the skill's base directory when the skill loads) and keep the working directory at the project root — the scripts read and write project files such as `docs/brand-guidelines.md`, `assets/design-tokens.json` or `src/` relative to it.
|
||||
|
||||
## Quick Start
|
||||
|
||||
**Generate tokens:**
|
||||
|
||||
@@ -15,12 +15,16 @@ const path = require('path');
|
||||
|
||||
// Find project root (look for assets/design-tokens.css)
|
||||
function findProjectRoot(startDir) {
|
||||
// Walk up until dirname stops changing: on Windows the root is 'C:\', so a
|
||||
// `dir !== '/'` guard never terminates.
|
||||
let dir = startDir;
|
||||
while (dir !== '/') {
|
||||
for (;;) {
|
||||
if (fs.existsSync(path.join(dir, 'assets', 'design-tokens.css'))) {
|
||||
return dir;
|
||||
}
|
||||
dir = path.dirname(dir);
|
||||
const parent = path.dirname(dir);
|
||||
if (parent === dir) break;
|
||||
dir = parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,32 @@ import json
|
||||
import csv
|
||||
import re
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Project root relative to this script
|
||||
PROJECT_ROOT = Path(__file__).parent.parent.parent.parent.parent
|
||||
# The skill can be installed outside the project it operates on (user-level
|
||||
# ~/.claude/skills/, or as a plugin), so the project root cannot be derived from
|
||||
# this file's location. Resolve it from the working directory instead -- the same
|
||||
# convention generate-tokens.cjs and validate-tokens.cjs already use via
|
||||
# process.cwd(). DESIGN_SYSTEM_PROJECT_ROOT overrides it explicitly.
|
||||
def _find_project_root():
|
||||
override = os.environ.get('DESIGN_SYSTEM_PROJECT_ROOT')
|
||||
if override:
|
||||
return Path(override).resolve()
|
||||
start = Path.cwd().resolve()
|
||||
markers = (
|
||||
Path('assets') / 'design-tokens.json',
|
||||
Path('assets') / 'design-tokens.css',
|
||||
Path('package.json'),
|
||||
Path('.git'),
|
||||
)
|
||||
for candidate in (start, *start.parents):
|
||||
if any((candidate / marker).exists() for marker in markers):
|
||||
return candidate
|
||||
return start
|
||||
|
||||
|
||||
PROJECT_ROOT = _find_project_root()
|
||||
TOKENS_PATH = PROJECT_ROOT / 'assets' / 'design-tokens.json'
|
||||
BACKGROUNDS_CSV = Path(__file__).parent.parent / 'data' / 'slide-backgrounds.csv'
|
||||
|
||||
|
||||
@@ -15,11 +15,43 @@ Usage:
|
||||
import re
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Tuple, Optional
|
||||
|
||||
# Project root relative to this script
|
||||
PROJECT_ROOT = Path(__file__).parent.parent.parent.parent.parent
|
||||
# The skill can be installed outside the project it operates on (user-level
|
||||
# ~/.claude/skills/, or as a plugin), so the project root cannot be derived from
|
||||
# this file's location. Resolve it from the working directory instead -- the same
|
||||
# convention generate-tokens.cjs and validate-tokens.cjs already use via
|
||||
# process.cwd(). DESIGN_SYSTEM_PROJECT_ROOT overrides it explicitly.
|
||||
def _find_project_root():
|
||||
override = os.environ.get('DESIGN_SYSTEM_PROJECT_ROOT')
|
||||
if override:
|
||||
return Path(override).resolve()
|
||||
start = Path.cwd().resolve()
|
||||
markers = (
|
||||
Path('assets') / 'design-tokens.json',
|
||||
Path('assets') / 'design-tokens.css',
|
||||
Path('package.json'),
|
||||
Path('.git'),
|
||||
)
|
||||
for candidate in (start, *start.parents):
|
||||
if any((candidate / marker).exists() for marker in markers):
|
||||
return candidate
|
||||
return start
|
||||
|
||||
|
||||
PROJECT_ROOT = _find_project_root()
|
||||
|
||||
# Force UTF-8 on stdout/stderr: this script prints emoji, which raises
|
||||
# UnicodeEncodeError on a Windows console (cp1252). Same guard as
|
||||
# src/ui-ux-pro-max/scripts/search.py.
|
||||
import io
|
||||
|
||||
if sys.stdout.encoding and sys.stdout.encoding.lower() != 'utf-8':
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||||
if sys.stderr.encoding and sys.stderr.encoding.lower() != 'utf-8':
|
||||
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
|
||||
TOKENS_JSON_PATH = PROJECT_ROOT / 'assets' / 'design-tokens.json'
|
||||
TOKENS_CSS_PATH = PROJECT_ROOT / 'assets' / 'design-tokens.css'
|
||||
|
||||
|
||||
@@ -13,6 +13,16 @@ from slide_search_core import (
|
||||
get_color_for_emotion, get_background_config
|
||||
)
|
||||
|
||||
# Force UTF-8 on stdout/stderr: this script prints emoji, which raises
|
||||
# UnicodeEncodeError on a Windows console (cp1252). Same guard as
|
||||
# src/ui-ux-pro-max/scripts/search.py.
|
||||
import io
|
||||
|
||||
if sys.stdout.encoding and sys.stdout.encoding.lower() != 'utf-8':
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||||
if sys.stderr.encoding and sys.stderr.encoding.lower() != 'utf-8':
|
||||
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
|
||||
|
||||
|
||||
def format_result(result, domain):
|
||||
"""Format a single search result for display"""
|
||||
|
||||
@@ -20,11 +20,15 @@ def _run(tmp_path: Path, css: str) -> subprocess.CompletedProcess:
|
||||
node = shutil.which("node")
|
||||
if not node:
|
||||
pytest.skip("node not available")
|
||||
(tmp_path / "sample.css").write_text(css)
|
||||
(tmp_path / "sample.css").write_text(css, encoding="utf-8")
|
||||
return subprocess.run(
|
||||
[node, str(SCRIPT), "--dir", str(tmp_path)],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
# validate-tokens.cjs prints emoji; without an explicit encoding Python
|
||||
# decodes the pipe with the locale codec (cp1252 on Windows), which
|
||||
# raises in the reader thread and leaves result.stdout set to None.
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user