@fliwright/cli 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +59 -2
- package/dist/ArtifactReferences.d.ts +7 -0
- package/dist/ArtifactReferences.js +82 -0
- package/dist/CommandRegistry.d.ts +40 -0
- package/dist/CommandRegistry.js +177 -0
- package/dist/InspectionOutput.d.ts +5 -0
- package/dist/InspectionOutput.js +11 -0
- package/dist/RecordingReplay.d.ts +24 -0
- package/dist/RecordingReplay.js +79 -0
- package/dist/WorkflowContext.d.ts +20 -0
- package/dist/WorkflowContext.js +1 -0
- package/dist/capabilities/form.d.ts +13 -0
- package/dist/capabilities/form.js +9 -0
- package/dist/capabilities/interaction.d.ts +226 -0
- package/dist/capabilities/interaction.js +447 -0
- package/dist/capabilities/session.d.ts +18 -0
- package/dist/capabilities/session.js +55 -0
- package/dist/catalog.d.ts +36 -0
- package/dist/catalog.js +69 -0
- package/dist/commands/app-inspect.d.ts +96 -0
- package/dist/commands/app-inspect.js +70 -0
- package/dist/commands/app.d.ts +53 -0
- package/dist/commands/app.js +104 -0
- package/dist/commands/artifact-query.d.ts +138 -0
- package/dist/commands/artifact-query.js +81 -0
- package/dist/commands/artifacts.d.ts +40 -0
- package/dist/commands/artifacts.js +311 -0
- package/dist/commands/doctor.d.ts +11 -0
- package/dist/commands/doctor.js +285 -0
- package/dist/commands/flow-runtime.d.ts +40 -0
- package/dist/commands/flow-runtime.js +37 -0
- package/dist/commands/flow.d.ts +122 -0
- package/dist/commands/flow.js +236 -0
- package/dist/commands/generate-test.d.ts +46 -0
- package/dist/commands/generate-test.js +233 -0
- package/dist/commands/init.d.ts +22 -0
- package/dist/commands/init.js +262 -0
- package/dist/commands/mock-management.d.ts +53 -0
- package/dist/commands/mock-management.js +65 -0
- package/dist/commands/mock.d.ts +8 -0
- package/dist/commands/mock.js +27 -0
- package/dist/commands/record.d.ts +55 -0
- package/dist/commands/record.js +216 -0
- package/dist/commands/run.d.ts +93 -0
- package/dist/commands/run.js +707 -0
- package/dist/commands/scenario.d.ts +26 -0
- package/dist/commands/scenario.js +39 -0
- package/dist/commands/tdd.d.ts +72 -0
- package/dist/commands/tdd.js +218 -0
- package/dist/config.d.ts +20 -0
- package/dist/config.js +40 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +139 -0
- package/dist/registry/devices.d.ts +2 -0
- package/dist/registry/devices.js +12 -0
- package/dist/registry/finite.d.ts +38 -0
- package/dist/registry/finite.js +121 -0
- package/dist/registry/flow-schemas.d.ts +405 -0
- package/dist/registry/flow-schemas.js +98 -0
- package/dist/registry/flow.d.ts +3 -0
- package/dist/registry/flow.js +56 -0
- package/dist/registry/generation-schema.d.ts +112 -0
- package/dist/registry/generation-schema.js +36 -0
- package/dist/registry/session.d.ts +2 -0
- package/dist/registry/session.js +24 -0
- package/dist/registry/tdd.d.ts +3 -0
- package/dist/registry/tdd.js +118 -0
- package/dist/reporter.d.ts +95 -0
- package/dist/reporter.js +61 -0
- package/dist/run.d.ts +6 -0
- package/dist/run.js +5 -0
- package/dist/session/ConnectionHost.d.ts +43 -0
- package/dist/session/ConnectionHost.js +129 -0
- package/dist/session/client.d.ts +38 -0
- package/dist/session/client.js +120 -0
- package/dist/session/worker.d.ts +1 -0
- package/dist/session/worker.js +161 -0
- package/dist/vm-discovery.d.ts +14 -0
- package/dist/vm-discovery.js +85 -0
- package/package.json +78 -3
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { FliwrightDriver } from '@fliwright/core';
|
|
7
|
+
import { resolveProjectConfig } from '../config.js';
|
|
8
|
+
import { resolveVmUrl } from '../vm-discovery.js';
|
|
9
|
+
export async function doctorCommand(projectDir, options = {}) {
|
|
10
|
+
options.signal?.throwIfAborted();
|
|
11
|
+
const checks = [];
|
|
12
|
+
checks.push(await checkNodeVersion());
|
|
13
|
+
checks.push(await checkFlutterSdk(options.signal));
|
|
14
|
+
checks.push(await checkPackageInstalled('@fliwright/core'));
|
|
15
|
+
checks.push(await checkPackageInstalled('@fliwright/vitest'));
|
|
16
|
+
checks.push(await checkConfigFile(projectDir));
|
|
17
|
+
checks.push(...await checkRecordingConfiguration(projectDir));
|
|
18
|
+
checks.push(await checkVitestPreset(projectDir, options.signal));
|
|
19
|
+
const vmService = await checkVmService(projectDir, options.vmServiceUrl);
|
|
20
|
+
checks.push(vmService.check);
|
|
21
|
+
checks.push(...await checkRuntimeDiagnostics(vmService.url, options.signal));
|
|
22
|
+
options.signal?.throwIfAborted();
|
|
23
|
+
const output = checks.map((check) => {
|
|
24
|
+
const icon = check.passed ? chalk.green('✅') : chalk.yellow('⚠️ ');
|
|
25
|
+
return `${icon} ${check.name}: ${check.message}`;
|
|
26
|
+
}).join('\n');
|
|
27
|
+
if (options.print !== false)
|
|
28
|
+
console.log(output);
|
|
29
|
+
return checks;
|
|
30
|
+
}
|
|
31
|
+
async function checkNodeVersion() {
|
|
32
|
+
const version = process.version;
|
|
33
|
+
const [major, minor] = version.slice(1).split('.').map(Number);
|
|
34
|
+
const supported = (major === 22 && minor >= 12) || major === 24 || major >= 26;
|
|
35
|
+
return {
|
|
36
|
+
name: 'Node.js',
|
|
37
|
+
passed: supported,
|
|
38
|
+
message: `${version}${!supported ? ' (requires Node 22.12+, 24.x or >=26)' : ''}`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function checkFlutterSdk(signal) {
|
|
42
|
+
try {
|
|
43
|
+
const output = await execAsync('flutter', ['--version'], undefined, signal);
|
|
44
|
+
const versionLine = output.split('\n')[0] ?? '';
|
|
45
|
+
return {
|
|
46
|
+
name: 'Flutter SDK',
|
|
47
|
+
passed: true,
|
|
48
|
+
message: versionLine.trim(),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return {
|
|
53
|
+
name: 'Flutter SDK',
|
|
54
|
+
passed: false,
|
|
55
|
+
message: 'not found (install from https://flutter.dev)',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function checkPackageInstalled(pkg) {
|
|
60
|
+
try {
|
|
61
|
+
const entry = fileURLToPath(import.meta.resolve(pkg));
|
|
62
|
+
const mod = JSON.parse(await readFile(join(dirname(entry), '..', 'package.json'), 'utf8'));
|
|
63
|
+
const version = mod.version ?? 'unknown';
|
|
64
|
+
return {
|
|
65
|
+
name: pkg,
|
|
66
|
+
passed: true,
|
|
67
|
+
message: `${version} installed`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return {
|
|
72
|
+
name: pkg,
|
|
73
|
+
passed: false,
|
|
74
|
+
message: `not installed (run: pnpm add -D ${pkg})`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function checkConfigFile(projectDir) {
|
|
79
|
+
const configPath = join(projectDir, 'fliwright.config.ts');
|
|
80
|
+
try {
|
|
81
|
+
await stat(configPath);
|
|
82
|
+
return {
|
|
83
|
+
name: 'fliwright.config.ts',
|
|
84
|
+
passed: true,
|
|
85
|
+
message: 'found',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return {
|
|
90
|
+
name: 'fliwright.config.ts',
|
|
91
|
+
passed: false,
|
|
92
|
+
message: 'not found (run: fliwright init)',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function checkRecordingConfiguration(projectDir) {
|
|
97
|
+
try {
|
|
98
|
+
const config = await resolveProjectConfig(projectDir);
|
|
99
|
+
const names = Object.keys(config.scenarios ?? {});
|
|
100
|
+
const environment = ['FLIWRIGHT_CONFIG', 'FLIWRIGHT_RECORDING_MODE', 'FLIWRIGHT_RUNS_ROOT',
|
|
101
|
+
'FLIWRIGHT_SCENARIOS', 'FLIWRIGHT_SCENARIO_MODE'].filter((key) => process.env[key]);
|
|
102
|
+
return [{
|
|
103
|
+
name: 'Recording configuration', passed: true,
|
|
104
|
+
message: `mode=${config.recording.mode}, runsRoot=${config.runsRoot}, cacheRoot=${config.cacheRoot}, scenarios=${names.join(',') || '(none)'}, source=${environment.length ? `environment (${environment.join(',')}) > ` : ''}fliwright.config.ts/defaults`,
|
|
105
|
+
}, {
|
|
106
|
+
name: 'Automation paths', passed: true,
|
|
107
|
+
message: Object.entries(config.paths).map(([key, value]) => `${key}=${value}`).join(', '),
|
|
108
|
+
}];
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return [{ name: 'Recording configuration', passed: false, message: messageOf(error) }];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** Resolve the real config in a bounded subprocess; never collect or execute project tests. */
|
|
115
|
+
async function checkVitestPreset(projectDir, signal) {
|
|
116
|
+
try {
|
|
117
|
+
const script = `
|
|
118
|
+
import { resolveConfig } from ${JSON.stringify(import.meta.resolve('vitest/node'))};
|
|
119
|
+
const viteConfig = await resolveConfig({ root: ${JSON.stringify(projectDir)} });
|
|
120
|
+
const result = { runner: viteConfig.test?.runner, include: viteConfig.test?.include ?? [],
|
|
121
|
+
env: viteConfig.test?.env, configFile: viteConfig.configFile };
|
|
122
|
+
process.stdout.write('\\nFLIWRIGHT_DOCTOR_CONFIG=' + JSON.stringify(result) + '\\n');
|
|
123
|
+
`;
|
|
124
|
+
const output = await execAsync(process.execPath, ['--input-type=module', '--eval', script], projectDir, signal);
|
|
125
|
+
const line = output.split('\n').find((entry) => entry.startsWith('FLIWRIGHT_DOCTOR_CONFIG='));
|
|
126
|
+
if (!line)
|
|
127
|
+
throw new Error('Vitest did not return its resolved configuration.');
|
|
128
|
+
const config = JSON.parse(line.slice('FLIWRIGHT_DOCTOR_CONFIG='.length));
|
|
129
|
+
const expectedRunner = fileURLToPath(import.meta.resolve('@fliwright/vitest/runner'));
|
|
130
|
+
const passed = config.runner === expectedRunner && Boolean(config.env?.FLIWRIGHT_CONFIG);
|
|
131
|
+
return {
|
|
132
|
+
name: 'Vitest recording preset', passed,
|
|
133
|
+
message: passed
|
|
134
|
+
? `resolved ${config.configFile}: runner=${config.runner}, include=${config.include.join(', ')}`
|
|
135
|
+
: `Recording lifecycle is not verified for runner=${config.runner ?? '(default)'}. Configure fliwrightPreset(); custom runners must explicitly compose the Fliwright lifecycle and pass runner integration checks.`,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
return { name: 'Vitest recording preset', passed: false, message: messageOf(error) };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async function checkVmService(projectDir, providedUrl) {
|
|
143
|
+
try {
|
|
144
|
+
const config = await resolveProjectConfig(projectDir);
|
|
145
|
+
const url = await resolveVmUrl({ cliFlag: providedUrl, configUrl: config.vmServiceUrl, cwd: projectDir, verify: true });
|
|
146
|
+
return { check: {
|
|
147
|
+
name: 'VM Service', passed: Boolean(url),
|
|
148
|
+
message: url ? 'reachable (using argument > environment > project config > workspace cache > discovery)'
|
|
149
|
+
: 'no Flutter app detected (run `flutter run` to start one)',
|
|
150
|
+
}, url: url ?? undefined };
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
return { check: { name: 'VM Service', passed: false, message: messageOf(error) } };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const runtimeCheckNames = ['Bridge extensions', 'Recording target capture', 'Recording focused input',
|
|
157
|
+
'Evidence screenshot', 'Evidence snapshot', 'Mock server', 'Riverpod observer'];
|
|
158
|
+
async function checkRuntimeDiagnostics(vmServiceUrl, signal) {
|
|
159
|
+
signal?.throwIfAborted();
|
|
160
|
+
if (!vmServiceUrl)
|
|
161
|
+
return runtimeCheckNames.map(skippedRuntimeCheck);
|
|
162
|
+
const driver = new FliwrightDriver();
|
|
163
|
+
const abort = () => { void driver.dispose({ signal: AbortSignal.abort() }).catch(() => { }); };
|
|
164
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
165
|
+
try {
|
|
166
|
+
await driver.connect(toWebSocketUrl(vmServiceUrl));
|
|
167
|
+
return [
|
|
168
|
+
...await checkBridgeExtensions(driver),
|
|
169
|
+
await checkEvidenceChannel(driver, 'screenshot'),
|
|
170
|
+
await checkEvidenceChannel(driver, 'snapshot'),
|
|
171
|
+
await checkMockServer(driver),
|
|
172
|
+
await checkRiverpodObserver(driver),
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
return runtimeCheckNames.map((name) => ({ name, passed: false,
|
|
177
|
+
message: `could not connect to VM Service: ${messageOf(error)}` }));
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
signal?.removeEventListener('abort', abort);
|
|
181
|
+
await driver.dispose(signal?.aborted ? { signal: AbortSignal.abort() } : undefined);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async function checkEvidenceChannel(driver, channel) {
|
|
185
|
+
try {
|
|
186
|
+
const response = await driver.sendRequest(channel === 'screenshot' ? 'ext.fliwright.screenshot' : 'ext.fliwright.snap', {});
|
|
187
|
+
const available = response.success !== false && (channel === 'screenshot'
|
|
188
|
+
? typeof response.screenshot === 'string' && response.screenshot.length > 0
|
|
189
|
+
: response.snapshot != null);
|
|
190
|
+
return { name: `Evidence ${channel}`, passed: available,
|
|
191
|
+
message: available ? 'capture available' : response.error ?? 'capture returned no evidence' };
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
return { name: `Evidence ${channel}`, passed: false, message: messageOf(error) };
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function skippedRuntimeCheck(name) {
|
|
198
|
+
return {
|
|
199
|
+
name,
|
|
200
|
+
passed: false,
|
|
201
|
+
message: 'skipped (no VM Service URL)',
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
async function checkBridgeExtensions(driver) {
|
|
205
|
+
try {
|
|
206
|
+
const ping = await driver.sendRequest('ext.fliwright.ping');
|
|
207
|
+
const handshake = await driver.sendRequest('ext.fliwright.handshake', {
|
|
208
|
+
protocolVersion: '2',
|
|
209
|
+
});
|
|
210
|
+
const passed = ping.status === 'ok' && handshake.compatible === true;
|
|
211
|
+
const targetCapture = handshake.bridgeCapabilities?.recordingBeforeDispatchTarget === true;
|
|
212
|
+
const focusedInput = handshake.bridgeCapabilities?.recordingFocusedInputController === true;
|
|
213
|
+
return [{
|
|
214
|
+
name: 'Bridge extensions', passed,
|
|
215
|
+
message: `protocol=${handshake.protocolVersion}, compatible=${handshake.compatible === true}, initialized=${handshake.initialized === true}, debugMode=${handshake.debugMode === true}`,
|
|
216
|
+
}, {
|
|
217
|
+
name: 'Recording target capture', passed: passed && targetCapture,
|
|
218
|
+
message: targetCapture ? 'before-dispatch target freezing available'
|
|
219
|
+
: 'Install FliwrightRecordingBinding before starting the app to capture targets before dispatch.',
|
|
220
|
+
}, {
|
|
221
|
+
name: 'Recording focused input', passed: passed && focusedInput,
|
|
222
|
+
message: focusedInput ? 'focused controller listener available' : 'bridge does not expose focused input capture',
|
|
223
|
+
}];
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
return ['Bridge extensions', 'Recording target capture', 'Recording focused input'].map((name) => ({
|
|
227
|
+
name, passed: false, message: messageOf(error),
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async function checkMockServer(driver) {
|
|
232
|
+
try {
|
|
233
|
+
const state = await driver.sendRequest('ext.fliwright.mock.debugState');
|
|
234
|
+
return {
|
|
235
|
+
name: 'Mock server',
|
|
236
|
+
passed: true,
|
|
237
|
+
message: `reachable (port=${state.serverPort ?? 'n/a'}, routes=${state.routeCount ?? state.routes?.length ?? 'n/a'})`,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
return {
|
|
242
|
+
name: 'Mock server',
|
|
243
|
+
passed: false,
|
|
244
|
+
message: error instanceof Error ? error.message : String(error),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
async function checkRiverpodObserver(driver) {
|
|
249
|
+
try {
|
|
250
|
+
const status = await driver.sendRequest('ext.fliwright.riverpod.status');
|
|
251
|
+
return {
|
|
252
|
+
name: 'Riverpod observer',
|
|
253
|
+
passed: status.observerInstalled === true || status.containerReady === true,
|
|
254
|
+
message: `observerInstalled=${status.observerInstalled === true}, containerReady=${status.containerReady === true}, providers=${status.providerCount ?? 0}`,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
return {
|
|
259
|
+
name: 'Riverpod observer',
|
|
260
|
+
passed: false,
|
|
261
|
+
message: error instanceof Error ? error.message : String(error),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function toWebSocketUrl(url) {
|
|
266
|
+
const converted = url
|
|
267
|
+
.replace('http://', 'ws://')
|
|
268
|
+
.replace('https://', 'wss://');
|
|
269
|
+
return converted.endsWith('/ws') ? converted : converted.replace(/\/?$/, '/ws');
|
|
270
|
+
}
|
|
271
|
+
function execAsync(command, args, cwd, signal) {
|
|
272
|
+
return new Promise((resolve, reject) => {
|
|
273
|
+
execFile(command, args, { timeout: 5000, cwd, signal }, (error, stdout) => {
|
|
274
|
+
if (error) {
|
|
275
|
+
reject(error);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
resolve(stdout);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function messageOf(error) {
|
|
284
|
+
return error instanceof Error ? error.message : String(error);
|
|
285
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type AppSessionOptions, type AppSessionDeps } from '../capabilities/session.js';
|
|
2
|
+
import { type FlowReviewPlanOptions } from './flow.js';
|
|
3
|
+
export interface FlowRuntimeOptions extends FlowReviewPlanOptions, AppSessionOptions {
|
|
4
|
+
outputDir?: string;
|
|
5
|
+
targetIds?: string[];
|
|
6
|
+
limit?: number;
|
|
7
|
+
pixelRatio?: number;
|
|
8
|
+
accessToken?: string;
|
|
9
|
+
scale?: number;
|
|
10
|
+
autoCompare?: boolean;
|
|
11
|
+
pixelThreshold?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function flowReviewCaptureRuntimeCommand(options: FlowRuntimeOptions, deps?: AppSessionDeps): Promise<{
|
|
14
|
+
path: string;
|
|
15
|
+
outputDir: string;
|
|
16
|
+
capturesFile: string;
|
|
17
|
+
captures: ({
|
|
18
|
+
flowNodeId: string;
|
|
19
|
+
title: string;
|
|
20
|
+
route: string | undefined;
|
|
21
|
+
screenshotPath: string;
|
|
22
|
+
status: "passed";
|
|
23
|
+
error?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
flowNodeId: string;
|
|
26
|
+
title: string;
|
|
27
|
+
route: string | undefined;
|
|
28
|
+
status: "failed";
|
|
29
|
+
error: string;
|
|
30
|
+
screenshotPath?: undefined;
|
|
31
|
+
})[];
|
|
32
|
+
}>;
|
|
33
|
+
export declare function flowReviewRunCommand(options: FlowRuntimeOptions, deps?: AppSessionDeps): Promise<{
|
|
34
|
+
bundlePath: string;
|
|
35
|
+
runtimeCapturesFile: string;
|
|
36
|
+
figmaCapturesFile: string;
|
|
37
|
+
path: string;
|
|
38
|
+
reportPath: string;
|
|
39
|
+
report: import("@fliwright/core").FlowReviewReport;
|
|
40
|
+
}>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { sanitizeFlowFileId } from '@fliwright/core';
|
|
4
|
+
import { withAppSession } from '../capabilities/session.js';
|
|
5
|
+
import { flowReviewPlanCommand, flowReviewBundleCommand, flowReviewCaptureFigmaCommand, flowReviewReportCommand } from './flow.js';
|
|
6
|
+
export async function flowReviewCaptureRuntimeCommand(options, deps = {}) {
|
|
7
|
+
const { path, reviewPlan } = await flowReviewPlanCommand(options);
|
|
8
|
+
const outputDir = resolve(options.cwd ?? process.cwd(), options.outputDir ?? `.fliwright/reviews/${sanitizeFlowFileId(reviewPlan.flowId)}-${Date.now()}/runtime`);
|
|
9
|
+
await mkdir(outputDir, { recursive: true });
|
|
10
|
+
return withAppSession(options, async ({ driver }) => {
|
|
11
|
+
const targets = reviewPlan.targets.filter((target) => !options.targetIds || options.targetIds.includes(target.flowNodeId)).slice(0, options.limit);
|
|
12
|
+
const captures = [];
|
|
13
|
+
for (const [index, target] of targets.entries()) {
|
|
14
|
+
options.signal?.throwIfAborted();
|
|
15
|
+
try {
|
|
16
|
+
if (target.route)
|
|
17
|
+
await driver.page.goto(target.route);
|
|
18
|
+
const screenshotPath = join(outputDir, `${String(index + 1).padStart(3, '0')}-${sanitizeFlowFileId(target.flowNodeId)}.png`);
|
|
19
|
+
await writeFile(screenshotPath, await driver.page.screenshot({ pixelRatio: options.pixelRatio }));
|
|
20
|
+
captures.push({ flowNodeId: target.flowNodeId, title: target.title, route: target.route, screenshotPath, status: 'passed' });
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
captures.push({ flowNodeId: target.flowNodeId, title: target.title, route: target.route, status: 'failed', error: error instanceof Error ? error.message : String(error) });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const capturesFile = join(outputDir, 'runtime-captures.json');
|
|
27
|
+
await writeFile(capturesFile, JSON.stringify(captures, null, 2));
|
|
28
|
+
return { path, outputDir, capturesFile, captures };
|
|
29
|
+
}, deps);
|
|
30
|
+
}
|
|
31
|
+
export async function flowReviewRunCommand(options, deps = {}) {
|
|
32
|
+
const bundle = await flowReviewBundleCommand(options);
|
|
33
|
+
const runtime = await flowReviewCaptureRuntimeCommand({ ...options, outputDir: bundle.bundle.artifacts.runtimeDir }, deps);
|
|
34
|
+
const figma = await flowReviewCaptureFigmaCommand({ ...options, outputDir: bundle.bundle.artifacts.figmaDir, capturesFile: bundle.bundle.figmaMcp.capturesFile });
|
|
35
|
+
const report = await flowReviewReportCommand({ ...options, outputPath: bundle.bundle.artifacts.reportPath, runtimeCaptures: runtime.captures, figmaCaptures: figma.captures });
|
|
36
|
+
return { ...report, bundlePath: bundle.outputPath, runtimeCapturesFile: runtime.capturesFile, figmaCapturesFile: figma.capturesFile };
|
|
37
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { AiRuntime } from '@fliwright/core';
|
|
2
|
+
import type { AiProviderName, FlowCleanPlan, FlowAgentSpec, FlowReviewArtifactInput, FlowReviewComparisonInput, FlowReviewPlan, FlowReviewBundle, FlowReviewReport, FlowValidationResult, FliwrightFlowDocument, FigmaScreenshotProvider } from '@fliwright/core';
|
|
3
|
+
export interface FlowCommandOptions {
|
|
4
|
+
cwd?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
json?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface FlowListItem {
|
|
10
|
+
id: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
source?: FliwrightFlowDocument['source'];
|
|
14
|
+
path: string;
|
|
15
|
+
nodeCount: number;
|
|
16
|
+
edgeCount: number;
|
|
17
|
+
}
|
|
18
|
+
export interface FlowBindFigmaOptions extends FlowCommandOptions {
|
|
19
|
+
flowNodeId: string;
|
|
20
|
+
figmaUrl?: string;
|
|
21
|
+
fileKey?: string;
|
|
22
|
+
figmaNodeId?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
codeConnectId?: string;
|
|
25
|
+
componentName?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface FlowValidateOptions extends FlowCommandOptions {
|
|
28
|
+
requireCodeTargetForFigmaNodes?: boolean;
|
|
29
|
+
requireReviewRuntimeEntryForFigmaNodes?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface FlowCleanOptions extends FlowCommandOptions {
|
|
32
|
+
outputPath?: string;
|
|
33
|
+
dryRun?: boolean;
|
|
34
|
+
aiProvider?: AiProviderName;
|
|
35
|
+
aiTimeoutMs?: number;
|
|
36
|
+
protectedNodeIds?: string[];
|
|
37
|
+
instructions?: string;
|
|
38
|
+
aiRuntime?: Pick<AiRuntime, 'generate'>;
|
|
39
|
+
}
|
|
40
|
+
export interface FlowGenerateTestOptions extends FlowCommandOptions {
|
|
41
|
+
outputFile?: string;
|
|
42
|
+
testName?: string;
|
|
43
|
+
resetToHomeBeforeEach?: boolean;
|
|
44
|
+
homeRoute?: string;
|
|
45
|
+
useFlowSteps?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface FlowReviewPlanOptions extends FlowCommandOptions {
|
|
48
|
+
pixelDiffTolerance?: number;
|
|
49
|
+
layoutPxTolerance?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface FlowReviewBundleOptions extends FlowReviewPlanOptions {
|
|
52
|
+
outputDir?: string;
|
|
53
|
+
outputPath?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface FlowReviewCaptureFigmaOptions extends FlowReviewPlanOptions {
|
|
56
|
+
outputDir?: string;
|
|
57
|
+
capturesFile?: string;
|
|
58
|
+
accessToken?: string;
|
|
59
|
+
scale?: number;
|
|
60
|
+
figmaProvider?: FigmaScreenshotProvider;
|
|
61
|
+
}
|
|
62
|
+
export interface FlowReviewReportOptions extends FlowReviewPlanOptions {
|
|
63
|
+
runtimeCaptures?: FlowReviewArtifactInput[];
|
|
64
|
+
figmaCaptures?: FlowReviewArtifactInput[];
|
|
65
|
+
comparisons?: FlowReviewComparisonInput[];
|
|
66
|
+
outputPath?: string;
|
|
67
|
+
autoCompare?: boolean;
|
|
68
|
+
pixelThreshold?: number;
|
|
69
|
+
}
|
|
70
|
+
export declare function flowListCommand(options?: FlowCommandOptions): Promise<{
|
|
71
|
+
flows: FlowListItem[];
|
|
72
|
+
}>;
|
|
73
|
+
export declare function flowGetCommand(options: FlowCommandOptions): Promise<{
|
|
74
|
+
path: string;
|
|
75
|
+
flow: FliwrightFlowDocument;
|
|
76
|
+
}>;
|
|
77
|
+
export declare function flowBindFigmaCommand(options: FlowBindFigmaOptions): Promise<{
|
|
78
|
+
path: string;
|
|
79
|
+
flow: FliwrightFlowDocument;
|
|
80
|
+
node: FliwrightFlowDocument['nodes'][number];
|
|
81
|
+
}>;
|
|
82
|
+
export declare function flowAgentSpecCommand(options: FlowCommandOptions): Promise<{
|
|
83
|
+
path: string;
|
|
84
|
+
spec: FlowAgentSpec;
|
|
85
|
+
}>;
|
|
86
|
+
export declare function flowCleanCommand(options: FlowCleanOptions): Promise<{
|
|
87
|
+
path: string;
|
|
88
|
+
outputPath: string;
|
|
89
|
+
flow: FliwrightFlowDocument;
|
|
90
|
+
plan: FlowCleanPlan;
|
|
91
|
+
dryRun: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
export declare function flowReviewPlanCommand(options: FlowReviewPlanOptions): Promise<{
|
|
94
|
+
path: string;
|
|
95
|
+
reviewPlan: FlowReviewPlan;
|
|
96
|
+
}>;
|
|
97
|
+
export declare function flowReviewBundleCommand(options: FlowReviewBundleOptions): Promise<{
|
|
98
|
+
path: string;
|
|
99
|
+
outputPath: string;
|
|
100
|
+
bundle: FlowReviewBundle;
|
|
101
|
+
}>;
|
|
102
|
+
export declare function flowReviewCaptureFigmaCommand(options: FlowReviewCaptureFigmaOptions): Promise<{
|
|
103
|
+
path: string;
|
|
104
|
+
outputDir: string;
|
|
105
|
+
capturesFile: string;
|
|
106
|
+
captures: FlowReviewArtifactInput[];
|
|
107
|
+
}>;
|
|
108
|
+
export declare function flowReviewReportCommand(options: FlowReviewReportOptions): Promise<{
|
|
109
|
+
path: string;
|
|
110
|
+
reportPath: string;
|
|
111
|
+
report: FlowReviewReport;
|
|
112
|
+
}>;
|
|
113
|
+
export declare function flowGenerateTestCommand(options: FlowGenerateTestOptions): Promise<{
|
|
114
|
+
path: string;
|
|
115
|
+
code: string;
|
|
116
|
+
outputFile?: string;
|
|
117
|
+
}>;
|
|
118
|
+
export declare function flowValidateCommand(options: FlowValidateOptions): Promise<{
|
|
119
|
+
path: string;
|
|
120
|
+
validation: FlowValidationResult;
|
|
121
|
+
}>;
|
|
122
|
+
export declare function flowIdFromPath(path: string): string;
|