包文件→ .shtukbase/packages/design-lenses/actions/build.ts
actions/build.ts
17 行, 908 B.
文件按包中的原样显示:代码及其注释不做翻译。
- // Action `build`: writes lib/design/style.data.js (window.SB_STYLE) from the chosen style of the project, for the
- // lens /design/style.html. The kit itself (lib/kit.js, lib/data.js) is built by `shtuk run lenses build`.
- import { mkdirSync, writeFileSync } from 'node:fs';
- import { dirname, join } from 'node:path';
- import { OUT, buildStyle } from '../lib/project.ts';
- import { styleDataJs } from '../lib/style-data.ts';
- const root = process.cwd();
- const { data, error } = buildStyle(root);
- if (!data) {
- console.log(`design-lenses: ${error}`);
- process.exit(1);
- }
- mkdirSync(dirname(join(root, OUT)), { recursive: true });
- writeFileSync(join(root, OUT), styleDataJs(data));
- for (const p of data.problems) console.log(`design-lenses: ${p}`);
- console.log(`design-lenses: ${OUT} — style ${data.id}, ${data.tokens.length} tokens, ${data.sections.length} sections, ${data.styles.length} styles installed`);