codemod 2.0.0-alpha.2 → 2.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ export declare function progress(message: string, meta?: unknown): void;
2
+ export declare function warn(message: string, meta?: unknown): void;
3
+ export declare function setCurrentUnit(_unitId: string, _meta?: unknown): void;
4
+ export declare function failFile(message: string, _meta?: unknown): never;
5
+ export declare function failStep(message: string, _meta?: unknown): never;
6
+ export declare function isCanceled(): boolean;
7
+ declare const runtime: {
8
+ progress: typeof progress;
9
+ warn: typeof warn;
10
+ setCurrentUnit: typeof setCurrentUnit;
11
+ failFile: typeof failFile;
12
+ failStep: typeof failStep;
13
+ isCanceled: typeof isCanceled;
14
+ };
15
+ export default runtime;
@@ -1,48 +1,40 @@
1
1
  // `codemod/runtime` in Node.js and Bun. Progress and warnings become the
2
2
  // step's log lines, written as the CLI writes them; failures throw, and stay
3
3
  // reported even when the code catches the error.
4
-
5
4
  import { context } from "./context.mjs";
6
-
7
5
  function text(message, what) {
8
- if (typeof message !== "string") throw new TypeError(`${what} expects a message string`);
9
- return message;
6
+ if (typeof message !== "string")
7
+ throw new TypeError(`${what} expects a message string`);
8
+ return message;
10
9
  }
11
-
12
10
  function log(prefix, message, meta) {
13
- const store = context.getStore();
14
- if (!store) return;
15
- const line = meta === undefined ? message : `${message} ${JSON.stringify(meta)}`;
16
- store.run.log(store.step?.position ?? null, `${prefix} ${line}`);
11
+ const store = context.getStore();
12
+ if (!store)
13
+ return;
14
+ const line = meta === undefined ? message : `${message} ${JSON.stringify(meta)}`;
15
+ store.run.log(store.step?.position ?? null, `${prefix} ${line}`);
17
16
  }
18
-
19
17
  export function progress(message, meta) {
20
- log("[progress]", text(message, "progress()"), meta);
18
+ log("[progress]", text(message, "progress()"), meta);
21
19
  }
22
-
23
20
  export function warn(message, meta) {
24
- log("[warn]", text(message, "warn()"), meta);
21
+ log("[warn]", text(message, "warn()"), meta);
25
22
  }
26
-
27
- export function setCurrentUnit(_unitId, _meta) {}
28
-
23
+ export function setCurrentUnit(_unitId, _meta) { }
29
24
  function fail(message, what) {
30
- const step = context.getStore()?.step;
31
- if (step) step.failure = text(message, what);
32
- throw new Error(text(message, what));
25
+ const step = context.getStore()?.step;
26
+ if (step)
27
+ step.failure = text(message, what);
28
+ throw new Error(text(message, what));
33
29
  }
34
-
35
30
  export function failFile(message, _meta) {
36
- fail(message, "failFile()");
31
+ fail(message, "failFile()");
37
32
  }
38
-
39
33
  export function failStep(message, _meta) {
40
- fail(message, "failStep()");
34
+ fail(message, "failStep()");
41
35
  }
42
-
43
36
  export function isCanceled() {
44
- return context.getStore()?.run.canceled() ?? false;
37
+ return context.getStore()?.run.canceled() ?? false;
45
38
  }
46
-
47
39
  const runtime = { progress, warn, setCurrentUnit, failFile, failStep, isCanceled };
48
40
  export default runtime;
