@stacksjs/buddy 0.58.51 → 0.58.52

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.
@@ -18,11 +18,13 @@ function build(buddy) {
18
18
  pages: "Build your frontend",
19
19
  docs: "Build your documentation",
20
20
  framework: "Build Stacks framework",
21
+ cli: "Automagically build the CLI",
22
+ server: "Build the Stacks cloud server (Docker image)",
21
23
  select: "What are you trying to build?",
22
24
  project: "Target a specific project",
23
25
  verbose: "Enable verbose output"
24
26
  };
25
- 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("--verbose", descriptions.verbose, { default: false }).action(async (server, options) => {
27
+ 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) => {
26
28
  switch (server) {
27
29
  case "components":
28
30
  options.components = true;
@@ -51,6 +53,9 @@ function build(buddy) {
51
53
  case "stacks":
52
54
  options.stacks = true;
53
55
  break;
56
+ case "server":
57
+ options.stacks = true;
58
+ break;
54
59
  default:
55
60
  break;
56
61
  }
@@ -76,9 +81,12 @@ function build(buddy) {
76
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) => {
77
82
  await runAction(Action.BuildComponentLibs, options);
78
83
  });
79
- buddy.command("build:cli", "Automagically build the 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) => {
84
+ 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) => {
80
85
  await runAction(Action.BuildCli, options);
81
86
  });
87
+ 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) => {
88
+ await runAction(Action.BuildServer, options);
89
+ });
82
90
  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) => {
83
91
  await runAction(Action.BuildFunctionLib, options);
84
92
  });
@@ -589,10 +597,9 @@ function deploy(buddy) {
589
597
  process8.exit(ExitCode7.FatalError);
590
598
  }
591
599
  if (await hasUserDomainBeenAddedToCloud(domain)) {
592
- log6.success("Your domain is properly configured.");
600
+ log6.info("Domain is properly configured");
593
601
  log6.info("Your cloud is deploying...");
594
602
  log6.info(`${italic2("This may take a while...")}`);
595
- await new Promise((resolve2) => setTimeout(resolve2, 2000));
596
603
  options.domain = domain;
597
604
  const result2 = await runAction5(Action5.Deploy, options);
598
605
  if (result2.isErr()) {
@@ -1103,8 +1110,35 @@ function lint(buddy) {
1103
1110
  });
1104
1111
  }
1105
1112
 
1106
- // src/commands/inspire.ts
1113
+ // src/commands/list.ts
1107
1114
  import process17 from "process";
1115
+ var {$ } = globalThis.Bun;
1116
+ import {projectPath} from "@stacksjs/path";
1117
+ function list(buddy) {
1118
+ const descriptions = {
1119
+ list: "List all of the project-specific Buddy commands",
1120
+ project: "Target a specific project",
1121
+ verbose: "Enable verbose output"
1122
+ };
1123
+ buddy.command("list", descriptions.list).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async () => {
1124
+ $.cwd(projectPath());
1125
+ const test = await $`buddy --help`.text();
1126
+ const commandsSection = test.match(/Commands:.*?(?=For more info, run any command with the)/s)?.[0];
1127
+ if (commandsSection) {
1128
+ const cleanedCommands = commandsSection.replace("Commands:", "").replace(/^\s+/gm, "");
1129
+ console.log(cleanedCommands);
1130
+ return;
1131
+ }
1132
+ console.error("#1 - Please reach out to our Discord for helper: https://discord.gg/stacksjs");
1133
+ });
1134
+ buddy.on("list:*", () => {
1135
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1136
+ process17.exit(1);
1137
+ });
1138
+ }
1139
+
1140
+ // src/commands/inspire.ts
1141
+ import process18 from "process";
1108
1142
  import {ExitCode as ExitCode15} from "@stacksjs/types";
1109
1143
  import {runAction as runAction10} from "@stacksjs/actions";
1110
1144
  import {intro as intro11, outro as outro11} from "@stacksjs/cli";
@@ -1115,15 +1149,15 @@ function inspire(buddy) {
1115
1149
  const result = await runAction10(Action10.Inspire);
1116
1150
  if (result.isErr()) {
1117
1151
  await outro11("While running the inspire command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1118
- process17.exit();
1152
+ process18.exit();
1119
1153
  }
1120
1154
  await outro11("Your quote is: ...", { startTime: perf, useSeconds: true });
1121
- process17.exit(ExitCode15.Success);
1155
+ process18.exit(ExitCode15.Success);
1122
1156
  });
1123
1157
  }
1124
1158
 
1125
1159
  // src/commands/install.ts
1126
- import process18 from "process";
1160
+ import process19 from "process";
1127
1161
  import {runCommand as runCommand6} from "@stacksjs/cli";
1128
1162
  import {path as p3} from "@stacksjs/path";
1129
1163
  function install2(buddy) {
@@ -1140,12 +1174,12 @@ function install2(buddy) {
1140
1174
  });
1141
1175
  buddy.on("install:*", () => {
1142
1176
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1143
- process18.exit(1);
1177
+ process19.exit(1);
1144
1178
  });
1145
1179
  }
1146
1180
 
1147
1181
  // src/commands/key.ts
1148
- import process19 from "process";
1182
+ import process20 from "process";
1149
1183
  import {intro as intro12, log as log9, outro as outro12} from "@stacksjs/cli";
1150
1184
  import {Action as Action11} from "@stacksjs/enums";
1151
1185
  import {runAction as runAction11} from "@stacksjs/actions";
