tstyche 7.2.4 → 8.0.0-beta.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.
Files changed (393) hide show
  1. package/README.md +4 -0
  2. package/dist/api.d.ts +16 -761
  3. package/dist/api.js +16 -6170
  4. package/dist/bin.js +2 -3
  5. package/dist/checker/BaseCheckerAdapter.d.ts +15 -0
  6. package/dist/checker/BaseCheckerAdapter.js +32 -0
  7. package/dist/checker/CompatCheckerAdapter.d.ts +70 -0
  8. package/dist/checker/CompatCheckerAdapter.js +221 -0
  9. package/dist/checker/NativeCheckerAdapter.d.ts +70 -0
  10. package/dist/checker/NativeCheckerAdapter.js +200 -0
  11. package/dist/checker/index.d.ts +3 -0
  12. package/dist/checker/index.js +2 -0
  13. package/dist/checker/types.d.ts +9 -0
  14. package/dist/checker/types.js +1 -0
  15. package/dist/cli/Cli.d.ts +5 -0
  16. package/dist/cli/Cli.js +144 -0
  17. package/dist/cli/CliDIagnosticText.d.ts +3 -0
  18. package/dist/cli/CliDIagnosticText.js +9 -0
  19. package/dist/cli/index.d.ts +1 -0
  20. package/dist/cli/index.js +1 -0
  21. package/dist/collect/CollectDiagnosticText.d.ts +3 -0
  22. package/dist/collect/CollectDiagnosticText.js +5 -0
  23. package/dist/collect/CollectService.d.ts +9 -0
  24. package/dist/collect/CollectService.js +150 -0
  25. package/dist/collect/ExpectNode.d.ts +16 -0
  26. package/dist/collect/ExpectNode.js +30 -0
  27. package/dist/collect/IdentifierLookup.d.ts +18 -0
  28. package/dist/collect/IdentifierLookup.js +90 -0
  29. package/dist/collect/TestTree.d.ts +16 -0
  30. package/dist/collect/TestTree.js +15 -0
  31. package/dist/collect/TestTreeNode.d.ts +15 -0
  32. package/dist/collect/TestTreeNode.js +27 -0
  33. package/dist/collect/TestTreeNodeBrand.enum.d.ts +6 -0
  34. package/dist/collect/TestTreeNodeBrand.enum.js +7 -0
  35. package/dist/collect/TestTreeNodeFlags.enum.d.ts +6 -0
  36. package/dist/collect/TestTreeNodeFlags.enum.js +7 -0
  37. package/dist/collect/index.d.ts +6 -0
  38. package/dist/collect/index.js +6 -0
  39. package/dist/config/CommandParser.d.ts +7 -0
  40. package/dist/config/CommandParser.js +107 -0
  41. package/dist/config/Config.d.ts +18 -0
  42. package/dist/config/Config.js +59 -0
  43. package/dist/config/ConfigDiagnosticText.d.ts +19 -0
  44. package/dist/config/ConfigDiagnosticText.js +57 -0
  45. package/dist/config/ConfigParser.d.ts +10 -0
  46. package/dist/config/ConfigParser.js +165 -0
  47. package/dist/config/Directive.d.ts +9 -0
  48. package/dist/config/Directive.js +119 -0
  49. package/dist/config/DirectiveDiagnosticText.d.ts +5 -0
  50. package/dist/config/DirectiveDiagnosticText.js +11 -0
  51. package/dist/config/OptionBrand.enum.d.ts +8 -0
  52. package/dist/config/OptionBrand.enum.js +9 -0
  53. package/dist/config/OptionGroup.enum.d.ts +5 -0
  54. package/dist/config/OptionGroup.enum.js +6 -0
  55. package/dist/config/Options.d.ts +29 -0
  56. package/dist/config/Options.js +290 -0
  57. package/dist/config/Target.d.ts +7 -0
  58. package/dist/config/Target.js +47 -0
  59. package/dist/config/defaultOptions.d.ts +2 -0
  60. package/dist/config/defaultOptions.js +14 -0
  61. package/dist/config/index.d.ts +8 -0
  62. package/dist/config/index.js +7 -0
  63. package/dist/config/types.d.ts +55 -0
  64. package/dist/config/types.js +1 -0
  65. package/dist/diagnostic/Diagnostic.d.ts +19 -0
  66. package/dist/diagnostic/Diagnostic.js +51 -0
  67. package/dist/diagnostic/DiagnosticCategory.enum.d.ts +4 -0
  68. package/dist/diagnostic/DiagnosticCategory.enum.js +5 -0
  69. package/dist/diagnostic/DiagnosticOrigin.d.ts +13 -0
  70. package/dist/diagnostic/DiagnosticOrigin.js +27 -0
  71. package/dist/diagnostic/helpers.d.ts +6 -0
  72. package/dist/diagnostic/helpers.js +74 -0
  73. package/dist/diagnostic/index.d.ts +5 -0
  74. package/dist/diagnostic/index.js +4 -0
  75. package/dist/diagnostic/types.d.ts +2 -0
  76. package/dist/diagnostic/types.js +1 -0
  77. package/dist/editor/TextEditor.d.ts +15 -0
  78. package/dist/editor/TextEditor.js +88 -0
  79. package/dist/editor/index.d.ts +2 -0
  80. package/dist/editor/index.js +1 -0
  81. package/dist/editor/types.d.ts +4 -0
  82. package/dist/editor/types.js +1 -0
  83. package/dist/environment/Environment.d.ts +5 -0
  84. package/dist/environment/Environment.js +89 -0
  85. package/dist/environment/environmentOptions.d.ts +1 -0
  86. package/dist/environment/environmentOptions.js +2 -0
  87. package/dist/environment/index.d.ts +2 -0
  88. package/dist/environment/index.js +1 -0
  89. package/dist/environment/types.d.ts +10 -0
  90. package/dist/environment/types.js +1 -0
  91. package/dist/events/EventEmitter.d.ts +14 -0
  92. package/dist/events/EventEmitter.js +42 -0
  93. package/dist/events/index.d.ts +2 -0
  94. package/dist/events/index.js +1 -0
  95. package/dist/events/types.d.ts +88 -0
  96. package/dist/events/types.js +1 -0
  97. package/dist/expect/AbilityMatcherBase.d.ts +16 -0
  98. package/dist/expect/AbilityMatcherBase.js +52 -0
  99. package/dist/expect/Ensure.d.ts +10 -0
  100. package/dist/expect/Ensure.js +51 -0
  101. package/dist/expect/ExpectDiagnosticText.d.ts +29 -0
  102. package/dist/expect/ExpectDiagnosticText.js +87 -0
  103. package/dist/expect/ExpectService.d.ts +21 -0
  104. package/dist/expect/ExpectService.js +90 -0
  105. package/dist/expect/RelationMatcherBase.d.ts +12 -0
  106. package/dist/expect/RelationMatcherBase.js +16 -0
  107. package/dist/expect/ToAcceptProps.d.ts +10 -0
  108. package/dist/expect/ToAcceptProps.js +52 -0
  109. package/dist/expect/ToBe.d.ts +13 -0
  110. package/dist/expect/ToBe.js +18 -0
  111. package/dist/expect/ToBeApplicable.d.ts +10 -0
  112. package/dist/expect/ToBeApplicable.js +72 -0
  113. package/dist/expect/ToBeAssignableFrom.d.ts +9 -0
  114. package/dist/expect/ToBeAssignableFrom.js +12 -0
  115. package/dist/expect/ToBeAssignableTo.d.ts +9 -0
  116. package/dist/expect/ToBeAssignableTo.js +12 -0
  117. package/dist/expect/ToBeCallableWith.d.ts +11 -0
  118. package/dist/expect/ToBeCallableWith.js +29 -0
  119. package/dist/expect/ToBeConstructableWith.d.ts +11 -0
  120. package/dist/expect/ToBeConstructableWith.js +29 -0
  121. package/dist/expect/ToBeInstantiableWith.d.ts +10 -0
  122. package/dist/expect/ToBeInstantiableWith.js +31 -0
  123. package/dist/expect/ToHaveProperty.d.ts +10 -0
  124. package/dist/expect/ToHaveProperty.js +59 -0
  125. package/dist/expect/ToRaiseError.d.ts +9 -0
  126. package/dist/expect/ToRaiseError.js +82 -0
  127. package/dist/expect/index.d.ts +2 -0
  128. package/dist/expect/index.js +1 -0
  129. package/dist/expect/types.d.ts +7 -0
  130. package/dist/expect/types.js +1 -0
  131. package/dist/file/FilePosition.d.ts +7 -0
  132. package/dist/file/FilePosition.js +16 -0
  133. package/dist/file/index.d.ts +1 -0
  134. package/dist/file/index.js +1 -0
  135. package/dist/glob/Braces.d.ts +4 -0
  136. package/dist/glob/Braces.js +56 -0
  137. package/dist/glob/Glob.d.ts +4 -0
  138. package/dist/glob/Glob.js +47 -0
  139. package/dist/glob/index.d.ts +1 -0
  140. package/dist/glob/index.js +1 -0
  141. package/dist/handlers/CancellationHandler.d.ts +7 -0
  142. package/dist/handlers/CancellationHandler.js +15 -0
  143. package/dist/handlers/ExitCodeHandler.d.ts +7 -0
  144. package/dist/handlers/ExitCodeHandler.js +20 -0
  145. package/dist/handlers/ResultHandler.d.ts +5 -0
  146. package/dist/handlers/ResultHandler.js +206 -0
  147. package/dist/handlers/index.d.ts +3 -0
  148. package/dist/handlers/index.js +3 -0
  149. package/dist/index.cjs +5 -5
  150. package/dist/index.d.cts +40 -45
  151. package/dist/index.d.ts +40 -45
  152. package/dist/index.js +1 -2
  153. package/dist/input/InputService.d.ts +6 -0
  154. package/dist/input/InputService.js +16 -0
  155. package/dist/input/index.d.ts +1 -0
  156. package/dist/input/index.js +1 -0
  157. package/dist/json/JsonNode.d.ts +11 -0
  158. package/dist/json/JsonNode.js +28 -0
  159. package/dist/json/JsonScanner.d.ts +14 -0
  160. package/dist/json/JsonScanner.js +105 -0
  161. package/dist/json/index.d.ts +3 -0
  162. package/dist/json/index.js +2 -0
  163. package/dist/json/types.d.ts +1 -0
  164. package/dist/json/types.js +1 -0
  165. package/dist/layers/AbilityLayer.d.ts +10 -0
  166. package/dist/layers/AbilityLayer.js +186 -0
  167. package/dist/layers/Layers.d.ts +11 -0
  168. package/dist/layers/Layers.js +47 -0
  169. package/dist/layers/SuppressedLayer.d.ts +11 -0
  170. package/dist/layers/SuppressedLayer.js +93 -0
  171. package/dist/layers/index.d.ts +2 -0
  172. package/dist/layers/index.js +1 -0
  173. package/dist/layers/types.d.ts +8 -0
  174. package/dist/layers/types.js +1 -0
  175. package/dist/output/CodeFrameText.d.ts +10 -0
  176. package/dist/output/CodeFrameText.js +71 -0
  177. package/dist/output/OutputService.d.ts +13 -0
  178. package/dist/output/OutputService.js +38 -0
  179. package/dist/output/StreamController.d.ts +10 -0
  180. package/dist/output/StreamController.js +16 -0
  181. package/dist/output/addsText.d.ts +4 -0
  182. package/dist/output/addsText.js +8 -0
  183. package/dist/output/describeNameText.d.ts +2 -0
  184. package/dist/output/describeNameText.js +5 -0
  185. package/dist/output/diagnosticText.d.ts +4 -0
  186. package/dist/output/diagnosticText.js +23 -0
  187. package/dist/output/dotText.d.ts +3 -0
  188. package/dist/output/dotText.js +11 -0
  189. package/dist/output/fileStatusText.d.ts +4 -0
  190. package/dist/output/fileStatusText.js +26 -0
  191. package/dist/output/formattedText.d.ts +2 -0
  192. package/dist/output/formattedText.js +19 -0
  193. package/dist/output/helpText.d.ts +3 -0
  194. package/dist/output/helpText.js +52 -0
  195. package/dist/output/helpers.d.ts +5 -0
  196. package/dist/output/helpers.js +23 -0
  197. package/dist/output/index.d.ts +16 -0
  198. package/dist/output/index.js +15 -0
  199. package/dist/output/prologueText.d.ts +2 -0
  200. package/dist/output/prologueText.js +5 -0
  201. package/dist/output/summaryText.d.ts +12 -0
  202. package/dist/output/summaryText.js +31 -0
  203. package/dist/output/testNameText.d.ts +3 -0
  204. package/dist/output/testNameText.js +24 -0
  205. package/dist/output/types.d.ts +5 -0
  206. package/dist/output/types.js +1 -0
  207. package/dist/output/usesText.d.ts +5 -0
  208. package/dist/output/usesText.js +22 -0
  209. package/dist/output/waitingForFileChangesText.d.ts +2 -0
  210. package/dist/output/waitingForFileChangesText.js +5 -0
  211. package/dist/output/watchUsageText.d.ts +2 -0
  212. package/dist/output/watchUsageText.js +12 -0
  213. package/dist/path/Path.d.ts +7 -0
  214. package/dist/path/Path.js +28 -0
  215. package/dist/path/index.d.ts +1 -0
  216. package/dist/path/index.js +1 -0
  217. package/dist/project/CompatMappedDiagnostic.d.ts +12 -0
  218. package/dist/project/CompatMappedDiagnostic.js +25 -0
  219. package/dist/project/CompatProjectService.d.ts +19 -0
  220. package/dist/project/CompatProjectService.js +188 -0
  221. package/dist/project/FileMapService.d.ts +6 -0
  222. package/dist/project/FileMapService.js +14 -0
  223. package/dist/project/NativeMappedDiagnostic.d.ts +14 -0
  224. package/dist/project/NativeMappedDiagnostic.js +29 -0
  225. package/dist/project/NativeProjectService.d.ts +21 -0
  226. package/dist/project/NativeProjectService.js +216 -0
  227. package/dist/project/ProjectConfigService.d.ts +8 -0
  228. package/dist/project/ProjectConfigService.js +73 -0
  229. package/dist/project/index.d.ts +3 -0
  230. package/dist/project/index.js +2 -0
  231. package/dist/project/types.d.ts +7 -0
  232. package/dist/project/types.js +1 -0
  233. package/dist/reject/Reject.d.ts +9 -0
  234. package/dist/reject/Reject.js +43 -0
  235. package/dist/reject/RejectDiagnosticText.d.ts +5 -0
  236. package/dist/reject/RejectDiagnosticText.js +16 -0
  237. package/dist/reject/helpers.d.ts +1 -0
  238. package/dist/reject/helpers.js +3 -0
  239. package/dist/reject/index.d.ts +1 -0
  240. package/dist/reject/index.js +1 -0
  241. package/dist/reporters/BaseReporter.d.ts +7 -0
  242. package/dist/reporters/BaseReporter.js +6 -0
  243. package/dist/reporters/DotReporter.d.ts +6 -0
  244. package/dist/reporters/DotReporter.js +51 -0
  245. package/dist/reporters/FileView.d.ts +13 -0
  246. package/dist/reporters/FileView.js +33 -0
  247. package/dist/reporters/ListReporter.d.ts +6 -0
  248. package/dist/reporters/ListReporter.js +125 -0
  249. package/dist/reporters/SetupReporter.d.ts +4 -0
  250. package/dist/reporters/SetupReporter.js +21 -0
  251. package/dist/reporters/SummaryReporter.d.ts +5 -0
  252. package/dist/reporters/SummaryReporter.js +19 -0
  253. package/dist/reporters/WatchReporter.d.ts +5 -0
  254. package/dist/reporters/WatchReporter.js +21 -0
  255. package/dist/reporters/index.d.ts +7 -0
  256. package/dist/reporters/index.js +6 -0
  257. package/dist/reporters/types.d.ts +5 -0
  258. package/dist/reporters/types.js +1 -0
  259. package/dist/result/DescribeResult.d.ts +9 -0
  260. package/dist/result/DescribeResult.js +11 -0
  261. package/dist/result/ExpectResult.d.ts +10 -0
  262. package/dist/result/ExpectResult.js +11 -0
  263. package/dist/result/FileResult.d.ts +15 -0
  264. package/dist/result/FileResult.js +13 -0
  265. package/dist/result/ProjectConfigKind.enum.d.ts +6 -0
  266. package/dist/result/ProjectConfigKind.enum.js +7 -0
  267. package/dist/result/ProjectResult.d.ts +8 -0
  268. package/dist/result/ProjectResult.js +9 -0
  269. package/dist/result/Result.d.ts +13 -0
  270. package/dist/result/Result.js +14 -0
  271. package/dist/result/ResultStatus.enum.d.ts +10 -0
  272. package/dist/result/ResultStatus.enum.js +11 -0
  273. package/dist/result/SuppressedResult.d.ts +5 -0
  274. package/dist/result/SuppressedResult.js +6 -0
  275. package/dist/result/TargetResult.d.ts +11 -0
  276. package/dist/result/TargetResult.js +12 -0
  277. package/dist/result/TestResult.d.ts +13 -0
  278. package/dist/result/TestResult.js +13 -0
  279. package/dist/result/helpers.d.ts +7 -0
  280. package/dist/result/helpers.js +21 -0
  281. package/dist/result/index.d.ts +11 -0
  282. package/dist/result/index.js +10 -0
  283. package/dist/result/types.d.ts +31 -0
  284. package/dist/result/types.js +1 -0
  285. package/dist/runner/FileRunner.d.ts +10 -0
  286. package/dist/runner/FileRunner.js +93 -0
  287. package/dist/runner/FixmeDiagnosticText.d.ts +4 -0
  288. package/dist/runner/FixmeDiagnosticText.js +8 -0
  289. package/dist/runner/FixmeService.d.ts +9 -0
  290. package/dist/runner/FixmeService.js +51 -0
  291. package/dist/runner/RunModeFlags.enum.d.ts +7 -0
  292. package/dist/runner/RunModeFlags.enum.js +8 -0
  293. package/dist/runner/Runner.d.ts +9 -0
  294. package/dist/runner/Runner.js +101 -0
  295. package/dist/runner/TestTreeWalker.d.ts +19 -0
  296. package/dist/runner/TestTreeWalker.js +169 -0
  297. package/dist/runner/index.d.ts +1 -0
  298. package/dist/runner/index.js +1 -0
  299. package/dist/scribbler/Color.enum.d.ts +10 -0
  300. package/dist/scribbler/Color.enum.js +11 -0
  301. package/dist/scribbler/Line.d.ts +9 -0
  302. package/dist/scribbler/Line.js +5 -0
  303. package/dist/scribbler/Scribbler.d.ts +10 -0
  304. package/dist/scribbler/Scribbler.js +53 -0
  305. package/dist/scribbler/Text.d.ts +9 -0
  306. package/dist/scribbler/Text.js +8 -0
  307. package/dist/scribbler/index.d.ts +5 -0
  308. package/dist/scribbler/index.js +4 -0
  309. package/dist/scribbler/jsxRuntime.d.ts +4 -0
  310. package/dist/scribbler/jsxRuntime.js +4 -0
  311. package/dist/scribbler/types.d.ts +19 -0
  312. package/dist/scribbler/types.js +1 -0
  313. package/dist/select/Select.d.ts +7 -0
  314. package/dist/select/Select.js +91 -0
  315. package/dist/select/SelectDiagnosticText.d.ts +6 -0
  316. package/dist/select/SelectDiagnosticText.js +24 -0
  317. package/dist/select/index.d.ts +2 -0
  318. package/dist/select/index.js +2 -0
  319. package/dist/store/Fetcher.d.ts +8 -0
  320. package/dist/store/Fetcher.js +52 -0
  321. package/dist/store/Lock.d.ts +5 -0
  322. package/dist/store/Lock.js +17 -0
  323. package/dist/store/LockService.d.ts +8 -0
  324. package/dist/store/LockService.js +36 -0
  325. package/dist/store/Manifest.d.ts +35 -0
  326. package/dist/store/Manifest.js +58 -0
  327. package/dist/store/ManifestService.d.ts +10 -0
  328. package/dist/store/ManifestService.js +129 -0
  329. package/dist/store/PackageService.d.ts +8 -0
  330. package/dist/store/PackageService.js +69 -0
  331. package/dist/store/Store.d.ts +12 -0
  332. package/dist/store/Store.js +103 -0
  333. package/dist/store/StoreDiagnosticText.d.ts +12 -0
  334. package/dist/store/StoreDiagnosticText.js +36 -0
  335. package/dist/store/TarReader.d.ts +9 -0
  336. package/dist/store/TarReader.js +56 -0
  337. package/dist/store/helpers.d.ts +1 -0
  338. package/dist/store/helpers.js +3 -0
  339. package/dist/store/index.d.ts +1 -0
  340. package/dist/store/index.js +1 -0
  341. package/dist/structure/ComparisonResult.enum.d.ts +5 -0
  342. package/dist/structure/ComparisonResult.enum.js +6 -0
  343. package/dist/structure/Structure.d.ts +24 -0
  344. package/dist/structure/Structure.js +481 -0
  345. package/dist/structure/index.d.ts +1 -0
  346. package/dist/structure/index.js +1 -0
  347. package/dist/suppressed/SuppressedDiagnosticText.d.ts +6 -0
  348. package/dist/suppressed/SuppressedDiagnosticText.js +18 -0
  349. package/dist/suppressed/SuppressedService.d.ts +5 -0
  350. package/dist/suppressed/SuppressedService.js +61 -0
  351. package/dist/suppressed/index.d.ts +1 -0
  352. package/dist/suppressed/index.js +1 -0
  353. package/dist/tag.d.ts +1 -3
  354. package/dist/tag.js +2 -5
  355. package/dist/text/TextFile.d.ts +11 -0
  356. package/dist/text/TextFile.js +41 -0
  357. package/dist/text/TextFileService.d.ts +10 -0
  358. package/dist/text/TextFileService.js +31 -0
  359. package/dist/text/index.d.ts +3 -0
  360. package/dist/text/index.js +2 -0
  361. package/dist/text/types.d.ts +5 -0
  362. package/dist/text/types.js +1 -0
  363. package/dist/token/CancellationReason.enum.d.ts +6 -0
  364. package/dist/token/CancellationReason.enum.js +7 -0
  365. package/dist/token/CancellationToken.d.ts +8 -0
  366. package/dist/token/CancellationToken.js +22 -0
  367. package/dist/token/index.d.ts +2 -0
  368. package/dist/token/index.js +2 -0
  369. package/dist/typescript/BaseAdapter.d.ts +36 -0
  370. package/dist/typescript/BaseAdapter.js +83 -0
  371. package/dist/typescript/CompatTypeScript.d.ts +21 -0
  372. package/dist/typescript/CompatTypeScript.js +37 -0
  373. package/dist/typescript/NativeTypeScript.d.ts +24 -0
  374. package/dist/typescript/NativeTypeScript.js +44 -0
  375. package/dist/typescript/index.d.ts +3 -0
  376. package/dist/typescript/index.js +2 -0
  377. package/dist/typescript/types.d.ts +69 -0
  378. package/dist/typescript/types.js +1 -0
  379. package/dist/version/Version.d.ts +6 -0
  380. package/dist/version/Version.js +30 -0
  381. package/dist/version/index.d.ts +1 -0
  382. package/dist/version/index.js +1 -0
  383. package/dist/watch/Debounce.d.ts +9 -0
  384. package/dist/watch/Debounce.js +27 -0
  385. package/dist/watch/FileWatcher.d.ts +5 -0
  386. package/dist/watch/FileWatcher.js +12 -0
  387. package/dist/watch/WatchService.d.ts +8 -0
  388. package/dist/watch/WatchService.js +96 -0
  389. package/dist/watch/Watcher.d.ts +10 -0
  390. package/dist/watch/Watcher.js +31 -0
  391. package/dist/watch/index.d.ts +3 -0
  392. package/dist/watch/index.js +3 -0
  393. package/package.json +9 -1
