Home / File/ update-css-vars.ts — ui Source File

update-css-vars.ts — ui Source File

Architecture documentation for update-css-vars.ts, a typescript file in the ui codebase. 13 imports, 1 dependents.

File typescript FrameworkTooling CLICore 13 imports 1 dependents 18 functions

Entity Profile

Dependency Diagram

graph LR
  09244f5d_7fce_b385_220b_05945bb9e93b["update-css-vars.ts"]
  eac8f98f_e40a_7fe8_f505_372c83d20c7a["fs"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> eac8f98f_e40a_7fe8_f505_372c83d20c7a
  d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5
  a3b2545e_3d8c_699d_ef11_6ab18db14666["schema"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> a3b2545e_3d8c_699d_ef11_6ab18db14666
  b2895591_2a74_d518_deda_2f26be766dcb["get-config"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> b2895591_2a74_d518_deda_2f26be766dcb
  52d51853_b453_3159_f5fc_2e8fcdf57c5f["get-package-info"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> 52d51853_b453_3159_f5fc_2e8fcdf57c5f
  24fd9695_7ceb_b1f6_c84e_e349d5356c12["get-project-info"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> 24fd9695_7ceb_b1f6_c84e_e349d5356c12
  15e8bad0_00cc_3d96_8e33_2f062120ea7f["highlighter"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> 15e8bad0_00cc_3d96_8e33_2f062120ea7f
  a3e9bc4e_1faf_6261_a1db_396981c7761d["spinner"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> a3e9bc4e_1faf_6261_a1db_396981c7761d
  b71db677_2c3f_c5cd_61c3_36109697225a["postcss"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> b71db677_2c3f_c5cd_61c3_36109697225a
  a28e5e74_bee8_fe92_eae8_330535100f05["at-rule"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> a28e5e74_bee8_fe92_eae8_330535100f05
  66e9386d_4b25_170c_221a_e9e57afa3f50["root"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> 66e9386d_4b25_170c_221a_e9e57afa3f50
  89f67ac0_c68e_7b54_1f23_a612feb26502["rule"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> 89f67ac0_c68e_7b54_1f23_a612feb26502
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  09244f5d_7fce_b385_220b_05945bb9e93b --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  a4f8ac42_6df6_4a5d_9e11_18e8114a4567["update-css-vars.test.ts"]
  a4f8ac42_6df6_4a5d_9e11_18e8114a4567 --> 09244f5d_7fce_b385_220b_05945bb9e93b
  style 09244f5d_7fce_b385_220b_05945bb9e93b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { promises as fs } from "fs"
import path from "path"
import {
  registryItemCssVarsSchema,
  registryItemTailwindSchema,
} from "@/src/schema"
import { Config } from "@/src/utils/get-config"
import { getPackageInfo } from "@/src/utils/get-package-info"
import { TailwindVersion } from "@/src/utils/get-project-info"
import { highlighter } from "@/src/utils/highlighter"
import { spinner } from "@/src/utils/spinner"
import postcss from "postcss"
import AtRule from "postcss/lib/at-rule"
import Root from "postcss/lib/root"
import Rule from "postcss/lib/rule"
import { z } from "zod"

export async function updateCssVars(
  cssVars: z.infer<typeof registryItemCssVarsSchema> | undefined,
  config: Config,
  options: {
    cleanupDefaultNextStyles?: boolean
    overwriteCssVars?: boolean
    initIndex?: boolean
    silent?: boolean
    tailwindVersion?: TailwindVersion
    tailwindConfig?: z.infer<typeof registryItemTailwindSchema>["config"]
  }
) {
  if (!config.resolvedPaths.tailwindCss || !Object.keys(cssVars ?? {}).length) {
    return
  }

  options = {
    cleanupDefaultNextStyles: false,
    silent: false,
    tailwindVersion: "v3",
    overwriteCssVars: false,
    initIndex: true,
    ...options,
  }
  const cssFilepath = config.resolvedPaths.tailwindCss
  const cssFilepathRelative = path.relative(
    config.resolvedPaths.cwd,
    cssFilepath
  )
  const cssVarsSpinner = spinner(
    `Updating CSS variables in ${highlighter.info(cssFilepathRelative)}`,
    {
      silent: options.silent,
    }
  ).start()
  const raw = await fs.readFile(cssFilepath, "utf8")
  let output = await transformCssVars(raw, cssVars ?? {}, config, {
    cleanupDefaultNextStyles: options.cleanupDefaultNextStyles,
    tailwindVersion: options.tailwindVersion,
    tailwindConfig: options.tailwindConfig,
    overwriteCssVars: options.overwriteCssVars,
    initIndex: options.initIndex,
  })
// ... (847 more lines)

Subdomains

Dependencies

  • at-rule
  • fs
  • get-config
  • get-package-info
  • get-project-info
  • highlighter
  • path
  • postcss
  • root
  • rule
  • schema
  • spinner
  • zod

Frequently Asked Questions

What does update-css-vars.ts do?
update-css-vars.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain, CLICore subdomain.
What functions are defined in update-css-vars.ts?
update-css-vars.ts defines 18 function(s): addCustomImport, addCustomVariant, addOrUpdateVars, cleanupDefaultNextStylesPlugin, getQuoteType, isColorValue, isLocalHSLValue, removeConflictVars, transformCssVars, updateBaseLayerPlugin, and 8 more.
What does update-css-vars.ts depend on?
update-css-vars.ts imports 13 module(s): at-rule, fs, get-config, get-package-info, get-project-info, highlighter, path, postcss, and 5 more.
What files import update-css-vars.ts?
update-css-vars.ts is imported by 1 file(s): update-css-vars.test.ts.
Where is update-css-vars.ts in the architecture?
update-css-vars.ts is located at packages/shadcn/src/utils/updaters/update-css-vars.ts (domain: FrameworkTooling, subdomain: CLICore, directory: packages/shadcn/src/utils/updaters).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free