@@ -1160,18 +1194,18 @@ function key(buddy) {
1160
1194
  const result = await runAction11(Action11.KeyGenerate, options);
1161
1195
  if (result.isErr()) {
1162
1196
  log9.error("Failed to set random application key.", result.error);
1163
- process19.exit();
1197
+ process20.exit();
1164
1198
  }
1165
1199
  await outro12("Random application key set.");
1166
1200
  });
1167
1201
  buddy.on("key:*", () => {
1168
1202
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1169
- process19.exit(1);
1203
+ process20.exit(1);
1170
1204
  });
1171
1205
  }
1172
1206
 
1173
1207
  // src/commands/make.ts
1174
- import process20 from "process";
1208
+ import process21 from "process";
1175
1209
  import {
1176
1210
  createModel,
1177
1211
  createNotification,
@@ -1207,7 +1241,7 @@ function make(buddy) {
1207
1241
  const name = buddy.args[0];
1208
1242
  if (!name) {
1209
1243
  log10.error("You need to specify a name. Read more about the documentation here.");
1210
- process20.exit();
1244
+ process21.exit();
1211
1245
  }
1212
1246
  if (hasNoOptions3(options)) {
1213
1247
  let answers = await prompt4.require().multiselect(descriptions.select, {
@@ -1224,20 +1258,20 @@ function make(buddy) {
1224
1258
  ]
1225
1259
  });
1226
1260
  if (answers !== null)
1227
- process20.exit(ExitCode16.InvalidArgument);
1261
+ process21.exit(ExitCode16.InvalidArgument);
1228
1262
  if (isString3(answers))
1229
1263
  answers = [answers];
1230
1264
  options = answers.reduce((a, v) => ({ ...a, [v]: true }), {});
1231
1265
  }
1232
1266
  await invoke(options);
1233
- process20.exit(ExitCode16.Success);
1267
+ process21.exit(ExitCode16.Success);
1234
1268
  });
1235
1269
  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) => {
1236
1270
  const name = buddy.args[0] || options.name;
1237
1271
  options.name = name;
1238
1272
  if (!name) {
1239
1273
  log10.error("You need to specify a name. Read more about the documentation here.");
1240
- process20.exit();
1274
+ process21.exit();
1241
1275
  }
1242
1276
  await makeComponent(options);
1243
1277
  });
@@ -1246,7 +1280,7 @@ function make(buddy) {
1246
1280
  options.name = name;
1247
1281
  if (!name) {
1248
1282
  log10.error("You need to specify a name. Read more about the documentation here.");
1249
- process20.exit();
1283
+ process21.exit();
1250
1284
  }
1251
1285
  makeDatabase(options);
1252
1286
  });
@@ -1255,7 +1289,7 @@ function make(buddy) {
1255
1289
  options.name = name;
1256
1290
  if (!name) {
1257
1291
  log10.error("You need to specify a name. Read more about the documentation here.");
1258
- process20.exit();
1292
+ process21.exit();
1259
1293
  }
1260
1294
  });
1261
1295
  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) => {
@@ -1263,7 +1297,7 @@ function make(buddy) {
1263
1297
  options.name = name;
1264
1298
  if (!name) {
1265
1299
  log10.error("You need to specify a name. Read more about the documentation here.");
1266
- process20.exit();
1300
+ process21.exit();
1267
1301
  }
1268
1302
  await makePage(options);
1269
1303
  });
@@ -1275,7 +1309,7 @@ function make(buddy) {
1275
1309
  options.name = name;
1276
1310
  if (!name) {
1277
1311
  log10.error("You need to specify a name. Read more about the documentation here.");
1278
- process20.exit();
1312
+ process21.exit();
1279
1313
  }
1280
1314
  await makeLanguage(options);
1281
1315
  });
@@ -1285,22 +1319,22 @@ function make(buddy) {
1285
1319
  options.name = name;
1286
1320
  if (!name) {
1287
1321
  log10.error("You need to specify a name. Read more about the documentation here.");
1288
- process20.exit();
1322
+ process21.exit();
1289
1323
  }
1290
1324
  const result = await createNotification(options);
1291
1325
  if (!result) {
1292
1326
  await outro13("While running the make:notification command, there was an issue", { startTime: perf, useSeconds: true });
1293
- process20.exit();
1327
+ process21.exit();
1294
1328
  }
1295
1329
  await outro13(`Created your ${italic4(name)} notification.`, { startTime: perf, useSeconds: true });
1296
- process20.exit(ExitCode16.Success);
1330
+ process21.exit(ExitCode16.Success);
1297
1331
  });
1298
1332
  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) => {
1299
1333
  const name = buddy.args[0] || options.name;
1300
1334
  options.name = name;
1301
1335
  if (!name) {
1302
1336
  log10.error("You need to specify a name. Read more about the documentation here.");
1303
- process20.exit();
1337
+ process21.exit();
1304
1338
  }
1305
1339
  makeStack(options);
1306
1340
  });
@@ -1309,7 +1343,7 @@ function make(buddy) {
1309
1343
  options.name = name;
1310
1344
  if (!name) {
1311
1345
  log10.error("You need to specify a model name");
1312
- process20.exit();
1346
+ process21.exit();
1313
1347
  }
1314
1348
  await createModel(options);
1315
1349
  });
@@ -1318,13 +1352,13 @@ function make(buddy) {
1318
1352
  options.name = name;
1319
1353
  if (!name) {
1320
1354
  log10.error("You need to specify a migration name");
1321
- process20.exit();
1355
+ process21.exit();
1322
1356
  }
1323
1357
  log10.info(path, name);
1324
1358
  });
