@neat.is/core 0.5.2 → 0.5.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.
package/dist/neatd.js CHANGED
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  reconcileDaemonRecordSync,
4
4
  startDaemon
5
- } from "./chunk-DPEPI2N6.js";
5
+ } from "./chunk-X2AMX3QZ.js";
6
6
  import {
7
7
  listProjects,
8
8
  registryPath
9
- } from "./chunk-BI3XKGVG.js";
9
+ } from "./chunk-GJHEZC5K.js";
10
10
  import {
11
11
  BindAuthorityError,
12
12
  __require
package/dist/server.cjs CHANGED
@@ -777,11 +777,42 @@ async function readPackageJson(scanPath) {
777
777
  const raw = await import_node_fs2.promises.readFile(pkgPath, "utf8");
778
778
  return JSON.parse(raw);
779
779
  }
780
+ var HOOK_WALK_SKIP_DIRS = /* @__PURE__ */ new Set([
781
+ "node_modules",
782
+ "dist",
783
+ "build",
784
+ "out",
785
+ "coverage",
786
+ "neat-out"
787
+ ]);
780
788
  async function findHookFiles(scanPath) {
781
- const entries = await import_node_fs2.promises.readdir(scanPath);
782
- return entries.filter(
783
- (e) => (e.startsWith("instrumentation") || e.startsWith("otel-init")) && /\.(ts|js)$/.test(e)
784
- ).sort();
789
+ const found = [];
790
+ const walk3 = async (dir) => {
791
+ const entries = await import_node_fs2.promises.readdir(dir, { withFileTypes: true }).catch(() => []);
792
+ for (const entry of entries) {
793
+ if (entry.isDirectory()) {
794
+ if (entry.name.startsWith(".") || HOOK_WALK_SKIP_DIRS.has(entry.name)) continue;
795
+ await walk3(import_node_path2.default.join(dir, entry.name));
796
+ } else if (entry.isFile()) {
797
+ if ((entry.name.startsWith("instrumentation") || entry.name.startsWith("otel-init")) && /\.(ts|js|cjs|mjs)$/.test(entry.name)) {
798
+ const rel = import_node_path2.default.relative(scanPath, import_node_path2.default.join(dir, entry.name));
799
+ found.push(rel.split(import_node_path2.default.sep).join("/"));
800
+ }
801
+ }
802
+ }
803
+ };
804
+ await walk3(scanPath);
805
+ return found.sort();
806
+ }
807
+ async function pickPrimaryHookFile(scanPath, hookFiles, snippet2) {
808
+ let fallback = null;
809
+ for (const file of hookFiles) {
810
+ const content = await import_node_fs2.promises.readFile(import_node_path2.default.join(scanPath, file), "utf8");
811
+ const patched = splicedContent(content, snippet2);
812
+ if (patched !== null) return { file, content, patched };
813
+ if (fallback === null) fallback = { file, content };
814
+ }
815
+ return { file: fallback.file, content: fallback.content, patched: null };
785
816
  }
786
817
  function extendLogPath() {
787
818
  return process.env.NEAT_EXTEND_LOG ?? import_node_path2.default.join(import_node_os.default.homedir(), ".neat", "extend-log.ndjson");
@@ -874,7 +905,13 @@ async function applyExtension(ctx, args, options) {
874
905
  return { library: args.library, filesTouched: [], depsAdded: [], installOutput: "", alreadyApplied: true };
875
906
  }
876
907
  }
877
- const primaryFile = hookFiles[0];
908
+ const primary = await pickPrimaryHookFile(ctx.scanPath, hookFiles, args.registration_snippet);
909
+ if (primary.patched === null) {
910
+ throw new Error(
911
+ `Could not find instrumentation insertion point in ${hookFiles.join(", ")}. Expected __INSTRUMENTATION_BLOCK__, instrumentations.push(, or new NodeSDK(.`
912
+ );
913
+ }
914
+ const primaryFile = primary.file;
878
915
  const primaryPath = import_node_path2.default.join(ctx.scanPath, primaryFile);
879
916
  const filesTouched = [];
880
917
  const depsAdded = [];
@@ -886,14 +923,7 @@ async function applyExtension(ctx, args, options) {
886
923
  filesTouched.push("package.json");
887
924
  depsAdded.push(`${args.instrumentation_package}@${args.version}`);
888
925
  }
889
- const hookContent = await import_node_fs2.promises.readFile(primaryPath, "utf8");
890
- const patched = splicedContent(hookContent, args.registration_snippet);
891
- if (!patched) {
892
- throw new Error(
893
- `Could not find instrumentation insertion point in ${primaryFile}. Expected __INSTRUMENTATION_BLOCK__, instrumentations.push(, or new NodeSDK(.`
894
- );
895
- }
896
- await import_node_fs2.promises.writeFile(primaryPath, patched, "utf8");
926
+ await import_node_fs2.promises.writeFile(primaryPath, primary.patched, "utf8");
897
927
  filesTouched.push(primaryFile);
898
928
  const cmd = await detectPackageManager(ctx.scanPath);
899
929
  const installer = options?.runInstall ?? runPackageManagerInstall;
@@ -935,7 +965,7 @@ async function dryRunExtension(ctx, args) {
935
965
  };
936
966
  }
