@ark/attest 0.45.10 → 0.46.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.
- package/README.md +1 -1
- package/out/assert/assertions.js +1 -1
- package/out/cache/snapshots.js +2 -2
- package/out/cache/ts.js +6 -6
- package/out/cache/utils.js +2 -2
- package/out/cli/cli.js +1 -1
- package/out/cli/precache.js +1 -1
- package/out/cli/shared.d.ts +1 -1
- package/out/cli/shared.js +1 -1
- package/out/cli/stats.js +1 -1
- package/out/cli/trace.js +21 -17
- package/out/config.js +2 -2
- package/out/tsVersioning.js +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -298,7 +298,7 @@ If you'd like to fail in CI above a threshold, you can add flags like the follow
|
|
|
298
298
|
|
|
299
299
|
## CLI
|
|
300
300
|
|
|
301
|
-
Attest also includes a
|
|
301
|
+
Attest also includes a built-in `attest` CLI including the following commands:
|
|
302
302
|
|
|
303
303
|
### `stats`
|
|
304
304
|
|
package/out/assert/assertions.js
CHANGED
|
@@ -67,7 +67,7 @@ Actual: ${serializedActual}`,
|
|
|
67
67
|
const serializedExpected = printable(expected);
|
|
68
68
|
const serializedActual = printable(actual);
|
|
69
69
|
throw new assert.AssertionError({
|
|
70
|
-
message: `Assertion including at least one function or object was not between reference
|
|
70
|
+
message: `Assertion including at least one function or object was not between reference equal items
|
|
71
71
|
Expected: ${serializedExpected}
|
|
72
72
|
Actual: ${serializedActual}`,
|
|
73
73
|
expected: serializedExpected,
|
package/out/cache/snapshots.js
CHANGED
|
@@ -89,8 +89,8 @@ const snapshotArgsToQueuedUpdate = ({ position, serializedValue, snapFunctionNam
|
|
|
89
89
|
"`"
|
|
90
90
|
: JSON.stringify(serializedValue);
|
|
91
91
|
newArgText = newArgText
|
|
92
|
-
.
|
|
93
|
-
.
|
|
92
|
+
.replaceAll(/"\$ark.bigint-(-?\d+)"/g, "$1n")
|
|
93
|
+
.replaceAll(/"\$ark.undefined"/g, "undefined");
|
|
94
94
|
return {
|
|
95
95
|
position,
|
|
96
96
|
snapCall,
|
package/out/cache/ts.js
CHANGED
|
@@ -20,7 +20,7 @@ export class TsServer {
|
|
|
20
20
|
this.tsConfigInfo = tsConfigInfo ?? getTsConfigInfoOrThrow();
|
|
21
21
|
const tsLibPaths = getTsLibFiles(this.tsConfigInfo.parsed.options);
|
|
22
22
|
// TS represents windows paths as `C:/Users/ssalb/...`
|
|
23
|
-
const normalizedCwd = fromCwd().replaceAll(
|
|
23
|
+
const normalizedCwd = fromCwd().replaceAll("\\", "/");
|
|
24
24
|
this.rootFiles = this.tsConfigInfo.parsed.fileNames.filter(path => {
|
|
25
25
|
if (!path.startsWith(normalizedCwd))
|
|
26
26
|
return;
|
|
@@ -35,7 +35,7 @@ export class TsServer {
|
|
|
35
35
|
TsServer._instance = this;
|
|
36
36
|
}
|
|
37
37
|
getSourceFileOrThrow(path) {
|
|
38
|
-
const tsPath = path.replaceAll(
|
|
38
|
+
const tsPath = path.replaceAll("\\", "/");
|
|
39
39
|
const file = this.virtualEnv.getSourceFile(tsPath);
|
|
40
40
|
if (!file) {
|
|
41
41
|
throwInternalError(`TypeScript was unable to resolve expected file at ${path}.\n
|
|
@@ -129,10 +129,10 @@ export const getStringifiableType = (node) => {
|
|
|
129
129
|
let stringified = typeChecker.typeToString(nodeType);
|
|
130
130
|
if (stringified.includes("...")) {
|
|
131
131
|
const nonTruncated = typeChecker.typeToString(nodeType, undefined, ts.TypeFormatFlags.NoTruncation);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
stringified =
|
|
133
|
+
nonTruncated.includes(" any") && !stringified.includes(" any") ?
|
|
134
|
+
nonTruncated.replaceAll(" any", " cyclic")
|
|
135
|
+
: nonTruncated;
|
|
136
136
|
}
|
|
137
137
|
return Object.assign(nodeType, {
|
|
138
138
|
toString: () => stringified,
|
package/out/cache/utils.js
CHANGED
|
@@ -55,7 +55,7 @@ ${enclosingFunction.ancestor.getText()}`);
|
|
|
55
55
|
};
|
|
56
56
|
export const getCallExpressionsByName = (startNode, names, isSnapCall = false) => {
|
|
57
57
|
const calls = [];
|
|
58
|
-
getDescendants(startNode)
|
|
58
|
+
for (const descendant of getDescendants(startNode)) {
|
|
59
59
|
if (ts.isCallExpression(descendant)) {
|
|
60
60
|
if (names.includes(descendant.expression.getText()) || !names.length)
|
|
61
61
|
calls.push(descendant);
|
|
@@ -66,7 +66,7 @@ export const getCallExpressionsByName = (startNode, names, isSnapCall = false) =
|
|
|
66
66
|
calls.push(descendant);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
return calls;
|
|
71
71
|
};
|
|
72
72
|
const instantiationsByPath = {};
|
package/out/cli/cli.js
CHANGED
package/out/cli/precache.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ensureDir } from "@ark/fs";
|
|
2
|
-
import { join } from "path";
|
|
2
|
+
import { join } from "node:path";
|
|
3
3
|
import { writeAssertionData } from "../fixtures.js";
|
|
4
4
|
export const precache = (args) => {
|
|
5
5
|
const cacheFileToWrite = args[0] ?? join(ensureDir(".attest"), "typescript.json");
|
package/out/cli/shared.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const baseDiagnosticTscCmd = "
|
|
1
|
+
export declare const baseDiagnosticTscCmd = "npm exec -- tsc --noEmit --extendedDiagnostics --incremental false --tsBuildInfoFile null";
|
package/out/cli/shared.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const baseDiagnosticTscCmd = "
|
|
1
|
+
export const baseDiagnosticTscCmd = "npm exec -- tsc --noEmit --extendedDiagnostics --incremental false --tsBuildInfoFile null";
|
package/out/cli/stats.js
CHANGED
package/out/cli/trace.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ensureDir, getShellOutput, readJson, writeFile } from "@ark/fs";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { basename, join, relative } from "node:path";
|
|
4
|
-
import { resolve } from "path";
|
|
3
|
+
import { basename, join, relative, resolve } from "node:path";
|
|
5
4
|
import ts from "typescript";
|
|
6
5
|
import { TsServer, getDescendants, getStringifiableType, nearestBoundingCallExpression } from "../cache/ts.js";
|
|
7
6
|
import { getConfig } from "../config.js";
|
|
@@ -201,11 +200,11 @@ const buildCallTree = (ctx) => {
|
|
|
201
200
|
// Sort by start time for nesting analysis
|
|
202
201
|
ctx.callRanges.sort((a, b) => a.startTime - b.startTime);
|
|
203
202
|
const activeCallStack = [];
|
|
204
|
-
ctx.callRanges
|
|
203
|
+
for (const call of ctx.callRanges) {
|
|
205
204
|
popFinishedCalls(call, activeCallStack);
|
|
206
205
|
assignToParentOrRoot(call, activeCallStack, ctx);
|
|
207
206
|
activeCallStack.push(call);
|
|
208
|
-
}
|
|
207
|
+
}
|
|
209
208
|
};
|
|
210
209
|
const popFinishedCalls = (call, activeCallStack) => {
|
|
211
210
|
while (activeCallStack.length > 0 &&
|
|
@@ -251,7 +250,8 @@ const collectFunctionStats = (call, ctx) => {
|
|
|
251
250
|
stats.selfTime += call.selfTime;
|
|
252
251
|
stats.count++;
|
|
253
252
|
// Process children
|
|
254
|
-
|
|
253
|
+
for (const child of call.children)
|
|
254
|
+
collectFunctionStats(child, ctx);
|
|
255
255
|
};
|
|
256
256
|
const addCallSiteToStats = (call, stats) => {
|
|
257
257
|
const [filePath, positionRange] = call.callSite.split(":");
|
|
@@ -265,9 +265,8 @@ const addCallSiteToStats = (call, stats) => {
|
|
|
265
265
|
};
|
|
266
266
|
const sortAndRankFunctions = (ctx) => {
|
|
267
267
|
// Sort each function's call sites by self-time
|
|
268
|
-
Object.values(ctx.functionStats)
|
|
268
|
+
for (const stats of Object.values(ctx.functionStats))
|
|
269
269
|
stats.detailedCallSites.sort((a, b) => b.selfTime - a.selfTime);
|
|
270
|
-
});
|
|
271
270
|
// Sort functions by self-time
|
|
272
271
|
ctx.allFunctions = Object.values(ctx.functionStats).sort((a, b) => b.selfTime - a.selfTime);
|
|
273
272
|
};
|
|
@@ -277,14 +276,17 @@ const analyzeTypeInstantiations = (traceDir) => {
|
|
|
277
276
|
// Filter entries with duration information
|
|
278
277
|
filterDurationEntries(ctx);
|
|
279
278
|
// Process each duration entry to extract call ranges
|
|
280
|
-
|
|
279
|
+
for (const entry of ctx.durationEntries)
|
|
280
|
+
processDurationEntry(entry, ctx);
|
|
281
281
|
// Build call tree from ranges
|
|
282
282
|
buildCallTree(ctx);
|
|
283
283
|
// Calculate self-time for each call
|
|
284
|
-
ctx.rootCalls
|
|
284
|
+
for (const root of ctx.rootCalls)
|
|
285
|
+
calculateSelfTimes(root);
|
|
285
286
|
// Collect statistics by view type
|
|
286
287
|
const ungroupedStats = collectUngroupedStats(ctx);
|
|
287
|
-
|
|
288
|
+
for (const call of ctx.rootCalls)
|
|
289
|
+
collectFunctionStats(call, ctx);
|
|
288
290
|
// Sort and rank functions
|
|
289
291
|
sortAndRankFunctions(ctx);
|
|
290
292
|
// Display summaries to console
|
|
@@ -346,9 +348,11 @@ const collectUngroupedStats = (ctx) => {
|
|
|
346
348
|
duration: call.duration,
|
|
347
349
|
selfTime: call.selfTime
|
|
348
350
|
});
|
|
349
|
-
call.children
|
|
351
|
+
for (const child of call.children)
|
|
352
|
+
flattenCallTree(child);
|
|
350
353
|
};
|
|
351
|
-
ctx.rootCalls
|
|
354
|
+
for (const root of ctx.rootCalls)
|
|
355
|
+
flattenCallTree(root);
|
|
352
356
|
// Sort by self time in descending order
|
|
353
357
|
return ungroupedStats.sort((a, b) => b.selfTime - a.selfTime);
|
|
354
358
|
};
|
|
@@ -358,12 +362,12 @@ const collectUngroupedStats = (ctx) => {
|
|
|
358
362
|
const displayIndividualSummary = (stats) => {
|
|
359
363
|
displayTableHeader(["Rank", "Function Name", "Self (ms)", "Location"]);
|
|
360
364
|
const top20 = stats.slice(0, 20);
|
|
361
|
-
top20.
|
|
365
|
+
for (const [index, stat] of top20.entries()) {
|
|
362
366
|
const typeNameFormatted = formatTypeName(stat.functionName, 20);
|
|
363
367
|
const selfTimeMs = (stat.selfTime / 1000).toFixed(2).padStart(15);
|
|
364
368
|
const location = formatLocation(stat.callSite);
|
|
365
369
|
outputCapture.write(`${(index + 1).toString().padStart(4)} | ${typeNameFormatted} | ${selfTimeMs} | ${location}`);
|
|
366
|
-
}
|
|
370
|
+
}
|
|
367
371
|
};
|
|
368
372
|
/**
|
|
369
373
|
* Display a summary table header with aligned columns
|
|
@@ -398,7 +402,7 @@ const displayGroupedSummary = (functions) => {
|
|
|
398
402
|
"Calls",
|
|
399
403
|
"Top Usage"
|
|
400
404
|
]);
|
|
401
|
-
functions.slice(0, 20).
|
|
405
|
+
for (const [index, stats] of functions.slice(0, 20).entries()) {
|
|
402
406
|
const typeNameFormatted = formatTypeName(stats.functionName, 20);
|
|
403
407
|
const totalTimeMs = (stats.selfTime / 1000).toFixed(2).padStart(15);
|
|
404
408
|
const avgTimeMs = (stats.selfTime / stats.count / 1000)
|
|
@@ -415,7 +419,7 @@ const displayGroupedSummary = (functions) => {
|
|
|
415
419
|
const topUsageTime = (topUsage.selfTime / 1000).toFixed(2) + "ms";
|
|
416
420
|
const topUsageLocation = formatLocation(`${topUsage.path}:${topUsage.pos}-${topUsage.end}`);
|
|
417
421
|
outputCapture.write(`${(index + 1).toString().padStart(4)} | ${typeNameFormatted} | ${totalTimeMs} | ${avgTimeMs} | ${calls} | ${topUsageLocation} (${topUsageTime})`);
|
|
418
|
-
}
|
|
422
|
+
}
|
|
419
423
|
};
|
|
420
424
|
/**
|
|
421
425
|
* Format a type name for display, ensuring the most identifiable parts are preserved
|
|
@@ -515,7 +519,7 @@ const escapeForCsv = (value) => {
|
|
|
515
519
|
if (value.includes(",") || value.includes('"') || value.includes("\n")) {
|
|
516
520
|
// If the value contains commas, double quotes, or newlines, wrap it in quotes
|
|
517
521
|
// and escape any double quotes by doubling them
|
|
518
|
-
return `"${value.
|
|
522
|
+
return `"${value.replaceAll('"', '""')}"`;
|
|
519
523
|
}
|
|
520
524
|
return value;
|
|
521
525
|
};
|
package/out/config.js
CHANGED
|
@@ -52,7 +52,7 @@ const getParamValue = (param) => {
|
|
|
52
52
|
};
|
|
53
53
|
export const attestEnvPrefix = "ATTEST_";
|
|
54
54
|
const addEnvConfig = (config) => {
|
|
55
|
-
Object.entries(process.env)
|
|
55
|
+
for (const [k, v] of Object.entries(process.env)) {
|
|
56
56
|
if (k.startsWith(attestEnvPrefix)) {
|
|
57
57
|
const optionName = k.slice(attestEnvPrefix.length);
|
|
58
58
|
if (optionName === "CONFIG")
|
|
@@ -60,7 +60,7 @@ const addEnvConfig = (config) => {
|
|
|
60
60
|
else
|
|
61
61
|
config[optionName] = JSON.parse(v);
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|
|
64
64
|
let k;
|
|
65
65
|
for (k in config) {
|
|
66
66
|
if (config[k] === false)
|
package/out/tsVersioning.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assertPackageRoot, findPackageAncestors, readJson } from "@ark/fs";
|
|
2
|
-
import { existsSync, readdirSync, renameSync, statSync, symlinkSync, unlinkSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
2
|
+
import { existsSync, readdirSync, renameSync, statSync, symlinkSync, unlinkSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
4
|
import ts from "typescript";
|
|
5
5
|
/**
|
|
6
6
|
* Executes a provided function for an installed set of TypeScript versions.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark/attest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "David Blass",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"@typescript/analyze-trace": "0.10.1",
|
|
37
37
|
"@typescript/vfs": "1.6.1",
|
|
38
38
|
"prettier": "3.5.3",
|
|
39
|
-
"@ark/
|
|
40
|
-
"
|
|
41
|
-
"
|
|
39
|
+
"@ark/util": "0.46.0",
|
|
40
|
+
"arktype": "2.1.20",
|
|
41
|
+
"@ark/fs": "0.46.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"typescript": "5.8.2"
|