@@ -0,0 +1,19 @@
1
+ import type { Callback, Duration, Json } from "./orchestrator.mts";
2
+ export { AwaitingApprovalError, CanceledError, StepError } from "./orchestrator.mts";
3
+ /** Identifies a callback given as a function, for replay checks. */
4
+ export declare function callbackId(fn: Callback): string;
5
+ export declare const __callback: (id: string, captures: () => Json) => import("./orchestrator.mts").CallbackReference, forEachFile: (selector: unknown, callback?: unknown) => import("./orchestrator.mts").ForEachFileTask | import("./orchestrator.mts").HostTask, shell: (command: unknown, ...rest: unknown[]) => import("./orchestrator.mts").HostTask | ((strings: TemplateStringsArray, ...values: unknown[]) => import("./orchestrator.mts").HostTask), jssg: (path: string, options?: object) => import("./orchestrator.mts").HostTask, astGrep: (path: string, options?: object) => import("./orchestrator.mts").HostTask, shard: (options: object) => import("./orchestrator.mts").HostTask, codemod: (source: string, options?: object) => import("./orchestrator.mts").HostTask, agent: (prompt: string, options?: object) => import("./orchestrator.mts").HostTask, installSkill: (options: object) => import("./orchestrator.mts").HostTask, approval: (message: string) => import("./orchestrator.mts").HostTask, branch: (name: string) => import("./orchestrator.mts").HostTask, commit: (message: string, options?: object) => import("./orchestrator.mts").HostTask, pullRequest: (options: object) => import("./orchestrator.mts").HostTask;
6
+ export declare function step(...args: unknown[]): Promise<Json>;
7
+ export declare function sleep(duration: Duration): Promise<Json>;
8
+ export declare function waitForEvent(name: string, options?: {
9
+ timeout?: Duration;
10
+ }): Promise<Json>;
11
+ export declare function getState(key?: string): unknown;
12
+ export declare function setState(key: string, value: unknown, persist?: boolean): void;
13
+ export declare function unsetState(key: string): void;
14
+ /** Callbacks run on one thread here, so a lock has nothing to wait for. */
15
+ export declare function acquireLock(name: string): () => void;
16
+ export declare function setStepOutput(name: string, value: unknown): void;
17
+ export declare function getStepOutput(stepId: string, name: string): string | null;
18
+ export declare function getOrSetStepOutput(stepId: string, name: string, value: unknown): string;
19
+ export declare function __evaluate(kind: string, expression: string, scope: unknown): unknown;
@@ -5,131 +5,122 @@
5
5
  // orchestrator. Inside a function step or a `forEachFile` callback, the state
6
6
  // functions see the state the step started with, and what they set becomes
7
7
  // the step's state changes, as in the engine's isolates.
8
-
9
8
  import { createHash } from "node:crypto";
10
-
11
9
  import { current } from "./context.mjs";
12
10
  import { createTasks } from "./orchestrator.mjs";
13
-
14
- export {
15
- AwaitingApprovalError,
16
- CanceledError,
17
- NondeterminismError,
18
- StepError,
19
- } from "./orchestrator.mjs";
20
-
11
+ export { AwaitingApprovalError, CanceledError, StepError } from "./orchestrator.mjs";
21
12
  /** Identifies a callback given as a function, for replay checks. */
22
13
  export function callbackId(fn) {
23
- return `fn:${createHash("sha256").update(String(fn)).digest("hex").slice(0, 16)}`;
14
+ return `fn:${createHash("sha256").update(String(fn)).digest("hex").slice(0, 16)}`;
24
15
  }
