@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/{chunk-UI3AFJAF.js → chunk-LN75Z624.js} +103 -2
- package/dist/chunk-LN75Z624.js.map +1 -0
- package/dist/{chunk-YVZRBT4C.js → chunk-OVRVDSUO.js} +2 -2
- package/dist/cli.cjs +102 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/index.cjs +102 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/neatd.cjs +102 -1
- package/dist/neatd.cjs.map +1 -1
- package/dist/neatd.js +2 -2
- package/dist/server.cjs +102 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-UI3AFJAF.js.map +0 -1
- /package/dist/{chunk-YVZRBT4C.js.map → chunk-OVRVDSUO.js.map} +0 -0
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
startStalenessLoop,
|
|
21
21
|
touchLastSeen,
|
|
22
22
|
writeAtomically
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-LN75Z624.js";
|
|
24
24
|
import {
|
|
25
25
|
assertBindAuthority,
|
|
26
26
|
buildOtelReceiver,
|
|
@@ -837,4 +837,4 @@ export {
|
|
|
837
837
|
resolveHost,
|
|
838
838
|
startDaemon
|
|
839
839
|
};
|
|
840
|
-
//# sourceMappingURL=chunk-
|
|
840
|
+
//# sourceMappingURL=chunk-OVRVDSUO.js.map
|
package/dist/cli.cjs
CHANGED
|
@@ -3065,6 +3065,7 @@ var ROUTER_METHODS = /* @__PURE__ */ new Set([
|
|
|
3065
3065
|
"all"
|
|
3066
3066
|
]);
|
|
3067
3067
|
var NEXT_APP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
3068
|
+
var NET_HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
3068
3069
|
var JS_ROUTE_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx"]);
|
|
3069
3070
|
function goRouterRoutesFromSource(source, parser, framework) {
|
|
3070
3071
|
const tree = parseSource2(parser, source);
|
|
@@ -3118,6 +3119,101 @@ function echoRoutesFromSource(source, parser) {
|
|
|
3118
3119
|
function fiberRoutesFromSource(source, parser) {
|
|
3119
3120
|
return goRouterRoutesFromSource(source, parser, "fiber");
|
|
3120
3121
|
}
|
|
3122
|
+
function chiRoutesFromSource(source, parser) {
|
|
3123
|
+
const tree = parseSource2(parser, source);
|
|
3124
|
+
const out = [];
|
|
3125
|
+
chiWalk(tree.rootNode, "", out);
|
|
3126
|
+
return out;
|
|
3127
|
+
}
|
|
3128
|
+
function stripChiRegex(path82) {
|
|
3129
|
+
return path82.replace(/\{([^{}:]+):[^{}]*\}/g, "{$1}");
|
|
3130
|
+
}
|
|
3131
|
+
function chiWalk(node, prefix, out) {
|
|
3132
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
3133
|
+
const child = node.namedChild(i);
|
|
3134
|
+
if (child) chiHandle(child, prefix, out);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
function chiHandle(node, prefix, out) {
|
|
3138
|
+
if (node.type === "call_expression") {
|
|
3139
|
+
const fn = node.childForFieldName("function");
|
|
3140
|
+
if (fn?.type === "selector_expression") {
|
|
3141
|
+
const field = fn.childForFieldName("field")?.text;
|
|
3142
|
+
const args = node.childForFieldName("arguments");
|
|
3143
|
+
if (field === "Route") {
|
|
3144
|
+
const leaf = goStringLiteral(args?.namedChild(0));
|
|
3145
|
+
const closure = args?.namedChild(1);
|
|
3146
|
+
if (leaf !== null && closure?.type === "func_literal") {
|
|
3147
|
+
const body = closure.childForFieldName("body");
|
|
3148
|
+
if (body) chiWalk(body, prefix + leaf, out);
|
|
3149
|
+
}
|
|
3150
|
+
return;
|
|
3151
|
+
}
|
|
3152
|
+
if (field === "Group") {
|
|
3153
|
+
const closure = args?.namedChild(0);
|
|
3154
|
+
if (closure?.type === "func_literal") {
|
|
3155
|
+
const body = closure.childForFieldName("body");
|
|
3156
|
+
if (body) chiWalk(body, prefix, out);
|
|
3157
|
+
}
|
|
3158
|
+
return;
|
|
3159
|
+
}
|
|
3160
|
+
if (field === "Mount") {
|
|
3161
|
+
return;
|
|
3162
|
+
}
|
|
3163
|
+
if (field && ROUTER_METHODS.has(field.toLowerCase())) {
|
|
3164
|
+
const leaf = goStringLiteral(args?.namedChild(0));
|
|
3165
|
+
if (leaf !== null) {
|
|
3166
|
+
out.push({
|
|
3167
|
+
method: field.toUpperCase(),
|
|
3168
|
+
pathTemplate: canonicalizeTemplate(stripChiRegex(prefix + leaf)),
|
|
3169
|
+
line: node.startPosition.row + 1,
|
|
3170
|
+
framework: "chi"
|
|
3171
|
+
});
|
|
3172
|
+
}
|
|
3173
|
+
return;
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
chiWalk(node, prefix, out);
|
|
3178
|
+
}
|
|
3179
|
+
function netHttpRoutesFromSource(source, parser) {
|
|
3180
|
+
const tree = parseSource2(parser, source);
|
|
3181
|
+
if (!goImportsNetHttp(tree.rootNode)) return [];
|
|
3182
|
+
const out = [];
|
|
3183
|
+
walk(tree.rootNode, (node) => {
|
|
3184
|
+
if (node.type !== "call_expression") return;
|
|
3185
|
+
const fn = node.childForFieldName("function");
|
|
3186
|
+
if (fn?.type !== "selector_expression") return;
|
|
3187
|
+
const field = fn.childForFieldName("field")?.text;
|
|
3188
|
+
if (field !== "HandleFunc" && field !== "Handle") return;
|
|
3189
|
+
const leaf = goStringLiteral(node.childForFieldName("arguments")?.namedChild(0));
|
|
3190
|
+
if (leaf === null) return;
|
|
3191
|
+
const sp = leaf.indexOf(" ");
|
|
3192
|
+
if (sp < 0) return;
|
|
3193
|
+
const method = leaf.slice(0, sp);
|
|
3194
|
+
const rest = leaf.slice(sp + 1);
|
|
3195
|
+
if (!NET_HTTP_METHODS.has(method)) return;
|
|
3196
|
+
if (!rest.startsWith("/")) return;
|
|
3197
|
+
out.push({
|
|
3198
|
+
method,
|
|
3199
|
+
pathTemplate: canonicalizeTemplate(rest),
|
|
3200
|
+
line: node.startPosition.row + 1,
|
|
3201
|
+
framework: "net/http"
|
|
3202
|
+
});
|
|
3203
|
+
});
|
|
3204
|
+
return out;
|
|
3205
|
+
}
|
|
3206
|
+
function goImportsNetHttp(root) {
|
|
3207
|
+
let found = false;
|
|
3208
|
+
walk(root, (node) => {
|
|
3209
|
+
if (found || node.type !== "import_spec") return;
|
|
3210
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
3211
|
+
const child = node.namedChild(i);
|
|
3212
|
+
if (goStringLiteral(child) === "net/http") found = true;
|
|
3213
|
+
}
|
|
3214
|
+
});
|
|
3215
|
+
return found;
|
|
3216
|
+
}
|
|
3121
3217
|
var FASTAPI_METHODS = /* @__PURE__ */ new Set(["get", "post", "put", "patch", "delete", "options", "head", "trace"]);
|
|
3122
3218
|
var NESTJS_METHODS = /* @__PURE__ */ new Map([
|
|
3123
3219
|
["Get", "GET"],
|
|
@@ -4383,9 +4479,11 @@ async function addRoutes(graph, services) {
|
|
|
4383
4479
|
const hasGin = deps["github.com/gin-gonic/gin"] !== void 0;
|
|
4384
4480
|
const hasEcho = deps["github.com/labstack/echo/v4"] !== void 0 || deps["github.com/labstack/echo"] !== void 0;
|
|
4385
4481
|
const hasFiber = deps["github.com/gofiber/fiber/v2"] !== void 0 || deps["github.com/gofiber/fiber/v3"] !== void 0;
|
|
4482
|
+
const hasChi = deps["github.com/go-chi/chi/v5"] !== void 0 || deps["github.com/go-chi/chi"] !== void 0;
|
|
4483
|
+
const isGoService = service.node.language === "go";
|
|
4386
4484
|
const hasRails = deps["rails"] !== void 0;
|
|
4387
4485
|
const hasLaravel = deps["laravel/framework"] !== void 0;
|
|
4388
|
-
if (!hasExpress && !hasFastify && !hasHono && !hasNext && !hasNestjs && !hasFastapi && !hasFlask && !hasDjango && !hasGin && !hasEcho && !hasFiber && !hasRails && !hasLaravel)
|
|
4486
|
+
if (!hasExpress && !hasFastify && !hasHono && !hasNext && !hasNestjs && !hasFastapi && !hasFlask && !hasDjango && !hasGin && !hasEcho && !hasFiber && !hasChi && !isGoService && !hasRails && !hasLaravel)
|
|
4389
4487
|
continue;
|
|
4390
4488
|
const files = await loadSourceFiles(service.dir);
|
|
4391
4489
|
const mountPrefixes = hasExpress ? await expressMountPrefixes(files, service.dir, await loadTsPathConfig(service.dir)) : /* @__PURE__ */ new Map();
|
|
@@ -4412,7 +4510,9 @@ async function addRoutes(graph, services) {
|
|
|
4412
4510
|
if (hasGin) routes = ginRoutesFromSource(file.content, goParser);
|
|
4413
4511
|
else if (hasEcho) routes = echoRoutesFromSource(file.content, goParser);
|
|
4414
4512
|
else if (hasFiber) routes = fiberRoutesFromSource(file.content, goParser);
|
|
4513
|
+
else if (hasChi) routes = chiRoutesFromSource(file.content, goParser);
|
|
4415
4514
|
else routes = [];
|
|
4515
|
+
routes = routes.concat(netHttpRoutesFromSource(file.content, goParser));
|
|
4416
4516
|
} else if (isPy) {
|
|
4417
4517
|
routes = hasFastapi || hasFlask ? pythonRoutesFromSource(file.content, pyParser, hasFastapi ? "fastapi" : "flask") : [];
|
|
4418
4518
|
if (hasDjango) routes = routes.concat(djangoRoutesFromSource(file.content, pyParser));
|
|
@@ -6026,6 +6126,7 @@ function goFramework(deps) {
|
|
|
6026
6126
|
if (deps["github.com/gin-gonic/gin"]) return "gin";
|
|
6027
6127
|
if (deps["github.com/labstack/echo/v4"] || deps["github.com/labstack/echo"]) return "echo";
|
|
6028
6128
|
if (deps["github.com/gofiber/fiber/v2"] || deps["github.com/gofiber/fiber/v3"]) return "fiber";
|
|
6129
|
+
if (deps["github.com/go-chi/chi/v5"] || deps["github.com/go-chi/chi"]) return "chi";
|
|
6029
6130
|
return void 0;
|
|
6030
6131
|
}
|
|
6031
6132
|
async function discoverGoService(scanPath, dir) {
|