файл пакета→ .shtukbase/packages/design-lenses/test/fixtures/override.ts
test/fixtures/override.ts
36 строк, 1.4 КБ.
Файл как есть в пакете: код и комментарии в нём не переводятся.
- // The partial package used by the installed-project test and the catalog proof.
- import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
- import { dirname, join } from 'node:path';
- export const BASE = 'shtukbase-ui-html';
- export const OVERRIDE = 'my-ui';
- export const IDS = ['button', 'badge'] as const;
- export const packages = join(import.meta.dir, '../../..');
- export function writeOverride(dest: string) {
- const put = (rel: string, content: string) => {
- const path = join(dest, rel);
- mkdirSync(dirname(path), { recursive: true });
- writeFileSync(path, content);
- };
- put('package.md', `---
- type: Package
- id: my-ui
- version: 0.1.0
- title: Project UI
- requires: {design-components: ^0.1.5, design-tokens: ^0.2.0}
- follows: [design/conventions/component-library]
- ---
- `);
- put('pages/design/my-ui.md', '---\ntype: Page\ntitle: Project UI\n---\n');
- for (const id of IDS) {
- const from = join(packages, BASE, 'pages/design', BASE, 'components/primitive', id, id);
- const to = `pages/design/${OVERRIDE}/components/primitive/${id}/${id}`;
- put(to + '.css', readFileSync(from + '.css', 'utf8').replaceAll('var(--primary)', 'var(--foreground)')
- .replaceAll('var(--primary-foreground)', 'var(--background)') + `
- /* Project UI ${id} */
- .${id}[data-slot="${id}"] { border-radius: 999px; }
- `);
- copyFileSync(from + '.html', join(dest, to + '.html'));
- }
- }