@ihyeon/flow-qa 0.10.13 → 0.10.14
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/dist/src/cli.js +5 -1
- package/dist/src/ui/entry.js +3 -2
- package/dist/src/ui/public/app.js +13 -3
- package/dist/src/ui/server.js +12 -7
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -250,7 +250,11 @@ export async function main(args) {
|
|
|
250
250
|
throw error;
|
|
251
251
|
}
|
|
252
252
|
const suite = await planFlow(flow, config.planner, { platform });
|
|
253
|
-
|
|
253
|
+
const sourceDirectory = dirname(flowPath);
|
|
254
|
+
const inWorkspaceFlows = sourceDirectory === join(workspace, 'flows')
|
|
255
|
+
|| sourceDirectory === join(await realpath(workspace), 'flows');
|
|
256
|
+
const sourceFile = inWorkspaceFlows ? `flows/${basename(flowPath)}` : arg;
|
|
257
|
+
suite.source = { file: sourceFile, sha256: sha256(flow) };
|
|
254
258
|
await writeJSON(output, suite, true);
|
|
255
259
|
console.log(localized(locale, `Cases created: ${output}\n${suite.cases.filter((c) => c.questions.length).length} of ${suite.cases.length} cases have open questions.`, `케이스 생성: ${output}\n${suite.cases.length}개 중 확인 질문이 있는 케이스 ${suite.cases.filter((c) => c.questions.length).length}개`));
|
|
256
260
|
return;
|
package/dist/src/ui/entry.js
CHANGED
|
@@ -34,9 +34,10 @@ async function start(args, locale) {
|
|
|
34
34
|
throw new StartupError(localized(locale, 'Port must be an integer from 0 to 65535. Example: flow-qa ui --port 4311', '포트는 0~65535 사이 정수여야 합니다. 예: flow-qa ui --port 4311'));
|
|
35
35
|
if (values.demo && values.workspace)
|
|
36
36
|
throw new StartupError(localized(locale, '--demo and --workspace cannot be used together.', '--demo와 --workspace는 함께 사용할 수 없습니다.'));
|
|
37
|
+
const requestedWorkspace = resolve(values.workspace ?? '.');
|
|
37
38
|
let workspace;
|
|
38
39
|
try {
|
|
39
|
-
workspace = await realpath(
|
|
40
|
+
workspace = await realpath(requestedWorkspace);
|
|
40
41
|
}
|
|
41
42
|
catch {
|
|
42
43
|
throw new StartupError(localized(locale, 'Workspace directory not found. Run flow-qa init /path/to/my-qa first, then pass --workspace.', '작업 공간 디렉터리를 찾을 수 없습니다. 먼저 flow-qa init /path/to/my-qa로 준비한 뒤 --workspace로 지정하세요.'));
|
|
@@ -69,7 +70,7 @@ async function start(args, locale) {
|
|
|
69
70
|
throw error;
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
ui = await startUIServer({ workspace, port });
|
|
73
|
+
ui = await startUIServer({ workspace, port, ...(values.demo ? {} : { workspaceAlias: requestedWorkspace }) });
|
|
73
74
|
console.log(localized(locale, `Flow QA: ${ui.url}\nWorkspace: ${workspace}`, `Flow QA: ${ui.url}\n작업 공간: ${workspace}`));
|
|
74
75
|
if (demo)
|
|
75
76
|
console.log(localized(locale, `Local demo app: ${demo.url}\nOpen the example in the case library, review it, then run it in a real browser. No model call is made.`, `로컬 데모 앱: ${demo.url}\n케이스 보관함에서 예제를 열고 검토한 뒤 실제 브라우저로 실행하세요. 모델 호출은 없습니다.`));
|
|
@@ -107,6 +107,13 @@
|
|
|
107
107
|
return Boolean(app.draft && app.script && app.savedFile && app.savedHash && !app.dirty && !app.stale && !app.busy && !hasUnsavedScenario());
|
|
108
108
|
}
|
|
109
109
|
function canDownloadSourceMarkdown() { return canDownloadSavedCases() && Boolean(app.draft.source); }
|
|
110
|
+
function sourceFileName(source) { return source.file.split(/[\\/]/).at(-1); }
|
|
111
|
+
function downloadSavedCases() {
|
|
112
|
+
if (!canDownloadSavedCases()) return;
|
|
113
|
+
const { source } = app.draft;
|
|
114
|
+
const suite = source ? { ...app.draft, source: { ...source, file: `flows/${sourceFileName(source)}` } } : app.draft;
|
|
115
|
+
download(app.savedFile, `${JSON.stringify(suite, null, 2)}\n`, 'application/json');
|
|
116
|
+
}
|
|
110
117
|
function readiness() {
|
|
111
118
|
const active = app.state?.active;
|
|
112
119
|
const ready = !!app.draft && !!app.script && !app.stale && !app.dirty;
|
|
@@ -704,7 +711,10 @@
|
|
|
704
711
|
if (jsonFiles[0].size > 1024 * 1024 || (markdownFiles[0] && markdownFiles[0].size > 128 * 1024)) throw localizedError('app.importTooLarge');
|
|
705
712
|
let suite;
|
|
706
713
|
try { suite = JSON.parse(await jsonFiles[0].text()); } catch { throw localizedError('app.invalidJson'); }
|
|
707
|
-
|
|
714
|
+
// Keep an initial UTF-8 BOM in the text used to verify the source hash.
|
|
715
|
+
const flow = markdownFiles[0]
|
|
716
|
+
? new TextDecoder('utf-8', { ignoreBOM: true }).decode(await markdownFiles[0].arrayBuffer())
|
|
717
|
+
: undefined;
|
|
708
718
|
const body = { suite, ...(flow === undefined ? {} : { flow }) };
|
|
709
719
|
if (new TextEncoder().encode(JSON.stringify(body)).byteLength > 256 * 1024) throw localizedError('app.importTooLarge');
|
|
710
720
|
const result = await api('/api/import', body);
|
|
@@ -1073,8 +1083,8 @@
|
|
|
1073
1083
|
$('import-btn').addEventListener('click', importFiles);
|
|
1074
1084
|
$('global-stop-btn').addEventListener('click', stop);
|
|
1075
1085
|
$('reconnect-btn').addEventListener('click', () => refresh(true).catch(showError));
|
|
1076
|
-
$('suite-download').addEventListener('click',
|
|
1077
|
-
$('flow-download').addEventListener('click', () => { if (canDownloadSourceMarkdown()) download(app.draft.source
|
|
1086
|
+
$('suite-download').addEventListener('click', downloadSavedCases);
|
|
1087
|
+
$('flow-download').addEventListener('click', () => { if (canDownloadSourceMarkdown()) download(sourceFileName(app.draft.source), app.sourceFlow, 'text/markdown'); });
|
|
1078
1088
|
$('script-download').addEventListener('click', () => { if (app.draft && !app.dirty && !app.stale) download(`${app.draft.id || 'flow-qa'}.test.mjs`, app.script, 'text/javascript'); });
|
|
1079
1089
|
$('report-md').addEventListener('click', downloadReportMarkdown);
|
|
1080
1090
|
$('report-json').addEventListener('click', () => { if (app.report) download(`${app.selectedRun}.json`, JSON.stringify(app.report, null, 2), 'application/json'); });
|
package/dist/src/ui/server.js
CHANGED
|
@@ -180,13 +180,17 @@ function safeBasename(value, extension) {
|
|
|
180
180
|
invalid('Invalid file name.');
|
|
181
181
|
return value;
|
|
182
182
|
}
|
|
183
|
-
function sourceName(suite) {
|
|
183
|
+
function sourceName(suite, workspaceFlowRoots = []) {
|
|
184
184
|
if (!suite.source)
|
|
185
185
|
return undefined;
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
const file = suite.source.file;
|
|
187
|
+
const match = /^(?:\.\/)?flows\/([^/\\]+)$/.exec(file);
|
|
188
|
+
if (match)
|
|
189
|
+
return safeBasename(match[1], '.md');
|
|
190
|
+
if (path.isAbsolute(file) && workspaceFlowRoots.includes(path.dirname(file))) {
|
|
191
|
+
return safeBasename(path.basename(file), '.md');
|
|
192
|
+
}
|
|
193
|
+
return invalid('Invalid source flow path.');
|
|
190
194
|
}
|
|
191
195
|
function headers(response) {
|
|
192
196
|
response.setHeader('Cache-Control', 'no-store');
|
|
@@ -224,6 +228,7 @@ export async function startUIServer(options) {
|
|
|
224
228
|
const workspace = await realpath(options.workspace);
|
|
225
229
|
if (!(await lstat(workspace)).isDirectory())
|
|
226
230
|
throw new Error('Flow QA workspace does not exist.');
|
|
231
|
+
const workspaceFlowRoots = [path.join(workspace, 'flows'), path.resolve(options.workspaceAlias ?? options.workspace, 'flows')];
|
|
227
232
|
const port = options.port ?? 4310;
|
|
228
233
|
if (!Number.isInteger(port) || port < 0 || port > 65535)
|
|
229
234
|
throw new Error('Invalid UI port.');
|
|
@@ -338,7 +343,7 @@ export async function startUIServer(options) {
|
|
|
338
343
|
}
|
|
339
344
|
}
|
|
340
345
|
async function readSource(suite, verify) {
|
|
341
|
-
const name = sourceName(suite);
|
|
346
|
+
const name = sourceName(suite, workspaceFlowRoots);
|
|
342
347
|
if (!name)
|
|
343
348
|
return undefined;
|
|
344
349
|
const root = await directory(['flows']);
|
|
@@ -380,7 +385,7 @@ export async function startUIServer(options) {
|
|
|
380
385
|
for (const file of files) {
|
|
381
386
|
try {
|
|
382
387
|
const suite = parse(suiteSchema, jsonObject(await readRegular(root, file, MAX_SUITE)));
|
|
383
|
-
sourceName(suite);
|
|
388
|
+
sourceName(suite, workspaceFlowRoots);
|
|
384
389
|
summaries.push({ file, id: suite.id, title: suite.title, caseCount: suite.cases.length,
|
|
385
390
|
questionCount: suite.cases.reduce((count, testCase) => count + testCase.questions.length, 0) });
|
|
386
391
|
}
|