Skip to content

Commit

Permalink
feat(cli): add preflight
Browse files Browse the repository at this point in the history
  • Loading branch information
shadcn committed Jan 16, 2024
1 parent 2078f66 commit c1749fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
type Config,
} from "@/src/utils/get-config"
import { getPackageManager } from "@/src/utils/get-package-manager"
import { getProjectConfig } from "@/src/utils/get-project-info"
import { getProjectConfig, preFlight } from "@/src/utils/get-project-info"
import { handleError } from "@/src/utils/handle-error"
import { logger } from "@/src/utils/logger"
import {
Expand Down Expand Up @@ -64,6 +64,8 @@ export const init = new Command()
process.exit(1)
}

preFlight(cwd)

const projectConfig = await getProjectConfig(cwd)
if (projectConfig) {
const config = await promptForMinimalConfig(
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/src/utils/get-project-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,20 @@ export async function isTypeScriptProject(cwd: string) {
// Check if cwd has a tsconfig.json file.
return pathExists(path.resolve(cwd, "tsconfig.json"))
}

export async function preFlight(cwd: string) {
// We need Tailwind CSS to be configured.
const tailwindConfig = await fg.glob("tailwind.config.*", {
cwd,
deep: 3,
ignore: PROJECT_SHARED_IGNORE,
})

if (!tailwindConfig.length) {
throw new Error(
"Tailwind CSS is not installed. Visit https://tailwindcss.com/docs/installation to get started."
)
}

return true
}

0 comments on commit c1749fc

Please sign in to comment.