tryscript 0.1.5 → 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
@@ -159,6 +159,8 @@ declare const CoverageConfigSchema: z.ZodObject<{
159
159
  src: z.ZodOptional<z.ZodString>;
160
160
  /** Use monocart for more accurate line counts (c8 --experimental-monocart) */
161
161
  monocart: z.ZodOptional<z.ZodBoolean>;
162
+ /** Path to external LCOV file to merge (e.g., vitest coverage output) */
163
+ mergeLcov: z.ZodOptional<z.ZodString>;
162
164
  }, "strip", z.ZodTypeAny, {
163
165
  reportsDir?: string | undefined;
164
166
  reporters?: string[] | undefined;
@@ -170,6 +172,7 @@ declare const CoverageConfigSchema: z.ZodObject<{
170
172
  allowExternal?: boolean | undefined;
171
173
  src?: string | undefined;
172
174
  monocart?: boolean | undefined;
175
+ mergeLcov?: string | undefined;
173
176
  }, {
174
177
  reportsDir?: string | undefined;
175
178
  reporters?: string[] | undefined;
@@ -181,6 +184,7 @@ declare const CoverageConfigSchema: z.ZodObject<{
181
184
  allowExternal?: boolean | undefined;
182
185
  src?: string | undefined;
183
186
  monocart?: boolean | undefined;
187
+ mergeLcov?: string | undefined;
184
188
  }>;
185
189
  /**
186
190
  * Coverage configuration options.
@@ -188,12 +192,51 @@ declare const CoverageConfigSchema: z.ZodObject<{
188
192
  type CoverageConfig = z.infer<typeof CoverageConfigSchema>;
189
193
  /**
190
194
  * Runtime context for coverage collection during test execution.
195
+ * Note: options type uses Omit to make mergeLcov remain optional (no default value).
191
196
  */
192
197
  interface CoverageContext {
193
198
  /** Temporary directory for V8 coverage data files */
194
199
  tempDir: string;
195
200
  /** Resolved coverage options with defaults applied */
196
- options: Required<CoverageConfig>;
201
+ options: Omit<Required<CoverageConfig>, 'mergeLcov'> & {
202
+ mergeLcov?: string;
203
+ };
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;
197
240
  }
198
241
  //#endregion
199
242
  //#region src/lib/config.d.ts
@@ -297,9 +340,112 @@ declare function matchOutput(actual: string, expected: string, context: {
297
340
  root: string;
298
341
  cwd: string;
299
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;
300
446
  //#endregion
301
447
  //#region src/index.d.ts
302
448
  declare const VERSION: string;
303
449
  //#endregion
304
- 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 };
305
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-CC3xA1cp.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 };