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

checks/fresh.ts

19 行, 1.1 KB.

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

  1. // SBS-R05. The CSS of the style is up to date: /design/shtukbase-style/tokens.css is exactly what `build` writes from
  2. // the style's tokens. Invalid tokens are the business of the design-tokens checks: 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 { buildStyle, CSS, DIR } from '../lib/stylelib.ts';
  7. export const RULE = { id: 'sbs-r05', title: 'The CSS of the style is rebuilt from its tokens' };
  8. export function check(root = process.cwd()): string[] {
  9. if (!existsSync(join(root, DIR))) return [];
  10. const { text, problems } = buildStyle(root);
  11. if (problems.length) return [];
  12. const p = join(root, CSS);
  13. if (!existsSync(p)) return [`${CSS}: the file is missing — build it: shtuk run shtukbase-style build`];
  14. return readFileSync(p, 'utf8') === text ? [] : [`${CSS}: does not match the tokens of the style — rebuild: shtuk run shtukbase-style build (this file is not edited by hand)`];
  15. }
  16. if (import.meta.main) report(check());