@topogram/cli 0.3.77 → 0.3.78
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/package.json +1 -1
- package/src/import/core/shared/files.js +21 -2
- package/src/import/core/shared.js +2 -1
- package/src/import/enrichers/django-rest.js +4 -4
- package/src/import/enrichers/rails-controllers.js +3 -3
- package/src/import/enrichers/rails-models.js +3 -3
- package/src/import/extractors/api/aspnet-core.js +5 -5
- package/src/import/extractors/api/django-routes.js +5 -5
- package/src/import/extractors/api/express.js +4 -4
- package/src/import/extractors/api/fastify.js +7 -7
- package/src/import/extractors/api/flutter-dio.js +4 -4
- package/src/import/extractors/api/generic-route-fallback.js +2 -2
- package/src/import/extractors/api/graphql-code-first.js +3 -3
- package/src/import/extractors/api/graphql-sdl.js +5 -5
- package/src/import/extractors/api/jaxrs.js +3 -3
- package/src/import/extractors/api/micronaut.js +3 -3
- package/src/import/extractors/api/openapi-code.js +4 -4
- package/src/import/extractors/api/openapi.js +3 -3
- package/src/import/extractors/api/rails-routes.js +3 -3
- package/src/import/extractors/api/react-native-repository.js +3 -3
- package/src/import/extractors/api/retrofit.js +3 -3
- package/src/import/extractors/api/spring-web.js +3 -3
- package/src/import/extractors/api/swift-webapi.js +3 -3
- package/src/import/extractors/api/trpc.js +4 -4
- package/src/import/extractors/cli/generic.js +3 -3
- package/src/import/extractors/db/django-models.js +4 -4
- package/src/import/extractors/db/dotnet-models.js +4 -4
- package/src/import/extractors/db/drizzle.js +9 -7
- package/src/import/extractors/db/ef-core.js +5 -5
- package/src/import/extractors/db/flutter-entities.js +3 -3
- package/src/import/extractors/db/jpa.js +3 -3
- package/src/import/extractors/db/liquibase.js +3 -3
- package/src/import/extractors/db/maintained-seams.js +4 -4
- package/src/import/extractors/db/mybatis-xml.js +4 -4
- package/src/import/extractors/db/prisma.js +3 -3
- package/src/import/extractors/db/rails-schema.js +3 -3
- package/src/import/extractors/db/react-native-entities.js +3 -3
- package/src/import/extractors/db/room.js +5 -5
- package/src/import/extractors/db/snapshot.js +3 -3
- package/src/import/extractors/db/sql.js +3 -3
- package/src/import/extractors/db/swiftdata.js +3 -3
- package/src/import/extractors/ui/android-compose.js +4 -4
- package/src/import/extractors/ui/backend-only.js +3 -3
- package/src/import/extractors/ui/blazor.js +3 -3
- package/src/import/extractors/ui/flutter-screens.js +3 -3
- package/src/import/extractors/ui/maui-xaml.js +4 -4
- package/src/import/extractors/ui/next-pages-router.js +3 -3
- package/src/import/extractors/ui/razor-pages.js +3 -3
- package/src/import/extractors/ui/react-native-screens.js +4 -4
- package/src/import/extractors/ui/swiftui.js +3 -3
- package/src/import/extractors/ui/uikit.js +3 -3
package/package.json
CHANGED
|
@@ -107,7 +107,7 @@ export function classifyImportSourcePath(paths, filePath) {
|
|
|
107
107
|
if (/(^|\/)(\.tmp|tmp|temp|dist|build|coverage|out|generated|docs-generated|snapshots?)(\/|$)/i.test(relativePath)) {
|
|
108
108
|
return "generated_output";
|
|
109
109
|
}
|
|
110
|
-
if (
|
|
110
|
+
if (/^(template|templates|[^/]+-templates|[^/]+_templates)(\/|$)/i.test(relativePath)) {
|
|
111
111
|
return "fixtures";
|
|
112
112
|
}
|
|
113
113
|
if (/(^|\/)(test|tests|__tests__|spec|specs|mocks?)(\/|$)|\.(test|spec)\.(js|jsx|ts|tsx|mjs|cjs)$/i.test(relativePath)) {
|
|
@@ -213,9 +213,10 @@ export function selectPreferredImportFiles(paths, files, kind) {
|
|
|
213
213
|
/**
|
|
214
214
|
* @param {import("./types.d.ts").ImportPaths} paths
|
|
215
215
|
* @param {any} predicate
|
|
216
|
+
* @param {{ primaryOnly?: boolean }} [options]
|
|
216
217
|
* @returns {any}
|
|
217
218
|
*/
|
|
218
|
-
export function findImportFiles(paths, predicate) {
|
|
219
|
+
export function findImportFiles(paths, predicate, options = {}) {
|
|
219
220
|
const files = new Set();
|
|
220
221
|
for (const rootDir of importSearchRoots(paths)) {
|
|
221
222
|
for (const filePath of listFilesRecursive(rootDir, predicate)) {
|
|
@@ -226,8 +227,26 @@ export function findImportFiles(paths, predicate) {
|
|
|
226
227
|
) {
|
|
227
228
|
continue;
|
|
228
229
|
}
|
|
230
|
+
if (options.primaryOnly && !isPrimaryImportSource(paths, filePath)) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
229
233
|
files.add(filePath);
|
|
230
234
|
}
|
|
231
235
|
}
|
|
232
236
|
return [...files].sort();
|
|
233
237
|
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Find files that are eligible to create primary import candidates.
|
|
241
|
+
*
|
|
242
|
+
* Docs, tests, fixture/template roots, generated output, and cache output may
|
|
243
|
+
* still support evidence elsewhere, but candidate-producing extractors should
|
|
244
|
+
* start from this helper so the primary-source rule is one API boundary.
|
|
245
|
+
*
|
|
246
|
+
* @param {import("./types.d.ts").ImportPaths} paths
|
|
247
|
+
* @param {any} predicate
|
|
248
|
+
* @returns {any}
|
|
249
|
+
*/
|
|
250
|
+
export function findPrimaryImportFiles(paths, predicate) {
|
|
251
|
+
return findImportFiles(paths, predicate, { primaryOnly: true });
|
|
252
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { findPrimaryImportFiles, readTextIfExists } from "../core/shared.js";
|
|
4
4
|
|
|
5
5
|
function splitClassBlocks(text) {
|
|
6
6
|
const lines = String(text || "").split(/\r?\n/);
|
|
@@ -51,7 +51,7 @@ function splitClassBlocks(text) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function buildSerializerIndex(paths) {
|
|
54
|
-
const files =
|
|
54
|
+
const files = findPrimaryImportFiles(paths, (filePath) => /\/serializers\.py$/i.test(filePath));
|
|
55
55
|
const index = new Map();
|
|
56
56
|
|
|
57
57
|
for (const filePath of files) {
|
|
@@ -89,7 +89,7 @@ function buildSerializerIndex(paths) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function buildViewIndex(paths) {
|
|
92
|
-
const files =
|
|
92
|
+
const files = findPrimaryImportFiles(paths, (filePath) => /\/views\.py$/i.test(filePath));
|
|
93
93
|
const index = new Map();
|
|
94
94
|
|
|
95
95
|
for (const filePath of files) {
|
|
@@ -182,7 +182,7 @@ export const djangoRestEnricher = {
|
|
|
182
182
|
applies(context, candidates) {
|
|
183
183
|
if ((candidates.capabilities || []).length === 0) return false;
|
|
184
184
|
return (candidates.stacks || []).includes("django") ||
|
|
185
|
-
|
|
185
|
+
findPrimaryImportFiles(context.paths, (filePath) => /\/serializers\.py$/i.test(filePath)).length > 0;
|
|
186
186
|
},
|
|
187
187
|
enrich(context, candidates) {
|
|
188
188
|
const serializerIndex = buildSerializerIndex(context.paths);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { findPrimaryImportFiles, readTextIfExists } from "../core/shared.js";
|
|
4
4
|
|
|
5
5
|
function buildControllerIndex(paths) {
|
|
6
|
-
const files =
|
|
6
|
+
const files = findPrimaryImportFiles(paths, (filePath) => /app\/controllers\/.+_controller\.rb$/i.test(filePath));
|
|
7
7
|
const index = new Map();
|
|
8
8
|
for (const filePath of files) {
|
|
9
9
|
const text = readTextIfExists(filePath) || "";
|
|
@@ -186,7 +186,7 @@ export const railsControllerEnricher = {
|
|
|
186
186
|
applies(context, candidates) {
|
|
187
187
|
if ((candidates.capabilities || []).length === 0) return false;
|
|
188
188
|
return (candidates.stacks || []).includes("rails") ||
|
|
189
|
-
|
|
189
|
+
findPrimaryImportFiles(context.paths, (filePath) => /app\/controllers\/.+_controller\.rb$/i.test(filePath)).length > 0;
|
|
190
190
|
},
|
|
191
191
|
enrich(context, candidates) {
|
|
192
192
|
const controllers = buildControllerIndex(context.paths);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { findPrimaryImportFiles, readTextIfExists } from "../core/shared.js";
|
|
4
4
|
|
|
5
5
|
function modelClassNameForEntity(entityId) {
|
|
6
6
|
const stem = String(entityId || "")
|
|
@@ -13,7 +13,7 @@ function modelClassNameForEntity(entityId) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function buildModelIndex(paths) {
|
|
16
|
-
const modelFiles =
|
|
16
|
+
const modelFiles = findPrimaryImportFiles(paths, (filePath) => /app\/models\/.+\.rb$/i.test(filePath));
|
|
17
17
|
const index = new Map();
|
|
18
18
|
for (const filePath of modelFiles) {
|
|
19
19
|
const text = readTextIfExists(filePath) || "";
|
|
@@ -93,7 +93,7 @@ export const railsModelEnricher = {
|
|
|
93
93
|
track: "db",
|
|
94
94
|
applies(context, candidates) {
|
|
95
95
|
if ((candidates.entities || []).length === 0) return false;
|
|
96
|
-
return
|
|
96
|
+
return findPrimaryImportFiles(context.paths, (filePath) => /app\/models\/.+\.rb$/i.test(filePath)).length > 0;
|
|
97
97
|
},
|
|
98
98
|
enrich(context, candidates) {
|
|
99
99
|
const modelIndex = buildModelIndex(context.paths);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dedupeCandidateRecords,
|
|
3
|
-
|
|
3
|
+
findPrimaryImportFiles,
|
|
4
4
|
inferApiEntityIdFromPath,
|
|
5
5
|
inferRouteCapabilityId,
|
|
6
6
|
makeCandidateRecord,
|
|
@@ -22,7 +22,7 @@ function parsePublicProperties(text) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function buildDotnetFileIndex(paths) {
|
|
25
|
-
const files =
|
|
25
|
+
const files = findPrimaryImportFiles(paths, (filePath) => /\.cs$/i.test(filePath));
|
|
26
26
|
const index = new Map();
|
|
27
27
|
for (const filePath of files) {
|
|
28
28
|
index.set(relativeTo(paths.repoRoot, filePath), readTextIfExists(filePath) || "");
|
|
@@ -239,8 +239,8 @@ export const aspNetCoreExtractor = {
|
|
|
239
239
|
id: "api.aspnet-core",
|
|
240
240
|
track: "api",
|
|
241
241
|
detect(context) {
|
|
242
|
-
const controllerFiles =
|
|
243
|
-
const programFiles =
|
|
242
|
+
const controllerFiles = findPrimaryImportFiles(context.paths, (filePath) => /Controller\.cs$/i.test(filePath));
|
|
243
|
+
const programFiles = findPrimaryImportFiles(context.paths, (filePath) => /Program\.cs$/i.test(filePath));
|
|
244
244
|
const score = controllerFiles.length > 0 && programFiles.some((filePath) => /WebApplication\.CreateBuilder|AddSwaggerGen|AddMvc/.test(readTextIfExists(filePath) || "")) ? 88 : 0;
|
|
245
245
|
return {
|
|
246
246
|
score,
|
|
@@ -248,7 +248,7 @@ export const aspNetCoreExtractor = {
|
|
|
248
248
|
};
|
|
249
249
|
},
|
|
250
250
|
extract(context) {
|
|
251
|
-
const controllerFiles =
|
|
251
|
+
const controllerFiles = findPrimaryImportFiles(context.paths, (filePath) => /Controller\.cs$/i.test(filePath));
|
|
252
252
|
const featureFiles = buildDotnetFileIndex(context.paths).files.map((filePath) => ({ filePath, text: readTextIfExists(filePath) || "" }));
|
|
253
253
|
const findings = [];
|
|
254
254
|
const candidates = { capabilities: [], routes: [], stacks: [] };
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
dedupeCandidateRecords,
|
|
5
|
-
|
|
5
|
+
findPrimaryImportFiles,
|
|
6
6
|
inferApiEntityIdFromPath,
|
|
7
7
|
inferRouteCapabilityId,
|
|
8
8
|
makeCandidateRecord,
|
|
@@ -90,7 +90,7 @@ function permissionAuthHint(permissionText, method) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
function buildViewIndex(paths) {
|
|
93
|
-
const viewFiles =
|
|
93
|
+
const viewFiles = findPrimaryImportFiles(paths, (filePath) => /\/views\.py$/i.test(filePath));
|
|
94
94
|
const index = new Map();
|
|
95
95
|
|
|
96
96
|
for (const filePath of viewFiles) {
|
|
@@ -250,8 +250,8 @@ export const djangoRoutesExtractor = {
|
|
|
250
250
|
id: "api.django-routes",
|
|
251
251
|
track: "api",
|
|
252
252
|
detect(context) {
|
|
253
|
-
const manageFiles =
|
|
254
|
-
const urlFiles =
|
|
253
|
+
const manageFiles = findPrimaryImportFiles(context.paths, (filePath) => /\/manage\.py$/i.test(filePath));
|
|
254
|
+
const urlFiles = findPrimaryImportFiles(context.paths, (filePath) => /\/urls\.py$/i.test(filePath));
|
|
255
255
|
const score = manageFiles.length > 0 && urlFiles.length > 0 ? 90 : 0;
|
|
256
256
|
return {
|
|
257
257
|
score,
|
|
@@ -259,7 +259,7 @@ export const djangoRoutesExtractor = {
|
|
|
259
259
|
};
|
|
260
260
|
},
|
|
261
261
|
extract(context) {
|
|
262
|
-
const urlFiles =
|
|
262
|
+
const urlFiles = findPrimaryImportFiles(context.paths, (filePath) => /\/urls\.py$/i.test(filePath));
|
|
263
263
|
const moduleMap = new Map(urlFiles.map((filePath) => [moduleNameForFile(context.paths.repoRoot, filePath), filePath]));
|
|
264
264
|
const viewIndex = buildViewIndex(context.paths);
|
|
265
265
|
const rootFiles = urlFiles.filter((filePath) => !/\/apps\//.test(filePath));
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
dedupeCandidateRecords,
|
|
5
|
-
|
|
5
|
+
findPrimaryImportFiles,
|
|
6
6
|
inferApiEntityIdFromPath,
|
|
7
7
|
inferRouteAuthHint,
|
|
8
8
|
inferRouteCapabilityId,
|
|
@@ -94,18 +94,18 @@ export const expressExtractor = {
|
|
|
94
94
|
id: "api.express",
|
|
95
95
|
track: "api",
|
|
96
96
|
detect(context) {
|
|
97
|
-
const routeFiles =
|
|
97
|
+
const routeFiles = findPrimaryImportFiles(context.paths, (filePath) => /src\/routes\/.+\.(ts|js|mjs|cjs)$/i.test(filePath));
|
|
98
98
|
return {
|
|
99
99
|
score: routeFiles.length > 0 ? 85 : 0,
|
|
100
100
|
reasons: routeFiles.length > 0 ? ["Found Express route modules"] : []
|
|
101
101
|
};
|
|
102
102
|
},
|
|
103
103
|
extract(context) {
|
|
104
|
-
const permissionsFile =
|
|
104
|
+
const permissionsFile = findPrimaryImportFiles(context.paths, (filePath) => /src\/helpers\/permissions\.(ts|js|mjs|cjs)$/i.test(filePath))[0];
|
|
105
105
|
const permissionsText = permissionsFile ? context.helpers.readTextIfExists(permissionsFile) || "" : "";
|
|
106
106
|
const apiRoutes = parseApiRoutesMap(permissionsText);
|
|
107
107
|
const permissionMeta = parsePermissionsMetadata(permissionsText);
|
|
108
|
-
const routeFiles =
|
|
108
|
+
const routeFiles = findPrimaryImportFiles(context.paths, (filePath) => /src\/routes\/.+\.(ts|js|mjs|cjs)$/i.test(filePath));
|
|
109
109
|
const routes = routeFiles.flatMap((filePath) =>
|
|
110
110
|
parseExpressRouteCalls(filePath, context.helpers.readTextIfExists(filePath) || "", apiRoutes, permissionMeta)
|
|
111
111
|
);
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
dedupeCandidateRecords,
|
|
5
|
-
|
|
5
|
+
findPrimaryImportFiles,
|
|
6
6
|
inferApiCapabilityIdFromOperation,
|
|
7
7
|
inferApiEntityIdFromPath,
|
|
8
8
|
makeCandidateRecord,
|
|
@@ -263,8 +263,8 @@ export const fastifyExtractor = {
|
|
|
263
263
|
id: "api.fastify",
|
|
264
264
|
track: "api",
|
|
265
265
|
detect(context) {
|
|
266
|
-
const routeFiles =
|
|
267
|
-
const packageJsonFiles =
|
|
266
|
+
const routeFiles = findPrimaryImportFiles(context.paths, (filePath) => /src\/routes\/api\/.+\.(ts|js|mjs|cjs)$/i.test(filePath));
|
|
267
|
+
const packageJsonFiles = findPrimaryImportFiles(context.paths, (filePath) => /package\.json$/i.test(filePath));
|
|
268
268
|
const hasFastifyDependency = packageJsonFiles.some((filePath) => /"fastify"\s*:/.test(context.helpers.readTextIfExists(filePath) || ""));
|
|
269
269
|
return {
|
|
270
270
|
score: routeFiles.length > 0 && hasFastifyDependency ? 86 : 0,
|
|
@@ -272,16 +272,16 @@ export const fastifyExtractor = {
|
|
|
272
272
|
};
|
|
273
273
|
},
|
|
274
274
|
extract(context) {
|
|
275
|
-
const apiRoutesRoot =
|
|
276
|
-
? path.join(path.dirname(
|
|
275
|
+
const apiRoutesRoot = findPrimaryImportFiles(context.paths, (filePath) => /src\/routes\/api\/index\.(ts|js|mjs|cjs)$/i.test(filePath))[0]
|
|
276
|
+
? path.join(path.dirname(findPrimaryImportFiles(context.paths, (filePath) => /src\/routes\/api\/index\.(ts|js|mjs|cjs)$/i.test(filePath))[0]))
|
|
277
277
|
: null;
|
|
278
278
|
if (!apiRoutesRoot) {
|
|
279
279
|
return { findings: [], candidates: { capabilities: [], routes: [], stacks: [] } };
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
const routeFiles =
|
|
282
|
+
const routeFiles = findPrimaryImportFiles(context.paths, (filePath) => /src\/routes\/api\/.+\.(ts|js|mjs|cjs)$/i.test(filePath))
|
|
283
283
|
.filter((filePath) => !/\/autohooks\.(ts|js|mjs|cjs)$/i.test(filePath));
|
|
284
|
-
const schemaFiles =
|
|
284
|
+
const schemaFiles = findPrimaryImportFiles(context.paths, (filePath) => /src\/schemas\/.+\.(ts|js|mjs|cjs)$/i.test(filePath));
|
|
285
285
|
const namedSchemas = parseNamedTypeboxSchemas(schemaFiles, context.helpers.readTextIfExists);
|
|
286
286
|
|
|
287
287
|
const routes = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
canonicalCandidateTerm,
|
|
3
3
|
dedupeCandidateRecords,
|
|
4
|
-
|
|
4
|
+
findPrimaryImportFiles,
|
|
5
5
|
makeCandidateRecord,
|
|
6
6
|
pluralizeCandidateTerm,
|
|
7
7
|
relativeTo,
|
|
@@ -31,7 +31,7 @@ function capabilityIdFor(featureStem, methodName, httpMethod) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function extractApiConfigPaths(context) {
|
|
34
|
-
const configFile =
|
|
34
|
+
const configFile = findPrimaryImportFiles(context.paths, (filePath) => /\/lib\/common\/network\/api_config\.dart$/i.test(filePath))[0];
|
|
35
35
|
const mapping = new Map();
|
|
36
36
|
if (!configFile) return mapping;
|
|
37
37
|
const text = context.helpers.readTextIfExists(configFile) || "";
|
|
@@ -87,7 +87,7 @@ export const flutterDioExtractor = {
|
|
|
87
87
|
id: "api.flutter-dio",
|
|
88
88
|
track: "api",
|
|
89
89
|
detect(context) {
|
|
90
|
-
const files =
|
|
90
|
+
const files = findPrimaryImportFiles(
|
|
91
91
|
context.paths,
|
|
92
92
|
(filePath) => /\/lib\/features\/.+\/data\/datasources\/.+_remote_data_source\.dart$/i.test(filePath)
|
|
93
93
|
);
|
|
@@ -98,7 +98,7 @@ export const flutterDioExtractor = {
|
|
|
98
98
|
};
|
|
99
99
|
},
|
|
100
100
|
extract(context) {
|
|
101
|
-
const files =
|
|
101
|
+
const files = findPrimaryImportFiles(
|
|
102
102
|
context.paths,
|
|
103
103
|
(filePath) => /\/lib\/features\/.+\/data\/datasources\/.+_remote_data_source\.dart$/i.test(filePath)
|
|
104
104
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findPrimaryImportFiles, inferRouteAuthHint, inferRouteCapabilityId, inferRouteQueryParams, isPrimaryImportSource, makeCandidateRecord, normalizeOpenApiPath, relativeTo } from "../../core/shared.js";
|
|
2
2
|
|
|
3
3
|
function extractHandlerContext(text, handlerName) {
|
|
4
4
|
if (!handlerName) return "";
|
|
@@ -15,7 +15,7 @@ function extractHandlerContext(text, handlerName) {
|
|
|
15
15
|
|
|
16
16
|
function inferServerRoutes(context) {
|
|
17
17
|
const routes = [];
|
|
18
|
-
const routeFiles =
|
|
18
|
+
const routeFiles = findPrimaryImportFiles(
|
|
19
19
|
context.paths,
|
|
20
20
|
(filePath) =>
|
|
21
21
|
/\.(ts|tsx|js|jsx|mjs|cjs)$/.test(filePath) &&
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
canonicalCandidateTerm,
|
|
3
3
|
dedupeCandidateRecords,
|
|
4
|
-
|
|
4
|
+
findPrimaryImportFiles,
|
|
5
5
|
idHintify,
|
|
6
6
|
makeCandidateRecord,
|
|
7
7
|
pluralizeCandidateTerm,
|
|
@@ -464,7 +464,7 @@ export const graphQlCodeFirstExtractor = {
|
|
|
464
464
|
id: "api.graphql-code-first",
|
|
465
465
|
track: "api",
|
|
466
466
|
detect(context) {
|
|
467
|
-
const files =
|
|
467
|
+
const files = findPrimaryImportFiles(context.paths, (filePath) => /(\/src\/.+|\/pages\/api\/.+)\.(ts|tsx|js|jsx)$/i.test(filePath));
|
|
468
468
|
const hasNestResolvers = files.some((filePath) => {
|
|
469
469
|
const text = readTextIfExists(filePath) || "";
|
|
470
470
|
return /@nestjs\/graphql/.test(text) && /@(Query|Mutation)\s*\(/.test(text);
|
|
@@ -489,7 +489,7 @@ export const graphQlCodeFirstExtractor = {
|
|
|
489
489
|
};
|
|
490
490
|
},
|
|
491
491
|
extract(context) {
|
|
492
|
-
const files =
|
|
492
|
+
const files = findPrimaryImportFiles(context.paths, (filePath) => /(\/src\/.+|\/pages\/api\/.+)\.(ts|tsx|js|jsx)$/i.test(filePath)).filter((filePath) => !/\.test\./i.test(filePath));
|
|
493
493
|
const nestTypes = parseNestTypes(files);
|
|
494
494
|
const pothosTypes = parsePothosTypes(files);
|
|
495
495
|
const nexusTypes = parseNexusTypes(files);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
canonicalCandidateTerm,
|
|
3
3
|
dedupeCandidateRecords,
|
|
4
|
-
|
|
4
|
+
findPrimaryImportFiles,
|
|
5
5
|
idHintify,
|
|
6
6
|
makeCandidateRecord,
|
|
7
7
|
pluralizeCandidateTerm,
|
|
@@ -174,7 +174,7 @@ function inferEndpointPath(context, graphqlFiles) {
|
|
|
174
174
|
return endpointMatch[1];
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
const packageJsonPath =
|
|
177
|
+
const packageJsonPath = findPrimaryImportFiles(context.paths, (filePath) => /package\.json$/i.test(filePath))[0];
|
|
178
178
|
const packageText = packageJsonPath ? readTextIfExists(packageJsonPath) : null;
|
|
179
179
|
if (packageText && /graphql-yoga|apollo-server|@apollo\/server/.test(packageText)) {
|
|
180
180
|
return "/graphql";
|
|
@@ -183,7 +183,7 @@ function inferEndpointPath(context, graphqlFiles) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
function extractGraphqlSchemaSources(context) {
|
|
186
|
-
const files =
|
|
186
|
+
const files = findPrimaryImportFiles(
|
|
187
187
|
context.paths,
|
|
188
188
|
(filePath) =>
|
|
189
189
|
/\/src\/.+\.(ts|tsx|js|jsx)$/i.test(filePath) ||
|
|
@@ -210,7 +210,7 @@ export const graphQlSdlExtractor = {
|
|
|
210
210
|
detect(context) {
|
|
211
211
|
const schemaSources = extractGraphqlSchemaSources(context);
|
|
212
212
|
const hasOperations = schemaSources.some(({ schema }) => /\btype\s+Query\b|\btype\s+Mutation\b/.test(schema));
|
|
213
|
-
const packageJsonPath =
|
|
213
|
+
const packageJsonPath = findPrimaryImportFiles(context.paths, (filePath) => /package\.json$/i.test(filePath))[0];
|
|
214
214
|
const packageText = packageJsonPath ? readTextIfExists(packageJsonPath) : "";
|
|
215
215
|
const hasGraphqlRuntime = /graphql-yoga|graphql|apollo-server|@apollo\/server/.test(packageText || "");
|
|
216
216
|
return {
|
|
@@ -220,7 +220,7 @@ export const graphQlSdlExtractor = {
|
|
|
220
220
|
},
|
|
221
221
|
extract(context) {
|
|
222
222
|
const schemaSources = extractGraphqlSchemaSources(context);
|
|
223
|
-
const endpointPath = inferEndpointPath(context,
|
|
223
|
+
const endpointPath = inferEndpointPath(context, findPrimaryImportFiles(context.paths, (filePath) => /\/src\/.+\.(ts|tsx|js|jsx)$/i.test(filePath)));
|
|
224
224
|
const mergedSchema = schemaSources.map(({ schema }) => schema).join("\n\n");
|
|
225
225
|
const blocks = parseGraphqlSchemaBlocks(mergedSchema);
|
|
226
226
|
const inputTypes = new Map([...blocks.entries()].filter(([, block]) => block.kind === "input"));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dedupeCandidateRecords,
|
|
3
|
-
|
|
3
|
+
findPrimaryImportFiles,
|
|
4
4
|
inferApiEntityIdFromPath,
|
|
5
5
|
inferRouteCapabilityId,
|
|
6
6
|
makeCandidateRecord,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "../../core/shared.js";
|
|
12
12
|
|
|
13
13
|
function buildJavaFileIndex(paths) {
|
|
14
|
-
const files =
|
|
14
|
+
const files = findPrimaryImportFiles(paths, (filePath) => /\.java$/i.test(filePath));
|
|
15
15
|
return files.map((filePath) => ({
|
|
16
16
|
filePath,
|
|
17
17
|
relativePath: relativeTo(paths.repoRoot, filePath),
|
|
@@ -253,7 +253,7 @@ export const jaxRsExtractor = {
|
|
|
253
253
|
id: "api.jaxrs",
|
|
254
254
|
track: "api",
|
|
255
255
|
detect(context) {
|
|
256
|
-
const javaFiles =
|
|
256
|
+
const javaFiles = findPrimaryImportFiles(context.paths, (filePath) => /\.java$/i.test(filePath));
|
|
257
257
|
const jaxrsCount = javaFiles.filter((filePath) => /@Path\(|@(GET|POST|PUT|PATCH|DELETE)\b/.test(readTextIfExists(filePath) || "")).length;
|
|
258
258
|
return {
|
|
259
259
|
score: jaxrsCount > 0 ? 92 : 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dedupeCandidateRecords,
|
|
3
|
-
|
|
3
|
+
findPrimaryImportFiles,
|
|
4
4
|
inferApiEntityIdFromPath,
|
|
5
5
|
inferRouteCapabilityId,
|
|
6
6
|
makeCandidateRecord,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "../../core/shared.js";
|
|
12
12
|
|
|
13
13
|
function buildJavaFileIndex(paths) {
|
|
14
|
-
const files =
|
|
14
|
+
const files = findPrimaryImportFiles(paths, (filePath) => /\.java$/i.test(filePath));
|
|
15
15
|
return files.map((filePath) => ({
|
|
16
16
|
filePath,
|
|
17
17
|
relativePath: relativeTo(paths.repoRoot, filePath),
|
|
@@ -163,7 +163,7 @@ export const micronautExtractor = {
|
|
|
163
163
|
id: "api.micronaut",
|
|
164
164
|
track: "api",
|
|
165
165
|
detect(context) {
|
|
166
|
-
const javaFiles =
|
|
166
|
+
const javaFiles = findPrimaryImportFiles(context.paths, (filePath) => /\.java$/i.test(filePath));
|
|
167
167
|
const count = javaFiles.filter((filePath) => /io\.micronaut\.http\.annotation|@Controller\(|@Get\(|@Post\(|@Put\(|@Delete\(/.test(readTextIfExists(filePath) || "")).length;
|
|
168
168
|
return {
|
|
169
169
|
score: count > 0 ? 95 : 0,
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
dedupeCandidateRecords,
|
|
5
|
-
|
|
5
|
+
findPrimaryImportFiles,
|
|
6
6
|
inferApiCapabilityIdFromOperation,
|
|
7
7
|
inferApiEntityIdFromPath,
|
|
8
8
|
makeCandidateRecord,
|
|
@@ -183,15 +183,15 @@ export const openApiCodeExtractor = {
|
|
|
183
183
|
id: "api.openapi-code",
|
|
184
184
|
track: "api",
|
|
185
185
|
detect(context) {
|
|
186
|
-
const openApiFiles =
|
|
186
|
+
const openApiFiles = findPrimaryImportFiles(context.paths, (filePath) => /src\/docs\/openapi\.(ts|js|mjs|cjs)$/i.test(filePath));
|
|
187
187
|
return {
|
|
188
188
|
score: openApiFiles.length > 0 ? 92 : 0,
|
|
189
189
|
reasons: openApiFiles.length > 0 ? ["Found code-generated OpenAPI source"] : []
|
|
190
190
|
};
|
|
191
191
|
},
|
|
192
192
|
extract(context) {
|
|
193
|
-
const openApiFiles =
|
|
194
|
-
const schemaFile =
|
|
193
|
+
const openApiFiles = findPrimaryImportFiles(context.paths, (filePath) => /src\/docs\/openapi\.(ts|js|mjs|cjs)$/i.test(filePath));
|
|
194
|
+
const schemaFile = findPrimaryImportFiles(context.paths, (filePath) => /src\/docs\/openapi-schemas\.(ts|js|mjs|cjs)$/i.test(filePath))[0];
|
|
195
195
|
const schemaFields = schemaFile ? parseZodObjectSchemaFields(context.helpers.readTextIfExists(schemaFile) || "") : new Map();
|
|
196
196
|
const findings = [];
|
|
197
197
|
const candidates = { capabilities: [], routes: [], stacks: [] };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findPrimaryImportFiles, isPrimaryImportSource, makeCandidateRecord, normalizeOpenApiPath, relativeTo, selectPreferredImportFiles, slugify, titleCase } from "../../core/shared.js";
|
|
2
2
|
|
|
3
3
|
function openApiRefName(ref) {
|
|
4
4
|
return typeof ref === "string" ? ref.split("/").pop() || null : null;
|
|
@@ -196,7 +196,7 @@ export const openApiExtractor = {
|
|
|
196
196
|
detect(context) {
|
|
197
197
|
const files = selectPreferredImportFiles(
|
|
198
198
|
context.paths,
|
|
199
|
-
|
|
199
|
+
findPrimaryImportFiles(context.paths, (filePath) => /(openapi|swagger)\.(json|ya?ml)$/i.test(filePath) && isPrimaryImportSource(context.paths, filePath)),
|
|
200
200
|
"openapi"
|
|
201
201
|
);
|
|
202
202
|
return {
|
|
@@ -207,7 +207,7 @@ export const openApiExtractor = {
|
|
|
207
207
|
extract(context) {
|
|
208
208
|
const openApiFiles = selectPreferredImportFiles(
|
|
209
209
|
context.paths,
|
|
210
|
-
|
|
210
|
+
findPrimaryImportFiles(context.paths, (filePath) => /(openapi|swagger)\.(json|ya?ml)$/i.test(filePath) && isPrimaryImportSource(context.paths, filePath)),
|
|
211
211
|
"openapi"
|
|
212
212
|
);
|
|
213
213
|
const findings = [];
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
dedupeCandidateRecords,
|
|
5
|
-
|
|
5
|
+
findPrimaryImportFiles,
|
|
6
6
|
inferApiEntityIdFromPath,
|
|
7
7
|
inferRouteCapabilityId,
|
|
8
8
|
makeCandidateRecord,
|
|
@@ -167,14 +167,14 @@ export const railsRoutesExtractor = {
|
|
|
167
167
|
id: "api.rails-routes",
|
|
168
168
|
track: "api",
|
|
169
169
|
detect(context) {
|
|
170
|
-
const routeFiles =
|
|
170
|
+
const routeFiles = findPrimaryImportFiles(context.paths, (filePath) => /config\/routes\.rb$/i.test(filePath));
|
|
171
171
|
return {
|
|
172
172
|
score: routeFiles.length > 0 ? 90 : 0,
|
|
173
173
|
reasons: routeFiles.length > 0 ? ["Found Rails routes.rb"] : []
|
|
174
174
|
};
|
|
175
175
|
},
|
|
176
176
|
extract(context) {
|
|
177
|
-
const routeFiles =
|
|
177
|
+
const routeFiles = findPrimaryImportFiles(context.paths, (filePath) => /config\/routes\.rb$/i.test(filePath));
|
|
178
178
|
const findings = [];
|
|
179
179
|
const candidates = { capabilities: [], routes: [], stacks: [] };
|
|
180
180
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
canonicalCandidateTerm,
|
|
3
3
|
dedupeCandidateRecords,
|
|
4
|
-
|
|
4
|
+
findPrimaryImportFiles,
|
|
5
5
|
makeCandidateRecord,
|
|
6
6
|
pluralizeCandidateTerm,
|
|
7
7
|
relativeTo,
|
|
@@ -82,7 +82,7 @@ export const reactNativeRepositoryExtractor = {
|
|
|
82
82
|
id: "api.react-native-repository",
|
|
83
83
|
track: "api",
|
|
84
84
|
detect(context) {
|
|
85
|
-
const files =
|
|
85
|
+
const files = findPrimaryImportFiles(
|
|
86
86
|
context.paths,
|
|
87
87
|
(filePath) => /\/src\/.+\/infrastructure\/implementations\/.+Repository\.ts$/i.test(filePath)
|
|
88
88
|
);
|
|
@@ -93,7 +93,7 @@ export const reactNativeRepositoryExtractor = {
|
|
|
93
93
|
};
|
|
94
94
|
},
|
|
95
95
|
extract(context) {
|
|
96
|
-
const files =
|
|
96
|
+
const files = findPrimaryImportFiles(
|
|
97
97
|
context.paths,
|
|
98
98
|
(filePath) => /\/src\/.+\/infrastructure\/implementations\/.+Repository\.ts$/i.test(filePath)
|
|
99
99
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
canonicalCandidateTerm,
|
|
3
3
|
dedupeCandidateRecords,
|
|
4
|
-
|
|
4
|
+
findPrimaryImportFiles,
|
|
5
5
|
makeCandidateRecord,
|
|
6
6
|
relativeTo,
|
|
7
7
|
titleCase
|
|
@@ -66,7 +66,7 @@ export const retrofitExtractor = {
|
|
|
66
66
|
id: "api.retrofit",
|
|
67
67
|
track: "api",
|
|
68
68
|
detect(context) {
|
|
69
|
-
const serviceFiles =
|
|
69
|
+
const serviceFiles = findPrimaryImportFiles(context.paths, (filePath) => /Service\.kt$/i.test(filePath) || /retrofit\/.+\.kt$/i.test(filePath));
|
|
70
70
|
const score = serviceFiles.some((filePath) => /@GET|@POST|@PUT|@PATCH|@DELETE/.test(context.helpers.readTextIfExists(filePath) || "")) ? 87 : 0;
|
|
71
71
|
return {
|
|
72
72
|
score,
|
|
@@ -74,7 +74,7 @@ export const retrofitExtractor = {
|
|
|
74
74
|
};
|
|
75
75
|
},
|
|
76
76
|
extract(context) {
|
|
77
|
-
const serviceFiles =
|
|
77
|
+
const serviceFiles = findPrimaryImportFiles(context.paths, (filePath) => /Service\.kt$/i.test(filePath) || /retrofit\/.+\.kt$/i.test(filePath));
|
|
78
78
|
const capabilities = [];
|
|
79
79
|
for (const filePath of serviceFiles) {
|
|
80
80
|
const provenance = relativeTo(context.paths.repoRoot, filePath);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dedupeCandidateRecords,
|
|
3
|
-
|
|
3
|
+
findPrimaryImportFiles,
|
|
4
4
|
inferApiEntityIdFromPath,
|
|
5
5
|
inferRouteCapabilityId,
|
|
6
6
|
makeCandidateRecord,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
const JAVA_ANNOTATION_PATTERN = String.raw`@[\w.]+(?:\((?:[^()]|\([^)]*\))*\))?`;
|
|
14
14
|
|
|
15
15
|
function buildJavaFileIndex(paths) {
|
|
16
|
-
const files =
|
|
16
|
+
const files = findPrimaryImportFiles(paths, (filePath) => /\.java$/i.test(filePath));
|
|
17
17
|
return files.map((filePath) => ({
|
|
18
18
|
filePath,
|
|
19
19
|
relativePath: relativeTo(paths.repoRoot, filePath),
|
|
@@ -318,7 +318,7 @@ export const springWebExtractor = {
|
|
|
318
318
|
id: "api.spring-web",
|
|
319
319
|
track: "api",
|
|
320
320
|
detect(context) {
|
|
321
|
-
const javaFiles =
|
|
321
|
+
const javaFiles = findPrimaryImportFiles(context.paths, (filePath) => /\.java$/i.test(filePath));
|
|
322
322
|
const springCount = javaFiles.filter((filePath) => /@(RestController|Controller)|@(?:Get|Post|Put|Patch|Delete)Exchange|@(GetMapping|PostMapping|PutMapping|PatchMapping|DeleteMapping)|@RequestMapping/.test(readTextIfExists(filePath) || "")).length;
|
|
323
323
|
return {
|
|
324
324
|
score: springCount > 0 ? 90 : 0,
|