ShtukbaseStandard
包文件→ .shtukbase/packages/design-tokens/checks/fresh.ts

checks/fresh.ts

19 行, 1012 B.

文件按包中的原样显示:代码及其注释不做翻译。

  1. // DTK-R02. The CSS of the tokens is up to date: the `out` file of /design/tokens.md is exactly what `build` writes
  2. // from the current tokens. Invalid tokens are DTK-R01's business: this check then stays quiet.
  3. import { existsSync, readFileSync } from 'node:fs';
  4. import { join } from 'node:path';
  5. import { report } from '../../design-base/lib/files.ts';
  6. import { build, config } from '../actions/tokenslib.ts';
  7. export const RULE = { id: 'dtk-r02', title: 'CSS from the tokens is rebuilt' };
  8. export function check(root = process.cwd()): string[] {
  9. const c = config(root);
  10. const { text, problems } = build(root);
  11. if (problems.length) return [];
  12. const p = join(root, c.out);
  13. if (!existsSync(p)) return [`${c.out}: the file is missing — build it: shtuk run design-tokens build`];
  14. 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)`];
  15. }
  16. if (import.meta.main) report(check());