25
-
26
- export const {
27
- __callback,
28
- forEachFile,
29
- shell,
30
- jssg,
31
- astGrep,
32
- shard,
33
- codemod,
34
- agent,
35
- installSkill,
36
- approval,
37
- branch,
38
- commit,
39
- pullRequest,
40
- } = createTasks({ callbackId });
41
-
42
- export function step(labelOrTask, maybeTask) {
43
- const scope = current("step()");
44
- if (scope.step) {
45
- throw new Error(
46
- "step() cannot be called inside a step or forEachFile callback; start steps from the workflow body",
47
- );
48
- }
49
- return scope.runtime.step(labelOrTask, maybeTask);
16
+ export const { __callback, forEachFile, shell, jssg, astGrep, shard, codemod, agent, installSkill, approval, branch, commit, pullRequest, } = createTasks({ callbackId });
17
+ /** The run's orchestrator, for what only the workflow body may call. */
18
+ function body(what) {
19
+ const scope = current(what);
20
+ if (scope.step) {
21
+ throw new Error(`${what} cannot be called inside a step or forEachFile callback; call it from the workflow body`);
22
+ }
23
+ return scope.runtime;
24
+ }
25
+ export function step(...args) {
26
+ return body("step()").step(...args);
27
+ }
28
+ export function sleep(duration) {
29
+ return body("sleep()").sleep(duration);
30
+ }
31
+ export function waitForEvent(name, options) {
32
+ return body("waitForEvent()").waitForEvent(name, options);
50
33
  }
51
-
52
34
  // In a step or callback the state functions behave as in the engine's
53
35
  // isolates: values are copied in and out, and what the step leaves different
54
36
  // from the state it started with becomes its state changes.
55
-
56
37
  export function getState(key) {
57
- const scope = current("getState()");
58
- if (!scope.step) return scope.runtime.getState(key);
59
- const state = scope.step.state;
60
- if (key === undefined) return structuredClone(Object.fromEntries(state));
61
- return state.has(key) ? structuredClone(state.get(key)) : undefined;
38
+ const scope = current("getState()");
39
+ if (!scope.step)
40
+ return scope.runtime.getState(key);
41
+ const state = scope.step.state;
42
+ if (key === undefined)
43
+ return structuredClone(Object.fromEntries(state));
44
+ return state.has(key) ? structuredClone(state.get(key)) : undefined;
62
45
  }
63
-
64
46
  export function setState(key, value, persist = true) {
65
- const scope = current("setState()");
66
- if (!scope.step) return scope.runtime.setState(key, value);
67
- const step = scope.step;
68
- step.state.set(key, stateValue(value));
69
- step.removed.delete(key);
70
- if (persist) step.unpersisted.delete(key);
71
- else step.unpersisted.add(key);
47
+ const scope = current("setState()");
48
+ if (!scope.step)
49
+ return scope.runtime.setState(key, value);
50
+ const step = scope.step;
51
+ step.state.set(key, stateValue(value));
52
+ step.removed.delete(key);
53
+ if (persist)
54
+ step.unpersisted.delete(key);
55
+ else
56
+ step.unpersisted.add(key);
72
57
  }
73
-
74
58
  export function unsetState(key) {
75
- const scope = current("unsetState()");
76
- if (!scope.step) return scope.runtime.unsetState(key);
77
- scope.step.state.delete(key);
78
- scope.step.removed.add(key);
59
+ const scope = current("unsetState()");
60
+ if (!scope.step)
61
+ return scope.runtime.unsetState(key);
62
+ scope.step.state.delete(key);
63
+ scope.step.removed.add(key);
79
64
  }
80
-
81
65
  /**
82
66
  * A value as state keeps it, the way the engine's isolates convert one:
83
67
  * what is not JSON becomes `null`, and objects keep their own enumerable
84
68
  * properties (so a `Date` or a `Map` becomes `{}`).
85
69
  */
86
70
  function stateValue(value) {
87
- switch (typeof value) {
88
- case "boolean":
89
- case "string":
90
- return value;
91
- case "number":
92
- return Number.isFinite(value) ? value : null;
93
- case "bigint":
94
- return Number(value);
95
- case "object":
96
- if (value === null) return null;
97
- if (Array.isArray(value)) return value.map(stateValue);
98
- return Object.fromEntries(Object.keys(value).map((key) => [key, stateValue(value[key])]));
99
- default:
100
- return null;
101
- }
71
+ switch (typeof value) {
72
+ case "boolean":
73
+ case "string":
74
+ return value;
75
+ case "number":
76
+ return Number.isFinite(value) ? value : null;
77
+ case "bigint":
78
+ return Number(value);
79
+ case "object":
80
+ if (value === null)
81
+ return null;
82
+ if (Array.isArray(value))
83
+ return value.map(stateValue);
84
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
85
+ key,
86
+ stateValue(item),
87
+ ]));
88
+ default:
89
+ return null;
90
+ }
102
91
  }
