@mercurjs/cli 2.0.0-canary.0
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 +460 -0
- package/dist/index.d.ts +318 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
# Mercur CLI
|
|
2
|
+
|
|
3
|
+
Add blocks (admin UI pages, vendor UI pages, workflows, modules, and more) from the Mercur registry to your project.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js v20 or higher
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Install globally (recommended):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @mercurjs/cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Any package manager works:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add -g @mercurjs/cli
|
|
21
|
+
yarn global add @mercurjs/cli
|
|
22
|
+
bun add -g @mercurjs/cli
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or install locally as a dev dependency:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -D @mercurjs/cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
**Create a new project:**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Create a new Mercur project
|
|
37
|
+
mercurjs create
|
|
38
|
+
|
|
39
|
+
# Create with a specific template
|
|
40
|
+
mercurjs create my-mercur --template basic
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Or add blocks to an existing project:**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Initialize your project
|
|
47
|
+
mercurjs init
|
|
48
|
+
|
|
49
|
+
# Add a block from the registry
|
|
50
|
+
mercurjs add product-review
|
|
51
|
+
|
|
52
|
+
# Search for available blocks
|
|
53
|
+
mercurjs search --query product
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Commands
|
|
59
|
+
|
|
60
|
+
### `create`
|
|
61
|
+
|
|
62
|
+
Create a new Mercur project with the selected template.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
mercurjs create [name] [options]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Arguments:**
|
|
69
|
+
|
|
70
|
+
| Argument | Description |
|
|
71
|
+
| -------- | ------------------------------------------------------------ |
|
|
72
|
+
| `name` | Name of your project (optional, will prompt if not provided) |
|
|
73
|
+
|
|
74
|
+
**Options:**
|
|
75
|
+
|
|
76
|
+
| Option | Description | Default |
|
|
77
|
+
| --------------------------------- | -------------------------------------- | ----------------- |
|
|
78
|
+
| `-t, --template <template>` | Template to use: `basic` or `registry` | - |
|
|
79
|
+
| `-c, --cwd <path>` | Working directory | Current directory |
|
|
80
|
+
| `-y, --yes` | Skip confirmation prompt | `true` |
|
|
81
|
+
| `--no-deps` | Skip installing dependencies | `false` |
|
|
82
|
+
| `--skip-db` | Skip database configuration | `false` |
|
|
83
|
+
| `--db-connection-string <string>` | PostgreSQL connection string | - |
|
|
84
|
+
|
|
85
|
+
**Examples:**
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Interactive project creation
|
|
89
|
+
mercurjs create
|
|
90
|
+
|
|
91
|
+
# Create with a specific name and template
|
|
92
|
+
mercurjs create my-marketplace --template basic
|
|
93
|
+
|
|
94
|
+
# Create without database setup
|
|
95
|
+
mercurjs create my-mercur --skip-db
|
|
96
|
+
|
|
97
|
+
# Create with a specific database connection
|
|
98
|
+
mercurjs create my-mercur --db-connection-string "postgresql://user:pass@localhost:5432/mydb"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### `init`
|
|
104
|
+
|
|
105
|
+
Initialize your project and create a `blocks.json` configuration file.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
mercurjs init [options]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Options:**
|
|
112
|
+
|
|
113
|
+
| Option | Description | Default |
|
|
114
|
+
| ------------------ | ------------------------- | ----------------- |
|
|
115
|
+
| `-y, --yes` | Skip confirmation prompt | `true` |
|
|
116
|
+
| `-d, --defaults` | Use default configuration | `false` |
|
|
117
|
+
| `-c, --cwd <path>` | Working directory | Current directory |
|
|
118
|
+
| `-s, --silent` | Mute output | `false` |
|
|
119
|
+
|
|
120
|
+
**Examples:**
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Interactive initialization
|
|
124
|
+
mercurjs init
|
|
125
|
+
|
|
126
|
+
# Non-interactive with defaults
|
|
127
|
+
mercurjs init --defaults
|
|
128
|
+
|
|
129
|
+
# Initialize in a specific directory
|
|
130
|
+
mercurjs init --cwd ./my-project
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### `add`
|
|
136
|
+
|
|
137
|
+
Add blocks to your project from the registry.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
mercurjs add <blocks...> [options]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Arguments:**
|
|
144
|
+
|
|
145
|
+
| Argument | Description |
|
|
146
|
+
| -------- | ---------------------------------------- |
|
|
147
|
+
| `blocks` | Names of blocks to add (space-separated) |
|
|
148
|
+
|
|
149
|
+
**Options:**
|
|
150
|
+
|
|
151
|
+
| Option | Description | Default |
|
|
152
|
+
| ------------------ | ------------------------ | ----------------- |
|
|
153
|
+
| `-y, --yes` | Skip confirmation prompt | `false` |
|
|
154
|
+
| `-o, --overwrite` | Overwrite existing files | `false` |
|
|
155
|
+
| `-c, --cwd <path>` | Working directory | Current directory |
|
|
156
|
+
| `-s, --silent` | Mute output | `false` |
|
|
157
|
+
|
|
158
|
+
**Examples:**
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Add a single block
|
|
162
|
+
mercurjs add product-review
|
|
163
|
+
|
|
164
|
+
# Add multiple blocks
|
|
165
|
+
mercurjs add product-review order-tracking wishlist
|
|
166
|
+
|
|
167
|
+
# Add with overwrite
|
|
168
|
+
mercurjs add product-review --overwrite
|
|
169
|
+
|
|
170
|
+
# Add to a specific directory
|
|
171
|
+
mercurjs add product-review --cwd ./my-project
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### `search`
|
|
177
|
+
|
|
178
|
+
Search blocks from registries by name or description.
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
mercurjs search [options]
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Options:**
|
|
185
|
+
|
|
186
|
+
| Option | Description | Default |
|
|
187
|
+
| --------------------------- | ----------------------- | ----------------- |
|
|
188
|
+
| `-q, --query <query>` | Search query string | - |
|
|
189
|
+
| `-r, --registry <registry>` | Registry to search from | `@mercurjs` |
|
|
190
|
+
| `-c, --cwd <path>` | Working directory | Current directory |
|
|
191
|
+
|
|
192
|
+
**Examples:**
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# Search for blocks with "product" in name or description
|
|
196
|
+
mercurjs search --query product
|
|
197
|
+
|
|
198
|
+
# Search a custom registry
|
|
199
|
+
mercurjs search --query review --registry @my-registry
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
### `view`
|
|
205
|
+
|
|
206
|
+
View detailed information about specific blocks from the registry.
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
mercurjs view <blocks...> [options]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Arguments:**
|
|
213
|
+
|
|
214
|
+
| Argument | Description |
|
|
215
|
+
| -------- | ----------------------------------------- |
|
|
216
|
+
| `blocks` | Names of blocks to view (space-separated) |
|
|
217
|
+
|
|
218
|
+
**Options:**
|
|
219
|
+
|
|
220
|
+
| Option | Description | Default |
|
|
221
|
+
| ------------------ | ----------------- | ----------------- |
|
|
222
|
+
| `-c, --cwd <path>` | Working directory | Current directory |
|
|
223
|
+
|
|
224
|
+
**Examples:**
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# View a block's details
|
|
228
|
+
mercurjs view product-review
|
|
229
|
+
|
|
230
|
+
# View multiple blocks
|
|
231
|
+
mercurjs view product-review order-tracking
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### `diff`
|
|
237
|
+
|
|
238
|
+
Check for updates by comparing local files against the registry.
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
mercurjs diff <blocks...> [options]
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Arguments:**
|
|
245
|
+
|
|
246
|
+
| Argument | Description |
|
|
247
|
+
| -------- | ----------------------------------------- |
|
|
248
|
+
| `blocks` | Names of blocks to diff (space-separated) |
|
|
249
|
+
|
|
250
|
+
**Options:**
|
|
251
|
+
|
|
252
|
+
| Option | Description | Default |
|
|
253
|
+
| ------------------ | ----------------- | ----------------- |
|
|
254
|
+
| `-c, --cwd <path>` | Working directory | Current directory |
|
|
255
|
+
|
|
256
|
+
**Examples:**
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Check if a block has updates
|
|
260
|
+
mercurjs diff product-review
|
|
261
|
+
|
|
262
|
+
# Check multiple blocks for updates
|
|
263
|
+
mercurjs diff product-review order-tracking
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
### `build`
|
|
269
|
+
|
|
270
|
+
Build the registry from a `registry.json` file.
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
mercurjs build [registry] [options]
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Arguments:**
|
|
277
|
+
|
|
278
|
+
| Argument | Description | Default |
|
|
279
|
+
| ---------- | -------------------------- | ----------------- |
|
|
280
|
+
| `registry` | Path to registry.json file | `./registry.json` |
|
|
281
|
+
|
|
282
|
+
**Options:**
|
|
283
|
+
|
|
284
|
+
| Option | Description | Default |
|
|
285
|
+
| --------------------- | ------------------------------------ | ----------------- |
|
|
286
|
+
| `-o, --output <path>` | Destination directory for JSON files | `./r` |
|
|
287
|
+
| `-c, --cwd <path>` | Working directory | Current directory |
|
|
288
|
+
| `-v, --verbose` | Verbose output | `false` |
|
|
289
|
+
|
|
290
|
+
**Examples:**
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# Build with defaults
|
|
294
|
+
mercurjs build
|
|
295
|
+
|
|
296
|
+
# Build with custom paths
|
|
297
|
+
mercurjs build ./my-registry.json --output ./dist/registry
|
|
298
|
+
|
|
299
|
+
# Build with verbose output
|
|
300
|
+
mercurjs build --verbose
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
### `info`
|
|
306
|
+
|
|
307
|
+
Get information about your project and configuration.
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
mercurjs info [options]
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Options:**
|
|
314
|
+
|
|
315
|
+
| Option | Description | Default |
|
|
316
|
+
| ------------------ | ----------------- | ----------------- |
|
|
317
|
+
| `-c, --cwd <path>` | Working directory | Current directory |
|
|
318
|
+
|
|
319
|
+
**Examples:**
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# Get project info
|
|
323
|
+
mercurjs info
|
|
324
|
+
|
|
325
|
+
# Get info for a specific directory
|
|
326
|
+
mercurjs info --cwd ./my-project
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Configuration
|
|
332
|
+
|
|
333
|
+
The CLI uses a `blocks.json` file for configuration. This file is created when you run `init`.
|
|
334
|
+
|
|
335
|
+
### Example `blocks.json`
|
|
336
|
+
|
|
337
|
+
```json
|
|
338
|
+
{
|
|
339
|
+
"$schema": "https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/schema/registry.json",
|
|
340
|
+
"aliases": {
|
|
341
|
+
"workflows": "packages/api/src/workflows",
|
|
342
|
+
"api": "packages/api/src/api",
|
|
343
|
+
"links": "packages/api/src/links",
|
|
344
|
+
"modules": "packages/api/src/modules",
|
|
345
|
+
"vendor": "apps/vendor/src/pages",
|
|
346
|
+
"admin": "apps/admin/src/pages",
|
|
347
|
+
"lib": "packages/api/src/lib"
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Configuration Options
|
|
353
|
+
|
|
354
|
+
| Option | Type | Description |
|
|
355
|
+
| --------------------- | -------- | ------------------------------------- |
|
|
356
|
+
| `$schema` | `string` | JSON schema URL for validation |
|
|
357
|
+
| `aliases.workflows` | `string` | Import alias for workflows directory |
|
|
358
|
+
| `aliases.api` | `string` | Import alias for API routes directory |
|
|
359
|
+
| `aliases.links` | `string` | Import alias for links directory |
|
|
360
|
+
| `aliases.modules` | `string` | Import alias for modules directory |
|
|
361
|
+
| `aliases.vendor` | `string` | Import alias for vendor panel pages |
|
|
362
|
+
| `aliases.admin` | `string` | Import alias for admin panel pages |
|
|
363
|
+
| `aliases.lib` | `string` | Import alias for lib directory |
|
|
364
|
+
| `registries` | `object` | Custom registry configurations |
|
|
365
|
+
|
|
366
|
+
### Custom Registries
|
|
367
|
+
|
|
368
|
+
You can add custom registries to your `blocks.json`:
|
|
369
|
+
|
|
370
|
+
```json
|
|
371
|
+
{
|
|
372
|
+
"aliases": {
|
|
373
|
+
"workflows": "packages/api/src/workflows",
|
|
374
|
+
"api": "packages/api/src/api",
|
|
375
|
+
"links": "packages/api/src/links",
|
|
376
|
+
"modules": "packages/api/src/modules",
|
|
377
|
+
"vendor": "apps/vendor/src/pages",
|
|
378
|
+
"admin": "apps/admin/src/pages",
|
|
379
|
+
"lib": "packages/api/src/lib"
|
|
380
|
+
},
|
|
381
|
+
"registries": {
|
|
382
|
+
"@my-registry": "https://my-registry.com/blocks/{name}.json",
|
|
383
|
+
"@private": {
|
|
384
|
+
"url": "https://private-registry.com/blocks/{name}.json",
|
|
385
|
+
"headers": {
|
|
386
|
+
"Authorization": "Bearer ${MY_AUTH_TOKEN}"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## Features
|
|
396
|
+
|
|
397
|
+
- **Project Scaffolding**: Create new Mercur projects with templates
|
|
398
|
+
- **Automatic Dependency Resolution**: When adding a block, the CLI automatically downloads any dependencies it requires
|
|
399
|
+
- **Import Transformation**: Automatically transforms imports to use your configured path aliases
|
|
400
|
+
- **Package Manager Detection**: Detects your package manager (npm, pnpm, yarn, bun) and installs dependencies automatically
|
|
401
|
+
- **TypeScript Support**: Full TypeScript support
|
|
402
|
+
- **Database Setup**: Automatic PostgreSQL database creation and migration
|
|
403
|
+
- **File Conflict Handling**: Prompts for confirmation before overwriting existing files
|
|
404
|
+
- **Diff Preview**: Shows colorized diff output when checking for updates
|
|
405
|
+
- **Custom Registries**: Support for multiple registries with authentication
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## Examples
|
|
410
|
+
|
|
411
|
+
### Creating a New Marketplace
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
# Create a new project
|
|
415
|
+
mercurjs create my-marketplace
|
|
416
|
+
|
|
417
|
+
# Follow the prompts to:
|
|
418
|
+
# 1. Select a template (basic or registry)
|
|
419
|
+
# 2. Configure database connection
|
|
420
|
+
# 3. Install dependencies
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Adding Blocks to an Existing Project
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
# Initialize the CLI in your project
|
|
427
|
+
mercurjs init
|
|
428
|
+
|
|
429
|
+
# Search for available blocks
|
|
430
|
+
mercurjs search --query product
|
|
431
|
+
|
|
432
|
+
# Add blocks
|
|
433
|
+
mercurjs add product-review order-tracking
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Checking for Updates
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
# See what changed in a block
|
|
440
|
+
mercurjs diff product-review
|
|
441
|
+
|
|
442
|
+
# Update by overwriting
|
|
443
|
+
mercurjs add product-review --overwrite
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Building a Custom Registry
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
# Create a registry.json file with your blocks
|
|
450
|
+
# Then build the registry
|
|
451
|
+
mercurjs build --verbose
|
|
452
|
+
|
|
453
|
+
# Output will be in ./registry directory
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## License
|
|
459
|
+
|
|
460
|
+
MIT
|