@take-out/cli 0.4.3 → 0.4.5

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 (69) hide show
  1. package/dist/cjs/cli.cjs +53 -35
  2. package/dist/cjs/commands/changed.cjs +133 -95
  3. package/dist/cjs/commands/docs.cjs +276 -203
  4. package/dist/cjs/commands/env-setup.cjs +45 -33
  5. package/dist/cjs/commands/onboard.cjs +668 -224
  6. package/dist/cjs/commands/run-all.cjs +54 -45
  7. package/dist/cjs/commands/run.cjs +80 -65
  8. package/dist/cjs/commands/script.cjs +263 -187
  9. package/dist/cjs/commands/skills.cjs +174 -118
  10. package/dist/cjs/commands/sync.cjs +193 -93
  11. package/dist/cjs/constants/ascii.cjs +14 -12
  12. package/dist/cjs/index.cjs +12 -10
  13. package/dist/cjs/types.cjs +7 -5
  14. package/dist/cjs/utils/env-categories.cjs +53 -48
  15. package/dist/cjs/utils/env-setup.cjs +214 -106
  16. package/dist/cjs/utils/env.cjs +65 -44
  17. package/dist/cjs/utils/files.cjs +186 -113
  18. package/dist/cjs/utils/parallel-runner.cjs +125 -75
  19. package/dist/cjs/utils/ports.cjs +21 -21
  20. package/dist/cjs/utils/prerequisites.cjs +42 -34
  21. package/dist/cjs/utils/prompts.cjs +66 -41
  22. package/dist/cjs/utils/script-listing.cjs +130 -60
  23. package/dist/cjs/utils/script-utils.cjs +29 -19
  24. package/dist/cjs/utils/sync.cjs +67 -45
  25. package/dist/esm/cli.mjs +40 -24
  26. package/dist/esm/cli.mjs.map +1 -1
  27. package/dist/esm/commands/changed.mjs +104 -68
  28. package/dist/esm/commands/changed.mjs.map +1 -1
  29. package/dist/esm/commands/docs.mjs +245 -174
  30. package/dist/esm/commands/docs.mjs.map +1 -1
  31. package/dist/esm/commands/env-setup.mjs +18 -8
  32. package/dist/esm/commands/env-setup.mjs.map +1 -1
  33. package/dist/esm/commands/onboard.mjs +631 -189
  34. package/dist/esm/commands/onboard.mjs.map +1 -1
  35. package/dist/esm/commands/run-all.mjs +26 -19
  36. package/dist/esm/commands/run-all.mjs.map +1 -1
  37. package/dist/esm/commands/run.mjs +52 -39
  38. package/dist/esm/commands/run.mjs.map +1 -1
  39. package/dist/esm/commands/script.mjs +230 -156
  40. package/dist/esm/commands/script.mjs.map +1 -1
  41. package/dist/esm/commands/skills.mjs +143 -89
  42. package/dist/esm/commands/skills.mjs.map +1 -1
  43. package/dist/esm/commands/sync.mjs +160 -62
  44. package/dist/esm/commands/sync.mjs.map +1 -1
  45. package/dist/esm/constants/ascii.mjs +2 -2
  46. package/dist/esm/constants/ascii.mjs.map +1 -1
  47. package/dist/esm/utils/env-categories.mjs +29 -26
  48. package/dist/esm/utils/env-categories.mjs.map +1 -1
  49. package/dist/esm/utils/env-setup.mjs +184 -78
  50. package/dist/esm/utils/env-setup.mjs.map +1 -1
  51. package/dist/esm/utils/env.mjs +50 -31
  52. package/dist/esm/utils/env.mjs.map +1 -1
  53. package/dist/esm/utils/files.mjs +171 -100
  54. package/dist/esm/utils/files.mjs.map +1 -1
  55. package/dist/esm/utils/parallel-runner.mjs +111 -63
  56. package/dist/esm/utils/parallel-runner.mjs.map +1 -1
  57. package/dist/esm/utils/ports.mjs +9 -11
  58. package/dist/esm/utils/ports.mjs.map +1 -1
  59. package/dist/esm/utils/prerequisites.mjs +30 -24
  60. package/dist/esm/utils/prerequisites.mjs.map +1 -1
  61. package/dist/esm/utils/prompts.mjs +40 -17
  62. package/dist/esm/utils/prompts.mjs.map +1 -1
  63. package/dist/esm/utils/script-listing.mjs +101 -33
  64. package/dist/esm/utils/script-listing.mjs.map +1 -1
  65. package/dist/esm/utils/script-utils.mjs +14 -6
  66. package/dist/esm/utils/script-utils.mjs.map +1 -1
  67. package/dist/esm/utils/sync.mjs +38 -18
  68. package/dist/esm/utils/sync.mjs.map +1 -1
  69. package/package.json +5 -5
