@neat.is/core 0.7.7 → 0.7.8

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/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  resolveHost,
7
7
  resolveNeatVersion,
8
8
  writeDaemonRecord
9
- } from "./chunk-YVZRBT4C.js";
9
+ } from "./chunk-OVRVDSUO.js";
10
10
  import {
11
11
  buildSearchIndex
12
12
  } from "./chunk-BIY46Q6U.js";
@@ -74,7 +74,7 @@ import {
74
74
  startStalenessLoop,
75
75
  upsertConnectorEntry,
76
76
  validateConnectorEntry
77
- } from "./chunk-UI3AFJAF.js";
77
+ } from "./chunk-LN75Z624.js";
78
78
  import {
79
79
  startOtelGrpcReceiver
80
80
  } from "./chunk-4GCV46AP.js";
package/dist/index.cjs CHANGED
@@ -3045,6 +3045,7 @@ var ROUTER_METHODS = /* @__PURE__ */ new Set([
3045
3045
  "all"
3046
3046
  ]);
3047
3047
  var NEXT_APP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
3048
+ var NET_HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
3048
3049
  var JS_ROUTE_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx"]);
3049
3050
  function goRouterRoutesFromSource(source, parser, framework) {
3050
3051
  const tree = parseSource2(parser, source);
@@ -3098,6 +3099,101 @@ function echoRoutesFromSource(source, parser) {
3098
3099
  function fiberRoutesFromSource(source, parser) {
3099
3100
  return goRouterRoutesFromSource(source, parser, "fiber");
3100
3101
  }
3102
+ function chiRoutesFromSource(source, parser) {
3103
+ const tree = parseSource2(parser, source);
3104
+ const out = [];
3105
+ chiWalk(tree.rootNode, "", out);
3106
+ return out;
3107
+ }
3108
+ function stripChiRegex(path68) {
3109
+ return path68.replace(/\{([^{}:]+):[^{}]*\}/g, "{$1}");
3110
+ }
3111
+ function chiWalk(node, prefix, out) {
3112
+ for (let i = 0; i < node.namedChildCount; i++) {
3113
+ const child = node.namedChild(i);
3114
+ if (child) chiHandle(child, prefix, out);
3115
+ }
3116
+ }
3117
+ function chiHandle(node, prefix, out) {
3118
+ if (node.type === "call_expression") {
3119
+ const fn = node.childForFieldName("function");
3120
+ if (fn?.type === "selector_expression") {
3121
+ const field = fn.childForFieldName("field")?.text;
3122
+ const args = node.childForFieldName("arguments");
3123
+ if (field === "Route") {
3124
+ const leaf = goStringLiteral(args?.namedChild(0));
3125
+ const closure = args?.namedChild(1);
3126
+ if (leaf !== null && closure?.type === "func_literal") {
3127
+ const body = closure.childForFieldName("body");
3128
+ if (body) chiWalk(body, prefix + leaf, out);
3129
+ }
3130
+ return;
3131
+ }
3132
+ if (field === "Group") {
3133
+ const closure = args?.namedChild(0);
3134
+ if (closure?.type === "func_literal") {
3135
+ const body = closure.childForFieldName("body");
3136
+ if (body) chiWalk(body, prefix, out);
3137
+ }
3138
+ return;
3139
+ }
3140
+ if (field === "Mount") {
3141
+ return;
3142
+ }
3143
+ if (field && ROUTER_METHODS.has(field.toLowerCase())) {
3144
+ const leaf = goStringLiteral(args?.namedChild(0));
3145
+ if (leaf !== null) {
3146
+ out.push({
3147
+ method: field.toUpperCase(),
3148
+ pathTemplate: canonicalizeTemplate(stripChiRegex(prefix + leaf)),
3149
+ line: node.startPosition.row + 1,
3150
+ framework: "chi"
3151
+ });
3152
+ }
3153
+ return;
3154
+ }
3155
+ }
3156
+ }
3157
+ chiWalk(node, prefix, out);
3158
+ }
3159
+ function netHttpRoutesFromSource(source, parser) {
3160
+ const tree = parseSource2(parser, source);
3161
+ if (!goImportsNetHttp(tree.rootNode)) return [];
3162
+ const out = [];
3163
+ walk(tree.rootNode, (node) => {
3164
+ if (node.type !== "call_expression") return;
3165
+ const fn = node.childForFieldName("function");
3166
+ if (fn?.type !== "selector_expression") return;
3167
+ const field = fn.childForFieldName("field")?.text;
3168
+ if (field !== "HandleFunc" && field !== "Handle") return;
3169
+ const leaf = goStringLiteral(node.childForFieldName("arguments")?.namedChild(0));
3170
+ if (leaf === null) return;
3171
+ const sp = leaf.indexOf(" ");
3172
+ if (sp < 0) return;
3173
+ const method = leaf.slice(0, sp);
3174
+ const rest = leaf.slice(sp + 1);
3175
+ if (!NET_HTTP_METHODS.has(method)) return;
3176
+ if (!rest.startsWith("/")) return;
3177
+ out.push({
3178
+ method,
3179
+ pathTemplate: canonicalizeTemplate(rest),
3180
+ line: node.startPosition.row + 1,
3181
+ framework: "net/http"
3182
+ });
3183
+ });
3184
+ return out;
3185
+ }
3186
+ function goImportsNetHttp(root) {
3187
+ let found = false;
3188
+ walk(root, (node) => {
3189
+ if (found || node.type !== "import_spec") return;
3190
+ for (let i = 0; i < node.namedChildCount; i++) {
3191
+ const child = node.namedChild(i);
3192
+ if (goStringLiteral(child) === "net/http") found = true;
3193
+ }
3194
+ });
3195
+ return found;
3196
+ }
3101
3197
  var FASTAPI_METHODS = /* @__PURE__ */ new Set(["get", "post", "put", "patch", "delete", "options", "head", "trace"]);
3102
3198
  var NESTJS_METHODS = /* @__PURE__ */ new Map([
3103
3199
  ["Get", "GET"],
@@ -4363,9 +4459,11 @@ async function addRoutes(graph, services) {
4363
4459
  const hasGin = deps["github.com/gin-gonic/gin"] !== void 0;
4364
4460
  const hasEcho = deps["github.com/labstack/echo/v4"] !== void 0 || deps["github.com/labstack/echo"] !== void 0;
4365
4461
  const hasFiber = deps["github.com/gofiber/fiber/v2"] !== void 0 || deps["github.com/gofiber/fiber/v3"] !== void 0;
4462
+ const hasChi = deps["github.com/go-chi/chi/v5"] !== void 0 || deps["github.com/go-chi/chi"] !== void 0;
4463
+ const isGoService = service.node.language === "go";
4366
4464
  const hasRails = deps["rails"] !== void 0;
4367
4465
  const hasLaravel = deps["laravel/framework"] !== void 0;
4368
- if (!hasExpress && !hasFastify && !hasHono && !hasNext && !hasNestjs && !hasFastapi && !hasFlask && !hasDjango && !hasGin && !hasEcho && !hasFiber && !hasRails && !hasLaravel)
4466
+ if (!hasExpress && !hasFastify && !hasHono && !hasNext && !hasNestjs && !hasFastapi && !hasFlask && !hasDjango && !hasGin && !hasEcho && !hasFiber && !hasChi && !isGoService && !hasRails && !hasLaravel)
4369
4467
  continue;
4370
4468
  const files = await loadSourceFiles(service.dir);
4371
4469
  const mountPrefixes = hasExpress ? await expressMountPrefixes(files, service.dir, await loadTsPathConfig(service.dir)) : /* @__PURE__ */ new Map();
@@ -4392,7 +4490,9 @@ async function addRoutes(graph, services) {
4392
4490
  if (hasGin) routes = ginRoutesFromSource(file.content, goParser);
4393
4491
  else if (hasEcho) routes = echoRoutesFromSource(file.content, goParser);
4394
4492
  else if (hasFiber) routes = fiberRoutesFromSource(file.content, goParser);
4493
+ else if (hasChi) routes = chiRoutesFromSource(file.content, goParser);
4395
4494
  else routes = [];
4495
+ routes = routes.concat(netHttpRoutesFromSource(file.content, goParser));
4396
4496
  } else if (isPy) {
4397
4497
  routes = hasFastapi || hasFlask ? pythonRoutesFromSource(file.content, pyParser, hasFastapi ? "fastapi" : "flask") : [];
4398
4498
  if (hasDjango) routes = routes.concat(djangoRoutesFromSource(file.content, pyParser));
@@ -6006,6 +6106,7 @@ function goFramework(deps) {
6006
6106
  if (deps["github.com/gin-gonic/gin"]) return "gin";
6007
6107
  if (deps["github.com/labstack/echo/v4"] || deps["github.com/labstack/echo"]) return "echo";
6008
6108
  if (deps["github.com/gofiber/fiber/v2"] || deps["github.com/gofiber/fiber/v3"]) return "fiber";
6109
+ if (deps["github.com/go-chi/chi/v5"] || deps["github.com/go-chi/chi"]) return "chi";
6009
6110
  return void 0;
6010
6111
  }
6011
6112
  async function discoverGoService(scanPath, dir) {