@webdesignhot/design-md 0.4.0 → 0.5.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/package.json +15 -3
- package/src/commands/diff.mjs +21 -2
package/package.json
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webdesignhot/design-md",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Drop any DESIGN.md into your repo in one command. Browse, install, lint, diff, and export design systems extracted from real production sites.",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"design.md",
|
|
7
|
+
"design-system",
|
|
8
|
+
"design-tokens",
|
|
9
|
+
"ai-agents",
|
|
10
|
+
"cli",
|
|
11
|
+
"tailwind",
|
|
12
|
+
"figma",
|
|
13
|
+
"dtcg"
|
|
14
|
+
],
|
|
6
15
|
"author": "webdesignhot",
|
|
7
16
|
"license": "MIT",
|
|
8
17
|
"homepage": "https://www.webdesignhot.com/design.md/",
|
|
9
18
|
"repository": {
|
|
10
19
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/WebDesignHot/design-md"
|
|
20
|
+
"url": "git+https://github.com/WebDesignHot/design-md.git"
|
|
12
21
|
},
|
|
13
22
|
"bin": {
|
|
14
23
|
"design-md": "bin/design-md.mjs"
|
|
@@ -23,6 +32,9 @@
|
|
|
23
32
|
"engines": {
|
|
24
33
|
"node": ">=18"
|
|
25
34
|
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prepublishOnly": "node -e \"const p=require('./package.json');const e=require('child_process').execSync;let r='0.0.0';try{r=e('npm view '+p.name+' version 2>/dev/null').toString().trim()||'0.0.0'}catch(_){};if(p.version===r){console.error('\\n\\x1b[31m✗ '+p.name+'@'+p.version+' already on npm. Bump version before publishing.\\x1b[0m\\n');process.exit(1)}console.log('→ '+p.name+': '+r+' → '+p.version)\""
|
|
37
|
+
},
|
|
26
38
|
"dependencies": {
|
|
27
39
|
"@clack/prompts": "^0.7.0",
|
|
28
40
|
"kleur": "^4.1.5",
|
package/src/commands/diff.mjs
CHANGED
|
@@ -14,6 +14,19 @@ function parseFlags(args) {
|
|
|
14
14
|
return { flags, positional }
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
function flatten(obj, prefix = '') {
|
|
18
|
+
const out = {}
|
|
19
|
+
if (!obj || typeof obj !== 'object') return out
|
|
20
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
21
|
+
const key = prefix ? `${prefix}.${k}` : k
|
|
22
|
+
if (v == null) continue
|
|
23
|
+
if (Array.isArray(v)) out[key] = `[${v.join(', ')}]`
|
|
24
|
+
else if (typeof v === 'object') Object.assign(out, flatten(v, key))
|
|
25
|
+
else out[key] = String(v)
|
|
26
|
+
}
|
|
27
|
+
return out
|
|
28
|
+
}
|
|
29
|
+
|
|
17
30
|
function diffMaps(left, right) {
|
|
18
31
|
const result = { added: {}, removed: {}, modified: {} }
|
|
19
32
|
const keys = new Set([...Object.keys(left), ...Object.keys(right)])
|
|
@@ -39,10 +52,13 @@ export const diff = {
|
|
|
39
52
|
const A = await readDesignMd(resolve(process.cwd(), a))
|
|
40
53
|
const B = await readDesignMd(resolve(process.cwd(), b))
|
|
41
54
|
const colors = diffMaps(flattenColors(A.data), flattenColors(B.data))
|
|
42
|
-
const radii = diffMaps(A.data.radius ?? {}, B.data.radius ?? {})
|
|
55
|
+
const radii = diffMaps(flatten(A.data.radius ?? {}), flatten(B.data.radius ?? {}))
|
|
56
|
+
const typography = diffMaps(flatten(A.data.typography ?? {}), flatten(B.data.typography ?? {}))
|
|
57
|
+
const spacing = diffMaps(flatten(A.data.spacing ?? {}), flatten(B.data.spacing ?? {}))
|
|
58
|
+
const components = diffMaps(flatten(A.data.components ?? {}), flatten(B.data.components ?? {}))
|
|
43
59
|
|
|
44
60
|
if (flags.format === 'json') {
|
|
45
|
-
console.log(JSON.stringify({ colors, radii }, null, 2))
|
|
61
|
+
console.log(JSON.stringify({ colors, radii, typography, spacing, components }, null, 2))
|
|
46
62
|
return
|
|
47
63
|
}
|
|
48
64
|
|
|
@@ -61,5 +77,8 @@ export const diff = {
|
|
|
61
77
|
|
|
62
78
|
printSection('Colors', colors)
|
|
63
79
|
printSection('Radii', radii)
|
|
80
|
+
printSection('Typography', typography)
|
|
81
|
+
printSection('Spacing', spacing)
|
|
82
|
+
printSection('Components', components)
|
|
64
83
|
},
|
|
65
84
|
}
|