statelyai 0.7.4 → 0.7.6
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 +322 -28
- package/dist/bin.mjs +1 -1
- package/dist/{cli-CrVHYzeo.mjs → cli-D0TeuFzR.mjs} +176 -81
- package/dist/index.d.mts +55 -7
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,48 +1,126 @@
|
|
|
1
1
|
# statelyai
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`statelyai` connects local machine source files to Stately Studio. Use it to
|
|
4
|
+
open a file in the visual editor, compare local and remote machines, or sync a
|
|
5
|
+
project in both directions.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
## Run the CLI
|
|
6
8
|
|
|
7
|
-
<!--
|
|
8
|
-
## Happy Path
|
|
9
|
+
<!-- package name and binary from package.json -->
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
Run without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx statelyai --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or install it globally:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install --global statelyai
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Choose a workflow
|
|
24
|
+
|
|
25
|
+
<!-- command capabilities and side effects from src/cli.ts#COMMANDS -->
|
|
26
|
+
|
|
27
|
+
| Goal | Command | Writes |
|
|
28
|
+
| ---------------------------- | ---------------------------------------------------- | ------------------------------------------------------- |
|
|
29
|
+
| Edit one local file visually | `statelyai open <file>` | Local file, when you save in the editor |
|
|
30
|
+
| Set up project sync | `statelyai init [--scan]` | Remote project and local `statelyai.json` |
|
|
31
|
+
| Inspect project machines | `statelyai status` | Nothing |
|
|
32
|
+
| Preview project uploads | `statelyai push --dry-run` | Nothing |
|
|
33
|
+
| Upload local machines | `statelyai push [file]` | Remote machines and local `@statelyai` IDs |
|
|
34
|
+
| Download project machines | `statelyai pull` | Linked local files and new files under `newMachinesDir` |
|
|
35
|
+
| Compare two machines | `statelyai diff <source> <target>` | Nothing |
|
|
36
|
+
| Fail on differences in CI | `statelyai diff <source> <target> --fail-on-changes` | Nothing |
|
|
37
|
+
|
|
38
|
+
## Quick start
|
|
39
|
+
|
|
40
|
+
<!-- project initialization and sync flow from InitCommand, PushCommand, PullCommand, and projectConfig.ts -->
|
|
41
|
+
|
|
42
|
+
For hosted Stately, authenticate once:
|
|
11
43
|
|
|
12
44
|
```bash
|
|
13
45
|
statelyai login
|
|
14
46
|
```
|
|
15
47
|
|
|
16
|
-
|
|
17
|
-
API-key auth.
|
|
48
|
+
Initialize the current repository and scan for XState files:
|
|
18
49
|
|
|
19
|
-
|
|
50
|
+
```bash
|
|
51
|
+
statelyai init --scan
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`--scan` suggests `include` globs and asks before saving them. Without
|
|
55
|
+
`--scan`, `init` creates `statelyai.json` with an empty `include` list.
|
|
56
|
+
|
|
57
|
+
Preview the files and remote operations:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
statelyai push --dry-run
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then push and pull:
|
|
20
64
|
|
|
21
65
|
```bash
|
|
22
|
-
statelyai
|
|
66
|
+
statelyai push
|
|
67
|
+
statelyai pull
|
|
23
68
|
```
|
|
24
69
|
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
70
|
+
`push` creates remote machines for unlinked source machines, updates already
|
|
71
|
+
linked machines, and writes returned IDs into source comments. `pull` updates
|
|
72
|
+
linked files. If `newMachinesDir` is configured, it also creates local files
|
|
73
|
+
for machines that exist only in the Studio project.
|
|
74
|
+
|
|
75
|
+
## Authentication
|
|
30
76
|
|
|
31
|
-
|
|
77
|
+
<!-- authentication flags, environment resolution, and credential storage from src/cli.ts and src/credentials.ts -->
|
|
78
|
+
|
|
79
|
+
Browser OAuth is the default:
|
|
32
80
|
|
|
33
81
|
```bash
|
|
34
|
-
statelyai
|
|
82
|
+
statelyai login
|
|
35
83
|
```
|
|
36
84
|
|
|
37
|
-
|
|
85
|
+
Use an API key instead:
|
|
38
86
|
|
|
39
87
|
```bash
|
|
40
|
-
statelyai
|
|
88
|
+
statelyai login --api-key
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Create or manage keys in [Stately API key settings](https://stately.ai/registry/user/my-settings?tab=API+Key).
|
|
92
|
+
|
|
93
|
+
For noninteractive input:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
printf '%s\n' "$STATELY_API_KEY" | statelyai login --stdin
|
|
41
97
|
```
|
|
42
98
|
|
|
43
|
-
|
|
99
|
+
For automation, prefer an environment variable instead of storing a
|
|
100
|
+
credential. Resolution order is:
|
|
101
|
+
|
|
102
|
+
1. `STATELY_ACCESS_TOKEN`
|
|
103
|
+
2. `STATELY_API_KEY`
|
|
104
|
+
3. `NEXT_PUBLIC_STATELY_API_KEY`
|
|
105
|
+
4. the credential stored by `statelyai login`
|
|
106
|
+
|
|
107
|
+
The CLI loads `.env.local` from the current directory before resolving these
|
|
108
|
+
variables.
|
|
109
|
+
|
|
110
|
+
Use `statelyai status --auth` to report the selected source without printing
|
|
111
|
+
the credential. `statelyai logout` removes stored credentials but does not modify
|
|
112
|
+
environment variables.
|
|
44
113
|
|
|
45
|
-
|
|
114
|
+
Stored credentials use macOS Keychain or Linux Secret Service when available,
|
|
115
|
+
with a private config file as fallback. Set `STATELYAI_CREDENTIALS_BACKEND=file`
|
|
116
|
+
to force file storage, or `STATELYAI_CONFIG_DIR` to choose its directory.
|
|
117
|
+
|
|
118
|
+
## `statelyai.json`
|
|
119
|
+
|
|
120
|
+
<!-- config shape, defaults, and migration behavior from src/projectConfig.ts -->
|
|
121
|
+
|
|
122
|
+
`push` and `pull` use `statelyai.json` from the current directory unless
|
|
123
|
+
`--config` supplies another path.
|
|
46
124
|
|
|
47
125
|
```json
|
|
48
126
|
{
|
|
@@ -53,34 +131,250 @@ That writes a `statelyai.json` like:
|
|
|
53
131
|
"defaultXStateVersion": 5,
|
|
54
132
|
"include": ["src/**/*.ts"],
|
|
55
133
|
"exclude": ["**/*.test.*", "**/*.spec.*"],
|
|
56
|
-
"newMachinesDir": "src"
|
|
134
|
+
"newMachinesDir": "src/machines"
|
|
57
135
|
}
|
|
58
136
|
```
|
|
59
137
|
|
|
60
|
-
|
|
138
|
+
| Field | Purpose |
|
|
139
|
+
| ---------------------- | --------------------------------------------------------------- |
|
|
140
|
+
| `$schema` | Published JSON Schema URL. |
|
|
141
|
+
| `version` | Config format version. Currently `1.0.0`. |
|
|
142
|
+
| `projectId` | Remote Studio project ID. |
|
|
143
|
+
| `studioUrl` | Studio API origin. |
|
|
144
|
+
| `defaultXStateVersion` | XState version used when creating remote machines. Minimum `5`. |
|
|
145
|
+
| `include` | Source globs used by project-wide `push` and `pull`. |
|
|
146
|
+
| `exclude` | Globs removed from discovery. Defaults to tests and specs. |
|
|
147
|
+
| `newMachinesDir` | Destination for remote-only machines created by `pull`. |
|
|
148
|
+
|
|
149
|
+
Project-wide `push` currently discovers machine-bearing JavaScript and
|
|
150
|
+
TypeScript files configured as `xstate` or `auto`. The config schema accepts
|
|
151
|
+
other format names, but project discovery does not push them.
|
|
152
|
+
|
|
153
|
+
Mutating project commands rewrite legacy configs with one `sources` entry to
|
|
154
|
+
the current top-level shape. `status` and `push --dry-run` normalize legacy
|
|
155
|
+
config in memory without writing it. Multiple legacy entries cannot be merged
|
|
156
|
+
safely and require manual migration.
|
|
157
|
+
|
|
158
|
+
## Commands
|
|
159
|
+
|
|
160
|
+
<!-- command names, arguments, flags, defaults, and behavior from src/cli.ts#COMMANDS -->
|
|
161
|
+
|
|
162
|
+
### `login`
|
|
163
|
+
|
|
164
|
+
Store an OAuth credential or API key.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
statelyai login
|
|
168
|
+
statelyai login --api-key
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Flags: `--api-key`, `--stdin`, `--base-url`.
|
|
172
|
+
|
|
173
|
+
### `logout`
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
statelyai logout
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
`logout` deletes stored credentials. Environment variables are unchanged.
|
|
180
|
+
|
|
181
|
+
### `status`
|
|
182
|
+
|
|
183
|
+
Inspect the configured project and classify local and remote machines:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
statelyai status
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Statuses are `linked`, `local-only`, `remote-only`, and `missing-remote`.
|
|
190
|
+
Use `--json` for automation or `--auth` to show only credential resolution.
|
|
191
|
+
`status` is read-only and never migrates `statelyai.json`.
|
|
192
|
+
|
|
193
|
+
Flags: `--config <path>`, `--base-url <url>`, `--json`, `--auth`.
|
|
194
|
+
|
|
195
|
+
### `init`
|
|
196
|
+
|
|
197
|
+
Create or reuse a Studio project and write `statelyai.json`.
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
statelyai init --name "Checkout" --visibility Private --scan
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Flags:
|
|
204
|
+
|
|
205
|
+
- `--name <name>` sets the remote project name.
|
|
206
|
+
- `--visibility Private|Public|Unlisted` defaults to `Private`.
|
|
207
|
+
- `--scan` proposes source globs interactively.
|
|
208
|
+
- `--force` replaces an existing config.
|
|
209
|
+
- `--base-url <url>` overrides the Studio API origin.
|
|
210
|
+
|
|
211
|
+
### `open`
|
|
212
|
+
|
|
213
|
+
Start a local bridge and open one source file in the browser editor:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
statelyai open src/checkout.machine.ts
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Saved file changes refresh the editor. Saving visual edits writes them back to
|
|
220
|
+
the source file.
|
|
221
|
+
|
|
222
|
+
Flags:
|
|
223
|
+
|
|
224
|
+
- `--editor-url <url>` selects the editor origin. Default:
|
|
225
|
+
`https://editor.stately.ai`.
|
|
226
|
+
- `--host <host>` sets the local bridge host. Default: `127.0.0.1`.
|
|
227
|
+
- `--port <port>` selects a port. Default: a random available port.
|
|
228
|
+
- `--no-open` starts the bridge without launching a browser.
|
|
229
|
+
- `--debug` logs editor protocol messages.
|
|
230
|
+
|
|
231
|
+
### `diff`
|
|
232
|
+
|
|
233
|
+
Compare two locators after normalizing them to graph form:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
statelyai diff src/checkout.machine.ts machine_123 --fail-on-changes
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Locators may be:
|
|
240
|
+
|
|
241
|
+
- a local JavaScript or TypeScript machine file
|
|
242
|
+
- a local XState JSON, Stately graph JSON, or Studio digraph JSON file
|
|
243
|
+
- a Studio machine ID
|
|
244
|
+
- a Studio machine URL
|
|
245
|
+
|
|
246
|
+
`--fail-on-changes` exits with status `1` when the normalized graphs differ.
|
|
247
|
+
Use `--base-url` for remote IDs at another Studio origin. `plan` remains a
|
|
248
|
+
hidden compatibility alias for `diff`.
|
|
249
|
+
|
|
250
|
+
### `push`
|
|
251
|
+
|
|
252
|
+
Push every discovered machine in `statelyai.json`:
|
|
61
253
|
|
|
62
254
|
```bash
|
|
63
255
|
statelyai push
|
|
64
256
|
```
|
|
65
257
|
|
|
66
|
-
|
|
258
|
+
Push one file while still using the project and defaults from the config:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
statelyai push src/checkout.machine.ts
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Preview discovery and link/update decisions without a credential:
|
|
67
265
|
|
|
68
266
|
```bash
|
|
69
267
|
statelyai push --dry-run
|
|
70
268
|
```
|
|
71
269
|
|
|
72
|
-
|
|
270
|
+
`--dry-run` does not create or update machines, write `@statelyai` IDs, or
|
|
271
|
+
migrate legacy configuration.
|
|
272
|
+
|
|
273
|
+
Flags: `--config <path>`, `--base-url <url>`, `--dry-run`.
|
|
274
|
+
|
|
275
|
+
### `pull`
|
|
73
276
|
|
|
74
|
-
|
|
277
|
+
Pull all linked files from the configured project:
|
|
75
278
|
|
|
76
279
|
```bash
|
|
77
280
|
statelyai pull
|
|
78
281
|
```
|
|
79
282
|
|
|
80
|
-
|
|
283
|
+
Pull a linked file using its `@statelyai` ID:
|
|
81
284
|
|
|
82
|
-
|
|
285
|
+
```bash
|
|
286
|
+
statelyai pull src/checkout.machine.ts
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Pull a machine ID or URL to an explicit target:
|
|
83
290
|
|
|
84
291
|
```bash
|
|
85
|
-
|
|
292
|
+
statelyai pull machine_123 src/checkout.machine.ts
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
New targets support JavaScript/TypeScript, `.digraph.json`, and `.graph.json`.
|
|
296
|
+
For existing JSON targets, the current file shape determines the output format.
|
|
297
|
+
|
|
298
|
+
Project-wide pull skips linked files with uncommitted Git changes. Pass
|
|
299
|
+
`--force` to overwrite them. Remote-only machines are skipped until
|
|
300
|
+
`newMachinesDir` is set.
|
|
301
|
+
|
|
302
|
+
Flags: `--config <path>`, `--base-url <url>`, `--force`.
|
|
303
|
+
|
|
304
|
+
## CI examples
|
|
305
|
+
|
|
306
|
+
<!-- noninteractive and exit-code behavior from credential resolution, DiffCommand, and PushCommand -->
|
|
307
|
+
|
|
308
|
+
Fail when a local machine differs from Studio:
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
npx statelyai diff src/checkout.machine.ts machine_123 --fail-on-changes
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Provide `STATELY_API_KEY` or `STATELY_ACCESS_TOKEN` through the CI runner's
|
|
315
|
+
secret environment.
|
|
316
|
+
|
|
317
|
+
Check project discovery without network credentials or writes:
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
npx statelyai push --dry-run
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Set `NO_COLOR=1` or `CI=true` for plain output.
|
|
324
|
+
|
|
325
|
+
## Common problems
|
|
326
|
+
|
|
327
|
+
<!-- error and safeguard behavior from src/cli.ts and src/projectConfig.ts -->
|
|
328
|
+
|
|
329
|
+
- **The server returns `401`:** run `statelyai login`, or set
|
|
330
|
+
`STATELY_ACCESS_TOKEN` or `STATELY_API_KEY`.
|
|
331
|
+
- **`push` finds no files:** check `include` and `exclude`; `init` without
|
|
332
|
+
`--scan` intentionally leaves `include` empty.
|
|
333
|
+
- **`push` matches files but finds no machines:** project discovery currently
|
|
334
|
+
requires XState imports plus `createMachine(...)` or
|
|
335
|
+
`setup(...).createMachine(...)`.
|
|
336
|
+
- **Remote-only machines are skipped:** set `newMachinesDir`, then run
|
|
337
|
+
`statelyai pull` again.
|
|
338
|
+
- **`pull` refuses to overwrite a file:** commit or stash its changes, or pass
|
|
339
|
+
`--force` if overwriting is intentional.
|
|
340
|
+
- **A linked remote machine was deleted or is inaccessible:** interactive
|
|
341
|
+
`push` offers to relink it as a new remote machine and replaces the local ID.
|
|
342
|
+
|
|
343
|
+
Run `statelyai <command> --help` for generated command syntax and flags.
|
|
344
|
+
|
|
345
|
+
## Self-hosting
|
|
346
|
+
|
|
347
|
+
<!-- self-host auth and URL behavior from LoginCommand, baseUrlFlags, OpenCommand, credential resolution, and projectConfig.ts -->
|
|
348
|
+
|
|
349
|
+
Skip login when the server has authentication disabled. The CLI sends no
|
|
350
|
+
authorization header when no credential exists; the server decides whether
|
|
351
|
+
authentication is required. This also applies to `open` editor-sync requests
|
|
352
|
+
and CI commands.
|
|
353
|
+
|
|
354
|
+
For OAuth, point login at the deployment's protected resource:
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
statelyai login --base-url https://editor.example.com/api/mcp
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Passing only an origin uses its `/api/mcp` resource. The resource must
|
|
361
|
+
advertise an authorization server. If that server does not support dynamic
|
|
362
|
+
client registration, set `STATELY_OAUTH_CLIENT_ID`.
|
|
363
|
+
|
|
364
|
+
URL settings are intentionally scoped:
|
|
365
|
+
|
|
366
|
+
| Setting | Used by | Meaning |
|
|
367
|
+
| ------------------ | ---------------------------------------- | ---------------------------------------------------------- |
|
|
368
|
+
| `--base-url` | `init`, `status`, `diff`, `push`, `pull` | Studio API origin. |
|
|
369
|
+
| `studioUrl` | `statelyai.json` project sync | Default Studio API origin for that project. |
|
|
370
|
+
| `login --base-url` | `login` only | OAuth protected-resource URL used for discovery. |
|
|
371
|
+
| `--editor-url` | `open` only | Visual editor origin. Default `https://editor.stately.ai`. |
|
|
372
|
+
|
|
373
|
+
A complete setup may look like:
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
statelyai login --base-url https://editor.example.com/api/mcp
|
|
377
|
+
statelyai init --base-url https://studio.example.com --scan
|
|
378
|
+
statelyai open src/checkout.machine.ts \
|
|
379
|
+
--editor-url https://editor.example.com
|
|
86
380
|
```
|
package/dist/bin.mjs
CHANGED
|
@@ -168,7 +168,13 @@ var RemoteEditorSession = class {
|
|
|
168
168
|
activePanels: []
|
|
169
169
|
});
|
|
170
170
|
} catch (error) {
|
|
171
|
-
|
|
171
|
+
const message = formatError(error, "Failed to initialize the visual editor.");
|
|
172
|
+
this.postMessage({
|
|
173
|
+
type: "@statelyai.error",
|
|
174
|
+
code: "initialization_failed",
|
|
175
|
+
message
|
|
176
|
+
});
|
|
177
|
+
this.showError(message);
|
|
172
178
|
return;
|
|
173
179
|
}
|
|
174
180
|
for (const pending of this.pendingMessages) this.sendMessage(pending);
|
|
@@ -530,6 +536,8 @@ function watchWorkspace(rootDir, listener) {
|
|
|
530
536
|
}
|
|
531
537
|
function getCliWebviewContent(options) {
|
|
532
538
|
const baseUrl = normalizedBaseUrl(options.editorUrl);
|
|
539
|
+
const url = new URL(`${baseUrl}/embed`);
|
|
540
|
+
url.searchParams.set("auth", "message");
|
|
533
541
|
return `<!DOCTYPE html>
|
|
534
542
|
<html lang="en" style="height:100%;margin:0">
|
|
535
543
|
<head>
|
|
@@ -543,7 +551,7 @@ function getCliWebviewContent(options) {
|
|
|
543
551
|
<body>
|
|
544
552
|
<iframe
|
|
545
553
|
id="stately-editor"
|
|
546
|
-
src="${escapeAttribute(
|
|
554
|
+
src="${escapeAttribute(url.toString())}"
|
|
547
555
|
allow="clipboard-read; clipboard-write"
|
|
548
556
|
></iframe>
|
|
549
557
|
<script>
|
|
@@ -832,13 +840,10 @@ async function writeFileCredentials(apiKey) {
|
|
|
832
840
|
location: stored.location
|
|
833
841
|
};
|
|
834
842
|
}
|
|
835
|
-
async function writeFileStoredCredential(credential
|
|
843
|
+
async function writeFileStoredCredential(credential) {
|
|
836
844
|
const configDir = getConfigDir();
|
|
837
845
|
const credentialsPath = getCredentialsFilePath();
|
|
838
|
-
const payload =
|
|
839
|
-
version: 1,
|
|
840
|
-
authMode: "none"
|
|
841
|
-
} : {
|
|
846
|
+
const payload = {
|
|
842
847
|
version: 1,
|
|
843
848
|
credential
|
|
844
849
|
};
|
|
@@ -853,7 +858,6 @@ async function writeFileStoredCredential(credential, authMode) {
|
|
|
853
858
|
await promises.chmod(credentialsPath, 384);
|
|
854
859
|
return {
|
|
855
860
|
...credential ? { credential } : {},
|
|
856
|
-
...authMode ? { authMode } : {},
|
|
857
861
|
backend: "file",
|
|
858
862
|
location: credentialsPath
|
|
859
863
|
};
|
|
@@ -893,12 +897,9 @@ async function writeMacOSKeychain(apiKey) {
|
|
|
893
897
|
location: stored.location
|
|
894
898
|
} : void 0;
|
|
895
899
|
}
|
|
896
|
-
async function writeMacOSStoredCredential(credential
|
|
900
|
+
async function writeMacOSStoredCredential(credential) {
|
|
897
901
|
if (process.platform !== "darwin") return;
|
|
898
|
-
const payload =
|
|
899
|
-
version: 1,
|
|
900
|
-
authMode: "none"
|
|
901
|
-
} : {
|
|
902
|
+
const payload = {
|
|
902
903
|
version: 1,
|
|
903
904
|
credential
|
|
904
905
|
};
|
|
@@ -915,7 +916,6 @@ async function writeMacOSStoredCredential(credential, authMode) {
|
|
|
915
916
|
]);
|
|
916
917
|
return {
|
|
917
918
|
...credential ? { credential } : {},
|
|
918
|
-
...authMode ? { authMode } : {},
|
|
919
919
|
backend: "macos-keychain",
|
|
920
920
|
location: "macOS Keychain"
|
|
921
921
|
};
|
|
@@ -964,12 +964,9 @@ async function writeLinuxSecretTool(apiKey) {
|
|
|
964
964
|
location: stored.location
|
|
965
965
|
} : void 0;
|
|
966
966
|
}
|
|
967
|
-
async function writeLinuxStoredCredential(credential
|
|
967
|
+
async function writeLinuxStoredCredential(credential) {
|
|
968
968
|
if (process.platform !== "linux") return;
|
|
969
|
-
const payload =
|
|
970
|
-
version: 1,
|
|
971
|
-
authMode: "none"
|
|
972
|
-
} : {
|
|
969
|
+
const payload = {
|
|
973
970
|
version: 1,
|
|
974
971
|
credential
|
|
975
972
|
};
|
|
@@ -985,7 +982,6 @@ async function writeLinuxStoredCredential(credential, authMode) {
|
|
|
985
982
|
], { input: JSON.stringify(payload) });
|
|
986
983
|
return {
|
|
987
984
|
...credential ? { credential } : {},
|
|
988
|
-
...authMode ? { authMode } : {},
|
|
989
985
|
backend: "linux-secret-tool",
|
|
990
986
|
location: "Secret Service (secret-tool)"
|
|
991
987
|
};
|
|
@@ -1020,10 +1016,6 @@ async function setStoredCredential(credential) {
|
|
|
1020
1016
|
if (shouldUseFileBackendOnly()) return writeFileStoredCredential(credential);
|
|
1021
1017
|
return await writeMacOSStoredCredential(credential) ?? await writeLinuxStoredCredential(credential) ?? await writeFileStoredCredential(credential);
|
|
1022
1018
|
}
|
|
1023
|
-
async function setStoredNoAuth() {
|
|
1024
|
-
if (shouldUseFileBackendOnly()) return writeFileStoredCredential(void 0, "none");
|
|
1025
|
-
return await writeMacOSStoredCredential(void 0, "none") ?? await writeLinuxStoredCredential(void 0, "none") ?? await writeFileStoredCredential(void 0, "none");
|
|
1026
|
-
}
|
|
1027
1019
|
async function deleteStoredApiKey() {
|
|
1028
1020
|
if (shouldUseFileBackendOnly()) {
|
|
1029
1021
|
const deleted = await deleteFileCredentials();
|
|
@@ -1678,9 +1670,6 @@ function formatMissingNewMachineDirMessage(options) {
|
|
|
1678
1670
|
function toMachineFileStem(machineName) {
|
|
1679
1671
|
return (typeof machineName === "string" ? machineName : "").trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^A-Za-z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "machine";
|
|
1680
1672
|
}
|
|
1681
|
-
function getMissingCredentialMessage() {
|
|
1682
|
-
return `No Stately credential configured. Run \`statelyai login\`, set \`STATELY_ACCESS_TOKEN\`, or set \`STATELY_API_KEY\`.\nGet or create an API key at ${STATELY_API_KEY_SETTINGS_URL}`;
|
|
1683
|
-
}
|
|
1684
1673
|
function buildProjectEditorUrl(studioUrl, projectId) {
|
|
1685
1674
|
return `${studioUrl.replace(/\/+$/, "")}/registry/editor/${encodeURIComponent(projectId)}`;
|
|
1686
1675
|
}
|
|
@@ -1896,7 +1885,7 @@ async function resolveConfiguredProject(options) {
|
|
|
1896
1885
|
const { config, configPath, rootDir, rewriteStatus } = await readStatelyProjectConfig({
|
|
1897
1886
|
cwd: options.cwd,
|
|
1898
1887
|
configPath: options.configPath,
|
|
1899
|
-
rewriteIfNeeded: true
|
|
1888
|
+
rewriteIfNeeded: options.rewriteIfNeeded ?? true
|
|
1900
1889
|
});
|
|
1901
1890
|
const studioUrl = options.baseUrl ?? config.studioUrl;
|
|
1902
1891
|
return {
|
|
@@ -1942,13 +1931,102 @@ async function resolveConfiguredPullTargets(options) {
|
|
|
1942
1931
|
rewriteStatus
|
|
1943
1932
|
};
|
|
1944
1933
|
}
|
|
1945
|
-
|
|
1934
|
+
async function resolveCredentialStatus() {
|
|
1935
|
+
const envCredential = getEnvCredential();
|
|
1936
|
+
if (envCredential) return {
|
|
1937
|
+
detail: envCredential.variable,
|
|
1938
|
+
source: "environment",
|
|
1939
|
+
type: envCredential.credential.type
|
|
1940
|
+
};
|
|
1941
|
+
const storedCredential = await getStoredCredential();
|
|
1942
|
+
if (storedCredential?.credential) return {
|
|
1943
|
+
detail: describeCredentialBackend(storedCredential.backend, storedCredential.location),
|
|
1944
|
+
source: "stored",
|
|
1945
|
+
type: storedCredential.credential.type
|
|
1946
|
+
};
|
|
1947
|
+
return {
|
|
1948
|
+
detail: "server decides whether authentication is required",
|
|
1949
|
+
source: "none",
|
|
1950
|
+
type: "none"
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1953
|
+
function getProjectMachineId(machine) {
|
|
1954
|
+
const candidate = machine;
|
|
1955
|
+
return candidate.machineId || candidate.id;
|
|
1956
|
+
}
|
|
1957
|
+
function formatCredentialStatus(status) {
|
|
1958
|
+
return status.type === "none" ? `Auth: none (${status.detail})` : `Auth: ${status.type} from ${status.source} (${status.detail})`;
|
|
1959
|
+
}
|
|
1960
|
+
async function resolveProjectStatus(options = {}) {
|
|
1961
|
+
const { client, config, configPath, files } = await resolveConfiguredProject({
|
|
1962
|
+
...options,
|
|
1963
|
+
rewriteIfNeeded: false
|
|
1964
|
+
});
|
|
1965
|
+
const project = await client.projects.get(config.projectId);
|
|
1966
|
+
const { machineFiles } = await classifyPushCandidates(files.filter(supportsMachineDiscovery));
|
|
1967
|
+
const linkedTargets = await discoverLinkedPullTargets(machineFiles);
|
|
1968
|
+
const linkedByPath = new Map(linkedTargets.map((target) => [target.file.filePath, target]));
|
|
1969
|
+
const remoteById = new Map(project.machines.flatMap((machine) => {
|
|
1970
|
+
const id = getProjectMachineId(machine);
|
|
1971
|
+
return id ? [[id, machine]] : [];
|
|
1972
|
+
}));
|
|
1973
|
+
const linkedIds = new Set(linkedTargets.map((target) => target.machineId));
|
|
1974
|
+
const studioUrl = options.baseUrl ?? config.studioUrl;
|
|
1975
|
+
const machines = machineFiles.map((file) => {
|
|
1976
|
+
const linked = linkedByPath.get(file.filePath);
|
|
1977
|
+
if (!linked) return {
|
|
1978
|
+
name: path.basename(file.relativePath),
|
|
1979
|
+
path: file.relativePath,
|
|
1980
|
+
status: "local-only"
|
|
1981
|
+
};
|
|
1982
|
+
const remote = remoteById.get(linked.machineId);
|
|
1983
|
+
return {
|
|
1984
|
+
id: linked.machineId,
|
|
1985
|
+
name: remote?.name || path.basename(file.relativePath),
|
|
1986
|
+
path: file.relativePath,
|
|
1987
|
+
status: remote ? "linked" : "missing-remote",
|
|
1988
|
+
url: buildMachineEditorUrl(studioUrl, config.projectId, linked.machineId)
|
|
1989
|
+
};
|
|
1990
|
+
});
|
|
1991
|
+
for (const remote of project.machines) {
|
|
1992
|
+
const id = getProjectMachineId(remote);
|
|
1993
|
+
if (!id || linkedIds.has(id)) continue;
|
|
1994
|
+
machines.push({
|
|
1995
|
+
id,
|
|
1996
|
+
name: remote.name || id,
|
|
1997
|
+
status: "remote-only",
|
|
1998
|
+
url: buildMachineEditorUrl(studioUrl, config.projectId, id)
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
machines.sort((left, right) => left.status.localeCompare(right.status) || left.name.localeCompare(right.name));
|
|
2002
|
+
return {
|
|
2003
|
+
auth: await resolveCredentialStatus(),
|
|
2004
|
+
configPath,
|
|
2005
|
+
counts: {
|
|
2006
|
+
linked: machines.filter((machine) => machine.status === "linked").length,
|
|
2007
|
+
"local-only": machines.filter((machine) => machine.status === "local-only").length,
|
|
2008
|
+
"missing-remote": machines.filter((machine) => machine.status === "missing-remote").length,
|
|
2009
|
+
"remote-only": machines.filter((machine) => machine.status === "remote-only").length
|
|
2010
|
+
},
|
|
2011
|
+
machines,
|
|
2012
|
+
project: {
|
|
2013
|
+
id: config.projectId,
|
|
2014
|
+
...project.name ? { name: project.name } : {},
|
|
2015
|
+
url: buildProjectEditorUrl(studioUrl, config.projectId)
|
|
2016
|
+
},
|
|
2017
|
+
studioUrl
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
const baseUrlFlags = {
|
|
1946
2021
|
help: Flags.help({ char: "h" }),
|
|
2022
|
+
"base-url": Flags.string({ description: "Base URL for Stately Studio or a self-hosted deployment" })
|
|
2023
|
+
};
|
|
2024
|
+
const sharedFlags = {
|
|
2025
|
+
...baseUrlFlags,
|
|
1947
2026
|
"fail-on-changes": Flags.boolean({
|
|
1948
2027
|
default: false,
|
|
1949
2028
|
description: "Exit with a nonzero code when differences are found"
|
|
1950
|
-
})
|
|
1951
|
-
"base-url": Flags.string({ description: "Base URL for Stately Studio or a self-hosted deployment" })
|
|
2029
|
+
})
|
|
1952
2030
|
};
|
|
1953
2031
|
function formatChangeList(label, items) {
|
|
1954
2032
|
if (items.length === 0) return null;
|
|
@@ -1996,19 +2074,22 @@ var ParsedSyncCommand = class extends BaseSyncCommand {
|
|
|
1996
2074
|
return this.parse(command);
|
|
1997
2075
|
}
|
|
1998
2076
|
};
|
|
2077
|
+
async function createSemanticDiff(source, target, baseUrl) {
|
|
2078
|
+
return planSync({
|
|
2079
|
+
source,
|
|
2080
|
+
target,
|
|
2081
|
+
apiKey: (await resolveApiKey()).apiKey,
|
|
2082
|
+
baseUrl: baseUrl ?? getDefaultBaseUrl()
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
1999
2085
|
var PlanCommand = class PlanCommand extends ParsedSyncCommand {
|
|
2086
|
+
static hidden = true;
|
|
2000
2087
|
static summary = "Plan semantic sync changes between a source and target.";
|
|
2001
2088
|
static description = "Resolves the source and target, normalizes both into graph form, and prints a semantic change summary.";
|
|
2002
2089
|
static args = sharedArgs;
|
|
2003
2090
|
async run() {
|
|
2004
2091
|
const { args, flags } = await this.parseSync(PlanCommand);
|
|
2005
|
-
const
|
|
2006
|
-
const plan = await planSync({
|
|
2007
|
-
source: args.source,
|
|
2008
|
-
target: args.target,
|
|
2009
|
-
apiKey,
|
|
2010
|
-
baseUrl: flags["base-url"] ?? getDefaultBaseUrl()
|
|
2011
|
-
});
|
|
2092
|
+
const plan = await createSemanticDiff(args.source, args.target, flags["base-url"]);
|
|
2012
2093
|
this.log(formatPlanSummary(plan));
|
|
2013
2094
|
this.exit(flags["fail-on-changes"] && plan.summary.hasChanges ? 1 : 0);
|
|
2014
2095
|
}
|
|
@@ -2019,13 +2100,7 @@ var DiffCommand = class DiffCommand extends ParsedSyncCommand {
|
|
|
2019
2100
|
static args = sharedArgs;
|
|
2020
2101
|
async run() {
|
|
2021
2102
|
const { args, flags } = await this.parseSync(DiffCommand);
|
|
2022
|
-
const
|
|
2023
|
-
const plan = await planSync({
|
|
2024
|
-
source: args.source,
|
|
2025
|
-
target: args.target,
|
|
2026
|
-
apiKey,
|
|
2027
|
-
baseUrl: flags["base-url"] ?? getDefaultBaseUrl()
|
|
2028
|
-
});
|
|
2103
|
+
const plan = await createSemanticDiff(args.source, args.target, flags["base-url"]);
|
|
2029
2104
|
this.log(formatPlanSummary(plan));
|
|
2030
2105
|
this.exit(flags["fail-on-changes"] && plan.summary.hasChanges ? 1 : 0);
|
|
2031
2106
|
}
|
|
@@ -2034,7 +2109,7 @@ var PullCommand = class PullCommand extends ParsedSyncCommand {
|
|
|
2034
2109
|
static summary = "Pull a source locator into a local target file.";
|
|
2035
2110
|
static description = "Resolves the source, materializes it in the target format inferred from the target file, and writes the result locally. With no arguments, pulls all linked files discovered from statelyai.json.";
|
|
2036
2111
|
static flags = {
|
|
2037
|
-
...
|
|
2112
|
+
...baseUrlFlags,
|
|
2038
2113
|
config: Flags.string({ description: "Path to statelyai.json" }),
|
|
2039
2114
|
force: Flags.boolean({
|
|
2040
2115
|
description: "Overwrite linked files even when they have local git changes",
|
|
@@ -2055,7 +2130,6 @@ var PullCommand = class PullCommand extends ParsedSyncCommand {
|
|
|
2055
2130
|
const { args, flags } = await this.parseSync(PullCommand);
|
|
2056
2131
|
const apiKey = (await resolveApiKey()).apiKey;
|
|
2057
2132
|
if (!args.source) {
|
|
2058
|
-
if (!apiKey) this.error(getMissingCredentialMessage());
|
|
2059
2133
|
this.log(colorize("Resolving configured project and linked source files...", ANSI_CYAN));
|
|
2060
2134
|
const { config, linkedTargets, project, remoteOnlyTargets, skipped, rewriteStatus } = await resolveConfiguredPullTargets({
|
|
2061
2135
|
apiKey,
|
|
@@ -2134,7 +2208,6 @@ var PullCommand = class PullCommand extends ParsedSyncCommand {
|
|
|
2134
2208
|
target = localCandidate;
|
|
2135
2209
|
}
|
|
2136
2210
|
if (!target) this.error("Missing target path. Pass `statelyai pull <machine-id|url> <file>` or `statelyai pull <linked-file>`.");
|
|
2137
|
-
if (!apiKey) this.error(getMissingCredentialMessage());
|
|
2138
2211
|
if (!flags.force && await fileExists(target) && await isFileGitDirty(target)) this.error(`Refusing to overwrite locally modified file ${target}. Pass --force to overwrite it.`);
|
|
2139
2212
|
this.log(colorize(`Pulling ${source} into ${target}...`, ANSI_CYAN));
|
|
2140
2213
|
const result = await pullSync({
|
|
@@ -2166,12 +2239,11 @@ var PushCommand = class PushCommand extends Command {
|
|
|
2166
2239
|
async run() {
|
|
2167
2240
|
const { args, flags } = await this.parse(PushCommand);
|
|
2168
2241
|
const resolvedApiKey = flags["dry-run"] ? { source: "missing" } : await resolveApiKey();
|
|
2169
|
-
if (!flags["dry-run"] && !resolvedApiKey.apiKey) this.error(getMissingCredentialMessage());
|
|
2170
2242
|
this.log(colorize("Resolving configured project and source files...", ANSI_CYAN));
|
|
2171
2243
|
const { client, config, files, rewriteStatus } = flags["dry-run"] ? await (async () => {
|
|
2172
2244
|
const { config, rootDir, rewriteStatus } = await readStatelyProjectConfig({
|
|
2173
2245
|
configPath: flags.config,
|
|
2174
|
-
rewriteIfNeeded:
|
|
2246
|
+
rewriteIfNeeded: false
|
|
2175
2247
|
});
|
|
2176
2248
|
return {
|
|
2177
2249
|
client: void 0,
|
|
@@ -2304,7 +2376,6 @@ var OpenCommand = class OpenCommand extends Command {
|
|
|
2304
2376
|
async run() {
|
|
2305
2377
|
const { args, flags } = await this.parse(OpenCommand);
|
|
2306
2378
|
const apiKey = (await resolveApiKey()).apiKey;
|
|
2307
|
-
if (!apiKey) throw new Error("No Stately credential configured. Run `statelyai login` and retry.");
|
|
2308
2379
|
await openEditor({
|
|
2309
2380
|
fileName: path.resolve(args.file),
|
|
2310
2381
|
editorUrl: flags["editor-url"] ?? getDefaultEditorUrl(),
|
|
@@ -2345,7 +2416,6 @@ var InitCommand = class InitCommand extends Command {
|
|
|
2345
2416
|
async run() {
|
|
2346
2417
|
const { flags } = await this.parse(InitCommand);
|
|
2347
2418
|
const resolvedApiKey = await resolveApiKey();
|
|
2348
|
-
if (!resolvedApiKey.apiKey) this.error(getMissingCredentialMessage());
|
|
2349
2419
|
this.log("Creating or reusing remote project...");
|
|
2350
2420
|
const result = await initProject({
|
|
2351
2421
|
apiKey: resolvedApiKey.apiKey,
|
|
@@ -2397,21 +2467,10 @@ var LoginCommand = class LoginCommand extends Command {
|
|
|
2397
2467
|
stdin: Flags.boolean({
|
|
2398
2468
|
description: "Read the API key from standard input",
|
|
2399
2469
|
default: false
|
|
2400
|
-
}),
|
|
2401
|
-
auth: Flags.string({
|
|
2402
|
-
description: "Authentication mode for the target server",
|
|
2403
|
-
options: ["none", "bearer"]
|
|
2404
2470
|
})
|
|
2405
2471
|
};
|
|
2406
2472
|
async run() {
|
|
2407
2473
|
const { flags } = await this.parse(LoginCommand);
|
|
2408
|
-
if ((flags["api-key"] || flags.stdin) && flags.auth === "bearer") this.error("Pass either --auth bearer or API-key login flags, not both.");
|
|
2409
|
-
if (flags.auth === "none") {
|
|
2410
|
-
if (flags.stdin || flags["api-key"]) this.error("Pass either --auth none or an API key, not both.");
|
|
2411
|
-
const stored = await setStoredNoAuth();
|
|
2412
|
-
this.log(`Stored no-auth mode in ${describeCredentialBackend(stored.backend, stored.location)}.`);
|
|
2413
|
-
return;
|
|
2414
|
-
}
|
|
2415
2474
|
if (!flags["api-key"] && !flags.stdin) {
|
|
2416
2475
|
const stored = await runOAuthBrowserLogin({
|
|
2417
2476
|
baseUrl: flags["base-url"],
|
|
@@ -2441,29 +2500,64 @@ var LogoutCommand = class extends Command {
|
|
|
2441
2500
|
this.log(`Removed stored credential from ${result.locations.join(", ")}.`);
|
|
2442
2501
|
}
|
|
2443
2502
|
};
|
|
2503
|
+
function formatProjectStatus(result) {
|
|
2504
|
+
const lines = [
|
|
2505
|
+
formatCredentialStatus(result.auth),
|
|
2506
|
+
`Project: ${result.project.name ? `${result.project.name} ` : ""}(${result.project.id})`,
|
|
2507
|
+
`Studio: ${result.project.url}`,
|
|
2508
|
+
`Config: ${result.configPath}`,
|
|
2509
|
+
`Machines: ${result.machines.length} (${result.counts.linked} linked, ${result.counts["local-only"]} local-only, ${result.counts["remote-only"]} remote-only, ${result.counts["missing-remote"]} missing-remote)`
|
|
2510
|
+
];
|
|
2511
|
+
for (const machine of result.machines) {
|
|
2512
|
+
const details = [machine.id, machine.path].filter(Boolean).join(" ");
|
|
2513
|
+
lines.push(` [${machine.status}] ${machine.name}${details ? ` ${details}` : ""}`);
|
|
2514
|
+
}
|
|
2515
|
+
const next = [];
|
|
2516
|
+
if (result.counts["local-only"] > 0 || result.counts["missing-remote"] > 0) next.push("statelyai push");
|
|
2517
|
+
if (result.counts["remote-only"] > 0) next.push("statelyai pull");
|
|
2518
|
+
if (next.length > 0) lines.push(`Next: ${next.join(", ")}`);
|
|
2519
|
+
return lines.join("\n");
|
|
2520
|
+
}
|
|
2521
|
+
var StatusCommand = class StatusCommand extends Command {
|
|
2522
|
+
static enableJsonFlag = false;
|
|
2523
|
+
static summary = "Show project, machine, and authentication status.";
|
|
2524
|
+
static description = "Reads statelyai.json and Studio project metadata, then classifies configured machine files as linked, local-only, remote-only, or missing remotely.";
|
|
2525
|
+
static flags = {
|
|
2526
|
+
...baseUrlFlags,
|
|
2527
|
+
auth: Flags.boolean({
|
|
2528
|
+
description: "Show only credential resolution",
|
|
2529
|
+
default: false
|
|
2530
|
+
}),
|
|
2531
|
+
config: Flags.string({ description: "Path to statelyai.json" }),
|
|
2532
|
+
json: Flags.boolean({
|
|
2533
|
+
description: "Print machine-readable JSON",
|
|
2534
|
+
default: false
|
|
2535
|
+
})
|
|
2536
|
+
};
|
|
2537
|
+
async run() {
|
|
2538
|
+
const { flags } = await this.parse(StatusCommand);
|
|
2539
|
+
if (flags.auth) {
|
|
2540
|
+
const auth = await resolveCredentialStatus();
|
|
2541
|
+
this.log(flags.json ? JSON.stringify({ auth }, null, 2) : formatCredentialStatus(auth));
|
|
2542
|
+
return;
|
|
2543
|
+
}
|
|
2544
|
+
const apiKey = (await resolveApiKey()).apiKey;
|
|
2545
|
+
const result = await resolveProjectStatus({
|
|
2546
|
+
apiKey,
|
|
2547
|
+
baseUrl: flags["base-url"],
|
|
2548
|
+
configPath: flags.config
|
|
2549
|
+
});
|
|
2550
|
+
this.log(flags.json ? JSON.stringify(result, null, 2) : formatProjectStatus(result));
|
|
2551
|
+
}
|
|
2552
|
+
};
|
|
2444
2553
|
var WhoamiCommand = class extends Command {
|
|
2554
|
+
static hidden = true;
|
|
2445
2555
|
static enableJsonFlag = false;
|
|
2446
2556
|
static summary = "Show how the CLI would resolve credentials.";
|
|
2447
2557
|
static description = "Reports whether the CLI would use an environment variable or stored credential.";
|
|
2448
2558
|
static flags = { help: Flags.help({ char: "h" }) };
|
|
2449
2559
|
async run() {
|
|
2450
|
-
|
|
2451
|
-
const storedCredential = await getStoredCredential();
|
|
2452
|
-
const storedApiKey = storedCredential?.credential?.type === "api_key" ? {
|
|
2453
|
-
apiKey: storedCredential.credential.token,
|
|
2454
|
-
backend: storedCredential.backend,
|
|
2455
|
-
location: storedCredential.location
|
|
2456
|
-
} : void 0;
|
|
2457
|
-
if (envCredential) {
|
|
2458
|
-
this.log(`Credential source: environment ${envCredential.credential.type} (${envCredential.variable}).`);
|
|
2459
|
-
if (storedApiKey) this.log(`Stored credential also available in ${describeCredentialBackend(storedApiKey.backend, storedApiKey.location)}.`);
|
|
2460
|
-
return;
|
|
2461
|
-
}
|
|
2462
|
-
if (storedCredential) {
|
|
2463
|
-
this.log(formatStoredCredentialSource(storedCredential));
|
|
2464
|
-
return;
|
|
2465
|
-
}
|
|
2466
|
-
this.log(getMissingCredentialMessage());
|
|
2560
|
+
this.log(formatCredentialStatus(await resolveCredentialStatus()));
|
|
2467
2561
|
}
|
|
2468
2562
|
};
|
|
2469
2563
|
const COMMANDS = {
|
|
@@ -2472,6 +2566,7 @@ const COMMANDS = {
|
|
|
2472
2566
|
pull: PullCommand,
|
|
2473
2567
|
push: PushCommand,
|
|
2474
2568
|
open: OpenCommand,
|
|
2569
|
+
status: StatusCommand,
|
|
2475
2570
|
init: InitCommand,
|
|
2476
2571
|
login: LoginCommand,
|
|
2477
2572
|
logout: LogoutCommand,
|
|
@@ -2499,4 +2594,4 @@ function isDirectExecution() {
|
|
|
2499
2594
|
if (isDirectExecution()) run$1();
|
|
2500
2595
|
|
|
2501
2596
|
//#endregion
|
|
2502
|
-
export {
|
|
2597
|
+
export { createStatelyProjectConfig as S, resolveConfiguredPullTargets as _, discoverOAuthLogin as a, run$1 as b, formatPlanSummary as c, getEnvApiKey as d, getEnvCredential as f, resolveApiKey as g, isFileGitDirty as h, discoverLinkedPullTargets as i, formatProjectStatus as l, initProject as m, buildOAuthLoginStart as n, discoverRemoteProjectMachineTargets as o, inferInitProjectName as p, classifyPushCandidates as r, formatMissingNewMachineDirMessage as s, COMMANDS as t, formatStoredCredentialSource as u, resolveCredentialStatus as v, scanProjectSources as x, resolveProjectStatus as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -51,7 +51,7 @@ declare function createStatelyProjectConfig(options: {
|
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/cli.d.ts
|
|
53
53
|
interface InitProjectOptions {
|
|
54
|
-
apiKey
|
|
54
|
+
apiKey?: string;
|
|
55
55
|
baseUrl?: string;
|
|
56
56
|
cwd?: string;
|
|
57
57
|
client?: StudioClient;
|
|
@@ -97,6 +97,31 @@ interface ResolvedConfiguredPullTargets {
|
|
|
97
97
|
reason?: string;
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
+
type ProjectMachineStatus = 'linked' | 'local-only' | 'missing-remote' | 'remote-only';
|
|
101
|
+
interface ProjectStatusMachine {
|
|
102
|
+
id?: string;
|
|
103
|
+
name: string;
|
|
104
|
+
path?: string;
|
|
105
|
+
status: ProjectMachineStatus;
|
|
106
|
+
url?: string;
|
|
107
|
+
}
|
|
108
|
+
interface CredentialStatus {
|
|
109
|
+
detail: string;
|
|
110
|
+
source: 'environment' | 'none' | 'stored';
|
|
111
|
+
type: 'api_key' | 'none' | 'oauth';
|
|
112
|
+
}
|
|
113
|
+
interface ProjectStatusResult {
|
|
114
|
+
auth: CredentialStatus;
|
|
115
|
+
configPath: string;
|
|
116
|
+
counts: Record<ProjectMachineStatus, number>;
|
|
117
|
+
machines: ProjectStatusMachine[];
|
|
118
|
+
project: {
|
|
119
|
+
id: string;
|
|
120
|
+
name?: string;
|
|
121
|
+
url: string;
|
|
122
|
+
};
|
|
123
|
+
studioUrl: string;
|
|
124
|
+
}
|
|
100
125
|
type ApiKeyResolution = {
|
|
101
126
|
apiKey: string;
|
|
102
127
|
detail: string;
|
|
@@ -162,23 +187,31 @@ declare function classifyPushCandidates(files: DiscoveredSourceFile[]): Promise<
|
|
|
162
187
|
declare function resolveConfiguredPullTargets(options: {
|
|
163
188
|
cwd?: string;
|
|
164
189
|
configPath?: string;
|
|
165
|
-
apiKey
|
|
190
|
+
apiKey?: string;
|
|
166
191
|
baseUrl?: string;
|
|
167
192
|
client?: StudioClient;
|
|
168
193
|
}): Promise<ResolvedConfiguredPullTargets>;
|
|
194
|
+
declare function resolveCredentialStatus(): Promise<CredentialStatus>;
|
|
195
|
+
declare function resolveProjectStatus(options?: {
|
|
196
|
+
apiKey?: string;
|
|
197
|
+
baseUrl?: string;
|
|
198
|
+
client?: StudioClient;
|
|
199
|
+
configPath?: string;
|
|
200
|
+
cwd?: string;
|
|
201
|
+
}): Promise<ProjectStatusResult>;
|
|
169
202
|
declare function formatPlanSummary(plan: SyncPlan): string;
|
|
170
203
|
declare abstract class BaseSyncCommand extends Command {
|
|
171
204
|
static enableJsonFlag: boolean;
|
|
172
205
|
static flags: {
|
|
173
|
-
help: _oclif_core_interfaces0.BooleanFlag<void>;
|
|
174
206
|
'fail-on-changes': _oclif_core_interfaces0.BooleanFlag<boolean>;
|
|
207
|
+
help: _oclif_core_interfaces0.BooleanFlag<void>;
|
|
175
208
|
'base-url': _oclif_core_interfaces0.OptionFlag<string | undefined, _oclif_core_interfaces0.CustomOptions>;
|
|
176
209
|
};
|
|
177
210
|
}
|
|
178
211
|
declare abstract class ParsedSyncCommand extends BaseSyncCommand {
|
|
179
212
|
protected parseSync<T extends typeof BaseSyncCommand>(command: T): Promise<_oclif_core_interfaces0.ParserOutput<{
|
|
180
|
-
help: void;
|
|
181
213
|
'fail-on-changes': boolean;
|
|
214
|
+
help: void;
|
|
182
215
|
'base-url': string | undefined;
|
|
183
216
|
}, {
|
|
184
217
|
[flag: string]: any;
|
|
@@ -187,6 +220,7 @@ declare abstract class ParsedSyncCommand extends BaseSyncCommand {
|
|
|
187
220
|
}>>;
|
|
188
221
|
}
|
|
189
222
|
declare class PlanCommand extends ParsedSyncCommand {
|
|
223
|
+
static hidden: boolean;
|
|
190
224
|
static summary: string;
|
|
191
225
|
static description: string;
|
|
192
226
|
static args: {
|
|
@@ -211,7 +245,6 @@ declare class PullCommand extends ParsedSyncCommand {
|
|
|
211
245
|
config: _oclif_core_interfaces0.OptionFlag<string | undefined, _oclif_core_interfaces0.CustomOptions>;
|
|
212
246
|
force: _oclif_core_interfaces0.BooleanFlag<boolean>;
|
|
213
247
|
help: _oclif_core_interfaces0.BooleanFlag<void>;
|
|
214
|
-
'fail-on-changes': _oclif_core_interfaces0.BooleanFlag<boolean>;
|
|
215
248
|
'base-url': _oclif_core_interfaces0.OptionFlag<string | undefined, _oclif_core_interfaces0.CustomOptions>;
|
|
216
249
|
};
|
|
217
250
|
static args: {
|
|
@@ -275,7 +308,6 @@ declare class LoginCommand extends Command {
|
|
|
275
308
|
'api-key': _oclif_core_interfaces0.BooleanFlag<boolean>;
|
|
276
309
|
'base-url': _oclif_core_interfaces0.OptionFlag<string | undefined, _oclif_core_interfaces0.CustomOptions>;
|
|
277
310
|
stdin: _oclif_core_interfaces0.BooleanFlag<boolean>;
|
|
278
|
-
auth: _oclif_core_interfaces0.OptionFlag<string | undefined, _oclif_core_interfaces0.CustomOptions>;
|
|
279
311
|
};
|
|
280
312
|
run(): Promise<void>;
|
|
281
313
|
}
|
|
@@ -288,7 +320,22 @@ declare class LogoutCommand extends Command {
|
|
|
288
320
|
};
|
|
289
321
|
run(): Promise<void>;
|
|
290
322
|
}
|
|
323
|
+
declare function formatProjectStatus(result: ProjectStatusResult): string;
|
|
324
|
+
declare class StatusCommand extends Command {
|
|
325
|
+
static enableJsonFlag: boolean;
|
|
326
|
+
static summary: string;
|
|
327
|
+
static description: string;
|
|
328
|
+
static flags: {
|
|
329
|
+
auth: _oclif_core_interfaces0.BooleanFlag<boolean>;
|
|
330
|
+
config: _oclif_core_interfaces0.OptionFlag<string | undefined, _oclif_core_interfaces0.CustomOptions>;
|
|
331
|
+
json: _oclif_core_interfaces0.BooleanFlag<boolean>;
|
|
332
|
+
help: _oclif_core_interfaces0.BooleanFlag<void>;
|
|
333
|
+
'base-url': _oclif_core_interfaces0.OptionFlag<string | undefined, _oclif_core_interfaces0.CustomOptions>;
|
|
334
|
+
};
|
|
335
|
+
run(): Promise<void>;
|
|
336
|
+
}
|
|
291
337
|
declare class WhoamiCommand extends Command {
|
|
338
|
+
static hidden: boolean;
|
|
292
339
|
static enableJsonFlag: boolean;
|
|
293
340
|
static summary: string;
|
|
294
341
|
static description: string;
|
|
@@ -303,6 +350,7 @@ declare const COMMANDS: {
|
|
|
303
350
|
pull: typeof PullCommand;
|
|
304
351
|
push: typeof PushCommand;
|
|
305
352
|
open: typeof OpenCommand;
|
|
353
|
+
status: typeof StatusCommand;
|
|
306
354
|
init: typeof InitCommand;
|
|
307
355
|
login: typeof LoginCommand;
|
|
308
356
|
logout: typeof LogoutCommand;
|
|
@@ -310,4 +358,4 @@ declare const COMMANDS: {
|
|
|
310
358
|
};
|
|
311
359
|
declare function run(argv?: any, entryUrl?: string): Promise<void>;
|
|
312
360
|
//#endregion
|
|
313
|
-
export { ApiKeyResolution, COMMANDS, InitProjectOptions, InitProjectResult, LinkedPullTarget, OAuthLoginDiscovery, PushCandidateClassification, RemoteProjectMachineTarget, ResolvedConfiguredPullTargets, ScanProjectSourcesOptions, buildOAuthLoginStart, classifyPushCandidates, createStatelyProjectConfig, discoverLinkedPullTargets, discoverOAuthLogin, discoverRemoteProjectMachineTargets, formatMissingNewMachineDirMessage, formatPlanSummary, formatStoredCredentialSource, getEnvApiKey, getEnvCredential, inferInitProjectName, initProject, isFileGitDirty, resolveApiKey, resolveConfiguredPullTargets, run, scanProjectSources };
|
|
361
|
+
export { ApiKeyResolution, COMMANDS, CredentialStatus, InitProjectOptions, InitProjectResult, LinkedPullTarget, OAuthLoginDiscovery, ProjectMachineStatus, ProjectStatusMachine, ProjectStatusResult, PushCandidateClassification, RemoteProjectMachineTarget, ResolvedConfiguredPullTargets, ScanProjectSourcesOptions, buildOAuthLoginStart, classifyPushCandidates, createStatelyProjectConfig, discoverLinkedPullTargets, discoverOAuthLogin, discoverRemoteProjectMachineTargets, formatMissingNewMachineDirMessage, formatPlanSummary, formatProjectStatus, formatStoredCredentialSource, getEnvApiKey, getEnvCredential, inferInitProjectName, initProject, isFileGitDirty, resolveApiKey, resolveConfiguredPullTargets, resolveCredentialStatus, resolveProjectStatus, run, scanProjectSources };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { S as createStatelyProjectConfig, _ as resolveConfiguredPullTargets, a as discoverOAuthLogin, b as run, c as formatPlanSummary, d as getEnvApiKey, f as getEnvCredential, g as resolveApiKey, h as isFileGitDirty, i as discoverLinkedPullTargets, l as formatProjectStatus, m as initProject, n as buildOAuthLoginStart, o as discoverRemoteProjectMachineTargets, p as inferInitProjectName, r as classifyPushCandidates, s as formatMissingNewMachineDirMessage, t as COMMANDS, u as formatStoredCredentialSource, v as resolveCredentialStatus, x as scanProjectSources, y as resolveProjectStatus } from "./cli-D0TeuFzR.mjs";
|
|
2
2
|
|
|
3
|
-
export { COMMANDS, buildOAuthLoginStart, classifyPushCandidates, createStatelyProjectConfig, discoverLinkedPullTargets, discoverOAuthLogin, discoverRemoteProjectMachineTargets, formatMissingNewMachineDirMessage, formatPlanSummary, formatStoredCredentialSource, getEnvApiKey, getEnvCredential, inferInitProjectName, initProject, isFileGitDirty, resolveApiKey, resolveConfiguredPullTargets, run, scanProjectSources };
|
|
3
|
+
export { COMMANDS, buildOAuthLoginStart, classifyPushCandidates, createStatelyProjectConfig, discoverLinkedPullTargets, discoverOAuthLogin, discoverRemoteProjectMachineTargets, formatMissingNewMachineDirMessage, formatPlanSummary, formatProjectStatus, formatStoredCredentialSource, getEnvApiKey, getEnvCredential, inferInitProjectName, initProject, isFileGitDirty, resolveApiKey, resolveConfiguredPullTargets, resolveCredentialStatus, resolveProjectStatus, run, scanProjectSources };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "statelyai",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "Command-line tools for Stately",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@oclif/core": "^4.10.3",
|
|
24
|
-
"@statelyai/sdk": "0.13.
|
|
24
|
+
"@statelyai/sdk": "0.13.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "0.21.0-beta.2",
|