From f70c86de832da10e4afb5dd8b1793c7f7e84e05b Mon Sep 17 00:00:00 2001 From: Philzen Date: Sun, 29 Dec 2024 23:11:36 +0100 Subject: [PATCH] fixup! [feature] Generate typed chakra ui theme config file in Typescript projects --- .../commands/setup/ui/libraries/chakra-ui.js | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/cli/src/commands/setup/ui/libraries/chakra-ui.js b/packages/cli/src/commands/setup/ui/libraries/chakra-ui.js index 826db6af0da8..05a999ec0ec8 100644 --- a/packages/cli/src/commands/setup/ui/libraries/chakra-ui.js +++ b/packages/cli/src/commands/setup/ui/libraries/chakra-ui.js @@ -5,7 +5,7 @@ import { Listr } from 'listr2' import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers' -import { getPaths, writeFile } from '../../../../lib' +import { getPaths, transformTSToJS, writeFile } from '../../../../lib' import c from '../../../../lib/colors' import extendStorybookConfiguration from '../../../../lib/configureStorybook.js' import { extendJSXFile, fileIncludes } from '../../../../lib/extendFile' @@ -93,21 +93,18 @@ export async function handler({ force, install }) { { title: `Creating Theme File...`, task: async () => { - const ts = isTypeScriptProject() + const isTs = isTypeScriptProject() const themeFilePath = path.join( rwPaths.web.config, - `chakra.config.${ts ? 'ts' : 'js'}`, + `chakra.config.${isTs ? 'ts' : 'js'}`, + ) + writeFile( + themeFilePath, + isTs + ? CHAKRA_THEME_AND_COMMENTS + : await transformTSToJS(themeFilePath, CHAKRA_THEME_AND_COMMENTS), + { overwriteExisting: force }, ) - writeFile(themeFilePath, CHAKRA_THEME_AND_COMMENTS, { - overwriteExisting: force, - }) - if (ts === false) { - writeFile( - themeFilePath, - await transformTSToJS(themeFilePath, templateContent), - { overwriteExisting: force }, - ) - } }, }, {