Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tailwind as an option #245

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 25 additions & 4 deletions index.ts
Expand Up @@ -78,6 +78,7 @@ async function init() {
// --playwright
// --eslint
// --eslint-with-prettier (only support prettier through eslint for simplicity)
// --tailwind
// --force (for force overwriting)
const argv = minimist(process.argv.slice(2), {
alias: {
Expand All @@ -102,7 +103,8 @@ async function init() {
argv.vitest ??
argv.cypress ??
argv.playwright ??
argv.eslint
argv.eslint ??
argv.tailwind
) === 'boolean'

let targetDir = argv._[0]
Expand All @@ -122,6 +124,7 @@ async function init() {
needsE2eTesting?: false | 'cypress' | 'playwright'
needsEslint?: boolean
needsPrettier?: boolean
needsTailwind?: boolean
} = {}

try {
Expand All @@ -137,6 +140,7 @@ async function init() {
// - Add Playwright for end-to-end testing?
// - Add ESLint for code quality?
// - Add Prettier for code formatting?
// - Add Tailwind for styling?
result = await prompts(
[
{
Expand Down Expand Up @@ -252,6 +256,14 @@ async function init() {
initial: false,
active: 'Yes',
inactive: 'No'
},
{
name: 'needsTailwind',
type: () => (isFeatureFlagsUsed ? null : 'toggle'),
message: 'Add TailwindCss for styling?',
initial: false,
active: 'Yes',
inactive: 'No'
}
],
{
Expand All @@ -277,7 +289,8 @@ async function init() {
needsPinia = argv.pinia,
needsVitest = argv.vitest || argv.tests,
needsEslint = argv.eslint || argv['eslint-with-prettier'],
needsPrettier = argv['eslint-with-prettier']
needsPrettier = argv['eslint-with-prettier'],
needsTailwind = argv['tailwind']
} = result

const { needsE2eTesting } = result
Expand Down Expand Up @@ -357,6 +370,11 @@ async function init() {
renderEslint(root, { needsTypeScript, needsCypress, needsCypressCT, needsPrettier })
}

// Render tailwind config
if (needsTailwind) {
render('config/tailwind')
}

// Render code template.
// prettier-ignore
const codeTemplate =
Expand Down Expand Up @@ -440,14 +458,17 @@ async function init() {
needsCypress,
needsPlaywright,
needsCypressCT,
needsEslint
needsEslint,
needsTailwind
})
)

console.log(`\nDone. Now run:\n`)
if (root !== cwd) {
const cdProjectName = path.relative(cwd, root)
console.log(` ${bold(green(`cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`))}`)
console.log(
` ${bold(green(`cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`))}`
)
}
console.log(` ${bold(green(getCommand(packageManager, 'install')))}`)
if (needsPrettier) {
Expand Down