@stacksjs/buddy 0.58.73 → 0.59.2

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 (57) hide show
  1. package/dist/chunk-d2428b387d843985.js +2016 -0
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +23 -9
  4. package/dist/commands/build.d.ts +2 -0
  5. package/dist/commands/changelog.d.ts +2 -0
  6. package/dist/commands/clean.d.ts +2 -0
  7. package/dist/commands/cloud.d.ts +2 -0
  8. package/dist/commands/commit.d.ts +2 -0
  9. package/dist/commands/configure.d.ts +2 -0
  10. package/dist/commands/create.d.ts +2 -0
  11. package/dist/commands/deploy.d.ts +2 -0
  12. package/dist/commands/dev.d.ts +3 -0
  13. package/dist/commands/dns.d.ts +2 -0
  14. package/dist/commands/domains.d.ts +2 -0
  15. package/dist/commands/fresh.d.ts +2 -0
  16. package/dist/commands/generate.d.ts +2 -0
  17. package/dist/commands/http.d.ts +2 -0
  18. package/dist/commands/index.d.ts +31 -0
  19. package/dist/commands/install.d.ts +2 -0
  20. package/dist/commands/key.d.ts +2 -0
  21. package/dist/commands/lint.d.ts +2 -0
  22. package/dist/commands/list.d.ts +2 -0
  23. package/dist/commands/make.d.ts +2 -0
  24. package/dist/commands/migrate.d.ts +2 -0
  25. package/dist/commands/ports.d.ts +2 -0
  26. package/dist/commands/prepublish.d.ts +2 -0
  27. package/dist/commands/projects.d.ts +2 -0
  28. package/dist/commands/release.d.ts +2 -0
  29. package/dist/commands/seed.d.ts +2 -0
  30. package/dist/commands/setup.d.ts +4 -0
  31. package/dist/commands/test.d.ts +2 -0
  32. package/dist/commands/tinker.d.ts +2 -0
  33. package/dist/commands/types.d.ts +2 -0
  34. package/dist/commands/upgrade.d.ts +2 -0
  35. package/dist/commands/version.d.ts +2 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +2 -5
  38. package/dist/stacks +0 -0
  39. package/package.json +1 -3
  40. package/src/cli.ts +18 -13
  41. package/src/commands/add.ts +1 -1
  42. package/src/commands/commit.ts +1 -1
  43. package/src/commands/deploy.ts +1 -1
  44. package/src/commands/dev.ts +1 -3
  45. package/src/commands/index.ts +0 -1
  46. package/src/commands/key.ts +1 -1
  47. package/src/commands/list.ts +1 -1
  48. package/src/commands/make.ts +28 -2
  49. package/src/commands/ports.ts +135 -28
  50. package/src/commands/prepublish.ts +1 -1
  51. package/src/commands/projects.ts +2 -3
  52. package/src/commands/setup.ts +1 -0
  53. package/src/commands/types.ts +1 -1
  54. package/dist/chunk-1a569f35f66ae151.js +0 -10945
  55. package/dist/chunk-bf054cfbc9cf2201.js +0 -993
  56. package/src/commands/check.ts +0 -45
  57. /package/dist/{chunk-0455e53fab4244b1.js → chunk-970e033f764e29fc.js} +0 -0
