envprism 0.4.0 → 0.4.1-dev-main.98-fbc96ec

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/README.md CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  [![npm Version](https://img.shields.io/npm/v/envprism.svg?style=flat-square&color=4f46e5)](https://www.npmjs.com/package/envprism)
8
8
  [![Downloads](https://img.shields.io/npm/dm/envprism.svg?style=flat-square&color=4f46e5)](https://www.npmjs.com/package/envprism)
9
- [![Tests](https://img.shields.io/github/actions/workflow/status/TitusKirch/envprism/ci.yml?branch=main&style=flat-square&label=tests)](https://github.com/TitusKirch/envprism/actions/workflows/ci.yml)
10
- [![Bun](https://img.shields.io/badge/bun-1.3%2B-8993be?style=flat-square)](https://bun.sh/)
9
+ [![Tests](https://img.shields.io/github/actions/workflow/status/TitusKirch/envprism/ci.yml?event=pull_request&style=flat-square&label=tests)](https://github.com/TitusKirch/envprism/actions/workflows/ci.yml)
10
+ [![Bun](https://img.shields.io/badge/bun-1.3.14%2B-8993be?style=flat-square)](https://bun.sh/)
11
11
  [![License: MIT](https://img.shields.io/npm/l/envprism.svg?style=flat-square&color=10b981)](LICENSE)
12
12
 
13
13
  ![envprism TUI preview](.github/assets/demo.gif)
@@ -31,7 +31,7 @@ envprism treats the whole set as one thing: every file a column, every variable
31
31
  ## 📦 Install & run
32
32
 
33
33
  > [!IMPORTANT]
34
- > envprism runs on **[Bun](https://bun.sh/)** 1.3+, not Node. The TUI links a native core via `bun:ffi`, so `npx envprism` will **not** work — [install Bun](https://bun.sh/) first.
34
+ > envprism runs on **[Bun](https://bun.sh/)** 1.3.14+, not Node. The TUI links a native core via `bun:ffi`, so `npx envprism` will **not** work — [install Bun](https://bun.sh/) first.
35
35
 
36
36
  ```bash
37
37
  bun add -g envprism # install globally
@@ -64,7 +64,7 @@ Inside the TUI, press `?` for the full keybinding reference.
64
64
 
65
65
  ### Discovery & comparison
66
66
 
67
- - **🔍 Auto-discovery** — finds every `.env*` file in the current directory (or in `--paths a b c`); skips editor swap files and backups.
67
+ - **🔍 Auto-discovery** — finds every `.env*` file in the current directory, or in the directories and files you pass (`envprism diff a b`); skips editor swap files and backups.
68
68
  - **🧮 Matrix view** — rows are the union of every variable, columns are the files; the prism metaphor, literal.
69
69
  - **🎯 Smart base resolution** — `.env.example` is auto-promoted to base if present, otherwise the alphabetically-first file. Override with `--base file`.
70
70
  - **🎨 Per-cell diff icons** — `≠` value differs (yellow), `✗ missing` (red), `★` extra (key not in base, yellow), `⚠` placeholder (orange) — only the icon is coloured, values stay neutral.
@@ -172,12 +172,7 @@ Theme keys (all optional hex strings): `fg`, `fgDim`, `fgHeader`, `fgBase`, `fgS
172
172
 
173
173
  ## 🤝 Contributing
174
174
 
175
- PRs welcome. Conventional Commits required (enforced via commitlint). Husky runs the project's linters/formatters on `git commit`.
176
-
177
- > [!TIP]
178
- > Run `pnpm check:fix` before pushing — CI will catch what husky missed.
179
-
180
- See [CONTRIBUTING.md](CONTRIBUTING.md) for the full workflow.
175
+ PRs welcome — setup, branching, commit conventions and the local gate are in [CONTRIBUTING.md](CONTRIBUTING.md).
181
176
 
182
177
  ## 🛣️ Versioning
183
178
 
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env bun
2
- import { a as computeDiff, c as loadEnvprismConfig, o as formatDiffText, r as discoverEnvFiles, s as resolveBase, t as buildMatrix } from "../chunks/matrix-CG1Msljr.mjs";
2
+ import { a as computeDiff, c as loadEnvprismConfig, o as formatDiffText, r as discoverEnvFiles, s as resolveBase, t as buildMatrix } from "../chunks/matrix-CiLpV5eV.mjs";
3
3
  import { defineCommand, runMain } from "citty";
4
4
  import { spawn } from "node:child_process";
5
5
  import { writeFile } from "node:fs/promises";
6
6
  import consola from "consola";
7
7
  import { join, resolve } from "pathe";
8
- //#region src/commands/config/init.ts
8
+ // src/commands/config/init.ts
9
9
  /** Scaffold template, shared with `config edit` for first-time creation. */
10
10
  var CONFIG_TEMPLATE = `/**
11
11
  * envprism configuration.
@@ -86,8 +86,7 @@ var initCommand = defineCommand({
86
86
  consola.success(`Wrote ${target}`);
87
87
  }
88
88
  });
89
- //#endregion
90
- //#region src/commands/config/edit.ts
89
+ // src/commands/config/edit.ts
91
90
  var editCommand = defineCommand({
92
91
  meta: {
93
92
  name: "edit",
@@ -120,8 +119,7 @@ var editCommand = defineCommand({
120
119
  });
121
120
  }
122
121
  });
123
- //#endregion
124
- //#region src/commands/config/path.ts
122
+ // src/commands/config/path.ts
125
123
  var pathCommand = defineCommand({
126
124
  meta: {
127
125
  name: "path",
@@ -137,8 +135,7 @@ var pathCommand = defineCommand({
137
135
  else consola.info(`No envprism.config found (searched up from ${cwd}); using built-in defaults.`);
138
136
  }
139
137
  });
140
- //#endregion
141
- //#region src/commands/config/show.ts
138
+ // src/commands/config/show.ts
142
139
  var showCommand = defineCommand({
143
140
  meta: {
144
141
  name: "show",
@@ -153,8 +150,7 @@ var showCommand = defineCommand({
153
150
  process.stdout.write(JSON.stringify(config, null, 2) + "\n");
154
151
  }
155
152
  });
156
- //#endregion
157
- //#region src/commands/config/index.ts
153
+ // src/commands/config/index.ts
158
154
  var configCommand = defineCommand({
159
155
  meta: {
160
156
  name: "config",
@@ -167,8 +163,20 @@ var configCommand = defineCommand({
167
163
  edit: editCommand
168
164
  }
169
165
  });
170
- //#endregion
171
- //#region src/commands/diff.ts
166
+ // src/commands/paths.ts
167
+ /**
168
+ * The paths a command should scan. citty puts only the first positional into
169
+ * a named positional arg and every positional into `_`, so `_` wins whenever
170
+ * it holds anything; otherwise the named arg, then the configured fallback.
171
+ */
172
+ function collectPaths(args, fallback) {
173
+ if (Array.isArray(args._) && args._.length > 0) return args._.map(String);
174
+ const { paths } = args;
175
+ if (Array.isArray(paths)) return paths.map(String);
176
+ if (typeof paths === "string" && paths.length > 0) return [paths];
177
+ return fallback;
178
+ }
179
+ // src/commands/diff.ts
172
180
  var diffCommand = defineCommand({
173
181
  meta: {
174
182
  name: "diff",
@@ -178,7 +186,7 @@ var diffCommand = defineCommand({
178
186
  paths: {
179
187
  type: "positional",
180
188
  required: false,
181
- description: "Directory or files to scan (defaults to cwd)."
189
+ description: "Directories or files to scan (defaults to cwd)."
182
190
  },
183
191
  base: {
184
192
  type: "string",
@@ -199,7 +207,7 @@ var diffCommand = defineCommand({
199
207
  },
200
208
  async run({ args }) {
201
209
  const { config } = await loadEnvprismConfig({ configFile: args.config });
202
- const inputs = collectPaths$1(args.paths, config.discovery.paths);
210
+ const inputs = collectPaths(args, config.discovery.paths);
203
211
  const files = await discoverEnvFiles(inputs.map((p) => resolve(p)), {
204
212
  skipSuffixes: config.discovery.skipSuffixes,
205
213
  exampleFirst: config.discovery.exampleFirst
@@ -226,20 +234,14 @@ var diffCommand = defineCommand({
226
234
  process.stdout.write(formatDiffText(report));
227
235
  }
228
236
  });
229
- function collectPaths$1(arg, fallback) {
230
- if (Array.isArray(arg)) return arg.map(String);
231
- if (typeof arg === "string" && arg.length > 0) return [arg];
232
- return fallback;
233
- }
234
- //#endregion
235
- //#region src/commands/tui.ts
237
+ // src/commands/tui.ts
236
238
  /**
237
239
  * Resolve the matrix and boot the TUI. Shared between the explicit `tui`
238
240
  * subcommand and the default-no-subcommand path in `rootCommand`.
239
241
  */
240
242
  async function runTui(args) {
241
243
  const { config } = await loadEnvprismConfig({ configFile: args.config });
242
- const inputs = collectPaths(args.paths, config.discovery.paths);
244
+ const inputs = collectPaths(args, config.discovery.paths);
243
245
  const files = await discoverEnvFiles(inputs.map((p) => resolve(p)), {
244
246
  skipSuffixes: config.discovery.skipSuffixes,
245
247
  exampleFirst: config.discovery.exampleFirst
@@ -257,7 +259,7 @@ async function runTui(args) {
257
259
  process.exit(1);
258
260
  }
259
261
  const matrix = buildMatrix(files, base);
260
- const { runMatrixTui } = await import("../chunks/app-DsXVBLxT.mjs");
262
+ const { runMatrixTui } = await import("../chunks/app-BqQuZiRW.mjs");
261
263
  await runMatrixTui(matrix, config);
262
264
  }
263
265
  var tuiCommand = defineCommand({
@@ -269,7 +271,7 @@ var tuiCommand = defineCommand({
269
271
  paths: {
270
272
  type: "positional",
271
273
  required: false,
272
- description: "Directory or files to scan (defaults to cwd)."
274
+ description: "Directories or files to scan (defaults to cwd)."
273
275
  },
274
276
  base: {
275
277
  type: "string",
@@ -283,18 +285,13 @@ var tuiCommand = defineCommand({
283
285
  async run({ args }) {
284
286
  await runTui({
285
287
  paths: args.paths,
288
+ _: args._,
286
289
  base: args.base,
287
290
  config: args.config
288
291
  });
289
292
  }
290
293
  });
291
- function collectPaths(arg, fallback) {
292
- if (Array.isArray(arg)) return arg.map(String);
293
- if (typeof arg === "string" && arg.length > 0) return [arg];
294
- return fallback;
295
- }
296
- //#endregion
297
- //#region src/cli.ts
294
+ // src/cli.ts
298
295
  var SUBCOMMANDS = /* @__PURE__ */ new Set([
299
296
  "tui",
300
297
  "diff",
@@ -316,9 +313,7 @@ var rootCommand = defineCommand({
316
313
  await runTui({});
317
314
  }
318
315
  });
319
- //#endregion
320
- //#region src/bin/envprism.ts
316
+ // src/bin/envprism.ts
321
317
  runMain(rootCommand);
322
- //#endregion
323
318
 
324
319
  //# sourceMappingURL=envprism.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"envprism.mjs","names":["collectPaths"],"sources":["../../src/commands/config/init.ts","../../src/commands/config/edit.ts","../../src/commands/config/path.ts","../../src/commands/config/show.ts","../../src/commands/config/index.ts","../../src/commands/diff.ts","../../src/commands/tui.ts","../../src/cli.ts","../../src/bin/envprism.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { join, resolve } from 'pathe';\n\n/** Scaffold template, shared with `config edit` for first-time creation. */\nexport const CONFIG_TEMPLATE = `/**\n * envprism configuration.\n *\n * For type-safe authoring, install envprism and switch to:\n * import { defineEnvprismConfig } from 'envprism/config';\n * export default defineEnvprismConfig({ ... });\n *\n * @type {import('envprism/config').EnvprismUserConfig}\n */\nexport default {\n discovery: {\n // paths: ['.'],\n // skipSuffixesExtra: ['.tmp'],\n // exampleFirst: true\n },\n base: {\n name: '.env.example'\n // priority: ['.env.shared']\n },\n heuristics: {\n // secretTokensExtra: ['JWT'],\n // placeholdersExtra: ['set[_-]?me'],\n grouping: 'auto'\n },\n diff: {\n json: false,\n checkExitCode: 1\n },\n tui: {\n theme: {\n // fgBase: '#82aaff'\n },\n layout: {\n keyColWidth: 22,\n valueColMin: 18,\n sidebarWidth: 30,\n rowGap: 0,\n cellPadX: 1\n },\n undoLimit: 50,\n maskSecrets: true\n }\n};\n`;\n\nexport const initCommand = defineCommand({\n meta: {\n name: 'init',\n description: 'Scaffold an envprism.config.ts with documented defaults.'\n },\n args: {\n out: {\n type: 'positional',\n required: false,\n description: 'Directory to write envprism.config.ts into (default: cwd).'\n },\n force: {\n type: 'boolean',\n description: 'Overwrite an existing config file.'\n }\n },\n async run({ args }) {\n const dir = resolve(typeof args.out === 'string' ? args.out : '.');\n const target = join(dir, 'envprism.config.ts');\n try {\n await writeFile(target, CONFIG_TEMPLATE, {\n encoding: 'utf8',\n flag: args.force ? 'w' : 'wx'\n });\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'EEXIST') {\n consola.error(`${target} already exists. Use --force to overwrite.`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n consola.success(`Wrote ${target}`);\n }\n});\n","import { spawn } from 'node:child_process';\nimport { writeFile } from 'node:fs/promises';\nimport { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { CONFIG_TEMPLATE } from '@/commands/config/init.ts';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const editCommand = defineCommand({\n meta: {\n name: 'edit',\n description:\n 'Open the config in $EDITOR (creates it in cwd if none exists).'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n let { configFile } = await loadEnvprismConfig({ configFile: args.config });\n\n if (!configFile) {\n configFile = resolve('envprism.config.ts');\n try {\n await writeFile(configFile, CONFIG_TEMPLATE, {\n encoding: 'utf8',\n flag: 'wx'\n });\n consola.info(`Created ${configFile}`);\n } catch {\n // Created concurrently or already present — open whatever is there.\n }\n }\n\n const editor = process.env.VISUAL || process.env.EDITOR || 'nano';\n await new Promise<void>((res, rej) => {\n const child = spawn(editor, [configFile!], { stdio: 'inherit' });\n child.on('error', rej);\n child.on('exit', (code) => {\n if (code && code !== 0) {\n consola.warn(`${editor} exited with code ${code}.`);\n }\n res();\n });\n });\n }\n});\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const pathCommand = defineCommand({\n meta: {\n name: 'path',\n description:\n 'Print the resolved config file path (or note that defaults are used).'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { configFile, cwd } = await loadEnvprismConfig({\n configFile: args.config\n });\n if (configFile) {\n // Path goes to stdout so it can be piped; the not-found note is on stderr.\n process.stdout.write(configFile + '\\n');\n } else {\n consola.info(\n `No envprism.config found (searched up from ${cwd}); using built-in defaults.`\n );\n }\n }\n});\n","import { defineCommand } from 'citty';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const showCommand = defineCommand({\n meta: {\n name: 'show',\n description: 'Print the effective (merged) config as JSON.'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n process.stdout.write(JSON.stringify(config, null, 2) + '\\n');\n }\n});\n","import { defineCommand } from 'citty';\nimport { editCommand } from '@/commands/config/edit.ts';\nimport { initCommand } from '@/commands/config/init.ts';\nimport { pathCommand } from '@/commands/config/path.ts';\nimport { showCommand } from '@/commands/config/show.ts';\n\nexport const configCommand = defineCommand({\n meta: {\n name: 'config',\n description: 'Inspect and manage the envprism config.'\n },\n subCommands: {\n init: initCommand,\n path: pathCommand,\n show: showCommand,\n edit: editCommand\n }\n});\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { loadEnvprismConfig } from '@/config/load.ts';\nimport { resolveBase } from '@/core/base.ts';\nimport { computeDiff, formatDiffText } from '@/core/diff.ts';\nimport { discoverEnvFiles } from '@/core/discover.ts';\nimport { buildMatrix } from '@/core/matrix.ts';\n\nexport const diffCommand = defineCommand({\n meta: {\n name: 'diff',\n description: 'Print the drift between .env* files compared to a base.'\n },\n args: {\n paths: {\n type: 'positional',\n required: false,\n description: 'Directory or files to scan (defaults to cwd).'\n },\n base: {\n type: 'string',\n description: 'Base file to diff against (defaults to .env.example).'\n },\n json: {\n type: 'boolean',\n description: 'Emit JSON instead of a text table.'\n },\n check: {\n type: 'boolean',\n description:\n 'Suppress output and exit 1 when any file drifts from the base.'\n },\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n const inputs = collectPaths(args.paths, config.discovery.paths);\n const files = await discoverEnvFiles(\n inputs.map((p) => resolve(p)),\n {\n skipSuffixes: config.discovery.skipSuffixes,\n exampleFirst: config.discovery.exampleFirst\n }\n );\n\n if (files.length === 0) {\n if (!args.check) consola.warn('No .env* files found.');\n process.exit(args.check ? 0 : 1);\n }\n\n const base = resolveBase(files, args.base, {\n name: config.base.name,\n priority: config.base.priority\n });\n if (!base) {\n consola.error('Could not resolve a base file.');\n process.exit(1);\n }\n\n const matrix = buildMatrix(files, base);\n const report = computeDiff(matrix);\n\n if (args.check) {\n process.exit(report.inSync ? 0 : config.diff.checkExitCode);\n }\n\n const json = args.json ?? config.diff.json;\n if (json) {\n process.stdout.write(JSON.stringify(report, null, 2) + '\\n');\n return;\n }\n\n process.stdout.write(formatDiffText(report));\n }\n});\n\nfunction collectPaths(arg: unknown, fallback: string[]): string[] {\n if (Array.isArray(arg)) return arg.map(String);\n if (typeof arg === 'string' && arg.length > 0) return [arg];\n return fallback;\n}\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { loadEnvprismConfig } from '@/config/load.ts';\nimport { resolveBase } from '@/core/base.ts';\nimport { discoverEnvFiles } from '@/core/discover.ts';\nimport { buildMatrix } from '@/core/matrix.ts';\n\ninterface TuiInvocation {\n paths?: string | string[];\n base?: string;\n config?: string;\n}\n\n/**\n * Resolve the matrix and boot the TUI. Shared between the explicit `tui`\n * subcommand and the default-no-subcommand path in `rootCommand`.\n */\nexport async function runTui(args: TuiInvocation): Promise<void> {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n const inputs = collectPaths(args.paths, config.discovery.paths);\n const files = await discoverEnvFiles(\n inputs.map((p) => resolve(p)),\n {\n skipSuffixes: config.discovery.skipSuffixes,\n exampleFirst: config.discovery.exampleFirst\n }\n );\n\n if (files.length === 0) {\n consola.warn('No .env* files found.');\n process.exit(1);\n }\n\n const base = resolveBase(files, args.base, {\n name: config.base.name,\n priority: config.base.priority\n });\n if (!base) {\n consola.error('Could not resolve a base file.');\n process.exit(1);\n }\n\n const matrix = buildMatrix(files, base);\n\n // Dynamic import keeps @opentui/core out of the bundle path used by the\n // `diff` subcommand, so users running diff on Node never hit Bun-only code.\n const { runMatrixTui } = await import('../tui/app.ts');\n await runMatrixTui(matrix, config);\n}\n\nexport const tuiCommand = defineCommand({\n meta: {\n name: 'tui',\n description: 'Open the interactive matrix view (default command).'\n },\n args: {\n paths: {\n type: 'positional',\n required: false,\n description: 'Directory or files to scan (defaults to cwd).'\n },\n base: {\n type: 'string',\n description: 'Base file to diff against (defaults to .env.example).'\n },\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n await runTui({ paths: args.paths, base: args.base, config: args.config });\n }\n});\n\nfunction collectPaths(arg: unknown, fallback: string[]): string[] {\n if (Array.isArray(arg)) return arg.map(String);\n if (typeof arg === 'string' && arg.length > 0) return [arg];\n return fallback;\n}\n","import { defineCommand } from 'citty';\nimport { configCommand } from '@/commands/config/index.ts';\nimport { diffCommand } from '@/commands/diff.ts';\nimport { runTui, tuiCommand } from '@/commands/tui.ts';\n\nconst SUBCOMMANDS = new Set(['tui', 'diff', 'config']);\n\nexport const rootCommand = defineCommand({\n meta: {\n name: 'envprism',\n description:\n 'TUI-based env file manager — refract one set of variables into many environment views.'\n },\n subCommands: {\n tui: tuiCommand,\n diff: diffCommand,\n config: configCommand\n },\n // citty 0.1.6 invokes the root `run` after a matched subcommand returns,\n // so guard against double-execution by bailing when the first positional\n // arg names a known subcommand. With no args at all we launch the TUI in\n // the cwd, which is the documented default.\n async run({ rawArgs }) {\n const firstPositional = rawArgs.find((a) => !a.startsWith('-'));\n if (firstPositional && SUBCOMMANDS.has(firstPositional)) return;\n await runTui({});\n }\n});\n","import { runMain } from 'citty';\nimport { rootCommand } from '@/cli.ts';\n\nrunMain(rootCommand);\n"],"mappings":";;;;;;;;;AAMA,IAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6C/B,IAAa,cAAc,cAAc;CACvC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,KAAK;GACH,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,OAAO;GACL,MAAM;GACN,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,KAAK,MAAM,GAAG;EACjE,MAAM,SAAS,KAAK,KAAK,oBAAoB;EAC7C,IAAI;GACF,MAAM,UAAU,QAAQ,iBAAiB;IACvC,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM;GAC3B,CAAC;EACH,SAAS,KAAK;GACZ,IAAK,IAA8B,SAAS,UAAU;IACpD,QAAQ,MAAM,GAAG,OAAO,2CAA2C;IACnE,QAAQ,WAAW;IACnB;GACF;GACA,MA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AAc;CACtC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,OAAO;GACL,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,MAAM;GACJ,MAAM;GACN,aAAa;EACf;EACA,QAAQ;GACN,MAAM;GACN,aACE;EACJ;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,OAAO;GAAE,OAAO,KAAK;GAAO,MAAM,KAAK;GAAM,QAAQ,KAAK;EAAO,CAAC;CAC1E;AACF,CAAC;AAED,SAAS,aAAa,KAAc,UAA8B;CAChE,IAAI,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI,IAAI,MAAM;CAC7C,IAAI,OAAO,QAAQ,YAAY,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG;CAC1D,OAAO;AACT;;;AC5EA,IAAM,8BAAc,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAQ,CAAC;AAErD,IAAa,cAAc,cAAc;CACvC,MAAM;EACJ,MAAM;EACN,aACE;CACJ;CACA,aAAa;EACX,KAAK;EACL,MAAM;EACN,QAAQ;CACV;CAKA,MAAM,IAAI,EAAE,WAAW;EACrB,MAAM,kBAAkB,QAAQ,MAAM,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC;EAC9D,IAAI,mBAAmB,YAAY,IAAI,eAAe,GAAG;EACzD,MAAM,OAAO,CAAC,CAAC;CACjB;AACF,CAAC;;;ACxBD,QAAQ,WAAW"}
1
+ {"version":3,"file":"envprism.mjs","names":[],"sources":["../../src/commands/config/init.ts","../../src/commands/config/edit.ts","../../src/commands/config/path.ts","../../src/commands/config/show.ts","../../src/commands/config/index.ts","../../src/commands/paths.ts","../../src/commands/diff.ts","../../src/commands/tui.ts","../../src/cli.ts","../../src/bin/envprism.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { join, resolve } from 'pathe';\n\n/** Scaffold template, shared with `config edit` for first-time creation. */\nexport const CONFIG_TEMPLATE = `/**\n * envprism configuration.\n *\n * For type-safe authoring, install envprism and switch to:\n * import { defineEnvprismConfig } from 'envprism/config';\n * export default defineEnvprismConfig({ ... });\n *\n * @type {import('envprism/config').EnvprismUserConfig}\n */\nexport default {\n discovery: {\n // paths: ['.'],\n // skipSuffixesExtra: ['.tmp'],\n // exampleFirst: true\n },\n base: {\n name: '.env.example'\n // priority: ['.env.shared']\n },\n heuristics: {\n // secretTokensExtra: ['JWT'],\n // placeholdersExtra: ['set[_-]?me'],\n grouping: 'auto'\n },\n diff: {\n json: false,\n checkExitCode: 1\n },\n tui: {\n theme: {\n // fgBase: '#82aaff'\n },\n layout: {\n keyColWidth: 22,\n valueColMin: 18,\n sidebarWidth: 30,\n rowGap: 0,\n cellPadX: 1\n },\n undoLimit: 50,\n maskSecrets: true\n }\n};\n`;\n\nexport const initCommand = defineCommand({\n meta: {\n name: 'init',\n description: 'Scaffold an envprism.config.ts with documented defaults.'\n },\n args: {\n out: {\n type: 'positional',\n required: false,\n description: 'Directory to write envprism.config.ts into (default: cwd).'\n },\n force: {\n type: 'boolean',\n description: 'Overwrite an existing config file.'\n }\n },\n async run({ args }) {\n const dir = resolve(typeof args.out === 'string' ? args.out : '.');\n const target = join(dir, 'envprism.config.ts');\n try {\n await writeFile(target, CONFIG_TEMPLATE, {\n encoding: 'utf8',\n flag: args.force ? 'w' : 'wx'\n });\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'EEXIST') {\n consola.error(`${target} already exists. Use --force to overwrite.`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n consola.success(`Wrote ${target}`);\n }\n});\n","import { spawn } from 'node:child_process';\nimport { writeFile } from 'node:fs/promises';\nimport { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { CONFIG_TEMPLATE } from '@/commands/config/init.ts';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const editCommand = defineCommand({\n meta: {\n name: 'edit',\n description:\n 'Open the config in $EDITOR (creates it in cwd if none exists).'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n let { configFile } = await loadEnvprismConfig({ configFile: args.config });\n\n if (!configFile) {\n configFile = resolve('envprism.config.ts');\n try {\n await writeFile(configFile, CONFIG_TEMPLATE, {\n encoding: 'utf8',\n flag: 'wx'\n });\n consola.info(`Created ${configFile}`);\n } catch {\n // Created concurrently or already present — open whatever is there.\n }\n }\n\n const editor = process.env.VISUAL || process.env.EDITOR || 'nano';\n await new Promise<void>((res, rej) => {\n const child = spawn(editor, [configFile!], { stdio: 'inherit' });\n child.on('error', rej);\n child.on('exit', (code) => {\n if (code && code !== 0) {\n consola.warn(`${editor} exited with code ${code}.`);\n }\n res();\n });\n });\n }\n});\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const pathCommand = defineCommand({\n meta: {\n name: 'path',\n description:\n 'Print the resolved config file path (or note that defaults are used).'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { configFile, cwd } = await loadEnvprismConfig({\n configFile: args.config\n });\n if (configFile) {\n // Path goes to stdout so it can be piped; the not-found note is on stderr.\n process.stdout.write(configFile + '\\n');\n } else {\n consola.info(\n `No envprism.config found (searched up from ${cwd}); using built-in defaults.`\n );\n }\n }\n});\n","import { defineCommand } from 'citty';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const showCommand = defineCommand({\n meta: {\n name: 'show',\n description: 'Print the effective (merged) config as JSON.'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n process.stdout.write(JSON.stringify(config, null, 2) + '\\n');\n }\n});\n","import { defineCommand } from 'citty';\nimport { editCommand } from '@/commands/config/edit.ts';\nimport { initCommand } from '@/commands/config/init.ts';\nimport { pathCommand } from '@/commands/config/path.ts';\nimport { showCommand } from '@/commands/config/show.ts';\n\nexport const configCommand = defineCommand({\n meta: {\n name: 'config',\n description: 'Inspect and manage the envprism config.'\n },\n subCommands: {\n init: initCommand,\n path: pathCommand,\n show: showCommand,\n edit: editCommand\n }\n});\n","/**\n * The paths a command should scan. citty puts only the first positional into\n * a named positional arg and every positional into `_`, so `_` wins whenever\n * it holds anything; otherwise the named arg, then the configured fallback.\n */\nexport function collectPaths(\n args: { paths?: unknown; _?: unknown },\n fallback: string[]\n): string[] {\n if (Array.isArray(args._) && args._.length > 0) return args._.map(String);\n const { paths } = args;\n if (Array.isArray(paths)) return paths.map(String);\n if (typeof paths === 'string' && paths.length > 0) return [paths];\n return fallback;\n}\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { loadEnvprismConfig } from '@/config/load.ts';\nimport { resolveBase } from '@/core/base.ts';\nimport { computeDiff, formatDiffText } from '@/core/diff.ts';\nimport { discoverEnvFiles } from '@/core/discover.ts';\nimport { buildMatrix } from '@/core/matrix.ts';\nimport { collectPaths } from '@/commands/paths.ts';\n\nexport const diffCommand = defineCommand({\n meta: {\n name: 'diff',\n description: 'Print the drift between .env* files compared to a base.'\n },\n args: {\n paths: {\n type: 'positional',\n required: false,\n description: 'Directories or files to scan (defaults to cwd).'\n },\n base: {\n type: 'string',\n description: 'Base file to diff against (defaults to .env.example).'\n },\n json: {\n type: 'boolean',\n description: 'Emit JSON instead of a text table.'\n },\n check: {\n type: 'boolean',\n description:\n 'Suppress output and exit 1 when any file drifts from the base.'\n },\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n const inputs = collectPaths(args, config.discovery.paths);\n const files = await discoverEnvFiles(\n inputs.map((p) => resolve(p)),\n {\n skipSuffixes: config.discovery.skipSuffixes,\n exampleFirst: config.discovery.exampleFirst\n }\n );\n\n if (files.length === 0) {\n if (!args.check) consola.warn('No .env* files found.');\n process.exit(args.check ? 0 : 1);\n }\n\n const base = resolveBase(files, args.base, {\n name: config.base.name,\n priority: config.base.priority\n });\n if (!base) {\n consola.error('Could not resolve a base file.');\n process.exit(1);\n }\n\n const matrix = buildMatrix(files, base);\n const report = computeDiff(matrix);\n\n if (args.check) {\n process.exit(report.inSync ? 0 : config.diff.checkExitCode);\n }\n\n const json = args.json ?? config.diff.json;\n if (json) {\n process.stdout.write(JSON.stringify(report, null, 2) + '\\n');\n return;\n }\n\n process.stdout.write(formatDiffText(report));\n }\n});\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { loadEnvprismConfig } from '@/config/load.ts';\nimport { resolveBase } from '@/core/base.ts';\nimport { discoverEnvFiles } from '@/core/discover.ts';\nimport { buildMatrix } from '@/core/matrix.ts';\nimport { collectPaths } from '@/commands/paths.ts';\n\ninterface TuiInvocation {\n paths?: string | string[];\n _?: string[];\n base?: string;\n config?: string;\n}\n\n/**\n * Resolve the matrix and boot the TUI. Shared between the explicit `tui`\n * subcommand and the default-no-subcommand path in `rootCommand`.\n */\nexport async function runTui(args: TuiInvocation): Promise<void> {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n const inputs = collectPaths(args, config.discovery.paths);\n const files = await discoverEnvFiles(\n inputs.map((p) => resolve(p)),\n {\n skipSuffixes: config.discovery.skipSuffixes,\n exampleFirst: config.discovery.exampleFirst\n }\n );\n\n if (files.length === 0) {\n consola.warn('No .env* files found.');\n process.exit(1);\n }\n\n const base = resolveBase(files, args.base, {\n name: config.base.name,\n priority: config.base.priority\n });\n if (!base) {\n consola.error('Could not resolve a base file.');\n process.exit(1);\n }\n\n const matrix = buildMatrix(files, base);\n\n // Dynamic import keeps @opentui/core out of the bundle path used by the\n // `diff` subcommand, so users running diff on Node never hit Bun-only code.\n const { runMatrixTui } = await import('../tui/app.ts');\n await runMatrixTui(matrix, config);\n}\n\nexport const tuiCommand = defineCommand({\n meta: {\n name: 'tui',\n description: 'Open the interactive matrix view (default command).'\n },\n args: {\n paths: {\n type: 'positional',\n required: false,\n description: 'Directories or files to scan (defaults to cwd).'\n },\n base: {\n type: 'string',\n description: 'Base file to diff against (defaults to .env.example).'\n },\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n await runTui({\n paths: args.paths,\n _: args._,\n base: args.base,\n config: args.config\n });\n }\n});\n","import { defineCommand } from 'citty';\nimport { configCommand } from '@/commands/config/index.ts';\nimport { diffCommand } from '@/commands/diff.ts';\nimport { runTui, tuiCommand } from '@/commands/tui.ts';\n\nconst SUBCOMMANDS = new Set(['tui', 'diff', 'config']);\n\nexport const rootCommand = defineCommand({\n meta: {\n name: 'envprism',\n description:\n 'TUI-based env file manager — refract one set of variables into many environment views.'\n },\n subCommands: {\n tui: tuiCommand,\n diff: diffCommand,\n config: configCommand\n },\n // citty 0.1.6 invokes the root `run` after a matched subcommand returns,\n // so guard against double-execution by bailing when the first positional\n // arg names a known subcommand. With no args at all we launch the TUI in\n // the cwd, which is the documented default.\n async run({ rawArgs }) {\n const firstPositional = rawArgs.find((a) => !a.startsWith('-'));\n if (firstPositional && SUBCOMMANDS.has(firstPositional)) return;\n await runTui({});\n }\n});\n","import { runMain } from 'citty';\nimport { rootCommand } from '@/cli.ts';\n\nrunMain(rootCommand);\n"],"mappings":";;;;;;;;;AAMA,IAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6C/B,IAAa,cAAc,cAAc;CACvC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,KAAK;GACH,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,OAAO;GACL,MAAM;GACN,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,MAAM,QAAQ,OAAO,KAAK,QAAQ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AAM,WAAW,GAAG;EACtB,QAAQ,KAAK,uBAAuB;EACpC,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,OAAO,YAAY,OAAO,KAAK,MAAM;EACzC,MAAM,OAAO,KAAK;EAClB,UAAU,OAAO,KAAK;CACxB,CAAC;CACD,IAAI,CAAC,MAAM;EACT,QAAQ,MAAM,gCAAgC;EAC9C,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,SAAS,YAAY,OAAO,IAAI;CAItC,MAAM,EAAE,iBAAiB,MAAM,OAAO;CACtC,MAAM,aAAa,QAAQ,MAAM;AACnC;AAEA,IAAa,aAAa,cAAc;CACtC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,OAAO;GACL,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,MAAM;GACJ,MAAM;GACN,aAAa;EACf;EACA,QAAQ;GACN,MAAM;GACN,aACE;EACJ;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,OAAO;GACX,OAAO,KAAK;GACZ,GAAG,KAAK;GACR,MAAM,KAAK;GACX,QAAQ,KAAK;EACf,CAAC;CACH;AACF,CAAC;;AC7ED,IAAM,8BAAc,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAQ,CAAC;AAErD,IAAa,cAAc,cAAc;CACvC,MAAM;EACJ,MAAM;EACN,aACE;CACJ;CACA,aAAa;EACX,KAAK;EACL,MAAM;EACN,QAAQ;CACV;CAKA,MAAM,IAAI,EAAE,WAAW;EACrB,MAAM,kBAAkB,QAAQ,MAAM,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC;EAC9D,IAAI,mBAAmB,YAAY,IAAI,eAAe,GAAG;EACzD,MAAM,OAAO,CAAC,CAAC;CACjB;AACF,CAAC;;ACxBD,QAAQ,WAAW"}
@@ -1,9 +1,9 @@
1
- import { d as resolveThemeHex, f as findKvEntry, g as DEFAULT_CONFIG, h as truncate, l as DEFAULT_THEME_HEX, m as matchesFilter, p as formatValue, t as buildMatrix, u as resolveHeuristics } from "./matrix-CG1Msljr.mjs";
2
- import { n as serializeEnv, t as rebuildKvLine } from "./serialize-DWF9VxrS.mjs";
1
+ import { d as resolveThemeHex, f as findKvEntry, g as DEFAULT_CONFIG, h as truncate, l as DEFAULT_THEME_HEX, m as matchesFilter, p as formatValue, t as buildMatrix, u as resolveHeuristics } from "./matrix-CiLpV5eV.mjs";
2
+ import { n as serializeEnv, t as rebuildKvLine } from "./serialize-B280a9BO.mjs";
3
3
  import { writeFile } from "node:fs/promises";
4
4
  import { basename, dirname, join } from "pathe";
5
5
  import { BoxRenderable, RGBA, ScrollBoxRenderable, TextRenderable, createCliRenderer } from "@opentui/core";
6
- //#region src/tui/grouping.ts
6
+ // src/tui/grouping.ts
7
7
  var SECTION_COLLAPSE_KEY = "__other__";
8
8
  function prefixSection(key) {
9
9
  const idx = key.indexOf("_");
@@ -94,8 +94,7 @@ function keyDrifts(matrix, key) {
94
94
  }
95
95
  return false;
96
96
  }
97
- //#endregion
98
- //#region src/tui/envfile.ts
97
+ // src/tui/envfile.ts
99
98
  function isValidEnvFileName(name) {
100
99
  if (!name.startsWith(".env")) return false;
101
100
  if (name.includes("/") || name.includes("\\")) return false;
@@ -128,8 +127,7 @@ function appendKv(file, key, value) {
128
127
  file.trailingNewline = true;
129
128
  return entry;
130
129
  }
131
- //#endregion
132
- //#region src/tui/state/visible.ts
130
+ // src/tui/state/visible.ts
133
131
  function cellKey(key, file) {
134
132
  return `${key}|${file.path}`;
135
133
  }
@@ -198,8 +196,7 @@ function rebuildMatrix(ctx) {
198
196
  if (state.sidebarIdx >= ctx.allFiles.length) state.sidebarIdx = Math.max(0, ctx.allFiles.length - 1);
199
197
  recomputeVisibleKeys(ctx);
200
198
  }
201
- //#endregion
202
- //#region src/tui/actions/batch.ts
199
+ // src/tui/actions/batch.ts
203
200
  function applyToAllFiles(ctx, key, value) {
204
201
  const { state } = ctx;
205
202
  let touched = 0;
@@ -312,8 +309,7 @@ function setBase(ctx) {
312
309
  state.message = wasDisabled ? `${basename(file.path)} is now the base (re-enabled).` : `${basename(file.path)} is now the base.`;
313
310
  ctx.refresh();
314
311
  }
315
- //#endregion
316
- //#region src/tui/actions/io.ts
312
+ // src/tui/actions/io.ts
317
313
  async function saveDirty(ctx) {
318
314
  const { state } = ctx;
319
315
  if (state.dirty.size === 0) {
@@ -335,11 +331,9 @@ async function saveDirty(ctx) {
335
331
  } else state.message = `Save failed: ${errors.join("; ")}`;
336
332
  ctx.refresh();
337
333
  }
338
- //#endregion
339
- //#region src/tui/types.ts
334
+ // src/tui/types.ts
340
335
  var KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
341
- //#endregion
342
- //#region src/tui/actions/prompt.ts
336
+ // src/tui/actions/prompt.ts
343
337
  function openPrompt(ctx, prompt, value = "") {
344
338
  const { state } = ctx;
345
339
  state.prompt = prompt;
@@ -509,8 +503,7 @@ function commitPrompt(ctx) {
509
503
  return;
510
504
  }
511
505
  }
512
- //#endregion
513
- //#region src/tui/keys/browse.ts
506
+ // src/tui/keys/browse.ts
514
507
  function handleBrowseKey(ctx, key, cleanup) {
515
508
  const { state } = ctx;
516
509
  const refresh = ctx.refresh;
@@ -642,8 +635,7 @@ function handleBrowseKey(ctx, key, cleanup) {
642
635
  refresh();
643
636
  }
644
637
  }
645
- //#endregion
646
- //#region src/tui/keys/filter.ts
638
+ // src/tui/keys/filter.ts
647
639
  function handleFilterKey(ctx, key) {
648
640
  const { state } = ctx;
649
641
  if (key.name === "escape") {
@@ -673,16 +665,14 @@ function handleFilterKey(ctx, key) {
673
665
  ctx.refresh();
674
666
  }
675
667
  }
676
- //#endregion
677
- //#region src/tui/keys/help.ts
668
+ // src/tui/keys/help.ts
678
669
  function handleHelpKey(ctx, key) {
679
670
  if (key.name === "escape" || key.sequence === "?" || key.sequence === "ß" || key.name === "q") {
680
671
  ctx.state.helpOpen = false;
681
672
  ctx.refresh();
682
673
  }
683
674
  }
684
- //#endregion
685
- //#region src/tui/keys/prompt.ts
675
+ // src/tui/keys/prompt.ts
686
676
  function handlePromptKey(ctx, key) {
687
677
  const { state } = ctx;
688
678
  if (key.name === "escape") {
@@ -720,8 +710,7 @@ function handlePromptKey(ctx, key) {
720
710
  ctx.refresh();
721
711
  }
722
712
  }
723
- //#endregion
724
- //#region src/tui/keys/onKey.ts
713
+ // src/tui/keys/onKey.ts
725
714
  /**
726
715
  * Build the global keypress handler. Dispatches by current mode; `cleanup`
727
716
  * tears down the renderer and resolves the run promise (used by Ctrl-C and
@@ -735,8 +724,7 @@ function createOnKey(ctx, cleanup) {
735
724
  handleBrowseKey(ctx, key, cleanup);
736
725
  };
737
726
  }
738
- //#endregion
739
- //#region src/tui/render/layout.ts
727
+ // src/tui/render/layout.ts
740
728
  /**
741
729
  * Build the static element tree once and return stable handles. Content is
742
730
  * (re)populated later by the refreshers; this only establishes the layout
@@ -774,8 +762,7 @@ function buildLayout(renderer, theme, layout) {
774
762
  title: "",
775
763
  flexDirection: "column",
776
764
  flexGrow: 1,
777
- paddingX: 1,
778
- paddingBottom: 1
765
+ paddingX: 1
779
766
  });
780
767
  body.add(matrixBox);
781
768
  const headerHost = new BoxRenderable(renderer, {
@@ -958,8 +945,7 @@ function buildLayout(renderer, theme, layout) {
958
945
  dimOverlay
959
946
  };
960
947
  }
961
- //#endregion
962
- //#region src/tui/render/filter.ts
948
+ // src/tui/render/filter.ts
963
949
  function refreshFilter(ctx) {
964
950
  const { el: { filterBox, filterField, filterStatus }, matrix, state } = ctx;
965
951
  const open = state.mode === "filter";
@@ -970,14 +956,12 @@ function refreshFilter(ctx) {
970
956
  const total = matrix.keys.length;
971
957
  filterStatus.content = state.filter.length === 0 ? "Type to filter the keys list." : `Matching ${matches} of ${total} keys.`;
972
958
  }
973
- //#endregion
974
- //#region src/tui/render/dom.ts
959
+ // src/tui/render/dom.ts
975
960
  function removeAllChildren(node) {
976
961
  const children = [...node.getChildren()];
977
962
  for (const child of children) node.remove(child);
978
963
  }
979
- //#endregion
980
- //#region src/tui/render/footer.ts
964
+ // src/tui/render/footer.ts
981
965
  function bindings(specs, theme) {
982
966
  const out = [];
983
967
  specs.forEach((spec, i) => {
@@ -1171,8 +1155,7 @@ function refreshFooter(ctx) {
1171
1155
  }
1172
1156
  status.content = state.message ?? "";
1173
1157
  }
1174
- //#endregion
1175
- //#region src/tui/help.ts
1158
+ // src/tui/help.ts
1176
1159
  function buildHelpLines() {
1177
1160
  return [
1178
1161
  {
@@ -1347,8 +1330,7 @@ function buildHelpLines() {
1347
1330
  }
1348
1331
  ];
1349
1332
  }
1350
- //#endregion
1351
- //#region src/tui/render/builders.ts
1333
+ // src/tui/render/builders.ts
1352
1334
  function buildValueCell(cell, secret, width, focused, modified, theme, isPlaceholder) {
1353
1335
  const bg = focused ? theme.focusBg : void 0;
1354
1336
  const trailing = modified ? {
@@ -1602,8 +1584,7 @@ function buildRow(renderer, idPrefix, cells, padX) {
1602
1584
  });
1603
1585
  return row;
1604
1586
  }
1605
- //#endregion
1606
- //#region src/tui/render/help.ts
1587
+ // src/tui/render/help.ts
1607
1588
  function refreshHelp(ctx) {
1608
1589
  const { el: { helpBox }, renderer, state, theme } = ctx;
1609
1590
  helpBox.visible = state.helpOpen;
@@ -1657,8 +1638,7 @@ function refreshHelp(ctx) {
1657
1638
  grid.add(right);
1658
1639
  helpBox.add(grid);
1659
1640
  }
1660
- //#endregion
1661
- //#region src/tui/render/matrix.ts
1641
+ // src/tui/render/matrix.ts
1662
1642
  function matrixTitle(matrix, state) {
1663
1643
  const visible = state.visibleKeys.length;
1664
1644
  const total = matrix.keys.length;
@@ -1739,8 +1719,7 @@ function refreshMatrix(ctx) {
1739
1719
  });
1740
1720
  }
1741
1721
  }
1742
- //#endregion
1743
- //#region src/tui/render/prompt.ts
1722
+ // src/tui/render/prompt.ts
1744
1723
  function promptLabelText(p) {
1745
1724
  switch (p.kind) {
1746
1725
  case "edit": return ` Edit ${p.key} in ${basename(p.file.path)}:`;
@@ -1813,8 +1792,7 @@ function refreshPrompt(ctx) {
1813
1792
  }
1814
1793
  }
1815
1794
  }
1816
- //#endregion
1817
- //#region src/tui/render/sidebar.ts
1795
+ // src/tui/render/sidebar.ts
1818
1796
  function refreshSidebar(ctx) {
1819
1797
  const { el: { sidebar }, renderer, matrix, allFiles, state, theme } = ctx;
1820
1798
  const total = allFiles.length;
@@ -1853,8 +1831,7 @@ function refreshSidebar(ctx) {
1853
1831
  sidebar.add(row);
1854
1832
  }
1855
1833
  }
1856
- //#endregion
1857
- //#region src/tui/render/index.ts
1834
+ // src/tui/render/index.ts
1858
1835
  /**
1859
1836
  * Full synchronous render of every region. Reads `ctx.matrix` fresh so a
1860
1837
  * `rebuildMatrix` that ran between scheduling and this flush is reflected.
@@ -1869,8 +1846,7 @@ function refreshAll(ctx) {
1869
1846
  refreshFilter(ctx);
1870
1847
  ctx.el.dimOverlay.visible = state.helpOpen || state.mode === "prompt" || state.mode === "filter";
1871
1848
  }
1872
- //#endregion
1873
- //#region src/tui/theme.ts
1849
+ // src/tui/theme.ts
1874
1850
  /** Resolve a partial hex theme into RGBA values (gaps + invalid → defaults). */
1875
1851
  function resolveTheme(theme = {}, warn) {
1876
1852
  const hex = resolveThemeHex(theme, warn);
@@ -1888,8 +1864,7 @@ function resolveLayout(layout) {
1888
1864
  CELL_PAD_X: layout.cellPadX
1889
1865
  };
1890
1866
  }
1891
- //#endregion
1892
- //#region src/tui/app.ts
1867
+ // src/tui/app.ts
1893
1868
  async function runMatrixTui(initialMatrix, config = DEFAULT_CONFIG) {
1894
1869
  const renderer = await createCliRenderer({ useMouse: true });
1895
1870
  const theme = resolveTheme(config.tui.theme);
@@ -1958,7 +1933,6 @@ async function runMatrixTui(initialMatrix, config = DEFAULT_CONFIG) {
1958
1933
  renderer.on("resize", ctx.refresh);
1959
1934
  });
1960
1935
  }
1961
- //#endregion
1962
1936
  export { runMatrixTui };
1963
1937
 
1964
- //# sourceMappingURL=app-DsXVBLxT.mjs.map
1938
+ //# sourceMappingURL=app-BqQuZiRW.mjs.map