0
# CLI Commands
1
2
Primary interface for Vue component library development workflows. Provides seven core commands for development, building, testing, and publishing Vue component libraries.
3
4
## Capabilities
5
6
### Development Command
7
8
Starts a development server for the documentation site with hot reload support.
9
10
```bash { .api }
11
# Start development server
12
vant-cli dev
13
```
14
15
**Usage:**
16
```bash
17
vant-cli dev
18
```
19
20
### Build Command
21
22
Compiles components in production mode with comprehensive build pipeline including multiple output formats.
23
24
```bash { .api }
25
# Build production package
26
vant-cli build
27
```
28
29
**Build Pipeline Steps:**
30
1. Copy source code to es/ and lib/ directories
31
2. Build package script entry points
32
3. Build component style entries
33
4. Build package style entry
34
5. Build TypeScript declarations
35
6. Build ESModule outputs
36
7. Build CommonJS outputs
37
8. Build bundled outputs
38
9. Install dependencies automatically
39
10. Generate WebStorm type definitions
40
41
**Usage:**
42
```bash
43
vant-cli build
44
```
45
46
### Site Build Command
47
48
Compiles the documentation site in production mode for deployment.
49
50
```bash { .api }
51
# Build documentation site
52
vant-cli build-site
53
```
54
55
**Usage:**
56
```bash
57
vant-cli build-site
58
```
59
60
### Clean Command
61
62
Removes all build output directories to ensure clean builds.
63
64
```bash { .api }
65
# Clean all build outputs
66
vant-cli clean
67
```
68
69
**Usage:**
70
```bash
71
vant-cli clean
72
```
73
74
### Lint Command
75
76
Runs ESLint with automatic fixing on source files.
77
78
```bash { .api }
79
# Run ESLint with automatic fixing
80
vant-cli lint
81
```
82
83
**Usage:**
84
```bash
85
vant-cli lint
86
```
87
88
### Release Command
89
90
Comprehensive package release workflow with version management, building, and publishing.
91
92
```bash { .api }
93
# Release package (interactive)
94
vant-cli release
95
96
# Release with specific options
97
vant-cli release --tag <tag> --gitTag
98
```
99
100
**Release Workflow:**
101
1. Interactive version input via enquirer
102
2. Automatic npm tag detection based on version (beta, alpha, rc, latest)
103
3. Package version update in package.json
104
4. Build package (if build script exists)
105
5. Publish to npm with appropriate tag
106
6. Git commit with version update
107
7. Optional git tagging and push
108
8. Rollback on build failures
109
110
**Tag Detection:**
111
- `1.0.0-beta.1` → `beta` tag
112
- `1.0.0-alpha.1` → `alpha` tag
113
- `1.0.0-rc.1` → `rc` tag
114
- `1.0.0` → `latest` tag
115
116
**Usage:**
117
```bash
118
vant-cli release # Basic release
119
vant-cli release --tag beta # Force beta tag
120
vant-cli release --gitTag # Create git tag
121
vant-cli release --tag beta --gitTag # Both options
122
```
123
124
### Commit Lint Command
125
126
Validates commit messages against conventional commit format.
127
128
```bash { .api }
129
# Validate commit message
130
vant-cli commit-lint <git-params-file>
131
```
132
133
**Supported Commit Types:**
134
- `fix(Component): description` - Bug fixes
135
- `feat(Component): description` - New features
136
- `docs(Component): description` - Documentation updates
137
- `perf(Component): description` - Performance improvements
138
- `test(Component): description` - Test additions
139
- `types(Component): description` - Type definition updates
140
- `style(Component): description` - Code style changes
141
- `build(Component): description` - Build system changes
142
- `chore(Component): description` - Maintenance tasks
143
- `release(Component): description` - Release commits
144
- `refactor(Component): description` - Code refactoring
145
- `breaking change(Component): description` - Breaking changes
146
- `Merge branch 'foo' into 'bar'` - Merge commits
147
148
**Usage:**
149
```bash
150
vant-cli commit-lint <git-params-file>
151
```
152
153
## Environment Management
154
155
Commands automatically manage environment variables for consistent builds:
156
157
- `NODE_ENV` - Set to 'development' or 'production' based on command
158
- `BABEL_MODULE` - Set to 'esmodule' or 'commonjs' during compilation
159
- `BUILD_TARGET` - Set to 'site' or 'package' based on build type
160
- `VANT_CLI_VERSION` - Current CLI version
161
162
## Error Handling
163
164
All commands implement consistent error handling:
165
166
- Exit with code 1 on failures
167
- Rollback mechanisms for build failures
168
- Colored output using rslog for clear error reporting
169
- Cross-platform compatibility using node:path