@design-token-kit/cli 0.3.0 → 0.3.2

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.
Files changed (3) hide show
  1. package/README.md +113 -35
  2. package/bin/index.mjs +3 -4
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,18 +1,29 @@
1
1
  # @design-token-kit/cli
2
2
 
3
- Command line interface for Design Token Kit.
4
-
5
- It provides commands to:
6
-
7
- - validate design tokens
8
- - convert between DTCG JSON, HRDT YAML, and CSS
9
- - generate HTML showcase pages
3
+ The CLI package of Design Token Kit provides the `dtokens` command for
4
+ validating, converting, and previewing design tokens from the terminal.
5
+
6
+ ## Features
7
+
8
+ * **DTCG 2025.10 validation** - schema validation for DTCG JSON token
9
+ documents
10
+ * **Semantic checks** - unresolved references, circular references,
11
+ group references, type mismatches, and deprecated token usage
12
+ * **HRDT YAML support** - a compact, human-readable alternative to
13
+ DTCG JSON
14
+ * **Token format conversion** - read and write DTCG JSON and HRDT YAML
15
+ * **CSS generation** - base and theme token sets rendered as CSS
16
+ custom properties
17
+ * **Static showcase** - HTML showcase generation from token sources or
18
+ existing CSS
19
+ * **Source abstraction** - local files, stdin, URLs, and raw token
20
+ content strings
10
21
 
11
22
  Node.js 18 or newer is required.
12
23
 
13
24
  ## Install
14
25
 
15
- Run without installation:
26
+ Run without installing:
16
27
 
17
28
  ```bash
18
29
  npx @design-token-kit/cli validate tokens.json
@@ -22,64 +33,131 @@ Install globally:
22
33
 
23
34
  ```bash
24
35
  npm install -g @design-token-kit/cli
25
- dtokens validate tokens.json
36
+ dtokens --version
26
37
  ```
27
38
 
28
- Install as a local dependency:
39
+ Install locally:
29
40
 
30
41
  ```bash
31
42
  npm install @design-token-kit/cli
32
43
  ```
33
44
 
34
- Show CLI version:
45
+ ## Quick Start
35
46
 
36
47
  ```bash
37
- dtokens -v
38
- dtokens --version
48
+ dtokens validate tokens.json
49
+ dtokens convert tokens.yaml --inform hrdt --outform css --out ./tokens.css
50
+ dtokens showcase tokens.json --out ./showcase.html --open
39
51
  ```
40
52
 
53
+ ## Input Formats
54
+
55
+ ### DTCG JSON
56
+
57
+ Use DTCG JSON token documents as the canonical source format for
58
+ validation, conversion, CSS generation, and showcase generation.
59
+
60
+ ### HRDT YAML
61
+
62
+ Use HRDT YAML as a compact, human-readable alternative to DTCG JSON.
63
+
64
+ ### Base and theme sources
65
+
66
+ When multiple token sources are provided, the first source is treated
67
+ as the base token set and the remaining sources are treated as theme
68
+ overrides.
69
+
70
+ ### Stdin
71
+
72
+ Pass `-` or omit source arguments to read from standard input.
73
+
74
+ ## Output Formats
75
+
76
+ ### CSS custom properties
77
+
78
+ Generate CSS variables from token sources. Base tokens are emitted
79
+ under `:root`; theme overrides are emitted under
80
+ `:root[data-theme="<theme>"]`.
81
+
82
+ ### HTML showcase
83
+
84
+ Generate a static HTML preview from DTCG JSON, HRDT YAML, or existing
85
+ CSS custom properties.
86
+
87
+ ### Serialized token documents
88
+
89
+ Convert token documents between DTCG JSON and HRDT YAML.
90
+
41
91
  ## Commands
42
92
 
43
- ### `validate`
93
+ | Command | Description |
94
+ | --- | --- |
95
+ | `validate [files...]` | Validate DTCG JSON or HRDT YAML token files. |
96
+ | `convert [options] [files...]` | Convert a token file to DTCG JSON, HRDT YAML, or CSS. |
97
+ | `showcase [options] [files...]` | Create HTML showcase from DTCG JSON, HRDT YAML, or CSS. |
98
+
99
+ ## Options
100
+
101
+ ### convert
44
102
 
45
- Validate one or more DTCG JSON or HRDT YAML token files.
103
+ | Option | Description |
104
+ | --- | --- |
105
+ | `-i, --inform [format]` | Input format: `dtcg`, `hrdt` |
106
+ | `-f, --outform [format]` | Output format: `dtcg`, `hrdt`, `css` |
107
+ | `-o, --out [file]` | Output file, defaults to stdout |
108
+
109
+ ### showcase
110
+
111
+ | Option | Description |
112
+ | --- | --- |
113
+ | `-o, --out <file>` | Output HTML file name or path |
114
+ | `--open` | Open the generated HTML in browser, only with `--out` |
115
+
116
+ ## Validation
117
+
118
+ Validate one or more DTCG JSON or HRDT YAML token sources.
46
119
 
47
120
  ```bash
