Skip to content

Commit 633bc56

Browse files
committed
chore: remove old logic for different templates
1 parent bfb6a33 commit 633bc56

6 files changed

Lines changed: 16 additions & 64 deletions

File tree

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ async function main() {
2121
// Collect User preferences
2222
let preferences: Preferences = {
2323
setProjectName: 'my-sidebase-app',
24-
setStack: 'merino',
2524
addModules: ['prisma', 'sidebase-auth', 'trpc', 'tailwind', 'naiveui', 'i18n'],
2625
runGitInit: true,
2726
addCi: 'github',
@@ -37,7 +36,7 @@ async function main() {
3736
}
3837

3938
// 1. Download the Nuxt 3 template
40-
const template = await wrapInSpinner(`Adding Nuxt 3 ${preferences.setStack}-template`, downloadTemplate, preferences)
39+
const template = await wrapInSpinner(`Adding Nuxt`, downloadTemplate, preferences)
4140

4241
// 2. Get Configs and modules
4342
const { configs, modules } = getConfigs(preferences)

src/prompts.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import prompts from 'prompts'
2-
import type { PromptObject, PromptType } from 'prompts'
2+
import type { PromptObject } from 'prompts'
33
import { say } from './messages'
44
import { getUserPkgManager } from './utils/getUserPkgManager'
55
import { getRandomProjectNoun } from './utils/getRandomProjectNoun'
6-
import type { Preferences, Stack } from './types'
6+
import type { Preferences } from './types'
77
import { modules } from './configs'
88

9-
function skipIf(stacksToSkip: Stack[], promptType: PromptType) {
10-
return (_: unknown, preferences: Record<string, string>) => {
11-
return stacksToSkip.includes(preferences.setStack as Stack) ? null : promptType
12-
}
13-
}
14-
159
const PROMPT_QUESTIONS: PromptObject[] = [
1610
{
1711
type: 'text',
@@ -20,17 +14,7 @@ const PROMPT_QUESTIONS: PromptObject[] = [
2014
initial: `my-sidebase-${getRandomProjectNoun()}`
2115
},
2216
{
23-
type: 'select',
24-
name: 'setStack',
25-
message: 'What stack would you like to use for your new project? More information: https://sidebase.io/sidebase/welcome/stacks',
26-
choices: [
27-
{ title: 'Merino', description: 'A modular stack that let\'s you choose configuration and modules, e.g.: Want Prisma ORM or not? Want Authentication or not? ... Merino is ideal if you want fine-grained control', value: 'merino' },
28-
{ title: 'Cheviot', description: 'A batteries-included stack where most decisions were made for you. Cheviot is ideal if you want to just get going with an opinionated stack that works', value: 'cheviot' },
29-
],
30-
initial: 0
31-
},
32-
{
33-
type: skipIf(['cheviot'], 'multiselect'),
17+
type: 'multiselect',
3418
name: 'addModules',
3519
message: 'Which modules would you like to use?',
3620
choices: Object.entries(modules).map((
@@ -43,7 +27,7 @@ const PROMPT_QUESTIONS: PromptObject[] = [
4327
initial: true,
4428
},
4529
{
46-
type: skipIf(['cheviot'], 'select'),
30+
type: 'select',
4731
name: 'addCi',
4832
message: 'Initialize a default CI pipeline?',
4933
choices: [

src/steps/1.downloadTemplate.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@ import { downloadTemplate } from 'giget'
22
import { say } from '../messages'
33
import type { Preferences } from '../types'
44

5-
const KNOWN_TEMPLATES = {
6-
merino: 'github:sidebase/templates#nuxt-3.15.4',
7-
cheviot: 'community/sidebase'
8-
}
5+
const TEMPLATE_NAME = 'github:sidebase/templates#nuxt-3.15.4'
96

107
export default async (preferences: Preferences) => {
11-
const templateName = KNOWN_TEMPLATES[preferences.setStack as keyof typeof KNOWN_TEMPLATES]
12-
138
// 1. Download template
149
let template
1510
try {
16-
template = await downloadTemplate(templateName, {
11+
template = await downloadTemplate(TEMPLATE_NAME, {
1712
dir: preferences.setProjectName,
1813
registry: 'https://raw.githubusercontent.com/nuxt/starter/templates/templates'
1914
})

src/steps/2.getConfigs.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,25 @@ import { getUserPkgManager } from '../utils/getUserPkgManager'
55
export default function (preferences: Preferences) {
66
const setConfigs: Config[] = []
77

8-
// 1. Check if stack is not cheviot
9-
if (preferences.setStack === 'cheviot') {
10-
return { configs: [], modules: [] }
11-
}
12-
13-
// 2. Add Prebuilt CI pipeline
8+
// 1. Add Prebuilt CI pipeline
149
if (preferences.addCi === 'github') {
1510
setConfigs.push(configs['github-actions'])
1611
}
1712
if (preferences.addCi === 'drone') {
1813
setConfigs.push(configs.droneCI)
1914
}
2015

21-
// 3. Add required base configs
16+
// 2. Add required base configs
2217
setConfigs.push(configs.eslint)
2318
setConfigs.push(configs.typescript)
2419
setConfigs.push(configs.vscode)
2520

26-
// 4. If pnpm is used, add `.npmrc`
21+
// 3. If pnpm is used, add `.npmrc`
2722
if (getUserPkgManager() === 'pnpm') {
2823
setConfigs.push(configs.pnpm)
2924
}
3025

31-
// 5. Get Modules
26+
// 4. Get Modules
3227
const setModules = preferences.addModules?.map(key => modules[key]) ?? []
3328

3429
return { configs: setConfigs, modules: setModules }

src/steps/8.addReadMe.ts

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,14 @@ import { getUserPkgManager } from '../utils/getUserPkgManager'
55
import { modules } from '../configs'
66

77
function makeReadme(preferences: Preferences) {
8-
const { setProjectName = 'sidebase', setStack = undefined, addModules = [], addCi = 'none' } = preferences
8+
const { setProjectName = 'sidebase', addModules = [], addCi = 'none' } = preferences
99

1010
let selectedFeatures = []
11-
if (setStack === 'merino') {
12-
selectedFeatures = addModules.map((module: keyof typeof modules) => `- ${modules[module].humanReadableName}`)
13-
if (addCi === 'github') {
14-
selectedFeatures.push('- GitHub Actions based CI')
15-
}
16-
selectedFeatures.push('- Linting via ESLint and @antfu/eslint-config')
17-
}
18-
else {
19-
selectedFeatures = [
20-
'- Database models, migrations, queries and easy DB-switching via Prisma',
21-
'- Deep Prisma integration: Use the client in your endpoints via nuxt-prisma, Prisma client is auto-generated for npm run dev and other commands and more',
22-
'- Frontend- and Backend data-transformation via nuxt-parse and zod',
23-
'- In-memory development SQL-database via sqlite3',
24-
'- Linting via eslint',
25-
'- Test management, Test UI, component snapshotting via vitest',
26-
'- Component tests via test-library/vue',
27-
'- Nuxt 3 native API testing via @nuxt/test-utils',
28-
'- Code coverage via c8',
29-
'- CSS utilities via TailwindCSS',
30-
'- CSS components via Naive UI',
31-
'- Type checking in script and template via Volar / vue-tsc',
32-
'- Code editor configuration via .editorconfig files and a portable .settings/ folder whith best-practice VS Code settings and extensions for Vue 3 / Nuxt 3 development',
33-
]
11+
selectedFeatures = addModules.map((module: keyof typeof modules) => `- ${modules[module].humanReadableName}`)
12+
if (addCi === 'github') {
13+
selectedFeatures.push('- GitHub Actions based CI')
3414
}
15+
selectedFeatures.push('- Linting via ESLint and @antfu/eslint-config')
3516

3617
const tasksPostInstall = addModules.map(module => modules[module].tasksPostInstall).flat()
3718
const packageManager = getUserPkgManager()

src/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import type { NuxtConfig } from '@nuxt/schema'
22
import type { Modules } from './configs'
33

4-
export type Stack = 'merino' | 'cheviot'
54
export interface Preferences {
65
setProjectName: string
7-
setStack: Stack
86
addModules?: Modules[]
97
runGitInit: boolean
108
addCi?: 'github' | 'drone'

0 commit comments

Comments
 (0)