tryscript 0.1.6 → 0.1.7

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/index.d.mts CHANGED
@@ -202,6 +202,42 @@ interface CoverageContext {
202
202
  mergeLcov?: string;
203
203
  };
204
204
  }
205
+ /**
206
+ * Categories of wildcards, forming a hierarchy for expansion flags.
207
+ *
208
+ * - `unknown`: `???` (multi-line) and `[??]` (single-line) — temporary scaffolding
209
+ * - `generic`: `...` (multi-line) and `[..]` (single-line) — intentional omission
210
+ * - `named`: `[HASH]`, `[CWD]`, etc. — typed dynamic values
211
+ */
212
+ type WildcardCategory = 'unknown' | 'generic' | 'named';
213
+ /**
214
+ * Which wildcards each `--expand*` flag targets.
215
+ *
216
+ * - `unknown`: only `???` and `[??]`
217
+ * - `generic`: unknown + `...` and `[..]`
218
+ * - `all`: everything including named patterns
219
+ */
220
+ type ExpandLevel = 'unknown' | 'generic' | 'all';
221
+ /**
222
+ * A single wildcard capture from matching actual output against expected pattern.
223
+ */
224
+ interface WildcardCapture {
225
+ category: WildcardCategory;
226
+ /** For named patterns, the pattern name (e.g., 'HASH') */
227
+ name?: string;
228
+ /** True for multi-line wildcards (`...`/`???`), false for single-line (`[..]`/`[??]`) */
229
+ multiline: boolean;
230
+ /** The actual text that the wildcard matched */
231
+ captured: string;
232
+ }
233
+ /**
234
+ * Result of expanding wildcards in expected output.
235
+ */
236
+ interface ExpansionResult {
237
+ expandedOutput: string;
238
+ captures: WildcardCapture[];
239
+ expandedCount: number;
240
+ }
205
241
  //#endregion
206
242
  //#region src/lib/config.d.ts
207
243
  /** Fixture configuration for copying files to sandbox directory */
@@ -304,9 +340,112 @@ declare function matchOutput(actual: string, expected: string, context: {
304
340
  root: string;
305
341
  cwd: string;
306
342
  }, customPatterns?: Record<string, string | RegExp>): boolean;
343
+ /**
344
+ * Match actual output against expected pattern and return wildcard captures.
345
+ * Returns `null` if the output does not match.
346
+ */
347
+ declare function matchAndCapture(actual: string, expected: string, context: {
348
+ root: string;
349
+ cwd: string;
350
+ }, customPatterns?: Record<string, string | RegExp>): {
351
+ captures: WildcardCapture[];
352
+ } | null;
353
+ //#endregion
354
+ //#region src/lib/expander.d.ts
355
+ /**
356
+ * Whether a wildcard category should be expanded at the given level.
357
+ *
358
+ * The hierarchy is: unknown < generic < all.
359
+ */
360
+ declare function shouldExpandCategory(category: WildcardCategory, level: ExpandLevel): boolean;
361
+ /**
362
+ * Expand wildcards in expected output by replacing them with captured actual text.
363
+ *
364
+ * Only wildcards whose category is targeted by `level` are replaced; others are
365
+ * left intact. Returns `null` if actual output doesn't match expected pattern.
366
+ */
367
+ declare function expandExpectedOutput(expected: string, actual: string, context: {
368
+ root: string;
369
+ cwd: string;
370
+ }, level: ExpandLevel, customPatterns?: Record<string, string | RegExp>): ExpansionResult | null;
371
+ /**
372
+ * Expand wildcards in a test file in place.
373
+ *
374
+ * Uses the same reverse-order strategy as `updater.ts` to maintain correct
375
+ * string offsets when modifying multiple blocks.
376
+ */
377
+ declare function expandTestFile(file: TestFile, results: TestBlockResult[], level: ExpandLevel, context: {
378
+ root: string;
379
+ cwd: string;
380
+ }, customPatterns?: Record<string, string | RegExp>): Promise<{
381
+ expanded: boolean;
382
+ expandedCount: number;
383
+ changes: string[];
384
+ }>;
385
+ //#endregion
386
+ //#region src/lib/capture-log.d.ts
387
+ interface CaptureLogBlock {
388
+ name: string | undefined;
389
+ command: string;
390
+ expected_exit_code: number;
391
+ actual_exit_code: number;
392
+ expected_output: string;
393
+ actual_output: string;
394
+ captures: {
395
+ category: string;
396
+ name?: string;
397
+ multiline: boolean;
398
+ matched: string;
399
+ }[];
400
+ passed: boolean;
401
+ }
402
+ interface CaptureLogFile {
403
+ path: string;
404
+ blocks: CaptureLogBlock[];
405
+ }
406
+ interface CaptureLogDoc {
407
+ generated: string;
408
+ files: CaptureLogFile[];
409
+ }
410
+ /**
411
+ * Build the capture log document structure from test results.
412
+ *
413
+ * `customPatterns` can be a static object or a per-file callback.
414
+ * Separated from `writeCaptureLog` for testability.
415
+ */
416
+ declare function buildCaptureLogDoc(fileResults: TestFileResult[], matchContext: (file: TestFile) => {
417
+ root: string;
418
+ cwd: string;
419
+ }, customPatterns?: Record<string, string | RegExp> | ((file: TestFile) => Record<string, string | RegExp>)): CaptureLogDoc;
420
+ /**
421
+ * Write a YAML capture log file recording wildcard captures and execution metadata.
422
+ */
423
+ declare function writeCaptureLog(path: string, fileResults: TestFileResult[], matchContext: (file: TestFile) => {
424
+ root: string;
425
+ cwd: string;
426
+ }, customPatterns?: Record<string, string | RegExp> | ((file: TestFile) => Record<string, string | RegExp>)): Promise<void>;
427
+ //#endregion
428
+ //#region src/lib/yaml-utils.d.ts
429
+ /**
430
+ * Manual key order comparator for YAML `sortMapEntries`.
431
+ *
432
+ * Keys listed in `order` appear first (in that order); unlisted keys sort
433
+ * to the end alphabetically. Adapted from tbd sorting patterns
434
+ * (`ordering.manual`).
435
+ */
436
+ declare function manualKeyOrder(order: readonly string[]): (a: {
437
+ key: {
438
+ value: string;
439
+ };
440
+ }, b: {
441
+ key: {
442
+ value: string;
443
+ };
444
+ }) => number;
445
+ declare function stringifyYaml(data: unknown, options?: object): string;
307
446
  //#endregion
