@ark/attest 0.17.0 → 0.18.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 +1 -1
- package/out/cli/trace.js +6 -2
- package/out/config.js +1 -1
- package/out/fixtures.js +1 -1
- package/out/tsVersioning.d.ts +3 -4
- package/out/tsVersioning.js +26 -17
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ export const mochaGlobalTeardown = teardown
|
|
|
66
66
|
|
|
67
67
|
You should also add `.attest` to your repository's `.gitignore` file.
|
|
68
68
|
|
|
69
|
-
Bun support is currently pending
|
|
69
|
+
Bun support is currently pending [them supporting @prettier/sync for type formatting](https://github.com/oven-sh/bun/issues/10768). If this is a problem for you, please 👍 that issue so they prioritize it!
|
|
70
70
|
|
|
71
71
|
## Assertions
|
|
72
72
|
|
package/out/cli/trace.js
CHANGED
|
@@ -4,8 +4,12 @@ import { resolve } from "path";
|
|
|
4
4
|
import { getConfig } from "../config.js";
|
|
5
5
|
import { baseDiagnosticTscCmd } from "./shared.js";
|
|
6
6
|
export const trace = async (args) => {
|
|
7
|
-
const packageDir = args[0] ?? process.cwd();
|
|
7
|
+
const packageDir = resolve(args[0] ?? process.cwd());
|
|
8
8
|
const config = getConfig();
|
|
9
|
+
if (!config.tsconfig) {
|
|
10
|
+
console.error(`attest trace must be run from a directory with a tsconfig.json file`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
9
13
|
const traceDir = resolve(config.cacheDir, "trace");
|
|
10
14
|
ensureDir(traceDir);
|
|
11
15
|
try {
|
|
@@ -15,7 +19,7 @@ export const trace = async (args) => {
|
|
|
15
19
|
// the .attest/trace directory will contain a trace.json file and a types.json file.
|
|
16
20
|
// the trace.json file can be viewed via a tool like https://ui.perfetto.dev/
|
|
17
21
|
// the types.json file can be used to associate IDs from the trace file with type aliases
|
|
18
|
-
execSync(`${baseDiagnosticTscCmd} --generateTrace ${traceDir}`, {
|
|
22
|
+
execSync(`${baseDiagnosticTscCmd} --project ${config.tsconfig} --generateTrace ${traceDir}`, {
|
|
19
23
|
cwd: packageDir,
|
|
20
24
|
stdio: "inherit"
|
|
21
25
|
});
|
package/out/config.js
CHANGED
|
@@ -10,7 +10,7 @@ export const getDefaultAttestConfig = () => ({
|
|
|
10
10
|
updateSnapshots: false,
|
|
11
11
|
skipTypes: false,
|
|
12
12
|
skipInlineInstantiations: false,
|
|
13
|
-
tsVersions: "
|
|
13
|
+
tsVersions: "default",
|
|
14
14
|
benchPercentThreshold: 20,
|
|
15
15
|
benchErrorOnThresholdExceeded: true,
|
|
16
16
|
filter: undefined,
|
package/out/fixtures.js
CHANGED
|
@@ -16,7 +16,7 @@ export const setup = (options) => {
|
|
|
16
16
|
if (config.skipTypes)
|
|
17
17
|
return teardown;
|
|
18
18
|
if (config.tsVersions.length === 1 &&
|
|
19
|
-
config.tsVersions[0].alias === "
|
|
19
|
+
config.tsVersions[0].alias === "default")
|
|
20
20
|
writeAssertionData(config.defaultAssertionCachePath);
|
|
21
21
|
else {
|
|
22
22
|
forTypeScriptVersions(config.tsVersions, version => {
|
package/out/tsVersioning.d.ts
CHANGED
|
@@ -21,8 +21,7 @@ export type TsVersionData = {
|
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* Find and return the paths of all installed TypeScript versions, including the
|
|
24
|
-
*
|
|
25
|
-
* "typescript-".
|
|
24
|
+
* all dependencies beginning with "typescript" or "@ark/attest-ts-".
|
|
26
25
|
*
|
|
27
26
|
* Starts checking from the current directory and looks for node_modules in parent
|
|
28
27
|
* directories up to the file system root.
|
|
@@ -30,10 +29,10 @@ export type TsVersionData = {
|
|
|
30
29
|
* Alternate versions can be installed using a package.json dependency like:
|
|
31
30
|
*
|
|
32
31
|
* ```json
|
|
33
|
-
* "
|
|
32
|
+
* "@ark/attest-ts-min": "npm:typescript@5.1.6"
|
|
34
33
|
* ```
|
|
35
34
|
* @returns {TsVersionData[]} Each version mapped to data, e.g.:
|
|
36
|
-
* {alias: "
|
|
35
|
+
* {alias: "@ark/attest-ts-min", version: "5.1.6", path: "/home/ssalb/arktype/node_modules/@ark/attest-ts-min" } *
|
|
37
36
|
*
|
|
38
37
|
* @throws {Error} If a TypeScript version specified in package.json is not
|
|
39
38
|
* installed at the expected location in node_modules.
|
package/out/tsVersioning.js
CHANGED
|
@@ -28,10 +28,6 @@ export const forTypeScriptVersions = (versions, fn) => {
|
|
|
28
28
|
try {
|
|
29
29
|
for (const version of versions) {
|
|
30
30
|
const targetPath = version.path === tsPrimaryPath ? tsTemporaryPath : version.path;
|
|
31
|
-
const tsPackageJson = readJson(join(targetPath, "package.json"));
|
|
32
|
-
if (tsPackageJson.name !== "typescript") {
|
|
33
|
-
throw new Error(`Expected to find a TypeScript version ${version.version} at ${version.path}`);
|
|
34
|
-
}
|
|
35
31
|
console.log(`⛵ Switching to TypeScript version ${version.alias} (${version.version})...`);
|
|
36
32
|
try {
|
|
37
33
|
if (existsSync(tsPrimaryPath))
|
|
@@ -61,10 +57,20 @@ export const forTypeScriptVersions = (versions, fn) => {
|
|
|
61
57
|
}
|
|
62
58
|
}
|
|
63
59
|
};
|
|
60
|
+
const possibleTsVersionPrefix = "typescript-";
|
|
61
|
+
const strictTsVersionPrefix = "@ark/attest-ts-";
|
|
62
|
+
const parseInstalledTsAlias = (installedAlias) => {
|
|
63
|
+
if (installedAlias === "typescript")
|
|
64
|
+
return "default";
|
|
65
|
+
if (installedAlias.startsWith(possibleTsVersionPrefix))
|
|
66
|
+
return installedAlias.slice(possibleTsVersionPrefix.length);
|
|
67
|
+
if (installedAlias.startsWith(strictTsVersionPrefix))
|
|
68
|
+
return installedAlias.slice(strictTsVersionPrefix.length);
|
|
69
|
+
return null;
|
|
70
|
+
};
|
|
64
71
|
/**
|
|
65
72
|
* Find and return the paths of all installed TypeScript versions, including the
|
|
66
|
-
*
|
|
67
|
-
* "typescript-".
|
|
73
|
+
* all dependencies beginning with "typescript" or "@ark/attest-ts-".
|
|
68
74
|
*
|
|
69
75
|
* Starts checking from the current directory and looks for node_modules in parent
|
|
70
76
|
* directories up to the file system root.
|
|
@@ -72,10 +78,10 @@ export const forTypeScriptVersions = (versions, fn) => {
|
|
|
72
78
|
* Alternate versions can be installed using a package.json dependency like:
|
|
73
79
|
*
|
|
74
80
|
* ```json
|
|
75
|
-
* "
|
|
81
|
+
* "@ark/attest-ts-min": "npm:typescript@5.1.6"
|
|
76
82
|
* ```
|
|
77
83
|
* @returns {TsVersionData[]} Each version mapped to data, e.g.:
|
|
78
|
-
* {alias: "
|
|
84
|
+
* {alias: "@ark/attest-ts-min", version: "5.1.6", path: "/home/ssalb/arktype/node_modules/@ark/attest-ts-min" } *
|
|
79
85
|
*
|
|
80
86
|
* @throws {Error} If a TypeScript version specified in package.json is not
|
|
81
87
|
* installed at the expected location in node_modules.
|
|
@@ -95,20 +101,23 @@ export const findAttestTypeScriptVersions = () => {
|
|
|
95
101
|
...packageJson.dependencies,
|
|
96
102
|
...packageJson.devDependencies
|
|
97
103
|
};
|
|
98
|
-
for (const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (alias.includes("eslint", 10))
|
|
104
|
+
for (const installedAlias in dependencies) {
|
|
105
|
+
const alias = parseInstalledTsAlias(installedAlias);
|
|
106
|
+
if (alias === null)
|
|
102
107
|
continue;
|
|
103
|
-
const path = join(nodeModulesPath,
|
|
108
|
+
const path = join(nodeModulesPath, installedAlias);
|
|
104
109
|
if (!existsSync(path)) {
|
|
105
|
-
throw Error(`TypeScript version ${
|
|
110
|
+
throw Error(`TypeScript version ${installedAlias} specified in ${packageJsonPath} must be installed at ${path} `);
|
|
111
|
+
}
|
|
112
|
+
const typescriptJson = readJson(join(path, "package.json"));
|
|
113
|
+
if (typescriptJson.name !== "typescript") {
|
|
114
|
+
if (installedAlias.startsWith(strictTsVersionPrefix))
|
|
115
|
+
throw new Error(`Package at ${path} should be named "typescript"`);
|
|
116
|
+
continue;
|
|
106
117
|
}
|
|
107
|
-
const version = readJson(join(path, "package.json"))
|
|
108
|
-
.version;
|
|
109
118
|
versions.push({
|
|
110
119
|
alias,
|
|
111
|
-
version,
|
|
120
|
+
version: typescriptJson.version,
|
|
112
121
|
path
|
|
113
122
|
});
|
|
114
123
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark/attest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "David Blass",
|
|
6
6
|
"email": "david@arktype.io",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"@typescript/analyze-trace": "0.10.1",
|
|
36
36
|
"prettier": "3.3.3",
|
|
37
37
|
"@prettier/sync": "0.5.2",
|
|
38
|
-
"arktype": "2.0.0-rc.
|
|
39
|
-
"@ark/fs": "0.
|
|
40
|
-
"@ark/util": "0.
|
|
38
|
+
"arktype": "2.0.0-rc.8",
|
|
39
|
+
"@ark/fs": "0.10.0",
|
|
40
|
+
"@ark/util": "0.10.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"typescript": "5.6.
|
|
43
|
+
"typescript": "5.6.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"typescript": "*"
|