@sanity/workflows-cli 0.0.0-main-039-20261113092657
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 +1936 -0
- package/LICENSE +21 -0
- package/README.md +814 -0
- package/bin/run.js +8 -0
- package/dist/command-ids.d.ts +10 -0
- package/dist/command-ids.js +10 -0
- package/dist/commands/workflows/abort.d.ts +29 -0
- package/dist/commands/workflows/abort.js +50 -0
- package/dist/commands/workflows/blueprints/generate.d.ts +12 -0
- package/dist/commands/workflows/blueprints/generate.js +46 -0
- package/dist/commands/workflows/codemod/packages.d.ts +13 -0
- package/dist/commands/workflows/codemod/packages.js +41 -0
- package/dist/commands/workflows/definitions/delete.d.ts +44 -0
- package/dist/commands/workflows/definitions/delete.js +74 -0
- package/dist/commands/workflows/definitions/diff.d.ts +23 -0
- package/dist/commands/workflows/definitions/diff.js +55 -0
- package/dist/commands/workflows/definitions/list.d.ts +51 -0
- package/dist/commands/workflows/definitions/list.js +139 -0
- package/dist/commands/workflows/definitions/show.d.ts +65 -0
- package/dist/commands/workflows/definitions/show.js +129 -0
- package/dist/commands/workflows/definitions/validate.d.ts +14 -0
- package/dist/commands/workflows/definitions/validate.js +50 -0
- package/dist/commands/workflows/deploy.d.ts +117 -0
- package/dist/commands/workflows/deploy.js +266 -0
- package/dist/commands/workflows/diagnose.d.ts +52 -0
- package/dist/commands/workflows/diagnose.js +195 -0
- package/dist/commands/workflows/fire-action.d.ts +53 -0
- package/dist/commands/workflows/fire-action.js +182 -0
- package/dist/commands/workflows/list.d.ts +78 -0
- package/dist/commands/workflows/list.js +248 -0
- package/dist/commands/workflows/nuke.d.ts +73 -0
- package/dist/commands/workflows/nuke.js +176 -0
- package/dist/commands/workflows/reset-activity.d.ts +32 -0
- package/dist/commands/workflows/reset-activity.js +60 -0
- package/dist/commands/workflows/show.d.ts +29 -0
- package/dist/commands/workflows/show.js +156 -0
- package/dist/commands/workflows/start.d.ts +57 -0
- package/dist/commands/workflows/start.js +196 -0
- package/dist/commands/workflows/tail.d.ts +23 -0
- package/dist/commands/workflows/tail.js +83 -0
- package/dist/commands/workflows/whoami.d.ts +15 -0
- package/dist/commands/workflows/whoami.js +53 -0
- package/dist/help.d.ts +13 -0
- package/dist/help.js +50 -0
- package/dist/hooks/finally/telemetry.d.ts +3 -0
- package/dist/hooks/finally/telemetry.js +10 -0
- package/dist/hooks/prerun/telemetry.d.ts +28 -0
- package/dist/hooks/prerun/telemetry.js +37 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/base-command.d.ts +14 -0
- package/dist/lib/base-command.js +41 -0
- package/dist/lib/blueprint-emit.d.ts +56 -0
- package/dist/lib/blueprint-emit.js +233 -0
- package/dist/lib/blueprint-needs.d.ts +5 -0
- package/dist/lib/blueprint-needs.js +231 -0
- package/dist/lib/blueprint-stacks.d.ts +6 -0
- package/dist/lib/blueprint-stacks.js +111 -0
- package/dist/lib/cause-detail.d.ts +9 -0
- package/dist/lib/cause-detail.js +112 -0
- package/dist/lib/client.d.ts +27 -0
- package/dist/lib/client.js +45 -0
- package/dist/lib/codemod/ast.d.ts +17 -0
- package/dist/lib/codemod/ast.js +14 -0
- package/dist/lib/codemod/export-rename.d.ts +17 -0
- package/dist/lib/codemod/export-rename.js +253 -0
- package/dist/lib/codemod/manifest-rewrite.d.ts +14 -0
- package/dist/lib/codemod/manifest-rewrite.js +97 -0
- package/dist/lib/codemod/package-map.d.ts +26 -0
- package/dist/lib/codemod/package-map.js +90 -0
- package/dist/lib/codemod/report.d.ts +4 -0
- package/dist/lib/codemod/report.js +46 -0
- package/dist/lib/codemod/run.d.ts +23 -0
- package/dist/lib/codemod/run.js +106 -0
- package/dist/lib/codemod/source-rewrite.d.ts +20 -0
- package/dist/lib/codemod/source-rewrite.js +149 -0
- package/dist/lib/command-context.d.ts +20 -0
- package/dist/lib/command-context.js +24 -0
- package/dist/lib/command-telemetry.d.ts +54 -0
- package/dist/lib/command-telemetry.js +82 -0
- package/dist/lib/context.d.ts +155 -0
- package/dist/lib/context.js +272 -0
- package/dist/lib/default-partition.d.ts +23 -0
- package/dist/lib/default-partition.js +48 -0
- package/dist/lib/definition-files.d.ts +14 -0
- package/dist/lib/definition-files.js +60 -0
- package/dist/lib/definitions.d.ts +63 -0
- package/dist/lib/definitions.js +84 -0
- package/dist/lib/diff.d.ts +12 -0
- package/dist/lib/diff.js +93 -0
- package/dist/lib/env.d.ts +7 -0
- package/dist/lib/env.js +8 -0
- package/dist/lib/fail.d.ts +36 -0
- package/dist/lib/fail.js +55 -0
- package/dist/lib/failure-kind.d.ts +7 -0
- package/dist/lib/failure-kind.js +66 -0
- package/dist/lib/flags.d.ts +49 -0
- package/dist/lib/flags.js +117 -0
- package/dist/lib/follow-up-command.d.ts +18 -0
- package/dist/lib/follow-up-command.js +12 -0
- package/dist/lib/history-rows.d.ts +3 -0
- package/dist/lib/history-rows.js +44 -0
- package/dist/lib/load-config.d.ts +51 -0
- package/dist/lib/load-config.js +108 -0
- package/dist/lib/nuke.d.ts +124 -0
- package/dist/lib/nuke.js +206 -0
- package/dist/lib/operation-args.d.ts +42 -0
- package/dist/lib/operation-args.js +21 -0
- package/dist/lib/ops-report.d.ts +45 -0
- package/dist/lib/ops-report.js +31 -0
- package/dist/lib/params.d.ts +3 -0
- package/dist/lib/params.js +21 -0
- package/dist/lib/pick-dataset.d.ts +10 -0
- package/dist/lib/pick-dataset.js +30 -0
- package/dist/lib/prompt.d.ts +35 -0
- package/dist/lib/prompt.js +11 -0
- package/dist/lib/read-fanout.d.ts +45 -0
- package/dist/lib/read-fanout.js +44 -0
- package/dist/lib/select-deployment.d.ts +31 -0
- package/dist/lib/select-deployment.js +91 -0
- package/dist/lib/share-definitions.d.ts +101 -0
- package/dist/lib/share-definitions.js +188 -0
- package/dist/lib/telemetry-setup.d.ts +81 -0
- package/dist/lib/telemetry-setup.js +111 -0
- package/dist/lib/telemetry.d.ts +81 -0
- package/dist/lib/telemetry.js +90 -0
- package/dist/lib/ui.d.ts +91 -0
- package/dist/lib/ui.js +116 -0
- package/dist/standalone-argv.d.ts +14 -0
- package/dist/standalone-argv.js +57 -0
- package/oclif.manifest.json +1731 -0
- package/package.json +121 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Discovery is deliberately soft: telemetry must never break or exit a
|
|
2
|
+
* command — a missing/broken config, token, or dataset just leaves it off. */
|
|
3
|
+
import { processShellUserProperties, type TelemetryIntakeClient } from '@sanity/workflows';
|
|
4
|
+
import { type WorkflowCliCommandContext } from './command-context.ts';
|
|
5
|
+
/** The get/set slice of the shared Sanity user config (cli-core's
|
|
6
|
+
* `getUserConfig`) the shell persists flags into — narrow so tests fake
|
|
7
|
+
* exactly what's read and written. */
|
|
8
|
+
export interface UserConfigStore {
|
|
9
|
+
get: (key: string) => unknown;
|
|
10
|
+
set: (key: string, value: unknown) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The one-time transparency notice, mirroring the sanity CLI's
|
|
14
|
+
* `telemetryDisclosure` — both CLIs feed the same pipeline. Written to
|
|
15
|
+
* stderr so it never garbles command output.
|
|
16
|
+
*/
|
|
17
|
+
export declare function maybeShowTelemetryDisclosure(args: {
|
|
18
|
+
userConfig: UserConfigStore;
|
|
19
|
+
writeStderr: (message: string) => void;
|
|
20
|
+
}): void;
|
|
21
|
+
/** The project a run's events are attributed to. */
|
|
22
|
+
export interface TelemetryProject {
|
|
23
|
+
projectId: string;
|
|
24
|
+
dataset?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
type TelemetryTarget = {
|
|
27
|
+
projectId?: string | undefined;
|
|
28
|
+
dataset?: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Assemble and install the invocation's shell: a config-provided
|
|
32
|
+
* `telemetry` logger replaces the built-in shell wholesale (none of its
|
|
33
|
+
* policy applies); otherwise the built-in Sanity-intake store is
|
|
34
|
+
* constructed whenever an auth token exists, with or without a config —
|
|
35
|
+
* mirroring the standard recipe's "not logged in → nothing sent". Events
|
|
36
|
+
* are attributed to the `--project-id` the run names, else the config's
|
|
37
|
+
* first dataset deployment, else to no project.
|
|
38
|
+
*
|
|
39
|
+
* The optional args exist for the hook's dependencies (config path, environment,
|
|
40
|
+
* user config, stderr) — omitted, the real process surfaces apply.
|
|
41
|
+
*/
|
|
42
|
+
export declare function setupCliTelemetry(args?: {
|
|
43
|
+
/** The command's `--path`; omitted, the search starts in the working directory. */
|
|
44
|
+
configPath?: string | undefined;
|
|
45
|
+
/** The command's `--project-id` and `--dataset`, which win over the config's project. */
|
|
46
|
+
target?: TelemetryTarget;
|
|
47
|
+
env?: Record<string, string | undefined>;
|
|
48
|
+
userConfig?: UserConfigStore;
|
|
49
|
+
writeStderr?: (message: string) => void;
|
|
50
|
+
/** This package's version — the prerun hook supplies it. */
|
|
51
|
+
cliVersion?: string | undefined;
|
|
52
|
+
/** Override the environment denial (CI / `DO_NOT_TRACK`) — the prerun hook
|
|
53
|
+
* sets this for a deploy that may share definitions, either by default or
|
|
54
|
+
* through `--share-defs`. */
|
|
55
|
+
forceSend?: boolean;
|
|
56
|
+
/** Intake client override — tests inject a fake here, like the other
|
|
57
|
+
* hook dependencies above; omitted, the real project client applies. */
|
|
58
|
+
client?: TelemetryIntakeClient;
|
|
59
|
+
/** Omitted, the trace reports no command path and no flag values. */
|
|
60
|
+
context?: WorkflowCliCommandContext;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* The invocation's environment user properties — the sanity CLI's precedent
|
|
64
|
+
* set (versions, platform, runtime, and project coordinates when a project is
|
|
65
|
+
* known). `orgId` — which
|
|
66
|
+
* Studio's shell sends and the sanity CLI doesn't yet — attaches separately
|
|
67
|
+
* once {@link resolveOrgId} resolves. Joined to the session's events by
|
|
68
|
+
* sessionId downstream; user identity stays sink-side.
|
|
69
|
+
*/
|
|
70
|
+
export declare function cliUserProperties(args: {
|
|
71
|
+
project: TelemetryProject | undefined;
|
|
72
|
+
cliVersion: string | undefined;
|
|
73
|
+
}): ReturnType<typeof processShellUserProperties> & {
|
|
74
|
+
cliVersion?: string;
|
|
75
|
+
projectId?: string;
|
|
76
|
+
dataset?: string;
|
|
77
|
+
};
|
|
78
|
+
/** The intake project's organization id — degrade-soft: a failed, slow, or
|
|
79
|
+
* org-less lookup resolves undefined, never rejects, never breaks a command. */
|
|
80
|
+
export declare function resolveOrgId(client: TelemetryIntakeClient, projectId: string): Promise<string | undefined>;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
|
+
import { getUserConfig } from '@sanity/cli-core';
|
|
3
|
+
import { datasetResourceParts, processShellUserProperties, } from '@sanity/workflows';
|
|
4
|
+
import boxen from 'boxen';
|
|
5
|
+
import { globalClient, resolveToken } from './client.js';
|
|
6
|
+
import { commandTraceContext } from './command-context.js';
|
|
7
|
+
import { loadWorkflowConfigIfPresent } from './load-config.js';
|
|
8
|
+
import { createBuiltinTelemetry, raceWithDeadline, setCliTelemetry } from './telemetry.js';
|
|
9
|
+
const DISCLOSURE_KEY = 'workflowCliTelemetryDisclosed';
|
|
10
|
+
const SANITY_CLI_DISCLOSURE_KEY = 'telemetryDisclosed';
|
|
11
|
+
export function maybeShowTelemetryDisclosure(args) {
|
|
12
|
+
const { userConfig, writeStderr } = args;
|
|
13
|
+
if (userConfig.get(DISCLOSURE_KEY) !== undefined ||
|
|
14
|
+
userConfig.get(SANITY_CLI_DISCLOSURE_KEY) !== undefined) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
writeStderr(`${boxen(`The Sanity workflow CLI collects telemetry data on general usage and errors.
|
|
18
|
+
This helps us improve workflows and prioritize features.
|
|
19
|
+
|
|
20
|
+
To opt in/out, run ${styleText('cyan', 'npx sanity telemetry enable/disable')}.
|
|
21
|
+
Learn more: https://www.sanity.io/telemetry`, { borderColor: 'yellow', borderStyle: 'round', margin: 1, padding: 1 })}\n`);
|
|
22
|
+
userConfig.set(DISCLOSURE_KEY, Date.now());
|
|
23
|
+
}
|
|
24
|
+
function configProject(config) {
|
|
25
|
+
const resource = config?.deployments
|
|
26
|
+
.map((deployment) => deployment.workflowResource)
|
|
27
|
+
.find((candidate) => candidate.type === 'dataset');
|
|
28
|
+
return resource === undefined ? undefined : datasetResourceParts(resource.id);
|
|
29
|
+
}
|
|
30
|
+
export async function setupCliTelemetry(args) {
|
|
31
|
+
const env = args?.env ?? process.env;
|
|
32
|
+
const context = args?.context ??
|
|
33
|
+
commandTraceContext({
|
|
34
|
+
commandId: undefined,
|
|
35
|
+
argv: process.argv.slice(2),
|
|
36
|
+
flagDefs: undefined,
|
|
37
|
+
commandTelemetry: undefined,
|
|
38
|
+
env,
|
|
39
|
+
});
|
|
40
|
+
try {
|
|
41
|
+
const config = await loadWorkflowConfigIfPresent(args?.configPath).catch(() => undefined);
|
|
42
|
+
if (config?.telemetry !== undefined) {
|
|
43
|
+
setCliTelemetry({ kind: 'provided', logger: config.telemetry }, context);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const token = await resolveToken().catch(() => undefined);
|
|
47
|
+
if (token === undefined) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const project = targetProject(args?.target) ?? configProject(config);
|
|
51
|
+
const client = args?.client ?? globalClient(token);
|
|
52
|
+
const telemetry = createBuiltinTelemetry({
|
|
53
|
+
client,
|
|
54
|
+
projectId: project?.projectId,
|
|
55
|
+
env,
|
|
56
|
+
forceSend: args?.forceSend ?? false,
|
|
57
|
+
packageVersion: args?.cliVersion,
|
|
58
|
+
});
|
|
59
|
+
setCliTelemetry(telemetry, context);
|
|
60
|
+
attachBuiltinContext({ telemetry, project, client, deps: args });
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function targetProject(target) {
|
|
66
|
+
return target?.projectId === undefined
|
|
67
|
+
? undefined
|
|
68
|
+
: { projectId: target.projectId, dataset: target.dataset };
|
|
69
|
+
}
|
|
70
|
+
function attachBuiltinContext(args) {
|
|
71
|
+
const { telemetry, project, client, deps } = args;
|
|
72
|
+
if (!telemetry.envDenied || telemetry.forceSend) {
|
|
73
|
+
telemetry.store.logger.updateUserProperties(cliUserProperties({ project, cliVersion: deps?.cliVersion }));
|
|
74
|
+
if (project !== undefined) {
|
|
75
|
+
void resolveOrgId(client, project.projectId).then((orgId) => {
|
|
76
|
+
if (orgId !== undefined)
|
|
77
|
+
telemetry.store.logger.updateUserProperties({ orgId });
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!telemetry.envDenied) {
|
|
82
|
+
maybeShowTelemetryDisclosure({
|
|
83
|
+
userConfig: deps?.userConfig ?? getUserConfig(),
|
|
84
|
+
writeStderr: deps?.writeStderr ?? ((message) => void process.stderr.write(message)),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const ORG_LOOKUP_DEADLINE_MS = 2_000;
|
|
89
|
+
const CONTEXT_TAG = 'telemetry.context';
|
|
90
|
+
export function cliUserProperties(args) {
|
|
91
|
+
const { project, cliVersion } = args;
|
|
92
|
+
return {
|
|
93
|
+
...processShellUserProperties('cli'),
|
|
94
|
+
...(cliVersion !== undefined ? { cliVersion } : {}),
|
|
95
|
+
...(project !== undefined ? { projectId: project.projectId } : {}),
|
|
96
|
+
...(project?.dataset !== undefined ? { dataset: project.dataset } : {}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export async function resolveOrgId(client, projectId) {
|
|
100
|
+
try {
|
|
101
|
+
const project = await raceWithDeadline(client.request({
|
|
102
|
+
url: `/projects/${encodeURIComponent(projectId)}`,
|
|
103
|
+
tag: CONTEXT_TAG,
|
|
104
|
+
timeout: ORG_LOOKUP_DEADLINE_MS,
|
|
105
|
+
}), ORG_LOOKUP_DEADLINE_MS);
|
|
106
|
+
return project?.organizationId ?? undefined;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Payload policy under https://www.sanity.io/telemetry: option flags as `--name=value`;
|
|
2
|
+
* booleans, redacted, and undeclared flags by name only; never raw argv or error text. */
|
|
3
|
+
import { type DefinedTelemetryTrace, type TelemetryStore } from '@sanity/telemetry';
|
|
4
|
+
import { type DerivedEventData, type TelemetryIntakeClient, type WorkflowDefinitionDeployedData, type WorkflowTelemetryLogger } from '@sanity/workflows';
|
|
5
|
+
import type { WorkflowCliCommandContext } from './command-context.ts';
|
|
6
|
+
import type { CliFailureKind } from './failure-kind.ts';
|
|
7
|
+
export interface WorkflowCliCommandResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
/** Present only when `success` is false. */
|
|
10
|
+
failureKind?: CliFailureKind;
|
|
11
|
+
}
|
|
12
|
+
export declare const WorkflowCliCommandExecuted: DefinedTelemetryTrace<WorkflowCliCommandResult, void>;
|
|
13
|
+
export type WorkflowDefinitionSharedData = Omit<DerivedEventData<WorkflowDefinitionDeployedData>, 'status'>;
|
|
14
|
+
export declare const WorkflowDefinitionShared: import("@sanity/telemetry").DefinedTelemetryLog<WorkflowDefinitionSharedData>;
|
|
15
|
+
/**
|
|
16
|
+
* How the donation decision was reached, and what it was. Paired with `shared`
|
|
17
|
+
* (whether it actually reached the endpoint) this keeps every case distinct —
|
|
18
|
+
* an explicit opt-out vs default sharing, and a chosen share vs a failed POST:
|
|
19
|
+
* - `opt-in` / `opt-out` — an explicit `--share-defs` / `--no-share-defs`.
|
|
20
|
+
* - `default` — no sharing flag; definitions are donated in every environment.
|
|
21
|
+
*/
|
|
22
|
+
export type DefinitionSharingDecision = 'opt-in' | 'opt-out' | 'default';
|
|
23
|
+
export interface WorkflowDefinitionSharingDecidedData {
|
|
24
|
+
decision: DefinitionSharingDecision;
|
|
25
|
+
/** Whether the donation actually reached the feedback endpoint — `false` for
|
|
26
|
+
* any non-sharing decision, and also for a chosen share whose POST failed. */
|
|
27
|
+
shared: boolean;
|
|
28
|
+
/** Newly created definition versions this invocation could have donated. */
|
|
29
|
+
definitionCount: number;
|
|
30
|
+
}
|
|
31
|
+
export declare const WorkflowDefinitionSharingDecided: import("@sanity/telemetry").DefinedTelemetryLog<WorkflowDefinitionSharingDecidedData>;
|
|
32
|
+
/**
|
|
33
|
+
* The shell for one CLI invocation. `builtin` is the Sanity-intake store;
|
|
34
|
+
* `provided` is a config-supplied logger that replaces the shell and its
|
|
35
|
+
* policy wholesale; `off` (the default) emits nothing — no config-derived
|
|
36
|
+
* project, no auth token, or telemetry setup failed.
|
|
37
|
+
*/
|
|
38
|
+
export type CliTelemetry = {
|
|
39
|
+
kind: 'builtin';
|
|
40
|
+
logger: WorkflowTelemetryLogger;
|
|
41
|
+
store: TelemetryStore<unknown>;
|
|
42
|
+
envDenied: boolean;
|
|
43
|
+
/** The environment denial was overridden ({@link createBuiltinTelemetry}):
|
|
44
|
+
* the store sends despite CI / `DO_NOT_TRACK`, subject only to
|
|
45
|
+
* account consent. */
|
|
46
|
+
forceSend: boolean;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'provided';
|
|
49
|
+
logger: WorkflowTelemetryLogger;
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'off';
|
|
52
|
+
logger: WorkflowTelemetryLogger;
|
|
53
|
+
};
|
|
54
|
+
export declare function cliTelemetry(): CliTelemetry;
|
|
55
|
+
/** Install the shell and, for the built-in store, start the command trace. */
|
|
56
|
+
export declare function setCliTelemetry(telemetry: Exclude<CliTelemetry, {
|
|
57
|
+
kind: 'off';
|
|
58
|
+
}>, context: WorkflowCliCommandContext): void;
|
|
59
|
+
export declare function clearCliTelemetry(): void;
|
|
60
|
+
/** Build the built-in Sanity-intake shell over an authenticated client. `forceSend` overrides the environment denial
|
|
61
|
+
* (CI / `DO_NOT_TRACK`) when a deploy may share definitions—flagless by
|
|
62
|
+
* default or explicitly enabled. Account-level consent is unaffected: the intake still fetches
|
|
63
|
+
* `/intake/telemetry-status`, so `sanity telemetry disable` still mutes. */
|
|
64
|
+
export declare function createBuiltinTelemetry(args: {
|
|
65
|
+
client: TelemetryIntakeClient;
|
|
66
|
+
projectId: string | undefined;
|
|
67
|
+
env: Record<string, string | undefined>;
|
|
68
|
+
forceSend?: boolean;
|
|
69
|
+
packageVersion?: string | undefined;
|
|
70
|
+
}): Extract<CliTelemetry, {
|
|
71
|
+
kind: 'builtin';
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Race `work` against a deadline, resolving `undefined` when the deadline
|
|
75
|
+
* wins. The timer is always cleared once the race settles — oclif never
|
|
76
|
+
* force-exits on success, so a pending timer would hold a finished process
|
|
77
|
+
* open. The losing promise's eventual settlement is absorbed by the race.
|
|
78
|
+
*/
|
|
79
|
+
export declare function raceWithDeadline<T>(work: Promise<T>, deadlineMs: number): Promise<T | undefined>;
|
|
80
|
+
/** Complete the command trace and flush. A provided logger owns its own delivery. */
|
|
81
|
+
export declare function finishCliTelemetry(result: WorkflowCliCommandResult): Promise<void>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createBatchedStore, createSessionId, defineEvent, defineTrace, } from '@sanity/telemetry';
|
|
2
|
+
import { createTelemetryIntake, _resolveTelemetryEnvironment, isTelemetryEnvDenied, noopTelemetry, } from '@sanity/workflows';
|
|
3
|
+
export const WorkflowCliCommandExecuted = defineTrace({
|
|
4
|
+
name: 'Workflows CLI Command Executed',
|
|
5
|
+
version: 3,
|
|
6
|
+
description: 'A Workflows CLI command was executed — the trace context carries the command path and each flag used in canonical long form (an option flag as `--name=value`, a boolean as `--name` or `--no-name`, a redacted or undeclared flag as its name only), and the payload carries a success flag plus, on failure, a closed failure kind (an engine error kind, or usage, auth-missing, permission-denied, resource-not-found, request-failed, config-invalid, definition-file-invalid, or other)',
|
|
7
|
+
});
|
|
8
|
+
export const WorkflowDefinitionShared = defineEvent({
|
|
9
|
+
name: 'Workflows CLI Definition Shared',
|
|
10
|
+
version: 1,
|
|
11
|
+
description: 'A newly created workflow definition version was donated to Sanity. Content-free marker: the content hash plus the same structural counts Workflows Engine Definition Deployed carries — the document itself goes to the first-party definition-feedback endpoint, never through telemetry.',
|
|
12
|
+
});
|
|
13
|
+
export const WorkflowDefinitionSharingDecided = defineEvent({
|
|
14
|
+
name: 'Workflows CLI Definition Sharing Decided',
|
|
15
|
+
version: 2,
|
|
16
|
+
description: 'One per deploy invocation that created new definition versions: whether donation followed the default or an explicit flag, whether anything reached the endpoint, and how many versions were eligible. Content-free — measures the true opt-out rate without ever carrying the document.',
|
|
17
|
+
});
|
|
18
|
+
const OFF = { kind: 'off', logger: noopTelemetry };
|
|
19
|
+
let session;
|
|
20
|
+
export function cliTelemetry() {
|
|
21
|
+
return session?.telemetry ?? OFF;
|
|
22
|
+
}
|
|
23
|
+
export function setCliTelemetry(telemetry, context) {
|
|
24
|
+
const trace = telemetry.kind === 'builtin'
|
|
25
|
+
? telemetry.store.logger.trace(WorkflowCliCommandExecuted, context)
|
|
26
|
+
: undefined;
|
|
27
|
+
trace?.start();
|
|
28
|
+
session = { telemetry, context, trace };
|
|
29
|
+
}
|
|
30
|
+
export function clearCliTelemetry() {
|
|
31
|
+
session = undefined;
|
|
32
|
+
}
|
|
33
|
+
export function createBuiltinTelemetry(args) {
|
|
34
|
+
const { client, projectId, env, forceSend = false, packageVersion } = args;
|
|
35
|
+
const envDenied = isTelemetryEnvDenied(env);
|
|
36
|
+
const store = createBatchedStore(createSessionId(), createTelemetryIntake({
|
|
37
|
+
client,
|
|
38
|
+
projectId: projectId ?? '',
|
|
39
|
+
denied: forceSend ? false : envDenied,
|
|
40
|
+
context: {
|
|
41
|
+
surface: 'cli',
|
|
42
|
+
environment: _resolveTelemetryEnvironment(env.NODE_ENV, 'production'),
|
|
43
|
+
...(packageVersion !== undefined ? { packageVersion } : {}),
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
46
|
+
return { kind: 'builtin', logger: store.logger, store, envDenied, forceSend };
|
|
47
|
+
}
|
|
48
|
+
function traceAsLogEvent(trace) {
|
|
49
|
+
const { name, version, description } = trace;
|
|
50
|
+
return { type: 'log', name, version, description };
|
|
51
|
+
}
|
|
52
|
+
const FLUSH_DEADLINE_MS = 3_000;
|
|
53
|
+
export async function raceWithDeadline(work, deadlineMs) {
|
|
54
|
+
let deadline;
|
|
55
|
+
try {
|
|
56
|
+
return await Promise.race([
|
|
57
|
+
work,
|
|
58
|
+
new Promise((resolve) => {
|
|
59
|
+
deadline = setTimeout(() => resolve(undefined), deadlineMs);
|
|
60
|
+
}),
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
clearTimeout(deadline);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export async function finishCliTelemetry(result) {
|
|
68
|
+
if (session === undefined)
|
|
69
|
+
return;
|
|
70
|
+
const { telemetry, context, trace } = session;
|
|
71
|
+
if (telemetry.kind === 'provided') {
|
|
72
|
+
telemetry.logger.log(traceAsLogEvent(WorkflowCliCommandExecuted), {
|
|
73
|
+
...context,
|
|
74
|
+
...result,
|
|
75
|
+
});
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (trace !== undefined) {
|
|
79
|
+
trace.log(result);
|
|
80
|
+
trace.complete();
|
|
81
|
+
session = { ...session, trace: undefined };
|
|
82
|
+
}
|
|
83
|
+
const { store } = telemetry;
|
|
84
|
+
try {
|
|
85
|
+
await raceWithDeadline(store.flush(), FLUSH_DEADLINE_MS);
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
store.end();
|
|
89
|
+
}
|
|
90
|
+
}
|
package/dist/lib/ui.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
|
+
import type { ActivityStatus, WorkflowResource } from '@sanity/workflows';
|
|
3
|
+
/**
|
|
4
|
+
* A bold `Title:` section heading. Mirrors the Sanity CLI's `sectionHeader`
|
|
5
|
+
* (name + shape) so it folds into the shared helper when this CLI merges in.
|
|
6
|
+
*/
|
|
7
|
+
export declare function sectionHeader(title: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Wraps `lines` to `width` columns, keeping each line's indent (its leading
|
|
10
|
+
* spaces and a list glyph) as the hanging indent of its continuation lines,
|
|
11
|
+
* so a wrapped line stays at its level. Lines pass through untouched when
|
|
12
|
+
* `width` is undefined.
|
|
13
|
+
*/
|
|
14
|
+
export declare function wrapLines(lines: readonly string[], width: number | undefined): string[];
|
|
15
|
+
/** The column count of the terminal on stdout; `undefined` when stdout is
|
|
16
|
+
* not a terminal, so piped output is never wrapped. */
|
|
17
|
+
export declare function terminalWidth(): number | undefined;
|
|
18
|
+
/** `1 guard`, `2 guards`: a count with its noun, regular plurals only. */
|
|
19
|
+
export declare function pluralize(count: number, noun: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* A ` key: value` detail row — a dim, padded key then the value. Mirrors
|
|
22
|
+
* the Sanity CLI's `formatKeyValue` so it folds into the shared helper on
|
|
23
|
+
* merge; pass `padTo` (the longest key's length) to align a block of rows.
|
|
24
|
+
*
|
|
25
|
+
* Pass `emphasis` (a {@link styleText} colour) to render the whole row — key
|
|
26
|
+
* and value together — bold in that colour instead of the dim-key default, so
|
|
27
|
+
* a standout row (a terminal instance status) pops from the neutral rows.
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatKeyValue({ key, value, indent, padTo, emphasis, }: {
|
|
30
|
+
key: string;
|
|
31
|
+
value: string;
|
|
32
|
+
indent?: number;
|
|
33
|
+
padTo?: number;
|
|
34
|
+
emphasis?: Parameters<typeof styleText>[0];
|
|
35
|
+
}): string;
|
|
36
|
+
/**
|
|
37
|
+
* A borderless column table as printable lines: cyan header row, every
|
|
38
|
+
* column padded to its widest cell, columns joined by three spaces.
|
|
39
|
+
* Mirrors the Sanity CLI's list-table shape (see `projects list`) so it
|
|
40
|
+
* folds into the shared helper when this CLI merges in. Widths count
|
|
41
|
+
* visible characters, so a pre-styled (ANSI) cell still pads correctly.
|
|
42
|
+
*/
|
|
43
|
+
export declare function formatTable(headers: string[], rows: string[][]): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Clip a probe-fetched result back to `limit`. The list query builders
|
|
46
|
+
* fetch one row past the display limit; when that probe row comes back,
|
|
47
|
+
* `note` carries the dim "showing the first N" hint to print under the table.
|
|
48
|
+
*/
|
|
49
|
+
export declare function clipToLimit<T>(rows: T[], limit: number): {
|
|
50
|
+
rows: T[];
|
|
51
|
+
note?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The shared tail of a list command: {@link clipToLimit} the probe-fetched
|
|
55
|
+
* rows, render them through {@link formatTable}, print every line, and print
|
|
56
|
+
* the clip note (when present) beneath the table.
|
|
57
|
+
*/
|
|
58
|
+
export declare function logClippedTable<T>({ rows, limit, moreAvailable, headers, toCells, log, }: {
|
|
59
|
+
rows: T[];
|
|
60
|
+
limit: number;
|
|
61
|
+
moreAvailable?: boolean;
|
|
62
|
+
headers: string[];
|
|
63
|
+
toCells: (row: T) => string[];
|
|
64
|
+
log: (line: string) => void;
|
|
65
|
+
}): void;
|
|
66
|
+
/**
|
|
67
|
+
* The `▸ label` banner printed above a group's output when a run spans
|
|
68
|
+
* several groups (deployments for deploy, resources for fanned-out reads),
|
|
69
|
+
* so each block is attributable. `undefined` for a lone group — it keeps its
|
|
70
|
+
* original unprefixed output. A leading blank line separates every group
|
|
71
|
+
* after the first.
|
|
72
|
+
*/
|
|
73
|
+
export declare function groupBanner({ label, index, total, }: {
|
|
74
|
+
label: string;
|
|
75
|
+
index: number;
|
|
76
|
+
total: number;
|
|
77
|
+
}): string | undefined;
|
|
78
|
+
/** A workflow resource as a display label: a dataset's `project.dataset` id
|
|
79
|
+
* reads naturally bare; other resource types keep their type for clarity. */
|
|
80
|
+
export declare function resourceLabel(resource: WorkflowResource): string;
|
|
81
|
+
/** Where a read looked, for an empty result: `in partition prod of acme.workflows (deployment prod)`. */
|
|
82
|
+
export declare function searchedScope(args: {
|
|
83
|
+
partition: string | undefined;
|
|
84
|
+
resources: readonly WorkflowResource[];
|
|
85
|
+
deployment: string | undefined;
|
|
86
|
+
}): string;
|
|
87
|
+
/** Status glyph per activity state. log-symbols ship pre-colored (green ✔, red ✖),
|
|
88
|
+
* so those need no extra wrap; the rest carry their own state color. */
|
|
89
|
+
export declare const activityIcon: Record<ActivityStatus, string>;
|
|
90
|
+
/** Advisory warnings indented beneath the definition line they belong to. */
|
|
91
|
+
export declare function warningLines(warnings: readonly string[] | undefined): string[];
|
package/dist/lib/ui.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { stripVTControlCharacters, styleText } from 'node:util';
|
|
2
|
+
import logSymbols from 'log-symbols';
|
|
3
|
+
import wrapAnsi from 'wrap-ansi';
|
|
4
|
+
export function sectionHeader(title) {
|
|
5
|
+
return styleText('bold', `${title}:`);
|
|
6
|
+
}
|
|
7
|
+
const MIN_WRAP_WIDTH = 40;
|
|
8
|
+
const LIST_GLYPHS = new Set(['→', '▸', ...Object.values(logSymbols)].map((glyph) => stripVTControlCharacters(glyph)));
|
|
9
|
+
export function wrapLines(lines, width) {
|
|
10
|
+
if (width === undefined)
|
|
11
|
+
return [...lines];
|
|
12
|
+
return lines.flatMap((line) => wrapLine(line, width));
|
|
13
|
+
}
|
|
14
|
+
export function terminalWidth() {
|
|
15
|
+
return process.stdout.isTTY ? process.stdout.columns : undefined;
|
|
16
|
+
}
|
|
17
|
+
function wrapLine(line, width) {
|
|
18
|
+
const hang = hangingIndent(line);
|
|
19
|
+
const [prefix, body] = splitAtVisibleColumn(line, hang.length);
|
|
20
|
+
const wrapped = wrapAnsi(body, Math.max(width - hang.length, MIN_WRAP_WIDTH), { trim: false });
|
|
21
|
+
return wrapped
|
|
22
|
+
.split('\n')
|
|
23
|
+
.map((part, index) => (index === 0 ? prefix + part : hang + part.trimStart()).trimEnd());
|
|
24
|
+
}
|
|
25
|
+
function splitAtVisibleColumn(line, columns) {
|
|
26
|
+
let index = 0;
|
|
27
|
+
let seen = 0;
|
|
28
|
+
while (seen < columns && index < line.length) {
|
|
29
|
+
const escape = styleEscapeLength(line, index);
|
|
30
|
+
if (escape > 0) {
|
|
31
|
+
index += escape;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
index += String.fromCodePoint(line.codePointAt(index) ?? 0).length;
|
|
35
|
+
seen += 1;
|
|
36
|
+
}
|
|
37
|
+
return [line.slice(0, index), line.slice(index)];
|
|
38
|
+
}
|
|
39
|
+
const ESCAPE = 0x1b;
|
|
40
|
+
function styleEscapeLength(line, index) {
|
|
41
|
+
if (line.charCodeAt(index) !== ESCAPE || line[index + 1] !== '[')
|
|
42
|
+
return 0;
|
|
43
|
+
const end = line.indexOf('m', index);
|
|
44
|
+
return end === -1 ? 0 : end - index + 1;
|
|
45
|
+
}
|
|
46
|
+
function hangingIndent(line) {
|
|
47
|
+
const [, spaces = '', glyph] = /^( *)(?:(\S) )?/.exec(stripVTControlCharacters(line)) ?? [];
|
|
48
|
+
const glyphWidth = glyph !== undefined && LIST_GLYPHS.has(glyph) ? 2 : 0;
|
|
49
|
+
return ' '.repeat(spaces.length + glyphWidth);
|
|
50
|
+
}
|
|
51
|
+
export function pluralize(count, noun) {
|
|
52
|
+
return `${count} ${noun}${count === 1 ? '' : 's'}`;
|
|
53
|
+
}
|
|
54
|
+
export function formatKeyValue({ key, value, indent = 2, padTo = 0, emphasis, }) {
|
|
55
|
+
const paddedKey = `${key}:`.padEnd(padTo > 0 ? padTo + 1 : key.length + 1);
|
|
56
|
+
const pad = ' '.repeat(indent);
|
|
57
|
+
if (emphasis) {
|
|
58
|
+
return `${pad}${styleText('bold', styleText(emphasis, `${paddedKey} ${value}`))}`;
|
|
59
|
+
}
|
|
60
|
+
return `${pad}${styleText('dim', paddedKey)} ${value}`;
|
|
61
|
+
}
|
|
62
|
+
export function formatTable(headers, rows) {
|
|
63
|
+
const width = (cell) => stripVTControlCharacters(cell).length;
|
|
64
|
+
const widths = headers.map((header, i) => Math.max(width(header), ...rows.map((row) => width(row[i] ?? ''))));
|
|
65
|
+
const formatRow = (row) => widths
|
|
66
|
+
.map((columnWidth, i) => {
|
|
67
|
+
const cell = row[i] ?? '';
|
|
68
|
+
return cell + ' '.repeat(columnWidth - width(cell));
|
|
69
|
+
})
|
|
70
|
+
.join(' ')
|
|
71
|
+
.trimEnd();
|
|
72
|
+
return [styleText('cyan', formatRow(headers)), ...rows.map(formatRow)];
|
|
73
|
+
}
|
|
74
|
+
export function clipToLimit(rows, limit) {
|
|
75
|
+
if (rows.length <= limit) {
|
|
76
|
+
return { rows };
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
rows: rows.slice(0, limit),
|
|
80
|
+
note: styleText('dim', `showing the first ${limit} — raise --limit to see more`),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export function logClippedTable({ rows, limit, moreAvailable, headers, toCells, log, }) {
|
|
84
|
+
const { rows: clipped, note } = clipToLimit(rows, limit);
|
|
85
|
+
for (const line of formatTable(headers, clipped.map(toCells))) {
|
|
86
|
+
log(line);
|
|
87
|
+
}
|
|
88
|
+
if (note || moreAvailable) {
|
|
89
|
+
log(note ??
|
|
90
|
+
styleText('dim', `searched the first ${limit} candidates — raise --limit to see more`));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function groupBanner({ label, index, total, }) {
|
|
94
|
+
if (total <= 1) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
const gap = index > 0 ? '\n' : '';
|
|
98
|
+
return `${gap}${styleText('bold', `▸ ${label}`)}`;
|
|
99
|
+
}
|
|
100
|
+
export function resourceLabel(resource) {
|
|
101
|
+
return resource.type === 'dataset' ? resource.id : `${resource.type}:${resource.id}`;
|
|
102
|
+
}
|
|
103
|
+
export function searchedScope(args) {
|
|
104
|
+
const partition = args.partition === undefined ? 'any partition' : `partition ${args.partition}`;
|
|
105
|
+
const deployment = args.deployment === undefined ? '' : ` (deployment ${args.deployment})`;
|
|
106
|
+
return `in ${partition} of ${args.resources.map(resourceLabel).join(', ')}${deployment}`;
|
|
107
|
+
}
|
|
108
|
+
export const activityIcon = {
|
|
109
|
+
done: logSymbols.success,
|
|
110
|
+
active: styleText('cyan', '●'),
|
|
111
|
+
failed: logSymbols.error,
|
|
112
|
+
skipped: styleText('dim', '⊘'),
|
|
113
|
+
};
|
|
114
|
+
export function warningLines(warnings) {
|
|
115
|
+
return (warnings ?? []).map((w) => ` ${logSymbols.warning} ${w}`);
|
|
116
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First argv tokens that belong under {@link WORKFLOWS_TOPIC}.
|
|
3
|
+
* Keep in sync with `src/commands/workflows/` (top-level command
|
|
4
|
+
* files plus the `blueprints`, `codemod`, and `definitions` subtopic directories).
|
|
5
|
+
*/
|
|
6
|
+
export declare const STANDALONE_ROOT_COMMANDS: readonly ['abort', 'blueprints', 'codemod', 'definitions', 'deploy', 'diagnose', 'fire-action', 'list', 'nuke', 'reset-activity', 'show', 'start', 'tail', 'whoami'];
|
|
7
|
+
/** Index of the first argv token that is not a flag (and not `--`). */
|
|
8
|
+
export declare function firstPositionalIndex(args: string[]): number;
|
|
9
|
+
/**
|
|
10
|
+
* Rewrite standalone CLI args so short forms resolve to topic-scoped command
|
|
11
|
+
* ids. Idempotent when the topic is already present. Unknown first tokens are
|
|
12
|
+
* left alone so oclif's own "command not found" path still runs.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rewriteStandaloneArgv(args: string[]): string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { WORKFLOWS_TOPIC } from './command-ids.js';
|
|
2
|
+
export const STANDALONE_ROOT_COMMANDS = [
|
|
3
|
+
'abort',
|
|
4
|
+
'blueprints',
|
|
5
|
+
'codemod',
|
|
6
|
+
'definitions',
|
|
7
|
+
'deploy',
|
|
8
|
+
'diagnose',
|
|
9
|
+
'fire-action',
|
|
10
|
+
'list',
|
|
11
|
+
'nuke',
|
|
12
|
+
'reset-activity',
|
|
13
|
+
'show',
|
|
14
|
+
'start',
|
|
15
|
+
'tail',
|
|
16
|
+
'whoami',
|
|
17
|
+
];
|
|
18
|
+
const STANDALONE_ALIAS_ROOTS = ['blueprint', 'definition'];
|
|
19
|
+
const rootCommandSet = new Set([...STANDALONE_ROOT_COMMANDS, ...STANDALONE_ALIAS_ROOTS]);
|
|
20
|
+
export function firstPositionalIndex(args) {
|
|
21
|
+
for (let i = 0; i < args.length; i++) {
|
|
22
|
+
const token = args[i];
|
|
23
|
+
if (token === undefined)
|
|
24
|
+
continue;
|
|
25
|
+
if (token === '--')
|
|
26
|
+
return i + 1 < args.length ? i + 1 : -1;
|
|
27
|
+
if (!token.startsWith('-'))
|
|
28
|
+
return i;
|
|
29
|
+
}
|
|
30
|
+
return -1;
|
|
31
|
+
}
|
|
32
|
+
function stripScriptArgSeparator(args) {
|
|
33
|
+
return args[0] === '--' ? args.slice(1) : args;
|
|
34
|
+
}
|
|
35
|
+
export function rewriteStandaloneArgv(args) {
|
|
36
|
+
const normalized = stripScriptArgSeparator(args);
|
|
37
|
+
const i = firstPositionalIndex(normalized);
|
|
38
|
+
if (i === -1)
|
|
39
|
+
return normalized;
|
|
40
|
+
const first = normalized[i];
|
|
41
|
+
if (first === undefined || first === WORKFLOWS_TOPIC)
|
|
42
|
+
return normalized;
|
|
43
|
+
if (first === 'help') {
|
|
44
|
+
const commandIndex = firstPositionalIndex(normalized.slice(i + 1));
|
|
45
|
+
if (commandIndex === -1)
|
|
46
|
+
return normalized;
|
|
47
|
+
const absolute = i + 1 + commandIndex;
|
|
48
|
+
const command = normalized[absolute];
|
|
49
|
+
if (command === undefined || command === WORKFLOWS_TOPIC || !rootCommandSet.has(command)) {
|
|
50
|
+
return normalized;
|
|
51
|
+
}
|
|
52
|
+
return [...normalized.slice(0, absolute), WORKFLOWS_TOPIC, ...normalized.slice(absolute)];
|
|
53
|
+
}
|
|
54
|
+
if (!rootCommandSet.has(first))
|
|
55
|
+
return normalized;
|
|
56
|
+
return [...normalized.slice(0, i), WORKFLOWS_TOPIC, ...normalized.slice(i)];
|
|
57
|
+
}
|