Skip to content

Commit 2fcf39c

Browse files
mimarzBarsnes
andauthored
chore(cli): deprecate cli options for theme (#4912)
Co-authored-by: Tobias Barsnes <tobias.barsnes@digdir.no>
1 parent f97f55f commit 2fcf39c

3 files changed

Lines changed: 46 additions & 10 deletions

File tree

.changeset/tame-geese-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@digdir/designsystemet": patch
3+
---
4+
5+
Add deprecation warning for cli options `--main-colors`, `--support-colors`, `--neutral-color`, `--font-family`, `--border-radius` and `--theme`. Use JSON config file instead.

packages/cli/bin/designsystemet.ts

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,57 @@ function makeTokenCommands() {
8383
tokenCmd
8484
.command('create')
8585
.description('Create Designsystemet tokens')
86-
.option(`-m, --${cliOptions.theme.colors.main} <name:hex...>`, `Main colors`, parseColorValues)
87-
.option(`-s, --${cliOptions.theme.colors.support} <name:hex...>`, `Support colors`, parseColorValues)
88-
.option(`-n, --${cliOptions.theme.colors.neutral} <hex>`, `Neutral hex color`, convertToHex)
86+
.option('--config <string>', `Path to config file (default: "${DEFAULT_CONFIG_FILEPATH}")`)
87+
.option(`--${cliOptions.clean} [boolean]`, 'Clean output directory before creating tokens', parseBoolean, false)
88+
.option('--dry [boolean]', `Dry run for created ${pc.blue('design-tokens')}`, parseBoolean, false)
89+
/** Deprecated options */
90+
.option(
91+
`-m, --${cliOptions.theme.colors.main} <name:hex...>`,
92+
`Main colors (deprecated, use JSON config file instead)`,
93+
parseColorValues,
94+
)
95+
.option(
96+
`-s, --${cliOptions.theme.colors.support} <name:hex...>`,
97+
`Support colors (deprecated, use JSON config file instead)`,
98+
parseColorValues,
99+
)
100+
.option(
101+
`-n, --${cliOptions.theme.colors.neutral} <hex>`,
102+
`Neutral hex color (deprecated, use JSON config file instead)`,
103+
convertToHex,
104+
)
89105
.option(
90106
`-o, --${cliOptions.outDir} <string>`,
91107
`Output directory for created ${pc.blue('design-tokens')}`,
92108
DEFAULT_TOKENS_CREATE_DIR,
93109
)
94-
.option(`--${cliOptions.clean} [boolean]`, 'Clean output directory before creating tokens', parseBoolean, false)
95-
.option('--dry [boolean]', `Dry run for created ${pc.blue('design-tokens')}`, parseBoolean, false)
96-
.option(`-f, --${cliOptions.theme.typography.fontFamily} <string>`, `Font family (experimental)`, DEFAULT_FONT)
110+
.option(
111+
`-f, --${cliOptions.theme.typography.fontFamily} <string>`,
112+
`Font family (experimental, deprecated, use JSON config file instead)`,
113+
DEFAULT_FONT,
114+
)
97115
.option(
98116
`-b, --${cliOptions.theme.borderRadius} <number>`,
99-
`Unitless base border-radius in px`,
117+
`Unitless base border-radius in px (deprecated, use JSON config file instead)`,
100118
(radiusAsString) => Number(radiusAsString),
101119
4,
102120
)
103-
.option('--theme <string>', 'Theme name (ignored when using JSON config file)', DEFAULT_THEME_NAME)
104-
.option('--config <string>', `Path to config file (default: "${DEFAULT_CONFIG_FILEPATH}")`)
121+
.option('--theme <string>', 'Theme name (deprecated, use JSON config file instead)', DEFAULT_THEME_NAME)
105122
.action(async (opts, cmd) => {
123+
if (
124+
opts.mainColors ||
125+
opts.supportColors ||
126+
opts.neutralColor ||
127+
(opts.borderRadius && opts.borderRadius !== 4) ||
128+
(opts.theme && opts.theme !== DEFAULT_THEME_NAME) ||
129+
(opts.fontFamily && opts.fontFamily !== DEFAULT_FONT)
130+
) {
131+
console.warn(
132+
pc.yellow(`\n ⚠️ Using CLI options for ${pc.bold(`colors, border radius, theme, or font family is deprecated`)} and will be removed in a future release.
133+
\n ⚠️ Please use a JSON config file instead.`),
134+
);
135+
}
136+
106137
console.log(figletAscii);
107138
if (opts.dry) {
108139
console.log(`Performing dry run, no files will be written`);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "@digdir/designsystemet",
3-
"version": "1.13.2"
3+
"version": "1.14.0"
44
}

0 commit comments

Comments
 (0)