MCPcopy
hub / github.com/tailwindlabs/tailwindcss / run

Function run

packages/@tailwindcss-upgrade/src/index.ts:44–452  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44async function run() {
45 let base = process.cwd()
46 let isIgnored = await isGitIgnored({ cwd: base })
47
48 eprintln(header())
49 eprintln()
50
51 let cleanup: (() => void)[] = []
52
53 if (!flags['--force']) {
54 // Require a clean git directory
55 if (isRepoDirty()) {
56 error('Git directory is not clean. Please stash or commit your changes before migrating.')
57 info(
58 `You may use the ${highlight('--force')} flag to silence this warning and perform the migration.`,
59 )
60 process.exit(1)
61 }
62 }
63
64 info(`Upgrading from Tailwind CSS ${highlight(`v${version.installedTailwindVersion(base)}`)}`, {
65 prefix: '↳ ',
66 })
67
68 if (version.installedTailwindVersion(base) !== version.expectedTailwindVersion(base)) {
69 let pkgManager = await pkg(base).manager()
70
71 error(
72 [
73 'Version mismatch',
74 '',
75 pc.dim('```diff'),
76 `${pc.red('-')} ${`${pc.dim('"tailwindcss":')} ${`${pc.dim('"')}${pc.blue(version.expectedTailwindVersion(base))}${pc.dim('"')}`}`} (expected version in ${highlight('package.json')})`,
77 `${pc.green('+')} ${`${pc.dim('"tailwindcss":')} ${`${pc.dim('"')}${pc.blue(version.installedTailwindVersion(base))}${pc.dim('"')}`}`} (installed version in ${highlight('node_modules')})`,
78 pc.dim('```'),
79 '',
80 `Make sure to run ${highlight(`${pkgManager} install`)} and try again.`,
81 ].join('\n'),
82 {
83 prefix: '↳ ',
84 },
85 )
86 process.exit(1)
87 }
88
89 {
90 // Stylesheet migrations
91
92 // Use provided files
93 let files = flags._.map((file) => path.resolve(base, file))
94
95 // Discover CSS files in case no files were provided
96 if (files.length === 0) {
97 info('Searching for CSS files in the current directory and its subdirectories…')
98
99 files = await globby(['**/*.css'], {
100 cwd: base,
101 absolute: true,

Callers 1

index.tsFile · 0.70

Calls 15

eprintlnFunction · 0.90
headerFunction · 0.90
isRepoDirtyFunction · 0.90
errorFunction · 0.90
infoFunction · 0.90
highlightFunction · 0.90
pkgFunction · 0.90
prepareConfigFunction · 0.90
migrateJsConfigFunction · 0.90
successFunction · 0.90
relativeFunction · 0.90
sortBucketsFunction · 0.90

Tested by

no test coverage detected