@elench/testkit 0.1.64 → 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.
Files changed (74) hide show
  1. package/lib/coverage/evidence.mjs +15 -3
  2. package/lib/coverage/evidence.test.mjs +13 -4
  3. package/lib/coverage/graph-builder.mjs +23 -24
  4. package/lib/coverage/next-ir-to-graph.mjs +240 -0
  5. package/node_modules/@elench/next-analysis/package.json +14 -0
  6. package/node_modules/@elench/next-analysis/src/api-routes.mjs +81 -0
  7. package/node_modules/@elench/next-analysis/src/api-routes.test.mjs +22 -0
  8. package/node_modules/@elench/next-analysis/src/app-root.mjs +7 -0
  9. package/node_modules/@elench/next-analysis/src/backend-links.mjs +31 -0
  10. package/node_modules/@elench/next-analysis/src/index.mjs +21 -0
  11. package/node_modules/@elench/next-analysis/src/pages.mjs +68 -0
  12. package/node_modules/@elench/next-analysis/src/project.mjs +94 -0
  13. package/node_modules/@elench/next-analysis/src/project.test.mjs +35 -0
  14. package/node_modules/@elench/next-analysis/src/route-tree.mjs +621 -0
  15. package/node_modules/@elench/next-analysis/src/routes.mjs +41 -0
  16. package/node_modules/@elench/next-analysis/src/routes.test.mjs +25 -0
  17. package/node_modules/@elench/next-analysis/src/server-actions.mjs +53 -0
  18. package/node_modules/@elench/next-analysis/src/server-actions.test.mjs +37 -0
  19. package/node_modules/@elench/next-analysis/src/shared.mjs +209 -0
  20. package/node_modules/@elench/next-analysis/src/swc.mjs +388 -0
  21. package/node_modules/@elench/testkit-bridge/package.json +2 -2
  22. package/node_modules/@elench/testkit-protocol/package.json +1 -1
  23. package/node_modules/@elench/ts-analysis/package.json +1 -1
  24. package/node_modules/@next/routing/README.md +91 -0
  25. package/node_modules/@next/routing/dist/__tests__/captures.test.d.ts +1 -0
  26. package/node_modules/@next/routing/dist/__tests__/conditions.test.d.ts +1 -0
  27. package/node_modules/@next/routing/dist/__tests__/dynamic-after-rewrites.test.d.ts +1 -0
  28. package/node_modules/@next/routing/dist/__tests__/i18n-resolve-routes.test.d.ts +1 -0
  29. package/node_modules/@next/routing/dist/__tests__/i18n.test.d.ts +1 -0
  30. package/node_modules/@next/routing/dist/__tests__/middleware.test.d.ts +1 -0
  31. package/node_modules/@next/routing/dist/__tests__/normalize-next-data.test.d.ts +1 -0
  32. package/node_modules/@next/routing/dist/__tests__/redirects.test.d.ts +1 -0
  33. package/node_modules/@next/routing/dist/__tests__/resolve-routes.test.d.ts +1 -0
  34. package/node_modules/@next/routing/dist/__tests__/rewrites.test.d.ts +1 -0
  35. package/node_modules/@next/routing/dist/destination.d.ts +22 -0
  36. package/node_modules/@next/routing/dist/i18n.d.ts +48 -0
  37. package/node_modules/@next/routing/dist/index.d.ts +5 -0
  38. package/node_modules/@next/routing/dist/index.js +1 -0
  39. package/node_modules/@next/routing/dist/matchers.d.ts +12 -0
  40. package/node_modules/@next/routing/dist/middleware.d.ts +12 -0
  41. package/node_modules/@next/routing/dist/next-data.d.ts +10 -0
  42. package/node_modules/@next/routing/dist/resolve-routes.d.ts +2 -0
  43. package/node_modules/@next/routing/dist/types.d.ts +97 -0
  44. package/node_modules/@next/routing/package.json +39 -0
  45. package/node_modules/@swc/core/README.md +100 -0
  46. package/node_modules/@swc/core/Visitor.d.ts +218 -0
  47. package/node_modules/@swc/core/Visitor.js +1399 -0
  48. package/node_modules/@swc/core/binding.d.ts +59 -0
  49. package/node_modules/@swc/core/binding.js +368 -0
  50. package/node_modules/@swc/core/index.d.ts +120 -0
  51. package/node_modules/@swc/core/index.js +443 -0
  52. package/node_modules/@swc/core/package.json +120 -0
  53. package/node_modules/@swc/core/postinstall.js +148 -0
  54. package/node_modules/@swc/core/spack.d.ts +51 -0
  55. package/node_modules/@swc/core/spack.js +87 -0
  56. package/node_modules/@swc/core/util.d.ts +1 -0
  57. package/node_modules/@swc/core/util.js +104 -0
  58. package/node_modules/@swc/core-linux-x64-gnu/README.md +3 -0
  59. package/node_modules/@swc/core-linux-x64-gnu/package.json +46 -0
  60. package/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node +0 -0
  61. package/node_modules/@swc/counter/CHANGELOG.md +7 -0
  62. package/node_modules/@swc/counter/README.md +7 -0
  63. package/node_modules/@swc/counter/index.js +1 -0
  64. package/node_modules/@swc/counter/package.json +27 -0
  65. package/node_modules/@swc/types/LICENSE +201 -0
  66. package/node_modules/@swc/types/README.md +4 -0
  67. package/node_modules/@swc/types/assumptions.d.ts +92 -0
  68. package/node_modules/@swc/types/assumptions.js +2 -0
  69. package/node_modules/@swc/types/index.d.ts +2049 -0
  70. package/node_modules/@swc/types/index.js +2 -0
  71. package/node_modules/@swc/types/package.json +40 -0
  72. package/package.json +6 -4
  73. package/lib/coverage/next-discovery.mjs +0 -205
  74. package/lib/coverage/next-static-analysis.mjs +0 -1045
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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.64",
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,7 @@
51
51
  "vendor/"
52
52
  ],
53
53
  "bundleDependencies": [
54
+ "@elench/next-analysis",
54
55
  "@elench/ts-analysis",
55
56
  "@elench/testkit-bridge",
56
57
  "@elench/testkit-protocol"
@@ -60,9 +61,10 @@
60
61
  "vitest": "^3.2.4"
61
62
  },
62
63
  "dependencies": {
63
- "@elench/ts-analysis": "0.1.64",
64
- "@elench/testkit-bridge": "0.1.64",
65
- "@elench/testkit-protocol": "0.1.64",
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",
66
68
  "@babel/code-frame": "^7.29.0",
67
69
  "@oclif/core": "^4.10.6",
68
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
- }