@neat.is/core 0.5.1 → 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.
@@ -3990,14 +3990,21 @@ function engineFromImage(image) {
3990
3990
  // src/extract/databases/dotenv.ts
3991
3991
  var CONNECTION_KEYS = /* @__PURE__ */ new Set([
3992
3992
  "DATABASE_URL",
3993
+ "DATABASE_URI",
3993
3994
  "DB_URL",
3995
+ "DB_URI",
3994
3996
  "POSTGRES_URL",
3997
+ "POSTGRES_URI",
3995
3998
  "POSTGRESQL_URL",
3999
+ "POSTGRESQL_URI",
3996
4000
  "MYSQL_URL",
4001
+ "MYSQL_URI",
4002
+ "MONGODB_URL",
3997
4003
  "MONGODB_URI",
3998
4004
  "MONGO_URL",
3999
4005
  "MONGO_URI",
4000
- "REDIS_URL"
4006
+ "REDIS_URL",
4007
+ "REDIS_URI"
4001
4008
  ]);
4002
4009
  function parseDotenvLine(line) {
4003
4010
  const trimmed = line.trim();
@@ -7910,11 +7917,42 @@ async function readPackageJson(scanPath) {
7910
7917
  const raw = await fs27.readFile(pkgPath, "utf8");
7911
7918
  return JSON.parse(raw);
7912
7919
  }
7920
+ var HOOK_WALK_SKIP_DIRS = /* @__PURE__ */ new Set([
7921
+ "node_modules",
7922
+ "dist",
7923
+ "build",
7924
+ "out",
7925
+ "coverage",
7926
+ "neat-out"
7927
+ ]);
7913
7928
  async function findHookFiles(scanPath) {
7914
- const entries = await fs27.readdir(scanPath);
7915
- return entries.filter(
7916
- (e) => (e.startsWith("instrumentation") || e.startsWith("otel-init")) && /\.(ts|js)$/.test(e)
7917
- ).sort();
7929
+ const found = [];
7930
+ const walk3 = async (dir) => {
7931
+ const entries = await fs27.readdir(dir, { withFileTypes: true }).catch(() => []);
7932
+ for (const entry of entries) {
7933
+ if (entry.isDirectory()) {
7934
+ if (entry.name.startsWith(".") || HOOK_WALK_SKIP_DIRS.has(entry.name)) continue;
7935
+ await walk3(path45.join(dir, entry.name));
7936
+ } else if (entry.isFile()) {
7937
+ if ((entry.name.startsWith("instrumentation") || entry.name.startsWith("otel-init")) && /\.(ts|js|cjs|mjs)$/.test(entry.name)) {
7938
+ const rel = path45.relative(scanPath, path45.join(dir, entry.name));
7939
+ found.push(rel.split(path45.sep).join("/"));
7940
+ }
7941
+ }
7942
+ }
7943
+ };
7944
+ await walk3(scanPath);
7945
+ return found.sort();
7946
+ }
7947
+ async function pickPrimaryHookFile(scanPath, hookFiles, snippet2) {
7948
+ let fallback = null;
7949
+ for (const file of hookFiles) {
7950
+ const content = await fs27.readFile(path45.join(scanPath, file), "utf8");
7951
+ const patched = splicedContent(content, snippet2);
7952
+ if (patched !== null) return { file, content, patched };
7953
+ if (fallback === null) fallback = { file, content };
7954
+ }
7955
+ return { file: fallback.file, content: fallback.content, patched: null };
7918
7956
  }
7919
7957
  function extendLogPath() {
7920
7958
  return process.env.NEAT_EXTEND_LOG ?? path45.join(os3.homedir(), ".neat", "extend-log.ndjson");
@@ -8007,7 +8045,13 @@ async function applyExtension(ctx, args, options) {
8007
8045
  return { library: args.library, filesTouched: [], depsAdded: [], installOutput: "", alreadyApplied: true };
8008
8046
  }
8009
8047
  }
8010
- const primaryFile = hookFiles[0];
8048
+ const primary = await pickPrimaryHookFile(ctx.scanPath, hookFiles, args.registration_snippet);
8049
+ if (primary.patched === null) {
8050
+ throw new Error(
8051
+ `Could not find instrumentation insertion point in ${hookFiles.join(", ")}. Expected __INSTRUMENTATION_BLOCK__, instrumentations.push(, or new NodeSDK(.`
8052
+ );
8053
+ }
8054
+ const primaryFile = primary.file;
8011
8055
  const primaryPath = path45.join(ctx.scanPath, primaryFile);
8012
8056
  const filesTouched = [];
8013
8057
  const depsAdded = [];
@@ -8019,14 +8063,7 @@ async function applyExtension(ctx, args, options) {
8019
8063
  filesTouched.push("package.json");
8020
8064
  depsAdded.push(`${args.instrumentation_package}@${args.version}`);
8021
8065
  }
8022
- const hookContent = await fs27.readFile(primaryPath, "utf8");
8023
- const patched = splicedContent(hookContent, args.registration_snippet);
8024
- if (!patched) {
8025
- throw new Error(
8026
- `Could not find instrumentation insertion point in ${primaryFile}. Expected __INSTRUMENTATION_BLOCK__, instrumentations.push(, or new NodeSDK(.`
8027
- );
8028
- }
8029
- await fs27.writeFile(primaryPath, patched, "utf8");
8066
+ await fs27.writeFile(primaryPath, primary.patched, "utf8");
8030
8067
  filesTouched.push(primaryFile);
8031
8068
  const cmd = await detectPackageManager(ctx.scanPath);
8032
8069
  const installer = options?.runInstall ?? runPackageManagerInstall;
@@ -8068,7 +8105,7 @@ async function dryRunExtension(ctx, args) {
8068
8105
  };
8069
8106
  }
8070
8107
  }