1325
1359
  buddy.on("make:*", () => {
1326
1360
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1327
- process20.exit(1);
1361
+ process21.exit(1);
1328
1362
  });
1329
1363
  }
1330
1364
  var hasNoOptions3 = function(options) {
@@ -1332,7 +1366,7 @@ var hasNoOptions3 = function(options) {
1332
1366
  };
1333
1367
 
1334
1368
  // src/commands/migrate.ts
1335
- import process21 from "process";
1369
+ import process22 from "process";
1336
1370
  import {ExitCode as ExitCode17} from "@stacksjs/types";
1337
1371
  import {runAction as runAction12} from "@stacksjs/actions";
1338
1372
  import {intro as intro14, outro as outro14} from "@stacksjs/cli";
@@ -1349,31 +1383,31 @@ function migrate(buddy) {
1349
1383
  const result = await runAction12(Action12.Migrate, { ...options });
1350
1384
  if (result.isErr()) {
1351
1385
  await outro14("While running the migrate command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1352
- process21.exit();
1386
+ process22.exit();
1353
1387
  }
1354
- const APP_ENV = process21.env.APP_ENV || "local";
1388
+ const APP_ENV = process22.env.APP_ENV || "local";
1355
1389
  await outro14(`Migrated your ${APP_ENV} database.`, { startTime: perf, useSeconds: true });
1356
- process21.exit(ExitCode17.Success);
1390
+ process22.exit(ExitCode17.Success);
1357
1391
  });
1358
1392
  buddy.command("migrate:dns", descriptions.migrate).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
1359
1393
  const perf = await intro14("buddy migrate");
1360
1394
  const result = await runAction12(Action12.MigrateDns, { ...options });
1361
1395
  if (result.isErr()) {
1362
1396
  await outro14("While running the migrate:dns command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1363
- process21.exit();
1397
+ process22.exit();
1364
1398
  }
1365
- const APP_URL = process21.env.APP_URL || "undefined";
1399
+ const APP_URL = process22.env.APP_URL || "undefined";
1366
1400
  await outro14(`Migrated your ${APP_URL} DNS.`, { startTime: perf, useSeconds: true });
1367
- process21.exit(ExitCode17.Success);
1401
+ process22.exit(ExitCode17.Success);
1368
1402
  });
1369
1403
  buddy.on("migrate:*", () => {
1370
1404
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1371
- process21.exit(1);
1405
+ process22.exit(1);
1372
1406
  });
1373
1407
  }
1374
1408
 
1375
1409
  // src/commands/prepublish.ts
1376
- import process22 from "process";
1410
+ import process23 from "process";
1377
1411
  import {Action as Action13} from "@stacksjs/enums";
1378
1412
  import {runAction as runAction13} from "@stacksjs/actions";
1379
1413
  function prepublish(buddy) {
@@ -1387,12 +1421,12 @@ function prepublish(buddy) {
1387
1421
  });
1388
1422
  buddy.on("prepublish:*", () => {
1389
1423
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1390
- process22.exit(1);
1424
+ process23.exit(1);
1391
1425
  });
1392
1426
  }
1393
1427
 
1394
1428
  // src/commands/release.ts
1395
- import process23 from "process";
1429
+ import process24 from "process";
1396
1430
  import {Action as Action14} from "@stacksjs/enums";
1397
1431
  import {ExitCode as ExitCode18} from "@stacksjs/types";
1398
1432
  import {intro as intro15, log as log11, outro as outro15} from "@stacksjs/cli";
@@ -1403,13 +1437,13 @@ function release(buddy) {
1403
1437
  const result = await runAction14(Action14.Release, { ...options, stdin: "inherit" });
1404
1438
  if (result.isErr()) {
1405
1439
  log11.error("Failed to release", result.error);
1406
- process23.exit(ExitCode18.FatalError);
1440
+ process24.exit(ExitCode18.FatalError);
1407
1441
  }
1408
1442
  await outro15("Triggered your CI/CD release workflow", { startTime, useSeconds: true });
1409
1443
  });
1410
1444
  buddy.on("release:*", () => {
1411
1445
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1412
- process23.exit(1);
1446
+ process24.exit(1);
1413
1447
  });
1414
1448
  }
1415
1449
  var descriptions = {
@@ -1419,7 +1453,7 @@ var descriptions = {
1419
1453
  };
1420
1454
 
1421
1455
  // src/commands/seed.ts
1422
- import process24 from "process";
1456
+ import process25 from "process";
1423
1457
  import {ExitCode as ExitCode19} from "@stacksjs/types";
1424
1458
  import {runAction as runAction15} from "@stacksjs/actions";
1425
1459
  import {intro as intro16, outro as outro16} from "@stacksjs/cli";
@@ -1435,28 +1469,31 @@ function seed(buddy) {
1435
1469
  const result = await runAction15(Action15.Seed, options);
1436
1470
  if (result.isErr()) {
1437
1471
  await outro16("While running the seed command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1438
- process24.exit(ExitCode19.FatalError);
1472
+ process25.exit(ExitCode19.FatalError);
1439
1473
  }
1440
- const APP_ENV = process24.env.APP_ENV || "local";
1474
+ const APP_ENV = process25.env.APP_ENV || "local";
1441
1475
  await outro16(`Seeded your ${APP_ENV} database.`, { startTime: perf, useSeconds: true });
1442
- process24.exit(ExitCode19.Success);
1476
+ process25.exit(ExitCode19.Success);
1443
1477
  });
1444
1478
  buddy.on("seed:*", () => {
1445
1479
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1446
- process24.exit(1);
1480
+ process25.exit(1);
1447
1481
  });
1448
1482
  }
