Home / File/ package-version.ts — tailwindcss Source File

package-version.ts — tailwindcss Source File

Architecture documentation for package-version.ts, a typescript file in the tailwindcss codebase. 4 imports, 1 dependents.

File typescript UpgradeTool TemplateCodemods 4 imports 1 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  7aec33bf_d5c4_4534_1693_7176d2ba63a9["package-version.ts"]
  23f6b3a5_35d4_6ec7_6321_86d4980b302a["resolve.ts"]
  7aec33bf_d5c4_4534_1693_7176d2ba63a9 --> 23f6b3a5_35d4_6ec7_6321_86d4980b302a
  571a4a03_15e5_5d2a_40a0_219f3f6c9058["resolveJsId"]
  7aec33bf_d5c4_4534_1693_7176d2ba63a9 --> 571a4a03_15e5_5d2a_40a0_219f3f6c9058
  48506443_4a5a_de66_e007_5651d45dd16f["node:fs"]
  7aec33bf_d5c4_4534_1693_7176d2ba63a9 --> 48506443_4a5a_de66_e007_5651d45dd16f
  c2e062aa_797e_e503_7cfb_4d0c938cef09["promises"]
  7aec33bf_d5c4_4534_1693_7176d2ba63a9 --> c2e062aa_797e_e503_7cfb_4d0c938cef09
  5ad596c3_85f0_b158_9c2f_bfb60fe0f1fc["version.ts"]
  5ad596c3_85f0_b158_9c2f_bfb60fe0f1fc --> 7aec33bf_d5c4_4534_1693_7176d2ba63a9
  style 7aec33bf_d5c4_4534_1693_7176d2ba63a9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { readFileSync } from 'node:fs'
import fs from 'node:fs/promises'
import { resolveJsId } from './resolve'

/**
 * Resolves the version string of an npm dependency installed in the based
 * directory.
 */
export async function getPackageVersion(pkg: string, base: string): Promise<string | null> {
  try {
    let packageJson = resolveJsId(`${pkg}/package.json`, base)
    if (!packageJson) return null
    let { version } = JSON.parse(await fs.readFile(packageJson, 'utf8'))
    return version
  } catch {
    return null
  }
}

export function getPackageVersionSync(pkg: string, base: string): string | null {
  try {
    let packageJson = resolveJsId(`${pkg}/package.json`, base)
    if (!packageJson) return null
    let { version } = JSON.parse(readFileSync(packageJson, 'utf8'))
    return version
  } catch {
    return null
  }
}

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does package-version.ts do?
package-version.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the UpgradeTool domain, TemplateCodemods subdomain.
What functions are defined in package-version.ts?
package-version.ts defines 2 function(s): getPackageVersion, getPackageVersionSync.
What does package-version.ts depend on?
package-version.ts imports 4 module(s): node:fs, promises, resolve.ts, resolveJsId.
What files import package-version.ts?
package-version.ts is imported by 1 file(s): version.ts.
Where is package-version.ts in the architecture?
package-version.ts is located at packages/@tailwindcss-upgrade/src/utils/package-version.ts (domain: UpgradeTool, subdomain: TemplateCodemods, directory: packages/@tailwindcss-upgrade/src/utils).

Analyze Your Own Codebase

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

Try Supermodel Free