@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/neatd.js CHANGED
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  reconcileDaemonRecordSync,
4
4
  startDaemon
5
- } from "./chunk-YVZRBT4C.js";
5
+ } from "./chunk-OVRVDSUO.js";
6
6
  import {
7
7
  listProjects,
8
8
  registryPath
9
- } from "./chunk-UI3AFJAF.js";
9
+ } from "./chunk-LN75Z624.js";
10
10
  import {
11
11
  BindAuthorityError,
12
12
  __require
package/dist/server.cjs CHANGED
@@ -2796,6 +2796,7 @@ var ROUTER_METHODS = /* @__PURE__ */ new Set([
2796
2796
  "all"
2797
2797
  ]);
2798
2798
  var NEXT_APP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
2799
+ var NET_HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
2799
2800
  var JS_ROUTE_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx"]);
2800
2801
  function goRouterRoutesFromSource(source, parser, framework) {
2801
2802
  const tree = parseSource2(parser, source);
@@ -2849,6 +2850,101 @@ function echoRoutesFromSource(source, parser) {
2849
2850
  function fiberRoutesFromSource(source, parser) {
2850
2851
  return goRouterRoutesFromSource(source, parser, "fiber");
2851
2852
  }
2853
+ function chiRoutesFromSource(source, parser) {
2854
+ const tree = parseSource2(parser, source);
2855
+ const out = [];
2856
+ chiWalk(tree.rootNode, "", out);
2857
+ return out;
2858
+ }
2859
+ function stripChiRegex(path68) {
2860
+ return path68.replace(/\{([^{}:]+):[^{}]*\}/g, "{$1}");
2861
+ }
2862
+ function chiWalk(node, prefix, out) {
2863
+ for (let i = 0; i < node.namedChildCount; i++) {
2864
+ const child = node.namedChild(i);
2865
+ if (child) chiHandle(child, prefix, out);
2866
+ }
2867
+ }
2868
+ function chiHandle(node, prefix, out) {
2869
+ if (node.type === "call_expression") {
2870
+ const fn = node.childForFieldName("function");
2871
+ if (fn?.type === "selector_expression") {
2872
+ const field = fn.childForFieldName("field")?.text;
2873
+ const args = node.childForFieldName("arguments");
2874
+ if (field === "Route") {
2875
+ const leaf = goStringLiteral(args?.namedChild(0));
2876
+ const closure = args?.namedChild(1);
2877
+ if (leaf !== null && closure?.type === "func_literal") {
2878
+ const body = closure.childForFieldName("body");
2879
+ if (body) chiWalk(body, prefix + leaf, out);
2880
+ }
2881
+ return;
2882
+ }
2883
+ if (field === "Group") {
2884
+ const closure = args?.namedChild(0);
2885
+ if (closure?.type === "func_literal") {
2886
+ const body = closure.childForFieldName("body");
2887
+ if (body) chiWalk(body, prefix, out);
2888
+ }
2889
+ return;
2890
+ }
2891
+ if (field === "Mount") {
2892
+ return;
2893
+ }
2894
+ if (field && ROUTER_METHODS.has(field.toLowerCase())) {
2895
+ const leaf = goStringLiteral(args?.namedChild(0));
2896
+ if (leaf !== null) {
2897
+ out.push({
2898
+ method: field.toUpperCase(),
2899
+ pathTemplate: canonicalizeTemplate(stripChiRegex(prefix + leaf)),
2900
+ line: node.startPosition.row + 1,
2901
+ framework: "chi"
2902
+ });
2903
+ }
2904
+ return;
2905
+ }
2906
+ }
2907
+ }
2908
+ chiWalk(node, prefix, out);
2909
+ }
2910
+ function netHttpRoutesFromSource(source, parser) {
2911
+ const tree = parseSource2(parser, source);
2912
+ if (!goImportsNetHttp(tree.rootNode)) return [];
2913
+ const out = [];
2914
+ walk(tree.rootNode, (node) => {
2915
+ if (node.type !== "call_expression") return;
2916
+ const fn = node.childForFieldName("function");
2917
+ if (fn?.type !== "selector_expression") return;
2918
+ const field = fn.childForFieldName("field")?.text;
2919
+ if (field !== "HandleFunc" && field !== "Handle") return;
2920
+ const leaf = goStringLiteral(node.childForFieldName("arguments")?.namedChild(0));
2921
+ if (leaf === null) return;
2922
+ const sp = leaf.indexOf(" ");
2923
+ if (sp < 0) return;
2924
+ const method = leaf.slice(0, sp);
2925
+ const rest = leaf.slice(sp + 1);
2926
+ if (!NET_HTTP_METHODS.has(method)) return;
2927
+ if (!rest.startsWith("/")) return;
2928
+ out.push({
2929
+ method,
2930
+ pathTemplate: canonicalizeTemplate(rest),
2931
+ line: node.startPosition.row + 1,
2932
+ framework: "net/http"
2933
+ });
2934
+ });
2935
+ return out;
2936
+ }
2937
+ function goImportsNetHttp(root) {
2938
+ let found = false;
2939
+ walk(root, (node) => {
2940
+ if (found || node.type !== "import_spec") return;
2941
+ for (let i = 0; i < node.namedChildCount; i++) {
2942
+ const child = node.namedChild(i);
2943
+ if (goStringLiteral(child) === "net/http") found = true;
2944
+ }
2945
+ });
2946
+ return found;
2947
+ }
2852
2948
  var FASTAPI_METHODS = /* @__PURE__ */ new Set(["get", "post", "put", "patch", "delete", "options", "head", "trace"]);
2853
2949
  var NESTJS_METHODS = /* @__PURE__ */ new Map([
2854
2950
  ["Get", "GET"],
@@ -4114,9 +4210,11 @@ async function addRoutes(graph, services) {
4114
4210
  const hasGin = deps["github.com/gin-gonic/gin"] !== void 0;
4115
4211
  const hasEcho = deps["github.com/labstack/echo/v4"] !== void 0 || deps["github.com/labstack/echo"] !== void 0;
4116
4212
  const hasFiber = deps["github.com/gofiber/fiber/v2"] !== void 0 || deps["github.com/gofiber/fiber/v3"] !== void 0;
4213
+ const hasChi = deps["github.com/go-chi/chi/v5"] !== void 0 || deps["github.com/go-chi/chi"] !== void 0;
4214
+ const isGoService = service.node.language === "go";
4117
4215
  const hasRails = deps["rails"] !== void 0;
4118
4216
  const hasLaravel = deps["laravel/framework"] !== void 0;
4119
- if (!hasExpress && !hasFastify && !hasHono && !hasNext && !hasNestjs && !hasFastapi && !hasFlask && !hasDjango && !hasGin && !hasEcho && !hasFiber && !hasRails && !hasLaravel)
4217
+ if (!hasExpress && !hasFastify && !hasHono && !hasNext && !hasNestjs && !hasFastapi && !hasFlask && !hasDjango && !hasGin && !hasEcho && !hasFiber && !hasChi && !isGoService && !hasRails && !hasLaravel)
4120
4218
  continue;
4121
4219
  const files = await loadSourceFiles(service.dir);
4122
4220
  const mountPrefixes = hasExpress ? await expressMountPrefixes(files, service.dir, await loadTsPathConfig(service.dir)) : /* @__PURE__ */ new Map();
@@ -4143,7 +4241,9 @@ async function addRoutes(graph, services) {
4143
4241
  if (hasGin) routes = ginRoutesFromSource(file.content, goParser);
4144
4242
  else if (hasEcho) routes = echoRoutesFromSource(file.content, goParser);
4145
4243
  else if (hasFiber) routes = fiberRoutesFromSource(file.content, goParser);
4244
+ else if (hasChi) routes = chiRoutesFromSource(file.content, goParser);
4146
4245
  else routes = [];
4246
+ routes = routes.concat(netHttpRoutesFromSource(file.content, goParser));
4147
4247
  } else if (isPy) {
4148
4248
  routes = hasFastapi || hasFlask ? pythonRoutesFromSource(file.content, pyParser, hasFastapi ? "fastapi" : "flask") : [];
4149
4249
  if (hasDjango) routes = routes.concat(djangoRoutesFromSource(file.content, pyParser));
@@ -6585,6 +6685,7 @@ function goFramework(deps) {
6585
6685
  if (deps["github.com/gin-gonic/gin"]) return "gin";
6586
6686
  if (deps["github.com/labstack/echo/v4"] || deps["github.com/labstack/echo"]) return "echo";
6587
6687
  if (deps["github.com/gofiber/fiber/v2"] || deps["github.com/gofiber/fiber/v3"]) return "fiber";
6688
+ if (deps["github.com/go-chi/chi/v5"] || deps["github.com/go-chi/chi"]) return "chi";
6588
6689
  return void 0;
6589
6690
  }
6590
6691
  async function discoverGoService(scanPath, dir) {