@mtndev/cli 0.0.0-dev-20260618142325

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 (73) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/cjs/__chunks/4SFWHCB3.cjs +133 -0
  3. package/cjs/__chunks/B2KFW7T7.cjs +1 -0
  4. package/cjs/__chunks/EMMC33QA.cjs +401 -0
  5. package/cjs/__chunks/FFFTVBUR.cjs +22 -0
  6. package/cjs/__chunks/HFSXD6YE.cjs +100 -0
  7. package/cjs/__chunks/INFOPAHN.cjs +117 -0
  8. package/cjs/__chunks/J36P6UNE.cjs +75 -0
  9. package/cjs/__chunks/NIMXXHJQ.cjs +92 -0
  10. package/cjs/__chunks/QBNNK2WX.cjs +52 -0
  11. package/cjs/__chunks/WNJ3ZYLI.cjs +1 -0
  12. package/cjs/commands/doppler/handler.cjs +9 -0
  13. package/cjs/commands/doppler/handler.d.ts +5 -0
  14. package/cjs/commands/doppler/index.cjs +41 -0
  15. package/cjs/commands/doppler/index.d.ts +3 -0
  16. package/cjs/commands/doppler/schema.cjs +8 -0
  17. package/cjs/commands/doppler/schema.d.ts +50 -0
  18. package/cjs/commands/doppler/utils/exec.cjs +12 -0
  19. package/cjs/commands/doppler/utils/exec.d.ts +52 -0
  20. package/cjs/commands/doppler/utils.cjs +30 -0
  21. package/cjs/commands/doppler/utils.d.ts +69 -0
  22. package/cjs/commands/icons/handler.cjs +8 -0
  23. package/cjs/commands/icons/handler.d.ts +5 -0
  24. package/cjs/commands/icons/index.cjs +31 -0
  25. package/cjs/commands/icons/index.d.ts +3 -0
  26. package/cjs/commands/icons/schema.cjs +16 -0
  27. package/cjs/commands/icons/schema.d.ts +86 -0
  28. package/cjs/commands/icons/utils.cjs +13 -0
  29. package/cjs/commands/icons/utils.d.ts +52 -0
  30. package/cjs/commands/index.cjs +84 -0
  31. package/cjs/commands/index.d.ts +2 -0
  32. package/cjs/commands/schema.cjs +8 -0
  33. package/cjs/commands/schema.d.ts +26 -0
  34. package/cjs/index.cjs +5 -0
  35. package/cjs/index.d.ts +2 -0
  36. package/esm/__chunks/46HGXFME.js +0 -0
  37. package/esm/__chunks/6G4PXXKF.js +75 -0
  38. package/esm/__chunks/EC6MPHID.js +22 -0
  39. package/esm/__chunks/FL7AILGH.js +133 -0
  40. package/esm/__chunks/G6WUCFLD.js +100 -0
  41. package/esm/__chunks/HJSXC6HP.js +117 -0
  42. package/esm/__chunks/LHVSSZI7.js +52 -0
  43. package/esm/__chunks/O262GK4B.js +401 -0
  44. package/esm/__chunks/SJXQJ7RS.js +92 -0
  45. package/esm/__chunks/SNCKIAOR.js +0 -0
  46. package/esm/commands/doppler/handler.d.ts +5 -0
  47. package/esm/commands/doppler/handler.js +9 -0
  48. package/esm/commands/doppler/index.d.ts +3 -0
  49. package/esm/commands/doppler/index.js +41 -0
  50. package/esm/commands/doppler/schema.d.ts +50 -0
  51. package/esm/commands/doppler/schema.js +8 -0
  52. package/esm/commands/doppler/utils/exec.d.ts +52 -0
  53. package/esm/commands/doppler/utils/exec.js +12 -0
  54. package/esm/commands/doppler/utils.d.ts +69 -0
  55. package/esm/commands/doppler/utils.js +30 -0
  56. package/esm/commands/icons/handler.d.ts +5 -0
  57. package/esm/commands/icons/handler.js +8 -0
  58. package/esm/commands/icons/index.d.ts +3 -0
  59. package/esm/commands/icons/index.js +31 -0
  60. package/esm/commands/icons/schema.d.ts +86 -0
  61. package/esm/commands/icons/schema.js +16 -0
  62. package/esm/commands/icons/utils.d.ts +52 -0
  63. package/esm/commands/icons/utils.js +13 -0
  64. package/esm/commands/index.d.ts +2 -0
  65. package/esm/commands/index.js +84 -0
  66. package/esm/commands/schema.d.ts +26 -0
  67. package/esm/commands/schema.js +8 -0
  68. package/esm/index.d.ts +2 -0
  69. package/esm/index.js +5 -0
  70. package/package.json +62 -0
  71. package/utils/input/package.json +8 -0
  72. package/utils/package/package.json +8 -0
  73. package/utils/validation/package.json +8 -0
@@ -0,0 +1,117 @@
1
+ import {
2
+ checkDependencies,
3
+ generateAllIcons,
4
+ validateBaseIcons
5
+ } from "./FL7AILGH.js";
6
+ import {
7
+ iconsCommandMetadata,
8
+ iconsCommandOptionsSchema
9
+ } from "./6G4PXXKF.js";
10
+
11
+ // src/commands/icons/handler.js
12
+ import chalk from "chalk";
13
+ import { ZodError } from "zod";
14
+ async function iconsCommand(options) {
15
+ try {
16
+ const validatedOptions = iconsCommandOptionsSchema.parse(options);
17
+ if (validatedOptions.help) {
18
+ console.log(chalk.bold(`
19
+ Usage: mtn icons <input> [options]`));
20
+ console.log(chalk.gray(iconsCommandMetadata.description));
21
+ console.log(chalk.bold("\nOptions:"));
22
+ Object.entries(iconsCommandOptionsSchema.shape).forEach(
23
+ ([key, fieldSchema]) => {
24
+ if (key === "input") return;
25
+ const description = fieldSchema.description || "No description available";
26
+ const optionMeta = (
27
+ /** @type {any} */
28
+ iconsCommandMetadata.options[key]
29
+ );
30
+ const defaultValue = optionMeta?.default ?? false;
31
+ const alias = optionMeta?.alias ? chalk.cyan(`, -${optionMeta.alias}`) : "";
32
+ console.log(
33
+ chalk.cyan(` --${key}`) + alias + ` ${description} (default: ${defaultValue})`
34
+ );
35
+ }
36
+ );
37
+ console.log("");
38
+ return;
39
+ }
40
+ const { input, channels, iconTypes, verbose } = validatedOptions;
41
+ if (verbose) {
42
+ console.log(chalk.blue("\n\u{1F4F1} Icon Generation"));
43
+ console.log(chalk.gray(` Input directory: ${input}`));
44
+ console.log(chalk.gray(` Channels: ${channels.join(", ")}`));
45
+ console.log(chalk.gray(` Icon types: ${iconTypes.join(", ")}`));
46
+ }
47
+ checkDependencies(verbose);
48
+ validateBaseIcons(input, iconTypes, verbose);
49
+ const result = generateAllIcons({
50
+ baseDir: input,
51
+ channels,
52
+ iconTypes,
53
+ verbose
54
+ });
55
+ console.log(chalk.bold("\n\u{1F4CA} Summary:"));
56
+ console.log(
57
+ chalk.green(
58
+ ` \u2713 Successfully generated: ${result.success.length} icon(s)`
59
+ )
60
+ );
61
+ if (result.failed.length > 0) {
62
+ console.log(chalk.red(` \u2717 Failed: ${result.failed.length} icon(s)`));
63
+ result.failed.forEach(({ icon, error }) => {
64
+ console.log(chalk.red(` - ${icon}: ${error}`));
65
+ });
66
+ process.exit(1);
67
+ }
68
+ console.log(chalk.green(`
69
+ \u2705 All icons generated successfully!`));
70
+ } catch (error) {
71
+ if (error instanceof ZodError) {
72
+ console.error(chalk.red(`
73
+ \u274C Invalid command options:`));
74
+ error.errors.forEach((err) => {
75
+ console.error(chalk.red(` ${err.path.join(".")}: ${err.message}`));
76
+ });
77
+ process.exit(1);
78
+ }
79
+ const verbose = (
80
+ /** @type {any} */
81
+ options?.verbose || false
82
+ );
83
+ console.error(chalk.red(`
84
+ \u274C Icon generation failed:`));
85
+ if (error instanceof Error) {
86
+ console.error(chalk.red(` ${error.message}`));
87
+ if (verbose && error.stack) {
88
+ console.error(chalk.gray("\nStack trace:"));
89
+ console.error(chalk.gray(error.stack));
90
+ }
91
+ } else {
92
+ console.error(chalk.red(` ${String(error)}`));
93
+ }
94
+ console.error(chalk.yellow("\n\u{1F4A1} Troubleshooting tips:"));
95
+ console.error(
96
+ chalk.yellow(
97
+ " \u2022 Ensure ImageMagick is installed (brew install imagemagick)"
98
+ )
99
+ );
100
+ console.error(
101
+ chalk.yellow(
102
+ " \u2022 Make sure icon.png and adaptive-icon.png exist in the input directory"
103
+ )
104
+ );
105
+ console.error(
106
+ chalk.yellow(" \u2022 Verify the input directory path is correct")
107
+ );
108
+ console.error(
109
+ chalk.yellow(" \u2022 Use --verbose for detailed error information\n")
110
+ );
111
+ process.exit(1);
112
+ }
113
+ }
114
+
115
+ export {
116
+ iconsCommand
117
+ };
@@ -0,0 +1,52 @@
1
+ // src/commands/doppler/schema.js
2
+ import { z } from "zod";
3
+ var dopplerCommandOptionsSchema = z.object({
4
+ action: z.enum(["download", "upload"], {
5
+ errorMap: () => ({
6
+ message: "Action must be either 'download' or 'upload'"
7
+ })
8
+ }).describe("Action to perform: download or upload configurations"),
9
+ environment: z.string().optional().default("dev").describe(
10
+ 'Environment configuration to process (e.g., dev, stg, prd, or "all" for all configs)'
11
+ ),
12
+ verbose: z.boolean().optional().default(false).describe("Enable verbose logging for detailed error information"),
13
+ help: z.boolean().optional().default(false).describe("Display help for command")
14
+ });
15
+ var dopplerCommandMetadata = {
16
+ name: "doppler",
17
+ description: `Manage Doppler configurations
18
+
19
+ Subcommands:
20
+ download Download configurations from Doppler to local .env files
21
+ upload Upload local .env files to Doppler (with confirmation prompt)
22
+
23
+ Examples:
24
+ $ @mtndev/cli doppler download # Download dev config to .env.dev
25
+ $ @mtndev/cli doppler download -e all # Download all configs
26
+ $ @mtndev/cli doppler download -e stg # Download staging config
27
+ $ @mtndev/cli doppler upload # Upload .env.dev to Doppler
28
+ $ @mtndev/cli doppler upload -e prd # Upload production config`,
29
+ options: {
30
+ environment: {
31
+ description: dopplerCommandOptionsSchema.shape.environment.description,
32
+ default: "dev",
33
+ alias: "t"
34
+ },
35
+ // Global options are included here for help display
36
+ verbose: {
37
+ description: dopplerCommandOptionsSchema.shape.verbose.description,
38
+ default: false,
39
+ alias: "v"
40
+ },
41
+ help: {
42
+ description: dopplerCommandOptionsSchema.shape.help.description,
43
+ default: false,
44
+ alias: "h"
45
+ }
46
+ }
47
+ };
48
+
49
+ export {
50
+ dopplerCommandOptionsSchema,
51
+ dopplerCommandMetadata
52
+ };
@@ -0,0 +1,401 @@
1
+ import {
2
+ exec
3
+ } from "./SJXQJ7RS.js";
4
+
5
+ // src/commands/doppler/utils.js
6
+ import { execSync } from "child_process";
7
+ import {
8
+ copyFileSync,
9
+ existsSync,
10
+ readFileSync,
11
+ renameSync,
12
+ unlinkSync,
13
+ writeFileSync
14
+ } from "fs";
15
+ import { createInterface } from "readline";
16
+ import chalk from "chalk";
17
+ var DEFAULT_DOPPLER_ENVIRONMENT = "dev";
18
+ function execDoppler(args, parser = "string", silent = false, verbose = false) {
19
+ const command = `doppler ${args.join(" ")}`;
20
+ let verbosity = "default";
21
+ if (verbose) {
22
+ verbosity = "verbose";
23
+ } else if (silent) {
24
+ verbosity = "silent";
25
+ }
26
+ return exec(command, {
27
+ verbosity,
28
+ stdoutParser: parser,
29
+ throwOnError: true
30
+ });
31
+ }
32
+ function checkDependencies(verbose = false) {
33
+ if (verbose) {
34
+ console.log(chalk.blue("\n\u{1F50D} Checking Doppler dependencies..."));
35
+ }
36
+ try {
37
+ execSync("which doppler", { stdio: "pipe" });
38
+ if (verbose) {
39
+ console.log(chalk.green(" \u2713 Doppler CLI is installed"));
40
+ }
41
+ } catch {
42
+ throw new Error(
43
+ "Doppler is not installed. Please install Doppler (brew install dopplerhq/cli/doppler), login, setup, and try again."
44
+ );
45
+ }
46
+ try {
47
+ execDoppler(["me"], "string", true, verbose);
48
+ if (verbose) {
49
+ console.log(chalk.green(" \u2713 Doppler is authenticated"));
50
+ }
51
+ } catch {
52
+ throw new Error(
53
+ "Doppler is not logged in. Please run 'doppler login' then 'doppler setup' and try again."
54
+ );
55
+ }
56
+ try {
57
+ execDoppler(["configs", "--json"], "json", true, verbose);
58
+ if (verbose) {
59
+ console.log(chalk.green(" \u2713 Doppler project is configured"));
60
+ }
61
+ } catch {
62
+ throw new Error(
63
+ "Doppler is not configured. Please run 'doppler setup' and try again."
64
+ );
65
+ }
66
+ }
67
+ function getConfigs(environment, verbose = false) {
68
+ if (verbose) {
69
+ console.log(
70
+ chalk.blue(
71
+ `
72
+ \u{1F4CB} Resolving configurations for environment: ${chalk.cyan(environment)}`
73
+ )
74
+ );
75
+ }
76
+ const availableConfigs = execDoppler(
77
+ ["configs", "--json"],
78
+ "json",
79
+ true,
80
+ verbose
81
+ );
82
+ const configNames = Array.isArray(availableConfigs) ? availableConfigs.map(
83
+ (config) => config.name
84
+ ) : [];
85
+ if (verbose && configNames.length > 0) {
86
+ console.log(
87
+ chalk.gray(` Available configurations: ${configNames.join(", ")}`)
88
+ );
89
+ }
90
+ if (environment === "all") {
91
+ if (configNames.length === 0) {
92
+ throw new Error("No configurations found in Doppler");
93
+ }
94
+ if (verbose) {
95
+ console.log(
96
+ chalk.green(` \u2713 Using all ${configNames.length} configurations`)
97
+ );
98
+ }
99
+ return configNames;
100
+ }
101
+ if (configNames.length > 0 && !configNames.includes(environment)) {
102
+ throw new Error(
103
+ `Configuration "${environment}" not found. Available configurations: ${configNames.join(", ")}`
104
+ );
105
+ }
106
+ if (verbose) {
107
+ console.log(chalk.green(` \u2713 Using configuration: ${environment}`));
108
+ }
109
+ return [environment];
110
+ }
111
+ function normalizeEscapeSequences(content) {
112
+ return content.replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\r/g, "\r");
113
+ }
114
+ function createDiff(oldContent, newContent) {
115
+ const oldLines = oldContent.split("\n");
116
+ const newLines = newContent.split("\n");
117
+ const diff = [];
118
+ const maxLines = Math.max(oldLines.length, newLines.length);
119
+ for (let i = 0; i < maxLines; i++) {
120
+ const oldLine = oldLines[i] || "";
121
+ const newLine = newLines[i] || "";
122
+ if (oldLine !== newLine) {
123
+ if (oldLine && !newLine) {
124
+ diff.push(`-${oldLine}`);
125
+ } else if (!oldLine && newLine) {
126
+ diff.push(`+${newLine}`);
127
+ } else {
128
+ diff.push(`-${oldLine}`);
129
+ diff.push(`+${newLine}`);
130
+ }
131
+ }
132
+ }
133
+ return diff;
134
+ }
135
+ function promptConfirmation(message) {
136
+ return new Promise((resolve) => {
137
+ const rl = createInterface({
138
+ input: process.stdin,
139
+ output: process.stdout
140
+ });
141
+ rl.question(message, (answer) => {
142
+ rl.close();
143
+ resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
144
+ });
145
+ });
146
+ }
147
+ async function downloadConfigs(options) {
148
+ const { environment, verbose } = options;
149
+ const actualEnvironment = environment ?? DEFAULT_DOPPLER_ENVIRONMENT;
150
+ const configs = getConfigs(actualEnvironment, verbose);
151
+ if (verbose) {
152
+ console.log(
153
+ chalk.blue(
154
+ `
155
+ \u2B07\uFE0F Starting download process for ${configs.length} configuration(s)...`
156
+ )
157
+ );
158
+ }
159
+ if (configs.length === 1 && environment !== "all") {
160
+ console.log(
161
+ "You can use -e all to download all configurations, or -e <env> for a specific environment."
162
+ );
163
+ }
164
+ for (const config of configs) {
165
+ const envFile = `.env.${config}`;
166
+ const backupFile = `${envFile}.backup`;
167
+ let backupMsg = "";
168
+ if (verbose) {
169
+ console.log(chalk.blue(`
170
+ \u{1F4E6} Processing config: ${chalk.cyan(config)}`));
171
+ }
172
+ try {
173
+ if (existsSync(envFile)) {
174
+ if (verbose) {
175
+ console.log(chalk.gray(` Creating backup: ${backupFile}`));
176
+ }
177
+ renameSync(envFile, backupFile);
178
+ backupMsg = "Backed up existing file, ";
179
+ }
180
+ if (verbose) {
181
+ console.log(chalk.gray(` Downloading secrets from Doppler...`));
182
+ }
183
+ const content = execDoppler(
184
+ [
185
+ "secrets",
186
+ "download",
187
+ "--no-file",
188
+ "--format",
189
+ "env",
190
+ "--config",
191
+ config
192
+ ],
193
+ "string",
194
+ !verbose,
195
+ // Only silent if not verbose
196
+ verbose
197
+ );
198
+ if (typeof content === "string") {
199
+ writeFileSync(envFile, content, "utf-8");
200
+ if (verbose) {
201
+ console.log(chalk.gray(` Written to: ${envFile}`));
202
+ }
203
+ } else {
204
+ throw new Error("Invalid content received from Doppler");
205
+ }
206
+ console.log(
207
+ `Config ${chalk.blue(config)}: ${backupMsg}downloaded successfully to ${chalk.green(envFile)}`
208
+ );
209
+ if (config === "dev" && !existsSync(".env")) {
210
+ copyFileSync(envFile, ".env");
211
+ console.log(
212
+ `Copied ${chalk.green(".env.dev")} to ${chalk.green(".env")}`
213
+ );
214
+ }
215
+ if (existsSync(backupFile)) {
216
+ if (verbose) {
217
+ console.log(chalk.gray(` Removing backup file`));
218
+ }
219
+ unlinkSync(backupFile);
220
+ }
221
+ } catch (error) {
222
+ console.error(`Failed to download ${config}: ${error?.message || error}`);
223
+ if (existsSync(backupFile)) {
224
+ renameSync(backupFile, envFile);
225
+ console.log(`Restored backup for ${envFile}`);
226
+ }
227
+ }
228
+ }
229
+ }
230
+ async function uploadConfigs(options) {
231
+ const { environment, verbose } = options;
232
+ const configs = getConfigs(environment, verbose);
233
+ if (verbose) {
234
+ console.log(
235
+ chalk.blue(
236
+ `
237
+ \u2B06\uFE0F Starting upload process for ${configs.length} configuration(s)...`
238
+ )
239
+ );
240
+ }
241
+ for (const config of configs) {
242
+ const envFile = `.env.${config}`;
243
+ const backupFile = `${envFile}.doppler`;
244
+ const normalizedFile = `${envFile}.normalized`;
245
+ if (verbose) {
246
+ console.log(chalk.blue(`
247
+ \u{1F4E6} Processing config: ${chalk.cyan(config)}`));
248
+ }
249
+ try {
250
+ if (!existsSync(envFile)) {
251
+ console.log(
252
+ `Config ${config}: ${chalk.green(envFile)} does not exist. Skipping upload.`
253
+ );
254
+ continue;
255
+ }
256
+ if (verbose) {
257
+ console.log(
258
+ chalk.gray(` Creating backup of current Doppler config...`)
259
+ );
260
+ }
261
+ try {
262
+ const backupContent2 = execDoppler(
263
+ [
264
+ "secrets",
265
+ "download",
266
+ "--no-file",
267
+ "--format",
268
+ "env",
269
+ "--config",
270
+ config
271
+ ],
272
+ "string",
273
+ !verbose,
274
+ // Only silent if not verbose
275
+ verbose
276
+ );
277
+ if (typeof backupContent2 === "string") {
278
+ writeFileSync(backupFile, backupContent2, "utf-8");
279
+ if (verbose) {
280
+ console.log(chalk.gray(` Backup created: ${backupFile}`));
281
+ }
282
+ } else {
283
+ throw new Error("Invalid backup content received from Doppler");
284
+ }
285
+ } catch {
286
+ console.log(
287
+ `Config ${config}: Failed to create backup. Skipping upload.`
288
+ );
289
+ continue;
290
+ }
291
+ if (verbose) {
292
+ console.log(chalk.gray(` Reading local file: ${envFile}`));
293
+ }
294
+ const localContent = readFileSync(envFile, "utf-8");
295
+ const normalizedContent = normalizeEscapeSequences(localContent);
296
+ writeFileSync(normalizedFile, normalizedContent, "utf-8");
297
+ if (verbose) {
298
+ console.log(chalk.gray(` Comparing local changes with Doppler...`));
299
+ }
300
+ const backupContent = readFileSync(backupFile, "utf-8");
301
+ const diff = createDiff(backupContent, normalizedContent);
302
+ if (diff.length === 0) {
303
+ console.log(`Config ${config}: No differences found. Skipping upload.`);
304
+ unlinkSync(backupFile);
305
+ unlinkSync(normalizedFile);
306
+ continue;
307
+ }
308
+ if (verbose) {
309
+ console.log(chalk.yellow(` Found ${diff.length} line changes`));
310
+ }
311
+ console.log("\nChanges to be uploaded:");
312
+ for (const line of diff) {
313
+ if (line.startsWith("-")) {
314
+ console.log(chalk.red(line));
315
+ } else if (line.startsWith("+")) {
316
+ console.log(chalk.green(line));
317
+ }
318
+ }
319
+ const confirmed = await promptConfirmation(
320
+ "\nDo you want to proceed with the upload? (y/n) "
321
+ );
322
+ if (!confirmed) {
323
+ console.log(`Upload cancelled for ${chalk.green(envFile)}`);
324
+ unlinkSync(backupFile);
325
+ unlinkSync(normalizedFile);
326
+ continue;
327
+ }
328
+ if (verbose) {
329
+ console.log(chalk.gray(` Uploading to Doppler...`));
330
+ }
331
+ try {
332
+ execDoppler(
333
+ ["secrets", "upload", normalizedFile, "--config", config, "--silent"],
334
+ "string",
335
+ !verbose,
336
+ // Only silent if not verbose
337
+ verbose
338
+ );
339
+ if (config === "dev") {
340
+ console.log(
341
+ `Config ${chalk.blue(config)}: Successfully uploaded ${chalk.green(envFile)}`
342
+ );
343
+ } else {
344
+ console.log(
345
+ `Config ${config}: Successfully uploaded ${chalk.green(envFile)}`
346
+ );
347
+ }
348
+ } catch {
349
+ console.error(
350
+ `Config ${config}: Failed to upload ${chalk.green(envFile)}. Restoring previous configuration.`
351
+ );
352
+ try {
353
+ if (verbose) {
354
+ console.log(chalk.gray(` Restoring previous configuration...`));
355
+ }
356
+ execDoppler(
357
+ ["secrets", "upload", backupFile, "--config", config, "--silent"],
358
+ "string",
359
+ !verbose,
360
+ // Only silent if not verbose
361
+ verbose
362
+ );
363
+ console.log(
364
+ `Config ${config}: Successfully restored previous configuration`
365
+ );
366
+ } catch {
367
+ console.error(
368
+ `Config ${config}: Failed to restore previous configuration`
369
+ );
370
+ }
371
+ }
372
+ if (existsSync(backupFile)) {
373
+ unlinkSync(backupFile);
374
+ }
375
+ if (existsSync(normalizedFile)) {
376
+ unlinkSync(normalizedFile);
377
+ }
378
+ } catch (error) {
379
+ console.error(
380
+ `Error processing config ${config}: ${error?.message || error}`
381
+ );
382
+ if (existsSync(backupFile)) {
383
+ unlinkSync(backupFile);
384
+ }
385
+ if (existsSync(normalizedFile)) {
386
+ unlinkSync(normalizedFile);
387
+ }
388
+ }
389
+ }
390
+ }
391
+
392
+ export {
393
+ execDoppler,
394
+ checkDependencies,
395
+ getConfigs,
396
+ normalizeEscapeSequences,
397
+ createDiff,
398
+ promptConfirmation,
399
+ downloadConfigs,
400
+ uploadConfigs
401
+ };
@@ -0,0 +1,92 @@
1
+ // src/commands/doppler/utils/exec.js
2
+ import { execSync } from "child_process";
3
+ import chalk from "chalk";
4
+ function exec(command, options = {}) {
5
+ const {
6
+ stdoutParser = "string",
7
+ throwOnError = true,
8
+ verbosity = "default",
9
+ stdio: userStdio,
10
+ ...execSyncOptions
11
+ } = options;
12
+ try {
13
+ if (verbosity === "verbose") {
14
+ console.log(chalk.gray(` Executing: ${command}`));
15
+ }
16
+ let stdio;
17
+ if (userStdio) {
18
+ stdio = userStdio;
19
+ } else if (verbosity === "verbose") {
20
+ stdio = "inherit";
21
+ } else if (verbosity === "silent") {
22
+ stdio = "pipe";
23
+ } else {
24
+ stdio = ["pipe", "pipe", "pipe"];
25
+ }
26
+ const result = (
27
+ /** @type {string} */
28
+ execSync(command, {
29
+ encoding: "utf-8",
30
+ stdio,
31
+ ...execSyncOptions
32
+ })
33
+ );
34
+ if (stdio === "inherit") {
35
+ return stdoutParser === "string" ? "" : void 0;
36
+ }
37
+ if (!result || typeof result === "string" && !result.trim()) {
38
+ return stdoutParser === "string" ? "" : void 0;
39
+ }
40
+ switch (stdoutParser) {
41
+ case "json": {
42
+ try {
43
+ return JSON.parse(result);
44
+ } catch (parseError) {
45
+ if (throwOnError) {
46
+ throw new Error(
47
+ `Failed to parse JSON output: ${parseError.message}`
48
+ );
49
+ }
50
+ return void 0;
51
+ }
52
+ }
53
+ case "number": {
54
+ const num = parseFloat(result.trim());
55
+ if (isNaN(num)) {
56
+ if (throwOnError) {
57
+ throw new Error(`Failed to parse number from output: ${result}`);
58
+ }
59
+ return void 0;
60
+ }
61
+ return num;
62
+ }
63
+ case "string":
64
+ default:
65
+ return result;
66
+ }
67
+ } catch (error) {
68
+ if (!throwOnError) {
69
+ return void 0;
70
+ }
71
+ if (error.stderr) {
72
+ throw new Error(error.stderr.toString());
73
+ }
74
+ throw error;
75
+ }
76
+ }
77
+ function execString(command, options = {}) {
78
+ return exec(command, { ...options, stdoutParser: "string" });
79
+ }
80
+ function execJson(command, options = {}) {
81
+ return exec(command, { ...options, stdoutParser: "json" });
82
+ }
83
+ function execNumber(command, options = {}) {
84
+ return exec(command, { ...options, stdoutParser: "number" });
85
+ }
86
+
87
+ export {
88
+ exec,
89
+ execString,
90
+ execJson,
91
+ execNumber
92
+ };
File without changes
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Main doppler command handler
3
+ * @param {unknown} options - Command options (will be validated)
4
+ */
5
+ export function dopplerCommand(options: unknown): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import {
2
+ dopplerCommand
3
+ } from "../../__chunks/G6WUCFLD.js";
4
+ import "../../__chunks/O262GK4B.js";
5
+ import "../../__chunks/SJXQJ7RS.js";
6
+ import "../../__chunks/LHVSSZI7.js";
7
+ export {
8
+ dopplerCommand
9
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./handler.js";
2
+ export * from "./schema.js";
3
+ export * from "./utils.js";