103
-
104
92
  /** Callbacks run on one thread here, so a lock has nothing to wait for. */
105
93
  export function acquireLock(name) {
106
- const scope = current("acquireLock()");
107
- if (!scope.step) return scope.runtime.acquireLock(name);
108
- return () => {};
94
+ const scope = current("acquireLock()");
95
+ if (!scope.step)
96
+ return scope.runtime.acquireLock(name);
97
+ return () => { };
109
98
  }
110
-
111
99
  // Step outputs are kept for the transforms that still set them; nothing in a
112
100
  // workflow reads them back but these functions.
113
-
114
101
  export function setStepOutput(name, value) {
115
- const scope = current("setStepOutput()");
116
- if (!scope.step) return scope.runtime.setStepOutput(name, value);
117
- scope.step.outputs.set(name, String(value));
102
+ const scope = current("setStepOutput()");
103
+ if (!scope.step)
104
+ return scope.runtime.setStepOutput(name, value);
105
+ scope.step.outputs.set(name, String(value));
118
106
  }
119
-
120
107
  export function getStepOutput(stepId, name) {
121
- const scope = current("getStepOutput()");
122
- if (!scope.step) return scope.runtime.getStepOutput(stepId, name);
123
- return scope.step.outputs.get(name) ?? null;
108
+ const scope = current("getStepOutput()");
109
+ if (!scope.step)
110
+ return scope.runtime.getStepOutput(stepId, name);
111
+ return scope.step.outputs.get(name) ?? null;
124
112
  }
125
-
126
113
  export function getOrSetStepOutput(stepId, name, value) {
127
- const scope = current("getOrSetStepOutput()");
128
- if (!scope.step) return scope.runtime.getOrSetStepOutput(stepId, name, value);
129
- if (!scope.step.outputs.has(name)) scope.step.outputs.set(name, String(value));
130
- return scope.step.outputs.get(name);
114
+ const scope = current("getOrSetStepOutput()");
115
+ if (!scope.step)
116
+ return scope.runtime.getOrSetStepOutput(stepId, name, value);
117
+ const existing = scope.step.outputs.get(name);
118
+ if (existing !== undefined)
119
+ return existing;
120
+ const text = String(value);
121
+ scope.step.outputs.set(name, text);
122
+ return text;
131
123
  }
132
-
133
124
  export function __evaluate(kind, expression, scope) {
134
- return current("__evaluate()").runtime.__evaluate(kind, expression, scope);
125
+ return current("__evaluate()").runtime.__evaluate(kind, expression, scope);
135
126
  }
@@ -1,149 +1,131 @@
1
- /**
2
- * Run workflows from any test runner and compare the files they leave.
3
- *
4
- * ```ts
5
- * import { test } from "node:test";
6
- * import { runWorkflow, fixtures, assertTree } from "codemod/testing";
7
- *
8
- * for (const fixture of fixtures("tests")) {
9
- * test(fixture.name, async () => {
10
- * const run = await runWorkflow("workflow.ts", { target: fixture.input, params: fixture.params });
11
- * assertTree(run, fixture.expected);
12
- * });
13
- * }
14
- * ```
15
- *
16
- * Each run copies its target into a temporary directory first, so fixtures
17
- * are never changed. Paths are resolved against the current directory;
18
- * pass `new URL("./workflow.ts", import.meta.url)` to resolve against the
19
- * test file instead.
20
- *
21
- * TypeScript workflows run in the test's own process, so breakpoints,
22
- * coverage and mocks work in the workflow's code. `host: "quickjs"` runs them
23
- * with the codemod CLI instead, in the sandboxed runtime `codemod run` uses.
24
- *
25
- * @module
26
- */
27
-
28
- export type JsonValue =
29
- | string
30
- | number
31
- | boolean
32
- | null
33
- | JsonValue[]
34
- | { [key: string]: JsonValue };
35
-
1
+ export type JsonValue = string | number | boolean | null | JsonValue[] | {
2
+ [key: string]: JsonValue;
3
+ };
36
4
  /** File contents by path, relative to the target (`"src/a.ts"`). */
