@archlast/cli 0.1.0 → 0.1.3
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 +106 -137
- package/dist/cli.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,149 +1,118 @@
|
|
|
1
|
-
# Archlast CLI
|
|
2
|
-
|
|
3
|
-
CLI tool for Archlast development and
|
|
4
|
-
|
|
5
|
-
##
|
|
1
|
+
# Archlast CLI
|
|
2
|
+
|
|
3
|
+
CLI tool for Archlast development, deployment, and Docker lifecycle management.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js 18+
|
|
8
|
+
- Docker Desktop or Docker Engine
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
## Installation
|
|
8
11
|
|
|
9
12
|
```bash
|
|
10
13
|
npm install -g @archlast/cli
|
|
11
14
|
```
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
archlast start
|
|
20
|
+
archlast status
|
|
21
|
+
archlast logs --follow
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
To watch and auto-deploy functions during development:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
archlast dev --path ./archlast --server http://localhost:4000
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
- `dev` - watch `archlast/src` for changes, regenerate types, and deploy deltas
|
|
33
|
+
- `deploy` - one-time deployment to the server
|
|
34
|
+
- `build` - generate types without deploying
|
|
35
|
+
- `pull` - pull schema/files from the server, or use `--docker` to pull an image
|
|
36
|
+
- `start` / `stop` / `restart` - manage the Docker container
|
|
37
|
+
- `status` - print container status and health
|
|
38
|
+
- `logs` - stream container logs
|
|
39
|
+
- `upgrade` - pull a new image and restart the container
|
|
40
|
+
- `config` - show resolved Docker config (use `--json` for JSON)
|
|
41
|
+
- `generate crud <collection>` - scaffold CRUD handlers from schema
|
|
42
|
+
- `data` - snapshot/export/import/restore data (requires `ARCHLAST_API_KEY`)
|
|
43
|
+
|
|
44
|
+
## Common options
|
|
45
|
+
|
|
46
|
+
- `--path <path>` points to your Archlast project folder
|
|
47
|
+
- `--server <url>` sets the API base URL (default: `http://localhost:4000`)
|
|
48
|
+
- `--port <port>` overrides the container port for `start` and `upgrade`
|
|
49
|
+
- `--config <path>` points to `archlast.config.js`
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
The CLI reads configuration in this order:
|
|
54
|
+
1. CLI flags
|
|
55
|
+
2. `archlast.config.js`
|
|
56
|
+
3. `.env` or `.env.local`
|
|
57
|
+
4. defaults
|
|
58
|
+
|
|
59
|
+
Example `archlast.config.js`:
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
export default {
|
|
63
|
+
docker: {
|
|
64
|
+
image: "algochad/archlast-server",
|
|
65
|
+
tag: "0.1.0",
|
|
66
|
+
containerName: "archlast-server",
|
|
67
|
+
volumeName: "archlast-data",
|
|
68
|
+
},
|
|
69
|
+
server: { port: 4000 },
|
|
70
|
+
paths: {
|
|
71
|
+
config: ".archlast/config",
|
|
72
|
+
deploy: ".archlast-deploy",
|
|
73
|
+
},
|
|
74
|
+
cors: { origins: ["http://localhost:3000"] },
|
|
75
|
+
env: {
|
|
76
|
+
ARCHLAST_DASHBOARD_PORT: "4001",
|
|
77
|
+
ARCHLAST_STORE_PORT: "7001",
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Environment variables starting with `ARCHLAST_`, `S3_`, `AWS_`, and `STORAGE_`
|
|
83
|
+
are forwarded into the container.
|
|
84
|
+
|
|
85
|
+
## Dev and deploy flow
|
|
86
|
+
|
|
87
|
+
The server receives deployments at `POST /_archlast/deploy` with payload:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
{
|
|
91
|
+
functions: Array<{
|
|
92
|
+
name: string;
|
|
93
|
+
type: "query" | "mutation" | "action";
|
|
94
|
+
filePath: string;
|
|
95
|
+
code: string;
|
|
96
|
+
}>;
|
|
97
|
+
schema: { filePath: string; code: string } | null;
|
|
98
|
+
timestamp: number;
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Data management
|
|
103
|
+
|
|
104
|
+
Use the `data` command group to snapshot, export, import, and restore data.
|
|
105
|
+
Set `ARCHLAST_API_KEY` in your environment for authentication.
|
|
106
|
+
|
|
107
|
+
Examples:
|
|
14
108
|
|
|
15
109
|
```bash
|
|
16
|
-
|
|
17
|
-
|
|
110
|
+
archlast data snapshot --name "pre-migration"
|
|
111
|
+
archlast data export ./backup.zip
|
|
112
|
+
archlast data import ./backup.zip --strategy merge
|
|
113
|
+
archlast data restore snapshot-2026-01-01.zip
|
|
18
114
|
```
|
|
19
|
-
|
|
20
|
-
## Usage
|
|
21
|
-
|
|
22
|
-
### Development Mode
|
|
23
|
-
|
|
24
|
-
Watch for file changes and auto-generate types:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
bun run archlast:dev
|
|
28
|
-
# or
|
|
29
|
-
bun archlast dev
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Options:
|
|
33
|
-
|
|
34
|
-
- `--path <path>` - Path to archlast folder (default: `./archlast`)
|
|
35
|
-
- `--port <port>` - Server port (default: `3001`)
|
|
36
|
-
- `--server <url>` - Server URL for code upload (default: `http://localhost:3001`)
|
|
37
|
-
|
|
38
|
-
### Deploy Mode
|
|
39
|
-
|
|
40
|
-
One-time deployment:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
bun run archlast:deploy
|
|
44
|
-
# or
|
|
45
|
-
bun archlast deploy
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Options:
|
|
49
|
-
|
|
50
|
-
- `--path <path>` - Path to archlast folder (default: `./archlast`)
|
|
51
|
-
- `--server <url>` - Server URL for code upload (default: `http://localhost:3001`)
|
|
52
|
-
|
|
53
|
-
## Features
|
|
54
|
-
|
|
55
|
-
- 📁 **File Watching**: Monitors `archlast/src/` folder for changes
|
|
56
|
-
- 🔍 **Code Analysis**: Detects functions (query, mutation, action) and schema changes
|
|
57
|
-
- 🎯 **Type Generation**: Auto-generates client-side TypeScript types to `_generated/`
|
|
58
|
-
- 🔄 **Diff Detection**: Shows added, modified, and removed functions
|
|
59
|
-
- ⚡ **Fast Rebuilds**: Only regenerates on actual changes
|
|
60
|
-
- 🌐 **HTTP Upload**: Uploads code to server via `/_archlast/deploy` endpoint
|
|
61
|
-
|
|
62
|
-
## How It Works
|
|
63
|
-
|
|
64
|
-
1. Watches all `.ts` files in the `archlast/src/` folder
|
|
65
|
-
2. Analyzes exports to find `query`, `mutation`, and `action` functions
|
|
66
|
-
3. Detects schema changes in `src/schema.ts`
|
|
67
|
-
4. Generates type definitions in `archlast/_generated/api.ts`
|
|
68
|
-
5. **Uploads code to server via HTTP** (POST to `/_archlast/deploy`)
|
|
69
|
-
6. Shows a diff of changes in the console
|
|
70
|
-
|
|
71
|
-
## Project Structure
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
archlast/
|
|
75
|
-
├── src/ # Your function definitions
|
|
76
|
-
│ ├── schema.ts # Database schema
|
|
77
|
-
│ ├── tasks.ts # Function exports
|
|
78
|
-
│ └── ...
|
|
79
|
-
├── _generated/ # Auto-generated by CLI
|
|
80
|
-
│ ├── api.ts # Type-safe API object
|
|
81
|
-
│ ├── index.ts # Barrel export
|
|
82
|
-
│ └── server.ts # Server types (manual)
|
|
83
|
-
├── package.json
|
|
84
|
-
└── tsconfig.json
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Run `bun run dev` from the archlast folder to start development mode.
|
|
88
|
-
|
|
89
|
-
Similar to Convex's `npx convex dev` workflow.
|
|
90
|
-
|
|
91
|
-
## Server Endpoint
|
|
92
|
-
|
|
93
|
-
The server receives deployments at `POST /_archlast/deploy` with payload:
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
{
|
|
97
|
-
functions: Array<{
|
|
98
|
-
name: string;
|
|
99
|
-
type: 'query' | 'mutation' | 'action';
|
|
100
|
-
filePath: string;
|
|
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
|
-
|
|
124
|
-
## Testing
|
|
125
|
-
|
|
126
|
-
Run the test suite:
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
bun test
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Run with coverage:
|
|
133
|
-
|
|
134
|
-
```bash
|
|
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
115
|
|
|
147
116
|
## Publishing (maintainers)
|
|
148
117
|
|
|
149
|
-
See `docs/npm-publishing.md` for the release workflow and manual publish steps.
|
|
118
|
+
See `docs/npm-publishing.md` for the release workflow and manual publish steps.
|
package/dist/cli.js
CHANGED
|
@@ -320990,8 +320990,8 @@ import * as path10 from "path";
|
|
|
320990
320990
|
import { createRequire as createRequire2 } from "module";
|
|
320991
320991
|
var DEFAULTS = {
|
|
320992
320992
|
docker: {
|
|
320993
|
-
image: "archlast
|
|
320994
|
-
tag: "
|
|
320993
|
+
image: "algochad/archlast-server",
|
|
320994
|
+
tag: "0.1.0",
|
|
320995
320995
|
containerName: "archlast-server",
|
|
320996
320996
|
volumeName: "archlast-data"
|
|
320997
320997
|
},
|
|
@@ -322320,7 +322320,7 @@ async function configCommand(options) {
|
|
|
322320
322320
|
|
|
322321
322321
|
// src/cli.ts
|
|
322322
322322
|
var program2 = new Command;
|
|
322323
|
-
program2.name("archlast").description("Archlast CLI for development and deployment").version("0.1.
|
|
322323
|
+
program2.name("archlast").description("Archlast CLI for development and deployment").version("0.1.1");
|
|
322324
322324
|
program2.command("build").description("Generate types without deploying").option("--path <path>", "Path to archlast folder", ".").action(buildCommand);
|
|
322325
322325
|
program2.command("dev").description("Start development mode with file watching").option("-p, --port <port>", "Server port", "3001").option("--path <path>", "Path to archlast folder", ".").option("--server <url>", "Server URL for code upload", "http://localhost:4000").option("--max-poll <number>", "Maximum server polling retries", "30").action(devCommand);
|
|
322326
322326
|
program2.command("deploy").description("Deploy to production").option("--path <path>", "Path to archlast folder", ".").option("--server <url>", "Server URL for code upload", "http://localhost:4000").option("--max-poll <number>", "Maximum server polling retries", "30").action(deployCommand);
|