designlang 1.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -83
- package/bin/design-extract.js +247 -10
- package/package.json +1 -1
- package/skills/extract-design/SKILL.md +52 -25
- package/src/crawler.js +132 -20
- package/src/diff.js +146 -0
- package/src/extractors/accessibility.js +95 -0
- package/src/extractors/interactions.js +128 -0
- package/src/extractors/layout.js +114 -0
- package/src/extractors/responsive.js +132 -0
- package/src/formatters/figma.js +83 -0
- package/src/formatters/markdown.js +183 -1
- package/src/formatters/preview.js +237 -0
- package/src/formatters/theme.js +128 -0
- package/src/history.js +103 -0
- package/src/index.js +15 -0
- package/src/multibrand.js +151 -0
- package/src/sync.js +69 -0
package/src/sync.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Sync command — watch a live site and auto-update local tokens when design changes
|
|
2
|
+
|
|
3
|
+
import { extractDesignLanguage } from './index.js';
|
|
4
|
+
import { formatTokens } from './formatters/tokens.js';
|
|
5
|
+
import { formatTailwind } from './formatters/tailwind.js';
|
|
6
|
+
import { formatCssVars } from './formatters/css-vars.js';
|
|
7
|
+
import { saveSnapshot, getHistory } from './history.js';
|
|
8
|
+
import { writeFileSync, readFileSync, existsSync } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
|
|
11
|
+
export async function syncDesign(url, options = {}) {
|
|
12
|
+
const { out = '.', interval = 3600000 } = options; // default 1 hour
|
|
13
|
+
|
|
14
|
+
const current = await extractDesignLanguage(url, options);
|
|
15
|
+
const history = getHistory(url);
|
|
16
|
+
const previous = history.length > 1 ? history[history.length - 2] : null;
|
|
17
|
+
|
|
18
|
+
const changes = [];
|
|
19
|
+
|
|
20
|
+
if (previous) {
|
|
21
|
+
// Detect changes
|
|
22
|
+
if (previous.colors.primary !== current.colors.primary?.hex) {
|
|
23
|
+
changes.push({ type: 'color', property: 'primary', from: previous.colors.primary, to: current.colors.primary?.hex });
|
|
24
|
+
}
|
|
25
|
+
if (previous.colors.secondary !== current.colors.secondary?.hex) {
|
|
26
|
+
changes.push({ type: 'color', property: 'secondary', from: previous.colors.secondary, to: current.colors.secondary?.hex });
|
|
27
|
+
}
|
|
28
|
+
if (previous.typography.families.join(',') !== current.typography.families.map(f => f.name).join(',')) {
|
|
29
|
+
changes.push({ type: 'typography', property: 'fonts', from: previous.typography.families.join(', '), to: current.typography.families.map(f => f.name).join(', ') });
|
|
30
|
+
}
|
|
31
|
+
if (previous.colors.count !== current.colors.all.length) {
|
|
32
|
+
changes.push({ type: 'color', property: 'count', from: String(previous.colors.count), to: String(current.colors.all.length) });
|
|
33
|
+
}
|
|
34
|
+
if (previous.a11yScore !== current.accessibility?.score) {
|
|
35
|
+
changes.push({ type: 'accessibility', property: 'score', from: `${previous.a11yScore}%`, to: `${current.accessibility?.score}%` });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Save snapshot
|
|
40
|
+
saveSnapshot(current);
|
|
41
|
+
|
|
42
|
+
// Update local files
|
|
43
|
+
const updates = [];
|
|
44
|
+
|
|
45
|
+
const tokensPath = join(out, 'design-tokens.json');
|
|
46
|
+
if (existsSync(tokensPath)) {
|
|
47
|
+
writeFileSync(tokensPath, formatTokens(current), 'utf-8');
|
|
48
|
+
updates.push('design-tokens.json');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const tailwindPath = join(out, 'tailwind.config.js');
|
|
52
|
+
if (existsSync(tailwindPath)) {
|
|
53
|
+
writeFileSync(tailwindPath, formatTailwind(current), 'utf-8');
|
|
54
|
+
updates.push('tailwind.config.js');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const cssPath = join(out, 'variables.css');
|
|
58
|
+
if (existsSync(cssPath)) {
|
|
59
|
+
writeFileSync(cssPath, formatCssVars(current), 'utf-8');
|
|
60
|
+
updates.push('variables.css');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
changes,
|
|
65
|
+
updatedFiles: updates,
|
|
66
|
+
isFirstRun: !previous,
|
|
67
|
+
design: current,
|
|
68
|
+
};
|
|
69
|
+
}
|