37
- export type FileTree = { readonly [path: string]: string };
38
-
5
+ export type FileTree = {
6
+ readonly [path: string]: string;
7
+ };
39
8
  /** A `URL` (`new URL("./tests", import.meta.url)`); only `file:` URLs are paths. */
40
9
  export interface UrlLike {
41
- readonly href: string;
10
+ readonly href: string;
42
11
  }
43
-
44
12
  /** A path, or a `file:` URL. */
45
13
  export type PathLike = string | UrlLike;
46
-
47
14
  /** An `AbortSignal`. */
48
15
  export interface AbortSignalLike {
49
- readonly aborted: boolean;
16
+ readonly aborted: boolean;
50
17
  }
51
-
52
18
  /** A workflow module: what `import("./workflow.ts")` gives. */
53
19
  export interface WorkflowModule {
54
- readonly default: (...args: never[]) => unknown;
20
+ readonly default: (...args: never[]) => unknown;
55
21
  }
56
-
57
22
  /** A capability a transform may use beyond those codemod.yaml declares. */
58
23
  export type Capability = "fs" | "fetch" | "child_process";
59
-
60
24
  export interface RunWorkflowOptions {
61
- /**
62
- * The files the workflow runs on: a directory or a single file (copied
63
- * first), or files by path.
64
- */
65
- target: PathLike | FileTree;
66
- /** The workflow's parameters. */
67
- params?: Record<string, JsonValue>;
68
- /**
69
- * Stop after the step with this label: steps the workflow starts after it
70
- * do not run. The run's status is then `"stopped"`.
71
- */
72
- until?: string;
73
- /**
74
- * Results for steps that should not run, by label. The workflow gets the
75
- * given value as the step's result.
76
- */
77
- given?: Record<string, JsonValue>;
78
- /** Give every approval the workflow asks for. Default `true`. */
79
- approve?: boolean;
80
- /** Capabilities granted on top of those codemod.yaml declares. */
81
- capabilities?: Capability[];
82
- /** Which workflow to run when codemod.yaml defines several. */
83
- workflowName?: string;
84
- /** Keep the temporary directory the run changed (`run.dir`). */
85
- keep?: boolean;
86
- /** Stops the run. */
87
- signal?: AbortSignalLike;
88
- /**
89
- * Where the workflow runs. `"node"` (the default for TypeScript workflows):
90
- * in this process. `"quickjs"`: with the codemod CLI, in the sandboxed
91
- * runtime `codemod run` uses, where capabilities are enforced. YAML
92
- * workflows always run with the CLI.
93
- */
94
- host?: "node" | "quickjs";
95
- /** The workflow file, when `workflow` is the module itself. */
96
- path?: PathLike;
25
+ /**
26
+ * The files the workflow runs on: a directory or a single file (copied
27
+ * first), or files by path.
28
+ */
29
+ target: PathLike | FileTree;
30
+ /** The workflow's parameters. */
31
+ params?: Record<string, JsonValue>;
32
+ /**
33
+ * Stop after the step with this label: steps the workflow starts after it
34
+ * do not run. The run's status is then `"stopped"`.
35
+ */
36
+ until?: string;
37
+ /**
38
+ * Results for steps that should not run, by label. The workflow gets the
39
+ * given value as the step's result.
40
+ */
41
+ given?: Record<string, JsonValue>;
42
+ /** Give every approval the workflow asks for. Default `true`. */
43
+ approve?: boolean;
44
+ /** Capabilities granted on top of those codemod.yaml declares. */
45
+ capabilities?: Capability[];
46
+ /** Which workflow to run when codemod.yaml defines several. */
47
+ workflowName?: string;
48
+ /** Keep the temporary directory the run changed (`run.dir`). */
49
+ keep?: boolean;
50
+ /** Stops the run. */
51
+ signal?: AbortSignalLike;
52
+ /**
53
+ * Where the workflow runs. `"node"` (the default for TypeScript workflows):
54
+ * in this process. `"quickjs"`: with the codemod CLI, in the sandboxed
55
+ * runtime `codemod run` uses, where capabilities are enforced. YAML
56
+ * workflows always run with the CLI.
57
+ */
58
+ host?: "node" | "quickjs";
59
+ /** The workflow file, when `workflow` is the module itself. */
60
+ path?: PathLike;
97
61
  }
