servcraft 0.2.0 → 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 +44 -2
- package/ROADMAP.md +72 -34
- package/dist/cli/index.cjs +901 -289
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +984 -387
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/completion.ts +146 -0
- package/src/cli/commands/doctor.ts +116 -1
- package/src/cli/commands/generate.ts +30 -0
- package/src/cli/commands/list.ts +1 -1
- package/src/cli/commands/update.ts +221 -0
- package/src/cli/index.ts +8 -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/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
|
@@ -279,8 +279,9 @@ servcraft init my-app --dry-run -y # Preview without creating
|
|
|
279
279
|
```bash
|
|
280
280
|
# Generate complete module
|
|
281
281
|
servcraft generate module product
|
|
282
|
-
servcraft g m product --prisma
|
|
283
|
-
servcraft g m product --
|
|
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
|
|
284
285
|
|
|
285
286
|
# Generate individual files
|
|
286
287
|
servcraft generate controller user
|
|
@@ -312,6 +313,47 @@ servcraft list --json # Output as JSON
|
|
|
312
313
|
servcraft ls # Same as list
|
|
313
314
|
```
|
|
314
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
|
+
|
|
315
357
|
### Add pre-built modules
|
|
316
358
|
|
|
317
359
|
```bash
|
package/ROADMAP.md
CHANGED
|
@@ -4,7 +4,8 @@ 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 ✅
|
|
8
9
|
- **v0.1.9** - Added `--dry-run` option for all commands (init, add, generate)
|
|
9
10
|
- **v0.1.8** - Added `servcraft list` command
|
|
10
11
|
- **v0.1.7** - ESM/CommonJS module system choice
|
|
@@ -15,7 +16,17 @@ This document outlines the planned features and improvements for Servcraft.
|
|
|
15
16
|
|
|
16
17
|
---
|
|
17
18
|
|
|
18
|
-
## 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
|
+
---
|
|
19
30
|
|
|
20
31
|
### v0.2.0 - CLI Enhancements
|
|
21
32
|
|
|
@@ -49,89 +60,108 @@ servcraft generate service users --dry-run # ✅ Implemented
|
|
|
49
60
|
|
|
50
61
|
### v0.2.1 - Module Management
|
|
51
62
|
|
|
52
|
-
#### `servcraft remove <module>`
|
|
63
|
+
#### `servcraft remove <module>` ✅ Completed in v0.2.0
|
|
53
64
|
Remove an installed module.
|
|
54
65
|
```bash
|
|
55
66
|
servcraft remove auth
|
|
56
|
-
servcraft remove auth --
|
|
67
|
+
servcraft remove auth --yes # Skip confirmation
|
|
68
|
+
servcraft remove auth --keep-env # Keep environment variables
|
|
57
69
|
```
|
|
58
70
|
|
|
59
71
|
Features:
|
|
60
|
-
- Remove module files from `src/modules/`
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
72
|
+
- ✅ Remove module files from `src/modules/`
|
|
73
|
+
- ✅ Interactive confirmation
|
|
74
|
+
- ✅ Show cleanup instructions
|
|
75
|
+
- ✅ Alias: rm
|
|
64
76
|
|
|
65
|
-
#### `servcraft update [module]`
|
|
77
|
+
#### `servcraft update [module]` ✅ Completed in v0.3.0
|
|
66
78
|
Update modules to latest version.
|
|
67
79
|
```bash
|
|
68
80
|
servcraft update # Update all modules
|
|
69
81
|
servcraft update auth # Update specific module
|
|
70
82
|
servcraft update --check # Check for updates without applying
|
|
83
|
+
servcraft update --yes # Skip confirmation
|
|
71
84
|
```
|
|
72
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
|
+
|
|
73
95
|
**Estimated complexity:** Medium
|
|
74
96
|
|
|
75
97
|
---
|
|
76
98
|
|
|
77
99
|
### v0.2.2 - Developer Experience
|
|
78
100
|
|
|
79
|
-
#### `servcraft doctor`
|
|
101
|
+
#### `servcraft doctor` ✅ Completed in v0.2.0
|
|
80
102
|
Diagnose project configuration issues.
|
|
81
103
|
```bash
|
|
82
104
|
servcraft doctor
|
|
83
105
|
```
|
|
84
106
|
|
|
85
107
|
Checks:
|
|
86
|
-
- Node.js version compatibility
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
#### 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
|
|
94
115
|
```bash
|
|
95
116
|
servcraft completion bash >> ~/.bashrc
|
|
96
117
|
servcraft completion zsh >> ~/.zshrc
|
|
97
118
|
```
|
|
98
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
|
+
|
|
99
126
|
**Estimated complexity:** Medium
|
|
100
127
|
|
|
101
128
|
---
|
|
102
129
|
|
|
103
|
-
## Phase 2: Testing & Quality (v0.3.x)
|
|
130
|
+
## Phase 2: Testing & Quality (v0.3.x) 🚧 In Progress
|
|
104
131
|
|
|
105
132
|
### v0.3.0 - CLI Tests
|
|
106
133
|
|
|
107
134
|
#### Unit Tests for CLI Commands
|
|
108
|
-
- Test `
|
|
109
|
-
- Test `
|
|
110
|
-
- Test `
|
|
111
|
-
- Test `
|
|
112
|
-
- Test `
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
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)
|
|
118
145
|
|
|
119
146
|
#### CI/CD Pipeline
|
|
120
|
-
- GitHub Actions
|
|
121
|
-
-
|
|
122
|
-
-
|
|
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)
|
|
123
154
|
|
|
124
155
|
**Estimated complexity:** High
|
|
125
156
|
|
|
126
157
|
---
|
|
127
158
|
|
|
128
|
-
### v0.3.1 - Generated Project Tests
|
|
159
|
+
### v0.3.1 - Generated Project Tests ✅ Completed
|
|
129
160
|
|
|
130
161
|
#### Test Templates
|
|
131
162
|
Generate test files alongside modules:
|
|
132
163
|
```bash
|
|
133
164
|
servcraft generate module users --with-tests
|
|
134
|
-
servcraft add auth # Includes test files
|
|
135
165
|
```
|
|
136
166
|
|
|
137
167
|
Generated test structure:
|
|
@@ -146,6 +176,14 @@ src/modules/users/
|
|
|
146
176
|
│ └── users.integration.test.ts
|
|
147
177
|
```
|
|
148
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
|
+
|
|
149
187
|
**Estimated complexity:** Medium
|
|
150
188
|
|
|
151
189
|
---
|