@elench/testkit 0.1.63 → 0.1.65
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/lib/coverage/backend-discovery.mjs +6 -30
- package/lib/coverage/evidence.mjs +15 -3
- package/lib/coverage/evidence.test.mjs +13 -4
- package/lib/coverage/fs-walk.mjs +2 -2
- package/lib/coverage/graph-builder.mjs +23 -24
- package/lib/coverage/next-ir-to-graph.mjs +240 -0
- package/node_modules/@elench/next-analysis/package.json +14 -0
- package/node_modules/@elench/next-analysis/src/api-routes.mjs +81 -0
- package/node_modules/@elench/next-analysis/src/api-routes.test.mjs +22 -0
- package/node_modules/@elench/next-analysis/src/app-root.mjs +7 -0
- package/node_modules/@elench/next-analysis/src/backend-links.mjs +31 -0
- package/node_modules/@elench/next-analysis/src/index.mjs +21 -0
- package/node_modules/@elench/next-analysis/src/pages.mjs +68 -0
- package/node_modules/@elench/next-analysis/src/project.mjs +94 -0
- package/node_modules/@elench/next-analysis/src/project.test.mjs +35 -0
- package/node_modules/@elench/next-analysis/src/route-tree.mjs +621 -0
- package/node_modules/@elench/next-analysis/src/routes.mjs +41 -0
- package/node_modules/@elench/next-analysis/src/routes.test.mjs +25 -0
- package/node_modules/@elench/next-analysis/src/server-actions.mjs +53 -0
- package/node_modules/@elench/next-analysis/src/server-actions.test.mjs +37 -0
- package/node_modules/@elench/next-analysis/src/shared.mjs +209 -0
- package/node_modules/@elench/next-analysis/src/swc.mjs +388 -0
- package/node_modules/@elench/testkit-bridge/package.json +2 -2
- package/node_modules/@elench/testkit-protocol/package.json +1 -1
- package/node_modules/@elench/ts-analysis/package.json +10 -0
- package/node_modules/@elench/ts-analysis/src/callables.mjs +135 -0
- package/node_modules/@elench/ts-analysis/src/callables.test.mjs +55 -0
- package/node_modules/@elench/ts-analysis/src/exports.mjs +69 -0
- package/node_modules/@elench/ts-analysis/src/exports.test.mjs +50 -0
- package/node_modules/@elench/ts-analysis/src/index.mjs +14 -0
- package/node_modules/@elench/ts-analysis/src/jsx.mjs +69 -0
- package/node_modules/@elench/ts-analysis/src/jsx.test.mjs +43 -0
- package/node_modules/@elench/ts-analysis/src/project.mjs +100 -0
- package/node_modules/@elench/ts-analysis/src/project.test.mjs +54 -0
- package/node_modules/@elench/ts-analysis/src/requests.mjs +141 -0
- package/node_modules/@elench/ts-analysis/src/requests.test.mjs +35 -0
- package/node_modules/@elench/ts-analysis/src/resolution.mjs +53 -0
- package/node_modules/@elench/ts-analysis/src/shared.mjs +32 -0
- package/node_modules/@elench/ts-analysis/src/syntax.mjs +27 -0
- package/node_modules/@next/routing/README.md +91 -0
- package/node_modules/@next/routing/dist/__tests__/captures.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/conditions.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/dynamic-after-rewrites.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/i18n-resolve-routes.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/i18n.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/middleware.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/normalize-next-data.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/redirects.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/resolve-routes.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/rewrites.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/destination.d.ts +22 -0
- package/node_modules/@next/routing/dist/i18n.d.ts +48 -0
- package/node_modules/@next/routing/dist/index.d.ts +5 -0
- package/node_modules/@next/routing/dist/index.js +1 -0
- package/node_modules/@next/routing/dist/matchers.d.ts +12 -0
- package/node_modules/@next/routing/dist/middleware.d.ts +12 -0
- package/node_modules/@next/routing/dist/next-data.d.ts +10 -0
- package/node_modules/@next/routing/dist/resolve-routes.d.ts +2 -0
- package/node_modules/@next/routing/dist/types.d.ts +97 -0
- package/node_modules/@next/routing/package.json +39 -0
- package/node_modules/@swc/core/README.md +100 -0
- package/node_modules/@swc/core/Visitor.d.ts +218 -0
- package/node_modules/@swc/core/Visitor.js +1399 -0
- package/node_modules/@swc/core/binding.d.ts +59 -0
- package/node_modules/@swc/core/binding.js +368 -0
- package/node_modules/@swc/core/index.d.ts +120 -0
- package/node_modules/@swc/core/index.js +443 -0
- package/node_modules/@swc/core/package.json +120 -0
- package/node_modules/@swc/core/postinstall.js +148 -0
- package/node_modules/@swc/core/spack.d.ts +51 -0
- package/node_modules/@swc/core/spack.js +87 -0
- package/node_modules/@swc/core/util.d.ts +1 -0
- package/node_modules/@swc/core/util.js +104 -0
- package/node_modules/@swc/core-linux-x64-gnu/README.md +3 -0
- package/node_modules/@swc/core-linux-x64-gnu/package.json +46 -0
- package/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node +0 -0
- package/node_modules/@swc/counter/CHANGELOG.md +7 -0
- package/node_modules/@swc/counter/README.md +7 -0
- package/node_modules/@swc/counter/index.js +1 -0
- package/node_modules/@swc/counter/package.json +27 -0
- package/node_modules/@swc/types/LICENSE +201 -0
- package/node_modules/@swc/types/README.md +4 -0
- package/node_modules/@swc/types/assumptions.d.ts +92 -0
- package/node_modules/@swc/types/assumptions.js +2 -0
- package/node_modules/@swc/types/index.d.ts +2049 -0
- package/node_modules/@swc/types/index.js +2 -0
- package/node_modules/@swc/types/package.json +40 -0
- package/package.json +7 -3
- package/lib/coverage/next-discovery.mjs +0 -205
- package/lib/coverage/next-static-analysis.mjs +0 -1047
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@swc/types",
|
|
3
|
+
"version": "0.1.26",
|
|
4
|
+
"description": "Typings for the swc project.",
|
|
5
|
+
"types": "./index.d.ts",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "yarn build"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/swc-project/swc.git",
|
|
14
|
+
"directory": "packages/types"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"registry": "https://registry.npmjs.org/",
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"*.js",
|
|
22
|
+
"*.d.ts"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"swc",
|
|
26
|
+
"types"
|
|
27
|
+
],
|
|
28
|
+
"author": "강동윤 <kdy1997.dev@gmail.com>",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/swc-project/swc/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://swc.rs",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"typescript": "^5.2.2"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@swc/counter": "^0.1.3"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.65",
|
|
4
4
|
"description": "CLI for discovering and running local HTTP, DAL, and Playwright test suites",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -51,6 +51,8 @@
|
|
|
51
51
|
"vendor/"
|
|
52
52
|
],
|
|
53
53
|
"bundleDependencies": [
|
|
54
|
+
"@elench/next-analysis",
|
|
55
|
+
"@elench/ts-analysis",
|
|
54
56
|
"@elench/testkit-bridge",
|
|
55
57
|
"@elench/testkit-protocol"
|
|
56
58
|
],
|
|
@@ -59,8 +61,10 @@
|
|
|
59
61
|
"vitest": "^3.2.4"
|
|
60
62
|
},
|
|
61
63
|
"dependencies": {
|
|
62
|
-
"@elench/
|
|
63
|
-
"@elench/
|
|
64
|
+
"@elench/next-analysis": "0.1.65",
|
|
65
|
+
"@elench/ts-analysis": "0.1.65",
|
|
66
|
+
"@elench/testkit-bridge": "0.1.65",
|
|
67
|
+
"@elench/testkit-protocol": "0.1.65",
|
|
64
68
|
"@babel/code-frame": "^7.29.0",
|
|
65
69
|
"@oclif/core": "^4.10.6",
|
|
66
70
|
"esbuild": "^0.25.11",
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { analyzeNextRouteTree } from "./next-static-analysis.mjs";
|
|
4
|
-
import { extractBackendImports, extractExportedFunctions, extractExportedMethodBodies } from "./backend-discovery.mjs";
|
|
5
|
-
import { resolveImportToSourceFile, walkFiles } from "./fs-walk.mjs";
|
|
6
|
-
import { routeFromApiFile, routeFromAppFile } from "./routing.mjs";
|
|
7
|
-
import {
|
|
8
|
-
dedupeNodes,
|
|
9
|
-
hasWord,
|
|
10
|
-
HTTP_METHODS,
|
|
11
|
-
isServerActionFile,
|
|
12
|
-
normalizePath,
|
|
13
|
-
normalizeRoute,
|
|
14
|
-
pageLabelFromRoute,
|
|
15
|
-
toApiRequestPath,
|
|
16
|
-
} from "./shared.mjs";
|
|
17
|
-
|
|
18
|
-
export function discoverPageViews({ serviceName, serviceRoot, nextAppRoot, exclude = [], resolveImportToSourceFile }) {
|
|
19
|
-
const pageFiles = walkFiles(nextAppRoot, { baseDir: serviceRoot, exclude }).filter(
|
|
20
|
-
(filePath) => filePath.endsWith("/page.tsx") || filePath.endsWith("/page.ts")
|
|
21
|
-
);
|
|
22
|
-
const nodes = [];
|
|
23
|
-
const edges = [];
|
|
24
|
-
const pageEntries = [];
|
|
25
|
-
|
|
26
|
-
for (const absolutePath of pageFiles) {
|
|
27
|
-
const relativePath = normalizePath(path.relative(serviceRoot, absolutePath));
|
|
28
|
-
const route = routeFromAppFile(nextAppRoot, absolutePath);
|
|
29
|
-
const content = fs.readFileSync(absolutePath, "utf8");
|
|
30
|
-
const node = {
|
|
31
|
-
id: `page_view:${serviceName}:${route}`,
|
|
32
|
-
kind: "page_view",
|
|
33
|
-
service: serviceName,
|
|
34
|
-
label: pageLabelFromRoute(route),
|
|
35
|
-
route,
|
|
36
|
-
filePath: relativePath,
|
|
37
|
-
};
|
|
38
|
-
nodes.push(node);
|
|
39
|
-
const routeRootFiles = collectRouteRootFiles(nextAppRoot, absolutePath)
|
|
40
|
-
.map((absoluteRootPath) => ({
|
|
41
|
-
filePath: normalizePath(path.relative(serviceRoot, absoluteRootPath)),
|
|
42
|
-
content: fs.readFileSync(absoluteRootPath, "utf8"),
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
const pageAnalysis = analyzeNextRouteTree({
|
|
46
|
-
serviceName,
|
|
47
|
-
serviceRoot,
|
|
48
|
-
route,
|
|
49
|
-
rootFiles: routeRootFiles,
|
|
50
|
-
readSourceFile: (resolvedPath) => {
|
|
51
|
-
const absoluteResolved = path.join(serviceRoot, resolvedPath);
|
|
52
|
-
return fs.existsSync(absoluteResolved) ? fs.readFileSync(absoluteResolved, "utf8") : null;
|
|
53
|
-
},
|
|
54
|
-
resolveImportPath: (fromFilePath, specifier) => resolveImportToSourceFile(serviceRoot, fromFilePath, specifier),
|
|
55
|
-
isServerActionFile,
|
|
56
|
-
normalizeRoute,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
for (const analysisNode of pageAnalysis.nodes) nodes.push(analysisNode);
|
|
60
|
-
for (const analysisEdge of pageAnalysis.edges) edges.push(analysisEdge);
|
|
61
|
-
|
|
62
|
-
pageEntries.push({
|
|
63
|
-
node,
|
|
64
|
-
route,
|
|
65
|
-
filePath: relativePath,
|
|
66
|
-
requests: pageAnalysis.requests,
|
|
67
|
-
serverActionRefs: pageAnalysis.serverActionRefs,
|
|
68
|
-
surfacesByTargetValue: pageAnalysis.surfacesByTargetValue,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return { nodes, edges, pageEntries };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function collectRouteRootFiles(nextAppRoot, pageAbsolutePath) {
|
|
76
|
-
const rootFiles = [];
|
|
77
|
-
let currentDir = path.dirname(pageAbsolutePath);
|
|
78
|
-
const appRoot = path.resolve(nextAppRoot);
|
|
79
|
-
|
|
80
|
-
while (currentDir.startsWith(appRoot)) {
|
|
81
|
-
const layoutFile = resolveRouteCompanion(currentDir, "layout");
|
|
82
|
-
if (layoutFile) rootFiles.push(layoutFile);
|
|
83
|
-
if (currentDir === appRoot) break;
|
|
84
|
-
currentDir = path.dirname(currentDir);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
rootFiles.reverse();
|
|
88
|
-
rootFiles.push(pageAbsolutePath);
|
|
89
|
-
return [...new Set(rootFiles)];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function resolveRouteCompanion(directoryPath, baseName) {
|
|
93
|
-
const candidates = [
|
|
94
|
-
path.join(directoryPath, `${baseName}.tsx`),
|
|
95
|
-
path.join(directoryPath, `${baseName}.ts`),
|
|
96
|
-
path.join(directoryPath, `${baseName}.jsx`),
|
|
97
|
-
path.join(directoryPath, `${baseName}.js`),
|
|
98
|
-
];
|
|
99
|
-
return candidates.find((candidate) => fs.existsSync(candidate)) || null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function discoverApiRoutes({ serviceName, serviceRoot, nextAppRoot, exclude = [], resolveImportToSourceFile }) {
|
|
103
|
-
const routeFiles = walkFiles(path.join(nextAppRoot, "api"), { baseDir: serviceRoot, exclude }).filter(
|
|
104
|
-
(filePath) => filePath.endsWith("/route.ts") || filePath.endsWith("/route.tsx") || filePath.endsWith("/route.js")
|
|
105
|
-
);
|
|
106
|
-
const nodes = [];
|
|
107
|
-
const edges = [];
|
|
108
|
-
const routeEntries = [];
|
|
109
|
-
|
|
110
|
-
for (const absolutePath of routeFiles) {
|
|
111
|
-
const filePath = normalizePath(path.relative(serviceRoot, absolutePath));
|
|
112
|
-
const route = routeFromApiFile(nextAppRoot, absolutePath);
|
|
113
|
-
const requestPath = toApiRequestPath(route);
|
|
114
|
-
const content = fs.readFileSync(absolutePath, "utf8");
|
|
115
|
-
const methodBodies = extractExportedMethodBodies(content, HTTP_METHODS);
|
|
116
|
-
const backendImports = extractBackendImports({ serviceName, serviceRoot, filePath, content, resolveImportToSourceFile });
|
|
117
|
-
|
|
118
|
-
for (const [method, body] of methodBodies) {
|
|
119
|
-
const node = {
|
|
120
|
-
id: `api_route:${serviceName}:${method}:${requestPath}`,
|
|
121
|
-
kind: "api_route",
|
|
122
|
-
service: serviceName,
|
|
123
|
-
label: `${method} ${requestPath}`,
|
|
124
|
-
route,
|
|
125
|
-
method,
|
|
126
|
-
path: requestPath,
|
|
127
|
-
filePath,
|
|
128
|
-
};
|
|
129
|
-
nodes.push(node);
|
|
130
|
-
|
|
131
|
-
const matchedCapabilities = backendImports.filter((entry) => hasWord(body, entry.importName));
|
|
132
|
-
for (const capability of matchedCapabilities) {
|
|
133
|
-
nodes.push(capability.node);
|
|
134
|
-
edges.push({
|
|
135
|
-
id: `delegates_to:${node.id}:${capability.node.id}`,
|
|
136
|
-
kind: "delegates_to",
|
|
137
|
-
from: node.id,
|
|
138
|
-
to: capability.node.id,
|
|
139
|
-
confidence: "high",
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
routeEntries.push({ node, method, route, requestPath, filePath });
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return { nodes: dedupeNodes(nodes), edges, routeEntries };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export function discoverServerActions({ serviceName, serviceRoot, exclude = [], resolveImportToSourceFile }) {
|
|
151
|
-
const appRoots = [path.join(serviceRoot, "app"), path.join(serviceRoot, "src", "app")].filter((candidate) =>
|
|
152
|
-
fs.existsSync(candidate)
|
|
153
|
-
);
|
|
154
|
-
const nodes = [];
|
|
155
|
-
const edges = [];
|
|
156
|
-
const actionEntries = [];
|
|
157
|
-
|
|
158
|
-
for (const appRoot of appRoots) {
|
|
159
|
-
for (const absolutePath of walkFiles(appRoot, { baseDir: serviceRoot, exclude })) {
|
|
160
|
-
if (!absolutePath.endsWith(".ts") && !absolutePath.endsWith(".tsx")) continue;
|
|
161
|
-
const content = fs.readFileSync(absolutePath, "utf8");
|
|
162
|
-
if (!isServerActionFile(content)) continue;
|
|
163
|
-
|
|
164
|
-
const relativePath = normalizePath(path.relative(serviceRoot, absolutePath));
|
|
165
|
-
const backendImports = extractBackendImports({
|
|
166
|
-
serviceName,
|
|
167
|
-
serviceRoot,
|
|
168
|
-
filePath: relativePath,
|
|
169
|
-
content,
|
|
170
|
-
resolveImportToSourceFile,
|
|
171
|
-
});
|
|
172
|
-
const exportedFunctions = extractExportedFunctions(content);
|
|
173
|
-
|
|
174
|
-
for (const exported of exportedFunctions) {
|
|
175
|
-
const node = {
|
|
176
|
-
id: `server_action:${serviceName}:${relativePath}#${exported.name}`,
|
|
177
|
-
kind: "server_action",
|
|
178
|
-
service: serviceName,
|
|
179
|
-
label: exported.name,
|
|
180
|
-
filePath: relativePath,
|
|
181
|
-
};
|
|
182
|
-
nodes.push(node);
|
|
183
|
-
actionEntries.push({
|
|
184
|
-
node,
|
|
185
|
-
exportName: exported.name,
|
|
186
|
-
sourceFile: relativePath,
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const matchedCapabilities = backendImports.filter((entry) => hasWord(exported.body, entry.importName));
|
|
190
|
-
for (const capability of matchedCapabilities) {
|
|
191
|
-
nodes.push(capability.node);
|
|
192
|
-
edges.push({
|
|
193
|
-
id: `delegates_to:${node.id}:${capability.node.id}`,
|
|
194
|
-
kind: "delegates_to",
|
|
195
|
-
from: node.id,
|
|
196
|
-
to: capability.node.id,
|
|
197
|
-
confidence: "high",
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return { nodes: dedupeNodes(nodes), edges, actionEntries };
|
|
205
|
-
}
|