diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..55a9d3e --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,5 @@ +# Formatting-only commits skipped by `git blame`. +# Enable once with: git config blame.ignoreRevsFile .git-blame-ignore-revs + +# style(hub): format TypeScript and scripts with Biome +6b6ad4edc12e7685cc78c1cf0c96b930bc0b4742 diff --git a/.gitattributes b/.gitattributes index 4008199..503ee93 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,14 @@ # Keep bundled license texts byte-identical to upstream on every OS. apps/hub/src-tauri/licenses/*.txt text eol=lf + +# Biome checks LF line endings; keep the files it checks LF on Windows checkouts +# too, so `biome ci` gives the same result with any core.autocrlf setting. +/apps/hub/**/*.ts text eol=lf +/apps/hub/**/*.tsx text eol=lf +/apps/hub/**/*.js text eol=lf +/apps/hub/**/*.mjs text eol=lf +/apps/hub/**/*.cjs text eol=lf +/apps/hub/**/*.css text eol=lf +/apps/hub/biome.json text eol=lf +/apps/hub/src/**/*.json text eol=lf +/apps/hub/scripts/**/*.json text eol=lf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0281a8..88f3cf7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,9 @@ jobs: - name: Install locked frontend dependencies working-directory: apps/hub run: npm ci + - name: Biome lint and format + working-directory: apps/hub + run: npx biome ci - name: Design system doctor working-directory: apps/hub run: npm run ds:doctor diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b919658..d895219 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,14 @@ npm run app:dev See the [README](./README.md#scripts) for the individual frontend and Rust commands. +### Lint and formatting (Biome + Lefthook) + +TypeScript and JavaScript in `apps/hub` (`src/`, `scripts/`, `vite.config.ts` and `vitest.canvas.config.ts`) are linted and formatted by [Biome](https://biomejs.dev) (`apps/hub/biome.json`). CSS is linted but not formatted, because tests assert literal CSS text. CI runs `npx biome ci` in `ci.yml`: any lint error or unformatted file fails the check; warnings do not. + +After `npm ci`, run `npm run hooks:install` from `apps/hub` once per clone to install the [Lefthook](https://lefthook.dev) `pre-push` hook (`lefthook.yml` at the repository root). It is not automatic because npm lifecycle scripts stay off. The hook runs `npx biome ci` and `cargo fmt --all -- --check` before every push. If it fails, run `npm run check:fix` (and `cargo fmt --all` for Rust), commit, and push again. Skipping it with `--no-verify` only moves the failure to CI. + +The repository-wide Biome formatting landed as a formatting-only commit listed in `.git-blame-ignore-revs`; run `git config blame.ignoreRevsFile .git-blame-ignore-revs` once so `git blame` skips it. If you had a branch open before that commit, rebase it on `main` and run `npm run check:fix` to resolve formatting conflicts. + ### Branches and pull requests 1. Create a branch for the agreed issue and keep the change focused. @@ -87,6 +95,14 @@ npm run app:dev Consultad el [README](./README.es.md#scripts) para los comandos individuales del frontend y Rust. +### Lint y formato (Biome + Lefthook) + +El TypeScript y JavaScript de `apps/hub` (`src/`, `scripts/`, `vite.config.ts` y `vitest.canvas.config.ts`) se analizan y formatean con [Biome](https://biomejs.dev) (`apps/hub/biome.json`). El CSS se analiza pero no se formatea, porque hay tests que comprueban su texto literal. CI ejecuta `npx biome ci` en `ci.yml`: cualquier error de lint o archivo sin formatear hace fallar el check; los warnings no. + +Después de `npm ci`, ejecutad una vez por clon `npm run hooks:install` desde `apps/hub` para instalar el hook `pre-push` de [Lefthook](https://lefthook.dev) (`lefthook.yml` en la raíz del repositorio). No es automático porque los scripts de ciclo de vida de npm están desactivados. El hook ejecuta `npx biome ci` y `cargo fmt --all -- --check` antes de cada push. Si falla, ejecutad `npm run check:fix` (y `cargo fmt --all` para Rust), haced commit y volved a hacer push. Saltarlo con `--no-verify` solo traslada el fallo a CI. + +El formato de Biome de todo el repositorio entró como un commit solo de formato listado en `.git-blame-ignore-revs`; ejecutad una vez `git config blame.ignoreRevsFile .git-blame-ignore-revs` para que `git blame` lo omita. Si teníais una rama abierta antes de ese commit, rebasadla sobre `main` y ejecutad `npm run check:fix` para resolver los conflictos de formato. + ### Ramas y pull requests 1. Cread una rama para la issue acordada y mantened el cambio centrado. diff --git a/README.es.md b/README.es.md index 02357da..7a1433a 100644 --- a/README.es.md +++ b/README.es.md @@ -86,6 +86,10 @@ Desde `apps/hub`: | `npm test` | Ejecutar los tests del frontend. | | `npm run ds:doctor` | Comprobar la instalación del design system y ejecutar su protección (elementos sin componente, selectores internos, lista de excepciones). | | `npm run build` | Comprobar TypeScript y compilar el frontend. | +| `npm run check` | Lint y comprobación de formato con Biome (CI ejecuta `npx biome ci`). | +| `npm run check:fix` | Aplicar los arreglos seguros y el formato de Biome. | +| `npm run lint` / `npm run format` | Solo lint de Biome / solo escribir el formato. | +| `npm run hooks:install` | Instalar el hook `pre-push` de Lefthook (una vez por clon). | | `npm run app:dev` | Ejecutar la aplicación de escritorio en desarrollo. | Desde la raíz del repositorio, tras compilar el frontend: diff --git a/README.md b/README.md index 8fbf7e6..8ec32f0 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,10 @@ From `apps/hub`: | `npm test` | Run frontend tests. | | `npm run ds:doctor` | Check the design-system install and run its guard (raw elements, internal selectors, allowlist). | | `npm run build` | Check TypeScript and build the frontend. | +| `npm run check` | Biome lint and format check (CI runs `npx biome ci`). | +| `npm run check:fix` | Apply Biome safe fixes and formatting. | +| `npm run lint` / `npm run format` | Biome lint only / write formatting only. | +| `npm run hooks:install` | Install the Lefthook `pre-push` hook (once per clone). | | `npm run app:dev` | Run the desktop app in development. | From the repository root, after building the frontend: diff --git a/apps/hub/biome.json b/apps/hub/biome.json new file mode 100644 index 0000000..0ec84fb --- /dev/null +++ b/apps/hub/biome.json @@ -0,0 +1,39 @@ +{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "root": "../..", + "useIgnoreFile": true, + "defaultBranch": "main" + }, + "files": { + "includes": ["src/**", "scripts/**", "vite.config.ts", "vitest.canvas.config.ts"] + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 2, + "lineWidth": 160 + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "jsxQuoteStyle": "double" + } + }, + "assist": { + "enabled": false + }, + "linter": { + "enabled": true, + "rules": { + "preset": "recommended" + } + }, + "css": { + "formatter": { + "enabled": false + } + } +} diff --git a/apps/hub/package-lock.json b/apps/hub/package-lock.json index 94afa8e..dc65106 100644 --- a/apps/hub/package-lock.json +++ b/apps/hub/package-lock.json @@ -17,6 +17,7 @@ "react-dom": "^19.1.0" }, "devDependencies": { + "@biomejs/biome": "2.6.8", "@egdev/cli": "file:vendor/egdev-cli-0.1.1-96635dd.tgz", "@egdev/mcp": "file:vendor/egdev-mcp-0.4.6-96635dd.tgz", "@egdev/system": "file:vendor/egdev-system-0.7.0-96635dd.tgz", @@ -26,6 +27,7 @@ "@types/react-dom": "^19.1.0", "@vitejs/plugin-react": "^5.0.0", "jsdom": "^31.0.1", + "lefthook": "2.2.2", "typescript": "^5.9.0", "vite": "^7.1.0", "vitest": "^4.0.0" @@ -323,6 +325,217 @@ "node": ">=6.9.0" } }, + "node_modules/@biomejs/biome": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.6.8.tgz", + "integrity": "sha512-kqZUFvX6/aYQOmzfRN5ANcfNS9wLH4aHLWWP/dQKyhRZVoA6rdWszA7DGugFcxPbMiznUyVYyukVl+ExZN4PQA==", + "dev": true, + "license": "MIT OR Apache-2.0", + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-android-arm64": "2.6.8", + "@biomejs/cli-android-x64": "2.6.8", + "@biomejs/cli-darwin-arm64": "2.6.8", + "@biomejs/cli-darwin-x64": "2.6.8", + "@biomejs/cli-linux-arm64": "2.6.8", + "@biomejs/cli-linux-arm64-musl": "2.6.8", + "@biomejs/cli-linux-x64": "2.6.8", + "@biomejs/cli-linux-x64-musl": "2.6.8", + "@biomejs/cli-win32-arm64": "2.6.8", + "@biomejs/cli-win32-x64": "2.6.8" + } + }, + "node_modules/@biomejs/cli-android-arm64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-android-arm64/-/cli-android-arm64-2.6.8.tgz", + "integrity": "sha512-X4JKPLK85kfUTwuuaORFplnBfGjKkp62PsFhhcL7F/Tpltc7pyUofjlkkMnlZZLWsifFl7LNB8ngVrwJg1uo1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-android-x64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-android-x64/-/cli-android-x64-2.6.8.tgz", + "integrity": "sha512-C3Hk485vl+deEj53K08+SYYelPIPkdSZL3qHuD31Xi+qydVa4q2ze+aCYo1k3iJGWtvWtjHaGkDh7S2sX6wk8w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.6.8.tgz", + "integrity": "sha512-DHyj+JnRHcn4YdvpiqgTFZMYKSPELMCfFpNNlEuu1L8DKTGXhzW7raIwdsbo2Ie9nCljQLAQkVWQk/mwM0ueiA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.6.8.tgz", + "integrity": "sha512-QWWUPjlA0RnkkgYnFLUHZu+RrDc0FdK0A+wEPA+dENQJwsuSHMH89lspnAw2QUWWc9VHyfluGx1Xmp6Y2GZi8Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.6.8.tgz", + "integrity": "sha512-0Bjim8lKwnrvXUHoI4k3Tb51BjoiLEwDnovCI8nSzkk6wj3dShiuAjrx6+X0Hjf4ejR1sRZgTQiSDHlpy9vB7w==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.6.8.tgz", + "integrity": "sha512-WB9PhOitX+bRc0G3+GNJGlvbKoWn3JoB9z4E04JQizIC9aPCQyIvwvWG7QZHxw6k20Fi+dHLmZ2fSEmBa9HqiA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.6.8.tgz", + "integrity": "sha512-XIk3pLQT56I6Tti+u0DF8FtSNXjCMTPbxVTzfJ9cS2t1ImVKvrqV5b52GuEaJg6/wuiXvz0sjfb5saB4TPRjzA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.6.8.tgz", + "integrity": "sha512-64Yzo+J4fEk7Kf9SMnVdVxC+Y2A2e/L86QTP9JjGQ57lsddyELLpbBcNMxSJggre2T1AvISwwSrOApkBAHDqNA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.6.8.tgz", + "integrity": "sha512-ezjCEZzHIWE2pdh83a7zLVcAAcDaERcTcvfA7uWlxqz/1CuDxgtfO19pDg9B6YY4wKYIDvYBw2QCMnqIshSwmw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.6.8.tgz", + "integrity": "sha512-cD6HvGczZUiAYsY8s2TxxXj2AHFzEdMomvVJfEjzOjBM45nGqIDfBpbtvwGQzDCN8X2yKKk9u1jnDZisT2nxIg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, "node_modules/@egdev/cli": { "version": "0.1.1", "resolved": "file:vendor/egdev-cli-0.1.1-96635dd.tgz", @@ -4411,6 +4624,184 @@ "node": ">=6" } }, + "node_modules/lefthook": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook/-/lefthook-2.2.2.tgz", + "integrity": "sha512-37fYHAhL12r1twaEV0PA5TwoIT491eTGGYjhhXxlYNMq3DSkiGZBQ++Jfk5maXj0vq52NRauLtMikBKtbNJs3Q==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "lefthook": "bin/index.js" + }, + "optionalDependencies": { + "lefthook-android-arm64": "2.2.2", + "lefthook-darwin-arm64": "2.2.2", + "lefthook-darwin-x64": "2.2.2", + "lefthook-freebsd-arm64": "2.2.2", + "lefthook-freebsd-x64": "2.2.2", + "lefthook-linux-arm64": "2.2.2", + "lefthook-linux-x64": "2.2.2", + "lefthook-openbsd-arm64": "2.2.2", + "lefthook-openbsd-x64": "2.2.2", + "lefthook-windows-arm64": "2.2.2", + "lefthook-windows-x64": "2.2.2" + } + }, + "node_modules/lefthook-android-arm64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-android-arm64/-/lefthook-android-arm64-2.2.2.tgz", + "integrity": "sha512-wb9rQQFLX7u1dJLxvMrq9VUfMYi5kxM7tJQ6Y4mWEOwaU+SmIm2wjoT/nromKq27Y8fh2Qd7FgCD3G1wfW8CnQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/lefthook-darwin-arm64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-darwin-arm64/-/lefthook-darwin-arm64-2.2.2.tgz", + "integrity": "sha512-6V8D3bLnD/60Xhqn0o2EQD6H3Fe/U9LGkt4WF1O/3eBHbux+5ZJqoH0hfrC+Bi9Dy1Ve1AWxiAY7U2asYl8qVA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/lefthook-darwin-x64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-darwin-x64/-/lefthook-darwin-x64-2.2.2.tgz", + "integrity": "sha512-fH/kArZ9ZZ65wCFtvBMgGcq25qwQpkQ5jp93ba+8wpjgxxzjczYGluwHvM/NQDJWLOFXuKXW0yFs76SramQkyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/lefthook-freebsd-arm64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-freebsd-arm64/-/lefthook-freebsd-arm64-2.2.2.tgz", + "integrity": "sha512-MCRsU01ju989QQffOfS3gCeFfyVDXs5B/FzR65fmrNvqcxb98fldvfzzoAbnK2q6SBJlRT3QT1tNEMCxddCwlA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/lefthook-freebsd-x64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-freebsd-x64/-/lefthook-freebsd-x64-2.2.2.tgz", + "integrity": "sha512-LkKuJU0S2oLimeoHwPTy1TLWB6GcN0t5lLxiXNlsBKUkr6R47QRcvPMZMoXmu3IetQtd+WliXMLE8qTwi2fqBg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/lefthook-linux-arm64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-linux-arm64/-/lefthook-linux-arm64-2.2.2.tgz", + "integrity": "sha512-d+HFtS2DEKaOnD7vRU0tUz8pNgHwsUYmQ22+1dyXpOrXGyzNXR0AqX5KsIRF36JGhVvO5X5Anw5QYgR3mxVSuA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/lefthook-linux-x64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-2.2.2.tgz", + "integrity": "sha512-N/OlQyAhcU6RAXjrwFxLsh70sn96rBoi+XkuLJ8CVBkk9Ci3VDXQayDZTNz5B1xML8RwoMcV8Wblniy1xFOmSA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/lefthook-openbsd-arm64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-openbsd-arm64/-/lefthook-openbsd-arm64-2.2.2.tgz", + "integrity": "sha512-6G/gKXcpIwC+XcODg7ELZYP/hIrVIHQxhy2GoRdVyecmpGMFj+BZo3iqcUmeWusQMuL+UdNexbkrUaeJalIkNw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/lefthook-openbsd-x64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-openbsd-x64/-/lefthook-openbsd-x64-2.2.2.tgz", + "integrity": "sha512-eMJGi3/tqKEqu7XCZlqwQWRtK5JlL/9diaqqgRlEdlRD7GxwzHZN21z6awbITum9emea3lALvXFe6V8odQLGOA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/lefthook-windows-arm64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-windows-arm64/-/lefthook-windows-arm64-2.2.2.tgz", + "integrity": "sha512-4P1EaQb5xG1zhYD1RLJ6TEGdFkmHkB+Slqx6yRDPKuBDNxMiD0+kTAAdUY2E8xPuRR35xHpVPR+b3/HtzPrjQQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/lefthook-windows-x64": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/lefthook-windows-x64/-/lefthook-windows-x64-2.2.2.tgz", + "integrity": "sha512-9Ck4zancQilBfXT3ZeRipm7Lcq4RQfxyMpy8SAVINw0t/BrbjsT25V46ZuziERcwdajnE4myfMzC33GoCBwr7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", diff --git a/apps/hub/package.json b/apps/hub/package.json index d550086..0b0de79 100644 --- a/apps/hub/package.json +++ b/apps/hub/package.json @@ -9,6 +9,11 @@ "test": "vitest run --dir src", "test:ds-adoption": "vitest run --configLoader runner scripts/ds-adoption-report.test.mjs", "canvas": "vitest run --config vitest.canvas.config.ts", + "lint": "biome lint", + "format": "biome format --write", + "check": "biome check", + "check:fix": "biome check --write", + "hooks:install": "lefthook install", "tauri": "tauri", "app:dev": "tauri dev", "ds:doctor": "egdev-ds doctor ." @@ -23,6 +28,8 @@ "react-dom": "^19.1.0" }, "devDependencies": { + "@biomejs/biome": "2.6.8", + "@egdev/cli": "file:vendor/egdev-cli-0.1.1-96635dd.tgz", "@egdev/mcp": "file:vendor/egdev-mcp-0.4.6-96635dd.tgz", "@egdev/system": "file:vendor/egdev-system-0.7.0-96635dd.tgz", "@tauri-apps/cli": "^2.8.0", @@ -31,10 +38,10 @@ "@types/react-dom": "^19.1.0", "@vitejs/plugin-react": "^5.0.0", "jsdom": "^31.0.1", + "lefthook": "2.2.2", "typescript": "^5.9.0", "vite": "^7.1.0", - "vitest": "^4.0.0", - "@egdev/cli": "file:vendor/egdev-cli-0.1.1-96635dd.tgz" + "vitest": "^4.0.0" }, "overrides": { "@egdev/system": "$@egdev/system" diff --git a/apps/hub/scripts/canvas/build.tsx b/apps/hub/scripts/canvas/build.tsx index 2de9ea9..ad33568 100644 --- a/apps/hub/scripts/canvas/build.tsx +++ b/apps/hub/scripts/canvas/build.tsx @@ -14,32 +14,55 @@ const bridge = vi.hoisted(() => ({ receive: undefined as undefined | ((progress: InstallProgress) => void), saved: undefined as any, })); -vi.mock('@tauri-apps/api/core', () => ({ isTauri: () => true, invoke: async (command: string, args?: any) => { - if (command === 'get_settings') return { state: 'ready', settings: bridge.saved }; - if (command === 'save_settings') { bridge.saved = { ...bridge.saved, ...args?.patch }; return bridge.saved; } - if (command === 'plugin:autostart|is_enabled') return true; - if (command === 'get_flyout_state') return { visible: true, sequence: 1, cycle: 1, at: '2026-11-15T10:42:00.000Z' }; - if (command === 'get_flyout_motion') return { phase: 'open', sequence: 1 }; - if (command === 'local_apps_list') return [ - { id: 'local:manual:obs', source: 'local', name: 'OBS Studio', state: 'ready', origin: { kind: 'manual', id: 'obs' } }, - { id: 'local:manual:antena', source: 'local', name: 'Antena local', state: 'ready', origin: { kind: 'manual', id: 'antena' }, duplicateOf: 'antena' }, - { id: 'local:manual:editor', source: 'local', name: 'Editor de vídeo', state: 'missingExecutable', origin: { kind: 'manual', id: 'editor' } }, - ]; - if (command === 'local_catalog_refresh') throw 'nexo.local.catalogUnreadable'; - if (command === 'local_app_icon' || command === 'apply_saved_language') return null; - throw new Error(`Unexpected canvas bridge command: ${command}`); -} })); +vi.mock('@tauri-apps/api/core', () => ({ + isTauri: () => true, + invoke: async (command: string, args?: any) => { + if (command === 'get_settings') return { state: 'ready', settings: bridge.saved }; + if (command === 'save_settings') { + bridge.saved = { ...bridge.saved, ...args?.patch }; + return bridge.saved; + } + if (command === 'plugin:autostart|is_enabled') return true; + if (command === 'get_flyout_state') return { visible: true, sequence: 1, cycle: 1, at: '2026-11-15T10:42:00.000Z' }; + if (command === 'get_flyout_motion') return { phase: 'open', sequence: 1 }; + if (command === 'local_apps_list') + return [ + { id: 'local:manual:obs', source: 'local', name: 'OBS Studio', state: 'ready', origin: { kind: 'manual', id: 'obs' } }, + { id: 'local:manual:antena', source: 'local', name: 'Antena local', state: 'ready', origin: { kind: 'manual', id: 'antena' }, duplicateOf: 'antena' }, + { id: 'local:manual:editor', source: 'local', name: 'Editor de vídeo', state: 'missingExecutable', origin: { kind: 'manual', id: 'editor' } }, + ]; + if (command === 'local_catalog_refresh') throw 'nexo.local.catalogUnreadable'; + if (command === 'local_app_icon' || command === 'apply_saved_language') return null; + throw new Error(`Unexpected canvas bridge command: ${command}`); + }, +})); vi.mock('@tauri-apps/api/event', () => ({ listen: async () => () => {} })); vi.mock('../../src/shell/registry', () => ({ subscribeRegistry: async (publish: (snapshot: unknown) => void) => { - publish({ revision: 1, apps: [{ app: { id: 'quorb', name: 'Quorb', version: '1.2.0' }, capabilities: ['show', 'quit'], unified: true, responsive: true, generation: 1, menu_revision: 0, menu: [] }] }); + publish({ + revision: 1, + apps: [ + { + app: { id: 'quorb', name: 'Quorb', version: '1.2.0' }, + capabilities: ['show', 'quit'], + unified: true, + responsive: true, + generation: 1, + menu_revision: 0, + menu: [], + }, + ], + }); return () => {}; }, exitHubOnly: async () => {}, })); vi.mock('../../src/window', () => ({ backdropAvailable: async () => false, hideFlyout: async () => {} })); vi.mock('../../src/catalog/install', () => ({ - onInstallProgress: async (receive: (progress: InstallProgress) => void) => { bridge.receive = receive; return () => {}; }, + onInstallProgress: async (receive: (progress: InstallProgress) => void) => { + bridge.receive = receive; + return () => {}; + }, installApp: () => new Promise(() => {}), updateApp: () => new Promise(() => {}), cancelInstall: async () => 'cancelled', @@ -50,22 +73,110 @@ const sources = [ { id: 'local-1', label: 'Catálogo de trabajo', kind: 'local' as const, location: 'C:\\Nexo\\catalogo.json' }, ]; const apps: HubApp[] = [ - { id: 'antena', name: 'Antena', description: 'Panel de control para directos.', installed: true, running: false, integration: 'complete', source: 'official', statusKnown: true, installationState: 'installed', version: '1.4.0', canOpen: true }, - { id: 'quorb', name: 'Quorb', description: 'Tu espacio personalizable.', installed: true, running: false, integration: 'complete', source: 'official', statusKnown: true, installationState: 'installed', version: '1.2.0', canOpen: true }, - { id: 'pizarra', name: 'Pizarra', description: 'Organiza tus ideas.', tagline: 'Tus ideas de un vistazo.', tags: ['Ideas', 'Organización'], installed: false, running: false, integration: 'catalog', source: 'official', statusKnown: true, installationState: 'notInstalled' }, - { id: 'cadencia', name: 'Cadencia', description: 'Planifica tus proyectos.', tagline: 'Da ritmo a tus proyectos.', tags: ['Planificación'], installed: false, running: false, integration: 'catalog', source: 'official', statusKnown: true, installationState: 'notInstalled' }, - { id: 'archivo', name: 'Archivo', description: 'Organiza tus recursos.', tagline: 'Todos tus recursos a mano.', tags: ['Recursos'], installed: false, running: false, integration: 'catalog', source: 'official', statusKnown: true, installationState: 'notInstalled' }, + { + id: 'antena', + name: 'Antena', + description: 'Panel de control para directos.', + installed: true, + running: false, + integration: 'complete', + source: 'official', + statusKnown: true, + installationState: 'installed', + version: '1.4.0', + canOpen: true, + }, + { + id: 'quorb', + name: 'Quorb', + description: 'Tu espacio personalizable.', + installed: true, + running: false, + integration: 'complete', + source: 'official', + statusKnown: true, + installationState: 'installed', + version: '1.2.0', + canOpen: true, + }, + { + id: 'pizarra', + name: 'Pizarra', + description: 'Organiza tus ideas.', + tagline: 'Tus ideas de un vistazo.', + tags: ['Ideas', 'Organización'], + installed: false, + running: false, + integration: 'catalog', + source: 'official', + statusKnown: true, + installationState: 'notInstalled', + }, + { + id: 'cadencia', + name: 'Cadencia', + description: 'Planifica tus proyectos.', + tagline: 'Da ritmo a tus proyectos.', + tags: ['Planificación'], + installed: false, + running: false, + integration: 'catalog', + source: 'official', + statusKnown: true, + installationState: 'notInstalled', + }, + { + id: 'archivo', + name: 'Archivo', + description: 'Organiza tus recursos.', + tagline: 'Todos tus recursos a mano.', + tags: ['Recursos'], + installed: false, + running: false, + integration: 'catalog', + source: 'official', + statusKnown: true, + installationState: 'notInstalled', + }, ]; const catalog: Catalog = { schemaVersion: 3, - apps: apps.map(app => ({ id: app.id, name: app.name, tagline: app.tagline ?? app.description, description: app.description, tags: app.tags ?? [], integrationLevel: 'full' as const, - installerUrl: '', latestJsonUrl: '', releasedAt: '2026-11-01T12:00:00Z', featured: false, - version: app.id === 'antena' ? '1.5.0' : '1.0.0', updaterPublicKey: app.id === 'archivo' ? undefined : 'validated-fixture-key', - news: app.id === 'antena' ? [{ id: 'antena-15', title: 'Antena 1.5', text: 'Mejoras de estabilidad y control para tus directos.', publishedAt: '2026-11-14T12:00:00Z', kind: 'update' as const }] : [], + apps: apps.map((app) => ({ + id: app.id, + name: app.name, + tagline: app.tagline ?? app.description, + description: app.description, + tags: app.tags ?? [], + integrationLevel: 'full' as const, + installerUrl: '', + latestJsonUrl: '', + releasedAt: '2026-11-01T12:00:00Z', + featured: false, + version: app.id === 'antena' ? '1.5.0' : '1.0.0', + updaterPublicKey: app.id === 'archivo' ? undefined : 'validated-fixture-key', + news: + app.id === 'antena' + ? [ + { + id: 'antena-15', + title: 'Antena 1.5', + text: 'Mejoras de estabilidad y control para tus directos.', + publishedAt: '2026-11-14T12:00:00Z', + kind: 'update' as const, + }, + ] + : [], })), }; const news: NewsItem[] = [ - { id: 'antena-news', appId: 'antena', badge: 'Actualización', title: 'Antena 1.5', text: 'Más control y estabilidad para tus directos.', cta: 'Ver en el catálogo' }, + { + id: 'antena-news', + appId: 'antena', + badge: 'Actualización', + title: 'Antena 1.5', + text: 'Más control y estabilidad para tus directos.', + cta: 'Ver en el catálogo', + }, { id: 'pizarra-news', appId: 'pizarra', badge: 'Nuevo', title: 'Pizarra', text: 'Organiza tus ideas desde el catálogo.', cta: 'Ver en el catálogo' }, { id: 'cadencia-news', appId: 'cadencia', badge: 'Destacada', title: 'Cadencia', text: 'Planifica tus proyectos a tu ritmo.', cta: 'Ver en el catálogo' }, ]; @@ -75,22 +186,28 @@ const read = (path: string) => readFileSync(resolve(root, path), 'utf8'); const fontPath = resolve(root, 'apps/hub/src/fonts.css'); const fontSheet = postcss.parse(readFileSync(fontPath, 'utf8'), { from: fontPath }); let fontCount = 0; -fontSheet.walkAtRules('font-face', face => face.walkDecls('src', declaration => { - const match = declaration.value.match(/^url\((['"]?)(@fontsource\/[a-z-]+\/files\/[a-z0-9-]+\.woff2)\1\)\s*format\(['"]woff2['"]\)$/); - if (!match) throw new Error('Expected exactly one bundled WOFF2 font source'); - const data = readFileSync(resolve(root, 'apps/hub/node_modules', match[2])).toString('base64'); - declaration.value = `url(data:font/woff2;base64,${data}) format('woff2')`; - fontCount += 1; -})); +fontSheet.walkAtRules('font-face', (face) => + face.walkDecls('src', (declaration) => { + const match = declaration.value.match(/^url\((['"]?)(@fontsource\/[a-z-]+\/files\/[a-z0-9-]+\.woff2)\1\)\s*format\(['"]woff2['"]\)$/); + if (!match) throw new Error('Expected exactly one bundled WOFF2 font source'); + const data = readFileSync(resolve(root, 'apps/hub/node_modules', match[2])).toString('base64'); + declaration.value = `url(data:font/woff2;base64,${data}) format('woff2')`; + fontCount += 1; + }), +); if (!fontCount) throw new Error('No bundled font faces found'); const fontCss = fontSheet.toString(); const appIcon = read('apps/hub/src-tauri/app-icon.svg'); const trayIcon = read('design/nexo-logo/tray.svg'); const contrastCss = read('apps/hub/scripts/canvas/egdev-family-contrast.css'); const cssPaths = [ - 'apps/hub/node_modules/@egdev/tokens/dist/tokens.css', 'apps/hub/node_modules/@egdev/ui/dist/styles.css', - 'apps/hub/src/style.css', 'apps/hub/src/catalog/catalog.css', 'apps/hub/src/news/news.css', - 'apps/hub/src/settings/settings.css', 'apps/hub/src/first-run/first-run.css', + 'apps/hub/node_modules/@egdev/tokens/dist/tokens.css', + 'apps/hub/node_modules/@egdev/ui/dist/styles.css', + 'apps/hub/src/style.css', + 'apps/hub/src/catalog/catalog.css', + 'apps/hub/src/news/news.css', + 'apps/hub/src/settings/settings.css', + 'apps/hub/src/first-run/first-run.css', ]; const width = JSON.parse(read('apps/hub/src-tauri/tauri.conf.json')).app.windows.find((window: any) => window.label === 'main').width as number; // The flyout is flush with the right edge and fills the work area height (position.rs); fail if that changes. @@ -103,29 +220,34 @@ const taskbarHeight = 48; const flyoutHeight = boardHeight - taskbarHeight - margin * 2; function cssUnescape(value: string) { - return value.replace(/\\([\da-fA-F]{1,6}\s?|.)/g, (_, escaped: string) => /^[\da-fA-F]/.test(escaped) ? String.fromCodePoint(parseInt(escaped.trim(), 16)) : escaped); + return value.replace(/\\([\da-fA-F]{1,6}\s?|.)/g, (_, escaped: string) => + /^[\da-fA-F]/.test(escaped) ? String.fromCodePoint(parseInt(escaped.trim(), 16)) : escaped, + ); } function prunedCss(html: string) { // Keep element/attribute selectors, nested rules and keyframes conservatively. - const classes = new Set([...html.matchAll(/class="([^"]*)"/g)].flatMap(match => match[1].split(/\s+/))); - return cssPaths.map(path => { - const sheet = postcss.parse(read(path), { from: path }); - sheet.walkComments(comment => comment.remove()); - sheet.walkRules(rule => { - if (rule.parent?.type === 'atrule' && /keyframes$/i.test(rule.parent.name)) return; - const selectors = rule.selectors.filter(selector => { - if (selector.includes('[') || selector.includes(':root') || selector.includes(':host')) return true; - const found = [...selector.matchAll(/\.((?:\\[\da-fA-F]{1,6}\s?|\\.|[\w-])+)/g)].map(match => cssUnescape(match[1])); - return found.length === 0 || found.some(name => classes.has(name)); + const classes = new Set([...html.matchAll(/class="([^"]*)"/g)].flatMap((match) => match[1].split(/\s+/))); + return cssPaths + .map((path) => { + const sheet = postcss.parse(read(path), { from: path }); + sheet.walkComments((comment) => comment.remove()); + sheet.walkRules((rule) => { + if (rule.parent?.type === 'atrule' && /keyframes$/i.test(rule.parent.name)) return; + const selectors = rule.selectors.filter((selector) => { + if (selector.includes('[') || selector.includes(':root') || selector.includes(':host')) return true; + const found = [...selector.matchAll(/\.((?:\\[\da-fA-F]{1,6}\s?|\\.|[\w-])+)/g)].map((match) => cssUnescape(match[1])); + return found.length === 0 || found.some((name) => classes.has(name)); + }); + if (!selectors.length) rule.remove(); + else rule.selectors = selectors; }); - if (!selectors.length) rule.remove(); - else rule.selectors = selectors; - }); - return `/* ${path.replace('apps/hub/', '')} */\n${sheet.toString()}`; - }).join('\n'); + return `/* ${path.replace('apps/hub/', '')} */\n${sheet.toString()}`; + }) + .join('\n'); } -const bannerPlaceholder = ''; +const bannerPlaceholder = + ''; function capture() { const original = document.querySelector('main.flyout'); @@ -165,12 +287,17 @@ async function mount(firstRun = false, withNews = false) { render( {}} />); await waitFor(() => { if (!document.querySelector('.flyout')) throw new Error('Waiting for flyout'); - if (firstRun ? !screen.queryByRole('button', { name: 'Continuar' }) : !screen.queryByRole('button', { name: 'Ajustes', hidden: true })) throw new Error('Waiting for settings'); + if (firstRun ? !screen.queryByRole('button', { name: 'Continuar' }) : !screen.queryByRole('button', { name: 'Ajustes', hidden: true })) + throw new Error('Waiting for settings'); }); - if (!firstRun) await waitFor(() => { if (!screen.queryByText('OBS Studio') || !bridge.receive) throw new Error('Waiting for local apps and progress'); }); + if (!firstRun) + await waitFor(() => { + if (!screen.queryByText('OBS Studio') || !bridge.receive) throw new Error('Waiting for local apps and progress'); + }); } -const trayGlyph = (paths: string) => ``; +const trayGlyph = (paths: string) => + ``; function wrap(title: string, flyout: string) { const css = `${fontCss}\n${prunedCss(flyout)}`; if (/https?:\/\//.test(css)) throw new Error('Unexpected URL in inlined CSS'); @@ -186,17 +313,28 @@ function wrap(title: string, flyout: string) { } export async function buildArtboards(): Promise<{ file: string; html: string }[]> { - vi.stubGlobal('ResizeObserver', class { observe() {} unobserve() {} disconnect() {} }); + vi.stubGlobal( + 'ResizeObserver', + class { + observe() {} + unobserve() {} + disconnect() {} + }, + ); await mount(); // Cards start collapsed and only one stays open; open the app with an update so its notes show. for (const name of ['Antena']) { - const trigger = [...document.querySelectorAll('.app-card [aria-expanded="false"]')].find(item => item.querySelector('strong')?.textContent === name); + const trigger = [...document.querySelectorAll('.app-card [aria-expanded="false"]')].find( + (item) => item.querySelector('strong')?.textContent === name, + ); if (!trigger) throw new Error(`Missing collapsed app card: ${name}`); fireEvent.click(trigger); } const myApps = capture(); selectTab('Catálogo'); - await waitFor(() => { if ((screen.getByRole('button', { name: 'Instalar Cadencia' }) as HTMLButtonElement).disabled) throw new Error('Waiting for installation connection'); }); + await waitFor(() => { + if ((screen.getByRole('button', { name: 'Instalar Cadencia' }) as HTMLButtonElement).disabled) throw new Error('Waiting for installation connection'); + }); fireEvent.click(screen.getByRole('button', { name: 'Instalar Cadencia' })); act(() => bridge.receive!({ id: 'cadencia', phase: 'downloading', received: 60, total: 100 })); const catalogue = capture(); @@ -207,11 +345,15 @@ export async function buildArtboards(): Promise<{ file: string; html: string }[] fireEvent.click(screen.getByRole('button', { name: 'Ajustes' })); await screen.findByRole('switch', { name: 'Iniciar con Windows' }); const snapshots: Record = { general: capture() }; - selectTab('Apariencia'); snapshots.appearance = capture(); + selectTab('Apariencia'); + snapshots.appearance = capture(); selectTab('Apps locales'); - await waitFor(() => { if (!screen.queryByText('Editor de vídeo')) throw new Error('Waiting for local apps'); }); + await waitFor(() => { + if (!screen.queryByText('Editor de vídeo')) throw new Error('Waiting for local apps'); + }); snapshots.localApps = capture(); - selectTab('Acerca de'); snapshots.about = capture(); + selectTab('Acerca de'); + snapshots.about = capture(); await mount(true); const firstRun = capture(); cleanup(); diff --git a/apps/hub/scripts/canvas/generate.canvas.tsx b/apps/hub/scripts/canvas/generate.canvas.tsx index 15f4ab6..3b4af22 100644 --- a/apps/hub/scripts/canvas/generate.canvas.tsx +++ b/apps/hub/scripts/canvas/generate.canvas.tsx @@ -8,25 +8,33 @@ import { buildArtboards } from './build'; const digest = (value: string) => createHash('sha256').update(value).digest('hex'); const contrastCss = readFileSync(resolve('scripts/canvas/egdev-family-contrast.css'), 'utf8'); const expectedFonts = [ - ...[400, 500, 600, 700, 800].map(weight => ({ family: 'Barlow', packageName: 'barlow', weight })), - ...[400, 600, 700, 800].map(weight => ({ family: 'Barlow Condensed', packageName: 'barlow-condensed', weight })), + ...[400, 500, 600, 700, 800].map((weight) => ({ family: 'Barlow', packageName: 'barlow', weight })), + ...[400, 600, 700, 800].map((weight) => ({ family: 'Barlow Condensed', packageName: 'barlow-condensed', weight })), ].map(({ family, packageName, weight }) => ({ family, style: 'normal', display: 'swap', weight: String(weight), - range: 'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD', - src: digest(`url(data:font/woff2;base64,${readFileSync(resolve(`node_modules/@fontsource/${packageName}/files/${packageName}-latin-${weight}-normal.woff2`)).toString('base64')}) format('woff2')`), + range: + 'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD', + src: digest( + `url(data:font/woff2;base64,${readFileSync(resolve(`node_modules/@fontsource/${packageName}/files/${packageName}-latin-${weight}-normal.woff2`)).toString('base64')}) format('woff2')`, + ), })); it('generates self-contained Windows captures for each real component state and settings tab', async () => { const boards = await buildArtboards(); - expect(boards.map(board => board.file)).toEqual([ - '01-mis-apps.html', '02-catalogo.html', '03-novedades.html', - '04a-ajustes-general.html', '04b-ajustes-apariencia.html', - '04c-ajustes-apps-locales.html', '04d-ajustes-acerca-de.html', '05-primer-uso.html', + expect(boards.map((board) => board.file)).toEqual([ + '01-mis-apps.html', + '02-catalogo.html', + '03-novedades.html', + '04a-ajustes-general.html', + '04b-ajustes-apariencia.html', + '04c-ajustes-apps-locales.html', + '04d-ajustes-acerca-de.html', + '05-primer-uso.html', ]); - const docs = boards.map(board => new DOMParser().parseFromString(board.html, 'text/html')); + const docs = boards.map((board) => new DOMParser().parseFromString(board.html, 'text/html')); for (const [index, doc] of docs.entries()) { expect(doc.documentElement.lang).toBe('es'); expect(doc.querySelector('.flyout')).toBeTruthy(); @@ -36,9 +44,11 @@ it('generates self-contained Windows captures for each real component state and const css = doc.querySelector('style')?.textContent ?? ''; expect(css).toContain('--font-sans: "Barlow", system-ui, sans-serif'); const fonts: { family: string; style: string; display: string; weight: string; range: string; src: string }[] = []; - postcss.parse(css).walkAtRules('font-face', face => { + postcss.parse(css).walkAtRules('font-face', (face) => { const declarations: Record = {}; - face.walkDecls(declaration => { declarations[declaration.prop] = declaration.value; }); + face.walkDecls((declaration) => { + declarations[declaration.prop] = declaration.value; + }); fonts.push({ family: declarations['font-family']?.replace(/^['"]|['"]$/g, ''), style: declarations['font-style'], diff --git a/apps/hub/scripts/check-design-system-mcp.mjs b/apps/hub/scripts/check-design-system-mcp.mjs index b3b47a3..5071685 100644 --- a/apps/hub/scripts/check-design-system-mcp.mjs +++ b/apps/hub/scripts/check-design-system-mcp.mjs @@ -39,11 +39,13 @@ export async function checkDesignSystemMcp() { const { StdioClientTransport } = await import('@modelcontextprotocol/sdk/client/stdio.js'); const transport = new StdioClientTransport({ ...server, cwd: root, stderr: 'pipe' }); let stderr = ''; - transport.stderr?.on('data', chunk => { stderr += chunk.toString(); }); + transport.stderr?.on('data', (chunk) => { + stderr += chunk.toString(); + }); const client = new Client({ name: 'nexo-design-system-check', version: '1.0.0' }); try { await client.connect(transport); - const tools = (await client.listTools()).tools.map(tool => tool.name).sort(); + const tools = (await client.listTools()).tools.map((tool) => tool.name).sort(); assert.deepEqual(tools, expectedTools); const call = async (name, args) => { const result = await client.callTool({ name, arguments: args }); @@ -54,7 +56,7 @@ export async function checkDesignSystemMcp() { }; const list = await call('list_components', {}); assert.ok(list.total > 0); - assert.ok(list.components.some(component => component.name === 'Notice')); + assert.ok(list.components.some((component) => component.name === 'Notice')); const notice = await call('get_component', { name: 'Notice' }); assert.equal(notice.component.name, 'Notice'); const { systemMd } = await call('get_design_system_md', {}); diff --git a/apps/hub/scripts/design-system.test.mjs b/apps/hub/scripts/design-system.test.mjs index bac71d9..851fb9f 100644 --- a/apps/hub/scripts/design-system.test.mjs +++ b/apps/hub/scripts/design-system.test.mjs @@ -6,15 +6,12 @@ import { checkDesignSystemMcp } from './check-design-system-mcp.mjs'; const reference = new URL('../../../design/system.md', import.meta.url); const statusCommit = 'ca11bac'; -const withCommit = (markdown, commit) => markdown.replace( - /^(