@griffin-app/griffin-cli 1.0.25 → 1.0.28
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 +122 -367
- package/dist/cli.js +48 -29
- package/dist/commands/env.d.ts +14 -3
- package/dist/commands/env.js +24 -22
- package/dist/commands/generate-key.d.ts +5 -6
- package/dist/commands/generate-key.js +20 -26
- package/dist/commands/hub/apply.d.ts +1 -0
- package/dist/commands/hub/apply.js +44 -29
- package/dist/commands/hub/connect.d.ts +2 -1
- package/dist/commands/hub/connect.js +18 -22
- package/dist/commands/hub/destroy.d.ts +2 -1
- package/dist/commands/hub/destroy.js +123 -119
- package/dist/commands/hub/integrations.d.ts +4 -1
- package/dist/commands/hub/integrations.js +160 -141
- package/dist/commands/hub/login.d.ts +13 -1
- package/dist/commands/hub/login.js +81 -15
- package/dist/commands/hub/logout.d.ts +2 -1
- package/dist/commands/hub/logout.js +7 -12
- package/dist/commands/hub/metrics.js +29 -27
- package/dist/commands/hub/monitor.js +16 -16
- package/dist/commands/hub/notifications.d.ts +3 -6
- package/dist/commands/hub/notifications.js +52 -38
- package/dist/commands/hub/run.d.ts +1 -0
- package/dist/commands/hub/run.js +114 -87
- package/dist/commands/hub/runs.d.ts +2 -0
- package/dist/commands/hub/runs.js +47 -45
- package/dist/commands/hub/secrets.d.ts +5 -5
- package/dist/commands/hub/secrets.js +80 -72
- package/dist/commands/hub/status.d.ts +4 -1
- package/dist/commands/hub/status.js +15 -9
- package/dist/commands/init.d.ts +2 -1
- package/dist/commands/init.js +31 -25
- package/dist/commands/local/run.d.ts +1 -0
- package/dist/commands/local/run.js +34 -26
- package/dist/commands/validate.d.ts +4 -1
- package/dist/commands/validate.js +23 -14
- package/dist/commands/variables.d.ts +17 -3
- package/dist/commands/variables.js +29 -28
- package/dist/core/credentials.d.ts +15 -0
- package/dist/core/credentials.js +37 -0
- package/dist/core/variables.js +4 -0
- package/dist/monitor-runner.js +0 -12
- package/dist/utils/command-wrapper.d.ts +9 -0
- package/dist/utils/command-wrapper.js +23 -0
- package/dist/utils/output.d.ts +66 -0
- package/dist/utils/output.js +202 -0
- package/dist/utils/sdk-error.d.ts +6 -1
- package/dist/utils/sdk-error.js +107 -77
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,457 +1,212 @@
|
|
|
1
1
|
# Griffin CLI
|
|
2
2
|
|
|
3
|
-
Command-line interface for managing API
|
|
3
|
+
Command-line interface for running and managing Griffin API monitors. Supports local execution, validation, syncing to the hub, and managing environments, variables, secrets, integrations, and notifications.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
Griffin CLI
|
|
7
|
+
Griffin CLI provides monitoring-as-code with:
|
|
8
8
|
|
|
9
|
-
1. Write
|
|
10
|
-
2.
|
|
11
|
-
3.
|
|
12
|
-
4.
|
|
13
|
-
5. Monitor execution with `griffin hub runs`
|
|
9
|
+
1. **Local development**: Write monitors in TypeScript/JavaScript under `__griffin__/` directories; validate and run them locally with `griffin validate` and `griffin test`.
|
|
10
|
+
2. **Hub sync**: Preview changes with `griffin plan`, apply with `griffin apply`, or remove with `griffin destroy`.
|
|
11
|
+
3. **Hub operations**: List runs, trigger runs, and view metrics with `griffin runs`, `griffin run`, and `griffin metrics`.
|
|
12
|
+
4. **Configuration**: Manage environments, variables (in state), and secrets (on hub) per environment; manage integrations and notification rules.
|
|
14
13
|
|
|
15
14
|
## Installation
|
|
16
15
|
|
|
17
16
|
```bash
|
|
18
|
-
npm install -g griffin-cli
|
|
17
|
+
npm install -g @griffin-app/griffin-cli
|
|
19
18
|
```
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### 1. Initialize
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
griffin init
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
This creates `.griffin/state.json` which tracks:
|
|
30
|
-
|
|
31
|
-
- Project ID (auto-detected from package.json or directory name)
|
|
32
|
-
- Environment configurations with their targets
|
|
33
|
-
- Synced monitor state
|
|
34
|
-
- Hub connection settings (optional)
|
|
35
|
-
|
|
36
|
-
Override project ID with `--project <name>`.
|
|
37
|
-
|
|
38
|
-
### 2. View Environments
|
|
39
|
-
|
|
40
|
-
View configured environments:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
griffin env list
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### 3. Create Test Monitors
|
|
47
|
-
|
|
48
|
-
Create test files in `__griffin__/` directories. These files export test monitors that can be run locally or synced to the hub.
|
|
49
|
-
|
|
50
|
-
### 4. Run Tests Locally
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
griffin local run local
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Executes tests locally using variables from `variables.yaml` for the specified environment.
|
|
57
|
-
|
|
58
|
-
### 5. Connect to Hub (Optional)
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
griffin hub connect --url https://hub.example.com --token <token>
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### 6. Preview Hub Changes
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
griffin hub monitor
|
|
68
|
-
griffin hub monitor production
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Shows what will be created, updated, or deleted on the hub for the specified environment.
|
|
72
|
-
|
|
73
|
-
### 7. Apply to Hub
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
griffin hub apply
|
|
77
|
-
griffin hub apply production
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Syncs monitors to the hub for the specified environment.
|
|
81
|
-
|
|
82
|
-
### 8. Trigger Hub Run
|
|
20
|
+
Or run via npx:
|
|
83
21
|
|
|
84
22
|
```bash
|
|
85
|
-
griffin
|
|
23
|
+
npx @griffin-app/griffin-cli <command>
|
|
86
24
|
```
|
|
87
25
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
## Commands
|
|
91
|
-
|
|
92
|
-
Commands are organized into four groups:
|
|
93
|
-
|
|
94
|
-
- **Top-level**: Project initialization and utilities
|
|
95
|
-
- **env**: Environment management
|
|
96
|
-
- **local**: Local test execution
|
|
97
|
-
- **hub**: Hub operations (monitor sync, remote execution)
|
|
98
|
-
|
|
99
|
-
### Top-Level Commands
|
|
100
|
-
|
|
101
|
-
#### `griffin init`
|
|
26
|
+
The CLI is also available as the `gr` binary.
|
|
102
27
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
**Options:**
|
|
106
|
-
|
|
107
|
-
- `--project <name>` - Project ID (defaults to package.json name or directory name)
|
|
28
|
+
## Quick Start
|
|
108
29
|
|
|
109
|
-
|
|
30
|
+
### 1. Initialize
|
|
110
31
|
|
|
111
32
|
```bash
|
|
112
33
|
griffin init
|
|
113
|
-
griffin init --project my-service
|
|
34
|
+
griffin init --project my-service # override project ID
|
|
114
35
|
```
|
|
115
36
|
|
|
116
|
-
|
|
37
|
+
Creates `.griffin/state.json` with project ID, default environment, and hub config. Add `.griffin/` to `.gitignore` if you keep local-only state there.
|
|
117
38
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
**Example:**
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
griffin validate
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
#### `griffin generate-key`
|
|
127
|
-
|
|
128
|
-
Generate a cryptographically secure API key for authentication.
|
|
129
|
-
|
|
130
|
-
**Example:**
|
|
39
|
+
### 2. Optional: environments and variables
|
|
131
40
|
|
|
132
41
|
```bash
|
|
133
|
-
griffin
|
|
42
|
+
griffin env add staging
|
|
43
|
+
griffin env add production
|
|
44
|
+
griffin variables add API_BASE=https://staging.example.com --env staging
|
|
45
|
+
griffin variables add API_BASE=https://api.example.com --env production
|
|
134
46
|
```
|
|
135
47
|
|
|
136
|
-
|
|
48
|
+
Variables are stored in `.griffin/state.json` per environment and used when running monitors (e.g. for `variable("API_BASE")` in the monitor DSL).
|
|
137
49
|
|
|
138
|
-
|
|
50
|
+
### 3. Create monitors
|
|
139
51
|
|
|
140
|
-
|
|
52
|
+
Add TypeScript or JavaScript files under `__griffin__/` directories. Each file should export a default monitor (DSL). Discovery uses `**/__griffin__/*.{ts,js}` by default (configurable in state under `discovery`).
|
|
141
53
|
|
|
142
|
-
|
|
54
|
+
### 4. Validate and run locally
|
|
143
55
|
|
|
144
56
|
```bash
|
|
145
|
-
griffin
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
Shows all configured environments with an asterisk (\*) marking the default environment.
|
|
149
|
-
|
|
150
|
-
### Local Commands
|
|
151
|
-
|
|
152
|
-
#### `griffin local run [env]`
|
|
153
|
-
|
|
154
|
-
Run tests locally against an environment. Environment can be specified as a positional argument, or uses the default environment if omitted.
|
|
155
|
-
|
|
156
|
-
**Example:**
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
griffin local run
|
|
160
|
-
griffin local run staging
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Variables are loaded from `variables.yaml` for the specified environment.
|
|
164
|
-
|
|
165
|
-
### Hub Commands
|
|
166
|
-
|
|
167
|
-
#### `griffin hub connect`
|
|
168
|
-
|
|
169
|
-
Configure hub connection settings. When a token is provided, it is stored in the user-level credentials file (`~/.griffin/credentials.json`) for secure, cross-project authentication.
|
|
170
|
-
|
|
171
|
-
**Options:**
|
|
172
|
-
|
|
173
|
-
- `--url <url>` - Hub URL (required)
|
|
174
|
-
- `--token <token>` - API authentication token (optional)
|
|
175
|
-
|
|
176
|
-
**Example:**
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
griffin hub connect --url https://hub.example.com --token abc123
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
#### `griffin hub login`
|
|
183
|
-
|
|
184
|
-
Authenticate with the hub using device authorization flow. The received token is stored in the user-level credentials file (`~/.griffin/credentials.json`) for secure access across all projects.
|
|
185
|
-
|
|
186
|
-
**Example:**
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
griffin hub login
|
|
57
|
+
griffin validate
|
|
58
|
+
griffin test
|
|
59
|
+
griffin test --env staging
|
|
190
60
|
```
|
|
191
61
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
#### `griffin hub logout`
|
|
195
|
-
|
|
196
|
-
Remove stored credentials for the currently configured hub or all hubs.
|
|
62
|
+
`griffin test` runs discovered monitors locally using variables from state for the given environment.
|
|
197
63
|
|
|
198
|
-
|
|
64
|
+
### 5. Connect to the hub (optional)
|
|
199
65
|
|
|
200
|
-
-
|
|
66
|
+
- **Griffin Cloud**: `griffin auth login` (device flow; token stored in `~/.griffin/credentials.json`).
|
|
67
|
+
- **Self-hosted**: `griffin auth connect --url https://hub.example.com --token <api-key>`.
|
|
201
68
|
|
|
202
|
-
|
|
69
|
+
### 6. Preview and apply to hub
|
|
203
70
|
|
|
204
71
|
```bash
|
|
205
|
-
griffin
|
|
206
|
-
griffin
|
|
72
|
+
griffin plan
|
|
73
|
+
griffin plan --env production --json
|
|
74
|
+
griffin apply --env production
|
|
75
|
+
griffin apply --env production --auto-approve
|
|
76
|
+
griffin apply --env production --dry-run
|
|
77
|
+
griffin apply --env production --prune # delete hub monitors not present locally
|
|
207
78
|
```
|
|
208
79
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
Show hub connection status, including whether credentials are configured.
|
|
212
|
-
|
|
213
|
-
**Example:**
|
|
80
|
+
### 7. Runs and metrics
|
|
214
81
|
|
|
215
82
|
```bash
|
|
216
|
-
griffin
|
|
83
|
+
griffin runs
|
|
84
|
+
griffin runs --env production --monitor health-check --limit 20
|
|
85
|
+
griffin run --env production --monitor health-check
|
|
86
|
+
griffin run --env production --monitor health-check --wait
|
|
87
|
+
griffin metrics --env production
|
|
88
|
+
griffin metrics --env production --period 7d --json
|
|
217
89
|
```
|
|
218
90
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
Show recent runs from the hub.
|
|
222
|
-
|
|
223
|
-
**Options:**
|
|
224
|
-
|
|
225
|
-
- `--monitor <name>` - Filter by monitor name
|
|
226
|
-
- `--limit <number>` - Number of runs to show (default: 10)
|
|
227
|
-
|
|
228
|
-
**Example:**
|
|
229
|
-
|
|
230
|
-
```bash
|
|
231
|
-
griffin hub runs
|
|
232
|
-
griffin hub runs --monitor health-check --limit 5
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
#### `griffin hub monitor [env]`
|
|
236
|
-
|
|
237
|
-
Show what changes would be applied to the hub. Environment can be specified as a positional argument, or uses the default environment if omitted.
|
|
91
|
+
## Commands
|
|
238
92
|
|
|
239
|
-
**
|
|
93
|
+
Commands are **top-level** or under a **group**. The default environment is `default` unless overridden with `--env <name>` where supported.
|
|
240
94
|
|
|
241
|
-
|
|
95
|
+
| Area | Commands | Purpose |
|
|
96
|
+
|------|----------|--------|
|
|
97
|
+
| **Project** | `init`, `validate`, `status` | Bootstrap, validate monitors, show status |
|
|
98
|
+
| **Local run** | `test` | Run monitors locally |
|
|
99
|
+
| **Hub sync** | `plan`, `apply`, `destroy` | Preview changes, push to hub, remove from hub |
|
|
100
|
+
| **Hub runs** | `runs`, `run`, `metrics` | List runs, trigger run, view metrics |
|
|
101
|
+
| **Auth** | `auth login`, `auth logout`, `auth connect`, `auth generate-key` | Cloud or self-hosted auth |
|
|
102
|
+
| **Environments** | `env list`, `env add`, `env remove` | Manage environments |
|
|
103
|
+
| **Variables** | `variables list`, `variables add`, `variables remove` | Per-environment variables (in state) |
|
|
104
|
+
| **Secrets** | `secrets list`, `secrets set`, `secrets get`, `secrets delete` | Per-environment secrets (stored on hub) |
|
|
105
|
+
| **Integrations** | `integrations list`, `integrations show`, `integrations connect`, `integrations update`, `integrations remove` | Slack, email, webhooks, etc. |
|
|
106
|
+
| **Notifications** | `notifications list`, `notifications test` | Notification rules and test sends |
|
|
242
107
|
|
|
243
|
-
|
|
108
|
+
### Top-level commands
|
|
244
109
|
|
|
245
|
-
|
|
246
|
-
griffin
|
|
247
|
-
griffin hub
|
|
248
|
-
griffin
|
|
249
|
-
|
|
110
|
+
- **`griffin init`** – Initialize Griffin in the current directory. Options: `--project <name>`.
|
|
111
|
+
- **`griffin validate`** – Check monitor files for errors (no run, no hub).
|
|
112
|
+
- **`griffin status`** – Show project and hub connection status.
|
|
113
|
+
- **`griffin test`** – Run monitors locally. Options: `--env <name>` (default: `default`).
|
|
114
|
+
- **`griffin plan`** – Preview pending monitor changes. Options: `--env <name>`, `--json`. Exit code 2 if there are changes.
|
|
115
|
+
- **`griffin apply`** – Push monitor changes to the hub. Options: `--env <name>`, `--auto-approve`, `--dry-run`, `--prune`.
|
|
116
|
+
- **`griffin destroy`** – Destroy monitors on the hub. Options: `--env <name>`, `--monitor <nameOrId>`, `--auto-approve`, `--dry-run`.
|
|
117
|
+
- **`griffin runs`** – List recent runs. Options: `--env <name>`, `--monitor <name>`, `--limit <number>`.
|
|
118
|
+
- **`griffin run`** – Trigger a monitor run. Options: `--env <name>`, `--monitor <name>` (required), `--wait`, `--force`.
|
|
119
|
+
- **`griffin metrics`** – Show metrics summary. Options: `--env <name>`, `--period <1h|6h|24h|7d|30d>`, `--json`.
|
|
250
120
|
|
|
251
|
-
|
|
121
|
+
### Auth (`griffin auth`)
|
|
252
122
|
|
|
253
|
-
-
|
|
254
|
-
-
|
|
255
|
-
-
|
|
123
|
+
- **`auth login`** – Authenticate with Griffin Cloud (device flow).
|
|
124
|
+
- **`auth logout`** – Clear stored credentials.
|
|
125
|
+
- **`auth connect`** – Set hub URL and API key for self-hosted. Requires `--url <url>` and `--token <token>`.
|
|
126
|
+
- **`auth generate-key`** – Generate an API key.
|
|
256
127
|
|
|
257
|
-
|
|
128
|
+
### Environments (`griffin env`)
|
|
258
129
|
|
|
259
|
-
|
|
130
|
+
- **`env list`** – List configured environments.
|
|
131
|
+
- **`env add <name>`** – Add an environment.
|
|
132
|
+
- **`env remove <name>`** – Remove an environment.
|
|
260
133
|
|
|
261
|
-
|
|
134
|
+
### Variables (`griffin variables`)
|
|
262
135
|
|
|
263
|
-
|
|
264
|
-
- `--dry-run` - Show what would be done without making changes
|
|
265
|
-
- `--prune` - Delete monitors on hub that don't exist locally
|
|
136
|
+
Variables live in `.griffin/state.json` per environment (not in a separate file). Use them in monitors via `variable("KEY")`.
|
|
266
137
|
|
|
267
|
-
|
|
138
|
+
- **`variables list`** – List variables. Option: `--env <name>`.
|
|
139
|
+
- **`variables add <KEY=VALUE>`** – Set a variable. Option: `--env <name>`.
|
|
140
|
+
- **`variables remove <key>`** – Remove a variable. Option: `--env <name>`.
|
|
268
141
|
|
|
269
|
-
|
|
270
|
-
griffin hub apply
|
|
271
|
-
griffin hub apply production --auto-approve
|
|
272
|
-
griffin hub apply staging --dry-run
|
|
273
|
-
griffin hub apply production --prune
|
|
274
|
-
```
|
|
142
|
+
### Secrets (`griffin secrets`)
|
|
275
143
|
|
|
276
|
-
|
|
144
|
+
Secrets are stored on the hub per environment. Use them in monitors via `secret("REF")`.
|
|
277
145
|
|
|
278
|
-
|
|
146
|
+
- **`secrets list`** – List secret names. Options: `--env <name>`, `--json`.
|
|
147
|
+
- **`secrets set <name>`** – Create or update a secret. Options: `--env <name>`, `--value <value>` (avoid for sensitive data).
|
|
148
|
+
- **`secrets get <name>`** – Show secret metadata. Options: `--env <name>`, `--json`.
|
|
149
|
+
- **`secrets delete <name>`** – Delete a secret. Options: `--env <name>`, `--force`.
|
|
279
150
|
|
|
280
|
-
|
|
151
|
+
### Integrations (`griffin integrations`)
|
|
281
152
|
|
|
282
|
-
-
|
|
283
|
-
-
|
|
284
|
-
-
|
|
153
|
+
- **`integrations list`** – List integrations. Options: `--category`, `--provider`, `--env`, `--enabled`, `--json`.
|
|
154
|
+
- **`integrations show <id>`** – Show integration details. Option: `--json`.
|
|
155
|
+
- **`integrations connect [type] [provider]`** – Connect a new integration. Options: `--name`, `--env`, `--json`.
|
|
156
|
+
- **`integrations update <id>`** – Update an integration. Options: `--name`, `--env`, `--enabled`, `--json`.
|
|
157
|
+
- **`integrations remove <id>`** – Remove an integration. Option: `--force`.
|
|
285
158
|
|
|
286
|
-
|
|
159
|
+
### Notifications (`griffin notifications`)
|
|
287
160
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
griffin hub run staging --monitor health-check --wait
|
|
291
|
-
griffin hub run production --monitor api-check --force
|
|
292
|
-
```
|
|
161
|
+
- **`notifications list`** – List notification rules. Options: `--monitor <id>`, `--enabled`, `--json`.
|
|
162
|
+
- **`notifications test`** – Send a test notification. Options: `--integration <id|name>`, `--channel`, `--to-addresses`.
|
|
293
163
|
|
|
294
164
|
## Configuration
|
|
295
165
|
|
|
296
|
-
### Environment
|
|
297
|
-
|
|
298
|
-
- `GRIFFIN_ENV` - Default environment to use for commands
|
|
299
|
-
|
|
300
|
-
### State File
|
|
301
|
-
|
|
302
|
-
Griffin stores project configuration in `.griffin/state.json`:
|
|
303
|
-
|
|
304
|
-
```json
|
|
305
|
-
{
|
|
306
|
-
"stateVersion": 1,
|
|
307
|
-
"projectId": "my-project",
|
|
308
|
-
"environments": {
|
|
309
|
-
"local": {}
|
|
310
|
-
},
|
|
311
|
-
"defaultEnvironment": "local",
|
|
312
|
-
"hub": {
|
|
313
|
-
"baseUrl": "https://hub.example.com",
|
|
314
|
-
"clientId": "..."
|
|
315
|
-
},
|
|
316
|
-
"discovery": {
|
|
317
|
-
"pattern": "**/__griffin__/*.{ts,js}",
|
|
318
|
-
"ignore": ["node_modules/**", "dist/**"]
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
**Important:** Add `.griffin/` to `.gitignore` as it contains local project state.
|
|
324
|
-
|
|
325
|
-
### Credentials File
|
|
326
|
-
|
|
327
|
-
Griffin stores user-level authentication credentials in `~/.griffin/credentials.json`:
|
|
328
|
-
|
|
329
|
-
```json
|
|
330
|
-
{
|
|
331
|
-
"version": 1,
|
|
332
|
-
"hubs": {
|
|
333
|
-
"https://hub.example.com": {
|
|
334
|
-
"token": "...",
|
|
335
|
-
"updatedAt": "2024-01-24T12:00:00.000Z"
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
This file is automatically created and managed by the CLI when you use `griffin hub login` or `griffin hub connect --token <token>`. Credentials are stored per-hub URL and are available across all projects on your system.
|
|
342
|
-
|
|
343
|
-
**Security:** The credentials file is created with restricted permissions (0600) to ensure only the owner can read/write.
|
|
166
|
+
### Environment variable
|
|
344
167
|
|
|
345
|
-
|
|
168
|
+
- **`GRIFFIN_ENV`** – Default environment for commands (if the CLI respects it; otherwise pass `--env` explicitly).
|
|
346
169
|
|
|
347
|
-
|
|
170
|
+
### State file (`.griffin/state.json`)
|
|
348
171
|
|
|
349
|
-
|
|
172
|
+
Stores project configuration:
|
|
350
173
|
|
|
351
|
-
|
|
352
|
-
environments
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
staging:
|
|
357
|
-
api_host: "staging.example.com"
|
|
358
|
-
api_key: "staging-key"
|
|
359
|
-
production:
|
|
360
|
-
api_host: "api.example.com"
|
|
361
|
-
api_key: "prod-key"
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
**Example workflow:**
|
|
365
|
-
|
|
366
|
-
```bash
|
|
367
|
-
# List available environments
|
|
368
|
-
griffin env list
|
|
369
|
-
|
|
370
|
-
# Run tests against different environments
|
|
371
|
-
griffin local run local
|
|
372
|
-
griffin local run staging
|
|
373
|
-
|
|
374
|
-
# Sync to hub for specific environment
|
|
375
|
-
griffin hub apply production
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
## Test Monitor Discovery
|
|
174
|
+
- **projectId** – Project identifier.
|
|
175
|
+
- **environments** – Map of environment name to config (each can have optional **variables**).
|
|
176
|
+
- **hub** – `baseUrl`, optional `clientId`.
|
|
177
|
+
- **cloud** – `authUrl` (for Cloud login).
|
|
178
|
+
- **discovery** – Optional `pattern` (default `**/__griffin__/*.{ts,js}`) and `ignore` (e.g. `["node_modules/**", "dist/**"]`).
|
|
379
179
|
|
|
380
|
-
|
|
180
|
+
Add `.griffin/` to `.gitignore` if the file contains local-only overrides.
|
|
381
181
|
|
|
382
|
-
|
|
182
|
+
### Credentials (`~/.griffin/credentials.json`)
|
|
383
183
|
|
|
384
|
-
|
|
184
|
+
User-level auth. Used by `auth login` and `auth connect --token`. Do not commit. Created with restricted permissions (0600).
|
|
385
185
|
|
|
386
|
-
|
|
186
|
+
## Checklist
|
|
387
187
|
|
|
388
|
-
- **
|
|
389
|
-
- **UPDATE**: Monitor exists in both, but hash differs
|
|
390
|
-
- **DELETE**: Monitor exists in state but not locally
|
|
391
|
-
- **NOOP**: Monitor exists in both with same hash
|
|
188
|
+
**First-time setup**
|
|
392
189
|
|
|
393
|
-
|
|
190
|
+
- Run `griffin init` (optionally `griffin env add` for extra environments).
|
|
191
|
+
- Add variables with `griffin variables add KEY=value --env <env>` for monitor `variable("...")` refs.
|
|
192
|
+
- Use `griffin auth login` or `griffin auth connect` for plan/apply/runs/run/metrics.
|
|
394
193
|
|
|
395
|
-
|
|
194
|
+
**Before deploying**
|
|
396
195
|
|
|
397
|
-
|
|
196
|
+
- `griffin validate` then `griffin test --env <env>`.
|
|
197
|
+
- `griffin plan --env <env>` then `griffin apply --env <env>` (use `--dry-run` or `--auto-approve` as needed).
|
|
398
198
|
|
|
399
|
-
|
|
199
|
+
**Secrets in monitors**
|
|
400
200
|
|
|
401
|
-
- `
|
|
402
|
-
- `GET /monitor` - List monitors
|
|
403
|
-
- `GET /runs` - List runs
|
|
404
|
-
- `GET /runs/:id` - Get run details
|
|
405
|
-
- `POST /runs/trigger/:monitorId` - Trigger run
|
|
201
|
+
- Create/update with `griffin secrets set REF --env <env>`; ensure ref names match the monitor DSL (e.g. `API_TOKEN`).
|
|
406
202
|
|
|
407
203
|
## Development
|
|
408
204
|
|
|
409
205
|
```bash
|
|
410
|
-
# Install dependencies
|
|
411
206
|
npm install
|
|
412
|
-
|
|
413
|
-
# Build
|
|
414
207
|
npm run build
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
npm run dev -- <command>
|
|
418
|
-
|
|
419
|
-
# Example
|
|
420
|
-
npm run dev -- validate
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
## Architecture
|
|
424
|
-
|
|
425
|
-
```
|
|
426
|
-
griffin-cli/
|
|
427
|
-
├── src/
|
|
428
|
-
│ ├── commands/ # Command implementations
|
|
429
|
-
│ │ ├── local/ # Local execution commands
|
|
430
|
-
│ │ │ └── run.ts
|
|
431
|
-
│ │ ├── hub/ # Hub operation commands
|
|
432
|
-
│ │ │ ├── connect.ts
|
|
433
|
-
│ │ │ ├── status.ts
|
|
434
|
-
│ │ │ ├── runs.ts
|
|
435
|
-
│ │ │ ├── monitor.ts
|
|
436
|
-
│ │ │ ├── apply.ts
|
|
437
|
-
│ │ │ └── run.ts
|
|
438
|
-
│ │ ├── env.ts # Environment commands
|
|
439
|
-
│ │ ├── init.ts
|
|
440
|
-
│ │ ├── validate.ts
|
|
441
|
-
│ │ └── generate-key.ts
|
|
442
|
-
│ ├── core/ # Core logic
|
|
443
|
-
│ │ ├── sdk.ts # Hub SDK client
|
|
444
|
-
│ │ ├── apply.ts # Apply engine
|
|
445
|
-
│ │ ├── diff.ts # Diff computation
|
|
446
|
-
│ │ ├── discovery.ts # Monitor discovery
|
|
447
|
-
│ │ ├── state.ts # State management
|
|
448
|
-
│ │ ├── variables.ts # Variable resolution
|
|
449
|
-
│ │ └── project.ts # Project detection
|
|
450
|
-
│ ├── schemas/ # Type definitions
|
|
451
|
-
│ │ └── state.ts # State file schemas
|
|
452
|
-
│ ├── cli.ts # CLI entry point
|
|
453
|
-
│ └── index.ts # Public API exports
|
|
454
|
-
└── package.json
|
|
208
|
+
npm run dev -- <command> # e.g. npm run dev -- validate
|
|
209
|
+
npm run test
|
|
455
210
|
```
|
|
456
211
|
|
|
457
212
|
## License
|