utils.ts — ui Source File
Architecture documentation for utils.ts, a typescript file in the ui codebase. 11 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR edc2979a_e040_ab0c_5174_c69f7c8fa905["utils.ts"] 85d52bbd_4b11_bf06_ed3a_d8f77f5fee6d["promises"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> 85d52bbd_4b11_bf06_ed3a_d8f77f5fee6d b80715bf_43eb_b495_f2cf_a439c5eb0e34["os"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> b80715bf_43eb_b495_f2cf_a439c5eb0e34 d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5 a3b2545e_3d8c_699d_ef11_6ab18db14666["schema"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> a3b2545e_3d8c_699d_ef11_6ab18db14666 b2895591_2a74_d518_deda_2f26be766dcb["get-config"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> b2895591_2a74_d518_deda_2f26be766dcb 24fd9695_7ceb_b1f6_c84e_e349d5356c12["get-project-info"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> 24fd9695_7ceb_b1f6_c84e_e349d5356c12 45db7f11_9c93_4005_b06b_e244ebb11d78["resolve-import"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> 45db7f11_9c93_4005_b06b_e244ebb11d78 3e445f1c_e2b0_f7a6_4258_11866c5e5c1f["update-files"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> 3e445f1c_e2b0_f7a6_4258_11866c5e5c1f 4f6f7e78_23ff_4f5f_c723_474454f64c85["ts-morph"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> 4f6f7e78_23ff_4f5f_c723_474454f64c85 67c3fcb7_babc_5ba5_b887_30779f599239["tsconfig-paths"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> 67c3fcb7_babc_5ba5_b887_30779f599239 6802ce19_522d_e5fb_e458_8826d9f6952e["zod"] edc2979a_e040_ab0c_5174_c69f7c8fa905 --> 6802ce19_522d_e5fb_e458_8826d9f6952e d51ab9e0_8488_8598_7079_e383487a0885["utils.test.ts"] d51ab9e0_8488_8598_7079_e383487a0885 --> edc2979a_e040_ab0c_5174_c69f7c8fa905 style edc2979a_e040_ab0c_5174_c69f7c8fa905 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as fs from "fs/promises"
import { tmpdir } from "os"
import * as path from "path"
import {
configSchema,
registryItemFileSchema,
registryItemSchema,
} from "@/src/schema"
import { Config } from "@/src/utils/get-config"
import { ProjectInfo, getProjectInfo } from "@/src/utils/get-project-info"
import { resolveImport } from "@/src/utils/resolve-import"
import {
findCommonRoot,
resolveFilePath,
} from "@/src/utils/updaters/update-files"
import { Project, ScriptKind } from "ts-morph"
import { loadConfig } from "tsconfig-paths"
import { z } from "zod"
const FILE_EXTENSIONS_FOR_LOOKUP = [".tsx", ".ts", ".jsx", ".js", ".css"]
const FILE_PATH_SKIP_LIST = ["lib/utils.ts"]
const DEPENDENCY_SKIP_LIST = [
/^(react|react-dom|next)(\/.*)?$/, // Matches react, react-dom, next and their submodules
/^(node|jsr|npm):.*$/, // Matches node:, jsr:, and npm: prefixed modules
]
const project = new Project({
compilerOptions: {},
})
// This returns the dependency from the module specifier.
// Here dependency means an npm package.
export function getDependencyFromModuleSpecifier(
moduleSpecifier: string
): string | null {
// Skip if the dependency matches any pattern in the skip list
if (DEPENDENCY_SKIP_LIST.some((pattern) => pattern.test(moduleSpecifier))) {
return null
}
// If the module specifier does not start with `@` and has a /, add the dependency first part only.
// E.g. `foo/bar` -> `foo`
if (!moduleSpecifier.startsWith("@") && moduleSpecifier.includes("/")) {
moduleSpecifier = moduleSpecifier.split("/")[0]
}
// For scoped packages, we want to keep the first two parts
// E.g. `@types/react/dom` -> `@types/react`
if (moduleSpecifier.startsWith("@")) {
const parts = moduleSpecifier.split("/")
if (parts.length > 2) {
moduleSpecifier = parts.slice(0, 2).join("/")
}
}
return moduleSpecifier
}
export async function recursivelyResolveFileImports(
filePath: string,
// ... (291 more lines)
Domain
Subdomains
Functions
Dependencies
- get-config
- get-project-info
- os
- path
- promises
- resolve-import
- schema
- ts-morph
- tsconfig-paths
- update-files
- zod
Imported By
Source
Frequently Asked Questions
What does utils.ts do?
utils.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 utils.ts?
utils.ts defines 9 function(s): canDeduplicateFiles, createTempSourceFile, deduplicateFilesByTarget, determineFileType, getDependencyFromModuleSpecifier, isLocalFile, isUniversalRegistryItem, isUrl, recursivelyResolveFileImports.
What does utils.ts depend on?
utils.ts imports 11 module(s): get-config, get-project-info, os, path, promises, resolve-import, schema, ts-morph, and 3 more.
What files import utils.ts?
utils.ts is imported by 1 file(s): utils.test.ts.
Where is utils.ts in the architecture?
utils.ts is located at packages/shadcn/src/registry/utils.ts (domain: FrameworkTooling, subdomain: SchemaValidation, directory: packages/shadcn/src/registry).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free