@cairnvibe/indexer 0.2.5 → 0.2.6

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.
Files changed (2) hide show
  1. package/dist/cli.js +38 -0
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -18,6 +18,43 @@ const diff_1 = require("./diff");
18
18
  const docs_1 = require("./docs");
19
19
  const init_1 = require("./init");
20
20
  const setup_1 = require("./setup");
21
+ /**
22
+ * A local `cairn build`/`npx cairn build` run (as opposed to a hosting
23
+ * platform's own build step, which injects its configured env vars
24
+ * directly into process.env) only ever sees the plain shell environment —
25
+ * it does NOT get a bundler's or framework's automatic .env/.env.local
26
+ * loading, since that's scoped to that tool's own process, not whatever
27
+ * invokes this CLI. A real key sitting in .env was invisible here even
28
+ * though `cairn setup` had written it there — the exact same class of gap
29
+ * already fixed for cairn-realtime's own CLI (realtime-cli.ts), for the
30
+ * exact same reason. No new dependency: .env is a plain KEY=VALUE format.
31
+ * .env.local loads first so it wins (matches Next.js's own precedence);
32
+ * nothing here overrides a real, already-set process.env value (a shell
33
+ * export, or a platform's own injected env vars) — file contents only
34
+ * ever fill a gap, never override something actually set.
35
+ */
36
+ function loadDotEnv(dir) {
37
+ for (const filename of [".env.local", ".env"]) {
38
+ const filePath = node_path_1.default.join(dir, filename);
39
+ if (!node_fs_1.default.existsSync(filePath))
40
+ continue;
41
+ for (const line of node_fs_1.default.readFileSync(filePath, "utf8").split("\n")) {
42
+ const trimmed = line.trim();
43
+ if (!trimmed || trimmed.startsWith("#"))
44
+ continue;
45
+ const eq = trimmed.indexOf("=");
46
+ if (eq === -1)
47
+ continue;
48
+ const key = trimmed.slice(0, eq).trim();
49
+ let value = trimmed.slice(eq + 1).trim();
50
+ if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
51
+ value = value.slice(1, -1);
52
+ }
53
+ if (process.env[key] === undefined)
54
+ process.env[key] = value;
55
+ }
56
+ }
57
+ }
21
58
  function parseArgs(rest) {
22
59
  const positional = [];
23
60
  const flags = {};
@@ -37,6 +74,7 @@ async function main() {
37
74
  const [command, ...rest] = process.argv.slice(2);
38
75
  const { positional, flags } = parseArgs(rest);
39
76
  const dir = positional[0] ?? ".";
77
+ loadDotEnv(dir);
40
78
  if (command === "scan") {
41
79
  const facts = (0, l1_scan_1.scanL1)(dir);
42
80
  process.stdout.write(JSON.stringify(facts, null, 2) + "\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cairnvibe/indexer",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Cairn's analyzer and installer (the `cairn` CLI) — scans Next.js source or crawls any running app, and scaffolds the backend either way.",
5
5
  "license": "MIT",
6
6
  "publishConfig": { "access": "public" },