From b4d33beada59e190506c1374a74c6c4077223d50 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 25 Jun 2026 01:54:58 -0400 Subject: [PATCH] fix CLI asset sync (#355) * fix CLI asset sync * fix(cli): normalize line endings in asset sync/check check:assets hashed raw bytes, so identical CSV/JSON/py content with CRLF vs LF (git autocrlf on checkout) was reported as stale drift, blocking the release guard on Windows/mixed checkouts. - fileHash now normalizes CRLF->LF before hashing, so check:assets compares content, not line endings. - sync:assets writes LF-normalized copies instead of a raw byte copy, so re-syncing is deterministic across platforms. All synced assets are text (csv/json/md/py); no binaries affected. Co-Authored-By: Claude Opus 4.8 * ci: enforce CLI asset sync on PRs Adds a Check asset sync workflow that runs `npm run check:assets` on any PR touching src/ui-ux-pro-max/** or cli/assets/**, so the bundled CLI assets can't silently drift from the source of truth. The check uses only node builtins (no install step) and normalizes line endings before hashing, so it hard-fails on real content drift without the CRLF/LF soft-fail hack other approaches needed. Co-Authored-By: Claude Opus 4.8 --------- Co-authored-by: Claude Opus 4.8 --- .github/workflows/check-asset-sync.yml | 29 + CLAUDE.md | 6 +- README.md | 18 +- cli/README.md | 17 +- cli/assets/data/app-interface.csv | 60 +- cli/assets/data/charts.csv | 52 +- cli/assets/data/colors.csv | 324 +- cli/assets/data/google-fonts.csv | 3848 ++++++++--------- cli/assets/data/icons.csv | 209 +- cli/assets/data/landing.csv | 66 +- cli/assets/data/products.csv | 324 +- cli/assets/data/stacks/flutter.csv | 106 +- cli/assets/data/stacks/html-tailwind.csv | 112 +- cli/assets/data/stacks/nextjs.csv | 106 +- cli/assets/data/stacks/react-native.csv | 104 +- cli/assets/data/stacks/react.csv | 108 +- cli/assets/data/stacks/svelte.csv | 108 +- cli/assets/data/stacks/swiftui.csv | 102 +- cli/assets/data/stacks/vue.csv | 100 +- cli/assets/data/styles.csv | 136 +- cli/assets/data/typography.csv | 146 +- cli/assets/data/ui-reasoning.csv | 324 +- cli/assets/data/ux-guidelines.csv | 198 +- cli/assets/scripts/core.py | 15 +- cli/assets/scripts/search.py | 228 +- cli/assets/templates/base/skill-content.md | 9 +- cli/assets/templates/platforms/agent.json | 4 +- cli/assets/templates/platforms/augment.json | 2 +- cli/assets/templates/platforms/claude.json | 4 +- cli/assets/templates/platforms/codebuddy.json | 2 +- cli/assets/templates/platforms/codex.json | 2 +- cli/assets/templates/platforms/continue.json | 2 +- cli/assets/templates/platforms/copilot.json | 4 +- cli/assets/templates/platforms/cursor.json | 4 +- cli/assets/templates/platforms/droid.json | 4 +- cli/assets/templates/platforms/gemini.json | 2 +- cli/assets/templates/platforms/kilocode.json | 4 +- cli/assets/templates/platforms/kiro.json | 4 +- cli/assets/templates/platforms/opencode.json | 2 +- cli/assets/templates/platforms/qoder.json | 2 +- cli/assets/templates/platforms/roocode.json | 4 +- cli/assets/templates/platforms/trae.json | 2 +- cli/assets/templates/platforms/warp.json | 2 +- cli/assets/templates/platforms/windsurf.json | 4 +- cli/package.json | 5 +- cli/scripts/sync-assets.mjs | 142 + cli/src/commands/uninstall.ts | 4 +- cli/src/commands/update.ts | 27 +- cli/src/commands/versions.ts | 2 +- cli/src/index.ts | 2 +- cli/src/types/index.ts | 3 +- cli/src/utils/detect.ts | 6 +- docs/三个 data-scripts-templates 的区别.md | 6 +- 53 files changed, 3670 insertions(+), 3436 deletions(-) create mode 100644 .github/workflows/check-asset-sync.yml create mode 100644 cli/scripts/sync-assets.mjs diff --git a/.github/workflows/check-asset-sync.yml b/.github/workflows/check-asset-sync.yml new file mode 100644 index 0000000..5590cbe --- /dev/null +++ b/.github/workflows/check-asset-sync.yml @@ -0,0 +1,29 @@ +name: Check asset sync + +on: + pull_request: + paths: + - "src/ui-ux-pro-max/**" + - "cli/assets/**" + - "cli/scripts/sync-assets.mjs" + - ".github/workflows/check-asset-sync.yml" + push: + branches: [main] + paths: + - "src/ui-ux-pro-max/**" + - "cli/assets/**" + +jobs: + check-assets: + name: cli/assets must match src/ui-ux-pro-max + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + # check:assets runs `node scripts/sync-assets.mjs --check`, which uses only + # node builtins (no npm install needed) and normalizes CRLF/LF before + # hashing, so it compares content rather than line endings. + - name: Check CLI assets are in sync with source of truth + run: npm --prefix cli run check:assets diff --git a/CLAUDE.md b/CLAUDE.md index 364647c..f541cbf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -77,9 +77,9 @@ When modifying files: 3. **CLI Assets** - Run sync before publishing: ```bash - cp -r src/ui-ux-pro-max/data/* cli/assets/data/ - cp -r src/ui-ux-pro-max/scripts/* cli/assets/scripts/ - cp -r src/ui-ux-pro-max/templates/* cli/assets/templates/ + cd cli + npm run sync:assets + npm run check:assets ``` 4. **Reference Folders** - No manual sync needed. The CLI generates these from templates during `uipro init`. diff --git a/README.md b/README.md index 6a1f1ad..1df7180 100755 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Each rule includes: - **161 Color Palettes** - Industry-specific palettes aligned 1:1 with the 161 product types - **57 Font Pairings** - Curated typography combinations with Google Fonts imports - **25 Chart Types** - Recommendations for dashboards and analytics -- **16 Tech Stacks** - React, Next.js, Astro, Vue, Nuxt.js, Nuxt UI, Svelte, SwiftUI, React Native, Flutter, HTML+Tailwind, shadcn/ui, Jetpack Compose, Angular, Laravel, JavaFX +- **17 Tech Stacks** - React, Next.js, Astro, Vue, Nuxt.js, Nuxt UI, Svelte, SwiftUI, React Native, Flutter, HTML+Tailwind, shadcn/ui, Jetpack Compose, Angular, Laravel, Three.js, JavaFX - **99 UX Guidelines** - Best practices, anti-patterns, and accessibility rules - **161 Reasoning Rules** - Industry-specific design system generation (NEW in v2.0) @@ -304,8 +304,8 @@ uipro init --ai cursor --global # Install to ~/.cursor/skills/ ```bash uipro versions # List available versions -uipro update # Update to latest version -uipro init --offline # Skip GitHub download, use bundled assets +uipro update # Refresh skill files from installed CLI package +uipro init --offline # Compatibility flag; installs bundled templates uipro uninstall # Remove skill (auto-detect platform) uipro uninstall --ai claude # Remove specific platform uipro uninstall --global # Remove from global install @@ -386,7 +386,7 @@ The skill provides stack-specific guidelines for: | **Vue Ecosystem** | Vue, Nuxt.js, Nuxt UI | | **Angular** | Angular | | **PHP** | Laravel (Blade, Livewire, Inertia.js) | -| **Other Web** | Svelte, Astro | +| **Other Web** | Svelte, Astro, Three.js | | **Desktop** | JavaFX | | **iOS** | SwiftUI | | **Android** | Jetpack Compose | @@ -468,7 +468,7 @@ npm install -g uipro-cli uipro init --ai ``` -This ensures you get the latest templates and correct file structure for your AI assistant. +This ensures you get the latest templates bundled with the installed CLI package and the correct file structure for your AI assistant. Update the npm package first when a new release is published. ### For Contributors @@ -491,12 +491,12 @@ cli/ # CLI installer (generates files from templates) # - templates/ → Platform-specific templates # 4. Sync to CLI and test locally -cp -r src/ui-ux-pro-max/data/* cli/assets/data/ -cp -r src/ui-ux-pro-max/scripts/* cli/assets/scripts/ -cp -r src/ui-ux-pro-max/templates/* cli/assets/templates/ +cd cli +npm run sync:assets +npm run check:assets # 5. Build and test CLI -cd cli && bun run build +bun run build node dist/index.js init --ai claude --offline # Test in a temp folder # 6. Create PR (never push directly to main) diff --git a/cli/README.md b/cli/README.md index 2321ba3..40c7866 100644 --- a/cli/README.md +++ b/cli/README.md @@ -28,12 +28,12 @@ uipro init --ai continue # Continue (Skills) uipro init --ai all # All assistants # Options -uipro init --offline # Skip GitHub download, use bundled assets only +uipro init --offline # Compatibility flag; installs bundled templates uipro init --force # Overwrite existing files # Other commands uipro versions # List available versions -uipro update # Update to latest version +uipro update # Refresh skill files from installed CLI package ``` ## GitHub Authentication @@ -63,9 +63,12 @@ uipro init ## How It Works -By default, `uipro init` tries to download the latest release from GitHub to ensure you get the most up-to-date version. If the download fails (network error, rate limit), it automatically falls back to the bundled assets included in the CLI package. +`uipro init` generates assistant-specific files from the templates bundled with the installed CLI package. To get newer templates and data, update the package first: -Use `--offline` to skip the GitHub download and use bundled assets directly. +```bash +npm install -g uipro-cli@latest +uipro init --ai codex +``` ## Development @@ -79,6 +82,12 @@ bun run src/index.ts --help # Build bun run build +# Sync bundled CLI assets from the source skill +npm run sync:assets + +# Verify bundled assets are current before publishing +npm run check:assets + # Link for local testing bun link ``` diff --git a/cli/assets/data/app-interface.csv b/cli/assets/data/app-interface.csv index 636284c..f34c3cd 100644 --- a/cli/assets/data/app-interface.csv +++ b/cli/assets/data/app-interface.csv @@ -1,31 +1,31 @@ No,Category,Issue,Keywords,Platform,Description,Do,Don't,Code Example Good,Code Example Bad,Severity -1,Accessibility,Icon Button Labels,icon button aria-label,Web,Icon-only buttons must have accessible names,Add aria-label to icon buttons,Icon button without label,"","",Critical -2,Accessibility,Form Control Labels,form input label aria,Web,All form controls need labels or aria-label,Use label element or aria-label,Input without accessible name,"","",Critical -3,Accessibility,Keyboard Handlers,keyboard onclick onkeydown,Web,Interactive elements must support keyboard interaction,Add onKeyDown alongside onClick,Click-only interaction,"
","
",High -4,Accessibility,Semantic HTML,semantic button a label,Web,Use semantic HTML before ARIA attributes,Use button/a/label elements,Div with role attribute,"","
Submit
",High -5,Accessibility,Aria Live,aria-live polite async,Web,Async updates need aria-live for screen readers,Add aria-live='polite' for dynamic content,Silent async updates,"
{status}
","
{status}
// no announcement",Medium -6,Accessibility,Decorative Icons,aria-hidden decorative icon,Web,Decorative icons should be hidden from screen readers,Add aria-hidden='true' to decorative icons,Decorative icon announced,"