vue-feat-cli 26.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 João Pedro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,286 @@
1
+ # vue-feat-cli
2
+
3
+ An opinionated CLI for scaffolding feature-based Vue 3 projects. Generates consistent, typed code following a layered architecture: service → composable → store → view.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g vue-feat-cli
9
+ ```
10
+
11
+ Or use directly with npx:
12
+
13
+ ```bash
14
+ npx vue-feat-cli init
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ ```bash
20
+ # 1. Initialize — detects your stack and creates vf.config.json
21
+ vf init
22
+
23
+ # 2. Generate your first feature
24
+ vf g:feat Product
25
+
26
+ # Get help at any time
27
+ vf help
28
+ vf help generate:feat
29
+ ```
30
+
31
+ ## Commands
32
+
33
+ ### `help`
34
+
35
+ Shows an overview of all commands and their descriptions. Pass a command name (or its alias) to get detailed docs with options, examples, and related commands.
36
+
37
+ ```bash
38
+ vf help # overview interativo de todos os comandos
39
+ vf help generate:feat # docs detalhados de generate:feat
40
+ vf help g:feat # aliases também funcionam
41
+ ```
42
+
43
+ ---
44
+
45
+ ### `init`
46
+
47
+ Detects the project's installed dependencies (Pinia, Vue Router, Axios) and the TypeScript path alias, then saves `vf.config.json` at the project root and creates `src/shared/http/client.ts`.
48
+
49
+ ```bash
50
+ vf init
51
+ ```
52
+
53
+ Produces `vf.config.json`:
54
+
55
+ ```json
56
+ {
57
+ "srcDir": "src",
58
+ "featuresDir": "src/features",
59
+ "sharedDir": "src/shared",
60
+ "alias": "@",
61
+ "httpClient": "fetch",
62
+ "usesPinia": true,
63
+ "usesVueRouter": true,
64
+ "usesTanstackQuery": false
65
+ }
66
+ ```
67
+
68
+ All subsequent generators read this file. If it doesn't exist, safe defaults are used (`fetch`, no Pinia, no Router).
69
+
70
+ ---
71
+
72
+ ### `g:feat <name>`
73
+
74
+ Scaffolds a complete feature module under `featuresDir/<name>/`.
75
+
76
+ ```bash
77
+ vf g:feat Product
78
+ ```
79
+
80
+ Generated structure (with Pinia + Vue Router enabled):
81
+
82
+ ```
83
+ src/features/product/
84
+ ├── composables/
85
+ │ ├── useProductService.ts # business logic (data refs, CRUD)
86
+ │ └── useProductPage.ts # UI state (loading, error) — delegates to service
87
+ ├── services/
88
+ │ └── product.service.ts # HTTP layer using httpClient
89
+ ├── stores/
90
+ │ └── product.store.ts # Pinia store (Composition API) or reactive() fallback
91
+ ├── types/
92
+ │ └── product.types.ts # entity interface + CreateDto + UpdateDto
93
+ ├── views/
94
+ │ └── ProductView.vue # page component wired to useProductPage (Vue Router only)
95
+ ├── routes.ts # lazy-loaded route record (Vue Router only)
96
+ ├── components/ # feature-local components (empty)
97
+ └── index.ts # public barrel export
98
+ ```
99
+
100
+ Without Vue Router, `routes.ts` and `views/` are omitted and a blank `views/` folder is created instead.
101
+
102
+ ---
103
+
104
+ ### `g:composable <name>`
105
+
106
+ Creates a standalone composable inside a feature or in `sharedDir/composables/`.
107
+
108
+ ```bash
109
+ vf g:composable useFilters --feature product
110
+ vf g:composable useTheme # → src/shared/composables/useTheme.ts
111
+ ```
112
+
113
+ ---
114
+
115
+ ### `g:component <name>`
116
+
117
+ Creates a Vue component. Supports nested paths.
118
+
119
+ ```bash
120
+ vf g:component ProductCard --feature product
121
+ vf g:component cards/ProductCard
122
+ ```
123
+
124
+ ---
125
+
126
+ ### `g:service <name>`
127
+
128
+ Adds a service and its types file to an existing feature.
129
+
130
+ ```bash
131
+ vf g:service product --feature product
132
+ ```
133
+
134
+ ---
135
+
136
+ ### `g:store <name>`
137
+
138
+ Adds a store to an existing feature. Uses Pinia (`defineStore`) when `usesPinia: true`, falls back to `reactive()` otherwise.
139
+
140
+ ```bash
141
+ vf g:store product --feature product
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Architecture
147
+
148
+ Each feature follows a strict layered separation:
149
+
150
+ ```
151
+ service.ts
152
+ └── useXxxService.ts ← business composable: data refs + CRUD, no UI state
153
+ └── useXxxPage.ts ← UI composable: loading + error, delegates to service
154
+ └── XxxView.vue ← page component, calls load() on mount
155
+ ```
156
+
157
+ **Why two composables?**
158
+
159
+ - `useXxxService` owns domain data. Can be reused (e.g. in a modal) without triggering loading spinners.
160
+ - `useXxxPage` owns UI concerns. Keeps views thin and independently testable.
161
+
162
+ The store is optional and intended for state that must be shared across features.
163
+
164
+ ---
165
+
166
+ ## HTTP client
167
+
168
+ `vf init` generates `src/shared/http/client.ts` with a unified `httpClient` interface:
169
+
170
+ ```ts
171
+ httpClient.get<T>(url)
172
+ httpClient.post<T>(url, body)
173
+ httpClient.put<T>(url, body)
174
+ httpClient.patch<T>(url, body)
175
+ httpClient.delete<T>(url)
176
+ ```
177
+
178
+ Both the `fetch` and `axios` implementations expose the same interface, so generated services work unchanged regardless of which you choose.
179
+
180
+ The base URL is read from the `VITE_API_BASE_URL` environment variable.
181
+
182
+ ---
183
+
184
+ ## Expected project structure
185
+
186
+ ```
187
+ src/
188
+ ├── features/ # generated modules
189
+ ├── shared/
190
+ │ ├── http/
191
+ │ │ └── client.ts # generated by vf init
192
+ │ └── composables/
193
+ └── main.ts
194
+ ```
195
+
196
+ The path alias (`@` by default) must point to `src/` in your `tsconfig.json`:
197
+
198
+ ```json
199
+ {
200
+ "compilerOptions": {
201
+ "paths": { "@/*": ["./src/*"] }
202
+ }
203
+ }
204
+ ```
205
+
206
+ ---
207
+
208
+ ## Custom Templates
209
+
210
+ You can override any scaffold template on a per-project basis by creating `.hbs` files in a local folder and pointing `vf.config.json` to it.
211
+
212
+ ### Setup
213
+
214
+ **Option A — via `vf init`:**
215
+ Answer `y` when asked _"Use custom templates?"_. This sets `templatesDir: ".vf/templates"` in `vf.config.json` and creates the empty folder.
216
+
217
+ **Option B — copy all defaults for editing:**
218
+ ```bash
219
+ vf templates:init
220
+ ```
221
+ This copies every built-in template to `.vf/templates/`, ready to edit. It also adds `"templatesDir": ".vf/templates"` to `vf.config.json` if not already set.
222
+
223
+ **Option C — manual:**
224
+ Add `"templatesDir": ".vf/templates"` to your `vf.config.json` and create only the templates you want to override.
225
+
226
+ ### File structure
227
+
228
+ Your local templates must mirror the built-in structure:
229
+
230
+ ```
231
+ .vf/templates/
232
+ ├── component/
233
+ │ └── Component.vue.hbs
234
+ ├── composable/
235
+ │ └── composable.ts.hbs
236
+ └── feature/
237
+ ├── service.ts.hbs
238
+ ├── service-crud.ts.hbs
239
+ ├── service-composable.ts.hbs
240
+ ├── service-composable-crud.ts.hbs
241
+ ├── page-composable.ts.hbs
242
+ ├── page-composable-crud.ts.hbs
243
+ ├── store.ts.hbs
244
+ ├── store-composable.ts.hbs
245
+ ├── types.ts.hbs
246
+ ├── types-crud.ts.hbs
247
+ ├── index.ts.hbs
248
+ ├── routes.ts.hbs
249
+ └── View.vue.hbs
250
+ ```
251
+
252
+ You only need to include the files you want to override — missing files fall back to the built-in defaults automatically.
253
+
254
+ ### Handlebars context variables
255
+
256
+ | Variable | Type | Available in |
257
+ |---|---|---|
258
+ | `name` | `string` | all templates — kebab-case feature name |
259
+ | `Name` | `string` | all templates — PascalCase feature name |
260
+ | `nameCamel` | `string` | feature templates — camelCase feature name |
261
+ | `alias` | `string` | feature templates — import alias from config (e.g. `@`) |
262
+ | `usesVueRouter` | `boolean` | feature templates |
263
+
264
+ ### `.gitignore` recommendation
265
+
266
+ Commit `.vf/templates/` to your repo so the whole team uses the same overrides:
267
+
268
+ ```
269
+ # .gitignore — do NOT ignore .vf/templates if you want team-wide overrides
270
+ # .vf/ ← remove this line if present
271
+ ```
272
+
273
+ If you want the overrides to be personal only, add `.vf/` to `.gitignore`.
274
+
275
+ ---
276
+
277
+ ## Development
278
+
279
+ ```bash
280
+ npm run dev # run CLI with tsx (no build step)
281
+ npm run build # compile to dist/
282
+ ```
283
+
284
+ ## License
285
+
286
+ MIT
package/bin/vf.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.js';
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }