ultraenv 1.0.0

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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2058 -0
  3. package/bin/ultraenv.mjs +3 -0
  4. package/dist/chunk-2USZPWLZ.js +288 -0
  5. package/dist/chunk-3UV2QNJL.js +270 -0
  6. package/dist/chunk-3VYXPTYV.js +179 -0
  7. package/dist/chunk-4XUYMRK5.js +366 -0
  8. package/dist/chunk-5G2DU52U.js +189 -0
  9. package/dist/chunk-6KS56D6E.js +172 -0
  10. package/dist/chunk-AWN6ADV7.js +328 -0
  11. package/dist/chunk-CHVO6NWI.js +203 -0
  12. package/dist/chunk-CIFMBJ4H.js +3975 -0
  13. package/dist/chunk-GC7RXHLA.js +253 -0
  14. package/dist/chunk-HFXQGJY3.js +445 -0
  15. package/dist/chunk-IGFVP24Q.js +91 -0
  16. package/dist/chunk-IKPTKALB.js +78 -0
  17. package/dist/chunk-JB7RKV3C.js +66 -0
  18. package/dist/chunk-MNVFG7H4.js +611 -0
  19. package/dist/chunk-MSXMESFP.js +1910 -0
  20. package/dist/chunk-N5PAV4NM.js +127 -0
  21. package/dist/chunk-NBOABPHM.js +158 -0
  22. package/dist/chunk-OMAOROL4.js +49 -0
  23. package/dist/chunk-R7PZRSZ7.js +105 -0
  24. package/dist/chunk-TE7HPLA6.js +73 -0
  25. package/dist/chunk-TMT5KCO3.js +101 -0
  26. package/dist/chunk-UEWYFN6A.js +189 -0
  27. package/dist/chunk-WMHN5RW2.js +128 -0
  28. package/dist/chunk-XC65ORJ5.js +70 -0
  29. package/dist/chunk-YMMP4VQL.js +118 -0
  30. package/dist/chunk-YN2KGTCB.js +33 -0
  31. package/dist/chunk-YTICOB5M.js +65 -0
  32. package/dist/chunk-YVWLXFUT.js +107 -0
  33. package/dist/ci-check-sync-VBMSVWIV.js +48 -0
  34. package/dist/ci-scan-24MT5XGS.js +41 -0
  35. package/dist/ci-setup-C2NKEFRD.js +135 -0
  36. package/dist/ci-validate-7AW24LSQ.js +57 -0
  37. package/dist/cli/index.cjs +9217 -0
  38. package/dist/cli/index.d.cts +9 -0
  39. package/dist/cli/index.d.ts +9 -0
  40. package/dist/cli/index.js +339 -0
  41. package/dist/comparator-RDKX3OI7.js +13 -0
  42. package/dist/completion-MW35C2XO.js +168 -0
  43. package/dist/config-O5YRQP5Z.js +13 -0
  44. package/dist/debug-PTPXAF3K.js +131 -0
  45. package/dist/declaration-LEME4AFZ.js +10 -0
  46. package/dist/doctor-FZAUPKHS.js +129 -0
  47. package/dist/envs-compare-5K3HESX5.js +49 -0
  48. package/dist/envs-create-2XXHXMGA.js +58 -0
  49. package/dist/envs-list-NQM5252B.js +59 -0
  50. package/dist/envs-switch-6L2AQYID.js +50 -0
  51. package/dist/envs-validate-FL73Q76T.js +89 -0
  52. package/dist/fs-VH7ATUS3.js +31 -0
  53. package/dist/generator-LFZBMZZS.js +14 -0
  54. package/dist/git-BZS4DPAI.js +30 -0
  55. package/dist/help-3XJBXEHE.js +121 -0
  56. package/dist/index.cjs +12907 -0
  57. package/dist/index.d.cts +2562 -0
  58. package/dist/index.d.ts +2562 -0
  59. package/dist/index.js +3212 -0
  60. package/dist/init-Y7JQ2KYJ.js +146 -0
  61. package/dist/install-hook-SKXIV6NV.js +111 -0
  62. package/dist/json-schema-I26YNQBH.js +10 -0
  63. package/dist/key-manager-O3G55WPU.js +25 -0
  64. package/dist/middleware/express.cjs +103 -0
  65. package/dist/middleware/express.d.cts +115 -0
  66. package/dist/middleware/express.d.ts +115 -0
  67. package/dist/middleware/express.js +8 -0
  68. package/dist/middleware/fastify.cjs +91 -0
  69. package/dist/middleware/fastify.d.cts +111 -0
  70. package/dist/middleware/fastify.d.ts +111 -0
  71. package/dist/middleware/fastify.js +8 -0
  72. package/dist/module-IDIZPP4M.js +10 -0
  73. package/dist/protect-NCWPM6VC.js +161 -0
  74. package/dist/scan-TRLY36TT.js +58 -0
  75. package/dist/schema/index.cjs +4074 -0
  76. package/dist/schema/index.d.cts +1244 -0
  77. package/dist/schema/index.d.ts +1244 -0
  78. package/dist/schema/index.js +152 -0
  79. package/dist/sync-TMHMTLH2.js +186 -0
  80. package/dist/typegen-SQOSXBWM.js +80 -0
  81. package/dist/validate-IOAM5HWS.js +100 -0
  82. package/dist/vault-decrypt-U6HJZNBV.js +111 -0
  83. package/dist/vault-diff-B3ZOQTWI.js +132 -0
  84. package/dist/vault-encrypt-GUSLCSKS.js +112 -0
  85. package/dist/vault-init-GUBOTOUL.js +106 -0
  86. package/dist/vault-rekey-DAHT7JCN.js +132 -0
  87. package/dist/vault-status-GDLRU2OK.js +90 -0
  88. package/dist/vault-verify-CD76FJSF.js +102 -0
  89. package/package.json +106 -0
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Run the ultraenv CLI.
3
+ *
4
+ * @param argv - The raw argv array (process.argv.slice(2))
5
+ * @returns The exit code (0 = success, non-zero = failure)
6
+ */
7
+ declare function run(argv: string[]): Promise<number>;
8
+
9
+ export { run };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Run the ultraenv CLI.
3
+ *
4
+ * @param argv - The raw argv array (process.argv.slice(2))
5
+ * @returns The exit code (0 = success, non-zero = failure)
6
+ */
7
+ declare function run(argv: string[]): Promise<number>;
8
+
9
+ export { run };
@@ -0,0 +1,339 @@
1
+ import {
2
+ bold,
3
+ initColorSupport,
4
+ red
5
+ } from "../chunk-OMAOROL4.js";
6
+ import {
7
+ configureRenderer,
8
+ writeError,
9
+ writeLine
10
+ } from "../chunk-YN2KGTCB.js";
11
+ import {
12
+ loadConfig
13
+ } from "../chunk-4XUYMRK5.js";
14
+ import "../chunk-3VYXPTYV.js";
15
+ import {
16
+ VERSION
17
+ } from "../chunk-XC65ORJ5.js";
18
+ import {
19
+ UltraenvError
20
+ } from "../chunk-5G2DU52U.js";
21
+
22
+ // src/cli/parser.ts
23
+ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
24
+ "init",
25
+ "validate",
26
+ "typegen",
27
+ "sync",
28
+ "scan",
29
+ "debug",
30
+ "protect",
31
+ "vault",
32
+ "envs",
33
+ "ci",
34
+ "install-hook",
35
+ "doctor",
36
+ "completion",
37
+ "help",
38
+ "version"
39
+ ]);
40
+ var VAULT_SUBCOMMANDS = /* @__PURE__ */ new Set([
41
+ "init",
42
+ "encrypt",
43
+ "decrypt",
44
+ "rekey",
45
+ "status",
46
+ "diff",
47
+ "verify"
48
+ ]);
49
+ var ENVS_SUBCOMMANDS = /* @__PURE__ */ new Set([
50
+ "list",
51
+ "compare",
52
+ "validate",
53
+ "create",
54
+ "switch"
55
+ ]);
56
+ var CI_SUBCOMMANDS = /* @__PURE__ */ new Set([
57
+ "validate",
58
+ "check-sync",
59
+ "scan",
60
+ "setup"
61
+ ]);
62
+ var OPTIONS_WITH_VALUES = /* @__PURE__ */ new Set([
63
+ "--config",
64
+ "--format",
65
+ "--output",
66
+ "--cwd",
67
+ "--env",
68
+ "--schema",
69
+ "--out",
70
+ "--source",
71
+ "--target",
72
+ "--shell",
73
+ "--file",
74
+ "--exclude",
75
+ "--include"
76
+ ]);
77
+ function parseArgs(args) {
78
+ const flags = {};
79
+ const positional = [];
80
+ const commandParts = [];
81
+ let i = 0;
82
+ while (i < args.length) {
83
+ const arg = args[i];
84
+ if (arg === "") {
85
+ i++;
86
+ continue;
87
+ }
88
+ if (arg.startsWith("--no-")) {
89
+ const flagName = arg.slice(5);
90
+ flags[`--${flagName}`] = false;
91
+ i++;
92
+ continue;
93
+ }
94
+ if (arg.startsWith("--")) {
95
+ const eqIndex = arg.indexOf("=");
96
+ if (eqIndex !== -1) {
97
+ const key = arg.slice(0, eqIndex);
98
+ const value = arg.slice(eqIndex + 1);
99
+ flags[key] = value;
100
+ i++;
101
+ continue;
102
+ }
103
+ if (OPTIONS_WITH_VALUES.has(arg) && i + 1 < args.length) {
104
+ const nextArg = args[i + 1];
105
+ if (!nextArg.startsWith("-")) {
106
+ flags[arg] = nextArg;
107
+ i += 2;
108
+ continue;
109
+ }
110
+ }
111
+ flags[arg] = true;
112
+ i++;
113
+ continue;
114
+ }
115
+ if (arg.startsWith("-") && arg.length > 1) {
116
+ const shortFlags = arg.slice(1);
117
+ for (let j = 0; j < shortFlags.length; j++) {
118
+ const ch = shortFlags[j];
119
+ const shortKey = `-${ch}`;
120
+ if (j === shortFlags.length - 1) {
121
+ const valuePart = shortFlags.slice(j + 1);
122
+ if (valuePart.length > 0) {
123
+ flags[shortKey] = valuePart;
124
+ break;
125
+ }
126
+ }
127
+ if ((ch === "c" || ch === "f" || ch === "o") && i + 1 < args.length && j === shortFlags.length - 1) {
128
+ const nextArg = args[i + 1];
129
+ if (!nextArg.startsWith("-")) {
130
+ flags[shortKey] = nextArg;
131
+ i++;
132
+ break;
133
+ }
134
+ }
135
+ flags[shortKey] = true;
136
+ }
137
+ i++;
138
+ continue;
139
+ }
140
+ if (commandParts.length === 0 && KNOWN_COMMANDS.has(arg)) {
141
+ commandParts.push(arg);
142
+ i++;
143
+ if (arg === "vault" && i < args.length && VAULT_SUBCOMMANDS.has(args[i])) {
144
+ commandParts.push(args[i]);
145
+ i++;
146
+ } else if (arg === "envs" && i < args.length && ENVS_SUBCOMMANDS.has(args[i])) {
147
+ commandParts.push(args[i]);
148
+ i++;
149
+ } else if (arg === "ci" && i < args.length && CI_SUBCOMMANDS.has(args[i])) {
150
+ commandParts.push(args[i]);
151
+ i++;
152
+ }
153
+ continue;
154
+ }
155
+ positional.push(arg);
156
+ i++;
157
+ }
158
+ const command = commandParts.length > 0 ? commandParts.join(".") : flags["--help"] || flags["-h"] ? "help" : flags["--version"] || flags["-v"] === "--version" ? "version" : "help";
159
+ return {
160
+ command,
161
+ flags,
162
+ positional,
163
+ raw: args
164
+ };
165
+ }
166
+
167
+ // src/cli/ui/banner.ts
168
+ function showBanner() {
169
+ return `
170
+ \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
171
+ \u2551 \u2551
172
+ \u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 \u2551
173
+ \u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u255D \u2551
174
+ \u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2551
175
+ \u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2588\u2588\u2557 \u2551
176
+ \u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2557 \u2551
177
+ \u2551 \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u2551
178
+ \u2551 \u2551
179
+ \u2551 The Ultimate Environment Variable Manager \u2551
180
+ \u2551 v${VERSION.padEnd(42)}\u2551
181
+ \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D`.trimStart();
182
+ }
183
+ var TAGLINE = "The Ultimate Environment Variable Manager";
184
+ function showWelcome() {
185
+ return `${showBanner()}
186
+ ${TAGLINE}
187
+ `;
188
+ }
189
+
190
+ // src/cli/index.ts
191
+ import { resolve } from "path";
192
+ var COMMAND_REGISTRY = {
193
+ // Core commands
194
+ "init": () => import("../init-Y7JQ2KYJ.js").then((m) => ({ runner: m.run, description: "Initialize project" })),
195
+ "validate": () => import("../validate-IOAM5HWS.js").then((m) => ({ runner: m.run, description: "Validate environment" })),
196
+ "typegen": () => import("../typegen-SQOSXBWM.js").then((m) => ({ runner: m.run, description: "Generate TypeScript types" })),
197
+ "sync": () => import("../sync-TMHMTLH2.js").then((m) => ({ runner: m.run, description: "Sync .env.example" })),
198
+ "scan": () => import("../scan-TRLY36TT.js").then((m) => ({ runner: m.run, description: "Scan for secrets" })),
199
+ "debug": () => import("../debug-PTPXAF3K.js").then((m) => ({ runner: m.run, description: "Show diagnostics" })),
200
+ "protect": () => import("../protect-NCWPM6VC.js").then((m) => ({ runner: m.run, description: "Check .gitignore" })),
201
+ // Vault subcommands
202
+ "vault.init": () => import("../vault-init-GUBOTOUL.js").then((m) => ({ runner: m.run, description: "Initialize vault" })),
203
+ "vault.encrypt": () => import("../vault-encrypt-GUSLCSKS.js").then((m) => ({ runner: m.run, description: "Encrypt to vault" })),
204
+ "vault.decrypt": () => import("../vault-decrypt-U6HJZNBV.js").then((m) => ({ runner: m.run, description: "Decrypt from vault" })),
205
+ "vault.rekey": () => import("../vault-rekey-DAHT7JCN.js").then((m) => ({ runner: m.run, description: "Rotate keys" })),
206
+ "vault.status": () => import("../vault-status-GDLRU2OK.js").then((m) => ({ runner: m.run, description: "Vault status" })),
207
+ "vault.diff": () => import("../vault-diff-B3ZOQTWI.js").then((m) => ({ runner: m.run, description: "Compare vs vault" })),
208
+ "vault.verify": () => import("../vault-verify-CD76FJSF.js").then((m) => ({ runner: m.run, description: "Verify integrity" })),
209
+ // Environment subcommands
210
+ "envs.list": () => import("../envs-list-NQM5252B.js").then((m) => ({ runner: m.run, description: "List environments" })),
211
+ "envs.compare": () => import("../envs-compare-5K3HESX5.js").then((m) => ({ runner: m.run, description: "Compare envs" })),
212
+ "envs.validate": () => import("../envs-validate-FL73Q76T.js").then((m) => ({ runner: m.run, description: "Validate envs" })),
213
+ "envs.create": () => import("../envs-create-2XXHXMGA.js").then((m) => ({ runner: m.run, description: "Create environment" })),
214
+ "envs.switch": () => import("../envs-switch-6L2AQYID.js").then((m) => ({ runner: m.run, description: "Switch environment" })),
215
+ // CI subcommands
216
+ "ci.validate": () => import("../ci-validate-7AW24LSQ.js").then((m) => ({ runner: m.run, description: "CI validate" })),
217
+ "ci.check-sync": () => import("../ci-check-sync-VBMSVWIV.js").then((m) => ({ runner: m.run, description: "CI sync check" })),
218
+ "ci.scan": () => import("../ci-scan-24MT5XGS.js").then((m) => ({ runner: m.run, description: "CI scan" })),
219
+ "ci.setup": () => import("../ci-setup-C2NKEFRD.js").then((m) => ({ runner: m.run, description: "CI setup" })),
220
+ // Utility commands
221
+ "install-hook": () => import("../install-hook-SKXIV6NV.js").then((m) => ({ runner: m.run, description: "Install git hook" })),
222
+ "doctor": () => import("../doctor-FZAUPKHS.js").then((m) => ({ runner: m.run, description: "Self-check" })),
223
+ "completion": () => import("../completion-MW35C2XO.js").then((m) => ({ runner: m.run, description: "Shell completions" })),
224
+ "help": () => import("../help-3XJBXEHE.js").then((m) => ({ runner: m.run, description: "Show help" }))
225
+ };
226
+ function handleVersion() {
227
+ writeLine(`ultraenv v${VERSION}`);
228
+ return 0;
229
+ }
230
+ function resolveConfig(args) {
231
+ const configPath = args.flags["--config"];
232
+ const cwd = resolve(args.flags["--cwd"] ?? process.cwd());
233
+ const config = loadConfig(configPath);
234
+ const outputFormat = args.flags["--format"] ?? config.outputFormat;
235
+ const debug = args.flags["--debug"] ?? config.debug ?? false;
236
+ const quiet = args.flags["--quiet"] ?? args.flags["-q"] ?? config.silent ?? false;
237
+ return { config, cwd, outputFormat, debug, quiet };
238
+ }
239
+ async function run(argv) {
240
+ const args = parseArgs(argv);
241
+ if (args.flags["--version"] || args.flags["-v"] === "--version" || args.command === "version") {
242
+ return handleVersion();
243
+ }
244
+ if (args.flags["--help"] || args.flags["-h"] || args.command === "help") {
245
+ const config2 = resolveConfig(args);
246
+ configureRenderer({
247
+ quiet: config2.quiet,
248
+ debug: config2.debug,
249
+ format: config2.outputFormat
250
+ });
251
+ if (args.positional.length > 0) {
252
+ const helpCmd2 = COMMAND_REGISTRY["help"];
253
+ if (helpCmd2) {
254
+ const entry = await helpCmd2();
255
+ return entry.runner(args, { config: config2.config, cwd: config2.cwd, colorEnabled: true, debug: config2.debug, quiet: config2.quiet, outputFormat: config2.outputFormat });
256
+ }
257
+ return 1;
258
+ }
259
+ const helpCmd = COMMAND_REGISTRY["help"];
260
+ if (helpCmd) {
261
+ const entry = await helpCmd();
262
+ return entry.runner(args, { config: config2.config, cwd: config2.cwd, colorEnabled: true, debug: config2.debug, quiet: config2.quiet, outputFormat: config2.outputFormat });
263
+ }
264
+ return 1;
265
+ }
266
+ const { config, cwd, outputFormat, debug, quiet } = resolveConfig(args);
267
+ const noColor = args.flags["--no-color"];
268
+ initColorSupport(noColor);
269
+ configureRenderer({
270
+ quiet,
271
+ debug,
272
+ format: outputFormat
273
+ });
274
+ const ctx = {
275
+ config,
276
+ cwd,
277
+ colorEnabled: !noColor,
278
+ debug,
279
+ quiet,
280
+ outputFormat
281
+ };
282
+ if (!quiet && outputFormat === "terminal") {
283
+ if (!args.command.includes(".") && args.command !== "completion") {
284
+ writeLine(showWelcome());
285
+ }
286
+ }
287
+ const commandLoader = COMMAND_REGISTRY[args.command];
288
+ if (!commandLoader) {
289
+ writeError(red(bold(` Unknown command: ${args.command}`)));
290
+ writeLine("");
291
+ writeError(' Run "ultraenv help" to see available commands.');
292
+ writeLine("");
293
+ return 1;
294
+ }
295
+ try {
296
+ const entry = await commandLoader();
297
+ const exitCode = await entry.runner(args, ctx);
298
+ return exitCode;
299
+ } catch (error) {
300
+ if (error instanceof UltraenvError) {
301
+ if (outputFormat === "json") {
302
+ writeError(JSON.stringify({
303
+ error: true,
304
+ code: error.code,
305
+ message: error.message,
306
+ hint: error.hint
307
+ }, null, 2));
308
+ } else {
309
+ writeError("");
310
+ writeError(red(bold(` [${error.code}] ${error.message}`)));
311
+ if (error.hint) {
312
+ writeError("");
313
+ writeError(` Hint: ${error.hint}`);
314
+ }
315
+ writeError("");
316
+ }
317
+ return 1;
318
+ }
319
+ if (outputFormat === "json") {
320
+ writeError(JSON.stringify({
321
+ error: true,
322
+ message: error instanceof Error ? error.message : String(error)
323
+ }, null, 2));
324
+ } else {
325
+ writeError("");
326
+ writeError(red(bold(" Unexpected error:")));
327
+ writeError(red(` ${error instanceof Error ? error.message : String(error)}`));
328
+ if (debug && error instanceof Error && error.stack) {
329
+ writeError("");
330
+ writeError(error.stack);
331
+ }
332
+ writeError("");
333
+ }
334
+ return 1;
335
+ }
336
+ }
337
+ export {
338
+ run
339
+ };
@@ -0,0 +1,13 @@
1
+ import {
2
+ compareSync,
3
+ compareValues,
4
+ formatSyncDiff
5
+ } from "./chunk-YVWLXFUT.js";
6
+ import "./chunk-HFXQGJY3.js";
7
+ import "./chunk-3VYXPTYV.js";
8
+ import "./chunk-5G2DU52U.js";
9
+ export {
10
+ compareSync,
11
+ compareValues,
12
+ formatSyncDiff
13
+ };
@@ -0,0 +1,168 @@
1
+ import {
2
+ writeError,
3
+ writeLine
4
+ } from "./chunk-YN2KGTCB.js";
5
+
6
+ // src/cli/commands/completion.ts
7
+ var BASH_COMPLETION = `# ultraenv bash completion
8
+ _ultraenv_completions() {
9
+ local cur prev words cword
10
+ _init_completion || return
11
+
12
+ local commands="init validate typegen sync scan debug protect vault envs ci install-hook doctor completion help version"
13
+ local vault_cmds="init encrypt decrypt rekey status diff verify"
14
+ local envs_cmds="list compare validate create switch"
15
+ local ci_cmds="validate check-sync scan setup"
16
+
17
+ if [[ \${cword} -eq 1 ]]; then
18
+ COMPREPLY=($(compgen -W "\${commands}" -- "\${cur}"))
19
+ return
20
+ fi
21
+
22
+ if [[ "\${prev}" == "vault" ]]; then
23
+ COMPREPLY=($(compgen -W "\${vault_cmds}" -- "\${cur}"))
24
+ return
25
+ fi
26
+
27
+ if [[ "\${prev}" == "envs" ]]; then
28
+ COMPREPLY=($(compgen -W "\${envs_cmds}" -- "\${cur}"))
29
+ return
30
+ fi
31
+
32
+ if [[ "\${prev}" == "ci" ]]; then
33
+ COMPREPLY=($(compgen -W "\${ci_cmds}" -- "\${cur}"))
34
+ return
35
+ fi
36
+
37
+ # Complete flags
38
+ local flags="--help -h --version -v --no-color --verbose --quiet -q --strict --debug --cwd --config --format"
39
+ COMPREPLY=($(compgen -W "\${flags}" -- "\${cur}"))
40
+ }
41
+
42
+ complete -F _ultraenv_completions ultraenv
43
+ `;
44
+ var ZSH_COMPLETION = `#compdef ultraenv
45
+
46
+ _ultraenv() {
47
+ local -a commands
48
+ commands=(
49
+ 'init:Initialize ultraenv project'
50
+ 'validate:Validate environment'
51
+ 'typegen:Generate TypeScript types'
52
+ 'sync:Sync .env.example'
53
+ 'scan:Scan for secrets'
54
+ 'debug:Show diagnostics'
55
+ 'protect:Check .gitignore protection'
56
+ 'vault:Vault operations'
57
+ 'envs:Environment management'
58
+ 'ci:CI/CD operations'
59
+ 'install-hook:Install git hook'
60
+ 'doctor:Self-check'
61
+ 'completion:Shell completions'
62
+ 'help:Show help'
63
+ 'version:Show version'
64
+ )
65
+
66
+ local -a vault_cmds
67
+ vault_cmds=(init encrypt decrypt rekey status diff verify)
68
+
69
+ local -a envs_cmds
70
+ envs_cmds=(list compare validate create switch)
71
+
72
+ local -a ci_cmds
73
+ ci_cmds=(validate check-sync scan setup)
74
+
75
+ local -a flags
76
+ flags=(--help -h --version --no-color --verbose --quiet --strict --debug --cwd --config --format)
77
+
78
+ if (( CURRENT == 2 )); then
79
+ _describe 'command' commands
80
+ return
81
+ fi
82
+
83
+ case $words[2] in
84
+ vault)
85
+ if (( CURRENT == 3 )); then
86
+ _describe 'vault command' vault_cmds
87
+ fi
88
+ ;;
89
+ envs)
90
+ if (( CURRENT == 3 )); then
91
+ _describe 'envs command' envs_cmds
92
+ fi
93
+ ;;
94
+ ci)
95
+ if (( CURRENT == 3 )); then
96
+ _describe 'ci command' ci_cmds
97
+ fi
98
+ ;;
99
+ *)
100
+ _describe 'flags' flags
101
+ ;;
102
+ esac
103
+ }
104
+
105
+ _ultraenv "$@"
106
+ `;
107
+ var FISH_COMPLETION = `# ultraenv fish shell completion
108
+
109
+ # Disable file completions
110
+ complete -c ultraenv -f
111
+
112
+ # Main commands
113
+ complete -c ultraenv -n '__fish_is_first_arg' -a init validate typegen sync scan debug protect vault envs ci install-hook doctor completion help version
114
+
115
+ # Vault subcommands
116
+ complete -c ultraenv -n '__fish_seen_subcommand_from vault' -a init encrypt decrypt rekey status diff verify
117
+
118
+ # Envs subcommands
119
+ complete -c ultraenv -n '__fish_seen_subcommand_from envs' -a list compare validate create switch
120
+
121
+ # CI subcommands
122
+ complete -c ultraenv -n '__fish_seen_subcommand_from ci' -a validate check-sync scan setup
123
+
124
+ # Global flags
125
+ complete -c ultraenv -l help -s h -d 'Show help'
126
+ complete -c ultraenv -l version -d 'Show version'
127
+ complete -c ultraenv -l no-color -d 'Disable colors'
128
+ complete -c ultraenv -l verbose -s v -d 'Verbose output'
129
+ complete -c ultraenv -l quiet -s q -d 'Quiet output'
130
+ complete -c ultraenv -l strict -d 'Strict mode'
131
+ complete -c ultraenv -l debug -d 'Debug output'
132
+ complete -c ultraenv -l cwd -d 'Working directory'
133
+ complete -c ultraenv -l config -d 'Config file path'
134
+ complete -c ultraenv -l format -d 'Output format'
135
+ `;
136
+ async function run(args, _ctx) {
137
+ const shell = args.flags["--shell"] ?? args.positional[0];
138
+ if (!shell || shell === "help") {
139
+ writeLine(" Usage: ultraenv completion <shell>");
140
+ writeLine("");
141
+ writeLine(" Available shells: bash, zsh, fish");
142
+ writeLine("");
143
+ writeLine(" Install:");
144
+ writeLine(' eval "$(ultraenv completion bash)"');
145
+ writeLine(' eval "$(ultraenv completion zsh)"');
146
+ writeLine(" ultraenv completion fish | source");
147
+ writeLine("");
148
+ return 0;
149
+ }
150
+ switch (shell) {
151
+ case "bash":
152
+ process.stdout.write(BASH_COMPLETION);
153
+ return 0;
154
+ case "zsh":
155
+ process.stdout.write(ZSH_COMPLETION);
156
+ return 0;
157
+ case "fish":
158
+ process.stdout.write(FISH_COMPLETION);
159
+ return 0;
160
+ default:
161
+ writeError(` Unsupported shell: ${shell}`);
162
+ writeError(" Supported: bash, zsh, fish");
163
+ return 1;
164
+ }
165
+ }
166
+ export {
167
+ run
168
+ };
@@ -0,0 +1,13 @@
1
+ import {
2
+ DEFAULT_CONFIG,
3
+ findConfig,
4
+ loadConfig
5
+ } from "./chunk-4XUYMRK5.js";
6
+ import "./chunk-3VYXPTYV.js";
7
+ import "./chunk-XC65ORJ5.js";
8
+ import "./chunk-5G2DU52U.js";
9
+ export {
10
+ DEFAULT_CONFIG,
11
+ findConfig,
12
+ loadConfig
13
+ };
@@ -0,0 +1,131 @@
1
+ import {
2
+ drawTable
3
+ } from "./chunk-WMHN5RW2.js";
4
+ import {
5
+ isGitRepository
6
+ } from "./chunk-R7PZRSZ7.js";
7
+ import {
8
+ loadWithResult
9
+ } from "./chunk-MNVFG7H4.js";
10
+ import "./chunk-HFXQGJY3.js";
11
+ import {
12
+ bold,
13
+ cyan,
14
+ dim,
15
+ green,
16
+ red,
17
+ yellow
18
+ } from "./chunk-OMAOROL4.js";
19
+ import {
20
+ writeError,
21
+ writeLine
22
+ } from "./chunk-YN2KGTCB.js";
23
+ import {
24
+ findConfig
25
+ } from "./chunk-4XUYMRK5.js";
26
+ import "./chunk-3VYXPTYV.js";
27
+ import {
28
+ VERSION
29
+ } from "./chunk-XC65ORJ5.js";
30
+ import "./chunk-5G2DU52U.js";
31
+
32
+ // src/cli/commands/debug.ts
33
+ import { resolve } from "path";
34
+ import { existsSync } from "fs";
35
+ async function run(args, ctx) {
36
+ try {
37
+ const cwd = args.flags["--cwd"] ?? ctx.cwd;
38
+ const baseDir = resolve(cwd);
39
+ writeLine(bold("\u{1F527} ultraenv Diagnostics"));
40
+ writeLine("");
41
+ writeLine(bold(" System Information:"));
42
+ writeLine(` ultraenv version: ${cyan(VERSION)}`);
43
+ writeLine(` Node.js: ${cyan(process.version)}`);
44
+ writeLine(` Platform: ${cyan(process.platform)} ${process.arch}`);
45
+ writeLine(` CWD: ${cyan(baseDir)}`);
46
+ writeLine(` TTY: ${cyan(String(process.stdout.isTTY))}`);
47
+ writeLine("");
48
+ writeLine(bold(" Git Status:"));
49
+ const isGit = await isGitRepository(baseDir);
50
+ writeLine(` Repository: ${isGit ? green("Yes") : yellow("No")}`);
51
+ if (isGit) {
52
+ const { getCurrentBranch, isDirty, getCommitHash } = await import("./git-BZS4DPAI.js");
53
+ const branch = await getCurrentBranch(baseDir);
54
+ const dirty = await isDirty(baseDir);
55
+ const commit = await getCommitHash(baseDir);
56
+ writeLine(` Branch: ${cyan(branch ?? "detached")}`);
57
+ writeLine(` Dirty: ${dirty ? yellow("Yes") : green("No")}`);
58
+ writeLine(` Commit: ${cyan(commit ?? "unknown")}`);
59
+ }
60
+ writeLine("");
61
+ writeLine(bold(" Configuration:"));
62
+ const configPath = findConfig(baseDir);
63
+ if (configPath !== null) {
64
+ writeLine(` Config file: ${cyan(configPath)}`);
65
+ } else {
66
+ writeLine(` Config file: ${yellow("Not found (using defaults)")}`);
67
+ }
68
+ writeLine(` envDir: ${cyan(ctx.config.envDir)}`);
69
+ writeLine(` mergeStrategy: ${cyan(ctx.config.mergeStrategy)}`);
70
+ writeLine(` expandVars: ${cyan(String(ctx.config.expandVariables))}`);
71
+ writeLine(` outputFormat: ${cyan(ctx.config.outputFormat)}`);
72
+ writeLine(` debug: ${cyan(String(ctx.config.debug))}`);
73
+ writeLine("");
74
+ writeLine(bold(" Environment Files:"));
75
+ const envFiles = [
76
+ ".env",
77
+ ".env.local",
78
+ ".env.development",
79
+ ".env.production",
80
+ ".env.staging",
81
+ ".env.test",
82
+ ".env.ci"
83
+ ];
84
+ const fileHeaders = ["File", "Exists", "Size", "Modified"];
85
+ const fileRows = [];
86
+ for (const file of envFiles) {
87
+ const filePath = resolve(baseDir, ctx.config.envDir, file);
88
+ const exists = existsSync(filePath);
89
+ if (exists) {
90
+ const stat = await import("fs/promises").then((m) => m.stat(filePath));
91
+ const size = `${(stat.size / 1024).toFixed(1)} KB`;
92
+ const modified = stat.mtime.toISOString().slice(0, 19).replace("T", " ");
93
+ fileRows.push([file, green("Yes"), size, modified]);
94
+ } else {
95
+ fileRows.push([file, dim("No"), "-", "-"]);
96
+ }
97
+ }
98
+ writeLine(drawTable(fileHeaders, fileRows, { maxWidth: 100 }));
99
+ writeLine("");
100
+ writeLine(bold(" Load Test:"));
101
+ const startTime = Date.now();
102
+ try {
103
+ const result = loadWithResult({
104
+ envDir: baseDir,
105
+ expandVariables: ctx.config.expandVariables,
106
+ overrideProcessEnv: false
107
+ });
108
+ const loadTime = Date.now() - startTime;
109
+ writeLine(` Status: ${green("Success")}`);
110
+ writeLine(` Variables: ${cyan(String(result.metadata.totalVars))}`);
111
+ writeLine(` Files parsed: ${cyan(String(result.metadata.filesParsed))}`);
112
+ writeLine(` Load time: ${cyan(`${loadTime}ms`)}`);
113
+ } catch (err) {
114
+ const loadTime = Date.now() - startTime;
115
+ writeLine(` Status: ${red("Failed")}`);
116
+ writeLine(` Load time: ${cyan(`${loadTime}ms`)}`);
117
+ writeLine(` Error: ${red(err instanceof Error ? err.message : String(err))}`);
118
+ }
119
+ writeLine("");
120
+ writeLine(green(bold(" Diagnostics complete.")));
121
+ writeLine("");
122
+ return 0;
123
+ } catch (error) {
124
+ const msg = error instanceof Error ? error.message : String(error);
125
+ writeError(red(` Diagnostics error: ${msg}`));
126
+ return 1;
127
+ }
128
+ }
129
+ export {
130
+ run
131
+ };