@archlast/cli 0.1.0 → 0.2.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 +737 -139
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,149 +1,747 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
CLI tool for Archlast
|
|
4
|
-
|
|
1
|
+
# @archlast/cli
|
|
2
|
+
|
|
3
|
+
The Archlast CLI is a comprehensive command-line tool for development, deployment, and Docker lifecycle management of Archlast applications. It handles code generation, hot deployment, container management, and data operations.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Requirements](#requirements)
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Quick Start](#quick-start)
|
|
10
|
+
- [Commands Reference](#commands-reference)
|
|
11
|
+
- [Development Commands](#development-commands)
|
|
12
|
+
- [Docker Management](#docker-management)
|
|
13
|
+
- [Code Generation](#code-generation)
|
|
14
|
+
- [Data Management](#data-management)
|
|
15
|
+
- [Configuration](#configuration)
|
|
16
|
+
- [Environment Variables](#environment-variables)
|
|
17
|
+
- [Usage Examples](#usage-examples)
|
|
18
|
+
- [Troubleshooting](#troubleshooting)
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- **Node.js 18+** or **Bun 1.0+**
|
|
23
|
+
- **Docker Desktop** or **Docker Engine** (for container management)
|
|
24
|
+
- An Archlast project with schema and function definitions
|
|
25
|
+
|
|
5
26
|
## Installation
|
|
6
27
|
|
|
7
|
-
###
|
|
28
|
+
### Global Installation (Recommended)
|
|
8
29
|
|
|
9
30
|
```bash
|
|
10
31
|
npm install -g @archlast/cli
|
|
32
|
+
|
|
33
|
+
# Or with bun
|
|
34
|
+
bun add -g @archlast/cli
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Local Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install -D @archlast/cli
|
|
41
|
+
|
|
42
|
+
# Run via npx
|
|
43
|
+
npx archlast <command>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Verify Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
archlast --version
|
|
50
|
+
archlast --help
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
### 1. Start the Server
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Pull and start the Docker container
|
|
59
|
+
archlast start
|
|
60
|
+
|
|
61
|
+
# Check status
|
|
62
|
+
archlast status
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Development Mode
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Watch for changes and auto-deploy
|
|
69
|
+
archlast dev --path ./my-archlast-app
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 3. Production Deployment
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
archlast deploy --path ./my-archlast-app --server https://api.myapp.com
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Commands Reference
|
|
81
|
+
|
|
82
|
+
### Development Commands
|
|
83
|
+
|
|
84
|
+
#### `archlast dev`
|
|
85
|
+
|
|
86
|
+
Start development mode with file watching. Automatically regenerates types and deploys changes to the server.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
archlast dev [options]
|
|
90
|
+
|
|
91
|
+
Options:
|
|
92
|
+
--path <path> Path to archlast folder (default: ".")
|
|
93
|
+
--server <url> Server URL for code upload (default: "http://localhost:4000")
|
|
94
|
+
--max-poll <number> Maximum server polling retries (default: 30)
|
|
95
|
+
-p, --port <port> Server port (default: 3001)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Example:**
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Watch current directory
|
|
102
|
+
archlast dev
|
|
103
|
+
|
|
104
|
+
# Watch specific project with custom server
|
|
105
|
+
archlast dev --path ./apps/api --server http://localhost:5000
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### `archlast build`
|
|
109
|
+
|
|
110
|
+
Generate types without deploying. Useful for CI/CD pipelines or type checking.
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
archlast build --path ./my-archlast-app
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**What it generates:**
|
|
117
|
+
|
|
118
|
+
- `_generated/server.ts` - DataModel types, QueryCtx, MutationCtx
|
|
119
|
+
- `_generated/api.ts` - Client-side function references
|
|
120
|
+
- `_generated/rpc.ts` - tRPC router types (if using RPC)
|
|
121
|
+
- `_generated/crud/<collection>.ts` - Auto-generated CRUD handlers
|
|
122
|
+
|
|
123
|
+
#### `archlast deploy`
|
|
124
|
+
|
|
125
|
+
One-time deployment to the server.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
archlast deploy [options]
|
|
129
|
+
|
|
130
|
+
Options:
|
|
131
|
+
--path <path> Path to archlast folder (default: ".")
|
|
132
|
+
--server <url> Server URL (default: "http://localhost:4000")
|
|
133
|
+
--max-poll <number> Maximum polling retries (default: 30)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### `archlast pull`
|
|
137
|
+
|
|
138
|
+
Pull schema or files from the server, or pull Docker images.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
archlast pull [options]
|
|
142
|
+
|
|
143
|
+
Options:
|
|
144
|
+
--path <path> Local path (default: ".")
|
|
145
|
+
--server <url> Server URL (default: "http://localhost:4000")
|
|
146
|
+
--files <files...> Files to pull (default: ["src/schema.ts"])
|
|
147
|
+
--force Overwrite without prompt
|
|
148
|
+
--diff Show diff only
|
|
149
|
+
--merge Attempt merge
|
|
150
|
+
--docker Pull Docker image instead of schema
|
|
151
|
+
--image <image> Docker image name
|
|
152
|
+
--tag <tag> Docker image tag
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Examples:**
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Pull schema from server
|
|
159
|
+
archlast pull --server http://localhost:4000
|
|
160
|
+
|
|
161
|
+
# Pull and show diff only
|
|
162
|
+
archlast pull --diff
|
|
163
|
+
|
|
164
|
+
# Pull specific Docker image
|
|
165
|
+
archlast pull --docker --image archlast/server --tag v1.2.0
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### Docker Management
|
|
171
|
+
|
|
172
|
+
#### `archlast start`
|
|
173
|
+
|
|
174
|
+
Start the Archlast Docker container.
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
archlast start [options]
|
|
178
|
+
|
|
179
|
+
Options:
|
|
180
|
+
--path <path> Path to project root (default: ".")
|
|
181
|
+
--port <port> Host port to expose
|
|
182
|
+
--image <image> Docker image name
|
|
183
|
+
--tag <tag> Docker image tag
|
|
184
|
+
--container <name> Docker container name
|
|
185
|
+
--config <path> Path to archlast.config.js
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Example:**
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Start with defaults
|
|
192
|
+
archlast start
|
|
193
|
+
|
|
194
|
+
# Start on custom port
|
|
195
|
+
archlast start --port 5000
|
|
196
|
+
|
|
197
|
+
# Start specific version
|
|
198
|
+
archlast start --image archlast/server --tag v1.2.0
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### `archlast stop`
|
|
202
|
+
|
|
203
|
+
Stop the running container.
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
archlast stop [options]
|
|
207
|
+
|
|
208
|
+
Options:
|
|
209
|
+
--path <path> Path to project root
|
|
210
|
+
--container <name> Docker container name
|
|
211
|
+
--config <path> Path to archlast.config.js
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### `archlast restart`
|
|
215
|
+
|
|
216
|
+
Restart the container with optional new configuration.
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
archlast restart [options]
|
|
220
|
+
|
|
221
|
+
# All options from 'start' are available
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### `archlast status`
|
|
225
|
+
|
|
226
|
+
Show container status and health information.
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
archlast status [options]
|
|
230
|
+
|
|
231
|
+
Options:
|
|
232
|
+
--path <path> Path to project root
|
|
233
|
+
--container <name> Docker container name
|
|
234
|
+
--config <path> Path to archlast.config.js
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Output example:**
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
🐳 Archlast Server Status
|
|
241
|
+
|
|
242
|
+
Container: archlast-server
|
|
243
|
+
Status: running
|
|
244
|
+
Health: healthy
|
|
245
|
+
Uptime: 2 hours
|
|
246
|
+
Port: 4000
|
|
247
|
+
Image: archlast/server:latest
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### `archlast logs`
|
|
251
|
+
|
|
252
|
+
Stream container logs in real-time.
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
archlast logs [options]
|
|
256
|
+
|
|
257
|
+
Options:
|
|
258
|
+
--path <path> Path to project root
|
|
259
|
+
--container <name> Docker container name
|
|
260
|
+
--tail <lines> Number of log lines to show (default: 100)
|
|
261
|
+
--no-follow Do not follow logs (exit after showing)
|
|
262
|
+
--config <path> Path to archlast.config.js
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**Examples:**
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
# Follow logs in real-time
|
|
269
|
+
archlast logs --follow
|
|
270
|
+
|
|
271
|
+
# Show last 50 lines and exit
|
|
272
|
+
archlast logs --tail 50 --no-follow
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### `archlast upgrade`
|
|
276
|
+
|
|
277
|
+
Pull a new Docker image and restart the container.
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
archlast upgrade [options]
|
|
281
|
+
|
|
282
|
+
Options:
|
|
283
|
+
--path <path> Path to project root
|
|
284
|
+
--port <port> Host port to expose
|
|
285
|
+
--image <image> Docker image name
|
|
286
|
+
--tag <tag> Docker image tag (or --version)
|
|
287
|
+
--container <name> Docker container name
|
|
288
|
+
--config <path> Path to archlast.config.js
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Example:**
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Upgrade to latest
|
|
295
|
+
archlast upgrade
|
|
296
|
+
|
|
297
|
+
# Upgrade to specific version
|
|
298
|
+
archlast upgrade --tag v1.3.0
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### `archlast config`
|
|
302
|
+
|
|
303
|
+
Show resolved Docker configuration.
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
archlast config [options]
|
|
307
|
+
|
|
308
|
+
Options:
|
|
309
|
+
--path <path> Path to project root
|
|
310
|
+
--config <path> Path to archlast.config.js
|
|
311
|
+
--json Output config as JSON
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
### Code Generation
|
|
317
|
+
|
|
318
|
+
#### `archlast generate crud <collection>`
|
|
319
|
+
|
|
320
|
+
Generate CRUD handlers for a collection defined in your schema.
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
archlast generate crud <collection> [options]
|
|
324
|
+
|
|
325
|
+
Options:
|
|
326
|
+
--path <path> Path to archlast folder (default: ".")
|
|
327
|
+
--force Overwrite existing files
|
|
328
|
+
--linked Create linked re-export file (default: true)
|
|
329
|
+
--ejected Create standalone handlers (not linked to _generated)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Example:**
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
# Generate CRUD for tasks collection
|
|
336
|
+
archlast generate crud tasks
|
|
337
|
+
|
|
338
|
+
# Force overwrite existing
|
|
339
|
+
archlast generate crud tasks --force
|
|
340
|
+
|
|
341
|
+
# Generate standalone (ejected) handlers
|
|
342
|
+
archlast generate crud tasks --ejected
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Generated handlers (linked mode):**
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
// src/tasks.ts - Re-exports from generated code
|
|
349
|
+
export {
|
|
350
|
+
listTasks,
|
|
351
|
+
getTasks,
|
|
352
|
+
createTasks,
|
|
353
|
+
updateTasks,
|
|
354
|
+
deleteTasks,
|
|
355
|
+
} from "../_generated/crud/tasks";
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Generated handlers (ejected mode):**
|
|
359
|
+
|
|
360
|
+
```ts
|
|
361
|
+
// src/tasks.ts - Full implementation
|
|
362
|
+
import { query, mutation } from "../_generated/server";
|
|
363
|
+
|
|
364
|
+
export const listTasks = query(async (ctx) => {
|
|
365
|
+
return ctx.db.query("tasks").findMany();
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
export const getTasks = query({
|
|
369
|
+
args: { id: v.string().zodSchema },
|
|
370
|
+
handler: async (ctx, args) => {
|
|
371
|
+
return ctx.db.get("tasks", args.id);
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// ... create, update, delete handlers
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
### Data Management
|
|
381
|
+
|
|
382
|
+
Requires `ARCHLAST_API_KEY` environment variable for authentication.
|
|
383
|
+
|
|
384
|
+
#### `archlast data snapshot`
|
|
385
|
+
|
|
386
|
+
Create a backup snapshot of all data.
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
archlast data snapshot [options]
|
|
390
|
+
|
|
391
|
+
Options:
|
|
392
|
+
--server <url> Server URL (default: "http://localhost:4000")
|
|
393
|
+
--name <name> Custom snapshot name
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**Example:**
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
export ARCHLAST_API_KEY=arch_your_api_key
|
|
400
|
+
archlast data snapshot --name "pre-migration-backup"
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
#### `archlast data list`
|
|
404
|
+
|
|
405
|
+
List available snapshots.
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
archlast data list --server http://localhost:4000
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
#### `archlast data restore`
|
|
412
|
+
|
|
413
|
+
Restore from a snapshot.
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
archlast data restore <snapshot-name> [options]
|
|
417
|
+
|
|
418
|
+
Options:
|
|
419
|
+
--server <url> Server URL
|
|
420
|
+
--force Skip confirmation
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
#### `archlast data export`
|
|
424
|
+
|
|
425
|
+
Export data to a local JSON file.
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
archlast data export [options]
|
|
429
|
+
|
|
430
|
+
Options:
|
|
431
|
+
--server <url> Server URL
|
|
432
|
+
--output <path> Output file path (default: "archlast-export.json")
|
|
433
|
+
--collections <...> Specific collections to export
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
#### `archlast data import`
|
|
437
|
+
|
|
438
|
+
Import data from a local JSON file.
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
archlast data import <file> [options]
|
|
442
|
+
|
|
443
|
+
Options:
|
|
444
|
+
--server <url> Server URL
|
|
445
|
+
--force Skip confirmation
|
|
446
|
+
--merge Merge with existing data (default: replace)
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
#### `archlast data delete`
|
|
450
|
+
|
|
451
|
+
Delete a snapshot.
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
archlast data delete <snapshot-name> --server http://localhost:4000
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
## Configuration
|
|
460
|
+
|
|
461
|
+
The CLI reads configuration in this priority order:
|
|
462
|
+
|
|
463
|
+
1. **CLI flags** (highest priority)
|
|
464
|
+
2. **archlast.config.js** or **archlast.config.ts**
|
|
465
|
+
3. **.env** or **.env.local**
|
|
466
|
+
4. **Defaults** (lowest priority)
|
|
467
|
+
|
|
468
|
+
### Configuration File
|
|
469
|
+
|
|
470
|
+
Create `archlast.config.js` in your project root:
|
|
471
|
+
|
|
472
|
+
```js
|
|
473
|
+
// archlast.config.js
|
|
474
|
+
export default {
|
|
475
|
+
// Docker configuration
|
|
476
|
+
docker: {
|
|
477
|
+
image: "archlast/server",
|
|
478
|
+
tag: "latest",
|
|
479
|
+
containerName: "archlast-server",
|
|
480
|
+
volumeName: "archlast-data",
|
|
481
|
+
network: "archlast-network",
|
|
482
|
+
},
|
|
483
|
+
|
|
484
|
+
// Server settings
|
|
485
|
+
server: {
|
|
486
|
+
port: 4000,
|
|
487
|
+
host: "0.0.0.0",
|
|
488
|
+
},
|
|
489
|
+
|
|
490
|
+
// Paths configuration
|
|
491
|
+
paths: {
|
|
492
|
+
config: ".archlast/config",
|
|
493
|
+
deploy: ".archlast-deploy",
|
|
494
|
+
data: "./data",
|
|
495
|
+
},
|
|
496
|
+
|
|
497
|
+
// CORS settings
|
|
498
|
+
cors: {
|
|
499
|
+
origins: ["http://localhost:3000", "https://myapp.com"],
|
|
500
|
+
credentials: true,
|
|
501
|
+
},
|
|
502
|
+
|
|
503
|
+
// Environment variables to forward to container
|
|
504
|
+
env: {
|
|
505
|
+
ARCHLAST_DASHBOARD_PORT: "4001",
|
|
506
|
+
ARCHLAST_STORE_PORT: "7001",
|
|
507
|
+
NODE_ENV: "production",
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
### TypeScript Configuration
|
|
513
|
+
|
|
514
|
+
```ts
|
|
515
|
+
// archlast.config.ts
|
|
516
|
+
import type { ArchlastConfig } from "@archlast/cli";
|
|
517
|
+
|
|
518
|
+
const config: ArchlastConfig = {
|
|
519
|
+
docker: {
|
|
520
|
+
image: "archlast/server",
|
|
521
|
+
tag: "latest",
|
|
522
|
+
},
|
|
523
|
+
server: {
|
|
524
|
+
port: 4000,
|
|
525
|
+
},
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
export default config;
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
---
|
|
532
|
+
|
|
533
|
+
## Environment Variables
|
|
534
|
+
|
|
535
|
+
The following environment variables are automatically forwarded to the Docker container:
|
|
536
|
+
|
|
537
|
+
| Prefix | Description |
|
|
538
|
+
|--------|-------------|
|
|
539
|
+
| `ARCHLAST_*` | All Archlast configuration |
|
|
540
|
+
| `S3_*` | S3 storage configuration |
|
|
541
|
+
| `AWS_*` | AWS credentials |
|
|
542
|
+
| `STORAGE_*` | Storage settings |
|
|
543
|
+
|
|
544
|
+
### Key Variables
|
|
545
|
+
|
|
546
|
+
```bash
|
|
547
|
+
# API Authentication
|
|
548
|
+
ARCHLAST_API_KEY=arch_your_api_key
|
|
549
|
+
|
|
550
|
+
# Server Configuration
|
|
551
|
+
ARCHLAST_PORT=4000
|
|
552
|
+
ARCHLAST_ALLOWED_ORIGINS=http://localhost:3000,https://myapp.com
|
|
553
|
+
ARCHLAST_CORS_ALLOW_CREDENTIALS=true
|
|
554
|
+
|
|
555
|
+
# Database
|
|
556
|
+
ARCHLAST_DB_ROOT=./data
|
|
557
|
+
|
|
558
|
+
# Storage
|
|
559
|
+
STORAGE_ROOT=./storage
|
|
560
|
+
S3_ENABLED=false
|
|
561
|
+
S3_BUCKET=my-bucket
|
|
562
|
+
S3_REGION=us-east-1
|
|
563
|
+
AWS_ACCESS_KEY_ID=your_key
|
|
564
|
+
AWS_SECRET_ACCESS_KEY=your_secret
|
|
565
|
+
|
|
566
|
+
# Document Store
|
|
567
|
+
ARCHLAST_STORE_HOST=127.0.0.1
|
|
568
|
+
ARCHLAST_STORE_PORT=7001
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
## Usage Examples
|
|
574
|
+
|
|
575
|
+
### Complete Development Workflow
|
|
576
|
+
|
|
577
|
+
```bash
|
|
578
|
+
# 1. Initialize and start server
|
|
579
|
+
archlast start
|
|
580
|
+
|
|
581
|
+
# 2. Start development with hot reload
|
|
582
|
+
archlast dev --path ./my-app
|
|
583
|
+
|
|
584
|
+
# 3. Generate CRUD for new collection
|
|
585
|
+
archlast generate crud users
|
|
586
|
+
|
|
587
|
+
# 4. Check logs if issues arise
|
|
588
|
+
archlast logs --follow
|
|
589
|
+
|
|
590
|
+
# 5. Create backup before major changes
|
|
591
|
+
archlast data snapshot --name "before-feature-x"
|
|
592
|
+
|
|
593
|
+
# 6. Deploy to production
|
|
594
|
+
archlast deploy --server https://api.production.com
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
### CI/CD Pipeline
|
|
598
|
+
|
|
599
|
+
```yaml
|
|
600
|
+
# .github/workflows/deploy.yml
|
|
601
|
+
name: Deploy Archlast
|
|
602
|
+
|
|
603
|
+
on:
|
|
604
|
+
push:
|
|
605
|
+
branches: [main]
|
|
606
|
+
|
|
607
|
+
jobs:
|
|
608
|
+
deploy:
|
|
609
|
+
runs-on: ubuntu-latest
|
|
610
|
+
steps:
|
|
611
|
+
- uses: actions/checkout@v4
|
|
612
|
+
|
|
613
|
+
- name: Setup Node.js
|
|
614
|
+
uses: actions/setup-node@v4
|
|
615
|
+
with:
|
|
616
|
+
node-version: '20'
|
|
617
|
+
|
|
618
|
+
- name: Install CLI
|
|
619
|
+
run: npm install -g @archlast/cli
|
|
620
|
+
|
|
621
|
+
- name: Build types
|
|
622
|
+
run: archlast build --path ./archlast
|
|
623
|
+
|
|
624
|
+
- name: Deploy
|
|
625
|
+
run: archlast deploy --path ./archlast --server ${{ secrets.API_URL }}
|
|
626
|
+
env:
|
|
627
|
+
ARCHLAST_API_KEY: ${{ secrets.ARCHLAST_API_KEY }}
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
### Multi-Environment Setup
|
|
631
|
+
|
|
632
|
+
```bash
|
|
633
|
+
# Development
|
|
634
|
+
archlast dev --server http://localhost:4000
|
|
635
|
+
|
|
636
|
+
# Staging
|
|
637
|
+
archlast deploy --server https://api.staging.myapp.com
|
|
638
|
+
|
|
639
|
+
# Production
|
|
640
|
+
archlast deploy --server https://api.myapp.com
|
|
11
641
|
```
|
|
12
642
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
archlast
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
code: string;
|
|
102
|
-
}>;
|
|
103
|
-
schema: {
|
|
104
|
-
filePath: string;
|
|
105
|
-
code: string;
|
|
106
|
-
} | null;
|
|
107
|
-
timestamp: number;
|
|
108
|
-
}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Server responds with:
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
{
|
|
115
|
-
success: boolean;
|
|
116
|
-
message: string;
|
|
117
|
-
functions: number;
|
|
118
|
-
schema: boolean;
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Similar to Convex's `npx convex dev` workflow.
|
|
123
|
-
|
|
643
|
+
---
|
|
644
|
+
|
|
645
|
+
## Troubleshooting
|
|
646
|
+
|
|
647
|
+
### Common Issues
|
|
648
|
+
|
|
649
|
+
#### "Docker not found"
|
|
650
|
+
|
|
651
|
+
Ensure Docker is installed and running:
|
|
652
|
+
|
|
653
|
+
```bash
|
|
654
|
+
docker --version
|
|
655
|
+
docker ps # Should not error
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
#### "Connection refused"
|
|
659
|
+
|
|
660
|
+
The server might not be running:
|
|
661
|
+
|
|
662
|
+
```bash
|
|
663
|
+
archlast status
|
|
664
|
+
archlast start
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
#### "Permission denied" (Linux)
|
|
668
|
+
|
|
669
|
+
For Docker socket access:
|
|
670
|
+
|
|
671
|
+
```bash
|
|
672
|
+
sudo usermod -aG docker $USER
|
|
673
|
+
newgrp docker
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
#### "Schema file not found"
|
|
677
|
+
|
|
678
|
+
Ensure your schema is at `src/schema.ts`:
|
|
679
|
+
|
|
680
|
+
```
|
|
681
|
+
my-app/
|
|
682
|
+
├── src/
|
|
683
|
+
│ ├── schema.ts # Required
|
|
684
|
+
│ └── functions/
|
|
685
|
+
└── archlast.config.js
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
#### "API key not found"
|
|
689
|
+
|
|
690
|
+
Set the API key:
|
|
691
|
+
|
|
692
|
+
```bash
|
|
693
|
+
export ARCHLAST_API_KEY=arch_your_key
|
|
694
|
+
|
|
695
|
+
# Or add to .env file
|
|
696
|
+
echo "ARCHLAST_API_KEY=arch_your_key" >> .env
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
### Debug Mode
|
|
700
|
+
|
|
701
|
+
Enable verbose logging:
|
|
702
|
+
|
|
703
|
+
```bash
|
|
704
|
+
DEBUG=archlast:* archlast dev
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
---
|
|
708
|
+
|
|
709
|
+
## Deployment Protocol
|
|
710
|
+
|
|
711
|
+
The server receives deployments at `POST /_archlast/deploy` with payload:
|
|
712
|
+
|
|
713
|
+
```typescript
|
|
714
|
+
interface DeployPayload {
|
|
715
|
+
functions: Array<{
|
|
716
|
+
name: string;
|
|
717
|
+
type: "query" | "mutation" | "action" | "http" | "webhook" | "rpc";
|
|
718
|
+
filePath: string;
|
|
719
|
+
code: string;
|
|
720
|
+
}>;
|
|
721
|
+
schema: {
|
|
722
|
+
filePath: string;
|
|
723
|
+
code: string;
|
|
724
|
+
} | null;
|
|
725
|
+
timestamp: number;
|
|
726
|
+
}
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
---
|
|
730
|
+
|
|
124
731
|
## Testing
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
bun test --coverage
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
The test suite includes:
|
|
139
|
-
|
|
140
|
-
- **Unit tests**: Individual module testing (analyzer, generator, uploader, watcher, DI generator)
|
|
141
|
-
- **Integration tests**: Command orchestration (dev, deploy)
|
|
142
|
-
- **CLI tests**: Entry point and command parsing
|
|
143
|
-
- **Fixtures**: Comprehensive test data for malformed exports, complex handlers, schema variations, and mock manifests
|
|
144
|
-
|
|
145
|
-
Coverage target: 90%+ lines/branches/functions
|
|
146
|
-
|
|
147
|
-
## Publishing (maintainers)
|
|
732
|
+
|
|
733
|
+
```bash
|
|
734
|
+
# Run CLI tests
|
|
735
|
+
bun test
|
|
736
|
+
|
|
737
|
+
# Run specific test
|
|
738
|
+
bun test tests/cli.test.ts
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
## Publishing (Maintainers)
|
|
148
742
|
|
|
149
743
|
See `docs/npm-publishing.md` for the release workflow and manual publish steps.
|
|
744
|
+
|
|
745
|
+
## License
|
|
746
|
+
|
|
747
|
+
MIT
|