@viucraft/cli 0.1.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/README.md +279 -0
- package/dist/index.js +2928 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# VIUCraft CLI
|
|
2
|
+
|
|
3
|
+
Official command-line client for the [VIUCraft](https://viucraft.com) image manipulation API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @viucraft/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or with pnpm:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add -g @viucraft/cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires Node.js 20 or later.
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Authenticate with your API key
|
|
23
|
+
viucraft auth login
|
|
24
|
+
|
|
25
|
+
# Upload an image
|
|
26
|
+
viucraft images upload photo.jpg
|
|
27
|
+
|
|
28
|
+
# Transform it
|
|
29
|
+
viucraft images transform --image <uuid> --ops "resize-800-600/sharp-1.2/q-85"
|
|
30
|
+
|
|
31
|
+
# List your images
|
|
32
|
+
viucraft images list
|
|
33
|
+
|
|
34
|
+
# Check usage
|
|
35
|
+
viucraft usage
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
### Profiles
|
|
41
|
+
|
|
42
|
+
The CLI supports multiple named profiles for switching between accounts or environments:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Add profiles
|
|
46
|
+
viucraft auth login --profile production
|
|
47
|
+
viucraft auth login --profile staging
|
|
48
|
+
|
|
49
|
+
# Switch between them
|
|
50
|
+
viucraft auth switch production
|
|
51
|
+
|
|
52
|
+
# List all profiles
|
|
53
|
+
viucraft auth list
|
|
54
|
+
|
|
55
|
+
# Use a specific profile for one command
|
|
56
|
+
viucraft images list --profile staging
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Environment Variables
|
|
60
|
+
|
|
61
|
+
| Variable | Description |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `VIUCRAFT_API_KEY` | API key (overrides profile config) |
|
|
64
|
+
| `VIUCRAFT_PROFILE` | Profile name to use |
|
|
65
|
+
| `VIUCRAFT_API_URL` | API base URL override |
|
|
66
|
+
| `NO_COLOR` | Disable colored output |
|
|
67
|
+
|
|
68
|
+
### Config File
|
|
69
|
+
|
|
70
|
+
Configuration is stored at `~/.viucraft/config.yaml`:
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
current_profile: default
|
|
74
|
+
profiles:
|
|
75
|
+
default:
|
|
76
|
+
api_key: "vc_live_..."
|
|
77
|
+
api_url: "https://api.viucraft.com"
|
|
78
|
+
environment: "live"
|
|
79
|
+
defaults:
|
|
80
|
+
output_format: "table"
|
|
81
|
+
color: true
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Commands
|
|
85
|
+
|
|
86
|
+
### Auth
|
|
87
|
+
|
|
88
|
+
| Command | Description |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `auth login` | Authenticate with your API key |
|
|
91
|
+
| `auth status` | Show current auth status and usage |
|
|
92
|
+
| `auth switch <profile>` | Switch active profile |
|
|
93
|
+
| `auth list` | List all profiles |
|
|
94
|
+
| `auth logout` | Remove a profile |
|
|
95
|
+
|
|
96
|
+
### Images
|
|
97
|
+
|
|
98
|
+
| Command | Description |
|
|
99
|
+
|---|---|
|
|
100
|
+
| `images list` | List uploaded images |
|
|
101
|
+
| `images upload <files...>` | Upload one or more images |
|
|
102
|
+
| `images delete <uuid>` | Delete an image |
|
|
103
|
+
| `images info <uuid>` | Show image metadata |
|
|
104
|
+
| `images transform` | Transform an image (returns URL) |
|
|
105
|
+
|
|
106
|
+
### Batch Processing
|
|
107
|
+
|
|
108
|
+
| Command | Description |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `batch create --file <json>` | Submit a batch job |
|
|
111
|
+
| `batch list` | List batch jobs |
|
|
112
|
+
| `batch status <id>` | Show job status and tasks |
|
|
113
|
+
| `batch stream <id>` | Live-stream job progress (SSE) |
|
|
114
|
+
| `batch cancel <id>` | Cancel a job |
|
|
115
|
+
| `batch retry <id>` | Retry failed tasks |
|
|
116
|
+
| `batch download <id>` | Download results as ZIP |
|
|
117
|
+
|
|
118
|
+
### Presets
|
|
119
|
+
|
|
120
|
+
| Command | Description |
|
|
121
|
+
|---|---|
|
|
122
|
+
| `presets list` | List all presets |
|
|
123
|
+
| `presets get <name>` | Show preset details |
|
|
124
|
+
| `presets create` | Create a custom preset (Enterprise) |
|
|
125
|
+
| `presets delete <name>` | Delete a custom preset (Enterprise) |
|
|
126
|
+
|
|
127
|
+
### Cache
|
|
128
|
+
|
|
129
|
+
| Command | Description |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `cache purge` | Purge cached images |
|
|
132
|
+
| `cache warm --image <uuid>` | Pre-generate image variants |
|
|
133
|
+
|
|
134
|
+
### Webhooks
|
|
135
|
+
|
|
136
|
+
| Command | Description |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `webhooks list` | List webhook endpoints |
|
|
139
|
+
| `webhooks create` | Create a webhook |
|
|
140
|
+
| `webhooks delete <id>` | Delete a webhook |
|
|
141
|
+
| `webhooks test <id>` | Send a test event |
|
|
142
|
+
|
|
143
|
+
### Other
|
|
144
|
+
|
|
145
|
+
| Command | Description |
|
|
146
|
+
|---|---|
|
|
147
|
+
| `usage` | View account usage and limits |
|
|
148
|
+
| `config list` | Show all configuration |
|
|
149
|
+
| `config get <key>` | Get a config value |
|
|
150
|
+
| `config set <key> <value>` | Set a config value |
|
|
151
|
+
| `completion bash\|zsh\|fish` | Generate shell completions |
|
|
152
|
+
| `docs` | Open documentation in browser |
|
|
153
|
+
| `version` | Show CLI version |
|
|
154
|
+
|
|
155
|
+
## Output Formats
|
|
156
|
+
|
|
157
|
+
All commands support `--output json` for machine-readable output:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Pipe to jq
|
|
161
|
+
viucraft images list --output json | jq '.images[].uuid'
|
|
162
|
+
|
|
163
|
+
# Default table format
|
|
164
|
+
viucraft images list
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Shell Completions
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Bash
|
|
171
|
+
viucraft completion bash >> ~/.bashrc
|
|
172
|
+
|
|
173
|
+
# Zsh
|
|
174
|
+
viucraft completion zsh >> ~/.zshrc
|
|
175
|
+
|
|
176
|
+
# Fish
|
|
177
|
+
viucraft completion fish > ~/.config/fish/completions/viucraft.fish
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Global Flags
|
|
181
|
+
|
|
182
|
+
| Flag | Description |
|
|
183
|
+
|---|---|
|
|
184
|
+
| `--api-key <key>` | Override API key for this command |
|
|
185
|
+
| `--profile <name>` | Use a specific profile |
|
|
186
|
+
| `--output <format>` | Output format: `table` (default), `json` |
|
|
187
|
+
| `--no-color` | Disable colored output |
|
|
188
|
+
| `--debug` | Show HTTP request/response details |
|
|
189
|
+
| `--insecure` | Allow HTTP connections (dev only) |
|
|
190
|
+
|
|
191
|
+
## Development
|
|
192
|
+
|
|
193
|
+
### Setup
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
git clone https://github.com/BStorm-IT/viucraft-cli.git
|
|
197
|
+
cd viucraft-cli
|
|
198
|
+
pnpm install
|
|
199
|
+
pnpm build
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Try it locally
|
|
203
|
+
|
|
204
|
+
Run directly without installing globally:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
pnpm start -- version
|
|
208
|
+
pnpm start -- --help
|
|
209
|
+
pnpm start -- images list --insecure
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Or link globally so `viucraft` works anywhere in your terminal:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pnpm build && pnpm link --global
|
|
216
|
+
|
|
217
|
+
# Now use it like a real install
|
|
218
|
+
viucraft version
|
|
219
|
+
viucraft auth login
|
|
220
|
+
viucraft images list
|
|
221
|
+
|
|
222
|
+
# Unlink when done
|
|
223
|
+
pnpm unlink --global
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Local dev server
|
|
227
|
+
|
|
228
|
+
To test against the VIUCraft API running locally (requires the [viucraft](https://github.com/BStorm-IT/viucraft) server repo):
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# Start the server (in the viucraft repo)
|
|
232
|
+
docker compose up -d
|
|
233
|
+
|
|
234
|
+
# Login with a test API key
|
|
235
|
+
viucraft auth login --api-key vc_test_YOUR_KEY --profile dev --api-url http://localhost:8080 --insecure
|
|
236
|
+
|
|
237
|
+
# Use commands with --insecure flag for http://
|
|
238
|
+
viucraft images list --insecure
|
|
239
|
+
viucraft images upload photo.jpg --insecure
|
|
240
|
+
viucraft usage --insecure
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Quality gates
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
pnpm lint # ESLint
|
|
247
|
+
pnpm typecheck # TypeScript strict mode
|
|
248
|
+
pnpm test # Vitest (49 tests)
|
|
249
|
+
pnpm format:check # Prettier check
|
|
250
|
+
pnpm build # tsup bundle
|
|
251
|
+
|
|
252
|
+
# Run all gates at once
|
|
253
|
+
pnpm lint && pnpm typecheck && pnpm test && pnpm build
|
|
254
|
+
|
|
255
|
+
# Fix formatting
|
|
256
|
+
pnpm format
|
|
257
|
+
|
|
258
|
+
# Dev mode (watch + rebuild on changes)
|
|
259
|
+
pnpm dev
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### CI
|
|
263
|
+
|
|
264
|
+
GitHub Actions runs on every push/PR to `main`:
|
|
265
|
+
|
|
266
|
+
- **Lint job**: ESLint + TypeScript + Prettier (ubuntu, Node 22)
|
|
267
|
+
- **Test job**: Vitest + build + smoke test (ubuntu + macOS, Node 20 + 22)
|
|
268
|
+
- **Release**: `npm publish` on `v*` tags
|
|
269
|
+
|
|
270
|
+
## Security
|
|
271
|
+
|
|
272
|
+
- API keys stored locally at `~/.viucraft/config.yaml` with `0600` permissions
|
|
273
|
+
- Keys are never printed in full — always masked as `vc_live_...xxxx`
|
|
274
|
+
- HTTPS enforced by default (use `--insecure` for local dev only)
|
|
275
|
+
- No telemetry or analytics
|
|
276
|
+
|
|
277
|
+
## License
|
|
278
|
+
|
|
279
|
+
MIT
|