@topogram/cli 0.3.34
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/ARCHITECTURE.md +67 -0
- package/CHANGELOG.md +240 -0
- package/README.md +223 -0
- package/package.json +51 -0
- package/src/adoption/index.js +3 -0
- package/src/adoption/plan.js +702 -0
- package/src/adoption/reporting.js +464 -0
- package/src/adoption/review-groups.js +313 -0
- package/src/agent-ops/query-builders.js +5012 -0
- package/src/archive/archive.js +141 -0
- package/src/archive/compact.js +26 -0
- package/src/archive/jsonl.js +70 -0
- package/src/archive/resolver-bridge.js +82 -0
- package/src/archive/schema.js +87 -0
- package/src/archive/unarchive.js +108 -0
- package/src/catalog.js +752 -0
- package/src/cli/catalog-alias.js +166 -0
- package/src/cli.js +9738 -0
- package/src/component-behavior.js +173 -0
- package/src/example-implementation.js +91 -0
- package/src/format.js +19 -0
- package/src/generator/adapters.d.ts +4 -0
- package/src/generator/adapters.js +325 -0
- package/src/generator/api.d.ts +1 -0
- package/src/generator/api.js +1196 -0
- package/src/generator/check.js +355 -0
- package/src/generator/component-conformance.js +767 -0
- package/src/generator/components.js +39 -0
- package/src/generator/context/bundle.js +291 -0
- package/src/generator/context/diff.js +256 -0
- package/src/generator/context/digest.js +182 -0
- package/src/generator/context/domain-coverage.js +94 -0
- package/src/generator/context/domain-page.js +137 -0
- package/src/generator/context/index.js +42 -0
- package/src/generator/context/report.js +121 -0
- package/src/generator/context/shared.js +1397 -0
- package/src/generator/context/slice.js +703 -0
- package/src/generator/context/task-mode.js +466 -0
- package/src/generator/docs.js +327 -0
- package/src/generator/index.js +161 -0
- package/src/generator/native/parity-bundle.js +311 -0
- package/src/generator/output.js +300 -0
- package/src/generator/registry.js +482 -0
- package/src/generator/runtime/app-bundle.js +456 -0
- package/src/generator/runtime/bundle-shared.js +166 -0
- package/src/generator/runtime/compile-check.js +163 -0
- package/src/generator/runtime/deployment.js +287 -0
- package/src/generator/runtime/environment.js +635 -0
- package/src/generator/runtime/index.js +32 -0
- package/src/generator/runtime/runtime-check.js +554 -0
- package/src/generator/runtime/shared.js +515 -0
- package/src/generator/runtime/smoke.js +219 -0
- package/src/generator/schema.js +204 -0
- package/src/generator/sdlc/board.js +66 -0
- package/src/generator/sdlc/doc-page.js +53 -0
- package/src/generator/sdlc/index.js +23 -0
- package/src/generator/sdlc/release-notes.js +62 -0
- package/src/generator/sdlc/traceability-matrix.js +65 -0
- package/src/generator/shared.js +29 -0
- package/src/generator/surfaces/contracts.js +146 -0
- package/src/generator/surfaces/databases/contract.js +40 -0
- package/src/generator/surfaces/databases/index.js +84 -0
- package/src/generator/surfaces/databases/lifecycle-shared.d.ts +1 -0
- package/src/generator/surfaces/databases/lifecycle-shared.js +612 -0
- package/src/generator/surfaces/databases/migration-plan.js +281 -0
- package/src/generator/surfaces/databases/postgres/capabilities.js +14 -0
- package/src/generator/surfaces/databases/postgres/drizzle.js +99 -0
- package/src/generator/surfaces/databases/postgres/index.js +9 -0
- package/src/generator/surfaces/databases/postgres/lifecycle.js +16 -0
- package/src/generator/surfaces/databases/postgres/prisma.js +159 -0
- package/src/generator/surfaces/databases/postgres/sql-migration.js +102 -0
- package/src/generator/surfaces/databases/postgres/sql-schema.js +34 -0
- package/src/generator/surfaces/databases/shared.d.ts +1 -0
- package/src/generator/surfaces/databases/shared.js +350 -0
- package/src/generator/surfaces/databases/snapshot.js +96 -0
- package/src/generator/surfaces/databases/sqlite/capabilities.js +14 -0
- package/src/generator/surfaces/databases/sqlite/index.js +8 -0
- package/src/generator/surfaces/databases/sqlite/lifecycle.js +16 -0
- package/src/generator/surfaces/databases/sqlite/prisma.js +143 -0
- package/src/generator/surfaces/databases/sqlite/sql-migration.js +65 -0
- package/src/generator/surfaces/databases/sqlite/sql-schema.js +27 -0
- package/src/generator/surfaces/index.js +25 -0
- package/src/generator/surfaces/native/swiftui-app.js +38 -0
- package/src/generator/surfaces/native/swiftui-templates/Package.swift.txt +20 -0
- package/src/generator/surfaces/native/swiftui-templates/README.generated.md +26 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/DynamicScreens.swift +682 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/TodoAPIClient.swift +156 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/TodoSwiftUIApp.swift +44 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/Visibility.swift +183 -0
- package/src/generator/surfaces/services/express.d.ts +1 -0
- package/src/generator/surfaces/services/express.js +766 -0
- package/src/generator/surfaces/services/hono.d.ts +1 -0
- package/src/generator/surfaces/services/hono.js +204 -0
- package/src/generator/surfaces/services/index.js +42 -0
- package/src/generator/surfaces/services/persistence-wiring.js +240 -0
- package/src/generator/surfaces/services/runtime-helpers.js +631 -0
- package/src/generator/surfaces/services/server-contract.js +80 -0
- package/src/generator/surfaces/services/stateless.d.ts +1 -0
- package/src/generator/surfaces/services/stateless.js +97 -0
- package/src/generator/surfaces/shared.js +64 -0
- package/src/generator/surfaces/web/api-client.js +1 -0
- package/src/generator/surfaces/web/forms.js +1 -0
- package/src/generator/surfaces/web/index.d.ts +2 -0
- package/src/generator/surfaces/web/index.js +53 -0
- package/src/generator/surfaces/web/react-components.js +248 -0
- package/src/generator/surfaces/web/react.js +538 -0
- package/src/generator/surfaces/web/routes.js +1 -0
- package/src/generator/surfaces/web/screens.js +1 -0
- package/src/generator/surfaces/web/shared.js +369 -0
- package/src/generator/surfaces/web/sveltekit-actions.js +28 -0
- package/src/generator/surfaces/web/sveltekit-components.js +234 -0
- package/src/generator/surfaces/web/sveltekit.js +426 -0
- package/src/generator/surfaces/web/ui-web-contract.js +65 -0
- package/src/generator/surfaces/web/vanilla.js +239 -0
- package/src/generator/verification.js +84 -0
- package/src/generator.js +1 -0
- package/src/import/core/context.js +52 -0
- package/src/import/core/contracts.js +23 -0
- package/src/import/core/registry.js +81 -0
- package/src/import/core/runner.js +646 -0
- package/src/import/core/shared.js +910 -0
- package/src/import/enrichers/auth-session.js +18 -0
- package/src/import/enrichers/django-rest.js +226 -0
- package/src/import/enrichers/doc-linking.js +20 -0
- package/src/import/enrichers/rails-controllers.js +246 -0
- package/src/import/enrichers/rails-models.js +130 -0
- package/src/import/enrichers/workflow-target-state.js +10 -0
- package/src/import/extractors/api/aspnet-core.js +304 -0
- package/src/import/extractors/api/django-routes.js +318 -0
- package/src/import/extractors/api/express.js +154 -0
- package/src/import/extractors/api/fastify.js +371 -0
- package/src/import/extractors/api/flutter-dio.js +135 -0
- package/src/import/extractors/api/generic-route-fallback.js +90 -0
- package/src/import/extractors/api/graphql-code-first.js +565 -0
- package/src/import/extractors/api/graphql-sdl.js +309 -0
- package/src/import/extractors/api/jaxrs.js +303 -0
- package/src/import/extractors/api/micronaut.js +213 -0
- package/src/import/extractors/api/next-route.js +50 -0
- package/src/import/extractors/api/next-server-action.js +51 -0
- package/src/import/extractors/api/nextauth.js +52 -0
- package/src/import/extractors/api/openapi-code.js +242 -0
- package/src/import/extractors/api/openapi.js +232 -0
- package/src/import/extractors/api/rails-routes.js +230 -0
- package/src/import/extractors/api/react-native-repository.js +128 -0
- package/src/import/extractors/api/retrofit.js +103 -0
- package/src/import/extractors/api/spring-web.js +372 -0
- package/src/import/extractors/api/swift-webapi.js +116 -0
- package/src/import/extractors/api/trpc.js +212 -0
- package/src/import/extractors/db/django-models.js +232 -0
- package/src/import/extractors/db/dotnet-models.js +93 -0
- package/src/import/extractors/db/drizzle.js +242 -0
- package/src/import/extractors/db/ef-core.js +221 -0
- package/src/import/extractors/db/flutter-entities.js +120 -0
- package/src/import/extractors/db/jpa.js +120 -0
- package/src/import/extractors/db/liquibase.js +180 -0
- package/src/import/extractors/db/mybatis-xml.js +145 -0
- package/src/import/extractors/db/prisma.js +185 -0
- package/src/import/extractors/db/rails-schema.js +175 -0
- package/src/import/extractors/db/react-native-entities.js +95 -0
- package/src/import/extractors/db/room.js +193 -0
- package/src/import/extractors/db/snapshot.js +112 -0
- package/src/import/extractors/db/sql.js +180 -0
- package/src/import/extractors/db/swiftdata.js +137 -0
- package/src/import/extractors/ui/android-compose.js +230 -0
- package/src/import/extractors/ui/backend-only.js +70 -0
- package/src/import/extractors/ui/blazor.js +227 -0
- package/src/import/extractors/ui/flutter-screens.js +152 -0
- package/src/import/extractors/ui/maui-xaml.js +135 -0
- package/src/import/extractors/ui/next-app-router.js +83 -0
- package/src/import/extractors/ui/next-pages-router.js +141 -0
- package/src/import/extractors/ui/razor-pages.js +181 -0
- package/src/import/extractors/ui/react-native-screens.js +166 -0
- package/src/import/extractors/ui/react-router.js +139 -0
- package/src/import/extractors/ui/sveltekit.js +123 -0
- package/src/import/extractors/ui/swiftui.js +193 -0
- package/src/import/extractors/ui/uikit.js +175 -0
- package/src/import/extractors/verification/generic.js +290 -0
- package/src/import/extractors/workflows/generic.js +137 -0
- package/src/import/index.js +7 -0
- package/src/import/provenance.js +158 -0
- package/src/new-project.js +2107 -0
- package/src/parser.js +439 -0
- package/src/policy/review-boundaries.js +165 -0
- package/src/project-config.js +535 -0
- package/src/proofs/backend-parity.js +19 -0
- package/src/proofs/contract-audit.js +220 -0
- package/src/proofs/ios-parity.js +7 -0
- package/src/proofs/issues-parity.js +10 -0
- package/src/proofs/web-parity.js +50 -0
- package/src/realization/api/build-api-realization.js +5 -0
- package/src/realization/api/index.js +1 -0
- package/src/realization/backend/build-backend-runtime-realization.js +82 -0
- package/src/realization/backend/index.d.ts +1 -0
- package/src/realization/backend/index.js +4 -0
- package/src/realization/db/build-db-realization.js +17 -0
- package/src/realization/db/index.js +3 -0
- package/src/realization/db/migration-plan.js +5 -0
- package/src/realization/db/snapshot.js +5 -0
- package/src/realization/ui/build-ui-shared-realization.js +305 -0
- package/src/realization/ui/build-web-realization.js +189 -0
- package/src/realization/ui/index.js +2 -0
- package/src/reconcile/docs.js +280 -0
- package/src/reconcile/index.js +3 -0
- package/src/reconcile/journeys.js +441 -0
- package/src/resolver/docs.js +1 -0
- package/src/resolver/enrich/acceptance-criterion.js +14 -0
- package/src/resolver/enrich/bug.js +12 -0
- package/src/resolver/enrich/component.js +2 -0
- package/src/resolver/enrich/index.js +1 -0
- package/src/resolver/enrich/pitch.js +18 -0
- package/src/resolver/enrich/requirement.js +20 -0
- package/src/resolver/enrich/task.js +16 -0
- package/src/resolver/expressions.js +1 -0
- package/src/resolver/index.js +2422 -0
- package/src/resolver/normalize.js +1 -0
- package/src/resolver.js +1 -0
- package/src/sdlc/adopt.js +65 -0
- package/src/sdlc/check.js +86 -0
- package/src/sdlc/dod/acceptance-criterion.js +22 -0
- package/src/sdlc/dod/bug.js +26 -0
- package/src/sdlc/dod/document.js +23 -0
- package/src/sdlc/dod/index.js +25 -0
- package/src/sdlc/dod/pitch.js +23 -0
- package/src/sdlc/dod/requirement.js +34 -0
- package/src/sdlc/dod/task.js +39 -0
- package/src/sdlc/explain.js +116 -0
- package/src/sdlc/history.js +80 -0
- package/src/sdlc/paths.js +11 -0
- package/src/sdlc/release.js +106 -0
- package/src/sdlc/scaffold.js +89 -0
- package/src/sdlc/status-filter.js +54 -0
- package/src/sdlc/transition.js +112 -0
- package/src/sdlc/transitions/acceptance-criterion.js +28 -0
- package/src/sdlc/transitions/bug.js +31 -0
- package/src/sdlc/transitions/document.js +29 -0
- package/src/sdlc/transitions/index.js +56 -0
- package/src/sdlc/transitions/pitch.js +34 -0
- package/src/sdlc/transitions/requirement.js +31 -0
- package/src/sdlc/transitions/task.js +34 -0
- package/src/template-trust.js +597 -0
- package/src/validator/expressions.js +1 -0
- package/src/validator/index.js +3424 -0
- package/src/validator/kinds.js +346 -0
- package/src/validator/per-kind/acceptance-criterion.js +91 -0
- package/src/validator/per-kind/bug.js +77 -0
- package/src/validator/per-kind/component.js +274 -0
- package/src/validator/per-kind/domain.js +205 -0
- package/src/validator/per-kind/pitch.js +101 -0
- package/src/validator/per-kind/requirement.js +75 -0
- package/src/validator/per-kind/task.js +96 -0
- package/src/validator/registry.js +1 -0
- package/src/validator/utils.js +12 -0
- package/src/validator.js +1 -0
- package/src/workflows.js +7597 -0
- package/src/workspace-docs.js +265 -0
- package/template-helpers/react.js +5 -0
- package/template-helpers/sveltekit.js +5 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { canonicalCandidateTerm, findImportFiles, makeCandidateRecord, relativeTo, selectPreferredImportFiles, slugify, titleCase, idHintify } from "../../core/shared.js";
|
|
2
|
+
|
|
3
|
+
function parseTableConstraint(line, tableName) {
|
|
4
|
+
const normalized = line.replace(/,$/, "").trim();
|
|
5
|
+
const relationMatch = normalized.match(/foreign\s+key\s*\(([^)]+)\)\s+references\s+([A-Za-z0-9_".]+)\s*\(([^)]+)\)/i);
|
|
6
|
+
if (relationMatch) {
|
|
7
|
+
return {
|
|
8
|
+
type: "relation",
|
|
9
|
+
relation: {
|
|
10
|
+
from_entity: `entity_${canonicalCandidateTerm(tableName)}`,
|
|
11
|
+
to_entity: `entity_${canonicalCandidateTerm(relationMatch[2].split(".").pop().replace(/"/g, ""))}`,
|
|
12
|
+
relation_field: relationMatch[1].split(",")[0].trim().replace(/"/g, ""),
|
|
13
|
+
fields: relationMatch[1].split(",").map((entry) => entry.trim().replace(/"/g, "")),
|
|
14
|
+
references: relationMatch[3].split(",").map((entry) => entry.trim().replace(/"/g, ""))
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return { type: "constraint" };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function parseSqlSchema(sqlText) {
|
|
22
|
+
const entities = [];
|
|
23
|
+
const enums = [];
|
|
24
|
+
const relations = [];
|
|
25
|
+
const indexes = [];
|
|
26
|
+
|
|
27
|
+
for (const match of sqlText.matchAll(/create\s+type\s+([A-Za-z0-9_"]+)\s+as\s+enum\s*\(([\s\S]*?)\)\s*;/gi)) {
|
|
28
|
+
const [, rawName, rawValues] = match;
|
|
29
|
+
const enumName = rawName.replace(/"/g, "");
|
|
30
|
+
const values = rawValues
|
|
31
|
+
.split(",")
|
|
32
|
+
.map((value) => value.trim().replace(/^'+|'+$/g, ""))
|
|
33
|
+
.filter(Boolean);
|
|
34
|
+
enums.push({ name: enumName, values });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const match of sqlText.matchAll(/create\s+table\s+([A-Za-z0-9_".]+)\s*\(([\s\S]*?)\)\s*;/gi)) {
|
|
38
|
+
const [, rawName, body] = match;
|
|
39
|
+
const tableName = rawName.split(".").pop().replace(/"/g, "");
|
|
40
|
+
const entityStem = canonicalCandidateTerm(tableName);
|
|
41
|
+
const fields = [];
|
|
42
|
+
const bodyLines = body
|
|
43
|
+
.split(/\r?\n/)
|
|
44
|
+
.map((line) => line.trim())
|
|
45
|
+
.filter(Boolean);
|
|
46
|
+
|
|
47
|
+
for (const line of bodyLines) {
|
|
48
|
+
if (/^(constraint\b.*)?foreign\s+key\b/i.test(line) || /^primary\s+key\b/i.test(line) || /^unique\b/i.test(line) || /^check\b/i.test(line)) {
|
|
49
|
+
const parsedConstraint = parseTableConstraint(line, tableName);
|
|
50
|
+
if (parsedConstraint.type === "relation") {
|
|
51
|
+
relations.push(parsedConstraint.relation);
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const columnMatch = line.replace(/,$/, "").match(/^"?(?<name>[A-Za-z0-9_]+)"?\s+(?<type>[A-Za-z0-9_()[\]".]+)(?<rest>.*)$/i);
|
|
56
|
+
if (!columnMatch) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const name = columnMatch.groups.name;
|
|
60
|
+
const fieldType = columnMatch.groups.type.replace(/"/g, "");
|
|
61
|
+
const rest = columnMatch.groups.rest || "";
|
|
62
|
+
fields.push({
|
|
63
|
+
name,
|
|
64
|
+
field_type: fieldType,
|
|
65
|
+
required: /\bnot\s+null\b/i.test(rest) || /\bprimary\s+key\b/i.test(rest),
|
|
66
|
+
list: /\[\]$/.test(fieldType),
|
|
67
|
+
unique: /\bunique\b/i.test(rest),
|
|
68
|
+
primary_key: /\bprimary\s+key\b/i.test(rest)
|
|
69
|
+
});
|
|
70
|
+
const inlineReferenceMatch = rest.match(/\breferences\s+([A-Za-z0-9_".]+)\s*\(([^)]+)\)/i);
|
|
71
|
+
if (inlineReferenceMatch) {
|
|
72
|
+
relations.push({
|
|
73
|
+
from_entity: `entity_${entityStem}`,
|
|
74
|
+
to_entity: `entity_${canonicalCandidateTerm(inlineReferenceMatch[1].split(".").pop().replace(/"/g, ""))}`,
|
|
75
|
+
relation_field: name,
|
|
76
|
+
fields: [name],
|
|
77
|
+
references: inlineReferenceMatch[2].split(",").map((entry) => entry.trim().replace(/"/g, ""))
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
entities.push({
|
|
83
|
+
name: entityStem,
|
|
84
|
+
table_name: tableName,
|
|
85
|
+
fields
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
for (const match of sqlText.matchAll(/create\s+(unique\s+)?index\s+([A-Za-z0-9_"]+)\s+on\s+([A-Za-z0-9_".]+)\s*\(([^)]+)\)/gi)) {
|
|
90
|
+
const [, uniqueFlag, rawIndexName, rawTableName, rawFields] = match;
|
|
91
|
+
const tableName = rawTableName.split(".").pop().replace(/"/g, "");
|
|
92
|
+
indexes.push({
|
|
93
|
+
id_hint: idHintify(rawIndexName.replace(/"/g, "")),
|
|
94
|
+
entity: `entity_${canonicalCandidateTerm(tableName)}`,
|
|
95
|
+
fields: rawFields.split(",").map((entry) => entry.trim().replace(/"/g, "")),
|
|
96
|
+
unique: Boolean(uniqueFlag)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return { entities, enums, relations, indexes };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const sqlExtractor = {
|
|
104
|
+
id: "db.sql",
|
|
105
|
+
track: "db",
|
|
106
|
+
detect(context) {
|
|
107
|
+
const files = findImportFiles(context.paths, (filePath) => filePath.endsWith(".sql"));
|
|
108
|
+
return {
|
|
109
|
+
score: files.length > 0 ? 80 : 0,
|
|
110
|
+
reasons: files.length > 0 ? ["Found SQL schema or migration files"] : []
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
extract(context) {
|
|
114
|
+
const allSqlFiles = findImportFiles(context.paths, (filePath) => filePath.endsWith(".sql"));
|
|
115
|
+
const schemaSqlFiles = allSqlFiles.filter((filePath) => !/migration/i.test(filePath) && !/\/src\/test\//i.test(filePath));
|
|
116
|
+
const migrationSqlFiles = allSqlFiles.filter((filePath) => /migration/i.test(filePath));
|
|
117
|
+
const sqlFiles =
|
|
118
|
+
schemaSqlFiles.length > 0
|
|
119
|
+
? selectPreferredImportFiles(context.paths, schemaSqlFiles, "sql")
|
|
120
|
+
: selectPreferredImportFiles(context.paths, migrationSqlFiles, "sql");
|
|
121
|
+
const findings = [];
|
|
122
|
+
const candidates = { entities: [], enums: [], relations: [], indexes: [] };
|
|
123
|
+
for (const filePath of sqlFiles) {
|
|
124
|
+
const parsed = parseSqlSchema(context.helpers.readTextIfExists(filePath) || "");
|
|
125
|
+
const provenance = relativeTo(context.paths.repoRoot, filePath);
|
|
126
|
+
const sourceKind = /migration/i.test(filePath) ? "migration" : "schema";
|
|
127
|
+
const confidence = sourceKind === "migration" ? "medium" : "high";
|
|
128
|
+
findings.push({
|
|
129
|
+
kind: "sql_schema",
|
|
130
|
+
file: provenance,
|
|
131
|
+
entity_count: parsed.entities.length,
|
|
132
|
+
enum_count: parsed.enums.length
|
|
133
|
+
});
|
|
134
|
+
candidates.entities.push(...parsed.entities.map((entity) => makeCandidateRecord({
|
|
135
|
+
kind: "entity",
|
|
136
|
+
idHint: `entity_${slugify(entity.name)}`,
|
|
137
|
+
label: titleCase(entity.name),
|
|
138
|
+
confidence,
|
|
139
|
+
sourceKind,
|
|
140
|
+
provenance,
|
|
141
|
+
table_name: entity.table_name || slugify(entity.name),
|
|
142
|
+
fields: entity.fields,
|
|
143
|
+
track: "db"
|
|
144
|
+
})));
|
|
145
|
+
candidates.enums.push(...parsed.enums.map((entry) => makeCandidateRecord({
|
|
146
|
+
kind: "enum",
|
|
147
|
+
idHint: idHintify(entry.name),
|
|
148
|
+
label: titleCase(entry.name),
|
|
149
|
+
confidence,
|
|
150
|
+
sourceKind,
|
|
151
|
+
provenance,
|
|
152
|
+
values: entry.values,
|
|
153
|
+
track: "db"
|
|
154
|
+
})));
|
|
155
|
+
candidates.relations.push(...parsed.relations.map((relation) => makeCandidateRecord({
|
|
156
|
+
kind: "relation",
|
|
157
|
+
idHint: slugify(`${relation.from_entity}_${relation.relation_field}_${relation.to_entity}`),
|
|
158
|
+
label: `${relation.from_entity} -> ${relation.to_entity}`,
|
|
159
|
+
confidence: "medium",
|
|
160
|
+
sourceKind,
|
|
161
|
+
provenance,
|
|
162
|
+
...relation,
|
|
163
|
+
track: "db"
|
|
164
|
+
})));
|
|
165
|
+
candidates.indexes.push(...parsed.indexes.map((index) => makeCandidateRecord({
|
|
166
|
+
kind: "index",
|
|
167
|
+
idHint: index.id_hint,
|
|
168
|
+
label: titleCase(index.id_hint.replace(/^index_/, "")),
|
|
169
|
+
confidence: "medium",
|
|
170
|
+
sourceKind,
|
|
171
|
+
provenance,
|
|
172
|
+
entity: index.entity,
|
|
173
|
+
fields: index.fields,
|
|
174
|
+
unique: index.unique,
|
|
175
|
+
track: "db"
|
|
176
|
+
})));
|
|
177
|
+
}
|
|
178
|
+
return { findings, candidates };
|
|
179
|
+
}
|
|
180
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonicalCandidateTerm,
|
|
3
|
+
dedupeCandidateRecords,
|
|
4
|
+
findImportFiles,
|
|
5
|
+
idHintify,
|
|
6
|
+
makeCandidateRecord,
|
|
7
|
+
relativeTo,
|
|
8
|
+
titleCase
|
|
9
|
+
} from "../../core/shared.js";
|
|
10
|
+
|
|
11
|
+
function swiftFieldType(typeName) {
|
|
12
|
+
const normalized = String(typeName || "").replace(/\?$/, "").trim();
|
|
13
|
+
switch (normalized) {
|
|
14
|
+
case "String": return "string";
|
|
15
|
+
case "Int": return "int";
|
|
16
|
+
case "Double": return "double";
|
|
17
|
+
case "Float": return "float";
|
|
18
|
+
case "Bool": return "boolean";
|
|
19
|
+
case "URL": return "url";
|
|
20
|
+
default:
|
|
21
|
+
if (/^\[.+\]$/.test(normalized)) return "json";
|
|
22
|
+
return idHintify(normalized) || "string";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function parseSwiftModelBlocks(text) {
|
|
27
|
+
const blocks = [];
|
|
28
|
+
const pattern = /@Model\s+final\s+class\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\n\}/g;
|
|
29
|
+
for (const match of String(text || "").matchAll(pattern)) {
|
|
30
|
+
blocks.push({ className: match[1], body: match[2] });
|
|
31
|
+
}
|
|
32
|
+
return blocks;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseSwiftDataEntity(block, provenance) {
|
|
36
|
+
const stem = idHintify(canonicalCandidateTerm(block.className.replace(/([a-z0-9])([A-Z])/g, "$1_$2")));
|
|
37
|
+
const fields = [];
|
|
38
|
+
const relations = [];
|
|
39
|
+
let uniqueNext = false;
|
|
40
|
+
let relationNext = false;
|
|
41
|
+
|
|
42
|
+
for (const rawLine of String(block.body || "").split(/\r?\n/)) {
|
|
43
|
+
const line = rawLine.trim();
|
|
44
|
+
if (!line) continue;
|
|
45
|
+
if (line.startsWith("@Attribute(.unique)")) {
|
|
46
|
+
uniqueNext = true;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (line.startsWith("@Relationship")) {
|
|
50
|
+
relationNext = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const match = line.match(/^var\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^=]+)/);
|
|
54
|
+
if (!match) continue;
|
|
55
|
+
const [, name, rawType] = match;
|
|
56
|
+
const typeName = rawType.trim();
|
|
57
|
+
const isList = /^\[.+\]\??$/.test(typeName);
|
|
58
|
+
const innerType = isList ? typeName.replace(/^\[/, "").replace(/\]\??$/, "") : typeName.replace(/\?$/, "");
|
|
59
|
+
const looksRelation = relationNext || /^[A-Z][A-Za-z0-9_]+$/.test(innerType);
|
|
60
|
+
fields.push({
|
|
61
|
+
name,
|
|
62
|
+
field_type: looksRelation ? idHintify(innerType.replace(/([a-z0-9])([A-Z])/g, "$1_$2")) : swiftFieldType(typeName),
|
|
63
|
+
required: !typeName.includes("?"),
|
|
64
|
+
list: isList,
|
|
65
|
+
unique: uniqueNext,
|
|
66
|
+
primary_key: false
|
|
67
|
+
});
|
|
68
|
+
if (looksRelation) {
|
|
69
|
+
relations.push(makeCandidateRecord({
|
|
70
|
+
kind: "relation",
|
|
71
|
+
idHint: `${stem}_${name}_${idHintify(innerType)}`,
|
|
72
|
+
label: `${stem} -> ${innerType}`,
|
|
73
|
+
confidence: "medium",
|
|
74
|
+
sourceKind: "schema",
|
|
75
|
+
provenance,
|
|
76
|
+
from_entity: `entity_${stem}`,
|
|
77
|
+
to_entity: `entity_${canonicalCandidateTerm(idHintify(innerType.replace(/([a-z0-9])([A-Z])/g, "$1_$2")))}`,
|
|
78
|
+
relation_field: name,
|
|
79
|
+
fields: [name],
|
|
80
|
+
references: ["id"],
|
|
81
|
+
relation_type: isList ? "many" : "one",
|
|
82
|
+
track: "db"
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
uniqueNext = false;
|
|
86
|
+
relationNext = false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
entity: makeCandidateRecord({
|
|
91
|
+
kind: "entity",
|
|
92
|
+
idHint: `entity_${stem}`,
|
|
93
|
+
label: titleCase(stem),
|
|
94
|
+
confidence: "high",
|
|
95
|
+
sourceKind: "schema",
|
|
96
|
+
provenance,
|
|
97
|
+
model_name: block.className,
|
|
98
|
+
fields,
|
|
99
|
+
track: "db"
|
|
100
|
+
}),
|
|
101
|
+
relations
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const swiftDataExtractor = {
|
|
106
|
+
id: "db.swiftdata",
|
|
107
|
+
track: "db",
|
|
108
|
+
detect(context) {
|
|
109
|
+
const files = findImportFiles(context.paths, (filePath) => /\.swift$/i.test(filePath))
|
|
110
|
+
.filter((filePath) => /@Model/.test(context.helpers.readTextIfExists(filePath) || ""));
|
|
111
|
+
return {
|
|
112
|
+
score: files.length > 0 ? 86 : 0,
|
|
113
|
+
reasons: files.length > 0 ? ["Found SwiftData @Model classes"] : []
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
extract(context) {
|
|
117
|
+
const files = findImportFiles(context.paths, (filePath) => /\.swift$/i.test(filePath))
|
|
118
|
+
.filter((filePath) => /@Model/.test(context.helpers.readTextIfExists(filePath) || ""));
|
|
119
|
+
const findings = [];
|
|
120
|
+
const candidates = { entities: [], enums: [], relations: [], indexes: [] };
|
|
121
|
+
for (const filePath of files) {
|
|
122
|
+
const provenance = relativeTo(context.paths.repoRoot, filePath);
|
|
123
|
+
const blocks = parseSwiftModelBlocks(context.helpers.readTextIfExists(filePath) || "");
|
|
124
|
+
for (const block of blocks) {
|
|
125
|
+
const parsed = parseSwiftDataEntity(block, provenance);
|
|
126
|
+
candidates.entities.push(parsed.entity);
|
|
127
|
+
candidates.relations.push(...parsed.relations);
|
|
128
|
+
}
|
|
129
|
+
if (blocks.length > 0) {
|
|
130
|
+
findings.push({ kind: "swiftdata_models", file: provenance, entity_count: blocks.length });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
candidates.entities = dedupeCandidateRecords(candidates.entities, (record) => record.id_hint);
|
|
134
|
+
candidates.relations = dedupeCandidateRecords(candidates.relations, (record) => record.id_hint);
|
|
135
|
+
return { findings, candidates };
|
|
136
|
+
}
|
|
137
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonicalCandidateTerm,
|
|
3
|
+
dedupeCandidateRecords,
|
|
4
|
+
findImportFiles,
|
|
5
|
+
idHintify,
|
|
6
|
+
makeCandidateRecord,
|
|
7
|
+
relativeTo,
|
|
8
|
+
titleCase
|
|
9
|
+
} from "../../core/shared.js";
|
|
10
|
+
|
|
11
|
+
function screenKindFromId(id) {
|
|
12
|
+
if (/detail/i.test(id)) return "detail";
|
|
13
|
+
if (/settings/i.test(id)) return "settings";
|
|
14
|
+
if (/home|list/i.test(id)) return "list";
|
|
15
|
+
return "flow";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function entityIdFromScreenId(id) {
|
|
19
|
+
if (/pokemon/i.test(id) || /home|detail/i.test(id)) return "entity_pokemon";
|
|
20
|
+
if (/settings/i.test(id)) return null;
|
|
21
|
+
return `entity_${canonicalCandidateTerm(id)}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function parseNavHostEntries(text) {
|
|
25
|
+
const entries = [];
|
|
26
|
+
for (const match of String(text || "").matchAll(/entry<[^>]*?\.([A-Za-z_][A-Za-z0-9_]*)>\s*(?:\([\s\S]*?\))?\s*\{[\s\S]*?\b([A-Z][A-Za-z0-9_]*)\s*\(/g)) {
|
|
27
|
+
entries.push({
|
|
28
|
+
navKey: match[1],
|
|
29
|
+
composable: match[2]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return entries;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseNavigationActions(text) {
|
|
36
|
+
const actions = [];
|
|
37
|
+
for (const match of String(text || "").matchAll(/navigate(?:To)?\(?\s*(?:PokedexScreen\.)?([A-Z][A-Za-z0-9_]+)/g)) {
|
|
38
|
+
actions.push(match[1]);
|
|
39
|
+
}
|
|
40
|
+
return [...new Set(actions)];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function composeNavigationSummary(text) {
|
|
44
|
+
const source = String(text || "");
|
|
45
|
+
return {
|
|
46
|
+
shellKind:
|
|
47
|
+
/\bNavigationRail\b/.test(source) ? "sidebar"
|
|
48
|
+
: /\bNavigationBar\b/.test(source) ? "bottom_tabs"
|
|
49
|
+
: /\bScaffold\b|\bTopAppBar\b/.test(source) ? "topbar"
|
|
50
|
+
: null,
|
|
51
|
+
patterns: [
|
|
52
|
+
...new Set([
|
|
53
|
+
/\bNavHost\b|\bNavController\b/.test(source) ? "stack_navigation" : null,
|
|
54
|
+
/\bNavigationBar\b/.test(source) ? "bottom_tabs" : null,
|
|
55
|
+
/\bNavigationRail\b/.test(source) ? "navigation_rail" : null,
|
|
56
|
+
/\bTabRow\b|\bScrollableTabRow\b|\bHorizontalPager\b/.test(source) ? "tabs" : null
|
|
57
|
+
].filter(Boolean))
|
|
58
|
+
],
|
|
59
|
+
features: [
|
|
60
|
+
...new Set([
|
|
61
|
+
/\bModalBottomSheet\b|\bBottomSheetScaffold\b/.test(source) ? "sheet" : null,
|
|
62
|
+
/\bModalBottomSheet\b|\bBottomSheetScaffold\b/.test(source) ? "bottom_sheet" : null,
|
|
63
|
+
/\bFloatingActionButton\b|\bExtendedFloatingActionButton\b/.test(source) ? "fab" : null,
|
|
64
|
+
/\bpullRefresh\b|\bPullRefreshIndicator\b/.test(source) ? "pull_to_refresh" : null,
|
|
65
|
+
/\bSearchBar\b|\bSearchView\b/.test(source) ? "search" : null
|
|
66
|
+
].filter(Boolean))
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function mergeComposeSummaries(summaries) {
|
|
72
|
+
const shellKind =
|
|
73
|
+
summaries.find((entry) => entry.shellKind === "sidebar")?.shellKind
|
|
74
|
+
|| summaries.find((entry) => entry.shellKind === "bottom_tabs")?.shellKind
|
|
75
|
+
|| summaries.find((entry) => entry.shellKind === "topbar")?.shellKind
|
|
76
|
+
|| null;
|
|
77
|
+
return {
|
|
78
|
+
shellKind,
|
|
79
|
+
patterns: [...new Set(summaries.flatMap((entry) => entry.patterns || []))].sort(),
|
|
80
|
+
features: [...new Set(summaries.flatMap((entry) => entry.features || []))].sort()
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const androidComposeUiExtractor = {
|
|
85
|
+
id: "ui.android-compose",
|
|
86
|
+
track: "ui",
|
|
87
|
+
detect(context) {
|
|
88
|
+
const composeFiles = findImportFiles(context.paths, (filePath) => /\.kt$/i.test(filePath))
|
|
89
|
+
.filter((filePath) => /@Composable/.test(context.helpers.readTextIfExists(filePath) || ""));
|
|
90
|
+
const score = composeFiles.length > 0 ? 84 : 0;
|
|
91
|
+
return {
|
|
92
|
+
score,
|
|
93
|
+
reasons: score > 0 ? ["Found Android Jetpack Compose screens"] : []
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
extract(context) {
|
|
97
|
+
const navFiles = findImportFiles(context.paths, (filePath) => /NavHost\.kt$/i.test(filePath) || /navigation\/.+\.kt$/i.test(filePath));
|
|
98
|
+
const composeFiles = findImportFiles(context.paths, (filePath) => /\.kt$/i.test(filePath))
|
|
99
|
+
.filter((filePath) => /@Composable/.test(context.helpers.readTextIfExists(filePath) || ""));
|
|
100
|
+
const findings = [];
|
|
101
|
+
const candidates = { screens: [], routes: [], actions: [], stacks: [] };
|
|
102
|
+
const composableByName = new Map();
|
|
103
|
+
const composeSummaries = [];
|
|
104
|
+
|
|
105
|
+
for (const filePath of composeFiles) {
|
|
106
|
+
const text = context.helpers.readTextIfExists(filePath) || "";
|
|
107
|
+
composeSummaries.push({
|
|
108
|
+
provenance: relativeTo(context.paths.repoRoot, filePath),
|
|
109
|
+
...composeNavigationSummary(text)
|
|
110
|
+
});
|
|
111
|
+
for (const match of text.matchAll(/@Composable[\s\S]*?fun\s+([A-Z][A-Za-z0-9_]*)\s*\(/g)) {
|
|
112
|
+
composableByName.set(match[1], {
|
|
113
|
+
filePath,
|
|
114
|
+
text
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const aggregateSummary = mergeComposeSummaries(composeSummaries);
|
|
120
|
+
if (aggregateSummary.shellKind) {
|
|
121
|
+
candidates.actions.push(makeCandidateRecord({
|
|
122
|
+
kind: "ui_shell",
|
|
123
|
+
idHint: `${idHintify(aggregateSummary.shellKind)}_shell`,
|
|
124
|
+
label: titleCase(aggregateSummary.shellKind),
|
|
125
|
+
confidence: "medium",
|
|
126
|
+
sourceKind: "layout_code",
|
|
127
|
+
provenance: composeSummaries.map((entry) => entry.provenance),
|
|
128
|
+
track: "ui",
|
|
129
|
+
shell_kind: aggregateSummary.shellKind
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
for (const pattern of aggregateSummary.patterns) {
|
|
133
|
+
candidates.actions.push(makeCandidateRecord({
|
|
134
|
+
kind: "ui_navigation",
|
|
135
|
+
idHint: `compose_${idHintify(pattern)}`,
|
|
136
|
+
label: pattern,
|
|
137
|
+
confidence: "medium",
|
|
138
|
+
sourceKind: "layout_code",
|
|
139
|
+
provenance: composeSummaries.filter((entry) => entry.patterns.includes(pattern)).map((entry) => entry.provenance),
|
|
140
|
+
track: "ui",
|
|
141
|
+
navigation_pattern: pattern
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
for (const feature of aggregateSummary.features) {
|
|
145
|
+
candidates.actions.push(makeCandidateRecord({
|
|
146
|
+
kind: "ui_presentation",
|
|
147
|
+
idHint: `compose_${idHintify(feature)}`,
|
|
148
|
+
label: feature,
|
|
149
|
+
confidence: "low",
|
|
150
|
+
sourceKind: "layout_code",
|
|
151
|
+
provenance: composeSummaries.filter((entry) => entry.features.includes(feature)).map((entry) => entry.provenance),
|
|
152
|
+
track: "ui",
|
|
153
|
+
presentation: feature
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
for (const filePath of navFiles) {
|
|
158
|
+
const text = context.helpers.readTextIfExists(filePath) || "";
|
|
159
|
+
const provenanceFile = relativeTo(context.paths.repoRoot, filePath);
|
|
160
|
+
for (const entry of parseNavHostEntries(text)) {
|
|
161
|
+
const screenStem = canonicalCandidateTerm(entry.navKey.replace(/Screen$/, ""));
|
|
162
|
+
const screenId = /details/i.test(entry.navKey) ? "pokemon_detail" : /home/i.test(entry.navKey) ? "pokemon_list" : /settings/i.test(entry.navKey) ? "settings" : idHintify(screenStem);
|
|
163
|
+
const routePath = /detail/i.test(screenId) ? "/pokemon/:name" : screenId === "pokemon_list" ? "/pokemon" : screenId === "settings" ? "/settings" : `/${screenStem.replace(/_/g, "-")}`;
|
|
164
|
+
const entityId = entityIdFromScreenId(screenId);
|
|
165
|
+
candidates.screens.push(makeCandidateRecord({
|
|
166
|
+
kind: "screen",
|
|
167
|
+
idHint: screenId,
|
|
168
|
+
label: titleCase(screenId),
|
|
169
|
+
confidence: "high",
|
|
170
|
+
sourceKind: "route_code",
|
|
171
|
+
provenance: `${provenanceFile}#${entry.navKey}`,
|
|
172
|
+
track: "ui",
|
|
173
|
+
entity_id: entityId,
|
|
174
|
+
concept_id: entityId || `surface_${screenId}`,
|
|
175
|
+
screen_kind: screenKindFromId(screenId),
|
|
176
|
+
route_path: routePath
|
|
177
|
+
}));
|
|
178
|
+
candidates.routes.push(makeCandidateRecord({
|
|
179
|
+
kind: "ui_route",
|
|
180
|
+
idHint: `${screenId}_route`,
|
|
181
|
+
label: routePath,
|
|
182
|
+
confidence: "high",
|
|
183
|
+
sourceKind: "route_code",
|
|
184
|
+
provenance: `${provenanceFile}#${entry.navKey}`,
|
|
185
|
+
track: "ui",
|
|
186
|
+
screen_id: screenId,
|
|
187
|
+
entity_id: entityId,
|
|
188
|
+
concept_id: entityId || `surface_${screenId}`,
|
|
189
|
+
path: routePath
|
|
190
|
+
}));
|
|
191
|
+
|
|
192
|
+
const screenFile = composableByName.get(entry.composable);
|
|
193
|
+
const actions = parseNavigationActions(screenFile?.text || "");
|
|
194
|
+
for (const action of actions) {
|
|
195
|
+
const capabilityHint = /detail/i.test(action) ? "cap_get_pokemon" : /settings/i.test(action) ? null : "cap_list_pokemons";
|
|
196
|
+
if (!capabilityHint) continue;
|
|
197
|
+
candidates.actions.push(makeCandidateRecord({
|
|
198
|
+
kind: "ui_action",
|
|
199
|
+
idHint: `${screenId}_${idHintify(capabilityHint)}`,
|
|
200
|
+
label: capabilityHint,
|
|
201
|
+
confidence: "medium",
|
|
202
|
+
sourceKind: "route_code",
|
|
203
|
+
provenance: `${relativeTo(context.paths.repoRoot, screenFile?.filePath || filePath)}#${entry.composable}`,
|
|
204
|
+
track: "ui",
|
|
205
|
+
screen_id: screenId,
|
|
206
|
+
entity_id: entityId,
|
|
207
|
+
concept_id: entityId || `surface_${screenId}`,
|
|
208
|
+
capability_hint: capabilityHint,
|
|
209
|
+
prominence: "primary"
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (candidates.screens.length > 0) {
|
|
216
|
+
findings.push({
|
|
217
|
+
kind: "android_compose_navigation",
|
|
218
|
+
screen_count: candidates.screens.length,
|
|
219
|
+
route_count: candidates.routes.length
|
|
220
|
+
});
|
|
221
|
+
candidates.stacks.push("android_compose");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
|
|
225
|
+
candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
|
|
226
|
+
candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
|
|
227
|
+
candidates.stacks = [...new Set(candidates.stacks)].sort();
|
|
228
|
+
return { findings, candidates };
|
|
229
|
+
}
|
|
230
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { findImportFiles, relativeTo } from "../../core/shared.js";
|
|
4
|
+
|
|
5
|
+
function readPackageJson(context) {
|
|
6
|
+
const packageFile = findImportFiles(context.paths, (filePath) => /package\.json$/i.test(filePath))[0];
|
|
7
|
+
if (!packageFile) return null;
|
|
8
|
+
try {
|
|
9
|
+
return {
|
|
10
|
+
filePath: packageFile,
|
|
11
|
+
json: JSON.parse(context.helpers.readTextIfExists(packageFile) || "{}")
|
|
12
|
+
};
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function hasFrontendSignals(context) {
|
|
19
|
+
const packageMeta = readPackageJson(context);
|
|
20
|
+
const deps = {
|
|
21
|
+
...(packageMeta?.json?.dependencies || {}),
|
|
22
|
+
...(packageMeta?.json?.devDependencies || {})
|
|
23
|
+
};
|
|
24
|
+
if (deps.react || deps.next || deps["@remix-run/react"] || deps["@sveltejs/kit"] || deps.svelte || deps.vue || deps.nuxt) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
const uiFiles = findImportFiles(
|
|
28
|
+
context.paths,
|
|
29
|
+
(filePath) =>
|
|
30
|
+
/(app\/.+\/page\.(tsx|ts|jsx|js|mdx)|src\/App\.tsx|src\/routes\/.+\.(svelte|tsx|jsx)|pages\/.+\.(tsx|ts|jsx|js))$/i.test(filePath)
|
|
31
|
+
);
|
|
32
|
+
return uiFiles.length > 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const backendOnlyUiExtractor = {
|
|
36
|
+
id: "ui.backend-only",
|
|
37
|
+
track: "ui",
|
|
38
|
+
detect(context) {
|
|
39
|
+
const packageMeta = readPackageJson(context);
|
|
40
|
+
if (!packageMeta || hasFrontendSignals(context)) {
|
|
41
|
+
return { score: 0, reasons: [] };
|
|
42
|
+
}
|
|
43
|
+
const deps = {
|
|
44
|
+
...(packageMeta.json.dependencies || {}),
|
|
45
|
+
...(packageMeta.json.devDependencies || {})
|
|
46
|
+
};
|
|
47
|
+
const isBackend = deps.express || deps.fastify || deps.hono || deps["@nestjs/core"];
|
|
48
|
+
return {
|
|
49
|
+
score: isBackend ? 5 : 0,
|
|
50
|
+
reasons: isBackend ? ["Detected backend-only project with no supported frontend stack"] : []
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
extract(context) {
|
|
54
|
+
const packageMeta = readPackageJson(context);
|
|
55
|
+
const provenance = packageMeta ? relativeTo(context.paths.repoRoot, packageMeta.filePath) : relativeTo(context.paths.repoRoot, path.join(context.paths.workspaceRoot, "package.json"));
|
|
56
|
+
return {
|
|
57
|
+
findings: [{
|
|
58
|
+
kind: "backend_only_project",
|
|
59
|
+
file: provenance,
|
|
60
|
+
message: "No supported frontend stack detected in this workspace"
|
|
61
|
+
}],
|
|
62
|
+
candidates: {
|
|
63
|
+
screens: [],
|
|
64
|
+
routes: [],
|
|
65
|
+
actions: [],
|
|
66
|
+
stacks: ["backend_only"]
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|