48
121
  dtokens validate tokens.json
49
122
  dtokens validate tokens.yaml
123
+ dtokens validate tokens.yaml tokens.dark.yaml
50
124
  ```
51
125
 
52
- ### `convert`
53
-
54
- Convert a token file to DTCG JSON, HRDT YAML, or CSS.
126
+ ## Document Conversion
55
127
 
56
- Defaults:
57
-
58
- - `--inform` defaults to `dtcg`
59
- - `--outform` defaults to `css`
128
+ Convert token documents between DTCG JSON and HRDT YAML.
60
129
 
61
130
  ```bash
62
- dtokens convert tokens.json
63
- dtokens convert tokens.yaml --inform hrdt --outform css --out ./dist/tokens.css
64
131
  dtokens convert tokens.json --outform hrdt
132
+ dtokens convert tokens.yaml --inform hrdt --outform dtcg
65
133
  ```
66
134
 
67
- Options:
135
+ Use `--out` to write the result to a file instead of stdout.
136
+
137
+ ```bash
138
+ dtokens convert tokens.json --outform hrdt --out tokens.yaml
139
+ ```
68
140
 
69
- - `--inform <format>`: input format override, `dtcg` or `hrdt`
70
- - `--outform <format>`: output format, `dtcg`, `hrdt`, or `css`
71
- - `--out <file>`: write output to a file instead of stdout
141
+ Multiple input sources are only supported when `--outform css`.
72
142
 
73
- ### `showcase`
143
+ ## CSS Conversion
74
144
 
75
- Generate an HTML showcase from token files or CSS.
145
+ Convert a base token set and optional theme overrides to CSS custom
146
+ properties.
76
147
 
77
148
  ```bash
78
- dtokens showcase tokens.yaml --out ./dist/showcase.html
149
+ dtokens convert tokens.json
150
+ dtokens convert tokens.yaml --inform hrdt --outform css
151
+ dtokens convert tokens.json tokens.dark.json --out ./tokens.css
79
152
  ```
80
153
 
81
- ## Supported Formats
154
+ ## HTML Showcase
155
+
156
+ Generate an HTML showcase from token sources or from a single CSS
157
+ source.
82
158
 
83
- - `dtcg` - Design Tokens Community Group JSON format
84
- - `hrdt` - Human-Readable Design Tokens YAML format
85
- - `css` - CSS custom properties output
159
+ ```bash
160
+ dtokens showcase tokens.yaml --out ./showcase.html
161
+ dtokens showcase tokens.css --out ./showcase.html
162
+ dtokens showcase - < tokens.yaml
163
+ ```
package/bin/index.mjs CHANGED
@@ -121,14 +121,13 @@ import { writeFile as writeFile2 } from "fs/promises";
121
121
  import { spawn } from "child_process";
122
122
  import path from "path";
123
123
  import { tmpdir } from "os";
124
- import { Source, createTokenHtmlShowcase } from "@design-token-kit/core";
124
+ import { createTokenHtmlShowcase } from "@design-token-kit/core";
125
125
  var EXIT_FAILURE3 = 1;
126
126
  var showcaseCommand = new Command3("showcase").description("Create HTML showcase from DTCG JSON, HRDT YAML, or CSS.").argument("[files...]", "Paths to token JSON, HRDT, or CSS files (reads from stdin when omitted)").option("-o, --out <file>", "Output HTML file name or path").option("--open", "Open the generated HTML in browser (only with --out)").addHelpText("after", "\nExit status:\n 0 success\n 1 showcase failed").action(async (files, options) => {
127
127
  try {
128
128
  const showcase = createTokenHtmlShowcase();
129
- const sources = (files.length > 0 ? files : ["-"]).map((f) => new Source(f));
130
- const filePaths = await Promise.all(sources.map((s) => s.getFile()));
131
- const html = await showcase.showcase(filePaths);
129
+ const sources = files.length > 0 ? files : ["-"];
130
+ const html = await showcase.showcase(sources);
132
131
  if (options.out) {
133
132
  const targetFile = resolveOutputPath(options.out);
134
133
  await writeFile2(targetFile, html);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-token-kit/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "CLI for Design Token Kit: validate, convert, showcase.",
5
5
  "keywords": [
6
6
  "design-tokens",
@@ -42,7 +42,7 @@
42
42
  "test": "vitest run"
43
43
  },
44
44
  "dependencies": {
45
- "@design-token-kit/core": "0.3.0",
45
+ "@design-token-kit/core": "0.3.2",
46
46
  "commander": "14.0.1"
47
47
  },
48
48
  "devDependencies": {