937
967
  }
938
- const primaryFile = hookFiles[0];
968
+ const primary = await pickPrimaryHookFile(ctx.scanPath, hookFiles, args.registration_snippet);
939
969
  const filesTouched = [];
940
970
  const depsToAdd = [];
941
971
  let packageJsonPatch = {};
@@ -946,10 +976,8 @@ async function dryRunExtension(ctx, args) {
946
976
  depsToAdd.push(`${args.instrumentation_package}@${args.version}`);
947
977
  filesTouched.push("package.json");
948
978
  }
949
- const hookContent = await import_node_fs2.promises.readFile(import_node_path2.default.join(ctx.scanPath, primaryFile), "utf8");
950
- const patched = splicedContent(hookContent, args.registration_snippet);
951
- if (patched) {
952
- filesTouched.push(primaryFile);
979
+ if (primary.patched !== null) {
980
+ filesTouched.push(primary.file);
953
981
  templatePatch = `+ ${args.registration_snippet}`;
954
982
  } else {
955
983
  templatePatch = "Could not find insertion point in hook file.";
@@ -5150,14 +5178,21 @@ function engineFromImage(image) {
5150
5178
  // src/extract/databases/dotenv.ts
5151
5179
  var CONNECTION_KEYS = /* @__PURE__ */ new Set([
5152
5180
  "DATABASE_URL",
5181
+ "DATABASE_URI",
5153
5182
  "DB_URL",
5183
+ "DB_URI",
5154
5184
  "POSTGRES_URL",
5185
+ "POSTGRES_URI",
5155
5186
  "POSTGRESQL_URL",
5187
+ "POSTGRESQL_URI",
5156
5188
  "MYSQL_URL",
5189
+ "MYSQL_URI",
5190
+ "MONGODB_URL",
5157
5191
  "MONGODB_URI",
5158
5192
  "MONGO_URL",
5159
5193
  "MONGO_URI",
5160
- "REDIS_URL"
5194
+ "REDIS_URL",
5195
+ "REDIS_URI"
5161
5196
  ]);
5162
5197
  function parseDotenvLine(line) {
5163
5198
  const trimmed = line.trim();
@@ -9127,7 +9162,7 @@ function registerRoutes(scope, ctx) {
9127
9162
  });
9128
9163
  }
9129
9164
  async function buildApi(opts) {
9130
- const app = (0, import_fastify.default)({ logger: false });
9165
+ const app = (0, import_fastify.default)({ logger: false, routerOptions: { maxParamLength: 1024 } });
9131
9166
  await app.register(import_cors.default, { origin: true });
9132
9167
  const env = readAuthEnv();
9133
9168
  const authToken = opts.authToken ?? env.authToken;