design-constraint-validator 2.0.1 → 2.2.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 +89 -23
- package/cli/commands/build.d.ts.map +1 -1
- package/cli/commands/build.js +32 -24
- package/cli/commands/build.ts +26 -17
- package/cli/commands/graph.d.ts.map +1 -1
- package/cli/commands/graph.js +35 -18
- package/cli/commands/graph.ts +30 -17
- package/cli/commands/patch-apply.d.ts.map +1 -1
- package/cli/commands/patch-apply.js +4 -1
- package/cli/commands/patch-apply.ts +4 -1
- package/cli/commands/set.d.ts.map +1 -1
- package/cli/commands/set.js +18 -19
- package/cli/commands/set.ts +19 -19
- package/cli/commands/utils.d.ts +1 -0
- package/cli/commands/utils.d.ts.map +1 -1
- package/cli/commands/utils.js +20 -1
- package/cli/commands/utils.ts +23 -1
- package/cli/commands/validate.d.ts.map +1 -1
- package/cli/commands/validate.js +45 -23
- package/cli/commands/validate.ts +47 -26
- package/cli/commands/why.d.ts.map +1 -1
- package/cli/commands/why.js +22 -10
- package/cli/commands/why.ts +20 -9
- package/cli/config-schema.d.ts +171 -166
- package/cli/config-schema.d.ts.map +1 -1
- package/cli/config-schema.js +29 -7
- package/cli/config-schema.ts +31 -7
- package/cli/config.d.ts.map +1 -1
- package/cli/config.js +8 -2
- package/cli/config.ts +8 -2
- package/cli/constraint-registry.d.ts +16 -0
- package/cli/constraint-registry.d.ts.map +1 -1
- package/cli/constraint-registry.js +115 -44
- package/cli/constraint-registry.ts +118 -47
- package/cli/cross-axis-loader.d.ts +62 -0
- package/cli/cross-axis-loader.d.ts.map +1 -1
- package/cli/cross-axis-loader.js +186 -31
- package/cli/cross-axis-loader.ts +199 -24
- package/cli/dcv.js +31 -25
- package/cli/dcv.ts +31 -21
- package/cli/json-output.d.ts +3 -1
- package/cli/json-output.d.ts.map +1 -1
- package/cli/json-output.js +11 -4
- package/cli/json-output.ts +13 -4
- package/cli/types.d.ts +21 -9
- package/cli/types.d.ts.map +1 -1
- package/cli/types.ts +25 -10
- package/cli/validate-api.d.ts +40 -0
- package/cli/validate-api.d.ts.map +1 -0
- package/cli/validate-api.js +90 -0
- package/cli/validate-api.ts +131 -0
- package/core/breakpoints.d.ts +8 -2
- package/core/breakpoints.d.ts.map +1 -1
- package/core/breakpoints.js +24 -3
- package/core/breakpoints.ts +22 -3
- package/core/color.js +4 -4
- package/core/color.ts +4 -4
- package/core/constraints/cross-axis.d.ts.map +1 -1
- package/core/constraints/cross-axis.js +37 -9
- package/core/constraints/cross-axis.ts +37 -9
- package/core/constraints/monotonic-lightness.d.ts.map +1 -1
- package/core/constraints/monotonic-lightness.js +9 -5
- package/core/constraints/monotonic-lightness.ts +9 -4
- package/core/constraints/monotonic.d.ts.map +1 -1
- package/core/constraints/monotonic.js +32 -8
- package/core/constraints/monotonic.ts +29 -8
- package/core/constraints/threshold.d.ts.map +1 -1
- package/core/constraints/threshold.js +24 -4
- package/core/constraints/threshold.ts +23 -4
- package/core/constraints/wcag.d.ts.map +1 -1
- package/core/constraints/wcag.js +7 -1
- package/core/constraints/wcag.ts +7 -1
- package/core/dtcg.d.ts +38 -0
- package/core/dtcg.d.ts.map +1 -0
- package/core/dtcg.js +88 -0
- package/core/dtcg.ts +102 -0
- package/core/engine.d.ts +6 -0
- package/core/engine.d.ts.map +1 -1
- package/core/engine.ts +7 -0
- package/core/flatten.d.ts +5 -3
- package/core/flatten.d.ts.map +1 -1
- package/core/flatten.js +32 -10
- package/core/flatten.ts +48 -16
- package/core/image-export.d.ts.map +1 -1
- package/core/image-export.js +10 -7
- package/core/image-export.ts +9 -6
- package/core/index.d.ts +2 -0
- package/core/index.d.ts.map +1 -1
- package/core/index.js +4 -0
- package/core/index.ts +6 -0
- package/core/poset.d.ts +6 -1
- package/core/poset.d.ts.map +1 -1
- package/core/poset.js +7 -2
- package/core/poset.ts +7 -2
- package/core/why.d.ts +1 -1
- package/core/why.d.ts.map +1 -1
- package/core/why.ts +1 -1
- package/mcp/contracts.d.ts +1561 -0
- package/mcp/contracts.d.ts.map +1 -0
- package/mcp/contracts.js +74 -0
- package/mcp/contracts.ts +105 -0
- package/mcp/index.d.ts +11 -0
- package/mcp/index.d.ts.map +1 -0
- package/mcp/index.js +35 -0
- package/mcp/index.ts +97 -0
- package/mcp/insights.d.ts +94 -0
- package/mcp/insights.d.ts.map +1 -0
- package/mcp/insights.js +445 -0
- package/mcp/insights.ts +541 -0
- package/mcp/tools.d.ts +63 -0
- package/mcp/tools.d.ts.map +1 -0
- package/mcp/tools.js +299 -0
- package/mcp/tools.ts +431 -0
- package/package.json +36 -26
- package/server.json +21 -0
- package/cli/constraints-loader.d.ts.map +0 -1
- package/cli/engine-helpers.d.ts.map +0 -1
- package/core/cross-axis-config.d.ts.map +0 -1
package/cli/dcv.js
CHANGED
|
@@ -2,31 +2,22 @@
|
|
|
2
2
|
// Clean minimal DCV CLI entrypoint
|
|
3
3
|
import yargs from 'yargs/yargs';
|
|
4
4
|
import { hideBin } from 'yargs/helpers';
|
|
5
|
-
import { spawnSync } from 'node:child_process';
|
|
6
|
-
import { createRequire } from 'module';
|
|
7
|
-
import path from 'node:path';
|
|
8
5
|
import { setCommand, buildCommand, validateCommand, graphCommand, whyCommand, patchCommand, patchApplyCommand } from './commands/index.js';
|
|
9
|
-
|
|
10
|
-
(() => {
|
|
11
|
-
const args = process.argv.slice(2);
|
|
12
|
-
if (args[0] === 'graph' && args[1] === 'diff') {
|
|
13
|
-
const pass = args.slice(2);
|
|
14
|
-
const require = createRequire(import.meta.url);
|
|
15
|
-
const tsx = (() => { try {
|
|
16
|
-
return require.resolve('tsx/dist/cli.mjs');
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
return path.resolve('node_modules/tsx/dist/cli.mjs');
|
|
20
|
-
} })();
|
|
21
|
-
const r = spawnSync(process.execPath, [tsx, path.resolve('scripts/graph-diff.ts'), ...pass], { stdio: 'inherit', env: process.env });
|
|
22
|
-
process.exit(r.status ?? 0);
|
|
23
|
-
}
|
|
24
|
-
})();
|
|
6
|
+
import { getVersionInfo } from './version-banner.js';
|
|
25
7
|
const cli = yargs(hideBin(process.argv))
|
|
26
8
|
.scriptName('dcv')
|
|
9
|
+
// camel-case-expansion is intentionally OFF, so the CLI delivers flags only
|
|
10
|
+
// under their kebab key (e.g. argv['dry-run'], never argv.dryRun). Commands
|
|
11
|
+
// read BOTH forms — `options['dry-run'] ?? options.dryRun` — so the same handler
|
|
12
|
+
// works whether invoked by the CLI (kebab) or programmatically/tests (camelCase).
|
|
13
|
+
// Reading only one form silently no-ops for the other caller (TASK-024).
|
|
27
14
|
.parserConfiguration({ 'camel-case-expansion': false })
|
|
28
|
-
.option('quiet', { type: 'boolean' })
|
|
29
|
-
|
|
15
|
+
.option('quiet', { type: 'boolean' })
|
|
16
|
+
.option('config', { type: 'string', describe: 'Path to JSON config file' });
|
|
17
|
+
// `[expressions..]` is OPTIONAL: batch mode (--json / `-` stdin) and unset-only
|
|
18
|
+
// mode (--unset) take no positional, and a mandatory positional made yargs abort
|
|
19
|
+
// before the handler (TASK-032).
|
|
20
|
+
cli.command('set [expressions..]', 'Set token values', y => y
|
|
30
21
|
.positional('expressions', { type: 'string', array: true })
|
|
31
22
|
.option('dry-run', { type: 'boolean', default: false })
|
|
32
23
|
.option('write', { type: 'boolean' })
|
|
@@ -35,6 +26,7 @@ cli.command('set <expressions..>', 'Set token values', y => y
|
|
|
35
26
|
.option('format', { type: 'string', choices: ['json', 'css', 'js'], default: 'json' })
|
|
36
27
|
.option('output', { type: 'string' })
|
|
37
28
|
.option('theme', { type: 'string' })
|
|
29
|
+
.option('debug-set', { type: 'boolean', hidden: true }) // hidden debug aid (also DCV_DEBUG_SET=1)
|
|
38
30
|
.option('tokens', { type: 'string', default: 'tokens/tokens.example.json' }), a => setCommand(a));
|
|
39
31
|
cli.command('build', 'Build token outputs', y => y
|
|
40
32
|
.option('format', { type: 'string', choices: ['css', 'json', 'js'], default: 'css' })
|
|
@@ -43,17 +35,20 @@ cli.command('build', 'Build token outputs', y => y
|
|
|
43
35
|
.option('mapper', { type: 'string' })
|
|
44
36
|
.option('theme', { type: 'string' })
|
|
45
37
|
.option('dry-run', { type: 'boolean', default: false })
|
|
46
|
-
.option('tokens', { type: 'string',
|
|
47
|
-
cli.command('validate', 'Validate constraints', y => y
|
|
38
|
+
.option('tokens', { type: 'string', describe: 'Path to a tokens file (defaults to tokens/tokens.example.json)' }), a => buildCommand(a));
|
|
39
|
+
cli.command('validate [tokens-path]', 'Validate constraints', y => y
|
|
40
|
+
.positional('tokens-path', { type: 'string', describe: 'Path to a tokens file (positional alias for --tokens)' })
|
|
41
|
+
.option('constraints-dir', { type: 'string', describe: 'Directory holding order / cross-axis constraint files (default: themes)' })
|
|
48
42
|
.option('fail-on', { type: 'string', choices: ['off', 'warn', 'error'], default: 'error' })
|
|
49
43
|
.option('summary', { type: 'string', choices: ['none', 'table', 'json'], default: 'none' })
|
|
50
44
|
.option('format', { type: 'string', choices: ['text', 'json'], default: 'text', describe: 'Output format' })
|
|
51
45
|
.option('output', { type: 'string', describe: 'Write JSON output to file' })
|
|
52
46
|
.option('receipt', { type: 'string', describe: 'Generate validation receipt with audit trail' })
|
|
53
|
-
.option('tokens', { type: 'string',
|
|
47
|
+
.option('tokens', { type: 'string', describe: 'Path to a tokens file (defaults to tokens/tokens.example.json)' })
|
|
54
48
|
.option('theme', { type: 'string', describe: 'Apply named theme tokens before validation' })
|
|
55
49
|
.option('breakpoint', { type: 'string' })
|
|
56
50
|
.option('all-breakpoints', { type: 'boolean' })
|
|
51
|
+
.option('cross-axis-debug', { type: 'boolean', hidden: true }) // hidden debug aid
|
|
57
52
|
.option('perf', { type: 'boolean', describe: 'Print timing info' })
|
|
58
53
|
.option('budget-total-ms', { type: 'number', describe: 'Fail if total validation exceeds this (ms)' })
|
|
59
54
|
.option('budget-per-bp-ms', { type: 'number', describe: 'Fail if any single breakpoint exceeds this (ms)' }), a => validateCommand(a));
|
|
@@ -61,6 +56,10 @@ cli.command('graph', 'Generate dependency / constraint graph', y => y
|
|
|
61
56
|
.option('format', { type: 'string', choices: ['json', 'mermaid', 'dot', 'svg', 'png'], default: 'json' })
|
|
62
57
|
.option('bundle', { type: 'boolean', describe: 'When used with --hasse export mermaid+dot (+image if svg/png requested)' })
|
|
63
58
|
.option('hasse', { type: 'string' })
|
|
59
|
+
.option('constraints-dir', { type: 'string', describe: 'Directory holding order / cross-axis constraint files (default: themes). Used with --hasse.' })
|
|
60
|
+
.option('filter', { type: 'string', describe: 'Filter dependency-graph edges by regex (matches either endpoint)' })
|
|
61
|
+
.option('breakpoint', { type: 'string', choices: ['sm', 'md', 'lg'] })
|
|
62
|
+
.option('all-breakpoints', { type: 'boolean' })
|
|
64
63
|
.option('filter-prefix', { type: 'string' })
|
|
65
64
|
.option('exclude-prefix', { type: 'string' })
|
|
66
65
|
.option('only-violations', { type: 'boolean' })
|
|
@@ -68,12 +67,15 @@ cli.command('graph', 'Generate dependency / constraint graph', y => y
|
|
|
68
67
|
.option('label-violations', { type: 'boolean' })
|
|
69
68
|
.option('label-truncate', { type: 'number', default: 0 })
|
|
70
69
|
.option('min-severity', { type: 'string', choices: ['warn', 'error'], default: 'warn' })
|
|
70
|
+
.option('violation-color', { type: 'string', describe: 'Hex color for highlighted violations (default: #ff2d55)' })
|
|
71
|
+
.option('image-from', { type: 'string', choices: ['mermaid', 'dot'], describe: 'Source format for svg/png export (default: mermaid)' })
|
|
71
72
|
.option('focus', { type: 'string' })
|
|
72
73
|
.option('radius', { type: 'number', default: 1 })
|
|
73
|
-
.option('tokens', { type: 'string',
|
|
74
|
+
.option('tokens', { type: 'string', describe: 'Path to a tokens file (defaults to tokens/tokens.example.json)' }), a => graphCommand(a));
|
|
74
75
|
cli.command('why <tokenId>', 'Explain token provenance', y => y
|
|
75
76
|
.positional('tokenId', { type: 'string', demandOption: true })
|
|
76
77
|
.option('format', { type: 'string', choices: ['json', 'table'], default: 'json' })
|
|
78
|
+
.option('constraints-dir', { type: 'string', describe: 'Directory holding order / cross-axis constraint files for the constraint summary (default: themes)' })
|
|
77
79
|
.option('tokens', { type: 'string', default: 'tokens/tokens.example.json' }), a => whyCommand(a));
|
|
78
80
|
cli.command('patch', 'Export patch (diff) from overrides', y => y
|
|
79
81
|
.option('overrides', { type: 'string', describe: 'Path or inline JSON of flat overrides' })
|
|
@@ -85,6 +87,10 @@ cli.command('patch:apply <patch>', 'Apply patch document to tokens', y => y
|
|
|
85
87
|
.option('tokens', { type: 'string', default: 'tokens/tokens.example.json' })
|
|
86
88
|
.option('output', { type: 'string', describe: 'Write updated tokens to this file' })
|
|
87
89
|
.option('dry-run', { type: 'boolean', default: false }), a => patchApplyCommand(a));
|
|
90
|
+
// Wire `--version` to the real package version (same source as the banner).
|
|
91
|
+
// Without this, yargs can't locate package.json from the installed bin and
|
|
92
|
+
// prints "unknown" (TASK-021 release smoke-test finding).
|
|
93
|
+
cli.version(getVersionInfo().version);
|
|
88
94
|
cli.help().alias('h', 'help').strict().wrap(cli.terminalWidth());
|
|
89
95
|
cli.parse();
|
|
90
96
|
// EOF
|
package/cli/dcv.ts
CHANGED
|
@@ -2,30 +2,25 @@
|
|
|
2
2
|
// Clean minimal DCV CLI entrypoint
|
|
3
3
|
import yargs from 'yargs/yargs';
|
|
4
4
|
import { hideBin } from 'yargs/helpers';
|
|
5
|
-
import { spawnSync } from 'node:child_process';
|
|
6
|
-
import { createRequire } from 'module';
|
|
7
|
-
import path from 'node:path';
|
|
8
5
|
import { type SetOptions, type BuildOptions, type ValidateOptions, type GraphOptions, type WhyOptions, type PatchOptions, type PatchApplyOptions } from './types.js';
|
|
9
6
|
import { setCommand, buildCommand, validateCommand, graphCommand, whyCommand, patchCommand, patchApplyCommand } from './commands/index.js';
|
|
10
|
-
|
|
11
|
-
// Early intercept: experimental graph diff helper
|
|
12
|
-
(() => {
|
|
13
|
-
const args = process.argv.slice(2);
|
|
14
|
-
if (args[0] === 'graph' && args[1] === 'diff') {
|
|
15
|
-
const pass = args.slice(2);
|
|
16
|
-
const require = createRequire(import.meta.url);
|
|
17
|
-
const tsx = (() => { try { return require.resolve('tsx/dist/cli.mjs'); } catch { return path.resolve('node_modules/tsx/dist/cli.mjs'); }})();
|
|
18
|
-
const r = spawnSync(process.execPath, [tsx, path.resolve('scripts/graph-diff.ts'), ...pass], { stdio: 'inherit', env: process.env });
|
|
19
|
-
process.exit(r.status ?? 0);
|
|
20
|
-
}
|
|
21
|
-
})();
|
|
7
|
+
import { getVersionInfo } from './version-banner.js';
|
|
22
8
|
|
|
23
9
|
const cli = yargs(hideBin(process.argv))
|
|
24
10
|
.scriptName('dcv')
|
|
11
|
+
// camel-case-expansion is intentionally OFF, so the CLI delivers flags only
|
|
12
|
+
// under their kebab key (e.g. argv['dry-run'], never argv.dryRun). Commands
|
|
13
|
+
// read BOTH forms — `options['dry-run'] ?? options.dryRun` — so the same handler
|
|
14
|
+
// works whether invoked by the CLI (kebab) or programmatically/tests (camelCase).
|
|
15
|
+
// Reading only one form silently no-ops for the other caller (TASK-024).
|
|
25
16
|
.parserConfiguration({ 'camel-case-expansion': false })
|
|
26
|
-
.option('quiet', { type: 'boolean' })
|
|
17
|
+
.option('quiet', { type: 'boolean' })
|
|
18
|
+
.option('config', { type: 'string', describe: 'Path to JSON config file' });
|
|
27
19
|
|
|
28
|
-
|
|
20
|
+
// `[expressions..]` is OPTIONAL: batch mode (--json / `-` stdin) and unset-only
|
|
21
|
+
// mode (--unset) take no positional, and a mandatory positional made yargs abort
|
|
22
|
+
// before the handler (TASK-032).
|
|
23
|
+
cli.command<SetOptions>('set [expressions..]', 'Set token values', y => y
|
|
29
24
|
.positional('expressions', { type: 'string', array: true })
|
|
30
25
|
.option('dry-run', { type: 'boolean', default: false })
|
|
31
26
|
.option('write', { type: 'boolean' })
|
|
@@ -34,6 +29,7 @@ cli.command<SetOptions>('set <expressions..>', 'Set token values', y => y
|
|
|
34
29
|
.option('format', { type: 'string', choices: ['json','css','js'], default: 'json' })
|
|
35
30
|
.option('output', { type: 'string' })
|
|
36
31
|
.option('theme', { type: 'string' })
|
|
32
|
+
.option('debug-set', { type: 'boolean', hidden: true }) // hidden debug aid (also DCV_DEBUG_SET=1)
|
|
37
33
|
.option('tokens', { type: 'string', default: 'tokens/tokens.example.json' }),
|
|
38
34
|
a => setCommand(a)
|
|
39
35
|
);
|
|
@@ -45,20 +41,23 @@ cli.command<BuildOptions>('build', 'Build token outputs', y => y
|
|
|
45
41
|
.option('mapper', { type: 'string' })
|
|
46
42
|
.option('theme', { type: 'string' })
|
|
47
43
|
.option('dry-run', { type: 'boolean', default: false })
|
|
48
|
-
.option('tokens', { type: 'string',
|
|
44
|
+
.option('tokens', { type: 'string', describe: 'Path to a tokens file (defaults to tokens/tokens.example.json)' }),
|
|
49
45
|
a => buildCommand(a)
|
|
50
46
|
);
|
|
51
47
|
|
|
52
|
-
cli.command<ValidateOptions>('validate', 'Validate constraints', y => y
|
|
48
|
+
cli.command<ValidateOptions>('validate [tokens-path]', 'Validate constraints', y => y
|
|
49
|
+
.positional('tokens-path', { type: 'string', describe: 'Path to a tokens file (positional alias for --tokens)' })
|
|
50
|
+
.option('constraints-dir', { type: 'string', describe: 'Directory holding order / cross-axis constraint files (default: themes)' })
|
|
53
51
|
.option('fail-on', { type: 'string', choices: ['off','warn','error'], default: 'error' })
|
|
54
52
|
.option('summary', { type: 'string', choices: ['none','table','json'], default: 'none' })
|
|
55
53
|
.option('format', { type: 'string', choices: ['text','json'], default: 'text', describe: 'Output format' })
|
|
56
54
|
.option('output', { type: 'string', describe: 'Write JSON output to file' })
|
|
57
55
|
.option('receipt', { type: 'string', describe: 'Generate validation receipt with audit trail' })
|
|
58
|
-
.option('tokens', { type: 'string',
|
|
56
|
+
.option('tokens', { type: 'string', describe: 'Path to a tokens file (defaults to tokens/tokens.example.json)' })
|
|
59
57
|
.option('theme', { type: 'string', describe: 'Apply named theme tokens before validation' })
|
|
60
58
|
.option('breakpoint', { type: 'string' })
|
|
61
59
|
.option('all-breakpoints', { type: 'boolean' })
|
|
60
|
+
.option('cross-axis-debug', { type: 'boolean', hidden: true }) // hidden debug aid
|
|
62
61
|
.option('perf', { type: 'boolean', describe: 'Print timing info' })
|
|
63
62
|
.option('budget-total-ms', { type: 'number', describe: 'Fail if total validation exceeds this (ms)' })
|
|
64
63
|
.option('budget-per-bp-ms', { type: 'number', describe: 'Fail if any single breakpoint exceeds this (ms)' }),
|
|
@@ -69,6 +68,10 @@ cli.command<GraphOptions>('graph', 'Generate dependency / constraint graph', y =
|
|
|
69
68
|
.option('format', { type: 'string', choices: ['json','mermaid','dot','svg','png'], default: 'json' })
|
|
70
69
|
.option('bundle', { type: 'boolean', describe: 'When used with --hasse export mermaid+dot (+image if svg/png requested)' })
|
|
71
70
|
.option('hasse', { type: 'string' })
|
|
71
|
+
.option('constraints-dir', { type: 'string', describe: 'Directory holding order / cross-axis constraint files (default: themes). Used with --hasse.' })
|
|
72
|
+
.option('filter', { type: 'string', describe: 'Filter dependency-graph edges by regex (matches either endpoint)' })
|
|
73
|
+
.option('breakpoint', { type: 'string', choices: ['sm','md','lg'] })
|
|
74
|
+
.option('all-breakpoints', { type: 'boolean' })
|
|
72
75
|
.option('filter-prefix', { type: 'string' })
|
|
73
76
|
.option('exclude-prefix', { type: 'string' })
|
|
74
77
|
.option('only-violations', { type: 'boolean' })
|
|
@@ -76,15 +79,18 @@ cli.command<GraphOptions>('graph', 'Generate dependency / constraint graph', y =
|
|
|
76
79
|
.option('label-violations', { type: 'boolean' })
|
|
77
80
|
.option('label-truncate', { type: 'number', default: 0 })
|
|
78
81
|
.option('min-severity', { type: 'string', choices: ['warn','error'], default: 'warn' })
|
|
82
|
+
.option('violation-color', { type: 'string', describe: 'Hex color for highlighted violations (default: #ff2d55)' })
|
|
83
|
+
.option('image-from', { type: 'string', choices: ['mermaid','dot'], describe: 'Source format for svg/png export (default: mermaid)' })
|
|
79
84
|
.option('focus', { type: 'string' })
|
|
80
85
|
.option('radius', { type: 'number', default: 1 })
|
|
81
|
-
.option('tokens', { type: 'string',
|
|
86
|
+
.option('tokens', { type: 'string', describe: 'Path to a tokens file (defaults to tokens/tokens.example.json)' }),
|
|
82
87
|
a => graphCommand(a)
|
|
83
88
|
);
|
|
84
89
|
|
|
85
90
|
cli.command<WhyOptions>('why <tokenId>', 'Explain token provenance', y => y
|
|
86
91
|
.positional('tokenId', { type: 'string', demandOption: true })
|
|
87
92
|
.option('format', { type: 'string', choices: ['json','table'], default: 'json' })
|
|
93
|
+
.option('constraints-dir', { type: 'string', describe: 'Directory holding order / cross-axis constraint files for the constraint summary (default: themes)' })
|
|
88
94
|
.option('tokens', { type: 'string', default: 'tokens/tokens.example.json' }),
|
|
89
95
|
a => whyCommand(a)
|
|
90
96
|
);
|
|
@@ -105,6 +111,10 @@ cli.command<PatchApplyOptions>('patch:apply <patch>', 'Apply patch document to t
|
|
|
105
111
|
a => patchApplyCommand(a)
|
|
106
112
|
);
|
|
107
113
|
|
|
114
|
+
// Wire `--version` to the real package version (same source as the banner).
|
|
115
|
+
// Without this, yargs can't locate package.json from the installed bin and
|
|
116
|
+
// prints "unknown" (TASK-021 release smoke-test finding).
|
|
117
|
+
cli.version(getVersionInfo().version);
|
|
108
118
|
cli.help().alias('h','help').strict().wrap(cli.terminalWidth());
|
|
109
119
|
cli.parse();
|
|
110
120
|
|
package/cli/json-output.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface ValidationResult {
|
|
|
21
21
|
};
|
|
22
22
|
violations: ConstraintViolation[];
|
|
23
23
|
warnings?: ConstraintViolation[];
|
|
24
|
+
/** Set when tokens were validated but no active constraint referenced any of them. */
|
|
25
|
+
note?: string;
|
|
24
26
|
stats: {
|
|
25
27
|
durationMs: number;
|
|
26
28
|
engineVersion: string;
|
|
@@ -57,7 +59,7 @@ export declare function formatViolation(issue: ConstraintIssue): ConstraintViola
|
|
|
57
59
|
/**
|
|
58
60
|
* Generate a ValidationResult from collected issues
|
|
59
61
|
*/
|
|
60
|
-
export declare function createValidationResult(errors: ConstraintIssue[], warnings: ConstraintIssue[], durationMs: number, engineVersion: string): ValidationResult;
|
|
62
|
+
export declare function createValidationResult(errors: ConstraintIssue[], warnings: ConstraintIssue[], durationMs: number, engineVersion: string, note?: string): ValidationResult;
|
|
61
63
|
/**
|
|
62
64
|
* Generate a ValidationReceipt with full audit trail
|
|
63
65
|
*/
|
package/cli/json-output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-output.d.ts","sourceRoot":"","sources":["json-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMzD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACjC,KAAK,EAAE;QACL,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,GAAG,EAAE;QACH,IAAI,EA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C3B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,MAAM,GACZ,gBAAgB,CAqBlB;AAcD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAC/B,iBAAiB,CAoCnB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CASxE"}
|
package/cli/json-output.js
CHANGED
|
@@ -11,19 +11,25 @@ export function formatViolation(issue) {
|
|
|
11
11
|
level: issue.level === 'error' ? 'error' : 'warn',
|
|
12
12
|
message: issue.message,
|
|
13
13
|
};
|
|
14
|
-
if (issue.
|
|
14
|
+
if (issue.involvedTokens?.length) {
|
|
15
|
+
violation.nodes = issue.involvedTokens;
|
|
16
|
+
}
|
|
17
|
+
else if (issue.id) {
|
|
15
18
|
violation.nodes = [issue.id];
|
|
16
19
|
}
|
|
17
20
|
// Add context from where field or other metadata
|
|
18
|
-
if (issue.where) {
|
|
19
|
-
violation.context = {
|
|
21
|
+
if (issue.where || issue.metadata) {
|
|
22
|
+
violation.context = {
|
|
23
|
+
...(issue.where ? { where: issue.where } : {}),
|
|
24
|
+
...(issue.metadata ?? {}),
|
|
25
|
+
};
|
|
20
26
|
}
|
|
21
27
|
return violation;
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* Generate a ValidationResult from collected issues
|
|
25
31
|
*/
|
|
26
|
-
export function createValidationResult(errors, warnings, durationMs, engineVersion) {
|
|
32
|
+
export function createValidationResult(errors, warnings, durationMs, engineVersion, note) {
|
|
27
33
|
const violations = errors.map(formatViolation);
|
|
28
34
|
const warningViolations = warnings.map(formatViolation);
|
|
29
35
|
return {
|
|
@@ -35,6 +41,7 @@ export function createValidationResult(errors, warnings, durationMs, engineVersi
|
|
|
35
41
|
},
|
|
36
42
|
violations,
|
|
37
43
|
warnings: warningViolations.length > 0 ? warningViolations : undefined,
|
|
44
|
+
note,
|
|
38
45
|
stats: {
|
|
39
46
|
durationMs: Math.round(durationMs),
|
|
40
47
|
engineVersion,
|
package/cli/json-output.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface ValidationResult {
|
|
|
27
27
|
};
|
|
28
28
|
violations: ConstraintViolation[];
|
|
29
29
|
warnings?: ConstraintViolation[];
|
|
30
|
+
/** Set when tokens were validated but no active constraint referenced any of them. */
|
|
31
|
+
note?: string;
|
|
30
32
|
stats: {
|
|
31
33
|
durationMs: number;
|
|
32
34
|
engineVersion: string;
|
|
@@ -68,13 +70,18 @@ export function formatViolation(issue: ConstraintIssue): ConstraintViolation {
|
|
|
68
70
|
message: issue.message,
|
|
69
71
|
};
|
|
70
72
|
|
|
71
|
-
if (issue.
|
|
73
|
+
if (issue.involvedTokens?.length) {
|
|
74
|
+
violation.nodes = issue.involvedTokens;
|
|
75
|
+
} else if (issue.id) {
|
|
72
76
|
violation.nodes = [issue.id];
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
// Add context from where field or other metadata
|
|
76
|
-
if (issue.where) {
|
|
77
|
-
violation.context = {
|
|
80
|
+
if (issue.where || issue.metadata) {
|
|
81
|
+
violation.context = {
|
|
82
|
+
...(issue.where ? { where: issue.where } : {}),
|
|
83
|
+
...(issue.metadata ?? {}),
|
|
84
|
+
};
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
return violation;
|
|
@@ -87,7 +94,8 @@ export function createValidationResult(
|
|
|
87
94
|
errors: ConstraintIssue[],
|
|
88
95
|
warnings: ConstraintIssue[],
|
|
89
96
|
durationMs: number,
|
|
90
|
-
engineVersion: string
|
|
97
|
+
engineVersion: string,
|
|
98
|
+
note?: string
|
|
91
99
|
): ValidationResult {
|
|
92
100
|
const violations = errors.map(formatViolation);
|
|
93
101
|
const warningViolations = warnings.map(formatViolation);
|
|
@@ -101,6 +109,7 @@ export function createValidationResult(
|
|
|
101
109
|
},
|
|
102
110
|
violations,
|
|
103
111
|
warnings: warningViolations.length > 0 ? warningViolations : undefined,
|
|
112
|
+
note,
|
|
104
113
|
stats: {
|
|
105
114
|
durationMs: Math.round(durationMs),
|
|
106
115
|
engineVersion,
|
package/cli/types.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export interface SetOptions extends GlobalOptions {
|
|
|
32
32
|
write?: boolean;
|
|
33
33
|
json?: string;
|
|
34
34
|
unset?: string[];
|
|
35
|
+
dryRun?: boolean;
|
|
36
|
+
'dry-run'?: boolean;
|
|
35
37
|
}
|
|
36
38
|
export interface BuildOptions extends GlobalOptions {
|
|
37
39
|
output?: string;
|
|
@@ -40,40 +42,49 @@ export interface BuildOptions extends GlobalOptions {
|
|
|
40
42
|
theme?: string;
|
|
41
43
|
mapper?: string;
|
|
42
44
|
dryRun?: boolean;
|
|
45
|
+
'dry-run'?: boolean;
|
|
43
46
|
allFormats?: boolean;
|
|
47
|
+
'all-formats'?: boolean;
|
|
44
48
|
}
|
|
45
49
|
export interface ValidateOptions extends GlobalOptions {
|
|
46
50
|
strict?: boolean;
|
|
47
51
|
constraints?: string[];
|
|
52
|
+
'tokens-path'?: string;
|
|
53
|
+
'constraints-dir'?: string;
|
|
48
54
|
perf?: boolean;
|
|
49
55
|
budgetTotalMs?: number;
|
|
56
|
+
'budget-total-ms'?: number;
|
|
50
57
|
budgetPerBpMs?: number;
|
|
58
|
+
'budget-per-bp-ms'?: number;
|
|
51
59
|
format?: 'text' | 'json';
|
|
52
60
|
output?: string;
|
|
53
61
|
receipt?: string;
|
|
54
62
|
failOn?: 'off' | 'warn' | 'error';
|
|
63
|
+
'fail-on'?: 'off' | 'warn' | 'error';
|
|
55
64
|
summary?: 'none' | 'table' | 'json';
|
|
56
65
|
}
|
|
57
66
|
export interface GraphOptions extends GlobalOptions {
|
|
58
67
|
output?: string;
|
|
68
|
+
'constraints-dir'?: string;
|
|
59
69
|
format?: 'dot' | 'mermaid' | 'json' | 'svg' | 'png';
|
|
60
|
-
imageFrom?: 'mermaid' | 'dot';
|
|
61
70
|
filter?: string;
|
|
62
71
|
hasse?: string;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
'image-from'?: 'mermaid' | 'dot';
|
|
73
|
+
'filter-prefix'?: string;
|
|
74
|
+
'exclude-prefix'?: string;
|
|
75
|
+
'only-violations'?: boolean;
|
|
76
|
+
'highlight-violations'?: boolean;
|
|
77
|
+
'violation-color'?: string;
|
|
78
|
+
'label-violations'?: boolean;
|
|
79
|
+
'label-truncate'?: number;
|
|
80
|
+
'min-severity'?: 'warn' | 'error';
|
|
71
81
|
focus?: string;
|
|
72
82
|
radius?: number;
|
|
73
83
|
tokens?: string;
|
|
74
84
|
}
|
|
75
85
|
export interface WhyOptions extends GlobalOptions {
|
|
76
86
|
tokenId: string;
|
|
87
|
+
'constraints-dir'?: string;
|
|
77
88
|
format?: 'json' | 'table';
|
|
78
89
|
}
|
|
79
90
|
export interface PatchOptions extends GlobalOptions {
|
|
@@ -87,6 +98,7 @@ export interface PatchApplyOptions extends GlobalOptions {
|
|
|
87
98
|
output?: string;
|
|
88
99
|
tokens?: string;
|
|
89
100
|
dryRun?: boolean;
|
|
101
|
+
'dry-run'?: boolean;
|
|
90
102
|
}
|
|
91
103
|
export type { Breakpoint };
|
|
92
104
|
//# sourceMappingURL=types.d.ts.map
|
package/cli/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAA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AChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AACD,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
package/cli/types.ts
CHANGED
|
@@ -25,6 +25,10 @@ export interface SetOptions extends GlobalOptions {
|
|
|
25
25
|
write?: boolean;
|
|
26
26
|
json?: string;
|
|
27
27
|
unset?: string[];
|
|
28
|
+
// CLI delivers the kebab key (camel-case-expansion off); programmatic callers
|
|
29
|
+
// pass camelCase. Commands read both (TASK-024).
|
|
30
|
+
dryRun?: boolean;
|
|
31
|
+
'dry-run'?: boolean;
|
|
28
32
|
}
|
|
29
33
|
export interface BuildOptions extends GlobalOptions {
|
|
30
34
|
output?: string;
|
|
@@ -33,40 +37,50 @@ export interface BuildOptions extends GlobalOptions {
|
|
|
33
37
|
theme?: string;
|
|
34
38
|
mapper?: string;
|
|
35
39
|
dryRun?: boolean;
|
|
40
|
+
'dry-run'?: boolean;
|
|
36
41
|
allFormats?: boolean;
|
|
42
|
+
'all-formats'?: boolean;
|
|
37
43
|
}
|
|
38
44
|
export interface ValidateOptions extends GlobalOptions {
|
|
39
45
|
strict?: boolean;
|
|
40
46
|
constraints?: string[];
|
|
47
|
+
'tokens-path'?: string;
|
|
48
|
+
'constraints-dir'?: string;
|
|
41
49
|
perf?: boolean;
|
|
42
50
|
budgetTotalMs?: number;
|
|
51
|
+
'budget-total-ms'?: number;
|
|
43
52
|
budgetPerBpMs?: number;
|
|
53
|
+
'budget-per-bp-ms'?: number;
|
|
44
54
|
format?: 'text' | 'json';
|
|
45
55
|
output?: string;
|
|
46
56
|
receipt?: string;
|
|
47
57
|
failOn?: 'off' | 'warn' | 'error';
|
|
58
|
+
'fail-on'?: 'off' | 'warn' | 'error';
|
|
48
59
|
summary?: 'none' | 'table' | 'json';
|
|
49
60
|
}
|
|
50
61
|
export interface GraphOptions extends GlobalOptions {
|
|
51
62
|
output?: string;
|
|
63
|
+
'constraints-dir'?: string;
|
|
52
64
|
format?: 'dot' | 'mermaid' | 'json' | 'svg' | 'png';
|
|
53
|
-
imageFrom?: 'mermaid' | 'dot';
|
|
54
65
|
filter?: string;
|
|
55
66
|
hasse?: string;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
// Kebab keys: the CLI parser runs with camel-case-expansion off.
|
|
68
|
+
'image-from'?: 'mermaid' | 'dot';
|
|
69
|
+
'filter-prefix'?: string;
|
|
70
|
+
'exclude-prefix'?: string;
|
|
71
|
+
'only-violations'?: boolean;
|
|
72
|
+
'highlight-violations'?: boolean;
|
|
73
|
+
'violation-color'?: string;
|
|
74
|
+
'label-violations'?: boolean;
|
|
75
|
+
'label-truncate'?: number;
|
|
76
|
+
'min-severity'?: 'warn' | 'error';
|
|
64
77
|
focus?: string;
|
|
65
78
|
radius?: number;
|
|
66
79
|
tokens?: string;
|
|
67
80
|
}
|
|
68
81
|
export interface WhyOptions extends GlobalOptions {
|
|
69
82
|
tokenId: string;
|
|
83
|
+
'constraints-dir'?: string;
|
|
70
84
|
format?: 'json' | 'table';
|
|
71
85
|
}
|
|
72
86
|
export interface PatchOptions extends GlobalOptions {
|
|
@@ -79,6 +93,7 @@ export interface PatchApplyOptions extends GlobalOptions {
|
|
|
79
93
|
patch: string; // path or inline patch JSON
|
|
80
94
|
output?: string; // where to write updated tokens (if omitted, prints result)
|
|
81
95
|
tokens?: string; // source tokens file (baseline)
|
|
82
|
-
dryRun?: boolean; // if true do not write
|
|
96
|
+
dryRun?: boolean; // if true do not write (programmatic callers)
|
|
97
|
+
'dry-run'?: boolean; // CLI key (camel-case-expansion off)
|
|
83
98
|
}
|
|
84
99
|
export type { Breakpoint };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type TokenNode } from '../core/flatten.js';
|
|
2
|
+
import type { Breakpoint } from '../core/breakpoints.js';
|
|
3
|
+
import { type ConstraintViolation } from './json-output.js';
|
|
4
|
+
import type { DcvConfig } from './types.js';
|
|
5
|
+
export interface ValidateInput {
|
|
6
|
+
/** Inline tokens object (DTCG-style `$value`/`$type`). Takes precedence over `tokensPath`. */
|
|
7
|
+
tokens?: TokenNode;
|
|
8
|
+
/** Path to a tokens file. Used when `tokens` is not provided. */
|
|
9
|
+
tokensPath?: string;
|
|
10
|
+
/** Inline constraints config (the `constraints` block of dcv.config.json). Takes precedence over `configPath`. */
|
|
11
|
+
constraints?: DcvConfig['constraints'];
|
|
12
|
+
/** Path to a config file. When neither `constraints` nor `configPath` is given, a dcv.config.* in cwd is discovered. */
|
|
13
|
+
configPath?: string;
|
|
14
|
+
/** Directory holding order / cross-axis constraint files. Defaults to `themes`. */
|
|
15
|
+
constraintsDir?: string;
|
|
16
|
+
/** Optional breakpoint, selecting `<axis>.<bp>.order.json` / cross-axis variants. */
|
|
17
|
+
breakpoint?: Breakpoint;
|
|
18
|
+
}
|
|
19
|
+
export interface ValidateResult {
|
|
20
|
+
/** True when there are no error-level violations. */
|
|
21
|
+
ok: boolean;
|
|
22
|
+
counts: {
|
|
23
|
+
checked: number;
|
|
24
|
+
violations: number;
|
|
25
|
+
warnings: number;
|
|
26
|
+
};
|
|
27
|
+
violations: ConstraintViolation[];
|
|
28
|
+
warnings: ConstraintViolation[];
|
|
29
|
+
/** Set when tokens were validated but no active constraint referenced any of them. */
|
|
30
|
+
note?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Validate a token set against constraints and return structured results.
|
|
34
|
+
*
|
|
35
|
+
* Unlike the CLI, this treats `tokens` / `tokensPath` as the complete token set
|
|
36
|
+
* (no implicit cwd token overrides), so it is safe to call from a server that
|
|
37
|
+
* cannot share a filesystem with the caller.
|
|
38
|
+
*/
|
|
39
|
+
export declare function validate(input?: ValidateInput): ValidateResult;
|
|
40
|
+
//# sourceMappingURL=validate-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-api.d.ts","sourceRoot":"","sources":["validate-api.ts"],"names":[],"mappings":"AAYA,OAAO,EAAiB,KAAK,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AAEnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,8FAA8F;IAC9F,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kHAAkH;IAClH,WAAW,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IACvC,wHAAwH;IACxH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qFAAqF;IACrF,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA6BD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,GAAE,aAAkB,GAAG,cAAc,CAkDlE"}
|