8071
- const primaryFile = hookFiles[0];
8108
+ const primary = await pickPrimaryHookFile(ctx.scanPath, hookFiles, args.registration_snippet);
8072
8109
  const filesTouched = [];
8073
8110
  const depsToAdd = [];
8074
8111
  let packageJsonPatch = {};
@@ -8079,10 +8116,8 @@ async function dryRunExtension(ctx, args) {
8079
8116
  depsToAdd.push(`${args.instrumentation_package}@${args.version}`);
8080
8117
  filesTouched.push("package.json");
8081
8118
  }
8082
- const hookContent = await fs27.readFile(path45.join(ctx.scanPath, primaryFile), "utf8");
8083
- const patched = splicedContent(hookContent, args.registration_snippet);
8084
- if (patched) {
8085
- filesTouched.push(primaryFile);
8119
+ if (primary.patched !== null) {
8120
+ filesTouched.push(primary.file);
8086
8121
  templatePatch = `+ ${args.registration_snippet}`;
8087
8122
  } else {
8088
8123
  templatePatch = "Could not find insertion point in hook file.";
@@ -9149,7 +9184,7 @@ function registerRoutes(scope, ctx) {
9149
9184
  });
9150
9185
  }
9151
9186
  async function buildApi(opts) {
9152
- const app = Fastify({ logger: false });
9187
+ const app = Fastify({ logger: false, routerOptions: { maxParamLength: 1024 } });
9153
9188
  await app.register(cors, { origin: true });
9154
9189
  const env = readAuthEnv();
9155
9190
  const authToken = opts.authToken ?? env.authToken;
@@ -9361,4 +9396,4 @@ export {
9361
9396
  recordConnectorPoll,
9362
9397
  buildApi
9363
9398
  };
9364
- //# sourceMappingURL=chunk-BI3XKGVG.js.map
9399
+ //# sourceMappingURL=chunk-GJHEZC5K.js.map