diff --git a/src/configs/droneCI.ts b/src/configs/droneCI.ts index 18d6828..7610e32 100644 --- a/src/configs/droneCI.ts +++ b/src/configs/droneCI.ts @@ -30,10 +30,12 @@ const droneCI: Config = { scripts: [], dependencies: [], nuxtConfig: {}, - files: [{ - path: '.drone.yml', - content: DRONE_TEMPLATE - }], + files: [ + { + path: '.drone.yml', + content: DRONE_TEMPLATE + } + ], } export default droneCI diff --git a/src/configs/eslint.ts b/src/configs/eslint.ts index ced5bb3..3add995 100644 --- a/src/configs/eslint.ts +++ b/src/configs/eslint.ts @@ -16,22 +16,13 @@ const ignores = [ export default antfu({ // .eslintignore is no longer supported in Flat config, use ignores instead ignores, - - // Stylistic formatting rules stylistic: { indent: 2, quotes: 'single', }, - - // TypeScript and Vue are auto-detected, you can also explicitly enable them - typescript: true, vue: true, - - // Disable jsonc and yaml support jsonc: false, yaml: false, - - // Overwrite certain rules to your preference rules: { 'no-console': ['error', { allow: ['info', 'warn', 'trace', 'error', 'group', 'groupEnd'], @@ -44,31 +35,40 @@ export default antfu({ ` const eslint: Config = { - scripts: [{ - name: 'lint', - command: 'oxlint --deny-warnings -D correctness -D suspicious -D perf && eslint --max-warnings 0 .' - }, { - name: 'lint:fix', - command: 'eslint . --fix', - }], - dependencies: [{ - name: 'eslint', - version: '^8.57.0', - isDev: true - }, { - name: '@antfu/eslint-config', - version: '^2.26.0', - isDev: true - }, { - name: 'oxlint', - version: '^0.7.2', - isDev: true - }], + scripts: [ + { + name: 'lint', + command: 'oxlint --deny-warnings -D correctness -D suspicious -D perf && eslint --max-warnings 0 .' + }, + { + name: 'lint:fix', + command: 'eslint . --fix', + } + ], + dependencies: [ + { + name: 'eslint', + version: '^9.18.0', + isDev: true + }, + { + name: '@antfu/eslint-config', + version: '^3.15.0', + isDev: true + }, + { + name: 'oxlint', + version: '^0.15.7', + isDev: true + } + ], nuxtConfig: {}, - files: [{ - path: 'eslint.config.js', - content: eslintConfig - }], + files: [ + { + path: 'eslint.config.js', + content: eslintConfig + } + ], } export default eslint diff --git a/src/configs/github-actions.ts b/src/configs/github-actions.ts index 3582b47..3086970 100644 --- a/src/configs/github-actions.ts +++ b/src/configs/github-actions.ts @@ -53,10 +53,12 @@ const githubActions: Config = { scripts: [], dependencies: [], nuxtConfig: {}, - files: [{ - path: '.github/workflows/ci.yaml', - content: GITHUB_ACTIONS_TEMPLATE - }], + files: [ + { + path: '.github/workflows/ci.yaml', + content: GITHUB_ACTIONS_TEMPLATE + } + ], } export default githubActions diff --git a/src/configs/i18n.ts b/src/configs/i18n.ts index 94586fe..1c8d4e6 100644 --- a/src/configs/i18n.ts +++ b/src/configs/i18n.ts @@ -47,37 +47,44 @@ const i18n: ModuleConfig = { humanReadableName: 'i18n', description: 'I18n (Internationalization) module for your Nuxt project powered by Vue I18n. See more: https://i18n.nuxtjs.org/', scripts: [], - dependencies: [{ - name: '@nuxtjs/i18n', - version: '^8.4.0', - isDev: true - }], + dependencies: [ + { + name: '@nuxtjs/i18n', + version: '^9.2.1', + isDev: true + } + ], nuxtConfig: { modules: ['@nuxtjs/i18n'], // @ts-expect-error i18n is not set in default Nuxt Config, as the package is not installed i18n: { - strategy: 'prefix_except_default', - lazy: true, - langDir: 'locales', defaultLocale: 'en', locales: [ { name: 'English', code: 'en', file: 'en.json' }, ], + strategy: 'prefix_except_default', + detectBrowserLanguage: false, + lazy: true, experimental: { - localeDetector: './localeDetector.ts' + autoImportTranslationFunctions: true, + localeDetector: 'localeDetector.ts' } } }, - files: [{ - path: 'localeDetector.ts', - content: localeDetector - }, { - path: 'locales/en.json', - content: englishLocaleFile - }, { - path: 'components/Welcome/I18nDemo.vue', - content: i18nDemoComponent - }], + files: [ + { + path: 'i18n/localeDetector.ts', + content: localeDetector + }, + { + path: 'i18n/locales/en.json', + content: englishLocaleFile + }, + { + path: 'components/Welcome/I18nDemo.vue', + content: i18nDemoComponent + } + ], tasksPostInstall: [], indexVue: generateModuleHTMLSnippet('WelcomeI18nDemo'), } diff --git a/src/configs/naiveui.ts b/src/configs/naiveui.ts index bc0cc0d..88fbd14 100644 --- a/src/configs/naiveui.ts +++ b/src/configs/naiveui.ts @@ -28,9 +28,10 @@ const showModal = ref(false) ` const nuxtAppVueWithNaiveConfig = ` ` @@ -38,26 +39,26 @@ const naiveui: ModuleConfig = { humanReadableName: 'Naive UI', description: 'A Vue 3 Component Library. Complete, Customizable, Uses TypeScript, Fast. See more: https://www.naiveui.com/', scripts: [], - dependencies: [{ - name: '@bg-dev/nuxt-naiveui', - /* - * Pinned to v1.0.0-edge.2 as naiveui was failing on typecheck. - * replace this with the offical release, once it is out. - * See: https://github.com/becem-gharbi/nuxt-naiveui/issues/76 - */ - version: '1.0.0-edge.2', - isDev: true - }], + dependencies: [ + { + name: '@bg-dev/nuxt-naiveui', + version: '2.0.0-rc.4', + isDev: true + } + ], nuxtConfig: { modules: ['@bg-dev/nuxt-naiveui'], }, - files: [{ - path: 'components/Welcome/NaiveDemo.vue', - content: naiveDemoComponent - }, { - path: 'app.vue', - content: nuxtAppVueWithNaiveConfig - }], + files: [ + { + path: 'components/Welcome/NaiveDemo.vue', + content: naiveDemoComponent + }, + { + path: 'app.vue', + content: nuxtAppVueWithNaiveConfig + } + ], tasksPostInstall: [], indexVue: generateModuleHTMLSnippet('WelcomeNaiveDemo'), } diff --git a/src/configs/pnpm.ts b/src/configs/pnpm.ts index b844d4a..5a528a1 100644 --- a/src/configs/pnpm.ts +++ b/src/configs/pnpm.ts @@ -1,8 +1,7 @@ import type { Config } from '../types' // nuxt 3 + pnpm needs to shamefully hoist + we want to auto-install required peer dependencies (last one taken from: https://github.com/antfu/vitesse/blob/main/.npmrc) -const npmrc = ` -shamefully-hoist=true +const npmrc = `shamefully-hoist=true strict-peer-dependencies=false ` @@ -10,10 +9,12 @@ const pnpm: Config = { dependencies: [], scripts: [], nuxtConfig: {}, - files: [{ - path: '.npmrc', - content: npmrc - }], + files: [ + { + path: '.npmrc', + content: npmrc + } + ], } export default pnpm diff --git a/src/configs/prisma.ts b/src/configs/prisma.ts index 751311f..30d6993 100644 --- a/src/configs/prisma.ts +++ b/src/configs/prisma.ts @@ -67,31 +67,6 @@ export default eventHandler((event) => { }) ` -const prismaUtils = `import { execSync } from 'node:child_process' - -/** - * Helper to reset the database via a programmatic prisma invocation. Helpful to add to \`beforeEach\` or \`beforeAll\` of your testing setup. - * - * WARNING: Never run this in production. - * - * Taken from https://github.com/prisma/prisma/issues/13549#issuecomment-1144883246 - * - * @param databaseUrl Connection URL to database. Inferred from \`process.env.DATABASE_URL\` if not provided - */ -export function resetDatabase(databaseUrl?: string) { - const url = databaseUrl || process.env.DATABASE_URL - if (!url) { - throw new Error('Cannot reset database - connection string could not be inferred.') - } - - if (process.env.NODE_ENV === 'production') { - throw new Error('This utility should not be called in production. It is meant for testing and development') - } - - execSync(\`cd \${process.cwd()} && DATABASE_URL=\${url} npx prisma db push --force-reset\`, { stdio: 'inherit' }) -} -` - const pglite = `/** * Script that starts a postgres database using pg-gateway (https://github.com/supabase-community/pg-gateway) and pglite (https://github.com/electric-sql/pglite). * @@ -100,11 +75,11 @@ const pglite = `/** * * To make use of the shadow-database add \`/prisma-shadow\` to the DSN you provide. This script will then spin up a second, in-memory-only database and connect you to it. */ -import net from 'node:net' import { unlinkSync, writeFileSync } from 'node:fs' +import net from 'node:net' import { PGlite } from '@electric-sql/pglite' -import { fromNodeSocket } from 'pg-gateway/node' import { join } from 'pathe' +import { fromNodeSocket } from 'pg-gateway/node' // If env var is set, we write a file to disk once the server is done starting up. This file can then be used by other processes to check whether the database is ready const doWriteHealthFile = process.env.WRITE_HEALTH_FILE === 'true' @@ -197,17 +172,17 @@ const prisma: ModuleConfig = { dependencies: [ { name: 'prisma', - version: '^5.18.0', + version: '^5.22.0', isDev: true }, { name: '@prisma/client', - version: '^5.18.0', + version: '^5.22.0', isDev: false }, { name: '@electric-sql/pglite', - version: '^0.2.9', + version: '0.2.13', isDev: true, }, { @@ -217,36 +192,41 @@ const prisma: ModuleConfig = { }, { name: 'vite-node', - version: '^2.1.1', + version: '^2.1.5', isDev: true, } ], nuxtConfig: {}, - files: [{ - path: '.env', - content: prismaEnvFile - }, { - path: 'prisma/schema/schema.prisma', - content: prismaRootSchema - }, { - path: 'prisma/schema/example.prisma', - content: prismaExampleSchema - }, { - path: 'server/api/examples.get.ts', - content: prismaExampleEndpoint - }, { - path: 'server/middleware/0.prisma.ts', - content: prismaServerMiddleware - }, { - path: 'prisma/utils.ts', - content: prismaUtils - }, { - path: 'components/Welcome/PrismaDemo.vue', - content: prismaDemoComponent, - }, { - path: 'prisma/pglite.ts', - content: pglite, - }], + files: [ + { + path: '.env', + content: prismaEnvFile + }, + { + path: 'prisma/schema/schema.prisma', + content: prismaRootSchema + }, + { + path: 'prisma/schema/example.prisma', + content: prismaExampleSchema + }, + { + path: 'server/api/examples.get.ts', + content: prismaExampleEndpoint + }, + { + path: 'server/middleware/0.prisma.ts', + content: prismaServerMiddleware + }, + { + path: 'components/Welcome/PrismaDemo.vue', + content: prismaDemoComponent, + }, + { + path: 'prisma/pglite.ts', + content: pglite, + } + ], tasksPostInstall: [ '- [ ] Prisma: Edit your `prisma/prisma.schema` to your liking', `- [ ] Prisma: Start your local postgres database using \`${getUserPkgManager()} run db\``, diff --git a/src/configs/sidebase-auth.ts b/src/configs/sidebase-auth.ts index 0a64472..14b9dc3 100644 --- a/src/configs/sidebase-auth.ts +++ b/src/configs/sidebase-auth.ts @@ -1,9 +1,9 @@ import { generateModuleHTMLComponent, generateModuleHTMLSnippet } from '../generators/generateModuleComponents' import type { ModuleConfig } from '../types' -const nuxtAuthServerFile = `import CredentialsProvider from 'next-auth/providers/credentials' +const nuxtAuthServerFile = `import { NuxtAuthHandler } from '#auth' +import CredentialsProvider from 'next-auth/providers/credentials' import GithubProvider from 'next-auth/providers/github' -import { NuxtAuthHandler } from '#auth' export default NuxtAuthHandler({ // TODO: SET A STRONG SECRET, SEE https://sidebase.io/nuxt-auth/configuration/nuxt-auth-handler#secret @@ -99,13 +99,16 @@ const sidebaseAuth: ModuleConfig = { nuxtConfig: { modules: ['@sidebase/nuxt-auth'], }, - files: [{ - path: 'server/api/auth/[...].ts', - content: nuxtAuthServerFile - }, { - path: 'components/Welcome/AuthDemo.vue', - content: authDemoComponent - }], + files: [ + { + path: 'server/api/auth/[...].ts', + content: nuxtAuthServerFile + }, + { + path: 'components/Welcome/AuthDemo.vue', + content: authDemoComponent + } + ], tasksPostInstall: [ '- [ ] Auth: Configure your auth providers to the [NuxtAuthHandler](./server/api/auth/[...].ts)', '- [ ] Auth, optional: Enable global protection by setting `enableGlobalAppMiddleware: true` in [your nuxt.config.ts](./nuxt.config.ts). Delete the local middleware in the [protected.vue](./pages/protected.vue) page if you do' diff --git a/src/configs/tailwind.ts b/src/configs/tailwind.ts index a4a2570..fd93b21 100644 --- a/src/configs/tailwind.ts +++ b/src/configs/tailwind.ts @@ -18,18 +18,22 @@ const tailwind: ModuleConfig = { humanReadableName: 'Tailwind CSS', description: 'A utility-first CSS framework packed with classes that can be composed to build any design, directly in your markup. See more: https://tailwindcss.com/', scripts: [], - dependencies: [{ - name: '@nuxtjs/tailwindcss', - version: '^6.11.4', - isDev: true - }], + dependencies: [ + { + name: '@nuxtjs/tailwindcss', + version: '^6.13.1', + isDev: true + } + ], nuxtConfig: { modules: ['@nuxtjs/tailwindcss'] }, - files: [{ - path: 'components/Welcome/TailwindDemo.vue', - content: tailwindDemoComponent, - }], + files: [ + { + path: 'components/Welcome/TailwindDemo.vue', + content: tailwindDemoComponent, + } + ], tasksPostInstall: [], indexVue: generateModuleHTMLSnippet('WelcomeTailwindDemo'), } diff --git a/src/configs/trpc.ts b/src/configs/trpc.ts index 4e22cbf..d4d4dca 100644 --- a/src/configs/trpc.ts +++ b/src/configs/trpc.ts @@ -10,9 +10,9 @@ const nuxtTrpcRootConfig = `/** * @see https://trpc.io/docs/v10/router * @see https://trpc.io/docs/v10/procedures */ +import type { Context } from '~/server/trpc/context' import { initTRPC } from '@trpc/server' import superjson from 'superjson' -import type { Context } from '~/server/trpc/context' const t = initTRPC.context().create({ transformer: superjson @@ -69,8 +69,8 @@ export type Context = inferAsyncReturnType ` const nuxtTrpcApiHandler = `import { createNuxtApiHandler } from 'trpc-nuxt' -import { appRouter } from '~/server/trpc/routers' import { createContext } from '~/server/trpc/context' +import { appRouter } from '~/server/trpc/routers' // export API handler export default createNuxtApiHandler({ @@ -79,9 +79,9 @@ export default createNuxtApiHandler({ }) ` -const nuxtTrpcPlugin = `import { createTRPCNuxtClient, httpBatchLink } from 'trpc-nuxt/client' +const nuxtTrpcPlugin = `import type { AppRouter } from '~/server/trpc/routers' import superjson from 'superjson' -import type { AppRouter } from '~/server/trpc/routers' +import { createTRPCNuxtClient, httpBatchLink } from 'trpc-nuxt/client' export default defineNuxtPlugin(() => { /** @@ -129,27 +129,33 @@ const trpc: ModuleConfig = { humanReadableName: 'tRPC 10', description: 'Build end-to-end typesafe APIs in Nuxt applications. See more: https://trpc.io/', scripts: [], - dependencies: [{ - name: '@trpc/server', - version: '^10.45.2', - isDev: false - }, { - name: '@trpc/client', - version: '^10.45.2', - isDev: false - }, { - name: 'trpc-nuxt', - version: '^0.10.21', - isDev: false - }, { - name: 'zod', - version: '^3.22.4', - isDev: false - }, { - name: 'superjson', - version: '^2.2.1', - isDev: false - }], + dependencies: [ + { + name: '@trpc/server', + version: '^10.45.2', + isDev: false + }, + { + name: '@trpc/client', + version: '^10.45.2', + isDev: false + }, + { + name: 'trpc-nuxt', + version: '^0.10.21', + isDev: false + }, + { + name: 'zod', + version: '^3.23.8', + isDev: false + }, + { + name: 'superjson', + version: '^2.2.1', + isDev: false + } + ], nuxtConfig: { build: { transpile: ['trpc-nuxt'] diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts index 8ff8904..d6e93e2 100644 --- a/src/configs/typescript.ts +++ b/src/configs/typescript.ts @@ -8,19 +8,18 @@ const scripts: Config = { name: 'start', command: 'NODE_ENV=production node .output/server/index.mjs' }], - dependencies: [{ - name: 'vue-tsc', - version: '^2.1.6', - isDev: true - }, { - name: 'typescript', - version: '^5.6.3', - isDev: true, - }, { - name: '@types/node', - version: '^22.7.8', - isDev: true, - }], + dependencies: [ + { + name: 'vue-tsc', + version: '2.2.8', + isDev: true + }, + { + name: 'typescript', + version: '5.7.3', + isDev: true, + } + ], files: [], nuxtConfig: {} } diff --git a/src/configs/vscode.ts b/src/configs/vscode.ts index 0689ae9..2b3bf97 100644 --- a/src/configs/vscode.ts +++ b/src/configs/vscode.ts @@ -60,13 +60,16 @@ const vscode: Config = { scripts: [], dependencies: [], nuxtConfig: {}, - files: [{ - path: '.vscode/settings.json', - content: VSCODE_SETTINGS - }, { - path: '.vscode/extensions.json', - content: VSCODE_EXTENSIONS - }], + files: [ + { + path: '.vscode/settings.json', + content: VSCODE_SETTINGS + }, + { + path: '.vscode/extensions.json', + content: VSCODE_EXTENSIONS + } + ], } export default vscode diff --git a/src/steps/1.downloadTemplate.ts b/src/steps/1.downloadTemplate.ts index 7c8b42e..7b637b8 100644 --- a/src/steps/1.downloadTemplate.ts +++ b/src/steps/1.downloadTemplate.ts @@ -3,7 +3,7 @@ import { say } from '../messages' import type { Preferences } from '../types' const KNOWN_TEMPLATES = { - merino: 'github:sidebase/templates#nuxt-3.12.4', + merino: 'github:sidebase/templates#nuxt-3.15.4', cheviot: 'community/sidebase' }