@@ -0,0 +1,107 @@
1
+ import { Diagnostic } from "#diagnostic";
2
+ import { Path } from "#path";
3
+ import { ConfigDiagnosticText } from "./ConfigDiagnosticText.js";
4
+ import { Options } from "./Options.js";
5
+ import { Target } from "./Target.js";
6
+ export class CommandParser {
7
+ #commandLineOptions;
8
+ #onDiagnostics;
9
+ #options;
10
+ #pathMatch;
11
+ constructor(commandLine, pathMatch, onDiagnostics) {
12
+ this.#commandLineOptions = commandLine;
13
+ this.#pathMatch = pathMatch;
14
+ this.#onDiagnostics = onDiagnostics;
15
+ this.#options = Options.for(2);
16
+ }
17
+ #onExpectsValue(optionName, optionBrand) {
18
+ const text = [
19
+ ConfigDiagnosticText.expectsValue(optionName),
20
+ ConfigDiagnosticText.optionValueMustBe(optionName, optionBrand),
21
+ ];
22
+ this.#onDiagnostics(Diagnostic.error(text));
23
+ }
24
+ async parse(commandLineArgs) {
25
+ let index = 0;
26
+ let arg = commandLineArgs[index];
27
+ while (arg != null) {
28
+ index++;
29
+ if (arg.startsWith("--")) {
30
+ const optionDefinition = this.#options.get(arg.slice(2));
31
+ if (optionDefinition) {
32
+ index = await this.#parseOptionValue(commandLineArgs, index, arg, optionDefinition);
33
+ }
34
+ else {
35
+ this.#onDiagnostics(Diagnostic.error(ConfigDiagnosticText.unknownOption(arg)));
36
+ }
37
+ }
38
+ else if (arg.startsWith("-")) {
39
+ this.#onDiagnostics(Diagnostic.error(ConfigDiagnosticText.unknownOption(arg)));
40
+ }
41
+ else {
42
+ this.#pathMatch.push(Path.normalizeSlashes(arg));
43
+ }
44
+ arg = commandLineArgs[index];
45
+ }
46
+ }
47
+ async #parseOptionValue(commandLineArgs, index, optionName, optionDefinition) {
48
+ let optionValue = this.#resolveOptionValue(commandLineArgs[index]);
49
+ switch (optionDefinition.brand) {
50
+ case "true":
51
+ await Options.validate(optionName, optionValue, this.#onDiagnostics);
52
+ this.#commandLineOptions[optionDefinition.name] = true;
53
+ break;
54
+ case "boolean":
55
+ await Options.validate(optionName, optionValue, this.#onDiagnostics);
56
+ this.#commandLineOptions[optionDefinition.name] = optionValue !== "false";
57
+ if (optionValue === "false" || optionValue === "true") {
58
+ index++;
59
+ }
60
+ break;
61
+ case "list":
62
+ if (optionValue !== "") {
63
+ const optionValues = optionValue
64
+ .split(",")
65
+ .map((value) => value.trim())
66
+ .filter((value) => value !== "")
67
+ .map((value) => Options.resolve(optionName, value));
68
+ for (const optionValue of optionValues) {
69
+ await Options.validate(optionName, optionValue, this.#onDiagnostics);
70
+ }
71
+ this.#commandLineOptions[optionDefinition.name] = optionValues;
72
+ index++;
73
+ break;
74
+ }
75
+ this.#onExpectsValue(optionName, optionDefinition.brand);
76
+ break;
77
+ case "string":
78
+ if (optionValue !== "") {
79
+ optionValue = Options.resolve(optionName, optionValue);
80
+ await Options.validate(optionName, optionValue, this.#onDiagnostics);
81
+ this.#commandLineOptions[optionDefinition.name] = optionValue;
82
+ index++;
83
+ break;
84
+ }
85
+ this.#onExpectsValue(optionName, optionDefinition.brand);
86
+ break;
87
+ case "range":
88
+ if (optionValue !== "") {
89
+ const optionValues = [];
90
+ for (const range of Target.split(optionValue)) {
91
+ await Options.validate(optionName, range, this.#onDiagnostics);
92
+ const versions = await Target.expand(range, this.#onDiagnostics);
93
+ optionValues.push(...versions);
94
+ }
95
+ this.#commandLineOptions[optionDefinition.name] = optionValues;
96
+ index++;
97
+ break;
98
+ }
99
+ this.#onExpectsValue(optionName, "string");
100
+ break;
101
+ }
102
+ return index;
103
+ }
104
+ #resolveOptionValue(target = "") {
105
+ return target.startsWith("-") ? "" : target;
106
+ }
107
+ }
@@ -0,0 +1,18 @@
1
+ import type { CommandLineOptions, ConfigFileOptions, ResolvedConfig } from "./types.js";
2
+ export declare class Config {
3
+ #private;
4
+ static parseCommandLine(commandLine: ReadonlyArray<string>): Promise<{
5
+ commandLineOptions: CommandLineOptions;
6
+ pathMatch: Array<string>;
7
+ }>;
8
+ static parseConfigFile(configPath?: string | undefined, rootPath?: string | undefined): Promise<{
9
+ configFileOptions: ConfigFileOptions;
10
+ }>;
11
+ static resolve(options?: {
12
+ configFileOptions?: ConfigFileOptions;
13
+ commandLineOptions?: CommandLineOptions;
14
+ pathMatch?: Array<string>;
15
+ }): ResolvedConfig;
16
+ static resolveConfigFilePath(configPath?: string | undefined, rootPath?: string | undefined): string;
17
+ static resolveRootPath(rootPath?: string | undefined): string;
18
+ }
@@ -0,0 +1,59 @@
1
+ import { existsSync } from "node:fs";
2
+ import fs from "node:fs/promises";
3
+ import { EventEmitter } from "#events";
4
+ import { JsonScanner } from "#json";
5
+ import { Path } from "#path";
6
+ import { TextFile } from "#text";
7
+ import { CommandParser } from "./CommandParser.js";
8
+ import { ConfigParser } from "./ConfigParser.js";
9
+ import { defaultOptions } from "./defaultOptions.js";
10
+ export class Config {
11
+ static #onDiagnostics(diagnostic) {
12
+ EventEmitter.dispatch(["config:error", { diagnostics: [diagnostic] }]);
13
+ }
14
+ static async parseCommandLine(commandLine) {
15
+ const commandLineOptions = {};
16
+ const pathMatch = [];
17
+ const commandLineParser = new CommandParser(commandLineOptions, pathMatch, Config.#onDiagnostics);
18
+ await commandLineParser.parse(commandLine);
19
+ return { commandLineOptions, pathMatch };
20
+ }
21
+ static async parseConfigFile(configPath, rootPath) {
22
+ const configFileOptions = {};
23
+ const configFilePath = Config.resolveConfigFilePath(configPath, rootPath);
24
+ if (existsSync(configFilePath)) {
25
+ const configFileText = await fs.readFile(configFilePath, {
26
+ encoding: "utf8",
27
+ });
28
+ const file = new TextFile(configFilePath, configFileText);
29
+ const configFileParser = new ConfigParser(configFileOptions, 4, file, new JsonScanner(file), Config.#onDiagnostics);
30
+ await configFileParser.parse();
31
+ }
32
+ return { configFileOptions };
33
+ }
34
+ static resolve(options) {
35
+ const resolvedConfig = {
36
+ configFilePath: Config.resolveConfigFilePath(options?.commandLineOptions?.config, options?.commandLineOptions?.root),
37
+ pathMatch: options?.pathMatch ?? [],
38
+ rootPath: Config.resolveRootPath(options?.commandLineOptions?.root),
39
+ ...defaultOptions,
40
+ ...options?.configFileOptions,
41
+ ...options?.commandLineOptions,
42
+ };
43
+ if ("config" in resolvedConfig) {
44
+ delete resolvedConfig.config;
45
+ }
46
+ if ("root" in resolvedConfig) {
47
+ delete resolvedConfig.root;
48
+ }
49
+ return resolvedConfig;
50
+ }
51
+ static resolveConfigFilePath(configPath, rootPath) {
52
+ return configPath != null
53
+ ? Path.resolve(configPath)
54
+ : Path.resolve(Config.resolveRootPath(rootPath), "./tstyche.json");
55
+ }
56
+ static resolveRootPath(rootPath) {
57
+ return Path.resolve(rootPath ?? ".");
58
+ }
59
+ }
@@ -0,0 +1,19 @@
1
+ import type { OptionBrand } from "./OptionBrand.enum.js";
2
+ export declare class ConfigDiagnosticText {
3
+ static expected(element: string): string;
4
+ static expectsListItemType(optionName: string, optionBrand: OptionBrand): string;
5
+ static expectsValue(optionName: string): string;
6
+ static fileDoesNotExist(filePath: string): string;
7
+ static fileMatchPatternCannotStartWith(optionName: string, segment: string): Array<string>;
8
+ static inspectSupportedVersions(): string;
9
+ static moduleWasNotFound(specifier: string): string;
10
+ static optionValueMustBe(optionName: string, optionBrand: OptionBrand): string;
11
+ static rangeIsNotValid(value: string): string;
12
+ static rangeDoesNotMatchSupported(value: string): string;
13
+ static rangeUsage(): Array<string>;
14
+ static seen(element: string): string;
15
+ static unexpected(element: string): string;
16
+ static unknownOption(optionName: string): string;
17
+ static versionIsNotSupported(value: string): string;
18
+ static watchCannotBeEnabled(): string;
19
+ }
@@ -0,0 +1,57 @@
1
+ export class ConfigDiagnosticText {
2
+ static expected(element) {
3
+ return `Expected ${element}.`;
4
+ }
5
+ static expectsListItemType(optionName, optionBrand) {
6
+ return `Item of the '${optionName}' list must be of type ${optionBrand}.`;
7
+ }
8
+ static expectsValue(optionName) {
9
+ return `Option '${optionName}' expects a value.`;
10
+ }
11
+ static fileDoesNotExist(filePath) {
12
+ return `The specified path '${filePath}' does not exist.`;
13
+ }
14
+ static fileMatchPatternCannotStartWith(optionName, segment) {
15
+ return [
16
+ `A '${optionName}' pattern cannot start with '${segment}'.`,
17
+ "The files are only collected within the root directory.",
18
+ ];
19
+ }
20
+ static inspectSupportedVersions() {
21
+ return "Use the '--list' command line option to inspect the list of supported versions.";
22
+ }
23
+ static moduleWasNotFound(specifier) {
24
+ return `The specified module '${specifier}' was not found.`;
25
+ }
26
+ static optionValueMustBe(optionName, optionBrand) {
27
+ return `Value for the '${optionName}' option must be a ${optionBrand}.`;
28
+ }
29
+ static rangeIsNotValid(value) {
30
+ return `The specified range '${value}' is not valid.`;
31
+ }
32
+ static rangeDoesNotMatchSupported(value) {
33
+ return `The specified range '${value}' does not match any supported TypeScript versions.`;
34
+ }
35
+ static rangeUsage() {
36
+ return [
37
+ "A range must be specified using an operator and a minor version: '>=5.8'.",
38
+ "To set an upper bound, use the intersection of two ranges: '>=5.4 <5.6'.",
39
+ "Use the '||' operator to join ranges into a union: '>=5.4 <5.6 || 5.6.2 || >=5.8'.",
40
+ ];
41
+ }
42
+ static seen(element) {
43
+ return `The ${element} was seen here.`;
44
+ }
45
+ static unexpected(element) {
46
+ return `Unexpected ${element}.`;
47
+ }
48
+ static unknownOption(optionName) {
49
+ return `Unknown option '${optionName}'.`;
50
+ }
51
+ static versionIsNotSupported(value) {
52
+ return `The TypeScript version '${value}' is not supported.`;
53
+ }
54
+ static watchCannotBeEnabled() {
55
+ return "Watch mode cannot be enabled in continuous integration environment.";
56
+ }
57
+ }
@@ -0,0 +1,10 @@
1
+ import { type DiagnosticsHandler } from "#diagnostic";
2
+ import type { JsonScanner } from "#json";
3
+ import type { TextFile } from "#text";
4
+ import type { OptionGroup } from "./OptionGroup.enum.js";
5
+ import type { OptionValue } from "./types.js";
6
+ export declare class ConfigParser {
7
+ #private;
8
+ constructor(configOptions: Record<string, OptionValue>, optionGroup: OptionGroup, file: TextFile, jsonScanner: JsonScanner, onDiagnostics: DiagnosticsHandler);
9
+ parse(): Promise<void>;
10
+ }
@@ -0,0 +1,165 @@
1
+ import { Diagnostic } from "#diagnostic";
2
+ import { Path } from "#path";
3
+ import { ConfigDiagnosticText } from "./ConfigDiagnosticText.js";
4
+ import { Options } from "./Options.js";
5
+ import { Target } from "./Target.js";
6
+ export class ConfigParser {
7
+ #configFileOptions;
8
+ #file;
9
+ #jsonScanner;
10
+ #onDiagnostics;
11
+ #options;
12
+ constructor(configOptions, optionGroup, file, jsonScanner, onDiagnostics) {
13
+ this.#configFileOptions = configOptions;
14
+ this.#file = file;
15
+ this.#jsonScanner = jsonScanner;
16
+ this.#onDiagnostics = onDiagnostics;
17
+ this.#options = Options.for(optionGroup);
18
+ }
19
+ #onRequiresValue(optionName, optionBrand, jsonNode, isListItem) {
20
+ const text = isListItem
21
+ ? ConfigDiagnosticText.expectsListItemType(optionName, optionBrand)
22
+ : ConfigDiagnosticText.optionValueMustBe(optionName, optionBrand);
23
+ this.#onDiagnostics(Diagnostic.error(text, jsonNode.origin));
24
+ }
25
+ async #parseValue(optionDefinition, isListItem = false) {
26
+ let jsonNode;
27
+ let optionValue;
28
+ switch (optionDefinition.brand) {
29
+ case "boolean": {
30
+ jsonNode = this.#jsonScanner.read();
31
+ optionValue = jsonNode.getValue();
32
+ if (typeof optionValue !== "boolean") {
33
+ this.#onRequiresValue(optionDefinition.name, optionDefinition.brand, jsonNode, isListItem);
34
+ break;
35
+ }
36
+ break;
37
+ }
38
+ case "string": {
39
+ jsonNode = this.#jsonScanner.read();
40
+ optionValue = jsonNode.getValue();
41
+ if (typeof optionValue !== "string") {
42
+ this.#onRequiresValue(optionDefinition.name, optionDefinition.brand, jsonNode, isListItem);
43
+ break;
44
+ }
45
+ const basePath = Path.dirname(this.#file.path);
46
+ optionValue = Options.resolve(optionDefinition.name, optionValue, basePath);
47
+ await Options.validate(optionDefinition.name, optionValue, this.#onDiagnostics, jsonNode.origin);
48
+ break;
49
+ }
50
+ case "range": {
51
+ optionValue = [];
52
+ jsonNode = this.#jsonScanner.read();
53
+ const ranges = jsonNode.getValue();
54
+ if (typeof ranges !== "string") {
55
+ this.#onRequiresValue(optionDefinition.name, "string", jsonNode, isListItem);
56
+ break;
57
+ }
58
+ for (const range of Target.split(ranges)) {
59
+ await Options.validate(optionDefinition.name, range, this.#onDiagnostics, jsonNode.origin);
60
+ const versions = await Target.expand(range, this.#onDiagnostics, jsonNode.origin);
61
+ optionValue.push(...versions);
62
+ }
63
+ break;
64
+ }
65
+ case "list": {
66
+ optionValue = [];
67
+ const leftBracketToken = this.#jsonScanner.readToken("[");
68
+ if (!leftBracketToken.text) {
69
+ jsonNode = this.#jsonScanner.read();
70
+ this.#onRequiresValue(optionDefinition.name, optionDefinition.brand, jsonNode, isListItem);
71
+ break;
72
+ }
73
+ while (!this.#jsonScanner.isRead()) {
74
+ if (this.#jsonScanner.peekToken("]")) {
75
+ break;
76
+ }
77
+ const item = await this.#parseValue(optionDefinition.items, true);
78
+ if (item != null) {
79
+ optionValue.push(item);
80
+ }
81
+ const commaToken = this.#jsonScanner.readToken(",");
82
+ if (!commaToken.text) {
83
+ break;
84
+ }
85
+ }
86
+ const rightBracketToken = this.#jsonScanner.readToken("]");
87
+ if (!rightBracketToken.text) {
88
+ const text = ConfigDiagnosticText.expected("closing ']'");
89
+ const relatedText = ConfigDiagnosticText.seen("opening '['");
90
+ const diagnostic = Diagnostic.error(text, rightBracketToken.origin).add({
91
+ related: [Diagnostic.error(relatedText, leftBracketToken.origin)],
92
+ });
93
+ this.#onDiagnostics(diagnostic);
94
+ }
95
+ break;
96
+ }
97
+ }
98
+ return optionValue;
99
+ }
100
+ async #parseObject() {
101
+ const leftBraceToken = this.#jsonScanner.readToken("{");
102
+ if (this.#jsonScanner.isRead()) {
103
+ return;
104
+ }
105
+ if (!leftBraceToken.text) {
106
+ const text = ConfigDiagnosticText.expected("'{'");
107
+ this.#onDiagnostics(Diagnostic.error(text, leftBraceToken.origin));
108
+ return;
109
+ }
110
+ while (!this.#jsonScanner.isRead()) {
111
+ if (this.#jsonScanner.peekToken("}")) {
112
+ break;
113
+ }
114
+ const optionNameNode = this.#jsonScanner.read();
115
+ const optionName = optionNameNode.getValue({ expectsIdentifier: true });
116
+ if (!optionName) {
117
+ const text = ConfigDiagnosticText.expected("option name");
118
+ this.#onDiagnostics(Diagnostic.error(text, optionNameNode.origin));
119
+ return;
120
+ }
121
+ const optionDefinition = this.#options.get(optionName);
122
+ if (!optionDefinition) {
123
+ const text = ConfigDiagnosticText.unknownOption(optionName);
124
+ this.#onDiagnostics(Diagnostic.error(text, optionNameNode.origin));
125
+ this.#jsonScanner.readToken(":");
126
+ this.#jsonScanner.read();
127
+ const commaToken = this.#jsonScanner.readToken(",");
128
+ if (!commaToken.text) {
129
+ break;
130
+ }
131
+ continue;
132
+ }
133
+ if (this.#jsonScanner.peekToken(":")) {
134
+ this.#jsonScanner.readToken(":");
135
+ }
136
+ const parsedValue = await this.#parseValue(optionDefinition);
137
+ if (optionDefinition.name !== "$schema") {
138
+ this.#configFileOptions[optionDefinition.name] = parsedValue;
139
+ }
140
+ const commaToken = this.#jsonScanner.readToken(",");
141
+ if (!commaToken.text) {
142
+ break;
143
+ }
144
+ }
145
+ const rightBraceToken = this.#jsonScanner.readToken("}");
146
+ if (!rightBraceToken.text) {
147
+ const text = ConfigDiagnosticText.expected("closing '}'");
148
+ const relatedText = ConfigDiagnosticText.seen("opening '{'");
149
+ const diagnostic = Diagnostic.error(text, rightBraceToken.origin).add({
150
+ related: [Diagnostic.error(relatedText, leftBraceToken.origin)],
151
+ });
152
+ this.#onDiagnostics(diagnostic);
153
+ return;
154
+ }
155
+ const unexpectedToken = this.#jsonScanner.readToken(/\S/);
156
+ if (unexpectedToken.text != null) {
157
+ const text = ConfigDiagnosticText.unexpected("token");
158
+ const diagnostic = Diagnostic.error(text, unexpectedToken.origin);
159
+ this.#onDiagnostics(diagnostic);
160
+ }
161
+ }
162
+ async parse() {
163
+ await this.#parseObject();
164
+ }
165
+ }
@@ -0,0 +1,9 @@
1
+ import type { TestTreeNode } from "#collect";
2
+ import type * as ts from "#typescript";
3
+ import type { DirectiveRange, InlineConfig } from "./types.js";
4
+ export declare class Directive {
5
+ #private;
6
+ static getDirectiveRange(ts: ts.TypeScript, owner: TestTreeNode, directiveText: string): DirectiveRange | undefined;
7
+ static getDirectiveRanges(ts: ts.TypeScript, node: ts.Node): Array<DirectiveRange> | undefined;
8
+ static getInlineConfig(ranges: Array<DirectiveRange> | DirectiveRange | undefined): Promise<InlineConfig | undefined>;
9
+ }
@@ -0,0 +1,119 @@
1
+ import { Diagnostic, DiagnosticOrigin } from "#diagnostic";
2
+ import { EventEmitter } from "#events";
3
+ import { JsonScanner } from "#json";
4
+ import { TextFileService } from "#text";
5
+ import { ConfigParser } from "./ConfigParser.js";
6
+ import { DirectiveDiagnosticText } from "./DirectiveDiagnosticText.js";
7
+ export class Directive {
8
+ static #directiveRegex = /^(\/\/ *@tstyche)( *|-)?(\S*)?( *)?(.*)?/i;
9
+ static #rangeCache = new WeakMap();
10
+ static getDirectiveRange(ts, owner, directiveText) {
11
+ const directiveRanges = Directive.getDirectiveRanges(ts, owner.node);
12
+ return directiveRanges?.find((range) => range.directive?.text === directiveText);
13
+ }
14
+ static getDirectiveRanges(ts, node) {
15
+ let ranges = Directive.#rangeCache.get(node);
16
+ if (ranges != null) {
17
+ return ranges;
18
+ }
19
+ let sourceFile;
20
+ let position = 0;
21
+ if (ts.isSourceFile(node)) {
22
+ sourceFile = node;
23
+ }
24
+ else {
25
+ sourceFile = node.getSourceFile();
26
+ position = node.getFullStart();
27
+ }
28
+ const comments = ts.getLeadingCommentRanges(sourceFile.text, position);
29
+ if (!comments || comments.length === 0) {
30
+ return;
31
+ }
32
+ ranges = [];
33
+ for (const comment of comments) {
34
+ if (comment.kind !== ts.SyntaxKind.SingleLineCommentTrivia) {
35
+ continue;
36
+ }
37
+ const range = Directive.#getRange(sourceFile, comment);
38
+ if (range != null) {
39
+ ranges.push(range);
40
+ }
41
+ }
42
+ Directive.#rangeCache.set(node, ranges);
43
+ return ranges;
44
+ }
45
+ static async getInlineConfig(ranges) {
46
+ if (!ranges) {
47
+ return;
48
+ }
49
+ ranges = Array.isArray(ranges) ? ranges : [ranges];
50
+ const inlineConfig = {};
51
+ for (const range of ranges) {
52
+ await Directive.#parse(inlineConfig, range);
53
+ }
54
+ return inlineConfig;
55
+ }
56
+ static #getRange(sourceFile, comment) {
57
+ const [text] = sourceFile.text.substring(comment.pos, comment.end).split(/--+/);
58
+ const match = text?.match(Directive.#directiveRegex);
59
+ const namespaceText = match?.[1];
60
+ if (!namespaceText) {
61
+ return;
62
+ }
63
+ const range = {
64
+ file: TextFileService.get(sourceFile),
65
+ namespace: { start: comment.pos, end: comment.pos + namespaceText.length, text: namespaceText },
66
+ };
67
+ const directiveSeparatorText = match[2];
68
+ const directiveText = match[3];
69
+ if (typeof directiveText === "string" && typeof directiveSeparatorText === "string") {
70
+ const start = range.namespace.end + directiveSeparatorText.length;
71
+ range.directive = { start, end: start + directiveText.length, text: directiveText };
72
+ const argumentSeparatorText = match[4];
73
+ const argumentText = match[5]?.trimEnd();
74
+ if (typeof argumentSeparatorText === "string" && typeof argumentText === "string") {
75
+ const start = range.directive.end + argumentSeparatorText.length;
76
+ range.argument = { start, end: start + argumentText.length, text: argumentText };
77
+ }
78
+ }
79
+ return range;
80
+ }
81
+ static #onDiagnostics(diagnostic) {
82
+ EventEmitter.dispatch(["directive:error", { diagnostics: [diagnostic] }]);
83
+ }
84
+ static async #parse(inlineConfig, range) {
85
+ switch (range.directive?.text) {
86
+ case "if":
87
+ {
88
+ if (!range.argument?.text) {
89
+ const text = DirectiveDiagnosticText.requiresArgument();
90
+ const origin = new DiagnosticOrigin(range.namespace.start, range.directive.end, range.file);
91
+ Directive.#onDiagnostics(Diagnostic.error(text, origin));
92
+ return;
93
+ }
94
+ const value = await Directive.#parseJson(range.file, range.argument.start, range.argument.end);
95
+ inlineConfig.if = value;
96
+ }
97
+ return;
98
+ case "fixme":
99
+ case "template":
100
+ if (range.argument?.text != null) {
101
+ const text = DirectiveDiagnosticText.doesNotTakeArgument();
102
+ const origin = new DiagnosticOrigin(range.argument.start, range.argument.end, range.file);
103
+ Directive.#onDiagnostics(Diagnostic.error(text, origin));
104
+ }
105
+ inlineConfig[range.directive.text] = true;
106
+ return;
107
+ }
108
+ const target = range.directive ?? range.namespace;
109
+ const text = DirectiveDiagnosticText.isNotSupported(target.text);
110
+ const origin = new DiagnosticOrigin(target.start, target.end, range.file);
111
+ Directive.#onDiagnostics(Diagnostic.error(text, origin));
112
+ }
113
+ static async #parseJson(file, start, end) {
114
+ const inlineOptions = {};
115
+ const configParser = new ConfigParser(inlineOptions, 8, file, new JsonScanner(file, { start, end }), Directive.#onDiagnostics);
116
+ await configParser.parse();
117
+ return inlineOptions;
118
+ }
119
+ }
@@ -0,0 +1,5 @@
1
+ export declare class DirectiveDiagnosticText {
2
+ static doesNotTakeArgument(): string;
3
+ static isNotSupported(directive: string): string;
4
+ static requiresArgument(): string;
5
+ }
@@ -0,0 +1,11 @@
1
+ export class DirectiveDiagnosticText {
2
+ static doesNotTakeArgument() {
3
+ return "Directive does not take an argument.";
4
+ }
5
+ static isNotSupported(directive) {
6
+ return `The '${directive}' directive is not supported.`;
7
+ }
8
+ static requiresArgument() {
9
+ return "Directive requires an argument.";
10
+ }
11
+ }
@@ -0,0 +1,8 @@
1
+ export declare enum OptionBrand {
2
+ String = "string",
3
+ SemverRange = "range",
4
+ Number = "number",
5
+ Boolean = "boolean",
6
+ True = "true",
7
+ List = "list"
8
+ }
@@ -0,0 +1,9 @@
1
+ export var OptionBrand;
2
+ (function (OptionBrand) {
3
+ OptionBrand["String"] = "string";
4
+ OptionBrand["SemverRange"] = "range";
5
+ OptionBrand["Number"] = "number";
6
+ OptionBrand["Boolean"] = "boolean";
7
+ OptionBrand["True"] = "true";
8
+ OptionBrand["List"] = "list";
9
+ })(OptionBrand || (OptionBrand = {}));
@@ -0,0 +1,5 @@
1
+ export declare enum OptionGroup {
2
+ CommandLine = 2,
3
+ ConfigFile = 4,
4
+ InlineConditions = 8
5
+ }
@@ -0,0 +1,6 @@
1
+ export var OptionGroup;
2
+ (function (OptionGroup) {
3
+ OptionGroup[OptionGroup["CommandLine"] = 2] = "CommandLine";
4
+ OptionGroup[OptionGroup["ConfigFile"] = 4] = "ConfigFile";
5
+ OptionGroup[OptionGroup["InlineConditions"] = 8] = "InlineConditions";
6
+ })(OptionGroup || (OptionGroup = {}));
@@ -0,0 +1,29 @@
1
+ import { type DiagnosticOrigin, type DiagnosticsHandler } from "#diagnostic";
2
+ import { OptionBrand } from "./OptionBrand.enum.js";
3
+ import { OptionGroup } from "./OptionGroup.enum.js";
4
+ interface BaseOptionDefinition {
5
+ brand: OptionBrand;
6
+ description: string;
7
+ group: OptionGroup;
8
+ name: string;
9
+ }
10
+ interface PrimitiveTypeOptionDefinition extends BaseOptionDefinition {
11
+ brand: OptionBrand.String | OptionBrand.SemverRange | OptionBrand.Number | OptionBrand.Boolean | OptionBrand.True;
12
+ }
13
+ export interface ItemDefinition {
14
+ brand: OptionBrand.String;
15
+ name: string;
16
+ }
17
+ interface ListTypeOptionDefinition extends BaseOptionDefinition {
18
+ brand: OptionBrand.List;
19
+ items: ItemDefinition;
20
+ }
21
+ export type OptionDefinition = PrimitiveTypeOptionDefinition | ListTypeOptionDefinition;
22
+ export declare class Options {
23
+ #private;
24
+ static for(optionGroup: OptionGroup): Map<string, OptionDefinition>;
25
+ static isJsonString(text: string): boolean;
26
+ static resolve(optionName: string, optionValue: string, basePath?: string): string;
27
+ static validate(optionName: string, optionValue: string, onDiagnostics: DiagnosticsHandler, origin?: DiagnosticOrigin): Promise<void>;
28
+ }
29
+ export {};