98
-
99
62
  export type RunStatus = "succeeded" | "failed" | "canceled" | "awaiting-approval" | "stopped";
100
-
101
63
  export interface StepRun {
102
- readonly position: number;
103
- readonly label: string;
104
- readonly status: "succeeded" | "failed";
105
- readonly result: JsonValue | null;
106
- readonly error: string | null;
107
- /** The step did not run: its result came from `given`. */
108
- readonly given: boolean;
64
+ readonly position: number;
65
+ readonly label: string;
66
+ /**
67
+ * `"partial"`: the step finished, but some of its files failed; `error`
68
+ * says how many.
69
+ */
70
+ readonly status: "succeeded" | "partial" | "failed";
71
+ readonly result: JsonValue | null;
72
+ readonly error: string | null;
73
+ /** The step did not run: its result came from `given`. */
74
+ readonly given: boolean;
109
75
  }
110
-
111
76
  export interface LogLine {
112
- /** Label of the step that logged it; `null` for the workflow body. */
113
- readonly step: string | null;
114
- readonly line: string;
77
+ /** Label of the step that logged it; `null` for the workflow body. */
78
+ readonly step: string | null;
79
+ readonly line: string;
115
80
  }
116
-
117
81
  export interface WorkflowRun {
118
- readonly status: RunStatus;
119
- /** Whether the run succeeded, or stopped at its `until` step. */
120
- readonly ok: boolean;
121
- /** What the workflow returned, when it succeeded. */
122
- readonly output: JsonValue | null;
123
- /** Why the run failed. */
124
- readonly error: string | null;
125
- /** The approval the run waits for (`approve: false`). */
126
- readonly awaiting: string | null;
127
- /** The `until` step the run stopped after. */
128
- readonly stoppedAt: string | null;
129
- /** The directory the run changed; removed afterwards unless `keep` is set. */
130
- readonly dir: string;
131
- /** Every file after the run. */
132
- readonly files: FileTree;
133
- /** Files the run wrote or created, with their new text; `null` for files it removed. */
134
- readonly changes: { readonly [path: string]: string | null };
135
- /** Every step, in the order the workflow started them. */
136
- readonly steps: readonly StepRun[];
137
- /** Console output, from steps, callbacks and the workflow body. */
138
- readonly logs: readonly LogLine[];
139
- /** Metrics the transforms recorded. */
140
- readonly metrics: Record<string, unknown>;
141
- /** The first step with this label. Throws when there is none. */
142
- step(label: string): StepRun;
143
- /** A unified diff of every file the run changed. */
144
- diff(): string;
82
+ readonly status: RunStatus;
83
+ /** Whether the run succeeded, or stopped at its `until` step. */
84
+ readonly ok: boolean;
85
+ /** What the workflow returned, when it succeeded. */
86
+ readonly output: JsonValue | null;
87
+ /** Why the run failed. */
88
+ readonly error: string | null;
89
+ /** The approval the run waits for (`approve: false`). */
90
+ readonly awaiting: string | null;
91
+ /** The `until` step the run stopped after. */
92
+ readonly stoppedAt: string | null;
93
+ /** The directory the run changed; removed afterwards unless `keep` is set. */
94
+ readonly dir: string;
95
+ /** Every file after the run. */
96
+ readonly files: FileTree;
97
+ /** Files the run wrote or created, with their new text; `null` for files it removed. */
98
+ readonly changes: {
99
+ readonly [path: string]: string | null;
100
+ };
101
+ /** Every step, in the order the workflow started them. */
102
+ readonly steps: readonly StepRun[];
103
+ /** Console output, from steps, callbacks and the workflow body. */
104
+ readonly logs: readonly LogLine[];
105
+ /** Metrics the transforms recorded. */
106
+ readonly metrics: Record<string, unknown>;
107
+ /** The first step with this label. Throws when there is none. */
108
+ step(label: string): StepRun;
109
+ /** A unified diff of every file the run changed. */
110
+ diff(): string;
111
+ }
112
+ export interface Fixture {
113
+ /** The fixture's directory, relative to the fixtures directory (`"renames/default-export"`). */
114
+ readonly name: string;
115
+ readonly dir: string;
116
+ /** `input/`, or the `input.<ext>` file: pass it as `target`. */
117
+ readonly input: string;
118
+ /** `expected/`, or the `expected.<ext>` file: pass it to `assertTree`. */
119
+ readonly expected: string;
120
+ /** From `params.json`, or empty. */
121
+ readonly params: Record<string, JsonValue>;
122
+ }
123
+ export interface AssertTreeOptions {
124
+ /** Ignore whitespace at the ends of lines and of files. */
125
+ ignoreWhitespace?: boolean;
126
+ /** Put in front of the failure message. */
127
+ message?: string;
145
128
  }
