kodingo-cli 1.1.2 → 1.1.3

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.
@@ -70,6 +70,7 @@ async function syncGraphCommand(options = {}) {
70
70
  fanOut: n.fanOut,
71
71
  centrality: n.centrality,
72
72
  rawCalls: n.rawCalls,
73
+ rawRoutes: n.rawRoutes,
73
74
  })),
74
75
  removed: i === 0 ? diff.removed : [],
75
76
  edgesAdded: edgeChunk.map(e => ({
@@ -142,6 +142,45 @@ function extractCallNames(node, acc = new Set()) {
142
142
  walk(node);
143
143
  return Array.from(acc);
144
144
  }
145
+ const ROUTE_HTTP_METHODS = new Set(["get", "post", "put", "patch", "delete", "all"]);
146
+ function extractRoutes(node) {
147
+ const routes = [];
148
+ function walk(n) {
149
+ if (!n || typeof n !== "object")
150
+ return;
151
+ if (n.type === "CallExpression") {
152
+ const callee = n.callee;
153
+ if (callee?.type === "MemberExpression" &&
154
+ ROUTE_HTTP_METHODS.has(callee.property?.name?.toLowerCase())) {
155
+ const firstArg = n.arguments?.[0];
156
+ if (firstArg?.type === "Literal" && typeof firstArg.value === "string" &&
157
+ firstArg.value.startsWith("/")) {
158
+ routes.push({ method: callee.property.name.toUpperCase(), path: firstArg.value });
159
+ }
160
+ if (firstArg?.type === "TemplateLiteral") {
161
+ const raw = firstArg.quasis?.map((q) => q.value?.raw ?? "").join("*") ?? "";
162
+ if (raw.startsWith("/")) {
163
+ routes.push({ method: callee.property.name.toUpperCase(), path: raw });
164
+ }
165
+ }
166
+ }
167
+ }
168
+ for (const key of Object.keys(n)) {
169
+ if (key === "parent")
170
+ continue;
171
+ const child = n[key];
172
+ if (Array.isArray(child)) {
173
+ for (const c of child)
174
+ walk(c);
175
+ }
176
+ else if (child && typeof child === "object" && child.type) {
177
+ walk(child);
178
+ }
179
+ }
180
+ }
181
+ walk(node);
182
+ return routes;
183
+ }
145
184
  async function parseTypeScript(filePath, source) {
146
185
  try {
147
186
  const parse = tsParse;
@@ -173,6 +212,7 @@ async function parseTypeScript(filePath, source) {
173
212
  body,
174
213
  fingerprint: computeFingerprint(body),
175
214
  calls: extractCallNames(node.body),
215
+ routes: extractRoutes(node.body),
176
216
  imports: fileImports,
177
217
  });
178
218
  }
@@ -190,6 +230,7 @@ async function parseTypeScript(filePath, source) {
190
230
  body,
191
231
  fingerprint: computeFingerprint(body),
192
232
  calls: extractCallNames(node.init.body),
233
+ routes: extractRoutes(node.init.body),
193
234
  imports: fileImports,
194
235
  });
195
236
  }
@@ -207,6 +248,7 @@ async function parseTypeScript(filePath, source) {
207
248
  body,
208
249
  fingerprint: computeFingerprint(body),
209
250
  calls: extractCallNames(node.body),
251
+ routes: extractRoutes(node.body),
210
252
  imports: fileImports,
211
253
  });
212
254
  // Visit methods inside the class
@@ -225,6 +267,7 @@ async function parseTypeScript(filePath, source) {
225
267
  body: mBody,
226
268
  fingerprint: computeFingerprint(mBody),
227
269
  calls: extractCallNames(member.value?.body),
270
+ routes: extractRoutes(member.value?.body),
228
271
  imports: fileImports,
229
272
  });
230
273
  }
@@ -299,6 +342,7 @@ function parseStructural(filePath, source, patterns) {
299
342
  body,
300
343
  fingerprint: computeFingerprint(body),
301
344
  calls: extractCallNamesRegex(body),
345
+ routes: [],
302
346
  imports: [],
303
347
  });
304
348
  break;
@@ -344,6 +388,7 @@ function parsePython(filePath, source) {
344
388
  body,
345
389
  fingerprint: computeFingerprint(body),
346
390
  calls: extractCallNamesRegex(body),
391
+ routes: [],
347
392
  imports: [],
348
393
  });
349
394
  }
@@ -302,6 +302,7 @@ async function buildGraph(repoRoot) {
302
302
  fanOut: 0,
303
303
  centrality: 0,
304
304
  rawCalls: sym.calls ?? [],
305
+ rawRoutes: sym.routes ?? [],
305
306
  };
306
307
  }
307
308
  const tsFiles = symbols
@@ -260,6 +260,7 @@ async function parseWithTreeSitter(filePath, source) {
260
260
  body,
261
261
  fingerprint: (0, ast_parser_1.computeFingerprint)(body),
262
262
  calls: extractCallNamesTs(node, config),
263
+ routes: [],
263
264
  imports: fileImports,
264
265
  });
265
266
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kodingo-cli",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Kodingo CLI",
5
5
  "license": "MIT",
6
6
  "private": false,