1449
1483
 
1450
1484
  // src/commands/setup.ts
1451
- import process25 from "process";
1485
+ import process26 from "process";
1452
1486
  import {path as p4} from "@stacksjs/path";
1453
1487
  import {handleError} from "@stacksjs/error-handling";
1454
- import {storage as storage3} from "@stacksjs/storage";
1488
+ import {writeFile} from "@stacksjs/storage";
1455
1489
  import {log as log12, runCommand as runCommand7} from "@stacksjs/cli";
1456
1490
  import {ExitCode as ExitCode20} from "@stacksjs/types";
1491
+ var {$: $2 } = globalThis.Bun;
1457
1492
  function setup(buddy) {
1458
1493
  const descriptions2 = {
1459
1494
  setup: "This command ensures your project is setup correctly",
1495
+ ohMyZsh: "Enable Oh My Zsh",
1496
+ aws: "Ensures AWS is connected to the project",
1460
1497
  project: "Target a specific project",
1461
1498
  verbose: "Enable verbose output"
1462
1499
  };
@@ -1466,9 +1503,40 @@ function setup(buddy) {
1466
1503
  await optimizePkgxDeps();
1467
1504
  await initializeProject(options);
1468
1505
  });
1506
+ buddy.command("setup:oh-my-zsh", descriptions2.ohMyZsh).option("--verbose", descriptions2.verbose, { default: false }).action(async (_options) => {
1507
+ const homePath = (await $2`echo $HOME`.text()).trim();
1508
+ const zshrcPath = p4.join(homePath, ".zshrc");
1509
+ const pluginPath = p4.frameworkPath("core/zsh-buddy/buddy.plugin.zsh");
1510
+ const customPath = p4.join(homePath, ".oh-my-zsh/custom/plugins/buddy/");
1511
+ log12.info(`Setting up Oh My Zsh via ${zshrcPath}...`);
1512
+ $2.cwd(p4.dirname(zshrcPath));
1513
+ let data = await $2`cat ${p4.basename(zshrcPath)}`.text();
1514
+ const pluginLineRegex = /^(?!#).*plugins=\(([^)]+)\)/m;
1515
+ const match = data.match(pluginLineRegex);
1516
+ if (match) {
1517
+ const plugins = match[1].split(" ");
1518
+ if (!plugins.includes("buddy")) {
1519
+ plugins.push("buddy");
1520
+ const newPluginLine = `plugins=(${plugins.join(" ")})`;
1521
+ data = data.replace(pluginLineRegex, newPluginLine);
1522
+ await writeFile(zshrcPath, data);
1523
+ log12.info(`Copying buddy zsh plugin ${pluginPath} to ${customPath}...`);
1524
+ await runCommand7(`mkdir -p ${customPath}`);
1525
+ await runCommand7(`cp -rf ${pluginPath} ${customPath}`);
1526
+ log12.success("Copied buddy zsh plugin");
1527
+ } else {
1528
+ log12.info("buddy is already integrated in your shell, updating...");
1529
+ await runCommand7(`cp -rf ${pluginPath} ${customPath}`);
1530
+ log12.success("Updated buddy zsh plugin");
1531
+ }
1532
+ }
1533
+ log12.success("Oh My Zsh setup complete.");
1534
+ log12.info("To see changes reflect, you may need to:");
1535
+ log12.info("\u2318\u21E7P workbench.action.reloadWindow");
1536
+ });
1469
1537
  buddy.on("setup:*", () => {
1470
1538
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1471
- process25.exit(ExitCode20.FatalError);
1539
+ process26.exit(ExitCode20.FatalError);
1472
1540
  });
1473
1541
  }
