Home / Function/ run() — tailwindcss Function Reference

run() — tailwindcss Function Reference

Architecture documentation for the run() function in index.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  6066f111_c660_b87d_6993_07d8cc779b5c["run()"]
  b2eb6cbf_d28d_9ec7_61c1_8992d8f4efb8["index.ts"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|defined in| b2eb6cbf_d28d_9ec7_61c1_8992d8f4efb8
  078d2bb7_b452_deb1_65fc_18a02b98d0fb["eprintln()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| 078d2bb7_b452_deb1_65fc_18a02b98d0fb
  19af1556_b46b_c92f_5197_2a29af9d42a2["header()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| 19af1556_b46b_c92f_5197_2a29af9d42a2
  4d4d6dde_2f48_a78c_bd07_da644bd1b7ef["isRepoDirty()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| 4d4d6dde_2f48_a78c_bd07_da644bd1b7ef
  f1ca9393_701c_e4a7_8303_ed03f028d19b["error()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| f1ca9393_701c_e4a7_8303_ed03f028d19b
  f6cf39d1_9161_38f6_5e39_d0d0f34bb6a8["info()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| f6cf39d1_9161_38f6_5e39_d0d0f34bb6a8
  a81de696_6bb5_40db_26ca_1d707ccebed9["highlight()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| a81de696_6bb5_40db_26ca_1d707ccebed9
  674ec8b4_cdc1_dbd1_ecd7_8b9bd712c1a1["installedTailwindVersion()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| 674ec8b4_cdc1_dbd1_ecd7_8b9bd712c1a1
  2cf65633_370f_39a2_153a_d25625fa74c9["expectedTailwindVersion()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| 2cf65633_370f_39a2_153a_d25625fa74c9
  14c611e1_f56a_262f_0861_6fb84b21afb3["pkg()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| 14c611e1_f56a_262f_0861_6fb84b21afb3
  f5b0b5ff_6cac_8425_61a9_f84aed9ce105["load()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| f5b0b5ff_6cac_8425_61a9_f84aed9ce105
  8d08c9fd_45a1_f37c_a879_6fd2c9991403["isMajor()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| 8d08c9fd_45a1_f37c_a879_6fd2c9991403
  9faa4462_1a05_6046_b23a_09ba561cb528["prepareConfig()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| 9faa4462_1a05_6046_b23a_09ba561cb528
  1ef01211_e07d_fbec_dcb1_d3c7a3bfe061["migrateJsConfig()"]
  6066f111_c660_b87d_6993_07d8cc779b5c -->|calls| 1ef01211_e07d_fbec_dcb1_d3c7a3bfe061
  style 6066f111_c660_b87d_6993_07d8cc779b5c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/index.ts lines 43–360

async function run() {
  let base = process.cwd()

  eprintln(header())
  eprintln()

  let cleanup: (() => void)[] = []

  if (!flags['--force']) {
    // Require a clean git directory
    if (isRepoDirty()) {
      error('Git directory is not clean. Please stash or commit your changes before migrating.')
      info(
        `You may use the ${highlight('--force')} flag to silence this warning and perform the migration.`,
      )
      process.exit(1)
    }
  }

  info(`Upgrading from Tailwind CSS ${highlight(`v${version.installedTailwindVersion(base)}`)}`, {
    prefix: '↳ ',
  })

  if (version.installedTailwindVersion(base) !== version.expectedTailwindVersion(base)) {
    let pkgManager = await pkg(base).manager()

    error(
      [
        'Version mismatch',
        '',
        pc.dim('```diff'),
        `${pc.red('-')} ${`${pc.dim('"tailwindcss":')} ${`${pc.dim('"')}${pc.blue(version.expectedTailwindVersion(base))}${pc.dim('"')}`}`} (expected version in ${highlight('package.json')})`,
        `${pc.green('+')} ${`${pc.dim('"tailwindcss":')} ${`${pc.dim('"')}${pc.blue(version.installedTailwindVersion(base))}${pc.dim('"')}`}`} (installed version in ${highlight('node_modules')})`,
        pc.dim('```'),
        '',
        `Make sure to run ${highlight(`${pkgManager} install`)} and try again.`,
      ].join('\n'),
      {
        prefix: '↳ ',
      },
    )
    process.exit(1)
  }

  {
    // Stylesheet migrations

    // Use provided files
    let files = flags._.map((file) => path.resolve(base, file))

    // Discover CSS files in case no files were provided
    if (files.length === 0) {
      info('Searching for CSS files in the current directory and its subdirectories…')

      files = await globby(['**/*.css'], {
        absolute: true,
        gitignore: true,
        // gitignore: true will first search for all .gitignore including node_modules folders, this makes the initial search much faster
        ignore: ['**/node_modules/**'],
      })
    }

    // Ensure we are only dealing with CSS files
    files = files.filter((file) => file.endsWith('.css'))

    // Analyze the stylesheets
    let loadResults = await Promise.allSettled(files.map((filepath) => Stylesheet.load(filepath)))

    // Load and parse all stylesheets
    for (let result of loadResults) {
      if (result.status === 'rejected') {
        error(`${result.reason?.message ?? result.reason}`, { prefix: '↳ ' })
      }
    }

    let stylesheets = loadResults
      .filter((result) => result.status === 'fulfilled')
      .map((result) => result.value)
    let originals = new Map(stylesheets.map((sheet) => [sheet, sheet.root.toString()]))

    // Analyze the stylesheets

Subdomains

Frequently Asked Questions

What does run() do?
run() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-upgrade/src/index.ts.
Where is run() defined?
run() is defined in packages/@tailwindcss-upgrade/src/index.ts at line 43.
What does run() call?
run() calls 22 function(s): ancestors, compiler, containsRule, designSystem, eprintln, error, expectedTailwindVersion, formatNodes, and 14 more.

Analyze Your Own Codebase

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

Try Supermodel Free