servcraft 0.1.7 → 0.3.1
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/.github/workflows/ci.yml +9 -4
- package/README.md +63 -2
- package/ROADMAP.md +86 -41
- package/dist/cli/index.cjs +1510 -172
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +1516 -172
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/add-module.ts +36 -7
- package/src/cli/commands/completion.ts +146 -0
- package/src/cli/commands/doctor.ts +123 -0
- package/src/cli/commands/generate.ts +73 -1
- package/src/cli/commands/init.ts +29 -10
- package/src/cli/commands/list.ts +274 -0
- package/src/cli/commands/remove.ts +102 -0
- package/src/cli/commands/update.ts +221 -0
- package/src/cli/index.ts +20 -0
- package/src/cli/templates/controller-test.ts +110 -0
- package/src/cli/templates/integration-test.ts +139 -0
- package/src/cli/templates/service-test.ts +100 -0
- package/src/cli/utils/dry-run.ts +155 -0
- package/src/cli/utils/error-handler.ts +184 -0
- package/src/cli/utils/helpers.ts +13 -0
- package/tests/cli/add.test.ts +32 -0
- package/tests/cli/completion.test.ts +35 -0
- package/tests/cli/doctor.test.ts +23 -0
- package/tests/cli/dry-run.test.ts +39 -0
- package/tests/cli/errors.test.ts +29 -0
- package/tests/cli/generate.test.ts +39 -0
- package/tests/cli/init.test.ts +63 -0
- package/tests/cli/list.test.ts +25 -0
- package/tests/cli/remove.test.ts +28 -0
- package/tests/cli/update.test.ts +34 -0
package/.github/workflows/ci.yml
CHANGED
|
@@ -82,10 +82,15 @@ jobs:
|
|
|
82
82
|
retention-days: 7
|
|
83
83
|
|
|
84
84
|
test:
|
|
85
|
-
name: Tests
|
|
85
|
+
name: Tests (Node ${{ matrix.node-version }})
|
|
86
86
|
runs-on: ubuntu-latest
|
|
87
87
|
needs: [lint, typecheck]
|
|
88
88
|
|
|
89
|
+
strategy:
|
|
90
|
+
matrix:
|
|
91
|
+
node-version: [18, 20, 22]
|
|
92
|
+
fail-fast: false
|
|
93
|
+
|
|
89
94
|
services:
|
|
90
95
|
postgres:
|
|
91
96
|
image: postgres:16-alpine
|
|
@@ -124,7 +129,7 @@ jobs:
|
|
|
124
129
|
- name: Setup Node.js
|
|
125
130
|
uses: actions/setup-node@v4
|
|
126
131
|
with:
|
|
127
|
-
node-version: ${{
|
|
132
|
+
node-version: ${{ matrix.node-version }}
|
|
128
133
|
cache: 'npm'
|
|
129
134
|
|
|
130
135
|
- name: Install dependencies
|
|
@@ -145,9 +150,9 @@ jobs:
|
|
|
145
150
|
|
|
146
151
|
- name: Upload coverage report
|
|
147
152
|
uses: actions/upload-artifact@v4
|
|
148
|
-
if: github.event_name == 'pull_request'
|
|
153
|
+
if: github.event_name == 'pull_request' && matrix.node-version == 20
|
|
149
154
|
with:
|
|
150
|
-
name: coverage
|
|
155
|
+
name: coverage-node-${{ matrix.node-version }}
|
|
151
156
|
path: coverage/
|
|
152
157
|
retention-days: 7
|
|
153
158
|
|
package/README.md
CHANGED
|
@@ -265,11 +265,13 @@ servcraft init --ts # Use TypeScript (default)
|
|
|
265
265
|
servcraft init --esm # Use ES Modules (default)
|
|
266
266
|
servcraft init --cjs # Use CommonJS
|
|
267
267
|
servcraft init --db postgresql # Specify database
|
|
268
|
+
servcraft init --dry-run # Preview files without writing
|
|
268
269
|
|
|
269
270
|
# Combined examples
|
|
270
271
|
servcraft init my-app --js --esm --db postgresql -y # JS + ESM + PostgreSQL
|
|
271
272
|
servcraft init my-app --js --cjs --db mongodb -y # JS + CommonJS + MongoDB
|
|
272
273
|
servcraft init my-app --ts --db mysql -y # TypeScript + MySQL
|
|
274
|
+
servcraft init my-app --dry-run -y # Preview without creating
|
|
273
275
|
```
|
|
274
276
|
|
|
275
277
|
### Generate resources
|
|
@@ -277,7 +279,9 @@ servcraft init my-app --ts --db mysql -y # TypeScript + MySQL
|
|
|
277
279
|
```bash
|
|
278
280
|
# Generate complete module
|
|
279
281
|
servcraft generate module product
|
|
280
|
-
servcraft g m product --prisma
|
|
282
|
+
servcraft g m product --prisma # Include Prisma model
|
|
283
|
+
servcraft g m product --with-tests # Include test files (__tests__ directory)
|
|
284
|
+
servcraft g m product --dry-run # Preview files
|
|
281
285
|
|
|
282
286
|
# Generate individual files
|
|
283
287
|
servcraft generate controller user
|
|
@@ -291,8 +295,65 @@ servcraft g c user # controller
|
|
|
291
295
|
servcraft g s order # service
|
|
292
296
|
servcraft g r item # repository
|
|
293
297
|
servcraft g v post # schema/validator
|
|
298
|
+
|
|
299
|
+
# Preview before generating
|
|
300
|
+
servcraft g m product name:string price:number --dry-run
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### List available modules
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
servcraft list # Show all available modules
|
|
307
|
+
servcraft list --installed # Show only installed modules
|
|
308
|
+
servcraft list --available # Show only available modules
|
|
309
|
+
servcraft list --category Security # Filter by category
|
|
310
|
+
servcraft list --json # Output as JSON
|
|
311
|
+
|
|
312
|
+
# Aliases
|
|
313
|
+
servcraft ls # Same as list
|
|
294
314
|
```
|
|
295
315
|
|
|
316
|
+
### Module Management
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
# Update modules
|
|
320
|
+
servcraft update # Update all installed modules
|
|
321
|
+
servcraft update auth # Update specific module
|
|
322
|
+
servcraft update --check # Check for updates without applying
|
|
323
|
+
servcraft update auth --yes # Skip confirmation
|
|
324
|
+
|
|
325
|
+
# Remove a module
|
|
326
|
+
servcraft remove auth # Interactive confirmation
|
|
327
|
+
servcraft rm auth --yes # Skip confirmation
|
|
328
|
+
servcraft remove auth --keep-env # Keep environment variables
|
|
329
|
+
|
|
330
|
+
# Diagnose project
|
|
331
|
+
servcraft doctor # Check configuration and dependencies
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Shell Auto-completion
|
|
335
|
+
|
|
336
|
+
Enable tab completion for servcraft commands in your shell:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
# Bash - Add to ~/.bashrc or ~/.bash_profile
|
|
340
|
+
servcraft completion bash >> ~/.bashrc
|
|
341
|
+
source ~/.bashrc
|
|
342
|
+
|
|
343
|
+
# Zsh - Add to ~/.zshrc
|
|
344
|
+
servcraft completion zsh >> ~/.zshrc
|
|
345
|
+
source ~/.zshrc
|
|
346
|
+
|
|
347
|
+
# Or save to completion directory (Zsh)
|
|
348
|
+
servcraft completion zsh > ~/.zsh/completion/_servcraft
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
After enabling, you can use tab to autocomplete:
|
|
352
|
+
- Commands: `servcraft <TAB>`
|
|
353
|
+
- Subcommands: `servcraft generate <TAB>`
|
|
354
|
+
- Module names: `servcraft add <TAB>`
|
|
355
|
+
- Options and flags
|
|
356
|
+
|
|
296
357
|
### Add pre-built modules
|
|
297
358
|
|
|
298
359
|
```bash
|
|
@@ -312,7 +373,7 @@ servcraft add feature-flag # Feature flags & A/B testing
|
|
|
312
373
|
servcraft add analytics # Prometheus metrics & tracking
|
|
313
374
|
servcraft add media-processing # Image/video processing
|
|
314
375
|
servcraft add api-versioning # API version management
|
|
315
|
-
servcraft add --
|
|
376
|
+
servcraft add auth --dry-run # Preview module files
|
|
316
377
|
```
|
|
317
378
|
|
|
318
379
|
**Automatic Environment Configuration:**
|
package/ROADMAP.md
CHANGED
|
@@ -4,7 +4,11 @@ This document outlines the planned features and improvements for Servcraft.
|
|
|
4
4
|
|
|
5
5
|
## Version History
|
|
6
6
|
|
|
7
|
-
- **v0.
|
|
7
|
+
- **v0.3.0** (Current) - Shell auto-completion, update command, comprehensive CLI tests (30 tests) - Phase 2 in progress 🚧
|
|
8
|
+
- **v0.2.0** - Better errors, remove, doctor, update (stub) - Phase 1 complete ✅
|
|
9
|
+
- **v0.1.9** - Added `--dry-run` option for all commands (init, add, generate)
|
|
10
|
+
- **v0.1.8** - Added `servcraft list` command
|
|
11
|
+
- **v0.1.7** - ESM/CommonJS module system choice
|
|
8
12
|
- **v0.1.6.3** - JavaScript/TypeScript support, docs command, bug fixes
|
|
9
13
|
- **v0.1.6.2** - Fixed empty modules, added config/middleware/utils generators
|
|
10
14
|
- **v0.1.6.1** - Added @fastify/jwt compatibility fix
|
|
@@ -12,23 +16,37 @@ This document outlines the planned features and improvements for Servcraft.
|
|
|
12
16
|
|
|
13
17
|
---
|
|
14
18
|
|
|
15
|
-
## Phase 1: Core CLI Improvements (v0.2.x)
|
|
19
|
+
## Phase 1: Core CLI Improvements (v0.2.x) ✅ COMPLETE
|
|
20
|
+
|
|
21
|
+
**Achievements:**
|
|
22
|
+
- ✅ `servcraft list` - List available and installed modules
|
|
23
|
+
- ✅ `--dry-run` - Preview changes for init, add, generate commands
|
|
24
|
+
- ✅ Better error messages - Suggestions, colored output, docs links
|
|
25
|
+
- ✅ `servcraft remove` - Remove modules with confirmation
|
|
26
|
+
- ✅ `servcraft doctor` - Diagnose project configuration
|
|
27
|
+
- ⏳ `servcraft update` - Stub created for v0.2.1
|
|
28
|
+
|
|
29
|
+
---
|
|
16
30
|
|
|
17
31
|
### v0.2.0 - CLI Enhancements
|
|
18
32
|
|
|
19
|
-
#### `servcraft list`
|
|
33
|
+
#### `servcraft list` ✅ Completed in v0.1.8
|
|
20
34
|
List available and installed modules.
|
|
21
35
|
```bash
|
|
22
|
-
servcraft list
|
|
23
|
-
servcraft list --installed
|
|
36
|
+
servcraft list # List all available modules
|
|
37
|
+
servcraft list --installed # List installed modules only
|
|
38
|
+
servcraft list --category Security # Filter by category
|
|
39
|
+
servcraft list --json # Output as JSON
|
|
24
40
|
```
|
|
25
41
|
|
|
26
|
-
#### `--dry-run` Option
|
|
42
|
+
#### `--dry-run` Option ✅ Completed in v0.1.9
|
|
27
43
|
Preview changes without writing files.
|
|
28
44
|
```bash
|
|
29
|
-
servcraft init my-app --dry-run
|
|
30
|
-
servcraft add auth --dry-run
|
|
31
|
-
servcraft generate module users --dry-run
|
|
45
|
+
servcraft init my-app --dry-run # ✅ Implemented
|
|
46
|
+
servcraft add auth --dry-run # ✅ Implemented
|
|
47
|
+
servcraft generate module users --dry-run # ✅ Implemented
|
|
48
|
+
servcraft generate controller users --dry-run # ✅ Implemented
|
|
49
|
+
servcraft generate service users --dry-run # ✅ Implemented
|
|
32
50
|
```
|
|
33
51
|
|
|
34
52
|
#### Better Error Messages
|
|
@@ -42,89 +60,108 @@ servcraft generate module users --dry-run
|
|
|
42
60
|
|
|
43
61
|
### v0.2.1 - Module Management
|
|
44
62
|
|
|
45
|
-
#### `servcraft remove <module>`
|
|
63
|
+
#### `servcraft remove <module>` ✅ Completed in v0.2.0
|
|
46
64
|
Remove an installed module.
|
|
47
65
|
```bash
|
|
48
66
|
servcraft remove auth
|
|
49
|
-
servcraft remove auth --
|
|
67
|
+
servcraft remove auth --yes # Skip confirmation
|
|
68
|
+
servcraft remove auth --keep-env # Keep environment variables
|
|
50
69
|
```
|
|
51
70
|
|
|
52
71
|
Features:
|
|
53
|
-
- Remove module files from `src/modules/`
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
72
|
+
- ✅ Remove module files from `src/modules/`
|
|
73
|
+
- ✅ Interactive confirmation
|
|
74
|
+
- ✅ Show cleanup instructions
|
|
75
|
+
- ✅ Alias: rm
|
|
57
76
|
|
|
58
|
-
#### `servcraft update [module]`
|
|
77
|
+
#### `servcraft update [module]` ✅ Completed in v0.3.0
|
|
59
78
|
Update modules to latest version.
|
|
60
79
|
```bash
|
|
61
80
|
servcraft update # Update all modules
|
|
62
81
|
servcraft update auth # Update specific module
|
|
63
82
|
servcraft update --check # Check for updates without applying
|
|
83
|
+
servcraft update --yes # Skip confirmation
|
|
64
84
|
```
|
|
65
85
|
|
|
86
|
+
Features:
|
|
87
|
+
- ✅ Update specific module or all installed modules
|
|
88
|
+
- ✅ Interactive confirmation before updating
|
|
89
|
+
- ✅ Check mode to see what would be updated
|
|
90
|
+
- ✅ Overwrites existing files with latest version
|
|
91
|
+
- ✅ Error handling and validation
|
|
92
|
+
|
|
93
|
+
Note: Version tracking will be added in a future release. Currently always installs latest version.
|
|
94
|
+
|
|
66
95
|
**Estimated complexity:** Medium
|
|
67
96
|
|
|
68
97
|
---
|
|
69
98
|
|
|
70
99
|
### v0.2.2 - Developer Experience
|
|
71
100
|
|
|
72
|
-
#### `servcraft doctor`
|
|
101
|
+
#### `servcraft doctor` ✅ Completed in v0.2.0
|
|
73
102
|
Diagnose project configuration issues.
|
|
74
103
|
```bash
|
|
75
104
|
servcraft doctor
|
|
76
105
|
```
|
|
77
106
|
|
|
78
107
|
Checks:
|
|
79
|
-
- Node.js version compatibility
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
#### Shell Auto-completion
|
|
108
|
+
- ✅ Node.js version compatibility
|
|
109
|
+
- ✅ package.json and Fastify
|
|
110
|
+
- ✅ Project directories (src, node_modules)
|
|
111
|
+
- ✅ Git repository
|
|
112
|
+
- ✅ .env file
|
|
113
|
+
|
|
114
|
+
#### Shell Auto-completion ✅ Completed in v0.3.0
|
|
87
115
|
```bash
|
|
88
116
|
servcraft completion bash >> ~/.bashrc
|
|
89
117
|
servcraft completion zsh >> ~/.zshrc
|
|
90
118
|
```
|
|
91
119
|
|
|
120
|
+
Features:
|
|
121
|
+
- ✅ Bash completion script with command and module suggestions
|
|
122
|
+
- ✅ Zsh completion script with descriptions
|
|
123
|
+
- ✅ Autocomplete for all commands, subcommands, and modules
|
|
124
|
+
- ✅ Support for aliases (g, m, c, s, etc.)
|
|
125
|
+
|
|
92
126
|
**Estimated complexity:** Medium
|
|
93
127
|
|
|
94
128
|
---
|
|
95
129
|
|
|
96
|
-
## Phase 2: Testing & Quality (v0.3.x)
|
|
130
|
+
## Phase 2: Testing & Quality (v0.3.x) 🚧 In Progress
|
|
97
131
|
|
|
98
132
|
### v0.3.0 - CLI Tests
|
|
99
133
|
|
|
100
134
|
#### Unit Tests for CLI Commands
|
|
101
|
-
- Test `
|
|
102
|
-
- Test `
|
|
103
|
-
- Test `
|
|
104
|
-
- Test `
|
|
105
|
-
- Test `
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
135
|
+
- ✅ Test `list` command (3 tests passing)
|
|
136
|
+
- ✅ Test `doctor` command (3 tests passing)
|
|
137
|
+
- ✅ Test `--dry-run` option (2 tests passing)
|
|
138
|
+
- ✅ Test `init` command with various options (4 tests: --js, --cjs, --esm, --dry-run)
|
|
139
|
+
- ✅ Test `generate` command variants (3 tests: controller, service, module)
|
|
140
|
+
- ✅ Test error handling (2 tests: invalid module, documentation links)
|
|
141
|
+
- ✅ Test `add` command for modules (3 tests: validation, error handling, help)
|
|
142
|
+
- ✅ Test `remove` command (3 tests: validation, help, alias)
|
|
143
|
+
- ✅ Test `update` command (3 tests: validation, check flag, help)
|
|
144
|
+
- ✅ Test `completion` command (4 tests: bash, zsh, error, help)
|
|
111
145
|
|
|
112
146
|
#### CI/CD Pipeline
|
|
113
|
-
- GitHub Actions
|
|
114
|
-
-
|
|
115
|
-
-
|
|
147
|
+
- ✅ GitHub Actions configured
|
|
148
|
+
- ✅ Tests run on Node.js 18, 20, 22 (matrix strategy)
|
|
149
|
+
- ✅ Coverage reporting configured
|
|
150
|
+
- ✅ PostgreSQL and Redis services for integration tests
|
|
151
|
+
- ✅ Lint, typecheck, build, test, security audit jobs
|
|
152
|
+
|
|
153
|
+
**Status:** 30 CLI tests added and passing ✅ (111 total tests including integration tests)
|
|
116
154
|
|
|
117
155
|
**Estimated complexity:** High
|
|
118
156
|
|
|
119
157
|
---
|
|
120
158
|
|
|
121
|
-
### v0.3.1 - Generated Project Tests
|
|
159
|
+
### v0.3.1 - Generated Project Tests ✅ Completed
|
|
122
160
|
|
|
123
161
|
#### Test Templates
|
|
124
162
|
Generate test files alongside modules:
|
|
125
163
|
```bash
|
|
126
164
|
servcraft generate module users --with-tests
|
|
127
|
-
servcraft add auth # Includes test files
|
|
128
165
|
```
|
|
129
166
|
|
|
130
167
|
Generated test structure:
|
|
@@ -139,6 +176,14 @@ src/modules/users/
|
|
|
139
176
|
│ └── users.integration.test.ts
|
|
140
177
|
```
|
|
141
178
|
|
|
179
|
+
Features:
|
|
180
|
+
- ✅ Controller test templates with Fastify injection
|
|
181
|
+
- ✅ Service test templates with unit test structure
|
|
182
|
+
- ✅ Integration test templates with full CRUD workflow
|
|
183
|
+
- ✅ --with-tests flag for generate module command
|
|
184
|
+
- ✅ Vitest test structure and assertions
|
|
185
|
+
- ✅ TODO comments for customization
|
|
186
|
+
|
|
142
187
|
**Estimated complexity:** Medium
|
|
143
188
|
|
|
144
189
|
---
|