@sanity/workflow-cli 0.12.0 → 0.14.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/CHANGELOG.md +51 -0
- package/README.md +77 -48
- package/dist/commands/{abort.d.ts → editorial-workflows/abort.d.ts} +4 -2
- package/dist/commands/{abort.js → editorial-workflows/abort.js} +8 -7
- package/dist/commands/{definition → editorial-workflows/definition}/delete.d.ts +4 -2
- package/dist/commands/{definition → editorial-workflows/definition}/delete.js +7 -6
- package/dist/commands/{definition → editorial-workflows/definition}/diff.d.ts +3 -1
- package/dist/commands/{definition → editorial-workflows/definition}/diff.js +8 -7
- package/dist/commands/{definition → editorial-workflows/definition}/list.d.ts +2 -1
- package/dist/commands/{definition → editorial-workflows/definition}/list.js +21 -21
- package/dist/commands/{definition → editorial-workflows/definition}/show.d.ts +3 -2
- package/dist/commands/{definition → editorial-workflows/definition}/show.js +7 -6
- package/dist/commands/{deploy.d.ts → editorial-workflows/deploy.d.ts} +4 -2
- package/dist/commands/{deploy.js → editorial-workflows/deploy.js} +26 -19
- package/dist/commands/{diagnose.d.ts → editorial-workflows/diagnose.d.ts} +3 -1
- package/dist/commands/{diagnose.js → editorial-workflows/diagnose.js} +8 -7
- package/dist/commands/{fire-action.d.ts → editorial-workflows/fire-action.d.ts} +4 -2
- package/dist/commands/{fire-action.js → editorial-workflows/fire-action.js} +9 -8
- package/dist/commands/{list.d.ts → editorial-workflows/list.d.ts} +2 -1
- package/dist/commands/{list.js → editorial-workflows/list.js} +24 -24
- package/dist/commands/editorial-workflows/nuke.d.ts +13 -0
- package/dist/commands/{nuke.js → editorial-workflows/nuke.js} +22 -17
- package/dist/commands/{reset-activity.d.ts → editorial-workflows/reset-activity.d.ts} +2 -1
- package/dist/commands/{reset-activity.js → editorial-workflows/reset-activity.js} +2 -1
- package/dist/commands/{set-stage.d.ts → editorial-workflows/set-stage.d.ts} +5 -3
- package/dist/commands/{set-stage.js → editorial-workflows/set-stage.js} +7 -6
- package/dist/commands/{show.d.ts → editorial-workflows/show.d.ts} +2 -1
- package/dist/commands/{show.js → editorial-workflows/show.js} +40 -26
- package/dist/commands/{start.d.ts → editorial-workflows/start.d.ts} +4 -2
- package/dist/commands/{start.js → editorial-workflows/start.js} +10 -9
- package/dist/commands/{tail.d.ts → editorial-workflows/tail.d.ts} +2 -1
- package/dist/commands/{tail.js → editorial-workflows/tail.js} +6 -5
- package/dist/hooks/finally/telemetry.js +2 -2
- package/dist/hooks/prerun/telemetry.d.ts +4 -3
- package/dist/lib/base-command.d.ts +4 -6
- package/dist/lib/base-command.js +6 -0
- package/dist/lib/context.d.ts +24 -9
- package/dist/lib/context.js +15 -6
- package/dist/lib/flags.d.ts +27 -4
- package/dist/lib/flags.js +17 -1
- package/dist/lib/nuke.d.ts +15 -1
- package/dist/lib/nuke.js +22 -1
- package/dist/lib/prompt.d.ts +3 -2
- package/dist/lib/select-deployment.d.ts +43 -16
- package/dist/lib/select-deployment.js +66 -15
- package/dist/lib/share-definitions.d.ts +23 -28
- package/dist/lib/share-definitions.js +26 -38
- package/dist/lib/telemetry-setup.d.ts +2 -2
- package/dist/lib/telemetry.d.ts +18 -10
- package/dist/lib/telemetry.js +5 -2
- package/dist/lib/ui.d.ts +12 -0
- package/dist/lib/ui.js +9 -0
- package/oclif.manifest.json +223 -66
- package/package.json +11 -9
- package/dist/commands/nuke.d.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @sanity/workflow-cli
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 59b40fd: **BREAKING:** deployment selection now keys on the deployment `name`, selected with `--deployment`. Deployment-targeted commands (`start`, `definition diff`, `definition delete`, `nuke`) take `--deployment` as the precise selector; `--tag` still selects while it names exactly one deployment and errors listing the candidates when it spans several. `deploy --tag <tag>` now deploys every deployment carrying the tag (a tag is an environment group); `--deployment` deploys one, `--all-tags` deploys everything, and the three are mutually exclusive. `nuke` requires exactly one of `--deployment` / `--tag`, and refuses when another same-tag deployment sweeps an overlapping resource — guard document ids embed only the tag, so within a shared dataset the sweep cannot tell the deployments' guards apart and would delete the other's live locks. The interactive deploy prompt selects by name with the tag as its description. Read commands keep `--tag` as an optional filter — a repeated tag fans reads out across every resource it is deployed to.
|
|
8
|
+
- de7ccfa: The instance-keyed commands (`diagnose`, `abort`, `set-stage`, `fire-action`) accept `--deployment <name>` to choose which resource to read the instance from — the precise selector consistent with the deployment-targeted commands. `--deployment` names one deployment and reads from the resource it targets; `--tag` stays the optional narrower it was, and the instance's own tag partition still comes from the loaded instance itself, never from the flag. This closes the dead end where a tag repeated across several resources left these commands unable to resolve a resource, and the "spans multiple resources" failures now point at `--deployment` as the remedy.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [24b11dd]
|
|
13
|
+
- Updated dependencies [2005ab7]
|
|
14
|
+
- Updated dependencies [24b11dd]
|
|
15
|
+
- Updated dependencies [59b40fd]
|
|
16
|
+
- @sanity/workflow-engine@0.19.0
|
|
17
|
+
|
|
18
|
+
## 0.13.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 58f8211: Every command's canonical oclif id now nests under the `editorial-workflows` topic, making the package mountable as a plugin of the `sanity` CLI (`sanity editorial-workflows deploy`) without colliding with host commands. The standalone surface is unchanged: the bare forms (`sanity-workflows deploy`, `sanity-workflows definition list`, …) remain as aliases of the nested ids.
|
|
23
|
+
- 00c089d: **BREAKING:** Require every definition deployment and workflow deployment configuration to state an `expectedMinReaderModel` literal that exactly matches the installed engine's writer capability.
|
|
24
|
+
|
|
25
|
+
Deploy and definition-diff paths now reject missing or stale acknowledgements before client access or telemetry, with a structured error and readers-first rollout guidance.
|
|
26
|
+
|
|
27
|
+
- 53661fa: Prompt interactive deploys to select a configured deployment tag when several are available and no selector flag was supplied. Render Ctrl+C prompt cancellations without a stack trace.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 82e4a4e: Fix definition sharing to honor its opt-out contract: deploys now share newly created definition versions by default in every environment, including CI, `DO_NOT_TRACK`, and non-TTY runs. The first interactive run shows a mandatory disclosure rather than a consent choice, every other flagless run prints a clear status block with the explicit opt-in and opt-out flags, and only `--no-share-defs` suppresses sharing for that invocation.
|
|
32
|
+
- 9126299: **BREAKING:** Delete persisted stage guard documents when their stage exits, and remove the lifted-record `GUARD_LIFTED_PREDICATE` and `isGuardLifted` exports.
|
|
33
|
+
|
|
34
|
+
Guard deletion now uses the observed document revision so stale exit reconciliation cannot delete a guard reactivated by a newer stage visit. Reactive guard streams contain only active persisted guards.
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [239d9f6]
|
|
37
|
+
- Updated dependencies [3af2ca0]
|
|
38
|
+
- Updated dependencies [7276702]
|
|
39
|
+
- Updated dependencies [58f8211]
|
|
40
|
+
- Updated dependencies [00c089d]
|
|
41
|
+
- Updated dependencies [71cd58e]
|
|
42
|
+
- Updated dependencies [cd03973]
|
|
43
|
+
- Updated dependencies [d26cc1a]
|
|
44
|
+
- Updated dependencies [9126299]
|
|
45
|
+
- Updated dependencies [72018af]
|
|
46
|
+
- Updated dependencies [5cd8ffd]
|
|
47
|
+
- Updated dependencies [b82bda4]
|
|
48
|
+
- Updated dependencies [55a54b3]
|
|
49
|
+
- Updated dependencies [b82bda4]
|
|
50
|
+
- Updated dependencies [4490442]
|
|
51
|
+
- Updated dependencies [1540dce]
|
|
52
|
+
- @sanity/workflow-engine@0.18.0
|
|
53
|
+
|
|
3
54
|
## 0.12.0
|
|
4
55
|
|
|
5
56
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -20,6 +20,19 @@ pnpm --filter @sanity/workflow-cli dev list --include-completed
|
|
|
20
20
|
pnpm --filter @sanity/workflow-cli dev show wf-instance.abc123
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
The package is an [oclif](https://oclif.io) plugin: every command's canonical
|
|
24
|
+
id nests under the `editorial-workflows` topic
|
|
25
|
+
(`sanity-workflows editorial-workflows deploy`), so mounting the package into
|
|
26
|
+
the `sanity` CLI's plugin list surfaces the same commands as
|
|
27
|
+
`sanity editorial-workflows …` without its canonical ids colliding with the
|
|
28
|
+
host's own commands (the sanity CLI already has a `deploy`). The bare forms
|
|
29
|
+
used throughout this README (`deploy`, `definition list`, …) are aliases of
|
|
30
|
+
the nested ids and are the standalone binary's stable surface. oclif registers
|
|
31
|
+
plugin aliases in a host unconditionally (an id collision resolves by plugin
|
|
32
|
+
priority, host first), so a host mount would also surface these bare aliases
|
|
33
|
+
at its root — trimming or hiding them for the mounted context is part of the
|
|
34
|
+
host-side mount work, not something a host can configure away.
|
|
35
|
+
|
|
23
36
|
Authenticate once with `sanity login` (the CLI reads that session token); for
|
|
24
37
|
CI, set `SANITY_AUTH_TOKEN` instead. Then create a `sanity.workflow.ts` in the
|
|
25
38
|
directory you run from — see [Configuration](#configuration).
|
|
@@ -36,7 +49,8 @@ project will fail on cross-resource reads.
|
|
|
36
49
|
|
|
37
50
|
The CLI is configured by a `sanity.workflow.ts` (or `.js`/`.mjs`) discovered in
|
|
38
51
|
the directory you run from. It exports a config built with
|
|
39
|
-
`defineWorkflowConfig`, declaring
|
|
52
|
+
`defineWorkflowConfig`, declaring your **deployments** (typically one per
|
|
53
|
+
environment):
|
|
40
54
|
|
|
41
55
|
```ts
|
|
42
56
|
import {defineWorkflowConfig} from '@sanity/workflow-engine/define'
|
|
@@ -46,7 +60,8 @@ import {articleReview, urlDraft} from './src/workflows.ts'
|
|
|
46
60
|
export default defineWorkflowConfig({
|
|
47
61
|
deployments: [
|
|
48
62
|
{
|
|
49
|
-
|
|
63
|
+
expectedMinReaderModel: 2,
|
|
64
|
+
name: 'production', // the deployment's unique identity (lowercase letters, digits, dashes)
|
|
50
65
|
tag: 'prod', // the environment partition the engine's docs are scoped to
|
|
51
66
|
workflowResource: {type: 'dataset', id: 'acme.workflows'}, // where those docs live
|
|
52
67
|
resourceAliases: [
|
|
@@ -62,14 +77,25 @@ export default defineWorkflowConfig({
|
|
|
62
77
|
})
|
|
63
78
|
```
|
|
64
79
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
`name` is the deployment's identity: unique across the config and constrained
|
|
81
|
+
to the same grammar as `tag`. Tags group deployments by environment and may
|
|
82
|
+
repeat, as long as no two deployments share both a `workflowResource` and a
|
|
83
|
+
`tag` — that pair is the storage partition, and the config rejects the
|
|
84
|
+
collision naming both entries.
|
|
85
|
+
|
|
86
|
+
Pick a deployment with `--deployment <name>`; with a single deployment configured you
|
|
87
|
+
can omit it. `--tag <tag>` also works on single-deployment commands while the
|
|
88
|
+
tag names exactly one deployment — on `deploy` it targets every deployment
|
|
89
|
+
carrying the tag (a tag is an environment group). With several configured, a
|
|
90
|
+
bare interactive `deploy` presents a keyboard-driven deployment selector (by
|
|
91
|
+
name, tag alongside). In CI or another non-interactive shell, it fails asking
|
|
92
|
+
for `--deployment`, `--tag`, or `--all-tags` instead of blocking for input.
|
|
93
|
+
`--all-tags` deploys every deployment in the config in one run: a failure in one doesn't
|
|
94
|
+
stop the rest — the run continues, prints a summary of what failed, and exits
|
|
95
|
+
non-zero. The client's project + dataset are derived from the deployment's
|
|
96
|
+
`workflowResource`, and `deploy` expands each definition's `@<handle>:`
|
|
97
|
+
reference to the bound physical resource. An invalid config fails with a clean,
|
|
98
|
+
path-prefixed error before the command runs.
|
|
73
99
|
|
|
74
100
|
`resourceAliases` is only for content that lives in a _different_ resource from
|
|
75
101
|
`workflowResource`. A definition can reference a document in the **same**
|
|
@@ -127,26 +153,26 @@ stale compiled output.
|
|
|
127
153
|
|
|
128
154
|
## Command status
|
|
129
155
|
|
|
130
|
-
| Command
|
|
131
|
-
|
|
|
132
|
-
| `deploy`
|
|
133
|
-
| `deploy --all-tags`
|
|
134
|
-
| `deploy --check`
|
|
135
|
-
| `deploy --dry-run`
|
|
136
|
-
| `deploy --only <name>`
|
|
137
|
-
| `start <name>`
|
|
138
|
-
| `list`
|
|
139
|
-
| `show <instance-id>`
|
|
140
|
-
| `diagnose <instance-id>`
|
|
141
|
-
| `tail <instance-id>`
|
|
142
|
-
| `abort <instance-id>`
|
|
143
|
-
| `set-stage <instance-id> --to <stage>`
|
|
144
|
-
| `fire-action <instance-id>`
|
|
145
|
-
| `definition list`
|
|
146
|
-
| `definition show <name>`
|
|
147
|
-
| `definition diff <name>`
|
|
148
|
-
| `definition delete <name>`
|
|
149
|
-
| `nuke --tag <tag>`
|
|
156
|
+
| Command | Status |
|
|
157
|
+
| ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
158
|
+
| `deploy` | wired — calls `workflow.deployDefinitions` over the selected deployment's definitions |
|
|
159
|
+
| `deploy --all-tags` | wired — deploys every deployment in the config, continuing past per-deployment failures |
|
|
160
|
+
| `deploy --check` | wired — runs `validateDefinition` over the local batch + a duplicate-name check |
|
|
161
|
+
| `deploy --dry-run` | wired — fetches existing docs and renders a coloured JSON diff per change |
|
|
162
|
+
| `deploy --only <name>` | wired — filters deploy/check/dry-run to one definition by `name` |
|
|
163
|
+
| `start <name>` | wired — calls `workflow.startInstance` (`--field` for input fields) |
|
|
164
|
+
| `list` | wired — `client.fetch` over `sanity.workflow.instance` documents (`--definition <name>` to filter) |
|
|
165
|
+
| `show <instance-id>` | wired — `client.getDocument` |
|
|
166
|
+
| `diagnose <instance-id>` | wired — calls `workflow.diagnose`, classifies why the instance is/isn't progressing |
|
|
167
|
+
| `tail <instance-id>` | wired — `client.listen()` over the instance, prints new history entries |
|
|
168
|
+
| `abort <instance-id>` | wired — calls `workflow.abortInstance` (hard stop: cancels pending effects, removes guards) |
|
|
169
|
+
| `set-stage <instance-id> --to <stage>` | wired — calls `workflow.setStage` (admin override: skips declared transitions/filters; enter lifecycle + cascade still run) |
|
|
170
|
+
| `fire-action <instance-id>` | wired — `workflow.availableActions` lists actions; `workflow.fireAction` fires one |
|
|
171
|
+
| `definition list` | wired — `client.fetch` over `sanity.workflow.definition` documents |
|
|
172
|
+
| `definition show <name>` | wired — `client.fetch`, latest version unless `--version` |
|
|
173
|
+
| `definition diff <name>` | wired — diffs the in-code definition against the deployed latest (`--version` to pin) |
|
|
174
|
+
| `definition delete <name>` | wired — calls `workflow.deleteDefinition` (refuses on live instances unless `--cascade`) |
|
|
175
|
+
| `nuke --deployment <name>` / `nuke --tag <tag>` | wired — dev-period reset (exists only until the versioned upgrade framework): deletes every engine-owned doc for the deployment's tag (instances, definitions, guards across resources); exactly one selector required; refuses while another same-tag deployment sweeps an overlapping resource (guard ids embed only the tag); plan + typed confirm |
|
|
150
176
|
|
|
151
177
|
## Telemetry
|
|
152
178
|
|
|
@@ -155,8 +181,9 @@ per-command trace (`Editorial Workflows CLI Command Executed` — the command id
|
|
|
155
181
|
names of declared flags used, never their values, and a success flag) plus
|
|
156
182
|
the engine's adoption events from the operations it drives. Consent is the
|
|
157
183
|
account-wide status managed by `npx sanity telemetry enable|disable|status`;
|
|
158
|
-
CI and trueish `DO_NOT_TRACK` suppress everything (except a
|
|
159
|
-
which forces that deploy's telemetry
|
|
184
|
+
CI and trueish `DO_NOT_TRACK` suppress everything (except a deploy that may share
|
|
185
|
+
new definitions, which forces that deploy's telemetry unless `--no-share-defs`
|
|
186
|
+
is passed — see [Definition sharing](#definition-sharing)),
|
|
160
187
|
and a session that isn't logged in sends nothing. A one-time notice on stderr
|
|
161
188
|
discloses collection on first use.
|
|
162
189
|
|
|
@@ -176,25 +203,27 @@ definition-feedback endpoint, not the telemetry pipeline; telemetry carries
|
|
|
176
203
|
only a content-free marker (content hash plus structural counts) per shared
|
|
177
204
|
definition and a per-invocation decision event.
|
|
178
205
|
|
|
179
|
-
Sharing is **opt-out**. Pass `--share-defs` to
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
account-level `sanity telemetry disable` still applies. A failed share
|
|
190
|
-
warns, never failing a completed deploy.
|
|
206
|
+
Sharing is **opt-out in every environment**. Pass `--no-share-defs` to decline
|
|
207
|
+
for one invocation. With neither flag, the first interactive deploy prints a
|
|
208
|
+
full notice before sending and remembers that the notice was shown; every later
|
|
209
|
+
flagless deploy prints a status block showing that sharing is on by default and
|
|
210
|
+
showing runnable shell examples for the default, explicit opt-in, and opt-out
|
|
211
|
+
forms; the explicit flags suppress the status block. Unattended runs (CI,
|
|
212
|
+
`DO_NOT_TRACK`, or a non-TTY pipe) also share by default and print that status
|
|
213
|
+
block in their logs.
|
|
214
|
+
A flagless deploy or explicit `--share-defs` forces that deploy's telemetry
|
|
215
|
+
through the environment gate so donated definitions retain their content-free
|
|
216
|
+
markers; account-level `sanity telemetry disable` still applies. A failed share
|
|
217
|
+
only warns, never failing a completed deploy.
|
|
191
218
|
|
|
192
219
|
## Known gaps
|
|
193
220
|
|
|
194
|
-
- **
|
|
195
|
-
|
|
196
|
-
`sanity
|
|
197
|
-
plugin
|
|
221
|
+
- **Not mounted in the `sanity` CLI yet.** The package side is mount-ready —
|
|
222
|
+
commands nest under the `editorial-workflows` oclif topic (see
|
|
223
|
+
[Run](#run)) — but the `sanity` CLI does not list this package in its
|
|
224
|
+
plugin array, so the commands ship only through the standalone
|
|
225
|
+
`sanity-workflows` binary today. The host-side mount (and what happens to
|
|
226
|
+
the bare aliases inside a host) is a separate piece of work.
|
|
198
227
|
- **No true bypass.** `set-stage` is the engine's `setStage` admin
|
|
199
228
|
override: it skips the definition's declared transitions and filters, but
|
|
200
229
|
the target stage's enter lifecycle and the post-move cascade still run. A
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type WorkflowInstance } from '@sanity/workflow-engine';
|
|
2
|
-
import { WorkflowCommand } from '
|
|
3
|
-
import { type WriteReport } from '
|
|
2
|
+
import { WorkflowCommand } from '../../lib/base-command.ts';
|
|
3
|
+
import { type WriteReport } from '../../lib/ops-report.ts';
|
|
4
4
|
export default class Abort extends WorkflowCommand {
|
|
5
|
+
static aliases: string[];
|
|
5
6
|
static description: string;
|
|
6
7
|
static examples: string[];
|
|
7
8
|
static args: {
|
|
@@ -9,6 +10,7 @@ export default class Abort extends WorkflowCommand {
|
|
|
9
10
|
};
|
|
10
11
|
static flags: {
|
|
11
12
|
reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
deployment: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
14
|
tag: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
15
|
};
|
|
14
16
|
run(): Promise<void>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
2
|
import { Args, Flags } from '@oclif/core';
|
|
3
3
|
import { workflow } from '@sanity/workflow-engine';
|
|
4
|
-
import { WorkflowCommand } from "
|
|
5
|
-
import { resolveInstanceContext } from "
|
|
6
|
-
import {
|
|
7
|
-
import { buildOperationArgs } from "
|
|
8
|
-
import { runWriteVerb } from "
|
|
4
|
+
import { WorkflowCommand } from "../../lib/base-command.js";
|
|
5
|
+
import { resolveInstanceContext } from "../../lib/context.js";
|
|
6
|
+
import { instanceFlags } from "../../lib/flags.js";
|
|
7
|
+
import { buildOperationArgs } from "../../lib/operation-args.js";
|
|
8
|
+
import { runWriteVerb } from "../../lib/ops-report.js";
|
|
9
9
|
export default class Abort extends WorkflowCommand {
|
|
10
|
-
static
|
|
10
|
+
static aliases = ['abort'];
|
|
11
|
+
static description = 'Abort an in-flight workflow instance — a hard stop: pending effects are cancelled, stage guards removed, and the instance is marked terminal where it stands.';
|
|
11
12
|
static examples = [
|
|
12
13
|
'<%= config.bin %> abort wf-instance.abc123',
|
|
13
14
|
"<%= config.bin %> abort wf-instance.abc123 --reason 'superseded by relaunch'",
|
|
@@ -16,7 +17,7 @@ export default class Abort extends WorkflowCommand {
|
|
|
16
17
|
instanceId: Args.string({ required: true, description: 'Workflow instance id.' }),
|
|
17
18
|
};
|
|
18
19
|
static flags = {
|
|
19
|
-
...
|
|
20
|
+
...instanceFlags,
|
|
20
21
|
reason: Flags.string({ description: 'Reason for aborting (recorded in history).' }),
|
|
21
22
|
};
|
|
22
23
|
async run() {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type DeleteDefinitionArgs, type DeleteDefinitionResult } from '@sanity/workflow-engine';
|
|
2
|
-
import { WorkflowCommand } from '
|
|
3
|
-
import { type EngineScope } from '
|
|
2
|
+
import { WorkflowCommand } from '../../../lib/base-command.ts';
|
|
3
|
+
import { type EngineScope } from '../../../lib/operation-args.ts';
|
|
4
4
|
export default class DefinitionDelete extends WorkflowCommand {
|
|
5
|
+
static aliases: string[];
|
|
5
6
|
static description: string;
|
|
6
7
|
static examples: string[];
|
|
7
8
|
static args: {
|
|
@@ -11,6 +12,7 @@ export default class DefinitionDelete extends WorkflowCommand {
|
|
|
11
12
|
version: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
13
|
cascade: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
14
|
reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
deployment: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
16
|
tag: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
17
|
};
|
|
16
18
|
run(): Promise<void>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
2
|
import { Args, Flags } from '@oclif/core';
|
|
3
3
|
import { workflow, } from '@sanity/workflow-engine';
|
|
4
|
-
import { WorkflowCommand } from "
|
|
5
|
-
import { resolveContext } from "
|
|
6
|
-
import {
|
|
7
|
-
import { baseEngineArgs } from "
|
|
8
|
-
import { runWriteVerb } from "
|
|
4
|
+
import { WorkflowCommand } from "../../../lib/base-command.js";
|
|
5
|
+
import { resolveContext } from "../../../lib/context.js";
|
|
6
|
+
import { deploymentFlags } from "../../../lib/flags.js";
|
|
7
|
+
import { baseEngineArgs } from "../../../lib/operation-args.js";
|
|
8
|
+
import { runWriteVerb } from "../../../lib/ops-report.js";
|
|
9
9
|
export default class DefinitionDelete extends WorkflowCommand {
|
|
10
|
+
static aliases = ['definition:delete'];
|
|
10
11
|
static description = 'Delete a deployed workflow definition (every version, or one via --version). ' +
|
|
11
12
|
'Refuses while non-terminal instances exist unless --cascade aborts them first — ' +
|
|
12
13
|
'instances are aborted in place, never deleted.';
|
|
@@ -19,7 +20,7 @@ export default class DefinitionDelete extends WorkflowCommand {
|
|
|
19
20
|
name: Args.string({ required: true, description: 'Workflow definition name.' }),
|
|
20
21
|
};
|
|
21
22
|
static flags = {
|
|
22
|
-
...
|
|
23
|
+
...deploymentFlags,
|
|
23
24
|
version: Flags.integer({
|
|
24
25
|
description: 'Delete only this deployed version (default: every version).',
|
|
25
26
|
}),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type WorkflowDefinition } from '@sanity/workflow-engine';
|
|
2
|
-
import { WorkflowCommand } from '
|
|
2
|
+
import { WorkflowCommand } from '../../../lib/base-command.ts';
|
|
3
3
|
export default class DefinitionDiff extends WorkflowCommand {
|
|
4
|
+
static aliases: string[];
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
6
7
|
static args: {
|
|
@@ -8,6 +9,7 @@ export default class DefinitionDiff extends WorkflowCommand {
|
|
|
8
9
|
};
|
|
9
10
|
static flags: {
|
|
10
11
|
version: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
deployment: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
13
|
tag: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
14
|
};
|
|
13
15
|
run(): Promise<void>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
2
|
import { diffEntry } from '@sanity/workflow-engine';
|
|
3
3
|
import ora from 'ora';
|
|
4
|
-
import { WorkflowCommand } from "
|
|
5
|
-
import { resolveContext } from "
|
|
6
|
-
import { fetchDeployedDefinition, selectDefinitions, validateOrFail } from "
|
|
7
|
-
import { diffReport } from "
|
|
8
|
-
import {
|
|
9
|
-
import { deploymentToTarget } from "
|
|
4
|
+
import { WorkflowCommand } from "../../../lib/base-command.js";
|
|
5
|
+
import { resolveContext } from "../../../lib/context.js";
|
|
6
|
+
import { fetchDeployedDefinition, selectDefinitions, validateOrFail, } from "../../../lib/definitions.js";
|
|
7
|
+
import { diffReport } from "../../../lib/diff.js";
|
|
8
|
+
import { deploymentFlags } from "../../../lib/flags.js";
|
|
9
|
+
import { deploymentToTarget } from "../../../lib/select-deployment.js";
|
|
10
10
|
export default class DefinitionDiff extends WorkflowCommand {
|
|
11
|
+
static aliases = ['definition:diff'];
|
|
11
12
|
static description = 'Diff an in-code definition against the deployed version (latest by default).';
|
|
12
13
|
static examples = [
|
|
13
14
|
'<%= config.bin %> definition diff productLaunch',
|
|
@@ -17,7 +18,7 @@ export default class DefinitionDiff extends WorkflowCommand {
|
|
|
17
18
|
name: Args.string({ required: true, description: 'Workflow definition name.' }),
|
|
18
19
|
};
|
|
19
20
|
static flags = {
|
|
20
|
-
...
|
|
21
|
+
...deploymentFlags,
|
|
21
22
|
version: Flags.integer({ description: 'Deployed version to diff against (default: latest).' }),
|
|
22
23
|
};
|
|
23
24
|
async run() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WorkflowCommand } from '
|
|
1
|
+
import { WorkflowCommand } from '../../../lib/base-command.ts';
|
|
2
2
|
interface DefinitionListFlags {
|
|
3
3
|
tag?: string | undefined;
|
|
4
4
|
name?: string | undefined;
|
|
@@ -22,6 +22,7 @@ export declare function buildDefinitionListQuery(flags: DefinitionListFlags): {
|
|
|
22
22
|
params: Record<string, unknown>;
|
|
23
23
|
};
|
|
24
24
|
export default class DefinitionList extends WorkflowCommand {
|
|
25
|
+
static aliases: string[];
|
|
25
26
|
static description: string;
|
|
26
27
|
static examples: string[];
|
|
27
28
|
static flags: {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import { WORKFLOW_DEFINITION_TYPE, WORKFLOW_INSTANCE_TYPE, assertReadableModel, inFlightFilter, tagScopeFilter, } from '@sanity/workflow-engine';
|
|
3
3
|
import logSymbols from 'log-symbols';
|
|
4
|
-
import { WorkflowCommand } from "
|
|
5
|
-
import { resolveReadTargets } from "
|
|
6
|
-
import { tagFlags } from "
|
|
7
|
-
import { runReadAcrossTargets } from "
|
|
8
|
-
import {
|
|
4
|
+
import { WorkflowCommand } from "../../../lib/base-command.js";
|
|
5
|
+
import { resolveReadTargets } from "../../../lib/context.js";
|
|
6
|
+
import { tagFlags } from "../../../lib/flags.js";
|
|
7
|
+
import { runReadAcrossTargets } from "../../../lib/read-fanout.js";
|
|
8
|
+
import { logClippedTable } from "../../../lib/ui.js";
|
|
9
9
|
export function buildDefinitionListQuery(flags) {
|
|
10
10
|
const params = { limit: flags.limit + 1 };
|
|
11
11
|
const filters = [`_type == "${WORKFLOW_DEFINITION_TYPE}"`];
|
|
@@ -40,6 +40,7 @@ export function buildDefinitionListQuery(flags) {
|
|
|
40
40
|
return { groq, params };
|
|
41
41
|
}
|
|
42
42
|
export default class DefinitionList extends WorkflowCommand {
|
|
43
|
+
static aliases = ['definition:list'];
|
|
43
44
|
static description = 'List deployed workflow definitions.';
|
|
44
45
|
static examples = [
|
|
45
46
|
'<%= config.bin %> definition list',
|
|
@@ -70,22 +71,21 @@ export default class DefinitionList extends WorkflowCommand {
|
|
|
70
71
|
this.log(`${logSymbols.info} no definitions found`);
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
r
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
74
|
+
logClippedTable({
|
|
75
|
+
rows: fetched,
|
|
76
|
+
limit: flags.limit,
|
|
77
|
+
headers: ['workflow', 'title', 'tag', 'stages', 'in flight', 'instances', 'created'],
|
|
78
|
+
toCells: (r) => [
|
|
79
|
+
`${r.name} v${r.version}`,
|
|
80
|
+
r.title,
|
|
81
|
+
r.tag,
|
|
82
|
+
String(r.stageCount),
|
|
83
|
+
String(r.inFlightCount),
|
|
84
|
+
String(r.totalInstances),
|
|
85
|
+
r._createdAt,
|
|
86
|
+
],
|
|
87
|
+
log: (line) => this.log(line),
|
|
88
|
+
});
|
|
89
89
|
},
|
|
90
90
|
});
|
|
91
91
|
if (failures.length > 0) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type DeployedDefinition, type WorkflowDefinition, type WorkflowResource } from '@sanity/workflow-engine';
|
|
2
|
-
import { WorkflowCommand } from '
|
|
3
|
-
import { type ReadTarget } from '
|
|
2
|
+
import { WorkflowCommand } from '../../../lib/base-command.ts';
|
|
3
|
+
import { type ReadTarget } from '../../../lib/context.ts';
|
|
4
4
|
export default class DefinitionShow extends WorkflowCommand {
|
|
5
|
+
static aliases: string[];
|
|
5
6
|
static description: string;
|
|
6
7
|
static args: {
|
|
7
8
|
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -2,13 +2,14 @@ import { styleText } from 'node:util';
|
|
|
2
2
|
import { Args, Flags } from '@oclif/core';
|
|
3
3
|
import { assertReadableModel, isTerminalStage, } from '@sanity/workflow-engine';
|
|
4
4
|
import logSymbols from 'log-symbols';
|
|
5
|
-
import { WorkflowCommand } from "
|
|
6
|
-
import { resolveReadTargets, soleHitOrFail } from "
|
|
7
|
-
import { buildDefinitionShowQuery, buildDefinitionTagsQuery } from "
|
|
8
|
-
import { fail } from "
|
|
9
|
-
import { tagFlags } from "
|
|
10
|
-
import { formatKeyValue, resourceLabel, sectionHeader } from "
|
|
5
|
+
import { WorkflowCommand } from "../../../lib/base-command.js";
|
|
6
|
+
import { resolveReadTargets, soleHitOrFail } from "../../../lib/context.js";
|
|
7
|
+
import { buildDefinitionShowQuery, buildDefinitionTagsQuery } from "../../../lib/definitions.js";
|
|
8
|
+
import { fail } from "../../../lib/fail.js";
|
|
9
|
+
import { tagFlags } from "../../../lib/flags.js";
|
|
10
|
+
import { formatKeyValue, resourceLabel, sectionHeader } from "../../../lib/ui.js";
|
|
11
11
|
export default class DefinitionShow extends WorkflowCommand {
|
|
12
|
+
static aliases = ['definition:show'];
|
|
12
13
|
static description = 'Show a deployed workflow definition.';
|
|
13
14
|
static args = {
|
|
14
15
|
name: Args.string({ required: true, description: 'Workflow definition name.' }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DeployDefinitionResult, type WorkflowDefinition, type WorkflowDeployment } from '@sanity/workflow-engine';
|
|
2
|
-
import { WorkflowCommand } from '
|
|
2
|
+
import { WorkflowCommand } from '../../lib/base-command.ts';
|
|
3
3
|
/** A deployment paired with the definitions selected + validated for it. */
|
|
4
4
|
interface DeployBatch {
|
|
5
5
|
deployment: WorkflowDeployment;
|
|
@@ -11,15 +11,17 @@ interface DeployFailure {
|
|
|
11
11
|
message: string;
|
|
12
12
|
}
|
|
13
13
|
export default class Deploy extends WorkflowCommand {
|
|
14
|
+
static aliases: string[];
|
|
14
15
|
static description: string;
|
|
15
16
|
static examples: string[];
|
|
16
17
|
static flags: {
|
|
18
|
+
tag: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
19
|
'all-tags': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
20
|
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
21
|
check: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
22
|
only: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
23
|
'share-defs': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
22
|
-
|
|
24
|
+
deployment: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
25
|
};
|
|
24
26
|
run(): Promise<void>;
|
|
25
27
|
/** Deploy (or diff, for `--dry-run`) one deployment's definitions.
|