包文件→ .shtukbase/packages/design-tokens/checks/fresh.ts
checks/fresh.ts
19 行, 1012 B.
文件按包中的原样显示:代码及其注释不做翻译。
- // DTK-R02. The CSS of the tokens is up to date: the `out` file of /design/tokens.md is exactly what `build` writes
- // from the current tokens. Invalid tokens are DTK-R01's business: this check then stays quiet.
- import { existsSync, readFileSync } from 'node:fs';
- import { join } from 'node:path';
- import { report } from '../../design-base/lib/files.ts';
- import { build, config } from '../actions/tokenslib.ts';
- export const RULE = { id: 'dtk-r02', title: 'CSS from the tokens is rebuilt' };
- export function check(root = process.cwd()): string[] {
- const c = config(root);
- const { text, problems } = build(root);
- if (problems.length) return [];
- const p = join(root, c.out);
- if (!existsSync(p)) return [`${c.out}: the file is missing — build it: shtuk run design-tokens build`];
- return readFileSync(p, 'utf8') === text ? [] : [`${c.out}: does not match the tokens ${c.source} — rebuild: shtuk run design-tokens build (this file is not edited by hand)`];
- }
- if (import.meta.main) report(check());