tstyche 1.0.0-beta.2 → 1.0.0-beta.4
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/CHANGELOG.md +47 -0
- package/README.md +6 -6
- package/build/{index-cjs.js → index.cjs} +0 -1
- package/build/{index-cjs.d.ts → index.d.cts} +13 -17
- package/build/index.d.ts +13 -17
- package/build/index.js +1 -1
- package/build/tstyche.d.ts +3 -3
- package/build/tstyche.js +50 -77
- package/package.json +19 -48
- package/lib/schema.json +0 -47
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.0.0-beta.4] - 2023-11-24
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Use Node.js Fetch API ([#23](https://github.com/tstyche/tstyche/pull/23))
|
|
8
|
+
|
|
9
|
+
### Removed
|
|
10
|
+
|
|
11
|
+
- **Breaking:** Remove the `context()` helper ([#24](https://github.com/tstyche/tstyche/pull/24))
|
|
12
|
+
- **Breaking:** Drop support for Node.js 16 ([#22](https://github.com/tstyche/tstyche/pull/22))
|
|
13
|
+
- **Breaking:** Rename methods of the `StoreService` class ([`5d74201`](https://github.com/tstyche/tstyche/commit/5d74201))
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Tune up behavior of `.skip` and `.only` run mode flags ([#25](https://github.com/tstyche/tstyche/pull/25))
|
|
18
|
+
- Clean up error messages of primitive type matchers ([#21](https://github.com/tstyche/tstyche/pull/21))
|
|
19
|
+
- Normalize `installationPath` path output ([#19](https://github.com/tstyche/tstyche/pull/19))
|
|
20
|
+
|
|
21
|
+
## [1.0.0-beta.3] - 2023-11-13
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Support TypeScript's 'node10' and 'node16' resolutions ([`7dd805a`](https://github.com/tstyche/tstyche/commit/7dd805a), [`9c83e79`](https://github.com/tstyche/tstyche/commit/9c83e79))
|
|
26
|
+
|
|
27
|
+
## [1.0.0-beta.2] - 2023-11-12
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Support TypeScript's 'node10' resolution ([#7](https://github.com/tstyche/tstyche/pull/7))
|
|
32
|
+
|
|
33
|
+
## [1.0.0-beta.1] - 2023-11-09
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Include 'cjs' files in the published package ([`90b6473`](https://github.com/tstyche/tstyche/commit/90b6473))
|
|
38
|
+
|
|
39
|
+
## [1.0.0-beta.0] - 2023-11-09
|
|
40
|
+
|
|
41
|
+
_First pre-release._
|
|
42
|
+
|
|
43
|
+
[1.0.0-beta.4]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-beta.4
|
|
44
|
+
[1.0.0-beta.3]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-beta.3
|
|
45
|
+
[1.0.0-beta.2]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-beta.2
|
|
46
|
+
[1.0.0-beta.1]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-beta.1
|
|
47
|
+
[1.0.0-beta.0]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-beta.0
|
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ test("firstItem", () => {
|
|
|
31
31
|
|
|
32
32
|
To organize, debug and plan tests TSTyche has:
|
|
33
33
|
|
|
34
|
-
- `test()`, `it()
|
|
34
|
+
- `test()`, `it()` and `describe()` helpers,
|
|
35
35
|
- with `.only`, `.skip` and `.todo` run mode flags.
|
|
36
36
|
|
|
37
37
|
## Assertions
|
|
@@ -39,18 +39,18 @@ To organize, debug and plan tests TSTyche has:
|
|
|
39
39
|
The assertions can be used to write type tests (like in the above example) or mixed in your functional tests:
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
|
+
import assert from "node:assert/strict";
|
|
43
|
+
import { test } from "node:test";
|
|
42
44
|
import * as tstyche from "tstyche";
|
|
43
45
|
|
|
44
46
|
function secondItem<T>(target: Array<T>): T | undefined {
|
|
45
47
|
return target[1];
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
expect(secondItem([1, 2, 3])).toBe(1);
|
|
50
|
+
test("handles numbers", () => {
|
|
51
|
+
assert.strictEqual(secondItem([1, 2, 3]), 2);
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
});
|
|
53
|
+
tstyche.expect(secondItem([1, 2, 3])).type.toEqual<number | undefined>();
|
|
54
54
|
});
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -60,7 +60,7 @@ interface Test {
|
|
|
60
60
|
}
|
|
61
61
|
interface Matchers {
|
|
62
62
|
/**
|
|
63
|
-
* Checks if the
|
|
63
|
+
* Checks if the `any` type is identical to the source type.
|
|
64
64
|
*/
|
|
65
65
|
toBeAny: () => void;
|
|
66
66
|
/**
|
|
@@ -77,47 +77,47 @@ interface Matchers {
|
|
|
77
77
|
(target: unknown): void;
|
|
78
78
|
};
|
|
79
79
|
/**
|
|
80
|
-
* Checks if the
|
|
80
|
+
* Checks if the `bigint` type is identical to the source type.
|
|
81
81
|
*/
|
|
82
82
|
toBeBigInt: () => void;
|
|
83
83
|
/**
|
|
84
|
-
* Checks if the
|
|
84
|
+
* Checks if the `boolean` type is identical to the source type.
|
|
85
85
|
*/
|
|
86
86
|
toBeBoolean: () => void;
|
|
87
87
|
/**
|
|
88
|
-
* Checks if the
|
|
88
|
+
* Checks if the `never` type is identical to the source type.
|
|
89
89
|
*/
|
|
90
90
|
toBeNever: () => void;
|
|
91
91
|
/**
|
|
92
|
-
* Checks if the
|
|
92
|
+
* Checks if the `null` type is identical to the source type.
|
|
93
93
|
*/
|
|
94
94
|
toBeNull: () => void;
|
|
95
95
|
/**
|
|
96
|
-
* Checks if the
|
|
96
|
+
* Checks if the `number` type is identical to the source type.
|
|
97
97
|
*/
|
|
98
98
|
toBeNumber: () => void;
|
|
99
99
|
/**
|
|
100
|
-
* Checks if the
|
|
100
|
+
* Checks if the `string` type is identical to the source type.
|
|
101
101
|
*/
|
|
102
102
|
toBeString: () => void;
|
|
103
103
|
/**
|
|
104
|
-
* Checks if the
|
|
104
|
+
* Checks if the `symbol` type is identical to the source type.
|
|
105
105
|
*/
|
|
106
106
|
toBeSymbol: () => void;
|
|
107
107
|
/**
|
|
108
|
-
* Checks if the
|
|
108
|
+
* Checks if the `undefined` type is identical to the source type.
|
|
109
109
|
*/
|
|
110
110
|
toBeUndefined: () => void;
|
|
111
111
|
/**
|
|
112
|
-
* Checks if the
|
|
112
|
+
* Checks if the `unique symbol` type is identical to the source type.
|
|
113
113
|
*/
|
|
114
114
|
toBeUniqueSymbol: () => void;
|
|
115
115
|
/**
|
|
116
|
-
* Checks if the
|
|
116
|
+
* Checks if the `unknown` type is identical to the source type.
|
|
117
117
|
*/
|
|
118
118
|
toBeUnknown: () => void;
|
|
119
119
|
/**
|
|
120
|
-
* Checks if the
|
|
120
|
+
* Checks if the `void` type is identical to the source type.
|
|
121
121
|
*/
|
|
122
122
|
toBeVoid: () => void;
|
|
123
123
|
/**
|
|
@@ -256,10 +256,6 @@ interface Expect {
|
|
|
256
256
|
* Defines a test group.
|
|
257
257
|
*/
|
|
258
258
|
declare const describe: Describe;
|
|
259
|
-
/**
|
|
260
|
-
* Defines a test group.
|
|
261
|
-
*/
|
|
262
|
-
declare const context: Describe;
|
|
263
259
|
/**
|
|
264
260
|
* Defines a single test.
|
|
265
261
|
*/
|
|
@@ -273,4 +269,4 @@ declare const it: Test;
|
|
|
273
269
|
*/
|
|
274
270
|
declare const expect: Expect;
|
|
275
271
|
|
|
276
|
-
export {
|
|
272
|
+
export { describe, expect, it, test };
|
package/build/index.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ interface Test {
|
|
|
60
60
|
}
|
|
61
61
|
interface Matchers {
|
|
62
62
|
/**
|
|
63
|
-
* Checks if the
|
|
63
|
+
* Checks if the `any` type is identical to the source type.
|
|
64
64
|
*/
|
|
65
65
|
toBeAny: () => void;
|
|
66
66
|
/**
|
|
@@ -77,47 +77,47 @@ interface Matchers {
|
|
|
77
77
|
(target: unknown): void;
|
|
78
78
|
};
|
|
79
79
|
/**
|
|
80
|
-
* Checks if the
|
|
80
|
+
* Checks if the `bigint` type is identical to the source type.
|
|
81
81
|
*/
|
|
82
82
|
toBeBigInt: () => void;
|
|
83
83
|
/**
|
|
84
|
-
* Checks if the
|
|
84
|
+
* Checks if the `boolean` type is identical to the source type.
|
|
85
85
|
*/
|
|
86
86
|
toBeBoolean: () => void;
|
|
87
87
|
/**
|
|
88
|
-
* Checks if the
|
|
88
|
+
* Checks if the `never` type is identical to the source type.
|
|
89
89
|
*/
|
|
90
90
|
toBeNever: () => void;
|
|
91
91
|
/**
|
|
92
|
-
* Checks if the
|
|
92
|
+
* Checks if the `null` type is identical to the source type.
|
|
93
93
|
*/
|
|
94
94
|
toBeNull: () => void;
|
|
95
95
|
/**
|
|
96
|
-
* Checks if the
|
|
96
|
+
* Checks if the `number` type is identical to the source type.
|
|
97
97
|
*/
|
|
98
98
|
toBeNumber: () => void;
|
|
99
99
|
/**
|
|
100
|
-
* Checks if the
|
|
100
|
+
* Checks if the `string` type is identical to the source type.
|
|
101
101
|
*/
|
|
102
102
|
toBeString: () => void;
|
|
103
103
|
/**
|
|
104
|
-
* Checks if the
|
|
104
|
+
* Checks if the `symbol` type is identical to the source type.
|
|
105
105
|
*/
|
|
106
106
|
toBeSymbol: () => void;
|
|
107
107
|
/**
|
|
108
|
-
* Checks if the
|
|
108
|
+
* Checks if the `undefined` type is identical to the source type.
|
|
109
109
|
*/
|
|
110
110
|
toBeUndefined: () => void;
|
|
111
111
|
/**
|
|
112
|
-
* Checks if the
|
|
112
|
+
* Checks if the `unique symbol` type is identical to the source type.
|
|
113
113
|
*/
|
|
114
114
|
toBeUniqueSymbol: () => void;
|
|
115
115
|
/**
|
|
116
|
-
* Checks if the
|
|
116
|
+
* Checks if the `unknown` type is identical to the source type.
|
|
117
117
|
*/
|
|
118
118
|
toBeUnknown: () => void;
|
|
119
119
|
/**
|
|
120
|
-
* Checks if the
|
|
120
|
+
* Checks if the `void` type is identical to the source type.
|
|
121
121
|
*/
|
|
122
122
|
toBeVoid: () => void;
|
|
123
123
|
/**
|
|
@@ -256,10 +256,6 @@ interface Expect {
|
|
|
256
256
|
* Defines a test group.
|
|
257
257
|
*/
|
|
258
258
|
declare const describe: Describe;
|
|
259
|
-
/**
|
|
260
|
-
* Defines a test group.
|
|
261
|
-
*/
|
|
262
|
-
declare const context: Describe;
|
|
263
259
|
/**
|
|
264
260
|
* Defines a single test.
|
|
265
261
|
*/
|
|
@@ -273,4 +269,4 @@ declare const it: Test;
|
|
|
273
269
|
*/
|
|
274
270
|
declare const expect: Expect;
|
|
275
271
|
|
|
276
|
-
export {
|
|
272
|
+
export { describe, expect, it, test };
|
package/build/index.js
CHANGED
package/build/tstyche.d.ts
CHANGED
|
@@ -35,10 +35,10 @@ declare class Diagnostic {
|
|
|
35
35
|
declare class StoreService {
|
|
36
36
|
#private;
|
|
37
37
|
constructor();
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
get supportedTags(): Array<string>;
|
|
39
|
+
install(tag: string, signal?: AbortSignal): Promise<string | undefined>;
|
|
40
|
+
load(tag: string, signal?: AbortSignal): Promise<typeof ts | undefined>;
|
|
40
41
|
open(signal?: AbortSignal): Promise<void>;
|
|
41
|
-
prepareCompilerModule(tag: string, signal?: AbortSignal): Promise<string | undefined>;
|
|
42
42
|
prune(): Promise<void>;
|
|
43
43
|
resolveTag(tag: string): string | undefined;
|
|
44
44
|
update(signal?: AbortSignal): Promise<void>;
|
package/build/tstyche.js
CHANGED
|
@@ -6,7 +6,6 @@ import fs from 'node:fs/promises';
|
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
7
7
|
import { spawn } from 'node:child_process';
|
|
8
8
|
import { setInterval } from 'node:timers/promises';
|
|
9
|
-
import https from 'node:https';
|
|
10
9
|
|
|
11
10
|
class EventEmitter {
|
|
12
11
|
static #handlers = new Set();
|
|
@@ -1387,7 +1386,6 @@ class IdentifierLookup {
|
|
|
1387
1386
|
this.compiler = compiler;
|
|
1388
1387
|
this.#identifiers = identifiers ?? {
|
|
1389
1388
|
namedImports: {
|
|
1390
|
-
context: undefined,
|
|
1391
1389
|
describe: undefined,
|
|
1392
1390
|
expect: undefined,
|
|
1393
1391
|
it: undefined,
|
|
@@ -1398,10 +1396,7 @@ class IdentifierLookup {
|
|
|
1398
1396
|
};
|
|
1399
1397
|
}
|
|
1400
1398
|
clone() {
|
|
1401
|
-
return
|
|
1402
|
-
namedImports: { ...this.#identifiers.namedImports },
|
|
1403
|
-
namespace: this.#identifiers.namespace,
|
|
1404
|
-
};
|
|
1399
|
+
return structuredClone(this.#identifiers);
|
|
1405
1400
|
}
|
|
1406
1401
|
handleImportDeclaration(node) {
|
|
1407
1402
|
if (this.#moduleSpecifiers.includes(node.moduleSpecifier.getText()) &&
|
|
@@ -1464,7 +1459,6 @@ class IdentifierLookup {
|
|
|
1464
1459
|
return;
|
|
1465
1460
|
}
|
|
1466
1461
|
switch (identifierName) {
|
|
1467
|
-
case "context":
|
|
1468
1462
|
case "describe":
|
|
1469
1463
|
return { brand: "describe", flags };
|
|
1470
1464
|
case "it":
|
|
@@ -1621,7 +1615,7 @@ class ProjectService {
|
|
|
1621
1615
|
startGroup: doNothing,
|
|
1622
1616
|
};
|
|
1623
1617
|
const host = {
|
|
1624
|
-
...compiler.sys,
|
|
1618
|
+
...this.compiler.sys,
|
|
1625
1619
|
clearImmediate,
|
|
1626
1620
|
clearTimeout,
|
|
1627
1621
|
setImmediate,
|
|
@@ -1838,7 +1832,9 @@ class Checker {
|
|
|
1838
1832
|
};
|
|
1839
1833
|
const sourceText = assertion.typeChecker.typeToString(assertion.sourceType.type);
|
|
1840
1834
|
return [
|
|
1841
|
-
Diagnostic.error(assertion.isNot
|
|
1835
|
+
Diagnostic.error(assertion.isNot
|
|
1836
|
+
? `Type '${targetText}' is identical to type '${sourceText}'.`
|
|
1837
|
+
: `Type '${targetText}' is not identical to type '${sourceText}'.`, origin),
|
|
1842
1838
|
];
|
|
1843
1839
|
}
|
|
1844
1840
|
match(assertion) {
|
|
@@ -2057,7 +2053,8 @@ class TestTreeWorker {
|
|
|
2057
2053
|
const describeResult = new DescribeResult(describe, parentResult);
|
|
2058
2054
|
EventEmitter.dispatch(["describe:start", { result: describeResult }]);
|
|
2059
2055
|
runMode = this.#resolveRunMode(runMode, describe);
|
|
2060
|
-
if (!(runMode & 4 || runMode &
|
|
2056
|
+
if (!(runMode & 4 || (this.#hasOnly && !(runMode & 2)) || runMode & 8) &&
|
|
2057
|
+
describe.diagnostics.length > 0) {
|
|
2061
2058
|
EventEmitter.dispatch([
|
|
2062
2059
|
"file:error",
|
|
2063
2060
|
{
|
|
@@ -2079,11 +2076,7 @@ class TestTreeWorker {
|
|
|
2079
2076
|
EventEmitter.dispatch(["test:todo", { result: testResult }]);
|
|
2080
2077
|
return;
|
|
2081
2078
|
}
|
|
2082
|
-
if (runMode & 4) {
|
|
2083
|
-
EventEmitter.dispatch(["test:skip", { result: testResult }]);
|
|
2084
|
-
return;
|
|
2085
|
-
}
|
|
2086
|
-
if (test.diagnostics.length > 0) {
|
|
2079
|
+
if (!(runMode & 4 || (this.#hasOnly && !(runMode & 2))) && test.diagnostics.length > 0) {
|
|
2087
2080
|
EventEmitter.dispatch([
|
|
2088
2081
|
"test:error",
|
|
2089
2082
|
{
|
|
@@ -2094,7 +2087,7 @@ class TestTreeWorker {
|
|
|
2094
2087
|
return;
|
|
2095
2088
|
}
|
|
2096
2089
|
this.visit(test.members, runMode, testResult);
|
|
2097
|
-
if (
|
|
2090
|
+
if (runMode & 4 || (this.#hasOnly && !(runMode & 2))) {
|
|
2098
2091
|
EventEmitter.dispatch(["test:skip", { result: testResult }]);
|
|
2099
2092
|
return;
|
|
2100
2093
|
}
|
|
@@ -2196,7 +2189,7 @@ class TaskRunner {
|
|
|
2196
2189
|
for (const versionTag of target) {
|
|
2197
2190
|
const targetResult = new TargetResult(versionTag, testFiles);
|
|
2198
2191
|
EventEmitter.dispatch(["target:start", { result: targetResult }]);
|
|
2199
|
-
const compiler = await this.#storeService.
|
|
2192
|
+
const compiler = await this.#storeService.load(versionTag, signal);
|
|
2200
2193
|
if (compiler) {
|
|
2201
2194
|
const testFileRunner = new TestFileRunner(this.resolvedConfig, compiler);
|
|
2202
2195
|
for (const testFile of testFiles) {
|
|
@@ -2429,7 +2422,7 @@ class OptionUsageText {
|
|
|
2429
2422
|
const usageText = [];
|
|
2430
2423
|
switch (optionName) {
|
|
2431
2424
|
case "target": {
|
|
2432
|
-
const supportedTags = this.#storeService
|
|
2425
|
+
const { supportedTags } = this.#storeService;
|
|
2433
2426
|
const supportedTagsText = `Supported tags: ${["'", supportedTags.join("', '"), "'"].join("")}.`;
|
|
2434
2427
|
switch (this.#optionGroup) {
|
|
2435
2428
|
case 2:
|
|
@@ -2966,7 +2959,7 @@ class CompilerModuleWorker {
|
|
|
2966
2959
|
if (existsSync(readyFilePath)) {
|
|
2967
2960
|
return tsserverFilePath;
|
|
2968
2961
|
}
|
|
2969
|
-
EventEmitter.dispatch(["store:info", { compilerVersion, installationPath }]);
|
|
2962
|
+
EventEmitter.dispatch(["store:info", { compilerVersion, installationPath: this.#normalizePath(installationPath) }]);
|
|
2970
2963
|
await fs.mkdir(installationPath, { recursive: true });
|
|
2971
2964
|
const lock = new Lock(installationPath);
|
|
2972
2965
|
await fs.writeFile(path.join(installationPath, "package.json"), this.#getPackageJson(compilerVersion));
|
|
@@ -3029,6 +3022,12 @@ class CompilerModuleWorker {
|
|
|
3029
3022
|
});
|
|
3030
3023
|
});
|
|
3031
3024
|
}
|
|
3025
|
+
#normalizePath(filePath) {
|
|
3026
|
+
if (path.sep === "/") {
|
|
3027
|
+
return filePath;
|
|
3028
|
+
}
|
|
3029
|
+
return filePath.replace(/\\/g, "/");
|
|
3030
|
+
}
|
|
3032
3031
|
}
|
|
3033
3032
|
|
|
3034
3033
|
class ManifestWorker {
|
|
@@ -3044,34 +3043,14 @@ class ManifestWorker {
|
|
|
3044
3043
|
this.#prune = prune;
|
|
3045
3044
|
}
|
|
3046
3045
|
async #fetch(signal) {
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
signal,
|
|
3051
|
-
}, (result) => {
|
|
3052
|
-
if (result.statusCode !== 200) {
|
|
3053
|
-
reject(new Error(`Request failed with status code ${String(result.statusCode)}.`));
|
|
3054
|
-
return;
|
|
3055
|
-
}
|
|
3056
|
-
result.setEncoding("utf8");
|
|
3057
|
-
let rawData = "";
|
|
3058
|
-
result.on("data", (chunk) => {
|
|
3059
|
-
rawData += chunk;
|
|
3060
|
-
});
|
|
3061
|
-
result.on("end", () => {
|
|
3062
|
-
try {
|
|
3063
|
-
const packageMetadata = JSON.parse(rawData);
|
|
3064
|
-
resolve(packageMetadata);
|
|
3065
|
-
}
|
|
3066
|
-
catch (error) {
|
|
3067
|
-
reject(error);
|
|
3068
|
-
}
|
|
3069
|
-
});
|
|
3070
|
-
});
|
|
3071
|
-
request.on("error", (error) => {
|
|
3072
|
-
reject(error);
|
|
3073
|
-
});
|
|
3046
|
+
const result = await fetch(new URL("typescript", this.#registryUrl), {
|
|
3047
|
+
headers: { accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*" },
|
|
3048
|
+
signal,
|
|
3074
3049
|
});
|
|
3050
|
+
if (!result.ok) {
|
|
3051
|
+
throw new Error(`Request failed with status code ${String(result.status)}.`);
|
|
3052
|
+
}
|
|
3053
|
+
return result.json();
|
|
3075
3054
|
}
|
|
3076
3055
|
isOutdated(manifest, ageTolerance = 0) {
|
|
3077
3056
|
if (Date.now() - manifest.lastUpdated > 2 * 60 * 60 * 1000 + ageTolerance * 1000) {
|
|
@@ -3114,7 +3093,7 @@ class ManifestWorker {
|
|
|
3114
3093
|
.sort();
|
|
3115
3094
|
const minorVersions = [...new Set(manifest.versions.map((version) => version.slice(0, -2)))];
|
|
3116
3095
|
for (const tag of minorVersions) {
|
|
3117
|
-
const resolvedVersion = manifest.versions.
|
|
3096
|
+
const resolvedVersion = manifest.versions.findLast((version) => version.startsWith(tag));
|
|
3118
3097
|
if (resolvedVersion != null) {
|
|
3119
3098
|
manifest.resolutions[tag] = resolvedVersion;
|
|
3120
3099
|
}
|
|
@@ -3195,14 +3174,33 @@ class StoreService {
|
|
|
3195
3174
|
this.#compilerModuleWorker = new CompilerModuleWorker(this.#cachePath);
|
|
3196
3175
|
this.#manifestWorker = new ManifestWorker(this.#cachePath, async () => this.prune());
|
|
3197
3176
|
}
|
|
3198
|
-
|
|
3177
|
+
get supportedTags() {
|
|
3199
3178
|
if (!this.#manifest) {
|
|
3200
3179
|
this.#onDiagnostic(Diagnostic.error("Store manifest is not open. Call 'StoreService.open()' first."));
|
|
3201
3180
|
return [];
|
|
3202
3181
|
}
|
|
3203
3182
|
return [...Object.keys(this.#manifest.resolutions), ...this.#manifest.versions].sort();
|
|
3204
3183
|
}
|
|
3205
|
-
async
|
|
3184
|
+
async install(tag, signal) {
|
|
3185
|
+
if (!this.#manifest) {
|
|
3186
|
+
this.#onDiagnostic(Diagnostic.error("Store manifest is not open. Call 'StoreService.open()' first."));
|
|
3187
|
+
return;
|
|
3188
|
+
}
|
|
3189
|
+
const version = this.resolveTag(tag);
|
|
3190
|
+
if (version == null) {
|
|
3191
|
+
this.#onDiagnostic(Diagnostic.error(`Cannot add the 'typescript' package for the '${tag}' tag.`));
|
|
3192
|
+
return;
|
|
3193
|
+
}
|
|
3194
|
+
let modulePath;
|
|
3195
|
+
try {
|
|
3196
|
+
modulePath = await this.#compilerModuleWorker.ensure(version, signal);
|
|
3197
|
+
}
|
|
3198
|
+
catch (error) {
|
|
3199
|
+
this.#onDiagnostic(Diagnostic.fromError(`Failed to install 'typescript@${version}'.`, error));
|
|
3200
|
+
}
|
|
3201
|
+
return modulePath;
|
|
3202
|
+
}
|
|
3203
|
+
async load(tag, signal) {
|
|
3206
3204
|
let modulePath;
|
|
3207
3205
|
if (tag === "local") {
|
|
3208
3206
|
try {
|
|
@@ -3213,7 +3211,7 @@ class StoreService {
|
|
|
3213
3211
|
}
|
|
3214
3212
|
}
|
|
3215
3213
|
if (modulePath == null) {
|
|
3216
|
-
modulePath = await this.
|
|
3214
|
+
modulePath = await this.install(tag, signal);
|
|
3217
3215
|
}
|
|
3218
3216
|
if (modulePath != null) {
|
|
3219
3217
|
return this.#nodeRequire(modulePath);
|
|
@@ -3229,31 +3227,6 @@ class StoreService {
|
|
|
3229
3227
|
}
|
|
3230
3228
|
this.#manifest = await this.#manifestWorker.open(signal);
|
|
3231
3229
|
}
|
|
3232
|
-
async prepareCompilerModule(tag, signal) {
|
|
3233
|
-
if (!this.#manifest) {
|
|
3234
|
-
this.#onDiagnostic(Diagnostic.error("Store manifest is not open. Call 'StoreService.open()' first."));
|
|
3235
|
-
return;
|
|
3236
|
-
}
|
|
3237
|
-
const version = this.resolveTag(tag);
|
|
3238
|
-
if (version == null) {
|
|
3239
|
-
this.#onDiagnostic(Diagnostic.error(`Cannot add the 'typescript' package for the '${tag}' tag.`));
|
|
3240
|
-
return;
|
|
3241
|
-
}
|
|
3242
|
-
let modulePath;
|
|
3243
|
-
try {
|
|
3244
|
-
modulePath = await this.#compilerModuleWorker.ensure(version, signal);
|
|
3245
|
-
}
|
|
3246
|
-
catch (error) {
|
|
3247
|
-
this.#onDiagnostic(Diagnostic.fromError(`Failed to install 'typescript@${version}'.`, error));
|
|
3248
|
-
}
|
|
3249
|
-
if (modulePath != null) {
|
|
3250
|
-
if (!("lastUsed" in this.#manifest)) {
|
|
3251
|
-
this.#manifest.lastUsed = {};
|
|
3252
|
-
}
|
|
3253
|
-
this.#manifest.lastUsed[version] = Date.now();
|
|
3254
|
-
}
|
|
3255
|
-
return modulePath;
|
|
3256
|
-
}
|
|
3257
3230
|
async prune() {
|
|
3258
3231
|
await fs.rm(this.#cachePath, { force: true, recursive: true });
|
|
3259
3232
|
}
|
|
@@ -3487,7 +3460,7 @@ class Cli {
|
|
|
3487
3460
|
if (this.#process.exitCode === 1) {
|
|
3488
3461
|
return;
|
|
3489
3462
|
}
|
|
3490
|
-
const compiler = await this.#storeService.
|
|
3463
|
+
const compiler = await this.#storeService.load("local", this.#abortController.signal);
|
|
3491
3464
|
if (!compiler) {
|
|
3492
3465
|
return;
|
|
3493
3466
|
}
|
|
@@ -3529,7 +3502,7 @@ class Cli {
|
|
|
3529
3502
|
}
|
|
3530
3503
|
if (configService.commandLineOptions.install === true) {
|
|
3531
3504
|
for (const tag of resolvedConfig.target) {
|
|
3532
|
-
await this.#storeService.
|
|
3505
|
+
await this.#storeService.install(tag, this.#abortController.signal);
|
|
3533
3506
|
}
|
|
3534
3507
|
return;
|
|
3535
3508
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tstyche",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"description": "The Essential Type Testing Tool.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -21,23 +21,24 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"import": "./build/index.js",
|
|
24
|
-
"require": "./build/index
|
|
24
|
+
"require": "./build/index.cjs"
|
|
25
25
|
},
|
|
26
26
|
"./package.json": "./package.json",
|
|
27
27
|
"./tstyche": "./build/tstyche.js"
|
|
28
28
|
},
|
|
29
|
-
"main": "./build/index
|
|
30
|
-
"types": "./build/index
|
|
31
|
-
"bin": "build/bin.js",
|
|
29
|
+
"main": "./build/index.js",
|
|
30
|
+
"types": "./build/index.d.ts",
|
|
31
|
+
"bin": "./build/bin.js",
|
|
32
32
|
"files": [
|
|
33
|
-
"build/*"
|
|
34
|
-
"lib/*.json"
|
|
33
|
+
"build/*"
|
|
35
34
|
],
|
|
36
35
|
"scripts": {
|
|
37
36
|
"build": "rollup --config rollup.config.js",
|
|
38
37
|
"build:watch": "yarn build --sourcemap --watch",
|
|
39
38
|
"clean": "rm -rf build",
|
|
40
|
-
"generate": "
|
|
39
|
+
"generate": "yarn generate:schema && yarn generate:types",
|
|
40
|
+
"generate:schema": "node scripts/generate-schema.js",
|
|
41
|
+
"generate:types": "node scripts/generate-types.js",
|
|
41
42
|
"lint": "yarn lint:cspell && yarn lint:eslint && yarn lint:prettier",
|
|
42
43
|
"lint:cspell": "cspell --cache --config cspell.config.json --quiet",
|
|
43
44
|
"lint:eslint": "yarn lint:eslint:md && yarn lint:eslint:ts",
|
|
@@ -56,13 +57,13 @@
|
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@jest/globals": "29.7.0",
|
|
58
59
|
"@rollup/plugin-typescript": "11.1.5",
|
|
59
|
-
"@types/node": "20.9.
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
61
|
-
"@typescript-eslint/parser": "6.
|
|
60
|
+
"@types/node": "20.9.5",
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "6.12.0",
|
|
62
|
+
"@typescript-eslint/parser": "6.12.0",
|
|
62
63
|
"ajv": "8.12.0",
|
|
63
64
|
"c8": "8.0.1",
|
|
64
65
|
"cspell": "8.0.0",
|
|
65
|
-
"eslint": "8.
|
|
66
|
+
"eslint": "8.54.0",
|
|
66
67
|
"eslint-config-prettier": "9.0.0",
|
|
67
68
|
"eslint-import-resolver-typescript": "3.6.1",
|
|
68
69
|
"eslint-plugin-import": "2.29.0",
|
|
@@ -74,14 +75,13 @@
|
|
|
74
75
|
"jest": "29.7.0",
|
|
75
76
|
"jest-serializer-ansi-escapes": "2.0.1",
|
|
76
77
|
"magic-string": "0.30.5",
|
|
77
|
-
"prettier": "3.0
|
|
78
|
-
"rollup": "4.
|
|
78
|
+
"prettier": "3.1.0",
|
|
79
|
+
"rollup": "4.5.2",
|
|
79
80
|
"rollup-plugin-dts": "6.1.0",
|
|
80
81
|
"rollup-plugin-tsconfig-paths": "1.5.2",
|
|
81
82
|
"ts-node": "10.9.1",
|
|
82
83
|
"tslib": "2.6.2",
|
|
83
|
-
"typescript": "5.2.2"
|
|
84
|
-
"wireit": "0.14.1"
|
|
84
|
+
"typescript": "5.2.2"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"typescript": "4.x || 5.x"
|
|
@@ -91,37 +91,8 @@
|
|
|
91
91
|
"optional": true
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
|
-
"packageManager": "yarn@4.0.
|
|
94
|
+
"packageManager": "yarn@4.0.2",
|
|
95
95
|
"engines": {
|
|
96
|
-
"node": "^
|
|
97
|
-
},
|
|
98
|
-
"wireit": {
|
|
99
|
-
"generate": {
|
|
100
|
-
"dependencies": [
|
|
101
|
-
"generate:schema",
|
|
102
|
-
"generate:types"
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
"generate:schema": {
|
|
106
|
-
"command": "node scripts/generate-schema.js",
|
|
107
|
-
"files": [
|
|
108
|
-
"./build",
|
|
109
|
-
"./scripts/generate-schema.js"
|
|
110
|
-
],
|
|
111
|
-
"output": [
|
|
112
|
-
"./lib/schema.json"
|
|
113
|
-
]
|
|
114
|
-
},
|
|
115
|
-
"generate:types": {
|
|
116
|
-
"command": "node scripts/generate-types.js",
|
|
117
|
-
"files": [
|
|
118
|
-
"./build",
|
|
119
|
-
"./scripts/generate-types.js"
|
|
120
|
-
],
|
|
121
|
-
"output": [
|
|
122
|
-
"./lib/CommandLineOptions.ts",
|
|
123
|
-
"./lib/ConfigFileOptions.ts"
|
|
124
|
-
]
|
|
125
|
-
}
|
|
96
|
+
"node": "^18.12 || >=20.x"
|
|
126
97
|
}
|
|
127
|
-
}
|
|
98
|
+
}
|
package/lib/schema.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"definitions": {},
|
|
4
|
-
"properties": {
|
|
5
|
-
"allowNoTestFiles": {
|
|
6
|
-
"default": false,
|
|
7
|
-
"description": "Do not raise an error, if no test files are selected.",
|
|
8
|
-
"type": "boolean"
|
|
9
|
-
},
|
|
10
|
-
"failFast": {
|
|
11
|
-
"default": false,
|
|
12
|
-
"description": "Stop running tests after the first failed assertion.",
|
|
13
|
-
"type": "boolean"
|
|
14
|
-
},
|
|
15
|
-
"rootPath": {
|
|
16
|
-
"default": "./",
|
|
17
|
-
"description": "The path to a directory containing files of a test project.",
|
|
18
|
-
"type": "string"
|
|
19
|
-
},
|
|
20
|
-
"target": {
|
|
21
|
-
"default": [
|
|
22
|
-
"latest"
|
|
23
|
-
],
|
|
24
|
-
"description": "The list of TypeScript versions to be tested on.",
|
|
25
|
-
"items": {
|
|
26
|
-
"pattern": "^([45]\\.[0-9](\\.[0-9])?)|beta|latest|next|rc$",
|
|
27
|
-
"type": "string"
|
|
28
|
-
},
|
|
29
|
-
"type": "array",
|
|
30
|
-
"uniqueItems": true
|
|
31
|
-
},
|
|
32
|
-
"testFileMatch": {
|
|
33
|
-
"default": [
|
|
34
|
-
"**/*.tst.*",
|
|
35
|
-
"**/__typetests__/*.test.*",
|
|
36
|
-
"**/typetests/*.test.*"
|
|
37
|
-
],
|
|
38
|
-
"description": "The list of glob patterns matching the test files.",
|
|
39
|
-
"items": {
|
|
40
|
-
"type": "string"
|
|
41
|
-
},
|
|
42
|
-
"type": "array",
|
|
43
|
-
"uniqueItems": true
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
"type": "object"
|
|
47
|
-
}
|