tstyche 7.2.5 → 8.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.
- package/README.md +4 -0
- package/dist/api.d.ts +16 -761
- package/dist/api.js +16 -6204
- package/dist/bin.js +2 -3
- package/dist/checker/BaseCheckerAdapter.d.ts +15 -0
- package/dist/checker/BaseCheckerAdapter.js +32 -0
- package/dist/checker/CompatCheckerAdapter.d.ts +70 -0
- package/dist/checker/CompatCheckerAdapter.js +221 -0
- package/dist/checker/NativeCheckerAdapter.d.ts +70 -0
- package/dist/checker/NativeCheckerAdapter.js +200 -0
- package/dist/checker/index.d.ts +3 -0
- package/dist/checker/index.js +2 -0
- package/dist/checker/types.d.ts +9 -0
- package/dist/checker/types.js +1 -0
- package/dist/cli/Cli.d.ts +5 -0
- package/dist/cli/Cli.js +144 -0
- package/dist/cli/CliDIagnosticText.d.ts +3 -0
- package/dist/cli/CliDIagnosticText.js +9 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/collect/CollectDiagnosticText.d.ts +3 -0
- package/dist/collect/CollectDiagnosticText.js +5 -0
- package/dist/collect/CollectService.d.ts +9 -0
- package/dist/collect/CollectService.js +150 -0
- package/dist/collect/ExpectNode.d.ts +16 -0
- package/dist/collect/ExpectNode.js +30 -0
- package/dist/collect/IdentifierLookup.d.ts +18 -0
- package/dist/collect/IdentifierLookup.js +90 -0
- package/dist/collect/TestTree.d.ts +16 -0
- package/dist/collect/TestTree.js +15 -0
- package/dist/collect/TestTreeNode.d.ts +15 -0
- package/dist/collect/TestTreeNode.js +27 -0
- package/dist/collect/TestTreeNodeBrand.enum.d.ts +6 -0
- package/dist/collect/TestTreeNodeBrand.enum.js +7 -0
- package/dist/collect/TestTreeNodeFlags.enum.d.ts +6 -0
- package/dist/collect/TestTreeNodeFlags.enum.js +7 -0
- package/dist/collect/index.d.ts +6 -0
- package/dist/collect/index.js +6 -0
- package/dist/config/CommandParser.d.ts +7 -0
- package/dist/config/CommandParser.js +107 -0
- package/dist/config/Config.d.ts +18 -0
- package/dist/config/Config.js +59 -0
- package/dist/config/ConfigDiagnosticText.d.ts +19 -0
- package/dist/config/ConfigDiagnosticText.js +57 -0
- package/dist/config/ConfigParser.d.ts +10 -0
- package/dist/config/ConfigParser.js +165 -0
- package/dist/config/Directive.d.ts +9 -0
- package/dist/config/Directive.js +119 -0
- package/dist/config/DirectiveDiagnosticText.d.ts +5 -0
- package/dist/config/DirectiveDiagnosticText.js +11 -0
- package/dist/config/OptionBrand.enum.d.ts +8 -0
- package/dist/config/OptionBrand.enum.js +9 -0
- package/dist/config/OptionGroup.enum.d.ts +5 -0
- package/dist/config/OptionGroup.enum.js +6 -0
- package/dist/config/Options.d.ts +29 -0
- package/dist/config/Options.js +290 -0
- package/dist/config/Target.d.ts +7 -0
- package/dist/config/Target.js +47 -0
- package/dist/config/defaultOptions.d.ts +2 -0
- package/dist/config/defaultOptions.js +14 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.js +7 -0
- package/dist/config/types.d.ts +55 -0
- package/dist/config/types.js +1 -0
- package/dist/diagnostic/Diagnostic.d.ts +19 -0
- package/dist/diagnostic/Diagnostic.js +51 -0
- package/dist/diagnostic/DiagnosticCategory.enum.d.ts +4 -0
- package/dist/diagnostic/DiagnosticCategory.enum.js +5 -0
- package/dist/diagnostic/DiagnosticOrigin.d.ts +13 -0
- package/dist/diagnostic/DiagnosticOrigin.js +27 -0
- package/dist/diagnostic/helpers.d.ts +6 -0
- package/dist/diagnostic/helpers.js +74 -0
- package/dist/diagnostic/index.d.ts +5 -0
- package/dist/diagnostic/index.js +4 -0
- package/dist/diagnostic/types.d.ts +2 -0
- package/dist/diagnostic/types.js +1 -0
- package/dist/editor/TextEditor.d.ts +15 -0
- package/dist/editor/TextEditor.js +88 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.js +1 -0
- package/dist/editor/types.d.ts +4 -0
- package/dist/editor/types.js +1 -0
- package/dist/environment/Environment.d.ts +5 -0
- package/dist/environment/Environment.js +89 -0
- package/dist/environment/environmentOptions.d.ts +1 -0
- package/dist/environment/environmentOptions.js +2 -0
- package/dist/environment/index.d.ts +2 -0
- package/dist/environment/index.js +1 -0
- package/dist/environment/types.d.ts +10 -0
- package/dist/environment/types.js +1 -0
- package/dist/events/EventEmitter.d.ts +14 -0
- package/dist/events/EventEmitter.js +42 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +1 -0
- package/dist/events/types.d.ts +88 -0
- package/dist/events/types.js +1 -0
- package/dist/expect/AbilityMatcherBase.d.ts +16 -0
- package/dist/expect/AbilityMatcherBase.js +52 -0
- package/dist/expect/Ensure.d.ts +10 -0
- package/dist/expect/Ensure.js +51 -0
- package/dist/expect/ExpectDiagnosticText.d.ts +29 -0
- package/dist/expect/ExpectDiagnosticText.js +87 -0
- package/dist/expect/ExpectService.d.ts +21 -0
- package/dist/expect/ExpectService.js +90 -0
- package/dist/expect/RelationMatcherBase.d.ts +12 -0
- package/dist/expect/RelationMatcherBase.js +16 -0
- package/dist/expect/ToAcceptProps.d.ts +10 -0
- package/dist/expect/ToAcceptProps.js +52 -0
- package/dist/expect/ToBe.d.ts +13 -0
- package/dist/expect/ToBe.js +18 -0
- package/dist/expect/ToBeApplicable.d.ts +10 -0
- package/dist/expect/ToBeApplicable.js +72 -0
- package/dist/expect/ToBeAssignableFrom.d.ts +9 -0
- package/dist/expect/ToBeAssignableFrom.js +12 -0
- package/dist/expect/ToBeAssignableTo.d.ts +9 -0
- package/dist/expect/ToBeAssignableTo.js +12 -0
- package/dist/expect/ToBeCallableWith.d.ts +11 -0
- package/dist/expect/ToBeCallableWith.js +29 -0
- package/dist/expect/ToBeConstructableWith.d.ts +11 -0
- package/dist/expect/ToBeConstructableWith.js +29 -0
- package/dist/expect/ToBeInstantiableWith.d.ts +10 -0
- package/dist/expect/ToBeInstantiableWith.js +31 -0
- package/dist/expect/ToHaveProperty.d.ts +10 -0
- package/dist/expect/ToHaveProperty.js +59 -0
- package/dist/expect/ToRaiseError.d.ts +9 -0
- package/dist/expect/ToRaiseError.js +82 -0
- package/dist/expect/index.d.ts +2 -0
- package/dist/expect/index.js +1 -0
- package/dist/expect/types.d.ts +7 -0
- package/dist/expect/types.js +1 -0
- package/dist/file/FilePosition.d.ts +7 -0
- package/dist/file/FilePosition.js +16 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/file/index.js +1 -0
- package/dist/glob/Braces.d.ts +4 -0
- package/dist/glob/Braces.js +56 -0
- package/dist/glob/Glob.d.ts +4 -0
- package/dist/glob/Glob.js +49 -0
- package/dist/glob/index.d.ts +1 -0
- package/dist/glob/index.js +1 -0
- package/dist/handlers/CancellationHandler.d.ts +7 -0
- package/dist/handlers/CancellationHandler.js +15 -0
- package/dist/handlers/ExitCodeHandler.d.ts +7 -0
- package/dist/handlers/ExitCodeHandler.js +20 -0
- package/dist/handlers/ResultHandler.d.ts +5 -0
- package/dist/handlers/ResultHandler.js +206 -0
- package/dist/handlers/index.d.ts +3 -0
- package/dist/handlers/index.js +3 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +40 -45
- package/dist/index.d.ts +40 -45
- package/dist/index.js +1 -2
- package/dist/input/InputService.d.ts +6 -0
- package/dist/input/InputService.js +16 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.js +1 -0
- package/dist/json/JsonNode.d.ts +11 -0
- package/dist/json/JsonNode.js +28 -0
- package/dist/json/JsonScanner.d.ts +14 -0
- package/dist/json/JsonScanner.js +105 -0
- package/dist/json/index.d.ts +3 -0
- package/dist/json/index.js +2 -0
- package/dist/json/types.d.ts +1 -0
- package/dist/json/types.js +1 -0
- package/dist/layers/AbilityLayer.d.ts +10 -0
- package/dist/layers/AbilityLayer.js +186 -0
- package/dist/layers/Layers.d.ts +11 -0
- package/dist/layers/Layers.js +47 -0
- package/dist/layers/SuppressedLayer.d.ts +11 -0
- package/dist/layers/SuppressedLayer.js +93 -0
- package/dist/layers/index.d.ts +2 -0
- package/dist/layers/index.js +1 -0
- package/dist/layers/types.d.ts +8 -0
- package/dist/layers/types.js +1 -0
- package/dist/output/CodeFrameText.d.ts +10 -0
- package/dist/output/CodeFrameText.js +71 -0
- package/dist/output/OutputService.d.ts +13 -0
- package/dist/output/OutputService.js +38 -0
- package/dist/output/StreamController.d.ts +10 -0
- package/dist/output/StreamController.js +16 -0
- package/dist/output/addsText.d.ts +4 -0
- package/dist/output/addsText.js +8 -0
- package/dist/output/describeNameText.d.ts +2 -0
- package/dist/output/describeNameText.js +5 -0
- package/dist/output/diagnosticText.d.ts +4 -0
- package/dist/output/diagnosticText.js +23 -0
- package/dist/output/dotText.d.ts +3 -0
- package/dist/output/dotText.js +11 -0
- package/dist/output/fileStatusText.d.ts +4 -0
- package/dist/output/fileStatusText.js +26 -0
- package/dist/output/formattedText.d.ts +2 -0
- package/dist/output/formattedText.js +19 -0
- package/dist/output/helpText.d.ts +3 -0
- package/dist/output/helpText.js +52 -0
- package/dist/output/helpers.d.ts +5 -0
- package/dist/output/helpers.js +23 -0
- package/dist/output/index.d.ts +16 -0
- package/dist/output/index.js +15 -0
- package/dist/output/prologueText.d.ts +2 -0
- package/dist/output/prologueText.js +5 -0
- package/dist/output/summaryText.d.ts +12 -0
- package/dist/output/summaryText.js +31 -0
- package/dist/output/testNameText.d.ts +3 -0
- package/dist/output/testNameText.js +24 -0
- package/dist/output/types.d.ts +5 -0
- package/dist/output/types.js +1 -0
- package/dist/output/usesText.d.ts +5 -0
- package/dist/output/usesText.js +22 -0
- package/dist/output/waitingForFileChangesText.d.ts +2 -0
- package/dist/output/waitingForFileChangesText.js +5 -0
- package/dist/output/watchUsageText.d.ts +2 -0
- package/dist/output/watchUsageText.js +12 -0
- package/dist/path/Path.d.ts +7 -0
- package/dist/path/Path.js +28 -0
- package/dist/path/index.d.ts +1 -0
- package/dist/path/index.js +1 -0
- package/dist/project/CompatMappedDiagnostic.d.ts +12 -0
- package/dist/project/CompatMappedDiagnostic.js +25 -0
- package/dist/project/CompatProjectService.d.ts +19 -0
- package/dist/project/CompatProjectService.js +188 -0
- package/dist/project/FileMapService.d.ts +6 -0
- package/dist/project/FileMapService.js +14 -0
- package/dist/project/NativeMappedDiagnostic.d.ts +14 -0
- package/dist/project/NativeMappedDiagnostic.js +29 -0
- package/dist/project/NativeProjectService.d.ts +21 -0
- package/dist/project/NativeProjectService.js +216 -0
- package/dist/project/ProjectConfigService.d.ts +8 -0
- package/dist/project/ProjectConfigService.js +73 -0
- package/dist/project/index.d.ts +3 -0
- package/dist/project/index.js +2 -0
- package/dist/project/types.d.ts +7 -0
- package/dist/project/types.js +1 -0
- package/dist/reject/Reject.d.ts +9 -0
- package/dist/reject/Reject.js +43 -0
- package/dist/reject/RejectDiagnosticText.d.ts +5 -0
- package/dist/reject/RejectDiagnosticText.js +16 -0
- package/dist/reject/helpers.d.ts +1 -0
- package/dist/reject/helpers.js +3 -0
- package/dist/reject/index.d.ts +1 -0
- package/dist/reject/index.js +1 -0
- package/dist/reporters/BaseReporter.d.ts +7 -0
- package/dist/reporters/BaseReporter.js +6 -0
- package/dist/reporters/DotReporter.d.ts +6 -0
- package/dist/reporters/DotReporter.js +51 -0
- package/dist/reporters/FileView.d.ts +13 -0
- package/dist/reporters/FileView.js +33 -0
- package/dist/reporters/ListReporter.d.ts +6 -0
- package/dist/reporters/ListReporter.js +125 -0
- package/dist/reporters/SetupReporter.d.ts +4 -0
- package/dist/reporters/SetupReporter.js +21 -0
- package/dist/reporters/SummaryReporter.d.ts +5 -0
- package/dist/reporters/SummaryReporter.js +19 -0
- package/dist/reporters/WatchReporter.d.ts +5 -0
- package/dist/reporters/WatchReporter.js +21 -0
- package/dist/reporters/index.d.ts +7 -0
- package/dist/reporters/index.js +6 -0
- package/dist/reporters/types.d.ts +5 -0
- package/dist/reporters/types.js +1 -0
- package/dist/result/DescribeResult.d.ts +9 -0
- package/dist/result/DescribeResult.js +11 -0
- package/dist/result/ExpectResult.d.ts +10 -0
- package/dist/result/ExpectResult.js +11 -0
- package/dist/result/FileResult.d.ts +15 -0
- package/dist/result/FileResult.js +13 -0
- package/dist/result/ProjectConfigKind.enum.d.ts +6 -0
- package/dist/result/ProjectConfigKind.enum.js +7 -0
- package/dist/result/ProjectResult.d.ts +8 -0
- package/dist/result/ProjectResult.js +9 -0
- package/dist/result/Result.d.ts +13 -0
- package/dist/result/Result.js +14 -0
- package/dist/result/ResultStatus.enum.d.ts +10 -0
- package/dist/result/ResultStatus.enum.js +11 -0
- package/dist/result/SuppressedResult.d.ts +5 -0
- package/dist/result/SuppressedResult.js +6 -0
- package/dist/result/TargetResult.d.ts +11 -0
- package/dist/result/TargetResult.js +12 -0
- package/dist/result/TestResult.d.ts +13 -0
- package/dist/result/TestResult.js +13 -0
- package/dist/result/helpers.d.ts +7 -0
- package/dist/result/helpers.js +21 -0
- package/dist/result/index.d.ts +11 -0
- package/dist/result/index.js +10 -0
- package/dist/result/types.d.ts +31 -0
- package/dist/result/types.js +1 -0
- package/dist/runner/FileRunner.d.ts +10 -0
- package/dist/runner/FileRunner.js +93 -0
- package/dist/runner/FixmeDiagnosticText.d.ts +4 -0
- package/dist/runner/FixmeDiagnosticText.js +8 -0
- package/dist/runner/FixmeService.d.ts +9 -0
- package/dist/runner/FixmeService.js +51 -0
- package/dist/runner/RunModeFlags.enum.d.ts +7 -0
- package/dist/runner/RunModeFlags.enum.js +8 -0
- package/dist/runner/Runner.d.ts +9 -0
- package/dist/runner/Runner.js +101 -0
- package/dist/runner/TestTreeWalker.d.ts +19 -0
- package/dist/runner/TestTreeWalker.js +169 -0
- package/dist/runner/index.d.ts +1 -0
- package/dist/runner/index.js +1 -0
- package/dist/scribbler/Color.enum.d.ts +10 -0
- package/dist/scribbler/Color.enum.js +11 -0
- package/dist/scribbler/Line.d.ts +9 -0
- package/dist/scribbler/Line.js +5 -0
- package/dist/scribbler/Scribbler.d.ts +10 -0
- package/dist/scribbler/Scribbler.js +53 -0
- package/dist/scribbler/Text.d.ts +9 -0
- package/dist/scribbler/Text.js +8 -0
- package/dist/scribbler/index.d.ts +5 -0
- package/dist/scribbler/index.js +4 -0
- package/dist/scribbler/jsxRuntime.d.ts +4 -0
- package/dist/scribbler/jsxRuntime.js +4 -0
- package/dist/scribbler/types.d.ts +19 -0
- package/dist/scribbler/types.js +1 -0
- package/dist/select/Select.d.ts +7 -0
- package/dist/select/Select.js +91 -0
- package/dist/select/SelectDiagnosticText.d.ts +6 -0
- package/dist/select/SelectDiagnosticText.js +24 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.js +2 -0
- package/dist/store/Fetcher.d.ts +24 -0
- package/dist/store/Fetcher.js +68 -0
- package/dist/store/Lock.d.ts +5 -0
- package/dist/store/Lock.js +24 -0
- package/dist/store/LockService.d.ts +8 -0
- package/dist/store/LockService.js +36 -0
- package/dist/store/Manifest.d.ts +30 -0
- package/dist/store/Manifest.js +58 -0
- package/dist/store/ManifestService.d.ts +10 -0
- package/dist/store/ManifestService.js +91 -0
- package/dist/store/PackageService.d.ts +9 -0
- package/dist/store/PackageService.js +89 -0
- package/dist/store/Store.d.ts +12 -0
- package/dist/store/Store.js +103 -0
- package/dist/store/StoreDiagnosticText.d.ts +13 -0
- package/dist/store/StoreDiagnosticText.js +42 -0
- package/dist/store/TarReader.d.ts +9 -0
- package/dist/store/TarReader.js +56 -0
- package/dist/store/helpers.d.ts +1 -0
- package/dist/store/helpers.js +3 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +1 -0
- package/dist/structure/ComparisonResult.enum.d.ts +5 -0
- package/dist/structure/ComparisonResult.enum.js +6 -0
- package/dist/structure/Structure.d.ts +24 -0
- package/dist/structure/Structure.js +481 -0
- package/dist/structure/index.d.ts +1 -0
- package/dist/structure/index.js +1 -0
- package/dist/suppressed/SuppressedDiagnosticText.d.ts +6 -0
- package/dist/suppressed/SuppressedDiagnosticText.js +18 -0
- package/dist/suppressed/SuppressedService.d.ts +5 -0
- package/dist/suppressed/SuppressedService.js +61 -0
- package/dist/suppressed/index.d.ts +1 -0
- package/dist/suppressed/index.js +1 -0
- package/dist/tag.d.ts +1 -3
- package/dist/tag.js +2 -5
- package/dist/text/TextFile.d.ts +11 -0
- package/dist/text/TextFile.js +41 -0
- package/dist/text/TextFileService.d.ts +10 -0
- package/dist/text/TextFileService.js +31 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.js +2 -0
- package/dist/text/types.d.ts +5 -0
- package/dist/text/types.js +1 -0
- package/dist/token/CancellationReason.enum.d.ts +6 -0
- package/dist/token/CancellationReason.enum.js +7 -0
- package/dist/token/CancellationToken.d.ts +8 -0
- package/dist/token/CancellationToken.js +22 -0
- package/dist/token/index.d.ts +2 -0
- package/dist/token/index.js +2 -0
- package/dist/typescript/BaseAdapter.d.ts +36 -0
- package/dist/typescript/BaseAdapter.js +83 -0
- package/dist/typescript/CompatTypeScript.d.ts +21 -0
- package/dist/typescript/CompatTypeScript.js +37 -0
- package/dist/typescript/NativeTypeScript.d.ts +24 -0
- package/dist/typescript/NativeTypeScript.js +44 -0
- package/dist/typescript/index.d.ts +3 -0
- package/dist/typescript/index.js +2 -0
- package/dist/typescript/types.d.ts +69 -0
- package/dist/typescript/types.js +1 -0
- package/dist/version/Version.d.ts +6 -0
- package/dist/version/Version.js +30 -0
- package/dist/version/index.d.ts +1 -0
- package/dist/version/index.js +1 -0
- package/dist/watch/Debounce.d.ts +9 -0
- package/dist/watch/Debounce.js +27 -0
- package/dist/watch/FileWatcher.d.ts +5 -0
- package/dist/watch/FileWatcher.js +12 -0
- package/dist/watch/WatchService.d.ts +8 -0
- package/dist/watch/WatchService.js +96 -0
- package/dist/watch/Watcher.d.ts +10 -0
- package/dist/watch/Watcher.js +31 -0
- package/dist/watch/index.d.ts +3 -0
- package/dist/watch/index.js +3 -0
- package/package.json +10 -2
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { NativeCheckerAdapter } from "#checker";
|
|
2
|
+
import { Options } from "#config";
|
|
3
|
+
import { Diagnostic } from "#diagnostic";
|
|
4
|
+
import { EventEmitter } from "#events";
|
|
5
|
+
import { Path } from "#path";
|
|
6
|
+
import { Select } from "#select";
|
|
7
|
+
import { TextFileService } from "../text/TextFileService.js";
|
|
8
|
+
import { FileMapService } from "./FileMapService.js";
|
|
9
|
+
import { NativeMappedDiagnostic } from "./NativeMappedDiagnostic.js";
|
|
10
|
+
import { ProjectConfigService } from "./ProjectConfigService.js";
|
|
11
|
+
export class NativeProjectService {
|
|
12
|
+
#api;
|
|
13
|
+
#baseSnapshot;
|
|
14
|
+
#currentSnapshot;
|
|
15
|
+
#currentProject;
|
|
16
|
+
#currentSpecifier;
|
|
17
|
+
#declarationFileRegex = /\.d\.[cm]?ts$/;
|
|
18
|
+
#fileMap = new FileMapService();
|
|
19
|
+
#projectConfig;
|
|
20
|
+
#resolvedConfig;
|
|
21
|
+
#ts;
|
|
22
|
+
#tsconfigPath;
|
|
23
|
+
#tsconfigSyntheticPath;
|
|
24
|
+
constructor(ts, resolvedConfig) {
|
|
25
|
+
this.#ts = ts;
|
|
26
|
+
this.#resolvedConfig = resolvedConfig;
|
|
27
|
+
this.#api = ts.getApi();
|
|
28
|
+
this.#baseSnapshot = this.#api.createSnapshot();
|
|
29
|
+
this.#projectConfig = new ProjectConfigService(this.#api, resolvedConfig);
|
|
30
|
+
const id = Date.now().toString(36);
|
|
31
|
+
this.#tsconfigPath = Path.resolve(resolvedConfig.rootPath, `${id}.tsconfig.json`);
|
|
32
|
+
this.#tsconfigSyntheticPath = Path.resolve(resolvedConfig.rootPath, `${id}-synthetic.tsconfig.json`);
|
|
33
|
+
}
|
|
34
|
+
close() {
|
|
35
|
+
this.#currentProject?.dispose();
|
|
36
|
+
this.#currentProject = undefined;
|
|
37
|
+
this.#api.close();
|
|
38
|
+
}
|
|
39
|
+
closeFile() {
|
|
40
|
+
TextFileService.close();
|
|
41
|
+
}
|
|
42
|
+
getChecker() {
|
|
43
|
+
return new NativeCheckerAdapter(this.#ts, this.#currentProject.checker);
|
|
44
|
+
}
|
|
45
|
+
#getDefaultCompilerOptions() {
|
|
46
|
+
const options = {
|
|
47
|
+
allowJs: true,
|
|
48
|
+
checkJs: true,
|
|
49
|
+
allowImportingTsExtensions: true,
|
|
50
|
+
exactOptionalPropertyTypes: true,
|
|
51
|
+
jsx: "preserve",
|
|
52
|
+
module: "nodenext",
|
|
53
|
+
moduleResolution: "nodenext",
|
|
54
|
+
noEmit: true,
|
|
55
|
+
noUncheckedIndexedAccess: true,
|
|
56
|
+
noUncheckedSideEffectImports: true,
|
|
57
|
+
resolveJsonModule: true,
|
|
58
|
+
strict: true,
|
|
59
|
+
target: "esnext",
|
|
60
|
+
};
|
|
61
|
+
return options;
|
|
62
|
+
}
|
|
63
|
+
getMappedDiagnostic(sourceFile, diagnostic, offsets) {
|
|
64
|
+
return new NativeMappedDiagnostic(sourceFile, diagnostic, offsets);
|
|
65
|
+
}
|
|
66
|
+
getProgram() {
|
|
67
|
+
return this.#currentProject.program;
|
|
68
|
+
}
|
|
69
|
+
getSourceFile(filePath) {
|
|
70
|
+
return this.#currentProject.program.getSourceFile(filePath);
|
|
71
|
+
}
|
|
72
|
+
#getProjectFacts(filePath) {
|
|
73
|
+
let compilerOptions = this.#getDefaultCompilerOptions();
|
|
74
|
+
let kind = 1;
|
|
75
|
+
let specifier = "baseline";
|
|
76
|
+
switch (this.#resolvedConfig.tsconfig) {
|
|
77
|
+
case "baseline":
|
|
78
|
+
break;
|
|
79
|
+
case "findup":
|
|
80
|
+
{
|
|
81
|
+
const configPath = this.#projectConfig.findUp(filePath);
|
|
82
|
+
if (configPath != null) {
|
|
83
|
+
compilerOptions = {};
|
|
84
|
+
kind = 0;
|
|
85
|
+
specifier = configPath;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
default: {
|
|
90
|
+
if (Options.isJsonString(this.#resolvedConfig.tsconfig)) {
|
|
91
|
+
const { config } = this.#api.parseConfigFileTextToJson(this.#tsconfigSyntheticPath, this.#resolvedConfig.tsconfig);
|
|
92
|
+
const { fileNames } = this.#api.parseJsonConfigFileContent(config, {
|
|
93
|
+
configFileName: this.#tsconfigSyntheticPath,
|
|
94
|
+
});
|
|
95
|
+
if (fileNames.includes(filePath)) {
|
|
96
|
+
this.#fileMap.add(this.#tsconfigSyntheticPath, this.#resolvedConfig.tsconfig);
|
|
97
|
+
compilerOptions = {};
|
|
98
|
+
kind = 3;
|
|
99
|
+
specifier = this.#tsconfigSyntheticPath;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (this.#api.parseConfigFile(this.#resolvedConfig.tsconfig).fileNames.includes(filePath)) {
|
|
103
|
+
compilerOptions = {};
|
|
104
|
+
kind = 2;
|
|
105
|
+
specifier = this.#resolvedConfig.tsconfig;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (kind !== 1 && specifier === this.#currentSpecifier && !this.#fileMap.hasChanged()) {
|
|
110
|
+
return { kind, project: this.#currentProject, specifier };
|
|
111
|
+
}
|
|
112
|
+
if (this.#resolvedConfig.checkDeclarationFiles) {
|
|
113
|
+
compilerOptions = { ...compilerOptions, skipLibCheck: false };
|
|
114
|
+
}
|
|
115
|
+
const tsconfigText = JSON.stringify({
|
|
116
|
+
extends: kind === 1 ? undefined : specifier,
|
|
117
|
+
compilerOptions,
|
|
118
|
+
include: kind === 1 ? [Path.relative(this.#resolvedConfig.rootPath, filePath)] : undefined,
|
|
119
|
+
});
|
|
120
|
+
this.#fileMap.add(this.#tsconfigPath, tsconfigText);
|
|
121
|
+
this.#currentSnapshot?.dispose();
|
|
122
|
+
this.#currentSnapshot = this.#baseSnapshot.update({
|
|
123
|
+
openProjects: [this.#tsconfigPath],
|
|
124
|
+
fileSystem: {
|
|
125
|
+
kind: "layer",
|
|
126
|
+
files: this.#fileMap.get(),
|
|
127
|
+
},
|
|
128
|
+
ensurePrograms: true,
|
|
129
|
+
});
|
|
130
|
+
const project = this.#currentSnapshot.getConfiguredProject(this.#tsconfigPath);
|
|
131
|
+
return { kind, project, specifier };
|
|
132
|
+
}
|
|
133
|
+
getSemanticDiagnostics(filePath) {
|
|
134
|
+
return this.#normalizeDiagnostics(this.#currentProject.program.getSemanticDiagnostics(filePath));
|
|
135
|
+
}
|
|
136
|
+
getSyntacticDiagnostics(filePath) {
|
|
137
|
+
return this.#normalizeDiagnostics(this.#currentProject.program.getSyntacticDiagnostics(filePath));
|
|
138
|
+
}
|
|
139
|
+
#normalizeDiagnostics(diagnostics) {
|
|
140
|
+
return diagnostics.map(function normalize(diagnostic) {
|
|
141
|
+
const { startPosition, endPosition, sourceLines, ...rest } = diagnostic;
|
|
142
|
+
return {
|
|
143
|
+
...rest,
|
|
144
|
+
...(diagnostic.messageChain && {
|
|
145
|
+
messageChain: diagnostic.messageChain.map((msg) => normalize(msg)),
|
|
146
|
+
}),
|
|
147
|
+
...(diagnostic.relatedInformation && {
|
|
148
|
+
relatedInformation: diagnostic.relatedInformation.map((info) => normalize(info)),
|
|
149
|
+
}),
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
openFile(filePath, fileText) {
|
|
154
|
+
if (fileText != null) {
|
|
155
|
+
this.#fileMap.add(filePath, fileText);
|
|
156
|
+
}
|
|
157
|
+
const { kind, project, specifier } = this.#getProjectFacts(filePath);
|
|
158
|
+
TextFileService.open(project.program);
|
|
159
|
+
if (specifier !== this.#currentSpecifier) {
|
|
160
|
+
this.#currentSpecifier = specifier;
|
|
161
|
+
EventEmitter.dispatch([
|
|
162
|
+
"project:uses",
|
|
163
|
+
{ compilerVersion: this.#ts.version, projectConfig: { kind, specifier } },
|
|
164
|
+
]);
|
|
165
|
+
const configFileParsingDiagnostics = project.program.getConfigFileParsingDiagnostics();
|
|
166
|
+
if (configFileParsingDiagnostics.length > 0) {
|
|
167
|
+
EventEmitter.dispatch([
|
|
168
|
+
"project:error",
|
|
169
|
+
{ diagnostics: Diagnostic.fromDiagnostics(configFileParsingDiagnostics) },
|
|
170
|
+
]);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (project === this.#currentProject) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.#currentProject?.dispose();
|
|
177
|
+
this.#currentProject = project;
|
|
178
|
+
const filesToCheck = project.program.getSourceFileNames().filter((filePath) => {
|
|
179
|
+
const sourceFileMetadata = project.program.getSourceFileMetadata(filePath);
|
|
180
|
+
if (sourceFileMetadata.isFromExternalLibrary || sourceFileMetadata.isDefaultLibrary) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
if (this.#resolvedConfig.checkDeclarationFiles && this.#declarationFileRegex.test(filePath)) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
if (Select.isFixtureFile(filePath, this.#resolvedConfig)) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
});
|
|
191
|
+
const diagnostics = [
|
|
192
|
+
...this.#normalizeDiagnostics(project.program.getProgramDiagnostics())
|
|
193
|
+
.map(({ fileName, ...rest }) => ({ ...rest, pos: -1, end: -1 })),
|
|
194
|
+
...filesToCheck.flatMap((filePath) => [
|
|
195
|
+
...this.#normalizeDiagnostics(project.program.getSyntacticDiagnostics(filePath)),
|
|
196
|
+
...this.#normalizeDiagnostics(project.program.getSemanticDiagnostics(filePath)),
|
|
197
|
+
...this.#normalizeDiagnostics(project.program.getDeclarationDiagnostics(filePath)),
|
|
198
|
+
].sort((a, b) => a.pos - b.pos)),
|
|
199
|
+
];
|
|
200
|
+
if (diagnostics.length > 0) {
|
|
201
|
+
EventEmitter.dispatch(["project:error", { diagnostics: Diagnostic.fromDiagnostics(diagnostics) }]);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
openLayer(filePath, fileText) {
|
|
205
|
+
using snapshot = this.#currentSnapshot.update({
|
|
206
|
+
fileSystem: {
|
|
207
|
+
kind: "layer",
|
|
208
|
+
files: { [filePath]: fileText },
|
|
209
|
+
},
|
|
210
|
+
ensurePrograms: true,
|
|
211
|
+
});
|
|
212
|
+
const project = snapshot.getConfiguredProject(this.#tsconfigPath);
|
|
213
|
+
const diagnostics = project.program.getSemanticDiagnostics(filePath);
|
|
214
|
+
return diagnostics;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as tsAst from "typescript/ast";
|
|
2
|
+
import type * as tsApi from "typescript/sync";
|
|
3
|
+
import type { ResolvedConfig } from "#config";
|
|
4
|
+
export declare class ProjectConfigService {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(api: InstanceType<typeof tsApi.API>, resolvedConfig: ResolvedConfig);
|
|
7
|
+
findUp(filePath: tsAst.RootedFilePath, currentPath?: string): string | undefined;
|
|
8
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { Path } from "#path";
|
|
3
|
+
export class ProjectConfigService {
|
|
4
|
+
#api;
|
|
5
|
+
#configCache = new Map();
|
|
6
|
+
#resolvedConfig;
|
|
7
|
+
constructor(api, resolvedConfig) {
|
|
8
|
+
this.#api = api;
|
|
9
|
+
this.#resolvedConfig = resolvedConfig;
|
|
10
|
+
}
|
|
11
|
+
findUp(filePath, currentPath = Path.dirname(filePath)) {
|
|
12
|
+
const configPath = this.#resolveConfigPath(filePath, currentPath);
|
|
13
|
+
if (configPath) {
|
|
14
|
+
return configPath;
|
|
15
|
+
}
|
|
16
|
+
if (currentPath === this.#resolvedConfig.rootPath) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return this.findUp(filePath, Path.dirname(currentPath));
|
|
20
|
+
}
|
|
21
|
+
#resolveConfigPath(filePath, currentPath) {
|
|
22
|
+
for (const configName of ["tsconfig.json", "jsconfig.json"]) {
|
|
23
|
+
const probePath = Path.join(currentPath, configName);
|
|
24
|
+
const config = this.#getParsedConfig(probePath);
|
|
25
|
+
if (!config) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (config.fileNames.includes(filePath)) {
|
|
29
|
+
return probePath;
|
|
30
|
+
}
|
|
31
|
+
const result = this.#resolveInProjectReferences(filePath, config, new Set());
|
|
32
|
+
if (result) {
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
#getParsedConfig(filePath) {
|
|
39
|
+
filePath = filePath.endsWith("json") ? filePath : `${filePath}/tsconfig.json`;
|
|
40
|
+
let config = this.#configCache.get(filePath);
|
|
41
|
+
if (!config) {
|
|
42
|
+
if (!existsSync(filePath)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
config = this.#api.parseConfigFile(filePath);
|
|
46
|
+
this.#configCache.set(filePath, config);
|
|
47
|
+
}
|
|
48
|
+
return config;
|
|
49
|
+
}
|
|
50
|
+
#resolveInProjectReferences(filePath, config, visited) {
|
|
51
|
+
if (!config.projectReferences) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
for (const projectReference of config.projectReferences) {
|
|
55
|
+
if (visited.has(projectReference.path)) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const config = this.#getParsedConfig(projectReference.path);
|
|
59
|
+
if (!config) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (config.fileNames.includes(filePath)) {
|
|
63
|
+
return projectReference.path;
|
|
64
|
+
}
|
|
65
|
+
visited.add(projectReference.path);
|
|
66
|
+
const configPath = this.#resolveInProjectReferences(filePath, config, visited);
|
|
67
|
+
if (configPath) {
|
|
68
|
+
return configPath;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CompatProjectService } from "./CompatProjectService.js";
|
|
2
|
+
import type { NativeProjectService } from "./NativeProjectService.js";
|
|
3
|
+
export interface FileSystem {
|
|
4
|
+
fileExists?: (path: string) => boolean | undefined;
|
|
5
|
+
readFile?: (path: string) => string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export type ProjectService = CompatProjectService | NativeProjectService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Checker } from "#checker";
|
|
2
|
+
import type { ResolvedConfig } from "#config";
|
|
3
|
+
import { Diagnostic, type DiagnosticsHandler } from "#diagnostic";
|
|
4
|
+
import type * as ts from "#typescript";
|
|
5
|
+
export declare class Reject {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(ts: ts.TypeScript, checker: Checker, resolvedConfig: ResolvedConfig);
|
|
8
|
+
argumentType(target: Array<ts.Expression | ts.TypeNode | undefined>, onDiagnostics: DiagnosticsHandler<Array<Diagnostic>>): boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Diagnostic, DiagnosticOrigin } from "#diagnostic";
|
|
2
|
+
import { capitalize } from "./helpers.js";
|
|
3
|
+
import { RejectDiagnosticText } from "./RejectDiagnosticText.js";
|
|
4
|
+
export class Reject {
|
|
5
|
+
#checker;
|
|
6
|
+
#rejectedArgumentTypes = new Set();
|
|
7
|
+
#ts;
|
|
8
|
+
constructor(ts, checker, resolvedConfig) {
|
|
9
|
+
this.#ts = ts;
|
|
10
|
+
this.#checker = checker;
|
|
11
|
+
if (resolvedConfig.rejectAnyType) {
|
|
12
|
+
this.#rejectedArgumentTypes.add("any");
|
|
13
|
+
}
|
|
14
|
+
if (resolvedConfig.rejectNeverType) {
|
|
15
|
+
this.#rejectedArgumentTypes.add("never");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
argumentType(target, onDiagnostics) {
|
|
19
|
+
for (const rejectedType of this.#rejectedArgumentTypes) {
|
|
20
|
+
const allowedKeyword = this.#ts.SyntaxKind[`${capitalize(rejectedType)}Keyword`];
|
|
21
|
+
if (target.some((node) => node?.kind === allowedKeyword)) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
for (const node of target) {
|
|
25
|
+
if (!node) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (this.#checker.getType(node).flags & this.#ts.TypeFlags[capitalize(rejectedType)]) {
|
|
29
|
+
const text = [
|
|
30
|
+
this.#ts.belongsToArgumentList(node)
|
|
31
|
+
? RejectDiagnosticText.argumentCannotBeOfType(rejectedType)
|
|
32
|
+
: RejectDiagnosticText.typeArgumentCannotBeOfType(rejectedType),
|
|
33
|
+
...RejectDiagnosticText.typeWasRejected(rejectedType),
|
|
34
|
+
];
|
|
35
|
+
const origin = DiagnosticOrigin.fromNode(node);
|
|
36
|
+
onDiagnostics([Diagnostic.error(text, origin)]);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { capitalize } from "./helpers.js";
|
|
2
|
+
export class RejectDiagnosticText {
|
|
3
|
+
static argumentCannotBeOfType(typeText) {
|
|
4
|
+
return `The argument cannot be of the '${typeText}' type.`;
|
|
5
|
+
}
|
|
6
|
+
static typeArgumentCannotBeOfType(typeText) {
|
|
7
|
+
return `The type argument cannot be of the '${typeText}' type.`;
|
|
8
|
+
}
|
|
9
|
+
static typeWasRejected(typeText) {
|
|
10
|
+
const optionNameText = `reject${capitalize(typeText)}Type`;
|
|
11
|
+
return [
|
|
12
|
+
`The '${typeText}' type was rejected because the '${optionNameText}' option is enabled.`,
|
|
13
|
+
`If this check is necessary, pass '${typeText}' as the type argument explicitly.`,
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function capitalize<const T extends string>(text: T): Capitalize<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Reject } from "./Reject.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Reject } from "./Reject.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "#config";
|
|
2
|
+
import type { Reporter, ReporterEvent } from "./types.js";
|
|
3
|
+
export declare abstract class BaseReporter implements Reporter {
|
|
4
|
+
protected resolvedConfig: ResolvedConfig;
|
|
5
|
+
constructor(resolvedConfig: ResolvedConfig);
|
|
6
|
+
abstract on([event, payload]: ReporterEvent): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { environmentOptions } from "#environment";
|
|
2
|
+
import { addsText, diagnosticText, dotText, OutputService, usesText } from "#output";
|
|
3
|
+
import { BaseReporter } from "./BaseReporter.js";
|
|
4
|
+
export class DotReporter extends BaseReporter {
|
|
5
|
+
#diagnostics = [];
|
|
6
|
+
#hasReportedAdds = false;
|
|
7
|
+
on([event, payload]) {
|
|
8
|
+
switch (event) {
|
|
9
|
+
case "store:adds":
|
|
10
|
+
OutputService.writeMessage(addsText(payload.packageVersion, payload.packagePath, { short: true }));
|
|
11
|
+
this.#hasReportedAdds = true;
|
|
12
|
+
break;
|
|
13
|
+
case "store:error":
|
|
14
|
+
for (const diagnostic of payload.diagnostics) {
|
|
15
|
+
OutputService.writeError(diagnosticText(diagnostic));
|
|
16
|
+
}
|
|
17
|
+
break;
|
|
18
|
+
case "project:uses":
|
|
19
|
+
if (this.#hasReportedAdds) {
|
|
20
|
+
if (!environmentOptions.noInteractive) {
|
|
21
|
+
OutputService.eraseLastLine();
|
|
22
|
+
}
|
|
23
|
+
this.#hasReportedAdds = false;
|
|
24
|
+
}
|
|
25
|
+
if (this.resolvedConfig.target.length > 1) {
|
|
26
|
+
OutputService.writeMessage(usesText(payload.compilerVersion, payload.projectConfig, { short: true }));
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
case "target:end":
|
|
30
|
+
OutputService.writeBlankLine(2);
|
|
31
|
+
for (const diagnostic of this.#diagnostics) {
|
|
32
|
+
OutputService.writeError(diagnosticText(diagnostic));
|
|
33
|
+
}
|
|
34
|
+
this.#diagnostics = [];
|
|
35
|
+
break;
|
|
36
|
+
case "file:end":
|
|
37
|
+
OutputService.writeMessage(dotText(payload.result.status));
|
|
38
|
+
break;
|
|
39
|
+
case "project:error":
|
|
40
|
+
case "file:error":
|
|
41
|
+
case "directive:error":
|
|
42
|
+
case "collect:error":
|
|
43
|
+
case "test:error":
|
|
44
|
+
case "suppressed:error":
|
|
45
|
+
case "expect:error":
|
|
46
|
+
case "expect:fail":
|
|
47
|
+
this.#diagnostics.push(...payload.diagnostics);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ResultStatus, TestResultStatus } from "#result";
|
|
2
|
+
import type { ScribblerJsx } from "#scribbler";
|
|
3
|
+
export declare class FileView {
|
|
4
|
+
#private;
|
|
5
|
+
addMessage(message: ScribblerJsx.Element): void;
|
|
6
|
+
addTest(status: Exclude<TestResultStatus, ResultStatus.Runs>, name: string): void;
|
|
7
|
+
beginDescribe(name: string): void;
|
|
8
|
+
clear(): void;
|
|
9
|
+
endDescribe(): void;
|
|
10
|
+
getMessages(): Array<ScribblerJsx.Element>;
|
|
11
|
+
getView(): Array<ScribblerJsx.Element>;
|
|
12
|
+
hasErrors(): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describeNameText, testNameText } from "#output";
|
|
2
|
+
export class FileView {
|
|
3
|
+
#indent = 0;
|
|
4
|
+
#lines = [];
|
|
5
|
+
#messages = [];
|
|
6
|
+
addMessage(message) {
|
|
7
|
+
this.#messages.push(message);
|
|
8
|
+
}
|
|
9
|
+
addTest(status, name) {
|
|
10
|
+
this.#lines.push(testNameText(status, name, this.#indent));
|
|
11
|
+
}
|
|
12
|
+
beginDescribe(name) {
|
|
13
|
+
this.#lines.push(describeNameText(name, this.#indent));
|
|
14
|
+
this.#indent++;
|
|
15
|
+
}
|
|
16
|
+
clear() {
|
|
17
|
+
this.#indent = 0;
|
|
18
|
+
this.#lines = [];
|
|
19
|
+
this.#messages = [];
|
|
20
|
+
}
|
|
21
|
+
endDescribe() {
|
|
22
|
+
this.#indent--;
|
|
23
|
+
}
|
|
24
|
+
getMessages() {
|
|
25
|
+
return this.#messages;
|
|
26
|
+
}
|
|
27
|
+
getView() {
|
|
28
|
+
return this.#lines;
|
|
29
|
+
}
|
|
30
|
+
hasErrors() {
|
|
31
|
+
return this.#messages.length > 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { environmentOptions } from "#environment";
|
|
2
|
+
import { addsText, diagnosticText, fileStatusText, OutputService, usesText } from "#output";
|
|
3
|
+
import { BaseReporter } from "./BaseReporter.js";
|
|
4
|
+
import { FileView } from "./FileView.js";
|
|
5
|
+
export class ListReporter extends BaseReporter {
|
|
6
|
+
#fileCount = 0;
|
|
7
|
+
#fileView = new FileView();
|
|
8
|
+
#hasReportedAdds = false;
|
|
9
|
+
#hasReportedError = false;
|
|
10
|
+
#hasReportedUses = false;
|
|
11
|
+
#isVerbose = false;
|
|
12
|
+
on([event, payload]) {
|
|
13
|
+
switch (event) {
|
|
14
|
+
case "run:start":
|
|
15
|
+
this.#isVerbose =
|
|
16
|
+
this.resolvedConfig.verbose || (payload.result.files.length === 1 && this.resolvedConfig.watch !== true);
|
|
17
|
+
break;
|
|
18
|
+
case "store:adds":
|
|
19
|
+
OutputService.writeMessage(addsText(payload.packageVersion, payload.packagePath));
|
|
20
|
+
this.#hasReportedAdds = true;
|
|
21
|
+
break;
|
|
22
|
+
case "store:error":
|
|
23
|
+
for (const diagnostic of payload.diagnostics) {
|
|
24
|
+
OutputService.writeError(diagnosticText(diagnostic));
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
case "target:start":
|
|
28
|
+
this.#fileCount = payload.result.files.length;
|
|
29
|
+
this.#hasReportedUses = false;
|
|
30
|
+
break;
|
|
31
|
+
case "project:uses":
|
|
32
|
+
if (this.#hasReportedUses && !(this.#hasReportedAdds || this.#hasReportedError)) {
|
|
33
|
+
OutputService.writeBlankLine();
|
|
34
|
+
}
|
|
35
|
+
OutputService.writeMessage(usesText(payload.compilerVersion, payload.projectConfig));
|
|
36
|
+
this.#hasReportedAdds = false;
|
|
37
|
+
this.#hasReportedUses = true;
|
|
38
|
+
break;
|
|
39
|
+
case "project:error":
|
|
40
|
+
for (const diagnostic of payload.diagnostics) {
|
|
41
|
+
OutputService.writeError(diagnosticText(diagnostic));
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
case "file:start":
|
|
45
|
+
if (!environmentOptions.noInteractive) {
|
|
46
|
+
OutputService.writeMessage(fileStatusText(payload.result.status, payload.result.file));
|
|
47
|
+
}
|
|
48
|
+
this.#fileCount--;
|
|
49
|
+
this.#hasReportedError = false;
|
|
50
|
+
break;
|
|
51
|
+
case "file:error":
|
|
52
|
+
case "directive:error":
|
|
53
|
+
case "collect:error":
|
|
54
|
+
case "suppressed:error":
|
|
55
|
+
for (const diagnostic of payload.diagnostics) {
|
|
56
|
+
this.#fileView.addMessage(diagnosticText(diagnostic));
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case "file:end":
|
|
60
|
+
if (!environmentOptions.noInteractive) {
|
|
61
|
+
OutputService.eraseLastLine();
|
|
62
|
+
}
|
|
63
|
+
OutputService.writeMessage(fileStatusText(payload.result.status, payload.result.file));
|
|
64
|
+
OutputService.writeMessage(this.#fileView.getView());
|
|
65
|
+
if (this.#isVerbose || this.#fileCount === 0 || this.#fileView.hasErrors()) {
|
|
66
|
+
OutputService.writeBlankLine();
|
|
67
|
+
}
|
|
68
|
+
if (this.#fileView.hasErrors()) {
|
|
69
|
+
OutputService.writeError(this.#fileView.getMessages());
|
|
70
|
+
this.#hasReportedError = true;
|
|
71
|
+
}
|
|
72
|
+
this.#fileView.clear();
|
|
73
|
+
break;
|
|
74
|
+
case "describe:start":
|
|
75
|
+
if (this.#isVerbose) {
|
|
76
|
+
this.#fileView.beginDescribe(payload.result.describe.name);
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case "describe:end":
|
|
80
|
+
if (this.#isVerbose) {
|
|
81
|
+
this.#fileView.endDescribe();
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case "test:skip":
|
|
85
|
+
if (this.#isVerbose) {
|
|
86
|
+
this.#fileView.addTest("skipped", payload.result.test.name);
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case "test:fixme":
|
|
90
|
+
if (this.#isVerbose) {
|
|
91
|
+
this.#fileView.addTest("fixme", payload.result.test.name);
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case "test:todo":
|
|
95
|
+
if (this.#isVerbose) {
|
|
96
|
+
this.#fileView.addTest("todo", payload.result.test.name);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case "test:error":
|
|
100
|
+
if (this.#isVerbose) {
|
|
101
|
+
this.#fileView.addTest("failed", payload.result.test.name);
|
|
102
|
+
}
|
|
103
|
+
for (const diagnostic of payload.diagnostics) {
|
|
104
|
+
this.#fileView.addMessage(diagnosticText(diagnostic));
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case "test:fail":
|
|
108
|
+
if (this.#isVerbose) {
|
|
109
|
+
this.#fileView.addTest("failed", payload.result.test.name);
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
case "test:pass":
|
|
113
|
+
if (this.#isVerbose) {
|
|
114
|
+
this.#fileView.addTest("passed", payload.result.test.name);
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
case "expect:error":
|
|
118
|
+
case "expect:fail":
|
|
119
|
+
for (const diagnostic of payload.diagnostics) {
|
|
120
|
+
this.#fileView.addMessage(diagnosticText(diagnostic));
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|