create-bitred-vue
v0.2.0
Published
[English](#english) | [Português](#português)
Readme
English
create-bitred-vue
CLI scaffolding tool that generates modular Vue 3 + TypeScript projects with selectable features and Laravel authentication presets.
npx create-bitred-vue my-projectFeatures
The CLI prompts you to select which features to include:
| Feature | What you get |
|---------|-------------|
| Router | Vue Router 4, dynamic layouts (guest/auth), useQueryParams composable |
| Pinia | Pinia 3, stores/ directory |
| UI | Shadcn Vue, Tailwind CSS v4, cn() utility, ThemeToggle, dark mode |
| Services | Axios + TanStack Vue Query, typed API layer (http.ts, ApiResponse<T>, ApiPaginatedResponse<T>), useErrorHandler |
| Forms | TanStack Vue Form + Zod |
| ESLint | ESLint 9 flat config + Prettier (semi, double quotes, trailing commas, 100 width) |
Authentication Presets
| Preset | Description |
|--------|-------------|
| None | No authentication |
| Laravel Sanctum | Cookie-based auth with withCredentials, CSRF cookie flow, POST /login |
| Laravel Passport | Bearer token auth, request/response interceptors, automatic token refresh on 401 |
Selecting an auth preset automatically enables Router, Pinia, and Services.
Both presets generate a complete auth module:
- Login page (always included)
- Selectable pages: Register, Forgot Password, Reset Password, Email Verification
- Auth store (Pinia) with
isAuthenticatedandisAdmin - TanStack Query services, queries, and mutations
- Navigation guards (
requiresAuth,requiresGuest) - Route-based layouts (
guestfor auth pages,authfor protected pages) - Dashboard placeholder page
When the UI feature is enabled, auth pages use Shadcn Vue components with a shared AuthPageLayout wrapper (card + image panel + dark mode toggle). Without UI, plain CSS pages are generated.
How It Works
npx create-bitred-vue my-project
? Project name: my-project
? Select features: Router, Pinia, UI, Services, Forms, ESLint
? Authentication: None | Sanctum | Passport
? Auth pages: Register, Forgot Password, Reset Password, Email Verification
-> Copies base template
-> Applies selected feature overlays
-> Applies auth preset (if any)
-> Copies auth-common files selectively based on chosen pages
-> Generates main.ts, App.vue, vite.config.ts dynamically
-> Runs npm installEach feature is a template overlay with its own package.json (merged automatically) and source files. Features are independent and composable.
Generated Project
my-project/
├── src/
│ ├── main.ts # Generated — imports only what you selected
│ ├── App.vue # Generated — layout system if Router, plain div otherwise
│ ├── assets/
│ ├── components/
│ │ ├── layouts/ # GuestLayout, AuthLayout (Router feature)
│ │ ├── shared/
│ │ └── ui/ # Shadcn Vue components (UI feature)
│ │ ├── button/
│ │ ├── card/
│ │ ├── theme-toggle/ # Dark/light mode toggle
│ │ └── ...
│ ├── composables/
│ │ └── use-theme.ts # Color mode management (UI feature)
│ ├── lib/
│ ├── modules/ # Feature modules (auth preset)
│ │ └── auth/
│ │ ├── pages/
│ │ ├── components/
│ │ │ └── auth-page-layout/ # Shared auth page wrapper (UI variant)
│ │ ├── composables/
│ │ └── router.ts
│ ├── pages/
│ ├── router/ # Router feature
│ ├── services/ # Services feature
│ └── stores/ # Pinia feature
├── vite.config.ts # Generated — plugins based on features
├── package.json # Merged from all selected features
├── tsconfig.json
├── CLAUDE.md # AI assistant context for the project
└── README.mdRepository Structure
vue-starter/
├── src/ # CLI source code
│ ├── index.ts # Entry point (#!/usr/bin/env node)
│ ├── types.ts # Feature, AuthPreset, AuthPage, ProjectOptions
│ ├── prompts.ts # Interactive prompts (@clack/prompts)
│ ├── generator.ts # Template orchestration
│ ├── utils.ts # renderTemplate, deepMerge, sortDependencies
│ └── generators/
│ ├── main-ts.ts # Generates src/main.ts
│ ├── app-vue.ts # Generates src/App.vue
│ ├── vite-config.ts # Generates vite.config.ts
│ ├── auth-router.ts # Generates auth module router
│ └── auth-indexes.ts # Generates auth service barrel indexes
├── template/
│ ├── base/ # Always included
│ ├── features/
│ │ ├── router/
│ │ ├── pinia/
│ │ ├── ui/
│ │ ├── services/
│ │ ├── forms/
│ │ └── eslint/
│ └── presets/
│ ├── auth-common/ # Shared auth files (pages, guards, routes, mutations)
│ ├── auth-sanctum/ # Sanctum-specific (http.ts, store, types)
│ └── auth-passport/ # Passport-specific (http.ts, store, types)
├── tests/
│ ├── utils.test.ts
│ ├── generators.test.ts
│ └── integration.test.ts
├── package.json
├── tsup.config.ts
└── tsconfig.jsonDevelopment
Prerequisites
- Node.js 20+
- npm
Setup
git clone https://github.com/bit-red/vue-starter.git
cd vue-starter
npm installBuild
npm run buildThis compiles the CLI to dist/index.js using tsup (ESM, target node20).
Watch Mode
npm run devRebuilds automatically on file changes.
Testing
# Run all tests
npm test
# Run in watch mode
npm run test:watch
# Run only unit tests (fast)
npx vitest run tests/utils.test.ts tests/generators.test.ts
# Run only integration tests (slow — generates + builds real projects)
npx vitest run tests/integration.test.tsTests cover:
- Unit:
toValidPackageName,sortDependencies,deepMerge,renderTemplate, all code generators (main-ts, app-vue, vite-config, auth-router, auth-indexes) - Integration: file structure verification for every feature/preset combo, package.json merging, and full
npm install+vite buildfor 5 scenarios (bare, all features, sanctum+UI, passport+UI, sanctum plain)
Manual Testing
You can also test the CLI interactively after building:
npm run build
node dist/index.js test-projectTemplate Conventions
- Files prefixed with
_are renamed to.(e.g._gitignorebecomes.gitignore,_prettierrcbecomes.prettierrc) - Each feature overlay has a
package.jsonwith only its extra dependencies — these are deep-merged with the basepackage.json - Feature overlays can overwrite files from the base template or from other features (last applied wins)
- Preset-specific overlays (
auth-sanctum/,auth-passport/) only containhttp.ts,stores/auth.ts, andservices/auth/types.ts - Common auth files (guards, routes, pages, mutations, queries) live in
auth-common/and are copied selectively bygenerator.ts
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feat/my-feature) - Make your changes
- Run
npm test— all tests must pass - Commit your changes
- Open a Pull Request
CI runs automatically on push/PR: build, unit tests, then integration tests.
Adding a New Feature
- Create
template/features/<name>/with apackage.jsonlisting extra dependencies - Add source files under
template/features/<name>/src/ - Add the feature name to the
Featuretype insrc/types.ts - Add a prompt option in
src/prompts.ts - If the feature needs dynamic imports in
main.ts, updatesrc/generators/main-ts.ts - If the feature adds Vite plugins, update
src/generators/vite-config.ts
Adding a New Auth Preset
- Create
template/presets/auth-<name>/with preset-specific files (http.ts,stores/auth.ts,services/auth/types.ts) - Add the preset name to the
AuthPresettype insrc/types.ts - Add a prompt option in
src/prompts.ts - Update
src/generators/auth-indexes.tsif the preset has different service functions
Adding a New Auth Page
- Add the page name to
AuthPagetype andSELECTABLE_AUTH_PAGESinsrc/types.ts - Add UI variant in
template/presets/auth-common/src/modules/auth/pages/ui/ - Add mutation in
template/presets/auth-common/src/services/auth/mutations/ - Add entry in
AUTH_PAGE_FILESmap insrc/generator.ts - Update
src/generators/auth-router.tsandsrc/generators/auth-indexes.ts - Add a multiselect option in
src/prompts.ts
License
MIT
Português
create-bitred-vue
Ferramenta CLI de scaffolding que gera projetos modulares Vue 3 + TypeScript com features selecionáveis e presets de autenticação Laravel.
npx create-bitred-vue my-projectFeatures
O CLI solicita que você selecione quais features incluir:
| Feature | O que você recebe |
|---------|-------------------|
| Router | Vue Router 4, layouts dinâmicos (guest/auth), composable useQueryParams |
| Pinia | Pinia 3, diretório stores/ |
| UI | Shadcn Vue, Tailwind CSS v4, utilitário cn(), ThemeToggle, dark mode |
| Services | Axios + TanStack Vue Query, camada de API tipada (http.ts, ApiResponse<T>, ApiPaginatedResponse<T>), useErrorHandler |
| Forms | TanStack Vue Form + Zod |
| ESLint | ESLint 9 flat config + Prettier (semi, aspas duplas, trailing commas, largura 100) |
Presets de Autenticação
| Preset | Descrição |
|--------|-----------|
| None | Sem autenticação |
| Laravel Sanctum | Auth baseada em cookie com withCredentials, fluxo CSRF, POST /login |
| Laravel Passport | Auth por token Bearer, interceptors de request/response, refresh automático em 401 |
Selecionar um preset de auth habilita automaticamente Router, Pinia e Services.
Ambos presets geram um módulo de auth completo:
- Página de login (sempre incluída)
- Páginas selecionáveis: Register, Forgot Password, Reset Password, Email Verification
- Auth store (Pinia) com
isAuthenticatedeisAdmin - Serviços, queries e mutations TanStack Query
- Guards de navegação (
requiresAuth,requiresGuest) - Layouts baseados em rota (
guestpara páginas de auth,authpara páginas protegidas) - Página placeholder de Dashboard
Quando a feature UI está habilitada, as páginas de auth usam componentes Shadcn Vue com um wrapper compartilhado AuthPageLayout (card + painel de imagem + toggle dark mode). Sem UI, páginas CSS puro são geradas.
Como Funciona
npx create-bitred-vue my-project
? Project name: my-project
? Select features: Router, Pinia, UI, Services, Forms, ESLint
? Authentication: None | Sanctum | Passport
? Auth pages: Register, Forgot Password, Reset Password, Email Verification
-> Copia template base
-> Aplica overlays das features selecionadas
-> Aplica preset de auth (se houver)
-> Copia arquivos auth-common seletivamente baseado nas páginas escolhidas
-> Gera main.ts, App.vue, vite.config.ts dinamicamente
-> Executa npm installCada feature é um overlay de template com seu próprio package.json (mesclado automaticamente) e arquivos fonte. Features são independentes e combináveis.
Projeto Gerado
my-project/
├── src/
│ ├── main.ts # Gerado — importa apenas o que foi selecionado
│ ├── App.vue # Gerado — sistema de layout se Router, div simples caso contrário
│ ├── assets/
│ ├── components/
│ │ ├── layouts/ # GuestLayout, AuthLayout (feature Router)
│ │ ├── shared/
│ │ └── ui/ # Componentes Shadcn Vue (feature UI)
│ │ ├── button/
│ │ ├── card/
│ │ ├── theme-toggle/ # Toggle dark/light mode
│ │ └── ...
│ ├── composables/
│ │ └── use-theme.ts # Gerenciamento de modo de cor (feature UI)
│ ├── lib/
│ ├── modules/ # Módulos de funcionalidade (preset auth)
│ │ └── auth/
│ │ ├── pages/
│ │ ├── components/
│ │ │ └── auth-page-layout/ # Wrapper compartilhado de auth (variante UI)
│ │ ├── composables/
│ │ └── router.ts
│ ├── pages/
│ ├── router/ # Feature Router
│ ├── services/ # Feature Services
│ └── stores/ # Feature Pinia
├── vite.config.ts # Gerado — plugins baseados nas features
├── package.json # Mesclado de todas as features selecionadas
├── tsconfig.json
├── CLAUDE.md # Contexto de assistente IA para o projeto
└── README.mdEstrutura do Repositório
vue-starter/
├── src/ # Código fonte do CLI
│ ├── index.ts # Entry point (#!/usr/bin/env node)
│ ├── types.ts # Feature, AuthPreset, AuthPage, ProjectOptions
│ ├── prompts.ts # Prompts interativos (@clack/prompts)
│ ├── generator.ts # Orquestração de templates
│ ├── utils.ts # renderTemplate, deepMerge, sortDependencies
│ └── generators/
│ ├── main-ts.ts # Gera src/main.ts
│ ├── app-vue.ts # Gera src/App.vue
│ ├── vite-config.ts # Gera vite.config.ts
│ ├── auth-router.ts # Gera router do módulo auth
│ └── auth-indexes.ts # Gera barrel indexes dos serviços auth
├── template/
│ ├── base/ # Sempre incluído
│ ├── features/
│ │ ├── router/
│ │ ├── pinia/
│ │ ├── ui/
│ │ ├── services/
│ │ ├── forms/
│ │ └── eslint/
│ └── presets/
│ ├── auth-common/ # Arquivos auth compartilhados (pages, guards, routes, mutations)
│ ├── auth-sanctum/ # Específico Sanctum (http.ts, store, types)
│ └── auth-passport/ # Específico Passport (http.ts, store, types)
├── tests/
│ ├── utils.test.ts
│ ├── generators.test.ts
│ └── integration.test.ts
├── package.json
├── tsup.config.ts
└── tsconfig.jsonDesenvolvimento
Pré-requisitos
- Node.js 20+
- npm
Setup
git clone https://github.com/bit-red/vue-starter.git
cd vue-starter
npm installBuild
npm run buildCompila o CLI para dist/index.js usando tsup (ESM, target node20).
Watch Mode
npm run devRecompila automaticamente quando arquivos são alterados.
Testes
# Rodar todos os testes
npm test
# Rodar em watch mode
npm run test:watch
# Rodar apenas testes unitários (rápido)
npx vitest run tests/utils.test.ts tests/generators.test.ts
# Rodar apenas testes de integração (lento — gera + builda projetos reais)
npx vitest run tests/integration.test.tsTestes cobrem:
- Unitários:
toValidPackageName,sortDependencies,deepMerge,renderTemplate, todos os geradores de código (main-ts, app-vue, vite-config, auth-router, auth-indexes) - Integração: verificação de estrutura de arquivos para cada combo feature/preset, merge de package.json, e
npm install+vite buildcompleto para 5 cenários (bare, all features, sanctum+UI, passport+UI, sanctum plain)
Teste Manual
Você também pode testar o CLI interativamente após o build:
npm run build
node dist/index.js test-projectConvenções de Template
- Arquivos com prefixo
_são renomeados para.(ex:_gitignorevira.gitignore,_prettierrcvira.prettierrc) - Cada overlay de feature tem um
package.jsoncom apenas suas dependências extras — estas são deep-merged com opackage.jsonbase - Overlays de feature podem sobrescrever arquivos do template base ou de outras features (último aplicado vence)
- Overlays específicos de preset (
auth-sanctum/,auth-passport/) contêm apenashttp.ts,stores/auth.tseservices/auth/types.ts - Arquivos auth comuns (guards, routes, pages, mutations, queries) ficam em
auth-common/e são copiados seletivamente pelogenerator.ts
Contribuindo
- Fork o repositório
- Crie uma branch de feature (
git checkout -b feat/my-feature) - Faça suas alterações
- Execute
npm test— todos os testes devem passar - Commit suas alterações
- Abra um Pull Request
CI roda automaticamente em push/PR: build, testes unitários, depois testes de integração.
Adicionando uma Nova Feature
- Crie
template/features/<name>/com umpackage.jsonlistando dependências extras - Adicione arquivos fonte em
template/features/<name>/src/ - Adicione o nome da feature ao tipo
Featureemsrc/types.ts - Adicione uma opção de prompt em
src/prompts.ts - Se a feature precisar de imports dinâmicos no
main.ts, atualizesrc/generators/main-ts.ts - Se a feature adicionar plugins Vite, atualize
src/generators/vite-config.ts
Adicionando um Novo Preset de Auth
- Crie
template/presets/auth-<name>/com arquivos específicos do preset (http.ts,stores/auth.ts,services/auth/types.ts) - Adicione o nome do preset ao tipo
AuthPresetemsrc/types.ts - Adicione uma opção de prompt em
src/prompts.ts - Atualize
src/generators/auth-indexes.tsse o preset tiver funções de serviço diferentes
Adicionando uma Nova Página de Auth
- Adicione o nome da página ao tipo
AuthPageeSELECTABLE_AUTH_PAGESemsrc/types.ts - Adicione variante UI em
template/presets/auth-common/src/modules/auth/pages/ui/ - Adicione mutation em
template/presets/auth-common/src/services/auth/mutations/ - Adicione entrada no mapa
AUTH_PAGE_FILESemsrc/generator.ts - Atualize
src/generators/auth-router.tsesrc/generators/auth-indexes.ts - Adicione uma opção multiselect em
src/prompts.ts
Licença
MIT