1474
1542
  async function isPkgxInstalled() {
@@ -1482,7 +1550,7 @@ async function installPkgx() {
1482
1550
  if (result.isOk())
1483
1551
  return;
1484
1552
  handleError(result.error);
1485
- process25.exit(ExitCode20.FatalError);
1553
+ process26.exit(ExitCode20.FatalError);
1486
1554
  }
1487
1555
  async function initializeProject(options) {
1488
1556
  log12.info("Installing dependencies...");
@@ -1491,17 +1559,17 @@ async function initializeProject(options) {
1491
1559
  });
1492
1560
  if (result.isErr()) {
1493
1561
  handleError(result.error);
1494
- process25.exit(ExitCode20.FatalError);
1562
+ process26.exit(ExitCode20.FatalError);
1495
1563
  }
1496
1564
  log12.success("Installed node_modules");
1497
1565
  log12.info("Ensuring .env exists...");
1498
- if (storage3.doesNotExist(p4.projectPath(".env"))) {
1566
+ if (storage.doesNotExist(p4.projectPath(".env"))) {
1499
1567
  const envResult = await runCommand7("cp .env.example .env", {
1500
1568
  cwd: options.cwd || p4.projectPath()
1501
1569
  });
1502
1570
  if (envResult.isErr()) {
1503
1571
  handleError(envResult.error);
1504
- process25.exit(ExitCode20.FatalError);
1572
+ process26.exit(ExitCode20.FatalError);
1505
1573
  }
1506
1574
  log12.success(".env created");
1507
1575
  } else {
@@ -1512,7 +1580,7 @@ async function initializeProject(options) {
1512
1580
  });
1513
1581
  if (keyResult.isErr()) {
1514
1582
  handleError(keyResult.error);
1515
- process25.exit(ExitCode20.FatalError);
1583
+ process26.exit(ExitCode20.FatalError);
1516
1584
  }
1517
1585
  log12.info("Ensuring AWS is connected...");
1518
1586
  log12.success("Configured AWS");
@@ -1524,10 +1592,10 @@ async function optimizePkgxDeps() {
1524
1592
  }
1525
1593
 
1526
1594
  // src/commands/test.ts
1527
- import process26 from "process";
1595
+ import process27 from "process";
1528
1596
  import {runAction as runAction16} from "@stacksjs/actions";
1529
1597
  import {intro as intro17, outro as outro17} from "@stacksjs/cli";
1530
- import {projectPath} from "@stacksjs/path";
1598
+ import {projectPath as projectPath2} from "@stacksjs/path";
1531
1599
  import {Action as Action16} from "@stacksjs/enums";
1532
1600
  function test(buddy) {
1533
1601
  const descriptions2 = {
@@ -1543,19 +1611,19 @@ function test(buddy) {
1543
1611
  };
1544
1612
  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) => {
1545
1613
  const perf = await intro17("buddy test");
1546
- const result = await runAction16(Action16.Test, { ...options, cwd: projectPath() });
1614
+ const result = await runAction16(Action16.Test, { ...options, cwd: projectPath2() });
1547
1615
  if (result.isErr()) {
1548
1616
  await outro17("While running `buddy test`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1549
- process26.exit();
1617
+ process27.exit();
1550
1618
  }
1551
1619
  await outro17("Finished running tests", { startTime: perf, useSeconds: true });
1552
1620
  });
1553
1621
  buddy.command("test:unit", descriptions2.unit).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1554
1622
  const perf = await intro17("buddy test:unit");
1555
- const result = await runAction16(Action16.TestUnit, { ...options, verbose: true, cwd: projectPath() });
1623
+ const result = await runAction16(Action16.TestUnit, { ...options, verbose: true, cwd: projectPath2() });
1556
1624
  if (result.isErr()) {
1557
1625
  await outro17("While running `buddy test:unit`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1558
- process26.exit();
1626
+ process27.exit();
1559
1627
  }
1560
1628
  await outro17("Finished running unit tests", { startTime: perf, useSeconds: true });
1561
1629
  });
@@ -1563,51 +1631,51 @@ function test(buddy) {
1563
1631
  const perf = await intro17("buddy test:feature");
1564
1632
  let result;
1565
1633
  if (options.showReport)
1566
- result = await runAction16(Action16.ShowFeatureTestReport, { ...options, verbose: true, cwd: projectPath() });
1634
+ result = await runAction16(Action16.ShowFeatureTestReport, { ...options, verbose: true, cwd: projectPath2() });
1567
1635
  else
1568
- result = await runAction16(Action16.TestFeature, { ...options, verbose: true, cwd: projectPath() });
1636
+ result = await runAction16(Action16.TestFeature, { ...options, verbose: true, cwd: projectPath2() });
1569
1637
  if (result.isErr()) {
1570
1638
  await outro17("While running `buddy test:feature`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1571
- process26.exit();
1639
+ process27.exit();
1572
1640
  }
1573
1641
  await outro17("Finished running feature tests", { startTime: perf, useSeconds: true });
1574
1642
  });
1575
1643
  buddy.command("test:ui", descriptions2.command).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1576
1644
  const perf = await intro17("buddy test:ui");
1577
- const result = await runAction16(Action16.TestUi, { ...options, verbose: true, cwd: projectPath() });
1645
+ const result = await runAction16(Action16.TestUi, { ...options, verbose: true, cwd: projectPath2() });
1578
1646
  if (result.isErr()) {
1579
1647
  await outro17("While running `buddy test:ui`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1580
- process26.exit();
1648
+ process27.exit();
1581
1649
  }
1582
1650
  await outro17("Finished running tests in the browser", { startTime: perf, useSeconds: true });
1583
1651
  });
1584
1652
  buddy.command("test:types", descriptions2.types).alias("typecheck").option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1585
1653
  const perf = await intro17("buddy test:types");
1586
- const result = await runAction16(Action16.Typecheck, { ...options, verbose: true, cwd: projectPath() });
1654
+ const result = await runAction16(Action16.Typecheck, { ...options, verbose: true, cwd: projectPath2() });
1587
1655
  if (result.isErr()) {
1588
1656
  await outro17("While running `buddy test:types`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1589
- process26.exit();
1657
+ process27.exit();
1590
1658
  }
1591
1659
  await outro17("Finished running typecheck", { startTime: perf, useSeconds: true });
1592
1660
  });
1593
1661
  buddy.command("test:coverage", descriptions2.coverage).action(async (options) => {
1594
1662
  const perf = await intro17("buddy test:coverage");
1595
- const result = await runAction16(Action16.TestCoverage, { ...options, cwd: projectPath(), verbose: true });
1663
+ const result = await runAction16(Action16.TestCoverage, { ...options, cwd: projectPath2(), verbose: true });
1596
1664
  if (result.isErr()) {
1597
1665
  await outro17("While running `buddy test:coverage`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1598
- process26.exit();
1666
+ process27.exit();
1599
1667
  }
1600
1668
  await outro17("Generated the test coverage report", { startTime: perf, useSeconds: true });
1601
- process26.exit();
1669
+ process27.exit();
1602
1670
  });
1603
1671
  buddy.on("test:*", () => {
1604
1672
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1605
- process26.exit(1);
1673
+ process27.exit(1);
1606
1674
  });
1607
1675
  }
1608
1676
 
1609
1677
  // src/commands/tinker.ts
1610
- import process27 from "process";
1678
+ import process28 from "process";
1611
1679
  import {ExitCode as ExitCode21} from "@stacksjs/types";
