Home / File/ add.ts — ui Source File

add.ts — ui Source File

Architecture documentation for add.ts, a typescript file in the ui codebase. 11 imports, 1 dependents.

File typescript FrameworkTooling SchemaValidation 11 imports 1 dependents 5 functions

Entity Profile

Dependency Diagram

graph LR
  670848eb_ec36_f11f_b3df_91f7406ddb11["add.ts"]
  d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5
  81c8b1a1_346a_8b27_dd1e_b8bbb29008b8["api"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> 81c8b1a1_346a_8b27_dd1e_b8bbb29008b8
  2ae56314_aa15_5495_52a2_137787e7b210["constants"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> 2ae56314_aa15_5495_52a2_137787e7b210
  6be7d8a9_c93c_8743_3ef7_968efff25479["handle-error"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> 6be7d8a9_c93c_8743_3ef7_968efff25479
  15e8bad0_00cc_3d96_8e33_2f062120ea7f["highlighter"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> 15e8bad0_00cc_3d96_8e33_2f062120ea7f
  1df8bbed_5110_29f0_12f0_996fc7a1eda1["logger"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> 1df8bbed_5110_29f0_12f0_996fc7a1eda1
  a3e9bc4e_1faf_6261_a1db_396981c7761d["spinner"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> a3e9bc4e_1faf_6261_a1db_396981c7761d
  7d629454_eee6_73fe_2526_919af8d00ef9["commander"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> 7d629454_eee6_73fe_2526_919af8d00ef9
  f9f5e551_eb59_1a6b_8bf2_b97e73eb13de["fs-extra"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> f9f5e551_eb59_1a6b_8bf2_b97e73eb13de
  e68f2c02_595f_e9c2_5917_7a8d47bcfc87["prompts"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> e68f2c02_595f_e9c2_5917_7a8d47bcfc87
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  670848eb_ec36_f11f_b3df_91f7406ddb11 --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  f6f5cf14_e6a1_39ed_ff02_387d541b5757["add-registries.test.ts"]
  f6f5cf14_e6a1_39ed_ff02_387d541b5757 --> 670848eb_ec36_f11f_b3df_91f7406ddb11
  style 670848eb_ec36_f11f_b3df_91f7406ddb11 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import path from "path"
import { getRegistries } from "@/src/registry/api"
import { BUILTIN_REGISTRIES } from "@/src/registry/constants"
import { handleError } from "@/src/utils/handle-error"
import { highlighter } from "@/src/utils/highlighter"
import { logger } from "@/src/utils/logger"
import { spinner } from "@/src/utils/spinner"
import { Command } from "commander"
import fs from "fs-extra"
import prompts from "prompts"
import { z } from "zod"

const addOptionsSchema = z.object({
  cwd: z.string(),
  silent: z.boolean(),
})

export const add = new Command()
  .name("add")
  .description("add registries to your project")
  .argument(
    "[registries...]",
    "registries (@namespace) or registry URLs (@namespace=url)"
  )
  .option(
    "-c, --cwd <cwd>",
    "the working directory. defaults to the current directory.",
    process.cwd()
  )
  .option("-s, --silent", "mute output.", false)
  .action(async (registries: string[], opts) => {
    try {
      const options = addOptionsSchema.parse({
        cwd: path.resolve(opts.cwd),
        silent: opts.silent,
      })

      const registryArgs =
        registries.length > 0
          ? registries
          : await promptForRegistries({ silent: options.silent })

      await addRegistriesToConfig(registryArgs, options.cwd, {
        silent: options.silent,
      })
    } catch (error) {
      logger.break()
      handleError(error)
    }
  })

export function parseRegistryArg(arg: string): {
  namespace: string
  url?: string
} {
  const [namespace, ...rest] = arg.split("=")
  const url = rest.length > 0 ? rest.join("=") : undefined

  if (!namespace.startsWith("@")) {
    throw new Error(
// ... (188 more lines)

Subdomains

Dependencies

  • api
  • commander
  • constants
  • fs-extra
  • handle-error
  • highlighter
  • logger
  • path
  • prompts
  • spinner
  • zod

Frequently Asked Questions

What does add.ts do?
add.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain, SchemaValidation subdomain.
What functions are defined in add.ts?
add.ts defines 5 function(s): add, addRegistriesToConfig, parseRegistryArg, pluralize, promptForRegistries.
What does add.ts depend on?
add.ts imports 11 module(s): api, commander, constants, fs-extra, handle-error, highlighter, logger, path, and 3 more.
What files import add.ts?
add.ts is imported by 1 file(s): add-registries.test.ts.
Where is add.ts in the architecture?
add.ts is located at packages/shadcn/src/commands/registry/add.ts (domain: FrameworkTooling, subdomain: SchemaValidation, directory: packages/shadcn/src/commands/registry).

Analyze Your Own Codebase

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

Try Supermodel Free