@@ -0,0 +1,2016 @@
1
+ // src/commands/build.ts
2
+ import process from "process";
3
+ import {runAction as runAction2} from "@stacksjs/actions";
4
+ import {intro, log, outro} from "@stacksjs/cli";
5
+ import {ExitCode} from "@stacksjs/types";
6
+ import {Action} from "@stacksjs/enums";
7
+ function build(buddy) {
8
+ const descriptions = {
9
+ build: "Build any of your libraries (packages) for production use",
10
+ components: "Build your component library",
11
+ vueComponents: "Build your Vue component library",
12
+ webComponents: "Build your framework agnostic web component library",
13
+ elements: "An alias to the -w flag",
14
+ buddy: "Build the Buddy binary",
15
+ functions: "Build your function library",
16
+ desktop: "Build the Desktop Application",
17
+ pages: "Build your frontend",
18
+ docs: "Build your documentation",
19
+ framework: "Build Stacks framework",
20
+ cli: "Automagically build the CLI",
21
+ server: "Build the Stacks cloud server (Docker image)",
22
+ select: "What are you trying to build?",
23
+ project: "Target a specific project",
24
+ verbose: "Enable verbose output"
25
+ };
26
+ buddy.command("build [type]", descriptions.build).option("-c, --components", descriptions.components).option("-v, --vue-components", descriptions.vueComponents).option("-w, --web-components", descriptions.webComponents).option("-e, --elements", descriptions.elements).option("-f, --functions", descriptions.functions).option("-p, --views", descriptions.pages).option("-d, --docs", descriptions.docs).option("-b, --buddy", descriptions.buddy, { default: false }).option("-s, --stacks", descriptions.framework, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--server", descriptions.server, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (server, options) => {
27
+ log.debug("Running `buddy build` ...", options);
28
+ switch (server) {
29
+ case "components":
30
+ options.components = true;
31
+ break;
32
+ case "vue":
33
+ options.vueComponents = true;
34
+ break;
35
+ case "web-components":
36
+ options.webComponents = true;
37
+ break;
38
+ case "functions":
39
+ options.functions = true;
40
+ break;
41
+ case "views":
42
+ options.views = true;
43
+ break;
44
+ case "docs":
45
+ options.docs = true;
46
+ break;
47
+ case "buddy":
48
+ options.buddy = true;
49
+ break;
50
+ case "cli":
51
+ options.buddy = true;
52
+ break;
53
+ case "stacks":
54
+ options.stacks = true;
55
+ break;
56
+ case "server":
57
+ options.stacks = true;
58
+ break;
59
+ default:
60
+ break;
61
+ }
62
+ if (hasNoOptions(options)) {
63
+ let answers = await log.prompt.require().multiselect(descriptions.select, {
64
+ options: [
65
+ { label: "Components", value: "components" },
66
+ { label: "Web Components", value: "web-components" },
67
+ { label: "Functions", value: "functions" },
68
+ { label: "Views", value: "views" },
69
+ { label: "Documentation", value: "docs" }
70
+ ]
71
+ });
72
+ if (answers !== null)
73
+ process.exit(ExitCode.InvalidArgument);
74
+ if (isString(answers))
75
+ answers = [answers];
76
+ options = answers.reduce((a, v) => ({ ...a, [v]: true }), {});
77
+ }
78
+ await runAction2(Action.BuildStacks, options);
79
+ process.exit(ExitCode.Success);
80
+ });
81
+ buddy.command("build:components", "Automagically build component libraries for production use & npm/CDN distribution").alias("prod:components").option("-c, --components", descriptions.components, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
82
+ log.debug("Running `buddy build:components` ...", options);
83
+ await runAction2(Action.BuildComponentLibs, options);
84
+ });
85
+ buddy.command("build:cli", descriptions.cli).alias("prod:cli").option("-b, --buddy", descriptions.buddy, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
86
+ log.debug("Running `buddy build:cli` ...", options);
87
+ await runAction2(Action.BuildCli, options);
88
+ });
89
+ buddy.command("build:server", descriptions.server).alias("prod:server").alias("build:docker").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
90
+ log.debug("Running `buddy build:server` ...", options);
91
+ await runAction2(Action.BuildServer, options);
92
+ });
93
+ buddy.command("build:functions", "Automagically build function library for npm/CDN distribution").option("-f, --functions", descriptions.functions, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
94
+ log.debug("Running `buddy `build:functions` ...", options);
95
+ await runAction2(Action.BuildFunctionLib, options);
96
+ });
97
+ buddy.command("build:vue-components", "Automagically build Vue component library for npm/CDN distribution").alias("build:vue").alias("prod:vue-components").alias("prod:vue").option("-v, --vue-components", descriptions.vueComponents, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).alias("build:vue").action(async (options) => {
98
+ log.debug("Running `buddy build:vue-components` ...", options);
99
+ await runAction2(Action.BuildVueComponentLib, options);
100
+ });
101
+ buddy.command("build:web-components", "Automagically build Web Component library for npm/CDN distribution").alias("build:wc").alias("prod:web-components").alias("prod:wc").option("-w, --web-components", descriptions.webComponents, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
102
+ log.debug("Running `buddy build:web-components` ...", options);
103
+ await runAction2(Action.BuildWebComponentLib, options);
104
+ });
105
+ buddy.command("build:docs", "Automagically build your documentation site.").alias("prod:docs").alias("build:documentation").alias("prod:documentation").option("-d, --docs", descriptions.docs, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
106
+ log.debug("Running `buddy build:docs` ...", options);
107
+ await runAction2(Action.BuildDocs, options);
108
+ });
109
+ buddy.command("build:core", "Automagically build the Stacks core.").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
110
+ log.debug("Running `buddy build:core` ...", options);
111
+ const startTime = await intro("buddy build:core");
112
+ const result = await runAction2(Action.BuildCore, options);
113
+ if (result.isErr()) {
114
+ log.error("Failed to build the Stacks core.", result.error);
115
+ process.exit();
116
+ }
117
+ await outro("Core packages built successfully", { startTime, useSeconds: true });
118
+ });
119
+ buddy.command("build:desktop", descriptions.desktop).alias("prod:desktop").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
120
+ log.debug("Running `buddy build:desktop` ...", options);
121
+ const perf = await intro("buddy build:desktop");
122
+ const result = await runAction2(Action.BuildDesktop, options);
123
+ if (result.isErr()) {
124
+ await outro("While running the build:desktop command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
125
+ process.exit();
126
+ }
127
+ console.log("");
128
+ await outro("Exited", { startTime: perf, useSeconds: true });
129
+ process.exit(ExitCode.Success);
130
+ });
131
+ buddy.command("build:stacks", "Build the Stacks framework.").option("-s, --stacks", descriptions.framework, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
132
+ log.debug("Running `buddy build:stacks` ...", options);
133
+ const startTime = await intro("buddy build:stacks");
134
+ const result = await runAction2(Action.BuildStacks, options);
135
+ if (result.isErr()) {
136
+ log.error("Failed to build Stacks.", result.error);
137
+ process.exit();
138
+ }
139
+ await outro("Stacks built successfully", { startTime, useSeconds: true });
140
+ });
141
+ buddy.on("build:*", () => {
142
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
143
+ process.exit(1);
144
+ });
145
+ }
146
+ var hasNoOptions = function(options) {
147
+ return !options.components && !options.vueComponents && !options.webComponents && !options.elements && !options.functions && !options.views && !options.docs && !options.stacks && !options.buddy;
148
+ };
149
+
150
+ // src/commands/changelog.ts
151
+ import process2 from "process";
152
+ import {runAction as runAction3} from "@stacksjs/actions";
153
+ import {intro as intro2, log as log2, outro as outro2} from "@stacksjs/cli";
154
+ import {Action as Action2} from "@stacksjs/enums";
155
+ function changelog(buddy) {
156
+ const descriptions = {
157
+ changelog: "Create a CHANGELOG.md file",
158
+ quiet: "Minimal output",
159
+ dryRun: "Do not write the file, just output the changes",
160
+ project: "Target a specific project",
161
+ verbose: "Enable verbose output"
162
+ };
163
+ buddy.command("changelog", descriptions.changelog).option("-q, --quiet", descriptions.quiet, { default: false }).option("-d, --dry-run", descriptions.dryRun, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
164
+ log2.debug("Running `buddy changelog` ...", options);
165
+ const perf = await intro2("buddy changelog");
166
+ const result = await runAction3(Action2.Changelog, options);
167
+ if (result.isErr()) {
168
+ await outro2("While running the changelog command, there was an issue", { ...options, startTime: perf, useSeconds: true }, result.error);
169
+ process2.exit();
170
+ }
171
+ await outro2("Generated CHANGELOG.md", { ...options, startTime: perf, useSeconds: true, type: "success" });
172
+ });
173
+ buddy.on("changelog:*", () => {
174
+ console.log("Invalid command: %s", buddy.args.join(" "));
175
+ console.log("See --help for a list of available commands.");
176
+ process2.exit(1);
177
+ });
178
+ }
179
+
180
+ // src/commands/clean.ts
181
+ import process3 from "process";
182
+ import {ExitCode as ExitCode2} from "@stacksjs/types";
183
+ import {runAction as runAction4} from "@stacksjs/actions";
184
+ import {intro as intro3, log as log3, outro as outro3} from "@stacksjs/cli";
185
+ import {Action as Action3} from "@stacksjs/enums";
186
+ function clean(buddy) {
187
+ const descriptions = {
188
+ clean: "Removes all node_modules & lock files",
189
+ project: "Target a specific project",
190
+ verbose: "Enable verbose output"
191
+ };
192
+ buddy.command("clean", descriptions.clean).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
193
+ log3.debug("Running `buddy clean` ...", options);
194
+ const perf = await intro3("buddy clean");
195
+ const result = await runAction4(Action3.Clean, options);
196
+ if (result.isErr()) {
197
+ await outro3("While running the clean command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
198
+ process3.exit(ExitCode2.FatalError);
199
+ }
200
+ await outro3("Cleaned up", { startTime: perf, useSeconds: true, message: "Cleaned up" });
201
+ process3.exit(ExitCode2.Success);
202
+ });
203
+ buddy.on("clean:*", () => {
204
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
205
+ process3.exit(1);
206
+ });
207
+ }
208
+
209
+ // src/commands/cloud.ts
210
+ import process4 from "process";
211
+ import {intro as intro4, italic, log as log4, outro as outro4, prompts, runCommand, runCommandSync, underline} from "@stacksjs/cli";
212
+ import {addJumpBox, deleteCdkRemnants, deleteIamUsers, deleteJumpBox, deleteLogGroups, deleteParameterStore, deleteStacksBuckets, deleteStacksFunctions, getJumpBoxInstanceId} from "@stacksjs/cloud";
213
+ import {path as p} from "@stacksjs/path";
214
+ import {ExitCode as ExitCode3} from "@stacksjs/types";
215
+ import {loop} from "@stacksjs/utils";
216
+ function cloud2(buddy) {
217
+ const descriptions = {
218
+ cloud: "Interact with the Stacks Cloud",
219
+ ssh: "SSH into the Stacks Cloud",
220
+ add: "Add a resource to the Stacks Cloud",
221
+ remove: "Removes the Stacks Cloud. In case it fails, try again",
222
+ optimizeCost: "Removes certain resources that may be re-applied at a later time",
223
+ cleanUp: "Removes all resources that were retained during the cloud deletion",
224
+ project: "Target a specific project",
225
+ verbose: "Enable verbose output"
226
+ };
227
+ buddy.command("cloud", descriptions.cloud).option("--ssh", descriptions.ssh, { default: false }).option("--connect", descriptions.ssh, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
228
+ log4.debug("Running `buddy cloud` ...", options);
229
+ if (options.ssh || options.connect) {
230
+ const startTime = performance.now();
231
+ const jumpBoxId = await getJumpBoxInstanceId();
232
+ const result = await runCommand(`aws ssm start-session --target ${jumpBoxId}`, {
233
+ ...options,
234
+ cwd: p.projectPath(),
235
+ stdin: "pipe"
236
+ });
237
+ if (result.isErr()) {
238
+ await outro4("While running the cloud command, there was an issue", { startTime, useSeconds: true }, result.error);
239
+ process4.exit(ExitCode3.FatalError);
240
+ }
241
+ await outro4("Exited", { startTime, useSeconds: true });
242
+ process4.exit(ExitCode3.Success);
243
+ }
244
+ log4.info("Not implemented yet. Please use the --ssh (or --connect) flag to connect to the Stacks Cloud.");
245
+ process4.exit(ExitCode3.Success);
246
+ });
247
+ buddy.command("cloud:add", descriptions.add).option("--jump-box", "Remove the jump-box", { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
248
+ log4.debug("Running `buddy cloud:add` ...", options);
249
+ const startTime = await intro4("buddy cloud:add");
250
+ if (options.jumpBox) {
251
+ const { confirm } = await prompts({
252
+ name: "confirm",
253
+ type: "confirm",
254
+ message: "Would you like to add a jump-box to your cloud?"
255
+ });
256
+ if (!confirm) {
257
+ await outro4("Exited", { startTime, useSeconds: true });
258
+ process4.exit(ExitCode3.Success);
259
+ }
260
+ log4.info("The jump-box is getting added to your cloud resources...");
261
+ log4.info("This takes a few moments, please be patient.");
262
+ await new Promise((resolve) => setTimeout(resolve, 2000));
263
+ const result = await addJumpBox();
264
+ if (result.isErr()) {
265
+ await outro4("While running the cloud:add command, there was an issue", { startTime, useSeconds: true }, result.error);
266
+ process4.exit(ExitCode3.FatalError);
267
+ }
268
+ log4.info(italic("View the jump-box in the AWS console:"));
269
+ log4.info(underline("https://us-east-1.console.aws.amazon.com/ec2/home?region=us-east-1#Instances:instanceState=running"));
270
+ log4.info(italic("Once it finished initializing, you may SSH into it:"));
271
+ log4.info(underline("buddy cloud --ssh"));
272
+ await outro4("Your jump-box was added.", { startTime, useSeconds: true });
273
+ process4.exit(ExitCode3.Success);
274
+ }
275
+ log4.info("This functionality is not yet implemented.");
276
+ process4.exit(ExitCode3.Success);
277
+ });
278
+ buddy.command("cloud:remove", descriptions.remove).alias("cloud:destroy").alias("cloud:rm").alias("undeploy").option("--jump-box", "Remove the jump-box", { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
279
+ log4.debug("Running `buddy cloud:remove` ...", options);
280
+ const startTime = await intro4("buddy cloud:remove");
281
+ if (options.jumpBox) {
282
+ const { confirm } = await prompts({
283
+ name: "confirm",
284
+ type: "confirm",
285
+ message: "Would you like to remove your jump-box for now?"
286
+ });
287
+ if (!confirm) {
288
+ await outro4("Exited", { startTime, useSeconds: true });
289
+ process4.exit(ExitCode3.Success);
290
+ }
291
+ const result2 = await deleteJumpBox();
292
+ if (result2.isErr()) {
293
+ await outro4("While removing your jump-box, there was an issue", { startTime, useSeconds: true }, result2.error);
294
+ process4.exit(ExitCode3.FatalError);
295
+ }
296
+ await outro4("Your jump-box was removed.", { startTime, useSeconds: true });
297
+ process4.exit(ExitCode3.Success);
298
+ }
299
+ console.log(` ${italic("\u2139\uFE0F Removing your cloud resources takes a while to complete.")}`);
300
+ console.log(` ${italic("Please note, your backups will not yet be deleted. Though,")}`);
301
+ console.log(` ${italic("Backups are scheduled to delete themselves in 30 days.")}`);
302
+ await new Promise((resolve) => setTimeout(resolve, 2000));
303
+ const result = await runCommand(`bunx cdk destroy`, {
304
+ ...options,
305
+ cwd: p.cloudPath(),
306
+ stdin: "inherit"
307
+ });
308
+ if (result.isErr()) {
309
+ await outro4('While running the cloud:remove ("undeploy") command, there was an issue', { startTime, useSeconds: true }, result.error);
310
+ process4.exit(ExitCode3.FatalError);
311
+ }
312
+ await runCommand("buddy cloud:cleanup", {
313
+ ...options,
314
+ cwd: p.projectPath(),
315
+ stdin: "inherit"
316
+ });
317
+ try {
318
+ log4.info("Finalizing the removal of your cloud resources.");
319
+ log4.info("This will take a few moments...");
320
+ loop(7, () => {
321
+ runCommandSync("buddy cloud:cleanup", {
322
+ ...options,
323
+ cwd: p.projectPath(),
324
+ stdout: "ignore"
325
+ });
326
+ });
327
+ await outro4("Your cloud has been removed", { startTime, useSeconds: true });
328
+ process4.exit(ExitCode3.Success);
329
+ } catch (error) {
330
+ await outro4("While cleaning up the cloud, there was an issue", { startTime, useSeconds: true }, error);
331
+ process4.exit(ExitCode3.FatalError);
332
+ }
333
+ });
334
+ buddy.command("cloud:optimize-cost", descriptions.optimizeCost).option("--jump-box", "Remove the jump-box", { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
335
+ log4.debug("Running `buddy cloud:optimize-cost` ...", options);
336
+ const startTime = await intro4("buddy cloud:optimize-cost");
337
+ if (options.jumpBox) {
338
+ const { confirm } = await prompts({
339
+ name: "confirm",
340
+ type: "confirm",
341
+ message: "Would you like to remove your jump-box to optimize your costs?"
342
+ });
343
+ if (!confirm) {
344
+ await outro4("Exited", { startTime, useSeconds: true });
345
+ process4.exit(ExitCode3.Success);
346
+ }
347
+ await deleteJumpBox();
348
+ await outro4("Your jump-box was removed & cost optimizations are applied.", { startTime, useSeconds: true });
349
+ process4.exit(ExitCode3.Success);
350
+ }
351
+ await outro4("No cost optimization was applied", { startTime, useSeconds: true });
352
+ process4.exit(ExitCode3.Success);
353
+ });
354
+ buddy.command("cloud:cleanup", descriptions.cleanUp).alias("cloud:clean-up").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
355
+ log4.debug("Running `buddy cloud:cleanup` ...", options);
356
+ const startTime = await intro4("buddy cloud:cleanup");
357
+ log4.info(`Cleaning up your cloud resources will take a while to complete. Please be patient.`);
358
+ await new Promise((resolve) => setTimeout(resolve, 2000));
359
+ log4.info("Removing any jump-boxes...");
360
+ const result = await deleteJumpBox();
361
+ if (result.isErr()) {
362
+ if (result.error !== "Jump-box not found") {
363
+ await outro4("While removing your jump-box, there was an issue", { startTime, useSeconds: true }, result.error);
364
+ process4.exit(ExitCode3.FatalError);
365
+ }
366
+ }
367
+ log4.info("Removing any retained S3 buckets...");
368
+ const result2 = await deleteStacksBuckets();
369
+ if (result2.isErr()) {
370
+ await outro4("While deleting the retained S3 buckets, there was an issue", { startTime, useSeconds: true }, result2.error);
371
+ process4.exit(ExitCode3.FatalError);
372
+ }
373
+ log4.info("Removing any retained Lambda functions...");
374
+ const result3 = await deleteStacksFunctions();
375
+ if (result3.isErr()) {
376
+ if (result3.error !== "No stacks functions found")
377
+ await outro4("While deleting the Origin Request Lambda function, there was an issue", { startTime, useSeconds: true }, result3.error);
378
+ process4.exit(ExitCode3.FatalError);
379
+ }
380
+ log4.info(result3.value);
381
+ log4.info("Removing any remaining Stacks logs...");
382
+ const result4 = await deleteLogGroups();
383
+ if (result4.isErr()) {
384
+ await outro4("While deleting the Stacks log groups, there was an issue", { startTime, useSeconds: true }, result4.error);
385
+ process4.exit(ExitCode3.FatalError);
386
+ }
387
+ log4.info("Removing any stored parameters...");
388
+ const result7 = await deleteParameterStore();
389
+ if (result7.isErr()) {
390
+ await outro4("While deleting the Stacks log groups, there was an issue", { startTime, useSeconds: true }, result7.error);
391
+ process4.exit(ExitCode3.FatalError);
392
+ }
393
+ log4.info("Removing any CDK remnants...");
394
+ const result6 = await deleteCdkRemnants();
395
+ if (result6.isErr()) {
396
+ await outro4("While deleting the Stacks log groups, there was an issue", { startTime, useSeconds: true }, result6.error);
397
+ process4.exit(ExitCode3.FatalError);
398
+ }
399
+ log4.info("Removing any IAM users...");
400
+ const result8 = await deleteIamUsers();
401
+ if (result8.isErr()) {
402
+ await outro4("While deleting the Stacks log groups, there was an issue", { startTime, useSeconds: true }, result8.error);
403
+ process4.exit(ExitCode3.FatalError);
404
+ }
405
+ await outro4("AWS resources have been removed", { startTime, useSeconds: true });
406
+ process4.exit(ExitCode3.Success);
407
+ });
408
+ buddy.on("cloud:*", () => {
409
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
410
+ process4.exit(1);
411
+ });
412
+ }
413
+
414
+ // src/commands/commit.ts
415
+ import process5 from "process";
416
+ import {runCommit} from "@stacksjs/actions";
417
+ import {log as log5} from "@stacksjs/logging";
418
+ function commit(buddy) {
419
+ const descriptions = {
420
+ commit: "Commit your stashed changes",
421
+ project: "Target a specific project",
422
+ verbose: "Enable verbose output"
423
+ };
424
+ buddy.command("commit", descriptions.commit).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
425
+ log5.debug("Running `buddy commit` ...", options);
426
+ await runCommit(options);
427
+ });
428
+ buddy.on("commit:*", () => {
429
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
430
+ process5.exit(1);
431
+ });
432
+ }
433
+
434
+ // src/commands/configure.ts
435
+ import process6 from "process";
436
+ import {log as log6, outro as outro5, runCommand as runCommand2} from "@stacksjs/cli";
437
+ import {path as p2} from "@stacksjs/path";
438
+ import {ExitCode as ExitCode4} from "@stacksjs/types";
439
+ function configure(buddy) {
440
+ const descriptions = {
441
+ configure: "Configure options",
442
+ aws: "Configure the AWS connection",
443
+ project: "Target a specific project",
444
+ profile: "The AWS profile to use",
445
+ verbose: "Enable verbose output"
446
+ };
447
+ buddy.command("configure", descriptions.configure).option("--aws", descriptions.aws, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
448
+ log6.debug("Running `buddy configure` ...", options);
449
+ if (options?.aws) {
450
+ await configureAws(options);
451
+ process6.exit(ExitCode4.Success);
452
+ }
453
+ log6.info("Not implemented yet. Please use the --aws flag to configure AWS.");
454
+ process6.exit(ExitCode4.Success);
455
+ });
456
+ buddy.command("configure:aws", descriptions.aws).option("-p, --project", descriptions.project, { default: false }).option("--profile", descriptions.profile, { default: process6.env.AWS_PROFILE }).option("--verbose", descriptions.verbose, { default: false }).option("--access-key-id", "The AWS access key").option("--secret-access-key", "The AWS secret access key").option("--region", "The AWS region").option("--output", "The AWS output format").option("--quiet", "Suppress output").action(async (options) => {
457
+ log6.debug("Running `buddy configure:aws` ...", options);
458
+ await configureAws(options);
459
+ process6.exit(ExitCode4.Success);
460
+ });
461
+ buddy.on("configure:*", () => {
462
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
463
+ process6.exit(ExitCode4.FatalError);
464
+ });
465
+ }
466
+ async function configureAws(options) {
467
+ const startTime = performance.now();
468
+ const awsAccessKeyId = options?.accessKeyId ?? process6.env.AWS_ACCESS_KEY_ID;
469
+ const awsSecretAccessKey = options?.secretAccessKey ?? process6.env.AWS_SECRET_ACCESS_KEY;
470
+ const defaultRegion = "us-east-1";
471
+ const defaultOutputFormat = options?.output ?? "json";
472
+ const command = `aws configure --profile ${options?.profile ?? process6.env.AWS_PROFILE}`;
473
+ const input = `${awsAccessKeyId}\n${awsSecretAccessKey}\n${defaultRegion}\n${defaultOutputFormat}\n`;
474
+ const result = await runCommand2(command, {
475
+ ...options,
476
+ cwd: p2.projectPath(),
477
+ stdin: "pipe",
478
+ input
479
+ });
480
+ if (result.isErr()) {
481
+ await outro5("While running the cloud command, there was an issue", { startTime, useSeconds: true }, result.error);
482
+ process6.exit(ExitCode4.FatalError);
483
+ }
484
+ if (options?.quiet)
485
+ return;
486
+ await outro5("Exited", { startTime, useSeconds: true });
487
+ }
488
+
489
+ // src/commands/create.ts
490
+ import process7 from "process";
491
+ import {ExitCode as ExitCode5} from "@stacksjs/types";
492
+ import {bold, cyan, dim, intro as intro5, log as log7, runCommand as runCommand3} from "@stacksjs/cli";
493
+ import {useOnline} from "@stacksjs/utils";
494
+ import {isFolder} from "@stacksjs/storage";
495
+ import {resolve} from "@stacksjs/path";
496
+ import {Action as Action4} from "@stacksjs/enums";
497
+ import {runAction as runAction5} from "@stacksjs/actions";
498
+ function create(buddy) {
499
+ const descriptions = {
500
+ command: "Create a new Stacks project",
501
+ ui: "Are you building a UI?",
502
+ components: "Are you building UI components?",
503
+ webComponents: "Automagically built optimized custom elements/web components?",
504
+ vue: "Automagically built a Vue component library?",
505
+ views: "How about views?",
506
+ functions: "Are you developing functions/composables?",
507
+ api: "Are you building an API?",
508
+ database: "Do you need a database?",
509
+ notifications: "Do you need notifications? e.g. email, SMS, push or chat notifications",
510
+ cache: "Do you need caching?",
511
+ email: "Do you need email?",
512
+ project: "Target a specific project",
513
+ verbose: "Enable verbose output"
514
+ };
515
+ buddy.command("new <name>", descriptions.command).alias("create <name>").option("-u, --ui", descriptions.ui, { default: true }).option("-c, --components", descriptions.components, { default: true }).option("-w, --web-components", descriptions.webComponents, { default: true }).option("-v, --vue", descriptions.vue, { default: true }).option("-p, --views", descriptions.views, { default: true }).option("-f, --functions", descriptions.functions, { default: true }).option("-a, --api", descriptions.api, { default: true }).option("-d, --database", descriptions.database, { default: true }).option("-ca, --cache", descriptions.cache, { default: false }).option("-e, --email", descriptions.email, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
516
+ log7.debug("Running `buddy new <name>` ...", options);
517
+ const startTime = await intro5("stacks new");
518
+ const name = options.name;
519
+ const path5 = resolve(process7.cwd(), name);
520
+ isFolderCheck(path5);
521
+ onlineCheck();
522
+ const result = await download(name, path5, options);
523
+ if (result.isErr()) {
524
+ log7.error(result.error);
525
+ process7.exit(ExitCode5.FatalError);
526
+ }
527
+ await ensureEnv(path5, options);
528
+ await install(path5, options);
529
+ if (startTime) {
530
+ const time = performance.now() - startTime;
531
+ log7.success(dim(`[${time.toFixed(2)}ms] Completed`));
532
+ }
533
+ log7.info(bold("Welcome to the Stacks Framework! \u269B\uFE0F"));
534
+ log7.info("To learn more, visit https://stacksjs.org");
535
+ process7.exit(ExitCode5.Success);
536
+ });
537
+ buddy.on("new:*", () => {
538
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
539
+ process7.exit(1);
540
+ });
541
+ }
542
+ var isFolderCheck = function(path5) {
543
+ if (isFolder(path5)) {
544
+ log7.error(`Path ${path5} already exists`);
545
+ process7.exit(ExitCode5.FatalError);
546
+ }
547
+ };
548
+ var onlineCheck = function() {
549
+ const online = useOnline();
550
+ if (!online) {
551
+ log7.info("It appears you are disconnected from the internet.");
552
+ log7.info("The Stacks setup requires a brief internet connection for setup.");
553
+ log7.info("For instance, it installs your dependencies from.");
554
+ process7.exit(ExitCode5.FatalError);
555
+ }
556
+ };
557
+ async function download(name, path5, options) {
558
+ log7.info("Setting up your stack.");
559
+ const result = await runCommand3(`bunx giget stacks ${name}`, options);
560
+ log7.success(`Successfully scaffolded your project at ${cyan(path5)}`);
561
+ return result;
562
+ }
563
+ async function ensureEnv(path5, options) {
564
+ log7.info("Ensuring your environment is ready...");
565
+ await runCommand3("pkgx --update ", { ...options, cwd: path5 });
566
+ log7.success("Environment is ready");
567
+ }
568
+ async function install(path5, options) {
569
+ log7.info("Installing & setting up Stacks");
570
+ let result = await runCommand3("bun install", { ...options, cwd: path5 });
571
+ if (result?.isErr()) {
572
+ log7.error(result.error);
573
+ process7.exit();
574
+ }
575
+ result = await runCommand3("cp .env.example .env", { ...options, cwd: path5 });
576
+ if (result?.isErr()) {
577
+ log7.error(result.error);
578
+ process7.exit(ExitCode5.FatalError);
579
+ }
580
+ await runAction5(Action4.KeyGenerate, { ...options, cwd: path5 });
581
+ result = await runCommand3("git init", { ...options, cwd: path5 });
582
+ if (result.isErr()) {
583
+ log7.error(result.error);
584
+ process7.exit(ExitCode5.FatalError);
585
+ }
586
+ log7.success("Installed & set-up \uD83D\uDE80");
587
+ }
588
+
589
+ // src/commands/deploy.ts
590
+ import process8 from "process";
591
+ import {ExitCode as ExitCode6} from "@stacksjs/types";
592
+ import {runAction as runAction6} from "@stacksjs/actions";
593
+ import {intro as intro6, italic as italic2, log as log8, outro as outro6, runCommand as runCommand4} from "@stacksjs/cli";
594
+ import {Action as Action5} from "@stacksjs/enums";
595
+ import {app} from "@stacksjs/config";
596
+ import {addDomain, hasUserDomainBeenAddedToCloud} from "@stacksjs/dns";
597
+ function deploy(buddy) {
598
+ const descriptions = {
599
+ deploy: "Re-installs your npm dependencies",
600
+ project: "Target a specific project",
601
+ verbose: "Enable verbose output"
602
+ };
603
+ buddy.command("deploy", descriptions.deploy).option("--domain", "Specify a domain to deploy to", { default: undefined }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
604
+ log8.debug("Running `buddy deploy` ...", options);
605
+ const startTime = await intro6("buddy deploy");
606
+ const domain = options.domain || app.url;
607
+ if (!domain) {
608
+ log8.info("No domain found in your .env or ./config/app.ts");
609
+ log8.info("Please ensure your domain is properly configured.");
610
+ log8.info("For more info, check out the docs or join our Discord.");
611
+ process8.exit(ExitCode6.FatalError);
612
+ }
613
+ await checkIfAwsIsConfigured();
614
+ options.domain = await configureDomain(domain, options, startTime);
615
+ const result = await runAction6(Action5.Deploy, options);
616
+ if (result.isErr()) {
617
+ await outro6("While running the `buddy deploy`, there was an issue", { startTime, useSeconds: true }, result.error);
618
+ process8.exit(ExitCode6.FatalError);
619
+ }
620
+ await outro6("Project deployed.", { startTime, useSeconds: true });
621
+ });
622
+ buddy.on("deploy:*", () => {
623
+ log8.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
624
+ process8.exit(1);
625
+ });
626
+ }
627
+ async function configureDomain(domain, options, startTime) {
628
+ if (!domain) {
629
+ log8.info("We could not identify a domain to deploy to.");
630
+ log8.info("Please set your .env or ./config/app.ts properly.");
631
+ console.log("");
632
+ log8.info("Alternatively, specify a domain to deploy via the `--domain` flag.");
633
+ console.log("");
634
+ log8.info(" \u27A1\uFE0F Example: `buddy deploy --domain example.com`");
635
+ console.log("");
636
+ process8.exit(ExitCode6.FatalError);
637
+ }
638
+ if (domain.includes("localhost")) {
639
+ log8.info("You are deploying to a local environment.");
640
+ log8.info("Please set your .env or ./config/app.ts properly. The domain we are deploying cannot be a `localhost` domain.");
641
+ console.log("");
642
+ log8.info("Alternatively, specify a domain to deploy via the `--domain` flag.");
643
+ console.log("");
644
+ log8.info(" \u27A1\uFE0F Example: `buddy deploy --domain example.com`");
645
+ console.log("");
646
+ process8.exit(ExitCode6.FatalError);
647
+ }
648
+ if (await hasUserDomainBeenAddedToCloud(domain)) {
649
+ log8.info("Domain is properly configured");
650
+ log8.info("Your cloud is deploying...");
651
+ log8.info(`${italic2("This may take a while...")}`);
652
+ return domain;
653
+ }
654
+ console.log("");
655
+ log8.info(` \uD83D\uDC4B It appears to be your first ${italic2(domain)} deployment.`);
656
+ console.log("");
657
+ log8.info(italic2("Let\u2019s ensure it is all connected properly."));
658
+ log8.info(italic2("One moment..."));
659
+ console.log("");
660
+ const result = await addDomain({
661
+ ...options,
662
+ deploy: true,
663
+ startTime
664
+ });
665
+ if (result.isErr()) {
666
+ await outro6("While running the `buddy deploy`, there was an issue", { startTime, useSeconds: true }, result.error);
667
+ process8.exit(ExitCode6.FatalError);
668
+ }
669
+ await outro6("Added your domain.", { startTime, useSeconds: true });
670
+ process8.exit(ExitCode6.Success);
671
+ }
672
+ async function checkIfAwsIsConfigured() {
673
+ log8.info("Ensuring AWS is configured...");
674
+ const result = await runCommand4("buddy configure:aws", {
675
+ silent: true
676
+ });
677
+ if (result.isErr()) {
678
+ log8.error("AWS is not configured properly.");
679
+ log8.error("Please run `buddy configure:aws` to set up your AWS credentials.");
680
+ process8.exit(ExitCode6.FatalError);
681
+ }
682
+ log8.success("AWS is configured");
683
+ }
684
+
685
+ // src/commands/dev.ts
686
+ import process9 from "process";
687
+ import {Action as Action6} from "@stacksjs/enums";
688
+ import {
689
+ runAction as runAction7,
690
+ runApiDevServer,
691
+ runComponentsDevServer,
692
+ runDashboardDevServer,
693
+ runDesktopDevServer,
694
+ runDocsDevServer,
695
+ runFrontendDevServer,
696
+ runSystemTrayDevServer
697
+ } from "@stacksjs/actions";
698
+ import {ExitCode as ExitCode7} from "@stacksjs/types";
699
+ import {intro as intro7, log as log9, outro as outro7, runCommand as runCommand5} from "@stacksjs/cli";
700
+ import {libsPath} from "@stacksjs/path";
701
+ function dev(buddy) {
702
+ const descriptions = {
703
+ dev: "Starts development server",
704
+ frontend: "Starts the frontend development server",
705
+ components: "Start the Components development server",
706
+ desktop: "Start the Desktop App development server",
707
+ dashboard: "Start the Dashboard development server",
708
+ api: "Start the local API development server",
709
+ email: "Start the Email development server",
710
+ docs: "Start the Documentation development server",
711
+ systemTray: "Start the System Tray development server",
712
+ interactive: "Get asked which development server to start",
713
+ select: "Which development server are you trying to start?",
714
+ withLocalhost: "Include the localhost URL in the output",
715
+ project: "Target a specific project",
716
+ verbose: "Enable verbose output"
717
+ };
718
+ buddy.command("dev [server]", descriptions.dev).option("-f, --frontend", descriptions.frontend).option("-a, --api", descriptions.api).option("-e, --email", descriptions.email).option("-c, --components", descriptions.components).option("-d, --dashboard", descriptions.dashboard).option("-t, --desktop", descriptions.desktop).option("-d, --docs", descriptions.docs).option("-t, --system-tray", descriptions.systemTray).option("-i, --interactive", descriptions.interactive, { default: false }).option("-l, --with-localhost", descriptions.withLocalhost, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (server, options) => {
719
+ log9.debug("Running `buddy dev [server]` ...", options);
720
+ const perf = await intro7("buddy dev");
721
+ switch (server) {
722
+ case "frontend":
723
+ await runFrontendDevServer(options);
724
+ break;
725
+ case "api":
726
+ await runApiDevServer(options);
727
+ break;
728
+ case "components":
729
+ await runComponentsDevServer(options);
730
+ break;
731
+ case "dashboard":
732
+ await runDashboardDevServer(options);
733
+ break;
734
+ case "desktop":
735
+ await runDesktopDevServer(options);
736
+ break;
737
+ case "system-tray":
738
+ await runSystemTrayDevServer(options);
739
+ break;
740
+ case "docs":
741
+ await runDocsDevServer(options);
742
+ break;
743
+ default:
744
+ }
745
+ if (wantsInteractive(options)) {
746
+ const answer = await log9.prompt.require().select(descriptions.select, {
747
+ options: [
748
+ { value: "all", label: "All" },
749
+ { value: "frontend", label: "Frontend" },
750
+ { value: "api", label: "Backend" },
751
+ { value: "dashboard", label: "Dashboard" },
752
+ { value: "desktop", label: "Desktop" },
753
+ { value: "email", label: "Email" },
754
+ { value: "components", label: "Components" },
755
+ { value: "docs", label: "Documentation" }
756
+ ]
757
+ });
758
+ if (answer === "components") {
759
+ await runComponentsDevServer(options);
760
+ } else if (answer === "api") {
761
+ await runApiDevServer(options);
762
+ } else if (answer === "dashboard") {
763
+ await runDashboardDevServer(options);
764
+ } else if (answer === "docs") {
765
+ await runDocsDevServer(options);
766
+ } else {
767
+ log9.error("Invalid option during interactive mode");
768
+ process9.exit(ExitCode7.InvalidArgument);
769
+ }
770
+ } else {
771
+ if (options.components)
772
+ await runComponentsDevServer(options);
773
+ if (options.docs)
774
+ await runDocsDevServer(options);
775
+ else if (options.api)
776
+ await runApiDevServer(options);
777
+ }
778
+ await startDevelopmentServer(options);
779
+ outro7("Exited", { startTime: perf, useSeconds: true });
780
+ process9.exit(ExitCode7.Success);
781
+ });
782
+ buddy.command("dev:components", descriptions.components).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
783
+ log9.debug("Running `buddy dev:components` ...", options);
784
+ const perf = await intro7("buddy dev:components");
785
+ const result = await runCommand5("bun run dev", {
786
+ cwd: libsPath("components/vue")
787
+ });
788
+ if (options.verbose)
789
+ log9.info("buddy dev:components result", result);
790
+ if (result.isErr()) {
791
+ await outro7("While running the dev:components command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
792
+ process9.exit();
793
+ }
794
+ console.log("");
795
+ await outro7("Exited", { startTime: perf, useSeconds: true });
796
+ process9.exit(ExitCode7.Success);
797
+ });
798
+ buddy.command("dev:docs", descriptions.docs).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
799
+ log9.debug("Running `buddy dev:docs` ...", options);
800
+ const perf = await intro7("buddy dev:docs");
801
+ const result = await runAction7(Action6.DevDocs, options);
802
+ if (result.isErr()) {
803
+ await outro7("While running the dev:docs command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
804
+ process9.exit();
805
+ }
806
+ console.log("");
807
+ await outro7("Exited", { startTime: perf, useSeconds: true });
808
+ process9.exit(ExitCode7.Success);
809
+ });
810
+ buddy.command("dev:desktop", descriptions.desktop).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
811
+ log9.debug("Running `buddy dev:desktop` ...", options);
812
+ const perf = await intro7("buddy dev:desktop");
813
+ const result = await runAction7(Action6.DevDesktop, options);
814
+ if (result.isErr()) {
815
+ await outro7("While running the dev:desktop command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
816
+ process9.exit();
817
+ }
818
+ console.log("");
819
+ await outro7("Exited", { startTime: perf, useSeconds: true });
820
+ process9.exit(ExitCode7.Success);
821
+ });
822
+ buddy.command("dev:api", descriptions.api).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
823
+ log9.debug("Running `buddy dev:api` ...", options);
824
+ await runApiDevServer(options);
825
+ });
826
+ buddy.command("dev:frontend", descriptions.frontend).alias("dev:pages").alias("dev:views").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
827
+ log9.debug("Running `buddy dev:frontend` ...", options);
828
+ await runFrontendDevServer(options);
829
+ });
830
+ buddy.command("dev:dashboard", descriptions.dashboard).alias("dev:admin").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
831
+ log9.debug("Running `buddy dev:dashboard` ...", options);
832
+ await runDashboardDevServer(options);
833
+ });
834
+ buddy.command("dev:system-tray", descriptions.systemTray).alias("dev:tray").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
835
+ log9.debug("Running `buddy dev:system-tray` ...", options);
836
+ await runSystemTrayDevServer(options);
837
+ });
838
+ buddy.on("dev:*", () => {
839
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
840
+ process9.exit(1);
841
+ });
842
+ }
843
+ async function startDevelopmentServer(options) {
844
+ const result = await runAction7(Action6.Dev, options);
845
+ if (result.isErr()) {
846
+ log9.error("While running the dev command, there was an issue", result.error);
847
+ process9.exit(ExitCode7.InvalidArgument);
848
+ }
849
+ }
850
+ var wantsInteractive = function(options) {
851
+ return options.interactive;
852
+ };
853
+
854
+ // src/commands/domains.ts
855
+ import process10 from "process";
856
+ import {runAction as runAction8} from "@stacksjs/actions";
857
+ import {bgCyan, bold as bold2, intro as intro8, italic as italic3, log as log10, outro as outro8, prompts as prompts2} from "@stacksjs/cli";
858
+ import {config as config3} from "@stacksjs/config";
859
+ import {addDomain as addDomain2} from "@stacksjs/dns";
860
+ import {ExitCode as ExitCode8} from "@stacksjs/types";
861
+ import {Action as Action7} from "@stacksjs/enums";
862
+ function domains(buddy) {
863
+ const descriptions = {
864
+ purchase: "Purchase a domain",
865
+ add: "Add a domain to your cloud",
866
+ remove: "Remove a domain from your cloud",
867
+ skip: "Skip the confirmation prompt",
868
+ project: "Target a specific project",
869
+ verbose: "Enable verbose output"
870
+ };
871
+ const c = config3.dns.contactInfo;
872
+ buddy.command("domains:purchase <domain>", descriptions.purchase).option("--years <years>", "Number of years to purchase the domain for", { default: 1 }).option("--privacy", "Enable privacy protection", { default: true }).option("--auto-renew", "Enable auto-renew", { default: true }).option("--first-name <firstName>", "Registrant first name", { default: c?.firstName }).option("--last-name <lastName>", "Registrant last name", { default: c?.lastName }).option("--organization <organization>", "Registrant organization name", { default: c?.organizationName }).option("--address-line1 <address>", "Registrant address line 1", { default: c?.addressLine1 }).option("--address-line2 <address>", "Registrant address line 2", { default: c?.addressLine2 }).option("--city <city>", "Registrant city", { default: c?.city }).option("--state <state>", "Registrant state", { default: c?.state }).option("--country <country>", "Registrant country code", { default: c?.countryCode }).option("--zip <zip>", "Registrant zip", { default: c?.zip }).option("--phone <phone>", "Registrant phone", { default: c?.phoneNumber }).option("--email <email>", "Registrant email", { default: c?.email }).option("--admin-first-name <firstName>", "Admin first name", { default: c?.admin?.firstName || c?.firstName }).option("--admin-last-name <lastName>", "Admin last name", { default: c?.admin?.lastName || c?.lastName }).option("--admin-organization <organization>", "Admin organization", { default: c?.admin?.organizationName || c?.organizationName }).option("--admin-address-line1 <address>", "Admin address line 1", { default: c?.admin?.addressLine1 || c?.addressLine1 }).option("--admin-address-line2 <address>", "Admin address line 2", { default: c?.admin?.addressLine2 || c?.addressLine2 }).option("--admin-city <city>", "Admin city", { default: c?.admin?.city || c?.city }).option("--admin-state <state>", "Admin state", { default: c?.admin?.state || c?.state }).option("--admin-country <country>", "Admin country code", { default: c?.admin?.countryCode || c?.countryCode }).option("--admin-zip <zip>", "Admin zip", { default: c?.admin?.zip || c?.zip }).option("--admin-phone <phone>", "Admin phone number", { default: c?.admin?.phoneNumber || c?.phoneNumber }).option("--admin-email <email>", "Admin email", { default: c?.admin?.email || c?.email }).option("--tech-first-name <firstName>", "Tech first name", { default: c?.tech?.firstName || c?.firstName }).option("--tech-last-name <lastName>", "Tech last name", { default: c?.tech?.lastName || c?.lastName }).option("--tech-organization <organization>", "Tech organization name", { default: c?.tech?.organizationName || c?.organizationName }).option("--tech-address-line1 <address>", "Tech address line 1", { default: c?.tech?.addressLine1 || c?.addressLine1 }).option("--tech-address-line2 <address>", "Tech address line 2", { default: c?.tech?.addressLine2 || c?.addressLine2 }).option("--tech-city <city>", "Tech city", { default: c?.tech?.city || c?.city }).option("--tech-state <state>", "Tech state", { default: c?.tech?.state || c?.state }).option("--tech-country <country>", "Tech country", { default: c?.tech?.countryCode || c?.countryCode }).option("--tech-zip <zip>", "Tech zip", { default: c?.tech?.zip || c?.zip }).option("--tech-phone <phone>", "Tech phone", { default: c?.tech?.phoneNumber || c?.phoneNumber }).option("--tech-email <email>", "Tech email", { default: c?.tech?.email || c?.email }).option("--privacy-admin", "Enable privacy protection for admin", { default: c?.privacyAdmin || c?.privacy || true }).option("--privacy-tech", "Enable privacy protection for tech", { default: c?.privacyTech || c?.privacy || true }).option("--privacy-registrant", "Enable privacy protection for registrant", { default: c?.privacyRegistrant || c?.privacy || true }).option("--contact-type <type>", "Contact type", { default: "person" }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (domain, options) => {
873
+ log10.debug("Running `buddy domains:purchase <domain>` ...", options);
874
+ options.domain = domain;
875
+ const startTime = await intro8("buddy domains:purchase");
876
+ const result = await runAction8(Action7.DomainsPurchase, options);
877
+ if (result.isErr()) {
878
+ await outro8("While running the domains:purchase command, there was an issue", { startTime, useSeconds: true }, result.error);
879
+ process10.exit(ExitCode8.FatalError);
880
+ }
881
+ const { confirm } = await prompts2({
882
+ name: "confirm",
883
+ type: "confirm",
884
+ message: `Would you like to set ${domain} as your APP_URL?`
885
+ });
886
+ if (!confirm) {
887
+ await outro8(`Alrighty! ${italic3(domain)} was added to your account.`, { startTime, useSeconds: true, type: "success" });
888
+ log10.info(`Please note, you may need to validate your email address. Check your ${italic3(options.registrantEmail)} inbox.`);
889
+ process10.exit(ExitCode8.Success);
890
+ }
891
+ const { writeEnv } = await import("../../env/src/index.js");
892
+ writeEnv("APP_URL", domain);
893
+ let message = `Great! ${italic3(domain)} was added to your account.`;
894
+ message += `\n\nAnd your APP_URL has been set to ${italic3(domain)}.
895
+ \nPlease note, this change has not been deployed yet.
896
+ \nThe next time you run ${bgCyan(italic3(bold2(" buddy deploy ")))}, your app will deploy to ${italic3(domain)}.
897
+ \n${italic3("You may need to deploy 2-3 times for the changes to take effect. Issue tracked here: https://github.com/stacksjs/stacks/issues/685")}`;
898
+ await outro8(message, { startTime, useSeconds: true, type: "info" });
899
+ process10.exit(ExitCode8.Success);
900
+ });
901
+ buddy.command("domains:add <domain>", descriptions.add).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
902
+ log10.debug("Running `buddy domains:add <domain>` ...", options);
903
+ const startTime = await intro8("buddy domains:add");
904
+ const result = await addDomain2({
905
+ ...options,
906
+ startTime
907
+ });
908
+ if (result.isErr()) {
909
+ await outro8("While running the `buddy deploy`, there was an issue", { startTime, useSeconds: true }, result.error);
910
+ process10.exit(ExitCode8.FatalError);
911
+ }
912
+ await outro8("Added your domain.", { startTime, useSeconds: true });
913
+ process10.exit(ExitCode8.Success);
914
+ });
915
+ buddy.command("domains:remove <domain>", descriptions.remove).option("--yes", descriptions.skip, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
916
+ log10.debug("Running `buddy domains:remove <domain>` ...", options);
917
+ const domain = options.domain || config3.app.url;
918
+ const opts = { ...options, domain };
919
+ const startTime = await intro8("buddy domains:remove");
920
+ if (!opts.yes) {
921
+ const { confirm } = await prompts2({
922
+ name: "confirm",
923
+ type: "confirm",
924
+ message: `Are you sure you want to remove ${domain}?`
925
+ });
926
+ if (!confirm) {
927
+ await outro8("Cancelled the domains:remove command", { startTime, useSeconds: true, type: "info" });
928
+ process10.exit(ExitCode8.Success);
929
+ }
930
+ }
931
+ const result = await runAction8(Action7.DomainsRemove, opts);
932
+ if (result.isErr()) {
933
+ await outro8("While running the domains:remove command, there was an issue", { startTime, useSeconds: true }, result.error);
934
+ process10.exit(ExitCode8.FatalError);
935
+ }
936
+ await outro8("Removed your domain DNS records.", { startTime, useSeconds: true });
937
+ process10.exit(ExitCode8.Success);
938
+ });
939
+ buddy.on("domains:*", () => {
940
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
941
+ process10.exit(1);
942
+ });
943
+ }
944
+
945
+ // src/commands/dns.ts
946
+ import process11 from "process";
947
+ import {ExitCode as ExitCode9} from "@stacksjs/types";
948
+ import {config as config5} from "@stacksjs/config";
949
+ import {log as log11, runCommand as runCommand6} from "@stacksjs/cli";
950
+ function dns3(buddy) {
951
+ const descriptions = {
952
+ dns: "Lists the DNS records for a domain",
953
+ query: "Host name or IP address to query",
954
+ type: "Type of the DNS record being queried (A, MX, NS\u2026)",
955
+ nameserver: "Address of the nameserver to send packets to",
956
+ class: "Network class of the DNS record being queried (IN, CH, HS)",
957
+ udp: "Use the DNS protocol over UDP",
958
+ tcp: "Use the DNS protocol over TCP",
959
+ tls: "Use the DNS-over-TLS protocol",
960
+ https: "Use the DNS-over-HTTPS protocol",
961
+ short: "Short mode: display nothing but the first result",
962
+ json: "Display the output as JSON",
963
+ pretty: "Display the output as JSON in a pretty format",
964
+ project: "Target a specific project",
965
+ verbose: "Enable verbose output"
966
+ };
967
+ buddy.command("dns [domain]", descriptions.dns).option("-q, --query <query>", descriptions.query).option("-t, --type <type>", descriptions.type, { default: "ANY" }).option("-n, --nameserver <nameserver>", descriptions.nameserver).option("--class <class>", descriptions.nameserver).option("-U, --udp", descriptions.udp).option("-T, --tcp", descriptions.tcp).option("-S, --tls", descriptions.tls).option("-H, --https", descriptions.https).option("-1, --short", descriptions.short, { default: false }).option("-J, --json", descriptions.json, { default: false }).option("-p, --pretty", descriptions.pretty, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (domain, options) => {
968
+ log11.debug("Running `buddy dns [domain]` ...", options);
969
+ delete options.pretty;
970
+ delete options.p;
971
+ const optionsString = Object.entries(options).filter(([key, value]) => key !== "--" && key.length > 1 && value !== false).map(([key, value]) => `--${key} ${value}`).join(" ");
972
+ await runCommand6(`dog ${domain || config5.app.url} ${optionsString}`);
973
+ process11.exit(ExitCode9.Success);
974
+ });
975
+ buddy.on("dns:*", () => {
976
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
977
+ process11.exit(1);
978
+ });
979
+ }
980
+
981
+ // src/commands/fresh.ts
982
+ import process12 from "process";
983
+ import {ExitCode as ExitCode10} from "@stacksjs/types";
984
+ import {runAction as runAction9} from "@stacksjs/actions";
985
+ import {intro as intro9, log as log12, outro as outro9} from "@stacksjs/cli";
986
+ import {Action as Action8} from "@stacksjs/enums";
987
+ function fresh(buddy) {
988
+ const descriptions = {
989
+ fresh: "Re-installs your npm dependencies",
990
+ project: "Target a specific project",
991
+ verbose: "Enable verbose output"
992
+ };
993
+ buddy.command("fresh", descriptions.fresh).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
994
+ log12.debug("Running `buddy fresh` ...", options);
995
+ const perf = await intro9("buddy fresh");
996
+ const result = await runAction9(Action8.Fresh, { ...options, stdout: "inherit" });
997
+ if (result.isErr()) {
998
+ await outro9("While running `buddy fresh`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
999
+ process12.exit(ExitCode10.FatalError);
1000
+ }
1001
+ await outro9("Freshly reinstalled your dependencies", { startTime: perf, useSeconds: true });
1002
+ process12.exit(ExitCode10.Success);
1003
+ });
1004
+ buddy.on("fresh:*", () => {
1005
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1006
+ process12.exit(1);
1007
+ });
1008
+ }
1009
+
1010
+ // src/commands/generate.ts
1011
+ import process13 from "process";
1012
+ import {
1013
+ generateComponentMeta,
1014
+ generateCoreSymlink,
1015
+ generateIdeHelpers,
1016
+ generateLibEntries,
1017
+ generateMigrations,
1018
+ generatePkgxConfig,
1019
+ generateTypes,
1020
+ generateVsCodeCustomData,
1021
+ generateWebTypes,
1022
+ invoke as startGenerationProcess
1023
+ } from "@stacksjs/actions";
1024
+ import {log as log13} from "@stacksjs/cli";
1025
+ import {ExitCode as ExitCode11} from "@stacksjs/types";
1026
+ function generate(buddy) {
1027
+ const descriptions = {
1028
+ command: "Automagically build any of your libraries/packages for production use. Select any of the following packages",
1029
+ types: "Generate your TypeScript types",
1030
+ entries: "Generate your function & Component Library Entry Points",
1031
+ webTypes: "Generate web-types.json for IDEs",
1032
+ customData: "Generate VS Code custom data (custom-elements.json) for IDEs",
1033
+ ideHelpers: "Generate IDE helpers",
1034
+ componentMeta: "Generate component meta information",
1035
+ coreSymlink: "Generate symlink of the core framework to the project root",
1036
+ pkgx: "Generate the pkgx configuration file",
1037
+ select: "What are you trying to generate?",
1038
+ project: "Target a specific project",
1039
+ verbose: "Enable verbose output"
1040
+ };
1041
+ buddy.command("generate", descriptions.command).option("-t, --types", descriptions.types).option("-e, --entries", descriptions.entries).option("-w, --web-types", descriptions.webTypes).option("-c, --custom-data", descriptions.customData).option("-i, --ide-helpers", descriptions.ideHelpers).option("-c, --component-meta", descriptions.componentMeta).option("-p, --pkgx", descriptions.pkgx).option("-p, --project", descriptions.project, { default: false }).option("--core-symlink", descriptions.coreSymlink).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1042
+ log13.debug("Running `buddy generate` ...", options);
1043
+ await startGenerationProcess(options);
1044
+ process13.exit(ExitCode11.Success);
1045
+ });
1046
+ buddy.command("generate:types", descriptions.types).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).alias("types:generate").action(async (options) => {
1047
+ log13.debug("Running `buddy generate:types` ...", options);
1048
+ await generateTypes(options);
1049
+ });
1050
+ buddy.command("generate:entries", descriptions.entries).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1051
+ log13.debug("Running `buddy generate:entries` ...", options);
1052
+ await generateLibEntries(options);
1053
+ });
1054
+ buddy.command("generate:web-types", descriptions.webTypes).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1055
+ log13.debug("Running `buddy generate:web-types` ...", options);
1056
+ await generateWebTypes(options);
1057
+ });
1058
+ buddy.command("generate:vscode-custom-data", descriptions.customData).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1059
+ log13.debug("Running `buddy generate:vscode-custom-data` ...", options);
1060
+ await generateVsCodeCustomData(options);
1061
+ });
1062
+ buddy.command("generate:ide-helpers", descriptions.ideHelpers).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1063
+ log13.debug("Running `buddy generate:ide-helpers` ...", options);
1064
+ await generateIdeHelpers(options);
1065
+ });
1066
+ buddy.command("generate:component-meta", descriptions.componentMeta).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1067
+ log13.debug("Running `buddy generate:component-meta` ...", options);
1068
+ await generateComponentMeta(options);
1069
+ });
1070
+ buddy.command("generate:pkgx-config", descriptions.pkgx).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action((options) => {
1071
+ log13.debug("Running `buddy generate:pkgx-config` ...", options);
1072
+ generatePkgxConfig();
1073
+ });
1074
+ buddy.command("generate:migrations", "Generate Migrations").action((options) => {
1075
+ log13.debug("Running `buddy generate:migrations` ...", options);
1076
+ generateMigrations();
1077
+ });
1078
+ buddy.command("generate:core-symlink", "Generate core symlink. A shortcut for core developers.").action(async (options) => {
1079
+ log13.debug("Running `buddy core-symlink` ...", options);
1080
+ await generateCoreSymlink();
1081
+ });
1082
+ buddy.on("generate:*", () => {
1083
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1084
+ process13.exit(1);
1085
+ });
1086
+ }
1087
+
1088
+ // src/commands/http.ts
1089
+ import process14 from "process";
1090
+ import {ExitCode as ExitCode12} from "@stacksjs/types";
1091
+ import {config as config7} from "@stacksjs/config";
1092
+ import {log as log14, runCommandSync as runCommandSync2} from "@stacksjs/cli";
1093
+ function http(buddy) {
1094
+ const descriptions = {
1095
+ http: "Send an HTTP request to a domain",
1096
+ project: "Target a specific project",
1097
+ verbose: "Enable verbose output"
1098
+ };
1099
+ buddy.command("http [domain]", descriptions.http).option("-p, --project", descriptions.project, { default: false }).action(async (domain, options) => {
1100
+ log14.debug("Running `buddy http [domain]` ...", options);
1101
+ const optionsString = Object.entries(options).filter(([key, value]) => key !== "--" && key.length > 1 && value !== false).map(([key, value]) => `--${key} ${value}`).join(" ");
1102
+ const command = `http GET ${domain || config7.app.url} ${optionsString}`;
1103
+ log14.info(`Running command: ${command}`);
1104
+ await runCommandSync2(command);
1105
+ process14.exit(ExitCode12.Success);
1106
+ });
1107
+ }
1108
+
1109
+ // src/commands/lint.ts
1110
+ import process15 from "process";
1111
+ import {intro as intro10, log as log15, outro as outro10} from "@stacksjs/cli";
1112
+ import {Action as Action9} from "@stacksjs/enums";
1113
+ import {runAction as runAction10} from "@stacksjs/actions";
1114
+ function lint(buddy) {
1115
+ const descriptions = {
1116
+ lint: "Automagically lints your project codebase",
1117
+ lintFix: "Automagically fixes all lint errors",
1118
+ project: "Target a specific project",
1119
+ verbose: "Enable verbose output"
1120
+ };
1121
+ buddy.command("lint", descriptions.lint).option("-f, --fix", descriptions.lintFix, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1122
+ log15.debug("Running `buddy lint` ...", options);
1123
+ const startTime = await intro10("buddy lint");
1124
+ const result = await runAction10(Action9.Lint, options);
1125
+ if (result.isErr()) {
1126
+ await outro10("While running `buddy lint`, there was an issue", { startTime, useSeconds: true }, result.error);
1127
+ process15.exit();
1128
+ }
1129
+ await outro10("Linted your project", { startTime, useSeconds: true });
1130
+ });
1131
+ buddy.command("lint:fix", descriptions.lintFix).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1132
+ log15.debug("Running `buddy lint:fix` ...", options);
1133
+ log15.info("Fixing lint errors...");
1134
+ const result = await runAction10(Action9.LintFix, { ...options });
1135
+ if (result.isErr()) {
1136
+ log15.error("There was an error lint fixing your code.", result.error);
1137
+ process15.exit();
1138
+ }
1139
+ log15.success("Fixed lint errors");
1140
+ });
1141
+ buddy.on("lint:*", () => {
1142
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1143
+ process15.exit(1);
1144
+ });
1145
+ }
1146
+
1147
+ // src/commands/list.ts
1148
+ import process16 from "process";
1149
+ var {$ } = globalThis.Bun;
1150
+ import {projectPath} from "@stacksjs/path";
1151
+ import {log as log16} from "@stacksjs/logging";
1152
+ function list(buddy) {
1153
+ const descriptions = {
1154
+ list: "List all of the project-specific Buddy commands",
1155
+ project: "Target a specific project",
1156
+ verbose: "Enable verbose output"
1157
+ };
1158
+ buddy.command("list", descriptions.list).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1159
+ log16.debug("Running `buddy list` ...", options);
1160
+ $.cwd(projectPath());
1161
+ const test = await $`buddy --help`.text();
1162
+ const commandsSection = test.match(/Commands:.*?(?=For more info, run any command with the)/s)?.[0];
1163
+ if (commandsSection) {
1164
+ const cleanedCommands = commandsSection.replace("Commands:", "").replace(/^\s+/gm, "");
1165
+ console.log(cleanedCommands);
1166
+ return;
1167
+ }
1168
+ console.error("#1 - Please reach out to our Discord for helper: https://discord.gg/stacksjs");
1169
+ });
1170
+ buddy.on("list:*", () => {
1171
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1172
+ process16.exit(1);
1173
+ });
1174
+ }
1175
+
1176
+ // src/commands/install.ts
1177
+ import process17 from "process";
1178
+ import {log as log17, runCommand as runCommand7} from "@stacksjs/cli";
1179
+ import {path as p3} from "@stacksjs/path";
1180
+ function install2(buddy) {
1181
+ const descriptions = {
1182
+ install: "Install your dependencies",
1183
+ project: "Target a specific project",
1184
+ verbose: "Enable verbose output"
1185
+ };
1186
+ buddy.command("install", descriptions.install).option("-p, --project", descriptions.project, { default: false }).option("-v, --verbose", descriptions.verbose, { default: false }).action(async (options) => {
1187
+ log17.debug("Running `buddy install` ...", options);
1188
+ await runCommand7("bun install", {
1189
+ ...options,
1190
+ cwd: p3.projectPath()
1191
+ });
1192
+ });
1193
+ buddy.on("install:*", () => {
1194
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1195
+ process17.exit(1);
1196
+ });
1197
+ }
1198
+
1199
+ // src/commands/key.ts
1200
+ import process18 from "process";
1201
+ import {intro as intro11, log as log18, outro as outro11} from "@stacksjs/cli";
1202
+ import {runAction as runAction11} from "@stacksjs/actions";
1203
+ import {Action as Action10} from "@stacksjs/enums";
1204
+ function key(buddy) {
1205
+ const descriptions = {
1206
+ command: "Generate & set the application key.",
1207
+ project: "Target a specific project",
1208
+ verbose: "Enable verbose output"
1209
+ };
1210
+ buddy.command("key:generate", descriptions.command).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1211
+ log18.debug("Running `buddy key:generate` ...", options);
1212
+ await intro11("buddy key:generate");
1213
+ const result = await runAction11(Action10.KeyGenerate, options);
1214
+ if (result.isErr()) {
1215
+ log18.error("Failed to set random application key.", result.error);
1216
+ process18.exit();
1217
+ }
1218
+ await outro11("Random application key set.");
1219
+ });
1220
+ buddy.on("key:*", () => {
1221
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1222
+ process18.exit(1);
1223
+ });
1224
+ }
1225
+
1226
+ // src/commands/make.ts
1227
+ import process19 from "process";
1228
+ import {
1229
+ createModel,
1230
+ createNotification,
1231
+ invoke,
1232
+ makeComponent,
1233
+ makeDatabase,
1234
+ makeFunction,
1235
+ makeLanguage,
1236
+ makePage,
1237
+ makeStack
1238
+ } from "@stacksjs/actions";
1239
+ import {intro as intro12, italic as italic4, outro as outro12, runCommand as runCommand8} from "@stacksjs/cli";
1240
+ import {localUrl} from "@stacksjs/config";
1241
+ import {path as p4} from "@stacksjs/path";
1242
+ import {log as log19} from "@stacksjs/logging";
1243
+ import {ExitCode as ExitCode13} from "@stacksjs/types";
1244
+ function make(buddy) {
1245
+ const descriptions = {
1246
+ model: "Create a new model",
1247
+ component: "Create a new component",
1248
+ page: "Create a new page",
1249
+ function: "Create a new function",
1250
+ language: "Create a new language",
1251
+ database: "Create a new database",
1252
+ migration: "Create a new migration",
1253
+ factory: "Create a new factory",
1254
+ notification: "Create a new notification",
1255
+ stack: "Create a new stack",
1256
+ certificate: "Create a new SSL Certificate",
1257
+ select: "What are you trying to make?",
1258
+ project: "Target a specific project",
1259
+ verbose: "Enable verbose output"
1260
+ };
1261
+ buddy.command("make", "The make command").option("-c, --component", descriptions.component, { default: false }).option("-p, --page", descriptions.page, { default: false }).option("-f, --function", descriptions.function, { default: false }).option("-l, --language", descriptions.language, { default: false }).option("-d, --database", descriptions.database, { default: false }).option("-m, --migration", descriptions.migration, { default: false }).option("-f, --factory", descriptions.factory, { default: false }).option("-n, --notification", descriptions.notification, { default: false }).option("-s, --stack", descriptions.stack, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1262
+ log19.debug("Running `buddy make` ...", options);
1263
+ const name = buddy.args[0];
1264
+ if (!name) {
1265
+ log19.error("You need to specify a name. Read more about the documentation here.");
1266
+ process19.exit();
1267
+ }
1268
+ await invoke(options);
1269
+ process19.exit(ExitCode13.Success);
1270
+ });
1271
+ buddy.command("make:component", descriptions.component).option("-n, --name", "The name of the component").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1272
+ log19.debug("Running `buddy make:component` ...", options);
1273
+ const name = buddy.args[0] || options.name;
1274
+ options.name = name;
1275
+ if (!name) {
1276
+ log19.error("You need to specify a name. Read more about the documentation here.");
1277
+ process19.exit();
1278
+ }
1279
+ await makeComponent(options);
1280
+ });
1281
+ buddy.command("make:database", descriptions.database).option("-n, --name", "The name of the database").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action((options) => {
1282
+ log19.debug("Running `buddy make:database` ...", options);
1283
+ const name = buddy.args[0] || options.name;
1284
+ options.name = name;
1285
+ if (!name) {
1286
+ log19.error("You need to specify a name. Read more about the documentation here.");
1287
+ process19.exit();
1288
+ }
1289
+ makeDatabase(options);
1290
+ });
1291
+ buddy.command("make:factory", descriptions.factory).option("-n, --name", "The name of the factory").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action((options) => {
1292
+ log19.debug("Running `buddy make:factory` ...", options);
1293
+ const name = buddy.args[0] || options.name;
1294
+ options.name = name;
1295
+ if (!name) {
1296
+ log19.error("You need to specify a name. Read more about the documentation here.");
1297
+ process19.exit();
1298
+ }
1299
+ });
1300
+ buddy.command("make:view", descriptions.page).alias("make:page").option("-n, --name", "The name of the page").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1301
+ log19.debug("Running `buddy make:view` ...", options);
1302
+ const name = buddy.args[0] || options.name;
1303
+ options.name = name;
1304
+ if (!name) {
1305
+ log19.error("You need to specify a name. Read more about the documentation here.");
1306
+ process19.exit();
1307
+ }
1308
+ await makePage(options);
1309
+ });
1310
+ buddy.command("make:function", descriptions.function).option("-n, --name", "The name of the function").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1311
+ log19.debug("Running `buddy make:function` ...", options);
1312
+ await makeFunction(options);
1313
+ });
1314
+ buddy.command("make:lang", descriptions.language).option("-n, --name", "The name of the language").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1315
+ log19.debug("Running `buddy make:lang` ...", options);
1316
+ const name = buddy.args[0] || options.name;
1317
+ options.name = name;
1318
+ if (!name) {
1319
+ log19.error("You need to specify a name. Read more about the documentation here.");
1320
+ process19.exit();
1321
+ }
1322
+ await makeLanguage(options);
1323
+ });
1324
+ buddy.command("make:notification", descriptions.notification).option("-n, --name", "The name of the notification").option("-e, --email", "Is it an email notification?", { default: true }).option("-c, --chat", "Is it a chat notification?", { default: false }).option("-s, --sms", "Is it a SMS notification?", { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1325
+ log19.debug("Running `buddy make:notification` ...", options);
1326
+ const perf = await intro12("buddy make:notification");
1327
+ const name = buddy.args[0] || options.name;
1328
+ options.name = name;
1329
+ if (!name) {
1330
+ log19.error("You need to specify a name. Read more about the documentation here.");
1331
+ process19.exit();
1332
+ }
1333
+ const result = await createNotification(options);
1334
+ if (!result) {
1335
+ await outro12("While running the make:notification command, there was an issue", { startTime: perf, useSeconds: true });
1336
+ process19.exit();
1337
+ }
1338
+ await outro12(`Created your ${italic4(name)} notification.`, { startTime: perf, useSeconds: true });
1339
+ process19.exit(ExitCode13.Success);
1340
+ });
1341
+ buddy.command("make:stack", descriptions.stack).option("-n, --name", "The name of the stack").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action((options) => {
1342
+ log19.debug("Running `buddy make:stack` ...", options);
1343
+ const name = buddy.args[0] || options.name;
1344
+ options.name = name;
1345
+ if (!name) {
1346
+ log19.error("You need to specify a name. Read more about the documentation here.");
1347
+ process19.exit();
1348
+ }
1349
+ makeStack(options);
1350
+ });
1351
+ buddy.command("make:model", descriptions.model).option("-n, --name", "The name of the model").action(async (options) => {
1352
+ log19.debug("Running `buddy make:model` ...", options);
1353
+ const name = buddy.args[0] || options.name;
1354
+ options.name = name;
1355
+ if (!name) {
1356
+ log19.error("You need to specify a model name");
1357
+ process19.exit();
1358
+ }
1359
+ await createModel(options);
1360
+ });
1361
+ buddy.command("make:migration", descriptions.migration).option("-n, --name", "The name of the migration").option("-e, --env", "The environment to run the migration in", { default: "dev" }).action((options) => {
1362
+ log19.debug("Running `buddy make:migration` ...", options);
1363
+ const name = buddy.args[0] || options.name;
1364
+ options.name = name;
1365
+ if (!name) {
1366
+ log19.error("You need to specify a migration name");
1367
+ process19.exit();
1368
+ }
1369
+ log19.info(path, name);
1370
+ });
1371
+ buddy.command("make:certificate", descriptions.certificate).alias("make:cert").example("buddy make:certificate").action(async (options) => {
1372
+ log19.debug("Running `buddy make:certificate` ...", options);
1373
+ const domain = await localUrl();
1374
+ log19.info(`Creating SSL certificate...`);
1375
+ await runCommand8(`mkcert ${domain}`, {
1376
+ cwd: p4.projectStoragePath("keys")
1377
+ });
1378
+ log19.success("Certificate created");
1379
+ log19.info(`Installing SSL certificate...`);
1380
+ await runCommand8(`mkcert -install`, {
1381
+ cwd: p4.projectStoragePath("keys")
1382
+ });
1383
+ log19.success("Certificate installed");
1384
+ });
1385
+ buddy.on("make:*", () => {
1386
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1387
+ process19.exit(1);
1388
+ });
1389
+ }
1390
+
1391
+ // src/commands/migrate.ts
1392
+ import process20 from "process";
1393
+ import {ExitCode as ExitCode14} from "@stacksjs/types";
1394
+ import {runAction as runAction12} from "@stacksjs/actions";
1395
+ import {intro as intro13, log as log20, outro as outro13} from "@stacksjs/cli";
1396
+ import {Action as Action11} from "@stacksjs/enums";
1397
+ function migrate(buddy) {
1398
+ const descriptions = {
1399
+ migrate: "Migrates your database",
1400
+ dns: "Writes the DNS records for a domain to ./config/dns.ts",
1401
+ project: "Target a specific project",
1402
+ verbose: "Enable verbose output"
1403
+ };
1404
+ buddy.command("migrate", descriptions.migrate).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1405
+ log20.debug("Running `buddy migrate` ...", options);
1406
+ const perf = await intro13("buddy migrate");
1407
+ const result = await runAction12(Action11.Migrate, { ...options });
1408
+ if (result.isErr()) {
1409
+ await outro13("While running the migrate command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1410
+ process20.exit();
1411
+ }
1412
+ const APP_ENV = process20.env.APP_ENV || "local";
1413
+ await outro13(`Migrated your ${APP_ENV} database.`, { startTime: perf, useSeconds: true });
1414
+ process20.exit(ExitCode14.Success);
1415
+ });
1416
+ buddy.command("migrate:dns", descriptions.migrate).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1417
+ log20.debug("Running `buddy migrate:dns` ...", options);
1418
+ const perf = await intro13("buddy migrate:dns");
1419
+ const result = await runAction12(Action11.MigrateDns, { ...options });
1420
+ if (result.isErr()) {
1421
+ await outro13("While running the migrate:dns command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1422
+ process20.exit();
1423
+ }
1424
+ const APP_URL = process20.env.APP_URL || "undefined";
1425
+ await outro13(`Migrated your ${APP_URL} DNS.`, { startTime: perf, useSeconds: true });
1426
+ process20.exit(ExitCode14.Success);
1427
+ });
1428
+ buddy.on("migrate:*", () => {
1429
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1430
+ process20.exit(1);
1431
+ });
1432
+ }
1433
+
1434
+ // src/commands/ports.ts
1435
+ import process21 from "process";
1436
+ import {ExitCode as ExitCode15} from "@stacksjs/types";
1437
+ import {ports as projectPorts} from "@stacksjs/config";
1438
+ import {log as log21} from "@stacksjs/logging";
1439
+ import {findProjectPath, path as p5, projectPath as projectPath2} from "@stacksjs/path";
1440
+ var {$: $2 } = globalThis.Bun;
1441
+ import {intro as intro14, italic as italic5, outro as outro14} from "@stacksjs/cli";
1442
+ import {findStacksProjects} from "@stacksjs/utils";
1443
+ function ports(buddy) {
1444
+ const descriptions = {
1445
+ command: "Let buddy check your project for potential issues and misconfigurations",
1446
+ ports: "Check if the ports are available",
1447
+ project: "Target a specific project",
1448
+ verbose: "Enable verbose output"
1449
+ };
1450
+ buddy.command("ports", descriptions.command).option("-l, --list", "List the used ports", { default: true }).option("-c, --check", "Check if the ports are available", { default: false }).option("-p, --project [name]", descriptions.project, { default: undefined }).option("-q, --quiet", "Use minimal output", { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1451
+ log21.debug("Running `buddy ports` ...", options);
1452
+ let perf;
1453
+ if (!options.quiet)
1454
+ perf = await intro14("buddy ports");
1455
+ if (options.project) {
1456
+ const path10 = await findProjectPath(options.project);
1457
+ log21.debug(`Path: ${path10}`);
1458
+ const ports2 = await getPortsForProjectPath(path10, options);
1459
+ log21.debug(`./buddy ports --quiet response for ${projectPath2}`, ports2);
1460
+ outputPorts(ports2, options);
1461
+ } else {
1462
+ outputPorts(projectPorts, options);
1463
+ }
1464
+ if (!options.quiet)
1465
+ await outro14("Exited", { startTime: perf, useSeconds: false });
1466
+ process21.exit(ExitCode15.Success);
1467
+ });
1468
+ buddy.command("ports:list", descriptions.ports).option("-p, --project [name]", descriptions.project, { default: undefined }).option("-q, --quiet", "Use minimal output", { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1469
+ log21.debug("Running `buddy ports:list` ...", options);
1470
+ let perf;
1471
+ if (!options.quiet)
1472
+ perf = await intro14("buddy ports:list");
1473
+ if (options.project) {
1474
+ if (!options.quiet)
1475
+ log21.info(`Listing ports for project: ${italic5(options.project)}`);
1476
+ const path10 = await findProjectPath(options.project);
1477
+ log21.debug(`Path: ${path10}`);
1478
+ const ports2 = await getPortsForProjectPath(path10, options);
1479
+ outputPorts(ports2, options);
1480
+ } else {
1481
+ outputPorts(projectPorts, options);
1482
+ }
1483
+ if (!options.quiet)
1484
+ await outro14("Exited", { startTime: perf, useSeconds: false });
1485
+ process21.exit(ExitCode15.Success);
1486
+ });
1487
+ buddy.command("ports:check", descriptions.ports).option("-p, --project [name]", descriptions.project, { default: projectPath2() }).option("-q, --quiet", "Use minimal output", { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1488
+ log21.debug("Running `buddy ports:check` ...", options);
1489
+ let perf;
1490
+ if (!options.quiet)
1491
+ perf = await intro14("buddy ports:check");
1492
+ const projects = await findStacksProjects(undefined, { quiet: true });
1493
+ log21.debug("Running `buddy ports`");
1494
+ log21.debug(`Found ${projects.length} projects`);
1495
+ log21.debug("Projects:", projects);
1496
+ const projectsPorts = {};
1497
+ for (const project of projects)
1498
+ projectsPorts[project] = await getPortsForProjectPath(project, options);
1499
+ log21.info("ProjectsPorts:", projectsPorts);
1500
+ if (!options.quiet)
1501
+ await outro14("Exited", { startTime: perf, useSeconds: false });
1502
+ process21.exit(ExitCode15.Success);
1503
+ });
1504
+ buddy.on("ports:*", () => {
1505
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1506
+ process21.exit(1);
1507
+ });
1508
+ }
1509
+ async function getPortsForProjectPath(path10, options) {
1510
+ if (!options.quiet)
1511
+ log21.info(`Checking ports for project: ${italic5(path10)}`);
1512
+ $2.cwd(path10);
1513
+ $2.env(await import(`${path10}/.env`));
1514
+ const projectList = await $2`./buddy projects:list --quiet`.text();
1515
+ log21.debug("ProjectListResponse", projectList);
1516
+ const projects = projectList.split("\n").filter((line) => line.startsWith(" - ")).map((line) => line.trim().substring(4));
1517
+ log21.debug("Projects:", projects);
1518
+ const ppath = options.project ?? p5.projectPath();
1519
+ let projectPath3 = projects.find((project) => project.includes(ppath));
1520
+ log21.debug(`Checking ports for project: ${projectPath3}`);
1521
+ if (projectPath3 === "" || !projectPath3)
1522
+ projectPath3 = p5.projectPath();
1523
+ log21.debug(`\$ Running: ./buddy ports:list --quiet via ${projectPath3}`);
1524
+ const response = await $2`./buddy ports:list --quiet`.json();
1525
+ log21.debug(`Response for ./buddy ports:list --quiet via ${projectPath3}`, response);
1526
+ let validJsonString = response.replace(/(\w+)(?=\s*:)/g, '"$1"');
1527
+ validJsonString = validJsonString.replace(/,(\s*})/g, "$1");
1528
+ const ports2 = JSON.parse(validJsonString);
1529
+ log21.debug(`Ports for ${projectPath3}`, ports2);
1530
+ return ports2;
1531
+ }
1532
+ var outputPorts = function(ports2, options) {
1533
+ if (!options.quiet)
1534
+ console.log("");
1535
+ console.log(ports2);
1536
+ if (!options.quiet)
1537
+ console.log("");
1538
+ };
1539
+
1540
+ // src/commands/prepublish.ts
1541
+ import process22 from "process";
1542
+ import {Action as Action12} from "@stacksjs/enums";
1543
+ import {runAction as runAction13} from "@stacksjs/actions";
1544
+ import {log as log22} from "@stacksjs/logging";
1545
+ function prepublish(buddy) {
1546
+ const descriptions = {
1547
+ command: "Run your prepublish script",
1548
+ project: "Target a specific project",
1549
+ verbose: "Enable verbose output"
1550
+ };
1551
+ buddy.command("prepublish", descriptions.command).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1552
+ log22.debug("Running `buddy prepublish` ...", options);
1553
+ await runAction13(Action12.Prepublish, options);
1554
+ });
1555
+ buddy.on("prepublish:*", () => {
1556
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1557
+ process22.exit(1);
1558
+ });
1559
+ }
1560
+
1561
+ // src/commands/projects.ts
1562
+ import process23 from "process";
1563
+ import {ExitCode as ExitCode16} from "@stacksjs/types";
1564
+ import {intro as intro15, log as log23} from "@stacksjs/cli";
1565
+ import {findStacksProjects as findStacksProjects2} from "@stacksjs/utils";
1566
+ function projects(buddy) {
1567
+ const descriptions = {
1568
+ projects: "Find all Stacks projects on your system",
1569
+ verbose: "Enable verbose output"
1570
+ };
1571
+ buddy.command("projects", descriptions.projects).option("-q, --quiet", "Use minimal output", { default: false }).option("-l, --list", "List all local Stacks projects", { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1572
+ log23.debug("Running `buddy projects` ...", options);
1573
+ if (!options.quiet)
1574
+ await intro15("buddy projects");
1575
+ const projects2 = await findStacksProjects2(undefined, options);
1576
+ for (const project of projects2)
1577
+ console.log(" - ", project);
1578
+ process23.exit(ExitCode16.Success);
1579
+ });
1580
+ buddy.command("projects:list", descriptions.projects).option("-q, --quiet", "Use minimal output", { default: false }).option("-l, --list", "List all local Stacks projects", { default: true }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1581
+ log23.debug("Running `buddy projects` ...", options);
1582
+ if (!options.quiet)
1583
+ await intro15("buddy projects:list");
1584
+ const projects2 = await findStacksProjects2(undefined, options);
1585
+ for (const project of projects2)
1586
+ console.log(" - ", project);
1587
+ process23.exit(ExitCode16.Success);
1588
+ });
1589
+ buddy.on("projects:*", () => {
1590
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1591
+ process23.exit(1);
1592
+ });
1593
+ }
1594
+
1595
+ // src/commands/release.ts
1596
+ import process24 from "process";
1597
+ import {Action as Action13} from "@stacksjs/enums";
1598
+ import {ExitCode as ExitCode17} from "@stacksjs/types";
1599
+ import {intro as intro16, log as log24, outro as outro15} from "@stacksjs/cli";
1600
+ import {runAction as runAction14} from "@stacksjs/actions";
1601
+ function release(buddy) {
1602
+ buddy.command("release", descriptions.release).option("--dry-run", descriptions.dryRun, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1603
+ log24.debug("Running `buddy release` ...", options);
1604
+ if (options.dryRun)
1605
+ log24.warn("Dry run enabled. No changes will be made or committed.");
1606
+ const startTime = await intro16("buddy release");
1607
+ const result = await runAction14(Action13.Release, {
1608
+ stdin: "inherit",
1609
+ ...options
1610
+ });
1611
+ if (result.isErr()) {
1612
+ log24.error("Failed to release", result.error);
1613
+ process24.exit(ExitCode17.FatalError);
1614
+ }
1615
+ await outro15("Triggered CI/CD Release Workflow", { startTime, useSeconds: true });
1616
+ });
1617
+ buddy.on("release:*", () => {
1618
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1619
+ process24.exit(1);
1620
+ });
1621
+ }
1622
+ var descriptions = {
1623
+ release: "Release a new version of your libraries/packages",
1624
+ project: "Target a specific project",
1625
+ dryRun: "Run the release without actually releasing",
1626
+ verbose: "Enable verbose output"
1627
+ };
1628
+
1629
+ // src/commands/seed.ts
1630
+ import process25 from "process";
1631
+ import {ExitCode as ExitCode18} from "@stacksjs/types";
1632
+ import {runAction as runAction15} from "@stacksjs/actions";
1633
+ import {intro as intro17, log as log25, outro as outro16} from "@stacksjs/cli";
1634
+ import {Action as Action14} from "@stacksjs/enums";
1635
+ function seed(buddy) {
1636
+ const descriptions2 = {
1637
+ seed: "Seed your database",
1638
+ project: "Target a specific project",
1639
+ verbose: "Enable verbose output"
1640
+ };
1641
+ buddy.command("seed", descriptions2.seed).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1642
+ log25.debug("Running `buddy seed` ...", options);
1643
+ const perf = await intro17("buddy seed");
1644
+ const result = await runAction15(Action14.Seed, options);
1645
+ if (result.isErr()) {
1646
+ await outro16("While running the seed command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1647
+ process25.exit(ExitCode18.FatalError);
1648
+ }
1649
+ const APP_ENV = process25.env.APP_ENV || "local";
1650
+ await outro16(`Seeded your ${APP_ENV} database.`, { startTime: perf, useSeconds: true });
1651
+ process25.exit(ExitCode18.Success);
1652
+ });
1653
+ buddy.on("seed:*", () => {
1654
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1655
+ process25.exit(1);
1656
+ });
1657
+ }
1658
+
1659
+ // src/commands/setup.ts
1660
+ import process26 from "process";
1661
+ import {path as p6} from "@stacksjs/path";
1662
+ import {Action as Action15} from "@stacksjs/enums";
1663
+ import {handleError} from "@stacksjs/error-handling";
1664
+ import {storage as storage3} from "@stacksjs/storage";
1665
+ import {log as log26, runCommand as runCommand9} from "@stacksjs/cli";
1666
+ import {ExitCode as ExitCode19} from "@stacksjs/types";
1667
+ function setup(buddy) {
1668
+ const descriptions2 = {
1669
+ setup: "This command ensures your project is setup correctly",
1670
+ ohMyZsh: "Enable Oh My Zsh",
1671
+ aws: "Ensures AWS is connected to the project",
1672
+ project: "Target a specific project",
1673
+ verbose: "Enable verbose output"
1674
+ };
1675
+ buddy.command("setup", descriptions2.setup).alias("ensure").option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1676
+ log26.debug("Running `buddy setup` ...", options);
1677
+ if (!await isPkgxInstalled())
1678
+ await installPkgx();
1679
+ await optimizePkgxDeps();
1680
+ await initializeProject(options);
1681
+ });
1682
+ buddy.command("setup:oh-my-zsh", descriptions2.ohMyZsh).alias("upgrade:oh-my-zsh").option("--verbose", descriptions2.verbose, { default: false }).action(async (_options) => {
1683
+ log26.debug("Running `buddy setup:oh-my-zsh` ...", _options);
1684
+ const result = await runAction(Action15.UpgradeShell);
1685
+ if (result.isErr()) {
1686
+ log26.error(result.error);
1687
+ process26.exit(ExitCode19.FatalError);
1688
+ }
1689
+ });
1690
+ buddy.on("setup:*", () => {
1691
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1692
+ process26.exit(ExitCode19.FatalError);
1693
+ });
1694
+ }
1695
+ async function isPkgxInstalled() {
1696
+ const result = await runCommand9("pkgx --version", { silent: true });
1697
+ if (result.isOk())
1698
+ return true;
1699
+ return false;
1700
+ }
1701
+ async function installPkgx() {
1702
+ const result = await runCommand9(p6.frameworkPath("scripts/pkgx-install"));
1703
+ if (result.isOk())
1704
+ return;
1705
+ handleError(result.error);
1706
+ process26.exit(ExitCode19.FatalError);
1707
+ }
1708
+ async function initializeProject(options) {
1709
+ log26.info("Installing dependencies...");
1710
+ const result = await runCommand9("bun install", {
1711
+ cwd: options.cwd || p6.projectPath()
1712
+ });
1713
+ if (result.isErr()) {
1714
+ handleError(result.error);
1715
+ process26.exit(ExitCode19.FatalError);
1716
+ }
1717
+ log26.success("Installed node_modules");
1718
+ ensureEnvIsSet(options);
1719
+ const keyResult = await runCommand9("buddy key:generate", {
1720
+ cwd: options.cwd || p6.projectPath()
1721
+ });
1722
+ if (keyResult.isErr()) {
1723
+ handleError(keyResult.error);
1724
+ process26.exit(ExitCode19.FatalError);
1725
+ }
1726
+ log26.info("Ensuring AWS is connected...");
1727
+ const awsResult = await runCommand9("buddy configure:aws", {
1728
+ cwd: options.cwd || p6.projectPath()
1729
+ });
1730
+ if (awsResult.isErr()) {
1731
+ handleError(awsResult.error);
1732
+ process26.exit(ExitCode19.FatalError);
1733
+ }
1734
+ log26.success("Configured AWS");
1735
+ log26.success("Project is setup");
1736
+ log26.info("Happy coding! \uD83D\uDC99");
1737
+ }
1738
+ async function optimizePkgxDeps() {
1739
+ return new Promise((resolve2) => setTimeout(resolve2, 300));
1740
+ }
1741
+ async function ensureEnvIsSet(options) {
1742
+ log26.info("Ensuring .env exists...");
1743
+ if (storage3.doesNotExist(p6.projectPath(".env"))) {
1744
+ const envResult = await runCommand9("cp .env.example .env", {
1745
+ cwd: options.cwd || p6.projectPath()
1746
+ });
1747
+ if (envResult.isErr()) {
1748
+ handleError(envResult.error);
1749
+ process26.exit(ExitCode19.FatalError);
1750
+ }
1751
+ log26.success(".env created");
1752
+ } else {
1753
+ log26.success(".env existed");
1754
+ }
1755
+ }
1756
+
1757
+ // src/commands/test.ts
1758
+ import process27 from "process";
1759
+ import {runAction as runAction16} from "@stacksjs/actions";
1760
+ import {intro as intro18, outro as outro17} from "@stacksjs/cli";
1761
+ import {projectPath as projectPath3} from "@stacksjs/path";
1762
+ import {Action as Action16} from "@stacksjs/enums";
1763
+ function test(buddy) {
1764
+ const descriptions2 = {
1765
+ command: "Runs your test suite",
1766
+ types: "Typechecks your codebase",
1767
+ coverage: "Generates a test coverage report",
1768
+ ui: "Runs your test suite in the browser",
1769
+ unit: "Runs your unit tests",
1770
+ feature: "Runs your feature tests",
1771
+ showReport: "Show the test report",
1772
+ project: "Target a specific project",
1773
+ verbose: "Enable verbose output"
1774
+ };
1775
+ buddy.command("test", descriptions2.command).option("--ui", descriptions2.ui, { default: false }).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: true }).action(async (options) => {
1776
+ const perf = await intro18("buddy test");
1777
+ const result = await runAction16(Action16.Test, { ...options, cwd: projectPath3() });
1778
+ if (result.isErr()) {
1779
+ await outro17("While running `buddy test`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1780
+ process27.exit();
1781
+ }
1782
+ await outro17("Finished running tests", { startTime: perf, useSeconds: true });
1783
+ });
1784
+ buddy.command("test:unit", descriptions2.unit).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1785
+ const perf = await intro18("buddy test:unit");
1786
+ const result = await runAction16(Action16.TestUnit, { ...options, verbose: true, cwd: projectPath3() });
1787
+ if (result.isErr()) {
1788
+ await outro17("While running `buddy test:unit`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1789
+ process27.exit();
1790
+ }
1791
+ await outro17("Finished running unit tests", { startTime: perf, useSeconds: true });
1792
+ });
1793
+ buddy.command("test:feature", descriptions2.feature).option("--show-report", descriptions2.showReport, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1794
+ const perf = await intro18("buddy test:feature");
1795
+ let result;
1796
+ if (options.showReport)
1797
+ result = await runAction16(Action16.ShowFeatureTestReport, { ...options, verbose: true, cwd: projectPath3() });
1798
+ else
1799
+ result = await runAction16(Action16.TestFeature, { ...options, verbose: true, cwd: projectPath3() });
1800
+ if (result.isErr()) {
1801
+ await outro17("While running `buddy test:feature`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1802
+ process27.exit();
1803
+ }
1804
+ await outro17("Finished running feature tests", { startTime: perf, useSeconds: true });
1805
+ });
1806
+ buddy.command("test:ui", descriptions2.command).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1807
+ const perf = await intro18("buddy test:ui");
1808
+ const result = await runAction16(Action16.TestUi, { ...options, verbose: true, cwd: projectPath3() });
1809
+ if (result.isErr()) {
1810
+ await outro17("While running `buddy test:ui`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1811
+ process27.exit();
1812
+ }
1813
+ await outro17("Finished running tests in the browser", { startTime: perf, useSeconds: true });
1814
+ });
1815
+ buddy.command("test:types", descriptions2.types).alias("typecheck").option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1816
+ const perf = await intro18("buddy test:types");
1817
+ const result = await runAction16(Action16.Typecheck, { ...options, verbose: true, cwd: projectPath3() });
1818
+ if (result.isErr()) {
1819
+ await outro17("While running `buddy test:types`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1820
+ process27.exit();
1821
+ }
1822
+ await outro17("Finished running typecheck", { startTime: perf, useSeconds: true });
1823
+ });
1824
+ buddy.command("test:coverage", descriptions2.coverage).action(async (options) => {
1825
+ const perf = await intro18("buddy test:coverage");
1826
+ const result = await runAction16(Action16.TestCoverage, { ...options, cwd: projectPath3(), verbose: true });
1827
+ if (result.isErr()) {
1828
+ await outro17("While running `buddy test:coverage`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1829
+ process27.exit();
1830
+ }
1831
+ await outro17("Generated the test coverage report", { startTime: perf, useSeconds: true });
1832
+ process27.exit();
1833
+ });
1834
+ buddy.on("test:*", () => {
1835
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1836
+ process27.exit(1);
1837
+ });
1838
+ }
1839
+
1840
+ // src/commands/tinker.ts
1841
+ import process28 from "process";
1842
+ import {ExitCode as ExitCode20} from "@stacksjs/types";
1843
+ import {runAction as runAction17} from "@stacksjs/actions";
1844
+ import {intro as intro19, log as log27, outro as outro18} from "@stacksjs/cli";
1845
+ import {Action as Action17} from "@stacksjs/enums";
1846
+ function tinker(buddy) {
1847
+ const descriptions2 = {
1848
+ tinker: "Tinker with your code",
1849
+ project: "Target a specific project",
1850
+ verbose: "Enable verbose output"
1851
+ };
1852
+ buddy.command("tinker", descriptions2.tinker).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1853
+ log27.debug("Running `buddy tinker` ...", options);
1854
+ const perf = await intro19("buddy tinker");
1855
+ const result = await runAction17(Action17.Tinker, options);
1856
+ if (result.isErr()) {
1857
+ await outro18("While running the tinker command, there was an issue", { startTime: perf, useSeconds: true }, result.error || undefined);
1858
+ process28.exit();
1859
+ }
1860
+ await outro18("Tinker mode exited.", { startTime: perf, useSeconds: true });
1861
+ process28.exit(ExitCode20.Success);
1862
+ });
1863
+ buddy.on("tinker:*", () => {
1864
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1865
+ process28.exit(1);
1866
+ });
1867
+ }
1868
+
1869
+ // src/commands/types.ts
1870
+ import process29 from "process";
1871
+ import {generateTypes as generateTypes2} from "@stacksjs/actions";
1872
+ import {log as log28} from "@stacksjs/logging";
1873
+ function types21(buddy) {
1874
+ const descriptions2 = {
1875
+ generate: "Generate the types of & for your library/libraries",
1876
+ fix: "wip",
1877
+ project: "Target a specific project",
1878
+ verbose: "Enable verbose output"
1879
+ };
1880
+ buddy.command("types:generate", descriptions2.generate).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1881
+ log28.debug("Running `buddy types:generate` ...", options);
1882
+ await generateTypes2();
1883
+ });
1884
+ buddy.command("types:fix", descriptions2.fix).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async () => {
1885
+ });
1886
+ buddy.on("types:*", () => {
1887
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1888
+ process29.exit(1);
1889
+ });
1890
+ }
1891
+
1892
+ // src/commands/upgrade.ts
1893
+ import process30 from "process";
1894
+ import {runAction as runAction18} from "@stacksjs/actions";
1895
+ import {intro as intro20, log as log29, outro as outro19} from "@stacksjs/cli";
1896
+ import {ExitCode as ExitCode21} from "@stacksjs/types";
1897
+ import {Action as Action18} from "@stacksjs/enums";
1898
+ function upgrade(buddy) {
1899
+ const descriptions2 = {
1900
+ command: "Upgrade dependencies, framework, package manager, JS/TS runtime",
1901
+ framework: "Upgrade the Stacks framework",
1902
+ dependencies: "Upgrade your dependencies (pkgx.yaml & package.json)",
1903
+ bun: "Upgrade Bun to the latest version",
1904
+ shell: "Upgrade the to the latest shell integration (currently only supports Oh My Zsh)",
1905
+ binary: "Upgrade the `stacks` binary to the latest version. Please note, the binary is moved to the `~/.stacks/bin` directory",
1906
+ all: "Upgrade Node, package manager, project dependencies, and framework",
1907
+ force: "Overwrite possible local updates with remote framework updates",
1908
+ select: "What are you trying to upgrade?",
1909
+ project: "Target a specific project",
1910
+ verbose: "Enable verbose output"
1911
+ };
1912
+ buddy.command("upgrade", descriptions2.command).option("-d, --dependencies", descriptions2.dependencies, { default: false }).option("-b, --bun", descriptions2.bun, { default: false }).option("-a, --all", descriptions2.all, { default: false }).option("-f, --force", descriptions2.force, { default: false }).option("--framework", descriptions2.framework, { default: false }).option("-p, --project", descriptions2.project, { default: false }).option("-s, --shell", descriptions2.shell, { default: false }).option("-b, --binary", descriptions2.binary, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).alias("update").example("buddy upgrade -a --verbose").action(async (options) => {
1913
+ log29.debug("Running `buddy upgrade` ...", options);
1914
+ const perf = await intro20("buddy upgrade");
1915
+ if (hasNoOptions2(options)) {
1916
+ let answers = await log29.prompt.require().multiselect(descriptions2.select, {
1917
+ options: [
1918
+ { value: "dependencies", label: "Dependencies" },
1919
+ { value: "framework", label: "Framework" },
1920
+ { value: "bun", label: "Bun" },
1921
+ { value: "shell", label: "Shell" },
1922
+ { value: "binary", label: "Binary" }
1923
+ ]
1924
+ });
1925
+ if (answers !== null)
1926
+ process30.exit(ExitCode21.InvalidArgument);
1927
+ if (isString(answers))
1928
+ answers = [answers];
1929
+ options = answers.reduce((a, v) => ({ ...a, [v]: true }), {});
1930
+ }
1931
+ const result = await runAction18(Action18.Upgrade, options);
1932
+ if (result.isErr()) {
1933
+ await outro19("While running the buddy:upgrade command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1934
+ process30.exit();
1935
+ }
1936
+ await outro19("Upgrade complete.", { startTime: perf, useSeconds: true });
1937
+ process30.exit();
1938
+ });
1939
+ buddy.command("upgrade:framework", descriptions2.framework).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).example("buddy upgrade:framework --verbose").action(async (options) => {
1940
+ log29.debug("Running `buddy upgrade:framework` ...", options);
1941
+ await runAction18(Action18.Upgrade, options);
1942
+ });
1943
+ buddy.command("upgrade:dependencies", descriptions2.dependencies).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).alias("upgrade:deps").example("buddy upgrade:dependencies --verbose").action(async (options) => {
1944
+ log29.debug("Running `buddy upgrade:dependencies` ...", options);
1945
+ await runAction18(Action18.Upgrade, options);
1946
+ });
1947
+ buddy.command("upgrade:bun", descriptions2.bun).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1948
+ log29.debug("Running `buddy upgrade:bun` ...", options);
1949
+ const perf = await intro20("buddy upgrade:bun");
1950
+ const result = await runAction18(Action18.UpgradeBun, options);
1951
+ if (result.isErr()) {
1952
+ await outro19("While running the buddy upgrade:bun command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1953
+ process30.exit();
1954
+ }
1955
+ process30.exit(ExitCode21.Success);
1956
+ });
1957
+ buddy.command("upgrade:all", descriptions2.all).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1958
+ log29.debug("Running `buddy upgrade:all` ...", options);
1959
+ await runAction18(Action18.Upgrade, options);
1960
+ });
1961
+ buddy.command("upgrade:shell", descriptions2.shell).option("--verbose", descriptions2.verbose, { default: false }).example("buddy upgrade:shell").action(async (options) => {
1962
+ log29.debug("Running `buddy upgrade:shell` ...", options);
1963
+ const perf = await intro20("buddy upgrade:shell");
1964
+ const result = await runAction18(Action18.UpgradeShell, options);
1965
+ if (result.isErr()) {
1966
+ await outro19("While running the buddy upgrade:shell command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1967
+ process30.exit();
1968
+ }
1969
+ process30.exit(ExitCode21.Success);
1970
+ });
1971
+ buddy.command("upgrade:binary", descriptions2.binary).option("--verbose", descriptions2.verbose, { default: false }).example("buddy upgrade:binary").action(async (options) => {
1972
+ if (process30.getuid && process30.getuid() !== 0) {
1973
+ log29.warn("To upgrade the binary, you need to run this command with sudo, or as root.");
1974
+ process30.exit(0);
1975
+ }
1976
+ log29.debug("Running `buddy upgrade:binary` ...", options);
1977
+ const perf = await intro20("buddy upgrade:binary");
1978
+ const result = await runAction18(Action18.UpgradeBinary, options);
1979
+ if (result.isErr()) {
1980
+ await outro19("While running the buddy upgrade:binary command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1981
+ process30.exit();
1982
+ }
1983
+ process30.exit(ExitCode21.Success);
1984
+ });
1985
+ buddy.on("upgrade:*", () => {
1986
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1987
+ process30.exit(1);
1988
+ });
1989
+ }
1990
+ var hasNoOptions2 = function(options) {
1991
+ return !options.framework && !options.dependencies && !options.bun && !options.shell && !options.binary && !options.all;
1992
+ };
1993
+
1994
+ // src/commands/version.ts
1995
+ import process31 from "process";
1996
+ import {bold as bold3, dim as dim2, green, intro as intro21, log as log30} from "@stacksjs/cli";
1997
+ import {storage as storage5} from "@stacksjs/storage";
1998
+ function version(buddy) {
1999
+ const descriptions2 = {
2000
+ version: "Retrieving Stacks build version"
2001
+ };
2002
+ buddy.command("version", descriptions2.version).action(async () => {
2003
+ log30.debug("Running `buddy version` ...");
2004
+ await intro21("buddy version");
2005
+ const pkg = await storage5.readPackageJson("./package.json");
2006
+ const bunVersion = "wip";
2007
+ const stacksVersion = pkg.version;
2008
+ log30.info(green(bold3("@stacksjs/ ")) + dim2(` ${stacksVersion}`));
2009
+ log30.info(green(bold3("Bun: ")) + dim2(` ${bunVersion}`));
2010
+ });
2011
+ buddy.on("version:*", () => {
2012
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
2013
+ process31.exit(1);
2014
+ });
2015
+ }
2016
+ export { build, changelog, clean, cloud2 as cloud, commit, configure, create, deploy, dev, startDevelopmentServer, domains, dns3 as dns, fresh, generate, http, lint, list, install2 as install, key, make, migrate, ports, prepublish, projects, release, seed, setup, optimizePkgxDeps, ensureEnvIsSet, test, tinker, types21 as types, upgrade, version };