@storytype/cli 0.2.3
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/README.md +282 -0
- package/dist/chunk-6DCDOH2S.js +507 -0
- package/dist/chunk-B35YCGV4.js +509 -0
- package/dist/chunk-C3R5YJAX.js +452 -0
- package/dist/chunk-IKQA7RO2.js +460 -0
- package/dist/chunk-MCTEMBK5.js +460 -0
- package/dist/chunk-ROL3KHCC.js +544 -0
- package/dist/chunk-U5YZ7DDR.js +523 -0
- package/dist/chunk-YXHZ2IEP.js +518 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +491 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +18 -0
- package/dist/templates/component/component.vue.hbs +20 -0
- package/dist/templates/component/index.ts.hbs +4 -0
- package/dist/templates/component/mock.ts.hbs +21 -0
- package/dist/templates/component/stories.ts.hbs +28 -0
- package/dist/templates/component/types.ts.hbs +17 -0
- package/package.json +78 -0
- package/src/templates/component/component.vue.hbs +20 -0
- package/src/templates/component/index.ts.hbs +4 -0
- package/src/templates/component/mock.ts.hbs +21 -0
- package/src/templates/component/stories.ts.hbs +28 -0
- package/src/templates/component/types.ts.hbs +17 -0
package/README.md
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# @storytype/cli
|
|
2
|
+
|
|
3
|
+
CLI tool for scaffolding Storytype components and analyzing project structure.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Using the short alias
|
|
9
|
+
npm install -g storytype
|
|
10
|
+
|
|
11
|
+
# Or the full package name
|
|
12
|
+
npm install -g @storytype/cli
|
|
13
|
+
|
|
14
|
+
# Both provide the same 'storytype' command
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
### `storytype generate <type> <name>` (alias: `g`)
|
|
20
|
+
|
|
21
|
+
Generate a new component following Atomic Design and Storytype conventions.
|
|
22
|
+
|
|
23
|
+
**Arguments:**
|
|
24
|
+
|
|
25
|
+
- `type` - Component type: `atomos`, `moleculas`, `organismos`, or `templates`
|
|
26
|
+
- `name` - Component name (will be converted to PascalCase)
|
|
27
|
+
|
|
28
|
+
**Options:**
|
|
29
|
+
|
|
30
|
+
- `-p, --path <path>` - Custom path for the component (default: current directory)
|
|
31
|
+
|
|
32
|
+
**What it creates:**
|
|
33
|
+
|
|
34
|
+
- Component directory in kebab-case (`my-component/`)
|
|
35
|
+
- Vue component file in PascalCase (`MyComponent.vue`)
|
|
36
|
+
- TypeScript types file (`MyComponent.types.ts`)
|
|
37
|
+
- Storybook stories file (`MyComponent.stories.ts`)
|
|
38
|
+
- Mock data file (`MyComponent.mock.ts`)
|
|
39
|
+
- Index file with exports (`index.ts`)
|
|
40
|
+
|
|
41
|
+
**Examples:**
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Generate an atom component
|
|
45
|
+
storytype generate atomos Button
|
|
46
|
+
|
|
47
|
+
# Generate a molecule with custom path
|
|
48
|
+
storytype g moleculas SearchBar --path src/components
|
|
49
|
+
|
|
50
|
+
# Generate an organism
|
|
51
|
+
storytype generate organismos DataTable
|
|
52
|
+
|
|
53
|
+
# Name will be normalized - all these create UserProfile component
|
|
54
|
+
storytype g atomos user-profile
|
|
55
|
+
storytype g atomos userProfile
|
|
56
|
+
storytype g atomos UserProfile
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### `storytype normalize [path]`
|
|
60
|
+
|
|
61
|
+
Normalize existing component structure to follow Storytype conventions:
|
|
62
|
+
|
|
63
|
+
- Convert directories to kebab-case (`UserProfile/` → `user-profile/`)
|
|
64
|
+
- Convert component files to PascalCase (`user-profile.vue` → `UserProfile.vue`)
|
|
65
|
+
- Create missing files (`index.ts`, `.types.ts`, `.spec.ts`)
|
|
66
|
+
- Update imports automatically
|
|
67
|
+
|
|
68
|
+
**Arguments:**
|
|
69
|
+
|
|
70
|
+
- `path` - Directory to normalize (default: current directory)
|
|
71
|
+
|
|
72
|
+
**Options:**
|
|
73
|
+
|
|
74
|
+
- `-d, --dry-run` - Show changes without executing them
|
|
75
|
+
- `--dirs-only` - Only normalize directory names
|
|
76
|
+
- `--files-only` - Only normalize file names and create missing files
|
|
77
|
+
- `-v, --verbose` - Show detailed output
|
|
78
|
+
|
|
79
|
+
**What it does:**
|
|
80
|
+
|
|
81
|
+
1. Scans for Vue components in the directory
|
|
82
|
+
2. Checks directory names (should be kebab-case)
|
|
83
|
+
3. Checks file names (components should be PascalCase)
|
|
84
|
+
4. Detects missing files (`index.ts`, `.types.ts`, `.spec.ts`)
|
|
85
|
+
5. Uses `git mv` for tracked files (preserves history)
|
|
86
|
+
6. Creates missing files with templates
|
|
87
|
+
|
|
88
|
+
**Examples:**
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Dry-run to see what would change
|
|
92
|
+
storytype normalize --dry-run
|
|
93
|
+
|
|
94
|
+
# Normalize specific directory
|
|
95
|
+
storytype normalize src/components
|
|
96
|
+
|
|
97
|
+
# Only fix directory names
|
|
98
|
+
storytype normalize --dirs-only
|
|
99
|
+
|
|
100
|
+
# Only fix file names and create missing files
|
|
101
|
+
storytype normalize --files-only
|
|
102
|
+
|
|
103
|
+
# Show detailed changes
|
|
104
|
+
storytype normalize -v --dry-run
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `storytype init`
|
|
108
|
+
|
|
109
|
+
Initialize Storytype in your project, creating the necessary folder structure and configuration files.
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
storytype init
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### `storytype analyze [path]` (alias: `audit`)
|
|
116
|
+
|
|
117
|
+
Analyze and score your project based on Storytype best practices.
|
|
118
|
+
|
|
119
|
+
**Arguments:**
|
|
120
|
+
|
|
121
|
+
- `path` - Project path to analyze (defaults to current directory)
|
|
122
|
+
|
|
123
|
+
**Options:**
|
|
124
|
+
|
|
125
|
+
- `-v, --verbose` - Show per-file issues and how to fix each one
|
|
126
|
+
|
|
127
|
+
**What it analyzes:**
|
|
128
|
+
|
|
129
|
+
1. **Estrutura Atomic Design (50 pts)**
|
|
130
|
+
- ✓ Components directory structure
|
|
131
|
+
- ✓ Atomic Design levels (atoms, molecules, organisms, templates, pages)
|
|
132
|
+
- ✓ Component organization
|
|
133
|
+
|
|
134
|
+
2. **TypeScript (30 pts)**
|
|
135
|
+
- ✓ TypeScript configuration (tsconfig.json)
|
|
136
|
+
- ✓ TypeScript usage in components
|
|
137
|
+
- ✓ Dedicated type files
|
|
138
|
+
|
|
139
|
+
3. **Testes e Stories (30 pts)**
|
|
140
|
+
- ✓ Test coverage (70%+ target)
|
|
141
|
+
- ✓ Storybook stories coverage (70%+ target)
|
|
142
|
+
|
|
143
|
+
4. **Nomenclatura (15 pts)**
|
|
144
|
+
- ✓ PascalCase convention
|
|
145
|
+
- ✓ Folder organization pattern
|
|
146
|
+
|
|
147
|
+
5. **Documentação (10 pts)**
|
|
148
|
+
- ✓ README.md file
|
|
149
|
+
- ✓ Documentation directory
|
|
150
|
+
|
|
151
|
+
**Examples:**
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Analyze current directory
|
|
155
|
+
storytype analyze
|
|
156
|
+
|
|
157
|
+
# Analyze specific project
|
|
158
|
+
storytype analyze /path/to/project
|
|
159
|
+
|
|
160
|
+
# Show per-file issues and how to fix them
|
|
161
|
+
storytype analyze --verbose
|
|
162
|
+
storytype analyze /path/to/project -v
|
|
163
|
+
|
|
164
|
+
# Using alias
|
|
165
|
+
storytype audit
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Sample Output:**
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
============================================================
|
|
172
|
+
📊 ANÁLISE DO PROJETO STORYTYPE
|
|
173
|
+
============================================================
|
|
174
|
+
|
|
175
|
+
Score Geral: 77/135 (57%)
|
|
176
|
+
Projeto precisa de melhorias significativas. ⚠️
|
|
177
|
+
|
|
178
|
+
Estrutura Atomic Design: 40/50 (80%)
|
|
179
|
+
✓ Diretório de componentes: 10/10 pts
|
|
180
|
+
Encontrado em: src/components
|
|
181
|
+
✓ Níveis Atomic Design: 15/25 pts
|
|
182
|
+
Encontrados: atoms, molecules, organisms (3/5)
|
|
183
|
+
✓ Organização de componentes: 15/15 pts
|
|
184
|
+
3 componentes encontrados
|
|
185
|
+
|
|
186
|
+
[...]
|
|
187
|
+
|
|
188
|
+
💡 Recomendações:
|
|
189
|
+
|
|
190
|
+
1. Migre mais componentes para TypeScript
|
|
191
|
+
2. Adicione mais testes unitários (meta: 70%+)
|
|
192
|
+
3. Crie stories no Storybook (meta: 70%+)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Score Ranges:**
|
|
196
|
+
|
|
197
|
+
- 🏆 **90-100%** - Excelente! Projeto muito bem estruturado!
|
|
198
|
+
- 🎯 **75-89%** - Muito bom! Algumas melhorias podem ser feitas.
|
|
199
|
+
- 💪 **60-74%** - Bom começo! Há espaço para melhorias.
|
|
200
|
+
- ⚠️ **40-59%** - Projeto precisa de melhorias significativas.
|
|
201
|
+
- 🔧 **0-39%** - Projeto precisa de reestruturação.
|
|
202
|
+
|
|
203
|
+
## Programmatic API
|
|
204
|
+
|
|
205
|
+
You can also use the CLI programmatically:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { generateComponent, normalizeComponents, analyzeProject, displayResults } from 'storytype';
|
|
209
|
+
|
|
210
|
+
// Generate component
|
|
211
|
+
await generateComponent({
|
|
212
|
+
name: 'Button',
|
|
213
|
+
type: 'atomos',
|
|
214
|
+
path: 'src/components',
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// Normalize components
|
|
218
|
+
const result = await normalizeComponents({
|
|
219
|
+
path: 'src/components',
|
|
220
|
+
dryRun: false,
|
|
221
|
+
dirsOnly: false,
|
|
222
|
+
filesOnly: false,
|
|
223
|
+
verbose: true,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// Analyze project
|
|
227
|
+
const analysis = await analyzeProject('/path/to/project');
|
|
228
|
+
console.log(`Score: ${analysis.percentage}%`);
|
|
229
|
+
|
|
230
|
+
// Display full results
|
|
231
|
+
displayResults(analysis);
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Best Practices
|
|
235
|
+
|
|
236
|
+
### Component Structure
|
|
237
|
+
|
|
238
|
+
Follow the Atomic Design methodology:
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
src/kebab-case** for component directories: `user-profile/`, `data-table/`
|
|
242
|
+
- Use **PascalCase** for component files: `UserProfile.vue`, `DataTable.tsx`
|
|
243
|
+
- Include TypeScript types: `UserProfile.types.ts`
|
|
244
|
+
- Include tests: `UserProfile.spec.ts` or `UserProfile.test.ts`
|
|
245
|
+
- Include stories: `UserProfile.stories.ts`
|
|
246
|
+
- Include index file: `index.ts` for exports
|
|
247
|
+
|
|
248
|
+
**Example structure:**
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
src/components/atomos/user-button/
|
|
253
|
+
├── UserButton.vue
|
|
254
|
+
├── UserButton.types.ts
|
|
255
|
+
├── UserButton.spec.ts
|
|
256
|
+
├── UserButton.stories.ts
|
|
257
|
+
├── UserButton.mock.ts
|
|
258
|
+
└── index.ts
|
|
259
|
+
``ps of atoms (SearchField, Card)
|
|
260
|
+
├── organisms/ # Complex UI components (Header, Form, Modal)
|
|
261
|
+
├── templates/ # Page-level layouts
|
|
262
|
+
└── pages/ # Specific page instances
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Component Naming
|
|
267
|
+
|
|
268
|
+
- Use **PascalCase** for component files: `Button.vue`, `SearchBar.tsx`
|
|
269
|
+
- Organize in folders: `Button/Button.vue` or `Button/index.vue`
|
|
270
|
+
- Include tests: `Button.spec.ts` or `Button.test.ts`
|
|
271
|
+
- Include stories: `Button.stories.ts`
|
|
272
|
+
|
|
273
|
+
### TypeScript
|
|
274
|
+
|
|
275
|
+
- Always use TypeScript for better type safety
|
|
276
|
+
- Define prop types and interfaces
|
|
277
|
+
- Create dedicated type files when needed
|
|
278
|
+
|
|
279
|
+
## License
|
|
280
|
+
|
|
281
|
+
MIT
|
|
282
|
+
```
|