tstyche 6.1.0 → 6.2.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/dist/tstyche.d.ts CHANGED
@@ -156,6 +156,7 @@ interface CommandLineOptions {
156
156
  target?: Array<string>;
157
157
  tsconfig?: string;
158
158
  update?: boolean;
159
+ verbose?: boolean;
159
160
  version?: boolean;
160
161
  watch?: boolean;
161
162
  }
@@ -172,6 +173,7 @@ interface ConfigFileOptions {
172
173
  target?: Array<string>;
173
174
  testFileMatch?: Array<string>;
174
175
  tsconfig?: string;
176
+ verbose?: boolean;
175
177
  }
176
178
 
177
179
  interface InlineConfig {
@@ -308,6 +310,11 @@ declare abstract class BaseReporter implements Reporter {
308
310
  abstract on([event, payload]: ReporterEvent): void;
309
311
  }
310
312
 
313
+ declare class DotReporter extends BaseReporter {
314
+ #private;
315
+ on([event, payload]: ReporterEvent): void;
316
+ }
317
+
311
318
  declare class ListReporter extends BaseReporter {
312
319
  #private;
313
320
  on([event, payload]: ReporterEvent): void;
@@ -592,7 +599,9 @@ interface TextProps {
592
599
  }
593
600
  declare function Text({ children, color, indent }: TextProps): ScribblerJsx.Element;
594
601
 
595
- declare function addsPackageText(packageVersion: string, packagePath: string): ScribblerJsx.Element;
602
+ declare function addsPackageText(packageVersion: string, packagePath: string, options?: {
603
+ short?: boolean;
604
+ }): ScribblerJsx.Element;
596
605
 
597
606
  declare function describeNameText(name: string, indent?: number): ScribblerJsx.Element;
598
607
 
@@ -604,9 +613,9 @@ interface CodeFrameOptions {
604
613
 
605
614
  declare function diagnosticText(diagnostic: Diagnostic, codeFrameOptions?: CodeFrameOptions): ScribblerJsx.Element;
606
615
 
607
- declare function fileStatusText(status: FileResultStatus, file: FileLocation): ScribblerJsx.Element;
616
+ declare function dotText(status: ResultStatus): ScribblerJsx.Element;
608
617
 
609
- declare function fileViewText(lines: Array<ScribblerJsx.Element>, addEmptyFinalLine: boolean): ScribblerJsx.Element;
618
+ declare function fileStatusText(status: FileResultStatus, file: FileLocation): ScribblerJsx.Element;
610
619
 
611
620
  declare function formattedText(input: string | Array<string> | Record<string, unknown>): ScribblerJsx.Element;
612
621
 
@@ -626,6 +635,7 @@ declare class OutputService {
626
635
  static outputStream: StreamController;
627
636
  static clearTerminal(): void;
628
637
  static eraseLastLine(): void;
638
+ static writeBlankLine(count?: number): void;
629
639
  static writeError(element: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
630
640
  static writeMessage(element: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
631
641
  static writeWarning(element: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
@@ -646,7 +656,8 @@ declare function summaryText({ targetCounts, fileCounts, testCounts, assertionCo
646
656
  declare function testNameText(status: Exclude<TestResultStatus, ResultStatus.Runs>, name: string, indent?: number): ScribblerJsx.Element;
647
657
 
648
658
  declare function usesCompilerText(compilerVersion: string, projectConfigFilePath: string | undefined, options?: {
649
- prependEmptyLine: boolean;
659
+ prependEmptyLine?: boolean;
660
+ short?: boolean;
650
661
  }): ScribblerJsx.Element;
651
662
 
652
663
  declare function waitingForFileChangesText(): ScribblerJsx.Element;
@@ -732,5 +743,5 @@ declare class Version {
732
743
  static isSatisfiedWith(source: string, target: string): boolean;
733
744
  }
734
745
 
735
- export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, ProjectResult, Result, ResultStatus, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, Store, StreamController, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsPackageText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileStatusText, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, prologueText, summaryText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
746
+ export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, DotReporter, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, ProjectResult, Result, ResultStatus, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, Store, StreamController, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsPackageText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, dotText, environmentOptions, fileStatusText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, prologueText, summaryText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
736
747
  export type { AssertionCounts, AssertionResultStatus, CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, DirectiveRange, EnvironmentOptions, Event, EventHandler, FileCounts, FileResultStatus, InlineConfig, ItemDefinition, OptionDefinition, Reporter, ReporterEvent, ResolvedConfig, ResultCounts, ResultTiming, ScribblerOptions, SuppressedCounts, SuppressedResultStatus, TargetCounts, TargetResultStatus, TestCounts, TestResultStatus, TextRange };
package/dist/tstyche.js CHANGED
@@ -375,7 +375,7 @@ class ConfigDiagnosticText {
375
375
  static fileMatchPatternCannotStartWith(optionName, segment) {
376
376
  return [
377
377
  `A '${optionName}' pattern cannot start with '${segment}'.`,
378
- "The files are only collected within the 'rootPath' directory.",
378
+ "The files are only collected within the root directory.",
379
379
  ];
380
380
  }
381
381
  static inspectSupportedVersions() {
@@ -1179,6 +1179,12 @@ class Options {
1179
1179
  group: 2,
1180
1180
  name: "update",
1181
1181
  },
1182
+ {
1183
+ brand: "boolean",
1184
+ description: "Enable detailed logging.",
1185
+ group: 2 | 4,
1186
+ name: "verbose",
1187
+ },
1182
1188
  {
1183
1189
  brand: "true",
1184
1190
  description: "Print the version number and exit.",
@@ -1205,7 +1211,7 @@ class Options {
1205
1211
  return optionName.startsWith("--") ? optionName.slice(2) : optionName;
1206
1212
  }
1207
1213
  static #isBuiltinReporter(optionValue) {
1208
- return ["list", "summary"].includes(optionValue);
1214
+ return ["dot", "list", "summary"].includes(optionValue);
1209
1215
  }
1210
1216
  static #isLookupStrategy(optionValue) {
1211
1217
  return ["findup", "ignore"].includes(optionValue);
@@ -1578,6 +1584,7 @@ const defaultOptions = {
1578
1584
  target: ["*"],
1579
1585
  testFileMatch: ["**/*.tst.*", "**/__typetests__/*.test.*", "**/typetests/*.test.*"],
1580
1586
  tsconfig: "findup",
1587
+ verbose: false,
1581
1588
  };
1582
1589
 
1583
1590
  class Config {
@@ -2222,7 +2229,10 @@ class Scribbler {
2222
2229
  }
2223
2230
  }
2224
2231
 
2225
- function addsPackageText(packageVersion, packagePath) {
2232
+ function addsPackageText(packageVersion, packagePath, options) {
2233
+ if (options?.short) {
2234
+ return (jsx(Line, { children: jsx(Text, { color: "90", children: packageVersion }) }));
2235
+ }
2226
2236
  return (jsx(Line, { children: [jsx(Text, { color: "90", children: "adds" }), " TypeScript ", packageVersion, jsx(Text, { color: "90", children: [" to ", packagePath] })] }));
2227
2237
  }
2228
2238
 
@@ -2319,6 +2329,16 @@ function diagnosticText(diagnostic, codeFrameOptions = {}) {
2319
2329
  return (jsx(Text, { children: [prefix, jsx(DiagnosticText, { codeFrameOptions: codeFrameOptions, diagnostic: diagnostic })] }));
2320
2330
  }
2321
2331
 
2332
+ function dotText(status) {
2333
+ let statusColor;
2334
+ let statusText = "·";
2335
+ if (status === "failed") {
2336
+ statusColor = "31";
2337
+ statusText = "×";
2338
+ }
2339
+ return jsx(Text, { color: statusColor, children: statusText });
2340
+ }
2341
+
2322
2342
  function getStatusColor(status) {
2323
2343
  switch (status) {
2324
2344
  case "runs":
@@ -2366,10 +2386,6 @@ function fileStatusText(status, file) {
2366
2386
  return (jsx(Line, { children: [jsx(Text, { color: getStatusColor(status), children: statusText }), " ", jsx(FileNameText, { filePath: file.path })] }));
2367
2387
  }
2368
2388
 
2369
- function fileViewText(lines, addEmptyFinalLine) {
2370
- return (jsx(Text, { children: [[...lines], addEmptyFinalLine ? jsx(Line, {}) : undefined] }));
2371
- }
2372
-
2373
2389
  function formattedText(input) {
2374
2390
  if (typeof input === "string") {
2375
2391
  return jsx(Line, { children: input });
@@ -2460,7 +2476,8 @@ class OutputService {
2460
2476
  static errorStream = new StreamController(process.stderr);
2461
2477
  static outputStream = new StreamController(process.stdout);
2462
2478
  static #isClear = false;
2463
- static #scribbler = new Scribbler();
2479
+ static #newLine = "\n";
2480
+ static #scribbler = new Scribbler({ newLine: OutputService.#newLine });
2464
2481
  static clearTerminal() {
2465
2482
  if (!OutputService.#isClear) {
2466
2483
  OutputService.outputStream.write("\u001B[2J\u001B[3J\u001B[H");
@@ -2470,21 +2487,24 @@ class OutputService {
2470
2487
  static eraseLastLine() {
2471
2488
  OutputService.outputStream.write("\u001B[1A\u001B[0K");
2472
2489
  }
2473
- static #writeTo(stream, element) {
2490
+ static #write(stream, element) {
2474
2491
  const elements = Array.isArray(element) ? element : [element];
2475
2492
  for (const element of elements) {
2476
2493
  stream.write(OutputService.#scribbler.render(element));
2477
2494
  }
2478
2495
  OutputService.#isClear = false;
2479
2496
  }
2497
+ static writeBlankLine(count = 1) {
2498
+ OutputService.outputStream.write(OutputService.#newLine.repeat(count));
2499
+ }
2480
2500
  static writeError(element) {
2481
- OutputService.#writeTo(OutputService.errorStream, element);
2501
+ OutputService.#write(OutputService.errorStream, element);
2482
2502
  }
2483
2503
  static writeMessage(element) {
2484
- OutputService.#writeTo(OutputService.outputStream, element);
2504
+ OutputService.#write(OutputService.outputStream, element);
2485
2505
  }
2486
2506
  static writeWarning(element) {
2487
- OutputService.#writeTo(OutputService.errorStream, element);
2507
+ OutputService.#write(OutputService.errorStream, element);
2488
2508
  }
2489
2509
  }
2490
2510
 
@@ -2544,6 +2564,9 @@ function testNameText(status, name, indent = 0) {
2544
2564
  }
2545
2565
 
2546
2566
  function usesCompilerText(compilerVersion, projectConfigFilePath, options) {
2567
+ if (options?.short) {
2568
+ return jsx(Text, { color: "34", children: compilerVersion });
2569
+ }
2547
2570
  let projectConfigPathText;
2548
2571
  if (projectConfigFilePath != null) {
2549
2572
  projectConfigPathText = (jsx(Text, { color: "90", children: [" with ", Path.relative("", projectConfigFilePath)] }));
@@ -2573,6 +2596,55 @@ class BaseReporter {
2573
2596
  }
2574
2597
  }
2575
2598
 
2599
+ class DotReporter extends BaseReporter {
2600
+ #diagnostics = [];
2601
+ #hasReportedAdds = false;
2602
+ on([event, payload]) {
2603
+ switch (event) {
2604
+ case "store:adds":
2605
+ OutputService.writeMessage(addsPackageText(payload.packageVersion, payload.packagePath, { short: true }));
2606
+ this.#hasReportedAdds = true;
2607
+ break;
2608
+ case "store:error":
2609
+ for (const diagnostic of payload.diagnostics) {
2610
+ OutputService.writeError(diagnosticText(diagnostic));
2611
+ }
2612
+ break;
2613
+ case "project:uses":
2614
+ if (this.#hasReportedAdds) {
2615
+ if (!environmentOptions.noInteractive) {
2616
+ OutputService.eraseLastLine();
2617
+ }
2618
+ this.#hasReportedAdds = false;
2619
+ }
2620
+ if (this.resolvedConfig.target.length > 1) {
2621
+ OutputService.writeMessage(usesCompilerText(payload.compilerVersion, payload.projectConfigFilePath, { short: true }));
2622
+ }
2623
+ break;
2624
+ case "target:end":
2625
+ OutputService.writeBlankLine(2);
2626
+ for (const diagnostic of this.#diagnostics) {
2627
+ OutputService.writeError(diagnosticText(diagnostic));
2628
+ }
2629
+ this.#diagnostics = [];
2630
+ break;
2631
+ case "file:end":
2632
+ OutputService.writeMessage(dotText(payload.result.status));
2633
+ break;
2634
+ case "project:error":
2635
+ case "file:error":
2636
+ case "directive:error":
2637
+ case "collect:error":
2638
+ case "test:error":
2639
+ case "suppressed:error":
2640
+ case "expect:error":
2641
+ case "expect:fail":
2642
+ this.#diagnostics.push(...payload.diagnostics);
2643
+ break;
2644
+ }
2645
+ }
2646
+ }
2647
+
2576
2648
  class FileView {
2577
2649
  #indent = 0;
2578
2650
  #lines = [];
@@ -2598,8 +2670,8 @@ class FileView {
2598
2670
  getMessages() {
2599
2671
  return this.#messages;
2600
2672
  }
2601
- getViewText(options) {
2602
- return fileViewText(this.#lines, options?.appendEmptyLine || this.hasErrors());
2673
+ getView() {
2674
+ return this.#lines;
2603
2675
  }
2604
2676
  hasErrors() {
2605
2677
  return this.#messages.length > 0;
@@ -2612,14 +2684,12 @@ class ListReporter extends BaseReporter {
2612
2684
  #hasReportedAdds = false;
2613
2685
  #hasReportedError = false;
2614
2686
  #hasReportedUses = false;
2615
- #isFileViewExpanded = false;
2616
- #isLastFile() {
2617
- return this.#fileCount === 0;
2618
- }
2687
+ #isVerbose = false;
2619
2688
  on([event, payload]) {
2620
2689
  switch (event) {
2621
2690
  case "run:start":
2622
- this.#isFileViewExpanded = payload.result.files.length === 1 && this.resolvedConfig.watch !== true;
2691
+ this.#isVerbose =
2692
+ this.resolvedConfig.verbose || (payload.result.files.length === 1 && this.resolvedConfig.watch !== true);
2623
2693
  break;
2624
2694
  case "store:adds":
2625
2695
  OutputService.writeMessage(addsPackageText(payload.packageVersion, payload.packagePath));
@@ -2666,7 +2736,10 @@ class ListReporter extends BaseReporter {
2666
2736
  OutputService.eraseLastLine();
2667
2737
  }
2668
2738
  OutputService.writeMessage(fileStatusText(payload.result.status, payload.result.file));
2669
- OutputService.writeMessage(this.#fileView.getViewText({ appendEmptyLine: this.#isLastFile() }));
2739
+ OutputService.writeMessage(this.#fileView.getView());
2740
+ if (this.#isVerbose || this.#fileCount === 0 || this.#fileView.hasErrors()) {
2741
+ OutputService.writeBlankLine();
2742
+ }
2670
2743
  if (this.#fileView.hasErrors()) {
2671
2744
  OutputService.writeError(this.#fileView.getMessages());
2672
2745
  this.#hasReportedError = true;
@@ -2674,32 +2747,32 @@ class ListReporter extends BaseReporter {
2674
2747
  this.#fileView.clear();
2675
2748
  break;
2676
2749
  case "describe:start":
2677
- if (this.#isFileViewExpanded) {
2750
+ if (this.#isVerbose) {
2678
2751
  this.#fileView.beginDescribe(payload.result.describe.name);
2679
2752
  }
2680
2753
  break;
2681
2754
  case "describe:end":
2682
- if (this.#isFileViewExpanded) {
2755
+ if (this.#isVerbose) {
2683
2756
  this.#fileView.endDescribe();
2684
2757
  }
2685
2758
  break;
2686
2759
  case "test:skip":
2687
- if (this.#isFileViewExpanded) {
2760
+ if (this.#isVerbose) {
2688
2761
  this.#fileView.addTest("skipped", payload.result.test.name);
2689
2762
  }
2690
2763
  break;
2691
2764
  case "test:fixme":
2692
- if (this.#isFileViewExpanded) {
2765
+ if (this.#isVerbose) {
2693
2766
  this.#fileView.addTest("fixme", payload.result.test.name);
2694
2767
  }
2695
2768
  break;
2696
2769
  case "test:todo":
2697
- if (this.#isFileViewExpanded) {
2770
+ if (this.#isVerbose) {
2698
2771
  this.#fileView.addTest("todo", payload.result.test.name);
2699
2772
  }
2700
2773
  break;
2701
2774
  case "test:error":
2702
- if (this.#isFileViewExpanded) {
2775
+ if (this.#isVerbose) {
2703
2776
  this.#fileView.addTest("failed", payload.result.test.name);
2704
2777
  }
2705
2778
  for (const diagnostic of payload.diagnostics) {
@@ -2707,12 +2780,12 @@ class ListReporter extends BaseReporter {
2707
2780
  }
2708
2781
  break;
2709
2782
  case "test:fail":
2710
- if (this.#isFileViewExpanded) {
2783
+ if (this.#isVerbose) {
2711
2784
  this.#fileView.addTest("failed", payload.result.test.name);
2712
2785
  }
2713
2786
  break;
2714
2787
  case "test:pass":
2715
- if (this.#isFileViewExpanded) {
2788
+ if (this.#isVerbose) {
2716
2789
  this.#fileView.addTest("passed", payload.result.test.name);
2717
2790
  }
2718
2791
  break;
@@ -2995,7 +3068,7 @@ class Glob {
2995
3068
  class SelectDiagnosticText {
2996
3069
  static #pathSelectOptions(resolvedConfig) {
2997
3070
  const text = [
2998
- `Root path: ${resolvedConfig.rootPath}`,
3071
+ `Root directory: ${resolvedConfig.rootPath}`,
2999
3072
  `Test file match: ${resolvedConfig.testFileMatch.join(", ")}`,
3000
3073
  ];
3001
3074
  if (resolvedConfig.pathMatch.length > 0) {
@@ -5955,7 +6028,7 @@ class FileRunner {
5955
6028
  class Runner {
5956
6029
  #eventEmitter = new EventEmitter();
5957
6030
  #resolvedConfig;
5958
- static version = "6.1.0";
6031
+ static version = "6.2.0";
5959
6032
  constructor(resolvedConfig) {
5960
6033
  this.#resolvedConfig = resolvedConfig;
5961
6034
  }
@@ -5974,14 +6047,16 @@ class Runner {
5974
6047
  }
5975
6048
  for (const reporter of this.#resolvedConfig.reporters) {
5976
6049
  switch (reporter) {
6050
+ case "dot": {
6051
+ this.#eventEmitter.addReporter(new DotReporter(this.#resolvedConfig));
6052
+ break;
6053
+ }
5977
6054
  case "list": {
5978
- const listReporter = new ListReporter(this.#resolvedConfig);
5979
- this.#eventEmitter.addReporter(listReporter);
6055
+ this.#eventEmitter.addReporter(new ListReporter(this.#resolvedConfig));
5980
6056
  break;
5981
6057
  }
5982
6058
  case "summary": {
5983
- const summaryReporter = new SummaryReporter(this.#resolvedConfig);
5984
- this.#eventEmitter.addReporter(summaryReporter);
6059
+ this.#eventEmitter.addReporter(new SummaryReporter(this.#resolvedConfig));
5985
6060
  break;
5986
6061
  }
5987
6062
  default: {
@@ -6161,4 +6236,4 @@ class Cli {
6161
6236
  }
6162
6237
  }
6163
6238
 
6164
- export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, ProjectResult, Result, ResultStatus, Runner, Scribbler, Select, SelectDiagnosticText, SetupReporter, Store, StreamController, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsPackageText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileStatusText, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, prologueText, summaryText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
6239
+ export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, DotReporter, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, ProjectResult, Result, ResultStatus, Runner, Scribbler, Select, SelectDiagnosticText, SetupReporter, Store, StreamController, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsPackageText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, dotText, environmentOptions, fileStatusText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, prologueText, summaryText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tstyche",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "description": "Everything You Need for Type Testing.",
5
5
  "keywords": [
6
6
  "typescript",