1612
1680
  import {runAction as runAction17} from "@stacksjs/actions";
1613
1681
  import {intro as intro18, outro as outro18} from "@stacksjs/cli";
@@ -1623,19 +1691,19 @@ function tinker(buddy) {
1623
1691
  const result = await runAction17(Action17.Tinker, options);
1624
1692
  if (result.isErr()) {
1625
1693
  await outro18("While running the tinker command, there was an issue", { startTime: perf, useSeconds: true }, result.error || undefined);
1626
- process27.exit();
1694
+ process28.exit();
1627
1695
  }
1628
1696
  await outro18("Tinker mode exited.", { startTime: perf, useSeconds: true });
1629
- process27.exit(ExitCode21.Success);
1697
+ process28.exit(ExitCode21.Success);
1630
1698
  });
1631
1699
  buddy.on("tinker:*", () => {
1632
1700
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1633
- process27.exit(1);
1701
+ process28.exit(1);
1634
1702
  });
1635
1703
  }
1636
1704
 
1637
1705
  // src/commands/types.ts
1638
- import process28 from "process";
1706
+ import process29 from "process";
1639
1707
  import {generateTypes as generateTypes2} from "@stacksjs/actions";
1640
1708
  function types22(buddy) {
1641
1709
  const descriptions2 = {
@@ -1651,12 +1719,12 @@ function types22(buddy) {
1651
1719
  });
1652
1720
  buddy.on("types:*", () => {
1653
1721
  console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
1654
- process28.exit(1);
1722
+ process29.exit(1);
1655
1723
  });
1656
1724
  }
1657
1725
 
1658
1726
  // src/commands/upgrade.ts
1659
- import process29 from "process";
1727
+ import process30 from "process";
1660
1728
  import {runAction as runAction18} from "@stacksjs/actions";
1661
1729
  import {intro as intro19, outro as outro19, prompt as prompt5} from "@stacksjs/cli";
1662
1730
  import {ExitCode as ExitCode22} from "@stacksjs/types";
@@ -1686,7 +1754,7 @@ function upgrade(buddy) {
1686
1754
  ]
1687
1755
  });
1688
1756
  if (answers !== null)
1689
- process29.exit(ExitCode22.InvalidArgument);
1757
+ process30.exit(ExitCode22.InvalidArgument);
1690
1758
  if (isString4(answers))
1691
1759
  answers = [answers];
1692
1760
  options = answers.reduce((a, v) => ({ ...a, [v]: true }), {});
@@ -1694,10 +1762,10 @@ function upgrade(buddy) {
1694
1762
  const result = await runAction18(Action18.Upgrade, options);
1695
1763
  if (result.isErr()) {
1696
1764
  await outro19("While running the buddy:upgrade command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1697
- process29.exit();
1765
+ process30.exit();
1698
1766
  }
1699
1767
  await outro19("Upgrade complete.", { startTime: perf, useSeconds: true });
1700
- process29.exit();
1768
+ process30.exit();
1701
1769
  });
1702
1770
  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) => {
1703
1771
  await runAction18(Action18.Upgrade, options);
@@ -1710,9 +1778,9 @@ function upgrade(buddy) {
1710
1778
  const result = await runAction18(Action18.UpgradeBun, options);
1711
1779
  if (result.isErr()) {
1712
1780
  await outro19("While running the buddy upgrade:bun command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
1713
- process29.exit();
1781
+ process30.exit();
1714
1782
  }
1715
- process29.exit(ExitCode22.Success);
1783
+ process30.exit(ExitCode22.Success);
1716
1784
  });
1717
1785
  buddy.command("upgrade:all", descriptions2.all).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
1718
1786
  await runAction18(Action18.Upgrade, options);
@@ -1738,4 +1806,4 @@ function version(buddy) {
1738
1806
  log13.info(green(bold3("Bun: ")) + dim2(` ${bunVersion}`));
1739
1807
  });
1740
1808
  }
1741
- export { build, changelog, clean, cloud2 as cloud, commit, configure, create, deploy, dev, startDevelopmentServer, domains, dns3 as dns, example, fresh, generate, http, lint, inspire, install2 as install, key, make, migrate, prepublish, release, seed, setup, optimizePkgxDeps, test, tinker, types22 as types, upgrade, version };
1809
+ export { build, changelog, clean, cloud2 as cloud, commit, configure, create, deploy, dev, startDevelopmentServer, domains, dns3 as dns, example, fresh, generate, http, lint, list, inspire, install2 as install, key, make, migrate, prepublish, release, seed, setup, optimizePkgxDeps, test, tinker, types22 as types, upgrade, version };
package/dist/cli.js CHANGED
@@ -15,10 +15,11 @@ http,
15
15
  install,
16
16
  key,
17
17
  lint,
18
+ list,
18
19
  release,
19
20
  setup,
20
21
  upgrade
21
- } from "./chunk-91084836e95161e8.js";
22
+ } from "./chunk-d52e40a990b45728.js";
22
23
  import"./chunk-0455e53fab4244b1.js";
23
24
 
24
25
  // src/cli.ts
@@ -47,6 +48,7 @@ async function main() {
47
48
  http(buddy);
48
49
  install(buddy);
49
50
  lint(buddy);
51
+ list(buddy);
50
52
  release(buddy);
51
53
  setup(buddy);
52
54
  upgrade(buddy);
@@ -60,6 +62,7 @@ async function main() {
60
62
  else
61
63
  console.error(`Expected a default export function in ${file}, but got:`, dynamicImport.default);
62
64
  }
65
+ buddy.help();
63
66
  buddy.parse();
64
67
  }