308
447
  //#region src/index.d.ts
309
448
  declare const VERSION: string;
310
449
  //#endregion
311
- export { type CoverageConfig, type CoverageContext, type ExecutionContext, type TestBlock, type TestBlockResult, type TestConfig, type TestFile, type TestFileResult, type TestRunSummary, type TryscriptConfig, VERSION, cleanupExecutionContext, createExecutionContext, defineConfig, matchOutput, normalizeOutput, parseTestFile, runBlock };
450
+ export { type CoverageConfig, type CoverageContext, type ExecutionContext, type ExpandLevel, type ExpansionResult, type TestBlock, type TestBlockResult, type TestConfig, type TestFile, type TestFileResult, type TestRunSummary, type TryscriptConfig, VERSION, type WildcardCapture, type WildcardCategory, buildCaptureLogDoc, cleanupExecutionContext, createExecutionContext, defineConfig, expandExpectedOutput, expandTestFile, manualKeyOrder, matchAndCapture, matchOutput, normalizeOutput, parseTestFile, runBlock, shouldExpandCategory, stringifyYaml, writeCaptureLog };
312
451
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
- import { a as createExecutionContext, c as parseTestFile, i as cleanupExecutionContext, l as defineConfig, n as matchOutput, r as normalizeOutput, s as runBlock, t as VERSION } from "./src-Bd9-Y0qp.mjs";
2
+ import { _ as defineConfig, a as stringifyYaml, c as shouldExpandCategory, d as normalizeOutput, f as cleanupExecutionContext, g as parseTestFile, h as runBlock, i as manualKeyOrder, l as matchAndCapture, n as buildCaptureLogDoc, o as expandExpectedOutput, p as createExecutionContext, r as writeCaptureLog, s as expandTestFile, t as VERSION, u as matchOutput } from "./src-BQxIhzgF.mjs";
3
3
 
4
- export { VERSION, cleanupExecutionContext, createExecutionContext, defineConfig, matchOutput, normalizeOutput, parseTestFile, runBlock };
4
+ export { VERSION, buildCaptureLogDoc, cleanupExecutionContext, createExecutionContext, defineConfig, expandExpectedOutput, expandTestFile, manualKeyOrder, matchAndCapture, matchOutput, normalizeOutput, parseTestFile, runBlock, shouldExpandCategory, stringifyYaml, writeCaptureLog };