diff --git a/.changeset/tame-geese-cover.md b/.changeset/tame-geese-cover.md new file mode 100644 index 0000000000..c4097bc974 --- /dev/null +++ b/.changeset/tame-geese-cover.md @@ -0,0 +1,5 @@ +--- +"@digdir/designsystemet": patch +--- + +Add deprecation warning for cli options `--main-colors`, `--support-colors`, `--neutral-color`, `--font-family`, `--border-radius` and `--theme`. Use JSON config file instead. diff --git a/packages/cli/bin/designsystemet.ts b/packages/cli/bin/designsystemet.ts index fbc6b3cc0d..5d5f3a6361 100644 --- a/packages/cli/bin/designsystemet.ts +++ b/packages/cli/bin/designsystemet.ts @@ -83,26 +83,57 @@ function makeTokenCommands() { tokenCmd .command('create') .description('Create Designsystemet tokens') - .option(`-m, --${cliOptions.theme.colors.main} `, `Main colors`, parseColorValues) - .option(`-s, --${cliOptions.theme.colors.support} `, `Support colors`, parseColorValues) - .option(`-n, --${cliOptions.theme.colors.neutral} `, `Neutral hex color`, convertToHex) + .option('--config ', `Path to config file (default: "${DEFAULT_CONFIG_FILEPATH}")`) + .option(`--${cliOptions.clean} [boolean]`, 'Clean output directory before creating tokens', parseBoolean, false) + .option('--dry [boolean]', `Dry run for created ${pc.blue('design-tokens')}`, parseBoolean, false) + /** Deprecated options */ + .option( + `-m, --${cliOptions.theme.colors.main} `, + `Main colors (deprecated, use JSON config file instead)`, + parseColorValues, + ) + .option( + `-s, --${cliOptions.theme.colors.support} `, + `Support colors (deprecated, use JSON config file instead)`, + parseColorValues, + ) + .option( + `-n, --${cliOptions.theme.colors.neutral} `, + `Neutral hex color (deprecated, use JSON config file instead)`, + convertToHex, + ) .option( `-o, --${cliOptions.outDir} `, `Output directory for created ${pc.blue('design-tokens')}`, DEFAULT_TOKENS_CREATE_DIR, ) - .option(`--${cliOptions.clean} [boolean]`, 'Clean output directory before creating tokens', parseBoolean, false) - .option('--dry [boolean]', `Dry run for created ${pc.blue('design-tokens')}`, parseBoolean, false) - .option(`-f, --${cliOptions.theme.typography.fontFamily} `, `Font family (experimental)`, DEFAULT_FONT) + .option( + `-f, --${cliOptions.theme.typography.fontFamily} `, + `Font family (experimental, deprecated, use JSON config file instead)`, + DEFAULT_FONT, + ) .option( `-b, --${cliOptions.theme.borderRadius} `, - `Unitless base border-radius in px`, + `Unitless base border-radius in px (deprecated, use JSON config file instead)`, (radiusAsString) => Number(radiusAsString), 4, ) - .option('--theme ', 'Theme name (ignored when using JSON config file)', DEFAULT_THEME_NAME) - .option('--config ', `Path to config file (default: "${DEFAULT_CONFIG_FILEPATH}")`) + .option('--theme ', 'Theme name (deprecated, use JSON config file instead)', DEFAULT_THEME_NAME) .action(async (opts, cmd) => { + if ( + opts.mainColors || + opts.supportColors || + opts.neutralColor || + (opts.borderRadius && opts.borderRadius !== 4) || + (opts.theme && opts.theme !== DEFAULT_THEME_NAME) || + (opts.fontFamily && opts.fontFamily !== DEFAULT_FONT) + ) { + console.warn( + 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. + \n ⚠️ Please use a JSON config file instead.`), + ); + } + console.log(figletAscii); if (opts.dry) { console.log(`Performing dry run, no files will be written`); diff --git a/packages/cli/tests/config/design-tokens/$designsystemet.jsonc b/packages/cli/tests/config/design-tokens/$designsystemet.jsonc index 2bc470b385..b982a9f27f 100644 --- a/packages/cli/tests/config/design-tokens/$designsystemet.jsonc +++ b/packages/cli/tests/config/design-tokens/$designsystemet.jsonc @@ -1,4 +1,4 @@ { "name": "@digdir/designsystemet", - "version": "1.13.2" + "version": "1.14.0" } \ No newline at end of file