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
  817bb61a_7ad0_1186_790a_6a40126eed80["run()"]
  f3e20782_7a7a_6d07_0472_a959db30007c["index.ts"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|defined in| f3e20782_7a7a_6d07_0472_a959db30007c
  886c613f_5f0c_8d65_8947_9c861e0c24eb["eprintln()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| 886c613f_5f0c_8d65_8947_9c861e0c24eb
  d51344bd_5caa_9aed_19fd_55a5425e524b["header()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| d51344bd_5caa_9aed_19fd_55a5425e524b
  e7b1089c_877d_2e3e_9622_6f5ac99ca7ba["isRepoDirty()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| e7b1089c_877d_2e3e_9622_6f5ac99ca7ba
  6c5b3bb2_4069_e0af_8887_216e1c995446["error()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| 6c5b3bb2_4069_e0af_8887_216e1c995446
  8e778e08_76c6_9ee6_899b_7331b37b18ea["info()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| 8e778e08_76c6_9ee6_899b_7331b37b18ea
  d3ccc5ce_e370_63df_a97d_a2f004fd83ca["highlight()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| d3ccc5ce_e370_63df_a97d_a2f004fd83ca
  32d4722d_8ebf_aac6_17f1_b44e71c91dab["installedTailwindVersion()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| 32d4722d_8ebf_aac6_17f1_b44e71c91dab
  f7502007_158c_d8dc_bc08_8f43a3aeb2e7["expectedTailwindVersion()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| f7502007_158c_d8dc_bc08_8f43a3aeb2e7
  9cc0ff32_ad5a_9207_5cc6_12717c5ad23e["pkg()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| 9cc0ff32_ad5a_9207_5cc6_12717c5ad23e
  cfe5faf0_6df4_9cfd_d25c_1dcf672e58ea["load()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| cfe5faf0_6df4_9cfd_d25c_1dcf672e58ea
  6cf757d4_aaad_b18d_cf21_ade24c6e2a77["isMajor()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| 6cf757d4_aaad_b18d_cf21_ade24c6e2a77
  3dec545a_c324_15f0_cdd3_7c9a86137145["prepareConfig()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| 3dec545a_c324_15f0_cdd3_7c9a86137145
  617e9831_5cd2_4ca6_2c65_f89e3720cfd8["migrateJsConfig()"]
  817bb61a_7ad0_1186_790a_6a40126eed80 -->|calls| 617e9831_5cd2_4ca6_2c65_f89e3720cfd8
  style 817bb61a_7ad0_1186_790a_6a40126eed80 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