@@ -2,151 +2,248 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var env_setup_exports = {};
33
35
  __export(env_setup_exports, {
34
36
  listCategories: () => listCategories,
35
37
  setupProductionEnv: () => setupProductionEnv
36
38
  });
37
39
  module.exports = __toCommonJS(env_setup_exports);
38
- var import_node_fs = require("node:fs"),
39
- import_node_path = require("node:path"),
40
- clack = __toESM(require("@clack/prompts"), 1),
41
- import_picocolors = __toESM(require("picocolors"), 1),
42
- import_env = require("./env.cjs"),
43
- import_env_categories = require("./env-categories.cjs");
40
+ var import_node_fs = require("node:fs");
41
+ var import_node_path = require("node:path");
42
+ var clack = __toESM(require("@clack/prompts"), 1);
43
+ var import_picocolors = __toESM(require("picocolors"), 1);
44
+ var import_env = require("./env.cjs");
45
+ var import_env_categories = require("./env-categories.cjs");
44
46
  async function setupProductionEnv(cwd, options = {}) {
45
- const envFile = options.envFile || ".env.production",
46
- fullPath = (0, import_node_path.resolve)(cwd, envFile),
47
- cleanup = () => {
48
- console.info(`
49
- ` + import_picocolors.default.yellow("Setup interrupted. You can resume anytime with:")), console.info(import_picocolors.default.cyan(" bun takeout env:setup")), console.info(import_picocolors.default.gray(`
50
- Note: All environment variables are optional for local development.`)), process.exit(0);
51
- };
52
- process.on("SIGINT", cleanup), process.on("SIGTERM", cleanup);
47
+ const envFile = options.envFile || ".env.production";
48
+ const fullPath = (0, import_node_path.resolve)(cwd, envFile);
49
+ const cleanup = () => {
50
+ console.info("\n" + import_picocolors.default.yellow("Setup interrupted. You can resume anytime with:"));
51
+ console.info(import_picocolors.default.cyan(" bun takeout env:setup"));
52
+ console.info(import_picocolors.default.gray("\nNote: All environment variables are optional for local development."));
53
+ process.exit(0);
54
+ };
55
+ process.on("SIGINT", cleanup);
56
+ process.on("SIGTERM", cleanup);
53
57
  try {
54
- if (clack.intro(import_picocolors.default.bgCyan(import_picocolors.default.black(" Production Environment Setup "))), console.info(import_picocolors.default.gray("All environment variables are optional.")), console.info(import_picocolors.default.gray(`You can skip any section or re-run this setup anytime.
55
- `)), !(0, import_env.envFileExists)(cwd, envFile)) {
58
+ clack.intro(import_picocolors.default.bgCyan(import_picocolors.default.black(" Production Environment Setup ")));
59
+ console.info(import_picocolors.default.gray("All environment variables are optional."));
60
+ console.info(import_picocolors.default.gray("You can skip any section or re-run this setup anytime.\n"));
61
+ if (!(0, import_env.envFileExists)(cwd, envFile)) {
56
62
  const createFile = await clack.confirm({
57
63
  message: `${envFile} doesn't exist. Create it from example?`,
58
- initialValue: !0
64
+ initialValue: true
59
65
  });
60
- if (clack.isCancel(createFile) || !createFile) return clack.cancel("Setup cancelled"), process.removeListener("SIGINT", cleanup), process.removeListener("SIGTERM", cleanup), !1;
66
+ if (clack.isCancel(createFile) || !createFile) {
67
+ clack.cancel("Setup cancelled");
68
+ process.removeListener("SIGINT", cleanup);
69
+ process.removeListener("SIGTERM", cleanup);
70
+ return false;
71
+ }
61
72
  const exampleFile = ".env.production.example";
62
- (0, import_env.envFileExists)(cwd, exampleFile) ? ((0, import_env.copyEnvFile)(cwd, exampleFile, envFile), console.info(import_picocolors.default.green(`\u2713 Created ${envFile} from example
63
- `))) : ((0, import_node_fs.writeFileSync)(fullPath, `# Production Environment Variables
64
- `), console.info(import_picocolors.default.green(`\u2713 Created empty ${envFile}
65
- `)));
73
+ if ((0, import_env.envFileExists)(cwd, exampleFile)) {
74
+ (0, import_env.copyEnvFile)(cwd, exampleFile, envFile);
75
+ console.info(import_picocolors.default.green(`\u2713 Created ${envFile} from example
76
+ `));
77
+ } else {
78
+ (0, import_node_fs.writeFileSync)(fullPath, "# Production Environment Variables\n");
79
+ console.info(import_picocolors.default.green(`\u2713 Created empty ${envFile}
80
+ `));
81
+ }
66
82
  }
67
83
  let categoriesToSetup = options.onlyCategory ? import_env_categories.envCategories.filter(cat => cat.id === options.onlyCategory) : import_env_categories.envCategories;
68
- if (categoriesToSetup.length === 0) return clack.cancel(`Category "${options.onlyCategory}" not found`), process.removeListener("SIGINT", cleanup), process.removeListener("SIGTERM", cleanup), !1;
69
- if (options.interactive !== !1 && !options.onlyCategory) {
84
+ if (categoriesToSetup.length === 0) {
85
+ clack.cancel(`Category "${options.onlyCategory}" not found`);
86
+ process.removeListener("SIGINT", cleanup);
87
+ process.removeListener("SIGTERM", cleanup);
88
+ return false;
89
+ }
90
+ if (options.interactive !== false && !options.onlyCategory) {
70
91
  const setupProd = await clack.confirm({
71
92
  message: "Do you want to set up production environment variables?",
72
- initialValue: !1
93
+ initialValue: false
73
94
  });
74
- if (clack.isCancel(setupProd) || !setupProd) return clack.note(`You can set up production environment later with:
75
- ${import_picocolors.default.cyan("bun takeout env:setup")}`, import_picocolors.default.yellow("Skipping production setup")), process.removeListener("SIGINT", cleanup), process.removeListener("SIGTERM", cleanup), !0;
95
+ if (clack.isCancel(setupProd) || !setupProd) {
96
+ clack.note(`You can set up production environment later with:
97
+ ${import_picocolors.default.cyan("bun takeout env:setup")}`, import_picocolors.default.yellow("Skipping production setup"));
98
+ process.removeListener("SIGINT", cleanup);
99
+ process.removeListener("SIGTERM", cleanup);
100
+ return true;
101
+ }
102
+ }
103
+ for (const category of categoriesToSetup) {
104
+ const shouldSetup = await setupCategory(category, envFile, cwd, options);
105
+ if (!shouldSetup) {
106
+ continue;
107
+ }
108
+ }
109
+ const configuredVars = [];
110
+ const skippedVars = [];
111
+ for (const category of categoriesToSetup) {
112
+ for (const variable of category.variables) {
113
+ const value = (0, import_env.readEnvVariable)(cwd, variable.key, envFile);
114
+ if (value && value !== "" && !value.includes("your-")) {
115
+ configuredVars.push(variable.key);
116
+ } else if (variable.required) {
117
+ skippedVars.push(variable.key);
118
+ }
119
+ }
76
120
  }
77
- for (const category of categoriesToSetup) await setupCategory(category, envFile, cwd, options);
78
- const configuredVars = [],
79
- skippedVars = [];
80
- for (const category of categoriesToSetup) for (const variable of category.variables) {
81
- const value = (0, import_env.readEnvVariable)(cwd, variable.key, envFile);
82
- value && value !== "" && !value.includes("your-") ? configuredVars.push(variable.key) : variable.required && skippedVars.push(variable.key);
121
+ if (configuredVars.length > 0) {
122
+ clack.outro(import_picocolors.default.green("\u2713 Environment setup complete!"));
123
+ console.info(import_picocolors.default.gray(`
124
+ Configured ${configuredVars.length} variables in ${envFile}`));
125
+ if (skippedVars.length > 0) {
126
+ console.info(import_picocolors.default.yellow(`
127
+ Note: Some required variables were skipped. You'll need to configure these before deploying:`));
128
+ skippedVars.forEach(v => console.info(import_picocolors.default.gray(` - ${v}`)));
129
+ }
130
+ console.info(import_picocolors.default.cyan("\nYou can re-run this setup anytime with:"));
131
+ console.info(import_picocolors.default.gray(" bun takeout env:setup"));
132
+ console.info(import_picocolors.default.cyan("\nOr set up specific categories:"));
133
+ console.info(import_picocolors.default.gray(" bun takeout env:setup --category aws"));
134
+ console.info(import_picocolors.default.gray(" bun takeout env:setup --category apple"));
135
+ } else {
136
+ clack.outro(import_picocolors.default.yellow("No variables configured"));
137
+ console.info(import_picocolors.default.gray("\nYou can re-run this setup anytime with:"));
138
+ console.info(import_picocolors.default.gray(" bun takeout env:setup"));
83
139
  }
84
- return configuredVars.length > 0 ? (clack.outro(import_picocolors.default.green("\u2713 Environment setup complete!")), console.info(import_picocolors.default.gray(`
85
- Configured ${configuredVars.length} variables in ${envFile}`)), skippedVars.length > 0 && (console.info(import_picocolors.default.yellow(`
86
- Note: Some required variables were skipped. You'll need to configure these before deploying:`)), skippedVars.forEach(v => console.info(import_picocolors.default.gray(` - ${v}`)))), console.info(import_picocolors.default.cyan(`
87
- You can re-run this setup anytime with:`)), console.info(import_picocolors.default.gray(" bun takeout env:setup")), console.info(import_picocolors.default.cyan(`
88
- Or set up specific categories:`)), console.info(import_picocolors.default.gray(" bun takeout env:setup --category aws")), console.info(import_picocolors.default.gray(" bun takeout env:setup --category apple"))) : (clack.outro(import_picocolors.default.yellow("No variables configured")), console.info(import_picocolors.default.gray(`
89
- You can re-run this setup anytime with:`)), console.info(import_picocolors.default.gray(" bun takeout env:setup"))), process.removeListener("SIGINT", cleanup), process.removeListener("SIGTERM", cleanup), !0;
140
+ process.removeListener("SIGINT", cleanup);
141
+ process.removeListener("SIGTERM", cleanup);
142
+ return true;
90
143
  } catch (error) {
91
- if (process.removeListener("SIGINT", cleanup), process.removeListener("SIGTERM", cleanup), error instanceof Error && error.message.includes("cancelled")) return !1;
144
+ process.removeListener("SIGINT", cleanup);
145
+ process.removeListener("SIGTERM", cleanup);
146
+ if (error instanceof Error && error.message.includes("cancelled")) {
147
+ return false;
148
+ }
92
149
  throw error;
93
150
  }
94
151
  }
95
152
  async function setupCategory(category, envFile, cwd, options) {
96
153
  const spinner = clack.spinner();
97
154
  let message = `Set up ${import_picocolors.default.bold(category.name)}?`;
98
- category.required || (message += import_picocolors.default.gray(" (optional)")), category.setupTime && (message += import_picocolors.default.yellow(` ${category.setupTime}`)), console.info("");
155
+ if (!category.required) {
156
+ message += import_picocolors.default.gray(" (optional)");
157
+ }
158
+ if (category.setupTime) {
159
+ message += import_picocolors.default.yellow(` ${category.setupTime}`);
160
+ }
161
+ console.info("");
99
162
  const setupCategory2 = await clack.confirm({
100
163
  message,
101
164
  initialValue: category.required
102
165
  });
103
- if (clack.isCancel(setupCategory2) || !setupCategory2) return console.info(import_picocolors.default.gray(` Skipping ${category.name}`)), !1;
166
+ if (clack.isCancel(setupCategory2) || !setupCategory2) {
167
+ console.info(import_picocolors.default.gray(` Skipping ${category.name}`));
168
+ return false;
169
+ }
104
170
  console.info(import_picocolors.default.gray(`
105
171
  ${category.description}
106
172
  `));
107
- for (const variable of category.variables) await setupVariable(variable, envFile, cwd);
108
- return !0;
173
+ for (const variable of category.variables) {
174
+ await setupVariable(variable, envFile, cwd);
175
+ }
176
+ return true;
109
177
  }
110
178
  async function setupVariable(variable, envFile, cwd) {
111
- const existingValue = (0, import_env.readEnvVariable)(cwd, variable.key, envFile),
112
- hasValue = existingValue && existingValue !== "" && !existingValue.includes("your-");
113
- if (console.info(""), console.info(import_picocolors.default.bold(variable.label)), console.info(import_picocolors.default.gray(variable.description)), hasValue) {
179
+ const existingValue = (0, import_env.readEnvVariable)(cwd, variable.key, envFile);
180
+ const hasValue = existingValue && existingValue !== "" && !existingValue.includes("your-");
181
+ console.info("");
182
+ console.info(import_picocolors.default.bold(variable.label));
183
+ console.info(import_picocolors.default.gray(variable.description));
184
+ if (hasValue) {
114
185
  const update = await clack.confirm({
115
186
  message: `${import_picocolors.default.green("\u2713")} Already configured. Update?`,
116
- initialValue: !1
187
+ initialValue: false
117
188
  });
118
- if (clack.isCancel(update) || !update) return;
189
+ if (clack.isCancel(update) || !update) {
190
+ return;
191
+ }
119
192
  }
120
- console.info(""), console.info(import_picocolors.default.cyan("Instructions:")), variable.instructions.split(`
121
- `).forEach(line => {
193
+ console.info("");
194
+ console.info(import_picocolors.default.cyan("Instructions:"));
195
+ variable.instructions.split("\n").forEach(line => {
122
196
  console.info(import_picocolors.default.gray(` ${line}`));
123
- }), console.info("");
197
+ });
198
+ console.info("");
124
199
  let value;
125
200
  if (variable.generator) {
126
201
  const generate = await clack.confirm({
127
202
  message: `Generate ${variable.label} automatically?`,
128
- initialValue: !0
203
+ initialValue: true
129
204
  });
130
- !clack.isCancel(generate) && generate && (value = variable.generator(), console.info(import_picocolors.default.green(`\u2713 Generated ${variable.label}`)));
205
+ if (!clack.isCancel(generate) && generate) {
206
+ value = variable.generator();
207
+ console.info(import_picocolors.default.green(`\u2713 Generated ${variable.label}`));
208
+ }
131
209
  }
132
- if (!value) if (variable.type === "multiline") console.info(import_picocolors.default.gray("Paste content (press Enter twice when done):")), value = await readMultilineInput();else if (variable.type === "secret") {
133
- const result = await clack.password({
134
- message: `Enter ${variable.label}:`,
135
- mask: "*"
136
- });
137
- clack.isCancel(result) || (value = result);
138
- } else {
139
- const result = await clack.text({
140
- message: `Enter ${variable.label}:`,
141
- placeholder: variable.placeholder,
142
- defaultValue: variable.default,
143
- validate: val => {
144
- if (variable.required && !val) return "This field is required";
210
+ if (!value) {
211
+ if (variable.type === "multiline") {
212
+ console.info(import_picocolors.default.gray("Paste content (press Enter twice when done):"));
213
+ value = await readMultilineInput();
214
+ } else if (variable.type === "secret") {
215
+ const result = await clack.password({
216
+ message: `Enter ${variable.label}:`,
217
+ mask: "*"
218
+ });
219
+ if (!clack.isCancel(result)) {
220
+ value = result;
145
221
  }
146
- });
147
- clack.isCancel(result) || (value = result);
222
+ } else {
223
+ const result = await clack.text({
224
+ message: `Enter ${variable.label}:`,
225
+ placeholder: variable.placeholder,
226
+ defaultValue: variable.default,
227
+ validate: val => {
228
+ if (variable.required && !val) {
229
+ return "This field is required";
230
+ }
231
+ return void 0;
232
+ }
233
+ });
234
+ if (!clack.isCancel(result)) {
235
+ value = result;
236
+ }
237
+ }
238
+ }
239
+ if (value && !clack.isCancel(value)) {
240
+ (0, import_env.updateEnvVariable)(cwd, variable.key, value, envFile);
241
+ console.info(import_picocolors.default.green(`\u2713 Saved ${variable.key}`));
242
+ } else if (variable.required) {
243
+ console.info(import_picocolors.default.yellow(`\u26A0 Skipped required variable: ${variable.key}`));
244
+ } else {
245
+ console.info(import_picocolors.default.gray(` Skipped ${variable.key}`));
148
246
  }
149
- value && !clack.isCancel(value) ? ((0, import_env.updateEnvVariable)(cwd, variable.key, value, envFile), console.info(import_picocolors.default.green(`\u2713 Saved ${variable.key}`))) : variable.required ? console.info(import_picocolors.default.yellow(`\u26A0 Skipped required variable: ${variable.key}`)) : console.info(import_picocolors.default.gray(` Skipped ${variable.key}`));
150
247
  }
151
248
  async function readMultilineInput() {
152
249
  return new Promise(resolve2 => {
@@ -155,27 +252,38 @@ async function readMultilineInput() {
155
252
  const reader = process.stdin;
156
253
  reader.setEncoding("utf8");
157
254
  const onData = chunk => {
158
- const chunkLines = chunk.split(`
159
- `);
160
- for (const line of chunkLines) if (line === "") {
161
- if (emptyLineCount++, emptyLineCount >= 2) {
162
- reader.removeListener("data", onData), resolve2(lines.join(`
163
- `));
164
- return;
255
+ const chunkLines = chunk.split("\n");
256
+ for (const line of chunkLines) {
257
+ if (line === "") {
258
+ emptyLineCount++;
259
+ if (emptyLineCount >= 2) {
260
+ reader.removeListener("data", onData);
261
+ resolve2(lines.join("\n"));
262
+ return;
263
+ }
264
+ } else {
265
+ if (emptyLineCount === 1) {
266
+ lines.push("");
267
+ }
268
+ emptyLineCount = 0;
269
+ lines.push(line);
165
270
  }
166
- } else emptyLineCount === 1 && lines.push(""), emptyLineCount = 0, lines.push(line);
271
+ }
167
272
  };
168
273
  reader.on("data", onData);
169
274
  });
170
275
  }
171
276
  function listCategories() {
172
- console.info(import_picocolors.default.bold(`
173
- Available environment categories:
174
- `));
277
+ console.info(import_picocolors.default.bold("\nAvailable environment categories:\n"));
175
278
  for (const category of import_env_categories.envCategories) {
176
279
  const status = category.required ? import_picocolors.default.red("required") : import_picocolors.default.gray("optional");
177
- console.info(` ${import_picocolors.default.cyan(category.id.padEnd(12))} - ${category.name} ${status}`), console.info(` ${import_picocolors.default.gray(category.description)}`), category.setupTime && console.info(` ${import_picocolors.default.yellow(category.setupTime)}`), console.info("");
280
+ console.info(` ${import_picocolors.default.cyan(category.id.padEnd(12))} - ${category.name} ${status}`);
281
+ console.info(` ${import_picocolors.default.gray(category.description)}`);
282
+ if (category.setupTime) {
283
+ console.info(` ${import_picocolors.default.yellow(category.setupTime)}`);
284
+ }
285
+ console.info("");
178
286
  }
179
- console.info(import_picocolors.default.gray("Run setup for a specific category:")), console.info(import_picocolors.default.cyan(` bun takeout env:setup --category <id>
180
- `));
287
+ console.info(import_picocolors.default.gray("Run setup for a specific category:"));
288
+ console.info(import_picocolors.default.cyan(" bun takeout env:setup --category <id>\n"));
181
289
  }
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var env_exports = {};
22
24
  __export(env_exports, {
@@ -28,9 +30,9 @@ __export(env_exports, {
28
30
  updateEnvVariable: () => updateEnvVariable
29
31
  });
30
32
  module.exports = __toCommonJS(env_exports);
31
- var import_node_crypto = require("node:crypto"),
32
- import_node_fs = require("node:fs"),
33
- import_node_path = require("node:path");
33
+ var import_node_crypto = require("node:crypto");
34
+ var import_node_fs = require("node:fs");
35
+ var import_node_path = require("node:path");
34
36
  function generateSecret(length = 32) {
35
37
  return (0, import_node_crypto.randomBytes)(length).toString("hex");
36
38
  }
@@ -38,53 +40,68 @@ function envFileExists(cwd, filename = ".env") {
38
40
  return (0, import_node_fs.existsSync)((0, import_node_path.join)(cwd, filename));
39
41
  }
40
42
  function copyEnvFile(cwd, source, target) {
41
- const sourcePath = (0, import_node_path.join)(cwd, source),
42
- targetPath = (0, import_node_path.join)(cwd, target);
43
- if (!(0, import_node_fs.existsSync)(sourcePath)) return {
44
- success: !1,
45
- error: `Source file ${source} not found`
46
- };
47
- if ((0, import_node_fs.existsSync)(targetPath)) return {
48
- success: !1,
49
- error: `Target file ${target} already exists`
50
- };
43
+ const sourcePath = (0, import_node_path.join)(cwd, source);
44
+ const targetPath = (0, import_node_path.join)(cwd, target);
45
+ if (!(0, import_node_fs.existsSync)(sourcePath)) {
46
+ return {
47
+ success: false,
48
+ error: `Source file ${source} not found`
49
+ };
50
+ }
51
+ if ((0, import_node_fs.existsSync)(targetPath)) {
52
+ return {
53
+ success: false,
54
+ error: `Target file ${target} already exists`
55
+ };
56
+ }
51
57
  try {
52
- return (0, import_node_fs.copyFileSync)(sourcePath, targetPath), {
53
- success: !0
58
+ (0, import_node_fs.copyFileSync)(sourcePath, targetPath);
59
+ return {
60
+ success: true
54
61
  };
55
62
  } catch (error) {
56
63
  return {
57
- success: !1,
64
+ success: false,
58
65
  error: error instanceof Error ? error.message : "Unknown error"
59
66
  };
60
67
  }
61
68
  }
62
69
  function updateEnvVariable(cwd, key, value, filename = ".env") {
63
70
  const envPath = (0, import_node_path.join)(cwd, filename);
64
- if (!(0, import_node_fs.existsSync)(envPath)) return {
65
- success: !1,
66
- error: `${filename} not found`
67
- };
71
+ if (!(0, import_node_fs.existsSync)(envPath)) {
72
+ return {
73
+ success: false,
74
+ error: `${filename} not found`
75
+ };
76
+ }
68
77
  try {
69
78
  let content = (0, import_node_fs.readFileSync)(envPath, "utf-8");
70
79
  const keyRegex = new RegExp(`^${key}=.*$`, "m");
71
- return keyRegex.test(content) ? content = content.replace(keyRegex, `${key}=${value}`) : content = content.trimEnd() + `
80
+ if (keyRegex.test(content)) {
81
+ content = content.replace(keyRegex, `${key}=${value}`);
82
+ } else {
83
+ content = content.trimEnd() + `
72
84
  ${key}=${value}
73
- `, (0, import_node_fs.writeFileSync)(envPath, content, "utf-8"), {
74
- success: !0
85
+ `;
86
+ }
87
+ (0, import_node_fs.writeFileSync)(envPath, content, "utf-8");
88
+ return {
89
+ success: true
75
90
  };
76
91
  } catch (error) {
77
92
  return {
78
- success: !1,
93
+ success: false,
79
94
  error: error instanceof Error ? error.message : "Unknown error"
80
95
  };
81
96
  }
82
97
  }
83
98
  function createEnvLocal(cwd) {
84
99
  const envLocalPath = (0, import_node_path.join)(cwd, ".env.local");
85
- if ((0, import_node_fs.existsSync)(envLocalPath)) return {
86
- success: !0
87
- };
100
+ if ((0, import_node_fs.existsSync)(envLocalPath)) {
101
+ return {
102
+ success: true
103
+ };
104
+ }
88
105
  const template = `# Local environment overrides
89
106
  # This file is gitignored and never committed
90
107
  # Add your personal secrets and local configuration here
@@ -95,23 +112,27 @@ function createEnvLocal(cwd) {
95
112
  # AWS_ACCESS_KEY_ID=your-key-here
96
113
  `;
97
114
  try {
98
- return (0, import_node_fs.writeFileSync)(envLocalPath, template, "utf-8"), {
99
- success: !0
115
+ (0, import_node_fs.writeFileSync)(envLocalPath, template, "utf-8");
116
+ return {
117
+ success: true
100
118
  };
101
119
  } catch (error) {
102
120
  return {
103
- success: !1,
121
+ success: false,
104
122
  error: error instanceof Error ? error.message : "Unknown error"
105
123
  };
106
124
  }
107
125
  }
108
126
  function readEnvVariable(cwd, key, filename = ".env") {
109
127
  const envPath = (0, import_node_path.join)(cwd, filename);
110
- if (!(0, import_node_fs.existsSync)(envPath)) return null;
128
+ if (!(0, import_node_fs.existsSync)(envPath)) {
129
+ return null;
130
+ }
111
131
  try {
112
- const content = (0, import_node_fs.readFileSync)(envPath, "utf-8"),
113
- keyRegex = new RegExp(`^${key}=(.*)$`, "m");
114
- return content.match(keyRegex)?.[1]?.trim().replace(/^["']|["']$/g, "") || null;
132
+ const content = (0, import_node_fs.readFileSync)(envPath, "utf-8");
133
+ const keyRegex = new RegExp(`^${key}=(.*)$`, "m");
134
+ const match = content.match(keyRegex);
135
+ return match?.[1]?.trim().replace(/^["']|["']$/g, "") || null;
115
136
  } catch {
116
137
  return null;
117
138
  }