tstyche 3.0.0-beta.0 → 3.0.0-beta.1

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.
Files changed (3) hide show
  1. package/build/tstyche.d.ts +141 -159
  2. package/build/tstyche.js +2685 -2711
  3. package/package.json +9 -9
@@ -1,52 +1,5 @@
1
1
  import type ts from 'typescript';
2
2
 
3
- declare class StoreService {
4
- #private;
5
- constructor();
6
- getSupportedTags(): Promise<Array<string>>;
7
- install(tag: string): Promise<string | undefined>;
8
- load(tag: string): Promise<typeof ts | undefined>;
9
- open(): Promise<void>;
10
- update(): Promise<void>;
11
- validateTag(tag: string): Promise<boolean | undefined>;
12
- }
13
-
14
- declare enum OptionBrand {
15
- String = "string",
16
- Number = "number",
17
- Boolean = "boolean",
18
- BareTrue = "bareTrue",// a boolean option that does not take a value and when specified is interpreted as 'true'
19
- List = "list"
20
- }
21
- declare enum OptionGroup {
22
- CommandLine = 2,
23
- ConfigFile = 4
24
- }
25
-
26
- interface ItemDefinition {
27
- brand: OptionBrand.String;
28
- name: string;
29
- pattern?: string;
30
- }
31
- type OptionDefinition = PrimitiveTypeOptionDefinition | ListTypeOptionDefinition;
32
- interface BaseOptionDefinition {
33
- brand: OptionBrand;
34
- description: string;
35
- group: OptionGroup;
36
- name: string;
37
- }
38
- interface PrimitiveTypeOptionDefinition extends BaseOptionDefinition {
39
- brand: OptionBrand.String | OptionBrand.Number | OptionBrand.Boolean | OptionBrand.BareTrue;
40
- }
41
- interface ListTypeOptionDefinition extends BaseOptionDefinition {
42
- brand: OptionBrand.List;
43
- items: ItemDefinition;
44
- }
45
- declare class OptionDefinitionsMap {
46
- #private;
47
- static for(optionGroup: OptionGroup): Map<string, OptionDefinition>;
48
- }
49
-
50
3
  declare class TestTree {
51
4
  diagnostics: Set<ts.Diagnostic>;
52
5
  members: Array<TestMember | Assertion>;
@@ -135,6 +88,28 @@ declare class Diagnostic {
135
88
  static warning(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
136
89
  }
137
90
 
91
+ /**
92
+ * Options loaded from the configuration file.
93
+ */
94
+ interface ConfigFileOptions {
95
+ /**
96
+ * Stop running tests after the first failed assertion.
97
+ */
98
+ failFast?: boolean;
99
+ /**
100
+ * The path to a directory containing files of a test project.
101
+ */
102
+ rootPath?: string;
103
+ /**
104
+ * The list of TypeScript versions to be tested on.
105
+ */
106
+ target?: Array<string>;
107
+ /**
108
+ * The list of glob patterns matching the test files.
109
+ */
110
+ testFileMatch?: Array<string>;
111
+ }
112
+
138
113
  /**
139
114
  * Options passed through the command line.
140
115
  */
@@ -193,6 +168,49 @@ interface CommandLineOptions {
193
168
  watch?: boolean;
194
169
  }
195
170
 
171
+ interface EnvironmentOptions {
172
+ /**
173
+ * Is `true` if the process is running in a continuous integration environment.
174
+ */
175
+ isCi: boolean;
176
+ /**
177
+ * Specifies whether color should be disabled in the output.
178
+ */
179
+ noColor: boolean;
180
+ /**
181
+ * Specifies whether interactive elements should be disabled in the output.
182
+ */
183
+ noInteractive: boolean;
184
+ /**
185
+ * The base URL of the 'npm' registry to use.
186
+ */
187
+ npmRegistry: string;
188
+ /**
189
+ * The directory where to store the 'typescript' packages.
190
+ */
191
+ storePath: string;
192
+ /**
193
+ * The number of seconds to wait before giving up stale operations.
194
+ */
195
+ timeout: number;
196
+ /**
197
+ * The path to the currently installed TypeScript module.
198
+ */
199
+ typescriptPath: string | undefined;
200
+ }
201
+
202
+ declare enum OptionBrand {
203
+ String = "string",
204
+ Number = "number",
205
+ Boolean = "boolean",
206
+ BareTrue = "bareTrue",// a boolean option that does not take a value and when specified is interpreted as 'true'
207
+ List = "list"
208
+ }
209
+ declare enum OptionGroup {
210
+ CommandLine = 2,
211
+ ConfigFile = 4
212
+ }
213
+
196
214
  declare class ConfigDiagnosticText {
197
215
  #private;
198
216
  static doubleQuotesExpected(): string;
@@ -206,29 +224,19 @@ declare class ConfigDiagnosticText {
206
224
  static watchCannotBeEnabled(): string;
207
225
  }
208
226
 
209
- /**
210
- * Options loaded from the configuration file.
211
- */
212
- interface ConfigFileOptions {
213
- /**
214
- * Stop running tests after the first failed assertion.
215
- */
216
- failFast?: boolean;
217
- /**
218
- * The path to a directory containing files of a test project.
219
- */
220
- rootPath?: string;
221
- /**
222
- * The list of TypeScript versions to be tested on.
223
- */
224
- target?: Array<string>;
225
- /**
226
- * The list of glob patterns matching the test files.
227
- */
228
- testFileMatch?: Array<string>;
227
+ declare class StoreService {
228
+ #private;
229
+ constructor();
230
+ getSupportedTags(): Promise<Array<string> | undefined>;
231
+ install(tag: string): Promise<void>;
232
+ load(tag: string): Promise<typeof ts | undefined>;
233
+ open(): Promise<void>;
234
+ prune(): Promise<void>;
235
+ update(): Promise<void>;
236
+ validateTag(tag: string): Promise<boolean | undefined>;
229
237
  }
230
238
 
231
- interface ResolvedConfig extends Omit<CommandLineOptions, keyof ConfigFileOptions | "config">, Required<ConfigFileOptions> {
239
+ interface ResolvedConfig extends EnvironmentOptions, Omit<CommandLineOptions, keyof ConfigFileOptions | "config">, Required<ConfigFileOptions> {
232
240
  /**
233
241
  * The path to a TSTyche configuration file.
234
242
  */
@@ -238,15 +246,41 @@ interface ResolvedConfig extends Omit<CommandLineOptions, keyof ConfigFileOption
238
246
  */
239
247
  pathMatch: Array<string>;
240
248
  }
241
- declare const defaultOptions: Required<ConfigFileOptions>;
242
249
  declare class ConfigService {
243
250
  #private;
244
- constructor(compiler: typeof ts, storeService: StoreService);
245
- parseCommandLine(commandLineArgs: Array<string>): Promise<void>;
246
- readConfigFile(): Promise<void>;
251
+ parseCommandLine(commandLineArgs: Array<string>, storeService: StoreService): Promise<void>;
252
+ readConfigFile(storeService: StoreService): Promise<void>;
247
253
  resolveConfig(): ResolvedConfig;
248
254
  }
249
255
 
256
+ interface ItemDefinition {
257
+ brand: OptionBrand.String;
258
+ name: string;
259
+ pattern?: string;
260
+ }
261
+ type OptionDefinition = PrimitiveTypeOptionDefinition | ListTypeOptionDefinition;
262
+ interface BaseOptionDefinition {
263
+ brand: OptionBrand;
264
+ description: string;
265
+ group: OptionGroup;
266
+ name: string;
267
+ }
268
+ interface PrimitiveTypeOptionDefinition extends BaseOptionDefinition {
269
+ brand: OptionBrand.String | OptionBrand.Number | OptionBrand.Boolean | OptionBrand.BareTrue;
270
+ }
271
+ interface ListTypeOptionDefinition extends BaseOptionDefinition {
272
+ brand: OptionBrand.List;
273
+ items: ItemDefinition;
274
+ }
275
+ declare class OptionDefinitionsMap {
276
+ #private;
277
+ static for(optionGroup: OptionGroup): Map<string, OptionDefinition>;
278
+ }
279
+
280
+ declare const defaultOptions: Required<ConfigFileOptions>;
281
+
282
+ declare const environmentOptions: EnvironmentOptions;
283
+
250
284
  declare enum Color {
251
285
  Reset = "0",
252
286
  Red = "31",
@@ -304,19 +338,12 @@ interface TextProps {
304
338
  }
305
339
  declare function Text({ children, color, indent }: TextProps): ScribblerJsx.Element;
306
340
 
307
- declare function addsPackageStepText(packageVersion: string, packagePath: string): ScribblerJsx.Element;
341
+ declare function addsPackageText(packageVersion: string, packagePath: string): ScribblerJsx.Element;
308
342
 
309
343
  declare function describeNameText(name: string, indent?: number): ScribblerJsx.Element;
310
344
 
311
345
  declare function diagnosticText(diagnostic: Diagnostic): ScribblerJsx.Element;
312
346
 
313
- declare class TestFile {
314
- #private;
315
- path: string;
316
- position: number | undefined;
317
- constructor(identifier: string | URL, position?: number);
318
- }
319
-
320
347
  declare class ResultTiming {
321
348
  end: number;
322
349
  start: number;
@@ -367,23 +394,30 @@ declare class DescribeResult {
367
394
  constructor(describe: TestMember, parent?: DescribeResult);
368
395
  }
369
396
 
370
- type FileResultStatus = ResultStatus.Runs | ResultStatus.Passed | ResultStatus.Failed;
371
- declare class FileResult {
397
+ declare class Task {
398
+ #private;
399
+ filePath: string;
400
+ position: number | undefined;
401
+ constructor(filePath: string | URL, position?: number);
402
+ }
403
+
404
+ type TaskResultStatus = ResultStatus.Runs | ResultStatus.Passed | ResultStatus.Failed;
405
+ declare class TaskResult {
372
406
  diagnostics: Array<Diagnostic>;
373
407
  expectCount: ResultCount;
374
408
  results: Array<DescribeResult | TestResult | ExpectResult>;
375
- status: FileResultStatus;
409
+ status: TaskResultStatus;
410
+ task: Task;
376
411
  testCount: ResultCount;
377
- testFile: TestFile;
378
412
  timing: ResultTiming;
379
- constructor(testFile: TestFile);
413
+ constructor(task: Task);
380
414
  }
381
415
 
382
416
  declare class ProjectResult {
383
417
  compilerVersion: string;
384
418
  diagnostics: Array<Diagnostic>;
385
419
  projectConfigFilePath: string | undefined;
386
- results: Array<FileResult>;
420
+ results: Array<TaskResult>;
387
421
  constructor(compilerVersion: string, projectConfigFilePath: string | undefined);
388
422
  }
389
423
 
@@ -391,10 +425,10 @@ type TargetResultStatus = ResultStatus.Runs | ResultStatus.Passed | ResultStatus
391
425
  declare class TargetResult {
392
426
  results: Map<string | undefined, ProjectResult>;
393
427
  status: TargetResultStatus;
394
- testFiles: Array<TestFile>;
428
+ tasks: Array<Task>;
395
429
  timing: ResultTiming;
396
430
  versionTag: string;
397
- constructor(versionTag: string, testFiles: Array<TestFile>);
431
+ constructor(versionTag: string, tasks: Array<Task>);
398
432
  }
399
433
 
400
434
  declare class Result {
@@ -403,13 +437,13 @@ declare class Result {
403
437
  resolvedConfig: ResolvedConfig;
404
438
  results: Array<TargetResult>;
405
439
  targetCount: ResultCount;
440
+ tasks: Array<Task>;
406
441
  testCount: ResultCount;
407
- testFiles: Array<TestFile>;
408
442
  timing: ResultTiming;
409
- constructor(resolvedConfig: ResolvedConfig, testFiles: Array<TestFile>);
443
+ constructor(resolvedConfig: ResolvedConfig, tasks: Array<Task>);
410
444
  }
411
445
 
412
- declare function fileStatusText(status: FileResultStatus, testFile: TestFile): ScribblerJsx.Element;
446
+ declare function taskStatusText(status: TaskResultStatus, task: Task): ScribblerJsx.Element;
413
447
 
414
448
  declare function fileViewText(lines: Array<ScribblerJsx.Element>, addEmptyFinalLine: boolean): ScribblerJsx.Element;
415
449
 
@@ -417,17 +451,9 @@ declare function formattedText(input: string | Array<string> | Record<string, un
417
451
 
418
452
  declare function helpText(optionDefinitions: Map<string, OptionDefinition>, tstycheVersion: string): ScribblerJsx.Element;
419
453
 
420
- interface WriteStream {
421
- write: (chunk: string) => void;
422
- }
423
- interface OutputServiceOptions {
424
- noColor?: boolean;
425
- stderr?: WriteStream;
426
- stdout?: WriteStream;
427
- }
428
454
  declare class OutputService {
429
455
  #private;
430
- constructor(options?: OutputServiceOptions);
456
+ constructor();
431
457
  clearTerminal(): void;
432
458
  eraseLastLine(): void;
433
459
  writeError(element: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
@@ -448,7 +474,7 @@ declare function summaryText({ duration, expectCount, fileCount, onlyMatch, path
448
474
 
449
475
  declare function testNameText(status: "fail" | "pass" | "skip" | "todo", name: string, indent?: number): ScribblerJsx.Element;
450
476
 
451
- declare function usesCompilerStepText(compilerVersion: string, tsconfigFilePath: string | undefined, options?: {
477
+ declare function usesCompilerText(compilerVersion: string, projectConfigFilePath: string | undefined, options?: {
452
478
  prependEmptyLine: boolean;
453
479
  }): ScribblerJsx.Element;
454
480
 
@@ -497,49 +523,15 @@ declare class Cli {
497
523
  run(commandLineArguments: Array<string>, cancellationToken?: CancellationToken): Promise<void>;
498
524
  }
499
525
 
500
- declare class Environment {
501
- #private;
502
- /**
503
- * Is `true` if the process is running in a continuous integration environment.
504
- */
505
- static get isCi(): boolean;
506
- /**
507
- * Specifies whether color should be disabled in the output.
508
- */
509
- static get noColor(): boolean;
510
- /**
511
- * Specifies whether interactive elements should be disabled in the output.
512
- */
513
- static get noInteractive(): boolean;
514
- /**
515
- * The base URL of the 'npm' registry to use.
516
- */
517
- static get npmRegistry(): string;
518
- /**
519
- * The directory where to store the 'typescript' packages.
520
- */
521
- static get storePath(): string;
522
- /**
523
- * The number of seconds to wait before giving up stale operations.
524
- */
525
- static get timeout(): number;
526
- /**
527
- * The path to the currently installed TypeScript module.
528
- */
529
- static get typescriptPath(): string | undefined;
530
- }
531
-
532
526
  type Event = ["config:error", {
533
527
  diagnostics: Array<Diagnostic>;
534
- }] | ["deprecation:info", {
535
- diagnostics: Array<Diagnostic>;
536
528
  }] | ["select:error", {
537
529
  diagnostics: Array<Diagnostic>;
538
530
  }] | ["run:start", {
539
531
  result: Result;
540
532
  }] | ["run:end", {
541
533
  result: Result;
542
- }] | ["store:info", {
534
+ }] | ["store:adds", {
543
535
  packagePath: string;
544
536
  packageVersion: string;
545
537
  }] | ["store:error", {
@@ -548,18 +540,18 @@ type Event = ["config:error", {
548
540
  result: TargetResult;
549
541
  }] | ["target:end", {
550
542
  result: TargetResult;
551
- }] | ["project:info", {
543
+ }] | ["project:uses", {
552
544
  compilerVersion: string;
553
545
  projectConfigFilePath: string | undefined;
554
546
  }] | ["project:error", {
555
547
  diagnostics: Array<Diagnostic>;
556
- }] | ["file:start", {
557
- result: FileResult;
558
- }] | ["file:error", {
548
+ }] | ["task:start", {
549
+ result: TaskResult;
550
+ }] | ["task:error", {
559
551
  diagnostics: Array<Diagnostic>;
560
- result: FileResult;
561
- }] | ["file:end", {
562
- result: FileResult;
552
+ result: TaskResult;
553
+ }] | ["task:end", {
554
+ result: TaskResult;
563
555
  }] | ["describe:start", {
564
556
  result: DescribeResult;
565
557
  }] | ["describe:end", {
@@ -793,19 +785,9 @@ declare class WatchReporter extends Reporter implements EventHandler {
793
785
  }
794
786
 
795
787
  type InputHandler = (chunk: string) => void;
796
- interface ReadStream {
797
- addListener: (event: "data", handler: InputHandler) => this;
798
- removeListener: (event: "data", handler: InputHandler) => this;
799
- setEncoding: (encoding: "utf8") => this;
800
- setRawMode?: (mode: boolean) => this;
801
- unref: () => this;
802
- }
803
- interface InputServiceOptions {
804
- stdin?: ReadStream;
805
- }
806
788
  declare class InputService {
807
789
  #private;
808
- constructor(onInput: InputHandler, options?: InputServiceOptions);
790
+ constructor(onInput: InputHandler);
809
791
  close(): void;
810
792
  }
811
793
 
@@ -826,11 +808,11 @@ declare class ProjectService {
826
808
  openFile(filePath: string, sourceText?: string | undefined, projectRootPath?: string | undefined): void;
827
809
  }
828
810
 
829
- declare class TaskRunner {
811
+ declare class Runner {
830
812
  #private;
831
813
  constructor(resolvedConfig: ResolvedConfig, selectService: SelectService, storeService: StoreService);
832
814
  close(): void;
833
- run(testFiles: Array<TestFile>, cancellationToken?: CancellationToken): Promise<void>;
815
+ run(tasks: Array<Task>, cancellationToken?: CancellationToken): Promise<void>;
834
816
  }
835
817
 
836
818
  declare class Version {
@@ -858,8 +840,8 @@ declare class FileWatcher extends Watcher {
858
840
 
859
841
  declare class WatchService {
860
842
  #private;
861
- constructor(resolvedConfig: ResolvedConfig, selectService: SelectService, testFiles: Array<TestFile>);
862
- watch(cancellationToken: CancellationToken): AsyncIterable<Array<TestFile>>;
843
+ constructor(resolvedConfig: ResolvedConfig, selectService: SelectService, tasks: Array<Task>);
844
+ watch(cancellationToken: CancellationToken): AsyncIterable<Array<Task>>;
863
845
  }
864
846
 
865
- export { Assertion, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, type CommandLineOptions, ConfigDiagnosticText, type ConfigFileOptions, ConfigService, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Environment, type Event, EventEmitter, type EventHandler, ExitCodeHandler, ExpectResult, ExpectService, FileResult, type FileResultStatus, type FileWatchHandler, FileWatcher, type InputHandler, InputService, type InputServiceOptions, type ItemDefinition, Line, type MatchResult, OptionBrand, type OptionDefinition, OptionDefinitionsMap, OptionGroup, OutputService, type OutputServiceOptions, Path, ProjectResult, ProjectService, type ReadStream, type ResolvedConfig, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, RunReporter, Scribbler, ScribblerJsx, type ScribblerOptions, SelectDiagnosticText, SelectService, SetupReporter, StoreService, SummaryReporter, TSTyche, TargetResult, type TargetResultStatus, TaskRunner, TestFile, TestMember, TestMemberBrand, TestMemberFlags, TestResult, TestTree, Text, type TypeChecker, Version, type WatchHandler, WatchReporter, WatchService, Watcher, type WatcherOptions, type WriteStream, addsPackageStepText, defaultOptions, describeNameText, diagnosticText, fileStatusText, fileViewText, formattedText, helpText, summaryText, testNameText, usesCompilerStepText, waitingForFileChangesText, watchUsageText };
847
+ export { Assertion, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, type CommandLineOptions, ConfigDiagnosticText, type ConfigFileOptions, ConfigService, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, type Event, EventEmitter, type EventHandler, ExitCodeHandler, ExpectResult, ExpectService, type FileWatchHandler, FileWatcher, type InputHandler, InputService, type ItemDefinition, Line, type MatchResult, OptionBrand, type OptionDefinition, OptionDefinitionsMap, OptionGroup, OutputService, Path, ProjectResult, ProjectService, type ResolvedConfig, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, RunReporter, Runner, Scribbler, ScribblerJsx, type ScribblerOptions, SelectDiagnosticText, SelectService, SetupReporter, StoreService, SummaryReporter, TSTyche, TargetResult, type TargetResultStatus, Task, TaskResult, type TaskResultStatus, TestMember, TestMemberBrand, TestMemberFlags, TestResult, TestTree, Text, type TypeChecker, Version, type WatchHandler, WatchReporter, WatchService, Watcher, type WatcherOptions, addsPackageText, defaultOptions, describeNameText, diagnosticText, environmentOptions, fileViewText, formattedText, helpText, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };