Home / File/ packages.ts — tailwindcss Source File

packages.ts — tailwindcss Source File

Architecture documentation for packages.ts, a typescript file in the tailwindcss codebase. 10 imports, 2 dependents.

File typescript CommandLineInterface Renderer 10 imports 2 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  3570f589_2f69_c1ce_f4d4_16edf9b89280["packages.ts"]
  28a2f72d_350c_6647_bf9d_77c69e637045["default-map.ts"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> 28a2f72d_350c_6647_bf9d_77c69e637045
  cfb4af0e_7b2d_34a1_693a_90088443cfec["DefaultMap"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> cfb4af0e_7b2d_34a1_693a_90088443cfec
  2329d36e_5aa2_4fa5_cf9f_a9c6cc4e1277["renderer.ts"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> 2329d36e_5aa2_4fa5_cf9f_a9c6cc4e1277
  6c5b3bb2_4069_e0af_8887_216e1c995446["error"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> 6c5b3bb2_4069_e0af_8887_216e1c995446
  f01ffd27_4737_8e3c_147a_bc30c19a4b4d["warn"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> f01ffd27_4737_8e3c_147a_bc30c19a4b4d
  69c3e246_0d60_1a3b_6419_4c423b01252f["node:child_process"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> 69c3e246_0d60_1a3b_6419_4c423b01252f
  9c72d32d_a535_69d4_565b_b620ce2eaae1["node:fs"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> 9c72d32d_a535_69d4_565b_b620ce2eaae1
  b75e8457_6610_e7ce_eeaf_9a1dd10fc510["promises"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> b75e8457_6610_e7ce_eeaf_9a1dd10fc510
  89aef3dd_1eed_c141_d425_b8949215a653["node:path"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> 89aef3dd_1eed_c141_d425_b8949215a653
  f909665b_1fad_0830_f03c_620b7c9464c3["node:util"]
  3570f589_2f69_c1ce_f4d4_16edf9b89280 --> f909665b_1fad_0830_f03c_620b7c9464c3
  9434c276_afef_dc51_650b_a8b408f077fc["migrate-postcss.ts"]
  9434c276_afef_dc51_650b_a8b408f077fc --> 3570f589_2f69_c1ce_f4d4_16edf9b89280
  f3e20782_7a7a_6d07_0472_a959db30007c["index.ts"]
  f3e20782_7a7a_6d07_0472_a959db30007c --> 3570f589_2f69_c1ce_f4d4_16edf9b89280
  style 3570f589_2f69_c1ce_f4d4_16edf9b89280 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { exec as execCb } from 'node:child_process'
import { readFileSync } from 'node:fs'
import fs from 'node:fs/promises'
import { dirname, resolve } from 'node:path'
import { promisify } from 'node:util'
import { DefaultMap } from '../../../tailwindcss/src/utils/default-map'
import { error, warn } from './renderer'

const exec = promisify(execCb)

const SAVE_DEV: Record<string, string> = {
  default: '-D',
  bun: '-d',
}

const manifests = new DefaultMap((base) => {
  try {
    let packageJsonPath = resolve(base, 'package.json')
    return readFileSync(packageJsonPath, 'utf-8')
  } catch {
    return ''
  }
})

export function pkg(base: string) {
  return {
    async manager() {
      return await packageManagerForBase.get(base)
    },
    async add(packages: string[], location: 'dependencies' | 'devDependencies' = 'dependencies') {
      let packageManager = await packageManagerForBase.get(base)
      let args = packages.slice()
      if (location === 'devDependencies') {
        args.push(SAVE_DEV[packageManager] || SAVE_DEV.default)
      }

      // Allow running the `pnpm` command in the workspace root without
      // erroring. Can't just use `--workspace-root` because that will force
      // install dependencies in the workspace root.
      if (packageManager === 'pnpm') {
        args.push('--ignore-workspace-root-check')
      }

      let command = `${packageManager} add ${args.join(' ')}`
      try {
        return await exec(command, { cwd: base })
      } catch (e: any) {
        error(`An error occurred while running \`${command}\`\n\n${e.stdout}\n${e.stderr}`, {
          prefix: '↳ ',
        })
        throw e
      } finally {
        manifests.delete(base)
      }
    },
    has(name: string) {
      return manifests.get(base).includes(`"${name}":`)
    },
    async remove(packages: string[]) {
      let packageManager = await packageManagerForBase.get(base)
// ... (79 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does packages.ts do?
packages.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the CommandLineInterface domain, Renderer subdomain.
What functions are defined in packages.ts?
packages.ts defines 3 function(s): manifests, packageManagerForBase, pkg.
What does packages.ts depend on?
packages.ts imports 10 module(s): DefaultMap, default-map.ts, error, node:child_process, node:fs, node:path, node:util, promises, and 2 more.
What files import packages.ts?
packages.ts is imported by 2 file(s): index.ts, migrate-postcss.ts.
Where is packages.ts in the architecture?
packages.ts is located at packages/@tailwindcss-upgrade/src/utils/packages.ts (domain: CommandLineInterface, subdomain: Renderer, 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