65
68
  process.on("uncaughtException", handleError);
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ inspire,
19
19
  install,
20
20
  key,
21
21
  lint,
22
+ list,
22
23
  make,
23
24
  migrate,
24
25
  optimizePkgxDeps,
@@ -32,7 +33,7 @@ tinker,
32
33
  types,
33
34
  upgrade,
34
35
  version
35
- } from "./chunk-91084836e95161e8.js";
36
+ } from "./chunk-d52e40a990b45728.js";
36
37
  import"./chunk-0455e53fab4244b1.js";
37
38
  export {
38
39
  version,
@@ -48,6 +49,7 @@ export {
48
49
  optimizePkgxDeps,
49
50
  migrate,
50
51
  make,
52
+ list,
51
53
  lint,
52
54
  key,
53
55
  install,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/buddy",
3
3
  "type": "module",
4
- "version": "0.58.51",
4
+ "version": "0.58.52",
5
5
  "description": "Meet Buddy. The Stacks runtime.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
package/src/cli.ts CHANGED
@@ -35,6 +35,7 @@ async function main() {
35
35
  cmd.http(buddy)
36
36
  cmd.install(buddy)
37
37
  cmd.lint(buddy)
38
+ cmd.list(buddy)
38
39
  // cmd.make(buddy)
39
40
  // cmd.migrate(buddy)
40
41
  cmd.release(buddy)
@@ -61,6 +62,7 @@ async function main() {
61
62
  console.error(`Expected a default export function in ${file}, but got:`, dynamicImport.default)
62
63
  }
63
64
 
65
+ buddy.help()
64
66
  buddy.parse()
65
67
  }
66
68
 
@@ -19,6 +19,8 @@ export function build(buddy: CLI) {
19
19
  pages: 'Build your frontend',
20
20
  docs: 'Build your documentation',
21
21
  framework: 'Build Stacks framework',
22
+ cli: 'Automagically build the CLI',
23
+ server: 'Build the Stacks cloud server (Docker image)',
22
24
  select: 'What are you trying to build?',
23
25
  project: 'Target a specific project',
24
26
  verbose: 'Enable verbose output',
@@ -36,6 +38,7 @@ export function build(buddy: CLI) {
36
38
  .option('-b, --buddy', descriptions.buddy, { default: false })
37
39
  .option('-s, --stacks', descriptions.framework, { default: false })
38
40
  .option('-p, --project', descriptions.project, { default: false })
41
+ .option('--server', descriptions.server, { default: false })
39
42
  .option('--verbose', descriptions.verbose, { default: false })
40
43
  .action(async (server: string | undefined, options: BuildOptions) => {
41
44
  switch (server) {
@@ -66,6 +69,9 @@ export function build(buddy: CLI) {
66
69
  case 'stacks':
67
70
  options.stacks = true
68
71
  break
72
+ case 'server':
73
+ options.stacks = true
74
+ break
69
75
  default:
70
76
  break
71
77
  }
@@ -109,7 +115,7 @@ export function build(buddy: CLI) {
109
115
  })
110
116
 
111
117
  buddy
112
- .command('build:cli', 'Automagically build the CLI')
118
+ .command('build:cli', descriptions.cli)
113
119
  .alias('prod:cli')
114
120
  .option('-b, --buddy', descriptions.buddy, { default: true })
115
121
  .option('-p, --project', descriptions.project, { default: false })
@@ -118,6 +124,16 @@ export function build(buddy: CLI) {
118
124
  await runAction(Action.BuildCli, options)
119
125
  })
120
126
 
127
+ buddy
128
+ .command('build:server', descriptions.server)
129
+ .alias('prod:server')
130
+ .alias('build:docker')
131
+ .option('-p, --project', descriptions.project, { default: false })
132
+ .option('--verbose', descriptions.verbose, { default: false })
133
+ .action(async (options: BuildOptions) => {
134
+ await runAction(Action.BuildServer, options)
135
+ })
136
+
121
137
  buddy
122
138
  .command('build:functions', 'Automagically build function library for npm/CDN distribution')
123
139
  .option('-f, --functions', descriptions.functions, { default: true })
@@ -36,6 +36,7 @@ export function deploy(buddy: CLI) {
36
36
  }
37
37
 
38
38
  // TODO: we can improve this check at some point, otherwise domains that legitimately include the word localhost will fail
39
+ // TODO: add check for whether the local APP_ENV is getting deployed, if so, ask if the user meant to deploy `dev`
39
40
  if (domain.includes('localhost')) {
40
41
  log.info('You are deploying to a local environment.')
41
42
  log.info('Please set your .env or ./config/app.ts properly.')
@@ -48,11 +49,10 @@ export function deploy(buddy: CLI) {
48
49
  }
49
50
 
50
51
  if (await hasUserDomainBeenAddedToCloud(domain)) {
51
- log.success('Your domain is properly configured.')
52
+ log.info('Domain is properly configured')
52
53
  log.info('Your cloud is deploying...')
53
54
 
54
55
  log.info(`${italic('This may take a while...')}`)
55
- await new Promise(resolve => setTimeout(resolve, 2000))
56
56
  options.domain = domain
57
57
 
58
58
  // now that we know the domain has been added to the users (AWS) cloud, we can deploy
@@ -14,6 +14,7 @@ export * from './fresh'
14
14
  export * from './generate'
15
15
  export * from './http'
16
16
  export * from './lint'
17
+ export * from './list'
17
18
  export * from './inspire'
18
19
  export * from './install'
19
20
  export * from './key'
@@ -0,0 +1,39 @@
1
+ import process from 'node:process'
2
+ import type { CLI } from '@stacksjs/types'
3
+ import { $ } from 'bun'
4
+ import { projectPath } from '@stacksjs/path'
5
+
6
+ export function list(buddy: CLI) {
7
+ const descriptions = {
8
+ list: 'List all of the project-specific Buddy commands',
9
+ project: 'Target a specific project',
10
+ verbose: 'Enable verbose output',
11
+ }
12
+
13
+ buddy
14
+ .command('list', descriptions.list)
15
+ .option('-p, --project', descriptions.project, { default: false })
16
+ .option('--verbose', descriptions.verbose, { default: false })
17
+ .action(async () => {
18
+ $.cwd(projectPath())
19
+ const test = await $`buddy --help`.text()
20
+ const commandsSection = test.match(/Commands:.*?(?=For more info, run any command with the)/s)?.[0]
21
+
22
+ if (commandsSection) {
23
+ const cleanedCommands = commandsSection
24
+ .replace('Commands:', '') // Remove "Commands:"
25
+ .replace(/^\s+/gm, '') // Trim leading whitespace from the start of each line
26
+
27
+ // eslint-disable-next-line no-console
28
+ console.log(cleanedCommands)
29
+ return
30
+ }
31
+
32
+ console.error('#1 - Please reach out to our Discord for helper: https://discord.gg/stacksjs')
33
+ })
34
+
35
+ buddy.on('list:*', () => {
36
+ console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
37
+ process.exit(1)
38
+ })
39
+ }
@@ -1,14 +1,17 @@
1
1
  import process from 'node:process'
2
2
  import { path as p } from '@stacksjs/path'
3
3
  import { handleError } from '@stacksjs/error-handling'
4
- import { storage } from '@stacksjs/storage'
4
+ import { writeFile } from '@stacksjs/storage'
5
5
  import { log, runCommand } from '@stacksjs/cli'
6
6
  import { ExitCode } from '@stacksjs/types'
7
7
  import type { CLI, CliOptions } from '@stacksjs/types'
8
+ import { $ } from 'bun'
8
9
 
9
10
  export function setup(buddy: CLI) {
10
11
  const descriptions = {
11
12
  setup: 'This command ensures your project is setup correctly',
13
+ ohMyZsh: 'Enable Oh My Zsh',
14
+ aws: 'Ensures AWS is connected to the project',
12
15
  project: 'Target a specific project',
13
16
  verbose: 'Enable verbose output',
14
17
  }
@@ -28,6 +31,59 @@ export function setup(buddy: CLI) {
28
31
  await initializeProject(options)
29
32
  })
30
33
 
34
+ buddy
35
+ .command('setup:oh-my-zsh', descriptions.ohMyZsh) // if triggered multiple times, it will update the plugin
36
+ .option('--verbose', descriptions.verbose, { default: false })
37
+ .action(async (_options?: CliOptions) => {
38
+ const homePath = (await $`echo $HOME`.text()).trim()
39
+ const zshrcPath = p.join(homePath, '.zshrc')
40
+ const pluginPath = p.frameworkPath('core/zsh-buddy/buddy.plugin.zsh')
41
+ const customPath = p.join(homePath, '.oh-my-zsh/custom/plugins/buddy/')
42
+
43
+ log.info(`Setting up Oh My Zsh via ${zshrcPath}...`)
44
+ $.cwd(p.dirname(zshrcPath))
45
+ let data = await $`cat ${p.basename(zshrcPath)}`.text()
46
+
47
+ // Manipulate the data
48
+ const pluginLineRegex = /^(?!#).*plugins=\(([^)]+)\)/m // ensure it's not a comment
49
+ const match = data.match(pluginLineRegex)
50
+
51
+ if (match) {
52
+ // 1. Find the plugins line
53
+ const plugins = match[1].split(' ')
54
+
55
+ // 2. Add buddy to the list of plugins if it's not already there
56
+ if (!plugins.includes('buddy')) {
57
+ plugins.push('buddy')
58
+ const newPluginLine = `plugins=(${plugins.join(' ')})`
59
+ // 3. Replace the old plugin line with the new one
60
+ data = data.replace(pluginLineRegex, newPluginLine)
61
+ // 4. Write the data back to the file
62
+ await writeFile(zshrcPath, data)
63
+
64
+ // need to copy plugin to ~/.oh-my-zsh/custom/plugins
65
+ log.info(`Copying buddy zsh plugin ${pluginPath} to ${customPath}...`)
66
+
67
+ // create customPath if it doesn't exist
68
+ await runCommand(`mkdir -p ${customPath}`)
69
+ await runCommand(`cp -rf ${pluginPath} ${customPath}`)
70
+ // await runCommand(`source ${customPath}/buddy.plugin.zsh`)
71
+
72
+ log.success('Copied buddy zsh plugin')
73
+ }
74
+ else {
75
+ log.info('buddy is already integrated in your shell, updating...')
76
+ await runCommand(`cp -rf ${pluginPath} ${customPath}`)
77
+ // await runCommand(`source ${customPath}/buddy.plugin.zsh`)
78
+ log.success('Updated buddy zsh plugin')
79
+ }
80
+ }
81
+
82
+ log.success('Oh My Zsh setup complete.')
83
+ log.info('To see changes reflect, you may need to:')
84
+ log.info('⌘⇧P workbench.action.reloadWindow')
85
+ })
86
+
31
87
  buddy.on('setup:*', () => {
32
88
  console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
33
89
  process.exit(ExitCode.FatalError)