146
-
147
129
  /**
148
130
  * Run a workflow (a workflow file, a package directory, or the workflow
149
131
  * module itself, with `options.path`) on a copy of `options.target`. Resolves for every outcome; check `run.status`, or use
@@ -151,38 +133,14 @@ export interface WorkflowRun {
151
133
  * workflow cannot run at all (for example it does not build), or when an
152
134
  * `until` or `given` label matches no step.
153
135
  */
154
- export function runWorkflow(
155
- workflow: PathLike | WorkflowModule,
156
- options: RunWorkflowOptions,
157
- ): Promise<WorkflowRun>;
158
-
159
- export interface Fixture {
160
- /** The fixture's directory, relative to the fixtures directory (`"renames/default-export"`). */
161
- readonly name: string;
162
- readonly dir: string;
163
- /** `input/`, or the `input.<ext>` file: pass it as `target`. */
164
- readonly input: string;
165
- /** `expected/`, or the `expected.<ext>` file: pass it to `assertTree`. */
166
- readonly expected: string;
167
- /** From `params.json`, or empty. */
168
- readonly params: Record<string, JsonValue>;
169
- }
170
-
136
+ export declare function runWorkflow(workflow: PathLike | WorkflowModule, options: RunWorkflowOptions): Promise<WorkflowRun>;
171
137
  /**
172
138
  * The fixtures in a directory: each subdirectory with `input/` and
173
139
  * `expected/` directories, or `input.<ext>` and `expected.<ext>` files (the
174
- * layouts `codemod jssg test` and `codemod workflow test` read). Groups of
140
+ * layouts `codemod jssg test` reads), and optionally `params.json`. Groups of
175
141
  * fixtures may be nested.
176
142
  */
177
- export function fixtures(dir: PathLike): Fixture[];
178
-
179
- export interface AssertTreeOptions {
180
- /** Ignore whitespace at the ends of lines and of files. */
181
- ignoreWhitespace?: boolean;
182
- /** Put in front of the failure message. */
183
- message?: string;
184
- }
185
-
143
+ export declare function fixtures(dir: PathLike): Fixture[];
186
144
  /**
187
145
  * Assert that `actual` holds exactly the expected files. Throws an
188
146
  * `AssertionError` with `actual` and `expected` set and a diff in the
@@ -196,8 +154,4 @@ export interface AssertTreeOptions {
196
154
  * Line endings are compared as `\n`. With `CODEMOD_UPDATE_FIXTURES=1`, an
197
155
  * expected directory or file is rewritten to match `actual` instead.
198
156
  */
199
- export function assertTree(
200
- actual: WorkflowRun | PathLike | FileTree,
201
- expected: PathLike | FileTree,
202
- options?: AssertTreeOptions,
203
- ): void;
157
+ export declare function assertTree(actual: WorkflowRun | PathLike | FileTree, expected: PathLike | FileTree, options?: AssertTreeOptions): void;