@stacksjs/buddy 0.70.160 → 0.70.162

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.
package/README.md CHANGED
@@ -35,7 +35,7 @@ curl -Ssf stacksjs.com/install | sh # wip
35
35
 
36
36
  # alternatively, if Bun >= v1.1.11 is installed already
37
37
  # you may also get started via
38
- bunx stacks new my-project
38
+ panx @stacksjs/buddy new my-project
39
39
  ```
40
40
 
41
41
  ## Usage
@@ -79,7 +79,7 @@ buddy --help # view help menu
79
79
  # `command --help` flag to review the help menu
80
80
 
81
81
  buddy install # installs dependencies
82
- buddy add # adds a stack or dependency
82
+ buddy add calendar # pulls a registered project-shaped stack into this project
83
83
  buddy fresh # fresh reinstall of all deps
84
84
  buddy clean # removes all deps
85
85
  buddy setup # sets up the project initially
@@ -126,7 +126,7 @@ buddy build:views # builds SSG views
126
126
  buddy build:desktop # builds Desktop application
127
127
  buddy build:library # builds any or all libraries
128
128
  buddy build:functions # builds function library
129
- buddy build:components # builds Vue component library & Web Component library
129
+ buddy build:components # builds the STX component library and Web Component library
130
130
  buddy build:web-components # builds framework agnostic Web Component library (i.e. Custom Elements)
131
131
  buddy build:all # builds all your code
132
132
 
@@ -154,7 +154,7 @@ buddy make:factory cars # creates a Car factory file
154
154
  buddy make:table cars # bootstraps a cars data table
155
155
  buddy make:notification welcome-email # bootstraps a welcome-email notification
156
156
  buddy make:lang de # bootstraps a lang/de.yml language file
157
- buddy make:stack my-project # shares logic with `bunx stacks new my-project`
157
+ buddy make:stack my-project # scaffolds a project-shaped registry stack
158
158
 
159
159
  buddy migrate # runs database migrations
160
160
  buddy migrate:dns # sets the ./config/dns.ts file
@@ -192,7 +192,6 @@ buddy cloud:add --jump-box # adds a jump box to your cloud setup
192
192
 
193
193
  # select the example to run (follow CLI prompts)
194
194
  buddy example # prompts you to select which example to run
195
- buddy example:vue # runs the Vue example
196
195
  buddy example:web-components # runs the Web Component example
197
196
 
198
197
  # you likely won’t need to run these commands as they are auto-triggered, but they are available
@@ -250,7 +249,7 @@ _Develop dynamic UIs with helpers for atomic design, and much more._
250
249
  - 🖥️ **Desktop** _transforms your web app into a desktop app, plus more_
251
250
  - 📝 **Documentation** _markdown-based documentation, auto-generated_
252
251
  - 📚 **Library** _auto-builds & manages component & function libraries_
253
- - ⚡️ Powered by Bun, Tauri, Headwind, Vite, VitePress and Vue
252
+ - ⚡️ Powered by Bun, STX, Tauri, Crosswind, and BunPress
254
253
 
255
254
  ### Backend Development
256
255
 
@@ -274,7 +273,6 @@ _Develop serverless (or server) functions with countless helpers to build scalab
274
273
  - 💾 **Storage** _a secure-by-default File API that feels right_
275
274
  - 🧪 **Tinker** _a powerful TypeScript REPL_
276
275
  - 🌪️ **Validation** _e2e type-safety (true frontend & backend harmony)_
277
- - 🎯 **X-Ray** _all you need to debug, log & analyze_
278
276
 
279
277
  ### Cloud Development
280
278
 
@@ -314,7 +312,7 @@ Convention over configuration, while staying wholly configurable. _No more boile
314
312
  - 🚗 **Auto Imports** _your components & functions, including date, string, array, & object helpers_
315
313
  - ⏩ **Code Snippets** _goodbye to the boilerplate code—thank you Sarah Drasner_
316
314
  - 🔤 **Spell Checker** _be notified once there are typos_
317
- - 🛠️ **Essential Utilities** _powers at your fingertips. Collections, VueUse, and more_
315
+ - 🛠️ **Essential Utilities** _powers at your fingertips. Collections, STX composables, and more_
318
316
  - 👥 **Team Management** _manage your team & their permissions_
319
317
  - 🧪 **Streamlined Testing** _unit & e2e tests powered by Bun, Vitest & Playwright_
320
318
 
package/dist/cli.js CHANGED
@@ -3,6 +3,7 @@ import process from "node:process";
3
3
  import { cli, log } from "@stacksjs/cli";
4
4
  import { path as p } from "@stacksjs/path";
5
5
  import { registerGlobalOptions } from "./global-options";
6
+ import { shouldSkipAppKeyCheck } from "./project-setup";
6
7
  try {
7
8
  const { isSupportedBunVersion, minimumBunVersion } = await import("@stacksjs/utils"), currentBunVersion = typeof Bun < "u" ? Bun.version : process.versions.bun;
8
9
  if (currentBunVersion && !isSupportedBunVersion(currentBunVersion)) {
@@ -10,35 +11,7 @@ try {
10
11
  process.exit(1);
11
12
  }
12
13
  } catch {}
13
- const args = process.argv.slice(2), requestedCommand = args[0] || "help", isHelpFlag = args.includes("--help") || args.includes("-h"), isVersionOnly = ["--version", "-V", "version"].includes(requestedCommand), isHelpMode = requestedCommand === "help" || isHelpFlag && args.length <= 2, skipAppKeyCheck = [
14
- "build",
15
- "lint",
16
- "lint:fix",
17
- "test",
18
- "test:types",
19
- "test:unit",
20
- "test:feature",
21
- "typecheck",
22
- "types:fix",
23
- "types:generate",
24
- "clean",
25
- "fresh",
26
- "about",
27
- "doctor",
28
- "setup",
29
- "setup:ssl",
30
- "setup:oh-my-zsh",
31
- "deploy",
32
- "serve",
33
- "new",
34
- "create",
35
- "migrate",
36
- "seed",
37
- "generate",
38
- "make",
39
- "key:generate",
40
- "scaffold:crud"
41
- ].some((cmd) => requestedCommand === cmd || requestedCommand.startsWith(`${cmd}:`)) || isHelpFlag || isHelpMode, needsFullSetup = !isVersionOnly;
14
+ const args = process.argv.slice(2), requestedCommand = args[0] || "help", isHelpFlag = args.includes("--help") || args.includes("-h"), isVersionOnly = ["--version", "-V", "version"].includes(requestedCommand), isHelpMode = requestedCommand === "help" || isHelpFlag && args.length <= 2, skipAppKeyCheck = shouldSkipAppKeyCheck(requestedCommand, { isHelpFlag, isHelpMode }), needsFullSetup = !isVersionOnly;
42
15
  if (needsFullSetup) {
43
16
  const reportFatal = (label, error) => {
44
17
  log.debug(`Buddy ${label}`);
@@ -1,33 +1,25 @@
1
1
  import process from "node:process";
2
- import { runAdd } from "@stacksjs/actions";
3
- import { log } from "@stacksjs/logging";
2
+ import { installStack } from "@stacksjs/actions";
3
+ import { intro, italic, log, onUnknownSubcommand, outro } from "@stacksjs/cli";
4
4
  import { ExitCode } from "@stacksjs/types";
5
- import { onUnknownSubcommand } from "@stacksjs/cli";
6
5
  export function add(buddy) {
7
- const descriptions = {
8
- add: "Add a stack to your project (table and calendar available, more coming soon)",
9
- table: "Add the Table Stack to your project",
10
- calendar: "Add the Calendar Stack to your project",
11
- all: "Add all stacks",
12
- select: "Which stack/s are you trying to add?",
13
- project: "Target a specific project",
14
- verbose: "Enable verbose output"
15
- };
16
- buddy.command("add", descriptions.add).option("-t, --table", descriptions.table, { default: !1 }).option("-c, --calendar", descriptions.calendar, { default: !1 }).option("-a, --all", descriptions.all, { default: !1 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
17
- log.debug("Running `buddy add`...", options);
18
- if (hasNoOptions(options))
19
- ;
20
- await runAdd(options);
6
+ buddy.command("add <stack>", "Pull a registered stack and merge its project files into this Stacks application").option("--force", "Overwrite existing files", { default: !1 }).option("--dry-run", "Show which files would be installed without changing the project", { default: !1 }).option("--conflict <strategy>", "Resolve existing files with skip, overwrite, or backup", { default: "skip" }).option("-p, --project <path>", "Target a specific Stacks project").option("--verbose", "Show every file copied or skipped", { default: !1 }).example("buddy add calendar").example("buddy add table --dry-run").example("buddy add calendar --conflict backup").action(async (stack, options) => {
7
+ const perf = await intro("buddy add");
8
+ if (!await installStack({
9
+ name: stack,
10
+ force: options.force,
11
+ dryRun: options.dryRun,
12
+ conflict: options.conflict,
13
+ project: options.project,
14
+ verbose: options.verbose
15
+ })) {
16
+ await outro(`Could not add stack ${italic(stack)}.`, { startTime: perf, useSeconds: !0 });
17
+ process.exit(ExitCode.FatalError);
18
+ }
19
+ if (options.dryRun)
20
+ log.info("Dry run complete. No project files were changed.");
21
+ await outro(`Stack ${italic(stack)} added.`, { startTime: perf, useSeconds: !0 });
21
22
  process.exit(ExitCode.Success);
22
23
  });
23
- buddy.command("add:table", descriptions.table).option("-t, --table", descriptions.table, { default: !0 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
24
- await runAdd(options);
25
- });
26
- buddy.command("add:calendar", descriptions.calendar).option("-t, --calendar", descriptions.calendar, { default: !0 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
27
- await runAdd(options);
28
- });
29
24
  onUnknownSubcommand(buddy, "add");
30
25
  }
31
- function hasNoOptions(options) {
32
- return !options.all && !options.table && !options.calendar;
33
- }
@@ -1,2 +1,3 @@
1
- import type { CLI } from '@stacksjs/types';
1
+ import type { BuildOptions, CLI } from '@stacksjs/types';
2
2
  export declare function build(buddy: CLI): void;
3
+ export declare function applyBuildTarget(target: string | undefined, options: BuildOptions): void;
@@ -28,39 +28,9 @@ export function build(buddy) {
28
28
  project: "Target a specific project",
29
29
  verbose: "Enable verbose output"
30
30
  };
31
- buddy.command("build [type]", descriptions.build).option("-c, --components", descriptions.components).option("-w, --web-components", descriptions.webComponents).option("-e, --elements", descriptions.elements).option("-f, --functions", descriptions.functions).option("-p, --views", descriptions.pages).option("--pages", descriptions.pages).option("-d, --docs", descriptions.docs).option("-b, --buddy", descriptions.buddy, { default: !1 }).option("-s, --stacks", descriptions.framework, { default: !1 }).option("--project [project]", descriptions.project, { default: !1 }).option("--server", descriptions.server, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (server, options) => {
31
+ buddy.command("build [type]", descriptions.build).option("-c, --components", descriptions.components).option("-w, --web-components", descriptions.webComponents).option("-e, --elements", descriptions.elements).option("-f, --functions", descriptions.functions).option("-k, --desktop", descriptions.desktop).option("-p, --views", descriptions.pages).option("--pages", descriptions.pages).option("-d, --docs", descriptions.docs).option("-b, --buddy", descriptions.buddy, { default: !1 }).option("-s, --stacks", descriptions.framework, { default: !1 }).option("--project [project]", descriptions.project, { default: !1 }).option("--server", descriptions.server, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (server, options) => {
32
32
  log.debug("Running `buddy build` ...", options);
33
- switch (server) {
34
- case "components":
35
- options.components = !0;
36
- break;
37
- case "web-components":
38
- options.webComponents = !0;
39
- break;
40
- case "functions":
41
- options.functions = !0;
42
- break;
43
- case "views":
44
- options.views = !0;
45
- break;
46
- case "docs":
47
- options.docs = !0;
48
- break;
49
- case "buddy":
50
- options.buddy = !0;
51
- break;
52
- case "cli":
53
- options.buddy = !0;
54
- break;
55
- case "stacks":
56
- options.stacks = !0;
57
- break;
58
- case "server":
59
- options.server = !0;
60
- break;
61
- default:
62
- break;
63
- }
33
+ applyBuildTarget(server, options);
64
34
  if (hasNoOptions(options)) {
65
35
  if (!isCI && hasTTY && process.stdin.isTTY) {
66
36
  const answers = await multiselect({
@@ -70,6 +40,7 @@ export function build(buddy) {
70
40
  { label: "Components", value: "components" },
71
41
  { label: "Web Components", value: "webComponents" },
72
42
  { label: "Functions", value: "functions" },
43
+ { label: "Desktop application", value: "desktop" },
73
44
  { label: "Documentation", value: "docs" },
74
45
  { label: "Stacks framework", value: "stacks" },
75
46
  { label: "Buddy CLI", value: "buddy" },
@@ -84,6 +55,8 @@ export function build(buddy) {
84
55
  options.webComponents = !0;
85
56
  if (selected.has("functions"))
86
57
  options.functions = !0;
58
+ if (selected.has("desktop"))
59
+ options.desktop = !0;
87
60
  if (selected.has("docs"))
88
61
  options.docs = !0;
89
62
  if (selected.has("stacks"))
@@ -107,6 +80,8 @@ export function build(buddy) {
107
80
  succeeded = await runBuildAction(Action.BuildWebComponentLib, "web component library") && succeeded;
108
81
  if (options.functions)
109
82
  succeeded = await runBuildAction(Action.BuildFunctionLib, "function library") && succeeded;
83
+ if (options.desktop)
84
+ succeeded = await runBuildAction(Action.BuildDesktop, "desktop application") && succeeded;
110
85
  if (options.views)
111
86
  succeeded = await runBuildAction(Action.BuildViews, "frontend") && succeeded;
112
87
  if (options.stacks)
@@ -188,7 +163,39 @@ export function build(buddy) {
188
163
  onUnknownSubcommand(buddy, "build");
189
164
  }
190
165
  function hasNoOptions(options) {
191
- return !options.components && !options.webComponents && !options.elements && !options.functions && !options.views && !options.docs && !options.stacks && !options.buddy && !options.server;
166
+ return !options.components && !options.webComponents && !options.elements && !options.functions && !options.desktop && !options.views && !options.docs && !options.stacks && !options.buddy && !options.server;
167
+ }
168
+ export function applyBuildTarget(target, options) {
169
+ switch (target) {
170
+ case "components":
171
+ options.components = !0;
172
+ break;
173
+ case "web-components":
174
+ options.webComponents = !0;
175
+ break;
176
+ case "functions":
177
+ options.functions = !0;
178
+ break;
179
+ case "desktop":
180
+ options.desktop = !0;
181
+ break;
182
+ case "views":
183
+ options.views = !0;
184
+ break;
185
+ case "docs":
186
+ options.docs = !0;
187
+ break;
188
+ case "buddy":
189
+ case "cli":
190
+ options.buddy = !0;
191
+ break;
192
+ case "stacks":
193
+ options.stacks = !0;
194
+ break;
195
+ case "server":
196
+ options.server = !0;
197
+ break;
198
+ }
192
199
  }
193
200
  async function runBuildAction(action, target) {
194
201
  const result = await runAction(action);
@@ -15,7 +15,6 @@ export function create(buddy) {
15
15
  ui: "Are you building a UI?",
16
16
  components: "Are you building UI components?",
17
17
  webComponents: "Automagically built optimized custom elements/web components?",
18
- vue: "Automagically built a Vue component library?",
19
18
  views: "How about views?",
20
19
  functions: "Are you developing functions/composables?",
21
20
  api: "Are you building an API?",
@@ -27,7 +26,7 @@ export function create(buddy) {
27
26
  minimal: "Skip optional feature bundles (cms, commerce, dashboard, marketing, monitoring, realtime, queue) \u2014 bare-bones API/SPA starter that can re-add them later via `./buddy <feature>:install`.",
28
27
  verbose: "Enable verbose output"
29
28
  };
30
- buddy.command("new [name]", descriptions.command).alias("create [name]").option("-n, --name [name]", descriptions.name, { default: !1 }).option("-u, --ui", descriptions.ui, { default: !0 }).option("-c, --components", descriptions.components, { default: !0 }).option("-w, --web-components", descriptions.webComponents, { default: !0 }).option("--vue", descriptions.vue, { default: !0 }).option("-p, --views", descriptions.views, { default: !0 }).option("-f, --functions", descriptions.functions, { default: !0 }).option("-a, --api", descriptions.api, { default: !0 }).option("-d, --database", descriptions.database, { default: !0 }).option("-ca, --cache", descriptions.cache, { default: !1 }).option("-e, --email", descriptions.email, { default: !1 }).option("-P, --project [project]", descriptions.project, { default: !1 }).option("-m, --minimal", descriptions.minimal, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (name, options) => {
29
+ buddy.command("new [name]", descriptions.command).alias("create [name]").option("-n, --name [name]", descriptions.name, { default: !1 }).option("-u, --ui", descriptions.ui, { default: !0 }).option("-c, --components", descriptions.components, { default: !0 }).option("-w, --web-components", descriptions.webComponents, { default: !0 }).option("-p, --views", descriptions.views, { default: !0 }).option("-f, --functions", descriptions.functions, { default: !0 }).option("-a, --api", descriptions.api, { default: !0 }).option("-d, --database", descriptions.database, { default: !0 }).option("-ca, --cache", descriptions.cache, { default: !1 }).option("-e, --email", descriptions.email, { default: !1 }).option("-P, --project [project]", descriptions.project, { default: !1 }).option("-m, --minimal", descriptions.minimal, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (name, options) => {
31
30
  log.debug("Running `buddy new <name>` ...", options);
32
31
  const startTime = await intro("buddy new");
33
32
  name = name ?? options.name;
@@ -104,14 +103,8 @@ async function ensureEnv(path, _options) {
104
103
  }
105
104
  async function install(path, options) {
106
105
  log.info("Installing & setting up Stacks");
107
- log.info("Running bun install...");
108
- let result = await runCommand("bun install", { ...options, cwd: path });
109
- if (result?.isErr) {
110
- log.error(result.error);
111
- process.exit(ExitCode.FatalError);
112
- }
113
106
  log.info("Copying .env.example \u2192 .env");
114
- result = await runCommand("cp .env.example .env", { ...options, cwd: path });
107
+ let result = await runCommand("cp .env.example .env", { ...options, cwd: path });
115
108
  if (result?.isErr) {
116
109
  log.error(result.error);
117
110
  process.exit(ExitCode.FatalError);
@@ -159,7 +159,7 @@ export function dev(buddy) {
159
159
  });
160
160
  buddy.command("dev:components", descriptions.components).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
161
161
  const perf = await intro("buddy dev:components"), result = await runCommand("bun run dev", {
162
- cwd: libsPath("components/vue")
162
+ cwd: libsPath("components/stx")
163
163
  });
164
164
  if (options.verbose)
165
165
  log.info("buddy dev:components result", result);
@@ -277,7 +277,6 @@ export async function startDevelopmentServer(_options, _startTime) {
277
277
  process.on("SIGTERM", cleanup);
278
278
  process.on("SIGHUP", cleanup);
279
279
  const quietOpts = { ...options, quiet: !0 }, a = await actions(), ports = [
280
- { name: "Frontend", port: frontendPort },
281
280
  { name: "API", port: apiPort }
282
281
  ], readinessTimeoutMs = 30000;
283
282
  let readyAnnounced = !1;
@@ -1,2 +1,27 @@
1
1
  import type { CLI } from '@stacksjs/types';
2
+ import type { Command } from '@stacksjs/clapp';
2
3
  export declare function list(buddy: CLI): void;
4
+ export declare function commandInventoryEntry(command: Command): BuddyCommandInventoryEntry;
5
+ export declare interface BuddyCommandInventoryOption {
6
+ name: string
7
+ flags: string[]
8
+ description: string
9
+ required: boolean
10
+ boolean: boolean
11
+ negated: boolean
12
+ default?: unknown
13
+ }
14
+ export declare interface BuddyCommandInventoryEntry {
15
+ name: string
16
+ description: string
17
+ aliases: string[]
18
+ namespace?: string
19
+ usage: string
20
+ arguments: Array<{
21
+ name: string
22
+ required: boolean
23
+ variadic: boolean
24
+ }>
25
+ options: BuddyCommandInventoryOption[]
26
+ examples: string[]
27
+ }
@@ -9,16 +9,17 @@ export function list(buddy) {
9
9
  filter: "Filter commands by name or group",
10
10
  namespace: "Filter commands by namespace (e.g., make, env, db)",
11
11
  grouped: "Group commands by category",
12
- format: "Output format (text, json)"
12
+ format: "Output format (text, json)",
13
+ json: "Output the complete command inventory as JSON"
13
14
  };
14
- buddy.command("list", descriptions.list).option("-p, --project [project]", descriptions.project, { default: !1 }).option("-f, --filter [filter]", descriptions.filter).option("-n, --namespace [namespace]", descriptions.namespace).option("-g, --grouped", descriptions.grouped, { default: !0 }).option("--format [format]", descriptions.format, { default: "text" }).option("--verbose", descriptions.verbose, { default: !1 }).example("buddy list").example("buddy list --filter=make").example("buddy list --namespace=make").example("buddy list --namespace=env").example("buddy list --no-grouped").example("buddy list --format=json").action(async (options) => {
15
+ buddy.command("list", descriptions.list).option("-p, --project [project]", descriptions.project, { default: !1 }).option("-f, --filter [filter]", descriptions.filter).option("-n, --namespace [namespace]", descriptions.namespace).option("-g, --grouped", descriptions.grouped, { default: !0 }).option("--format [format]", descriptions.format, { default: "text" }).option("-J, --json", descriptions.json, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).example("buddy list").example("buddy list --filter=make").example("buddy list --namespace=make").example("buddy list --namespace=env").example("buddy list --no-grouped").example("buddy list --format=json").example("buddy list --json").action(async (options) => {
15
16
  log.debug("Running `buddy list` ...", options);
16
17
  const { bold, dim, green } = await import("@stacksjs/cli"), commands = buddy.commands || [];
17
18
  let filteredCommands = commands;
18
19
  if (options.filter) {
19
20
  const filterStr = String(options.filter).toLowerCase();
20
21
  filteredCommands = commands.filter((cmd) => {
21
- const name = cmd.name || "", desc = cmd.description || "";
22
+ const name = canonicalCommandName(cmd), desc = cmd.description || "";
22
23
  return name.toLowerCase().includes(filterStr) || desc.toLowerCase().includes(filterStr);
23
24
  });
24
25
  }
@@ -29,7 +30,7 @@ export function list(buddy) {
29
30
  });
30
31
  }
31
32
  if (filteredCommands.length === 0) {
32
- if (options.format === "json")
33
+ if (usesJsonOutput(options))
33
34
  console.log(JSON.stringify({ commands: [], total: 0 }, null, 2));
34
35
  else {
35
36
  console.log(dim("No commands found"));
@@ -38,19 +39,15 @@ export function list(buddy) {
38
39
  }
39
40
  return;
40
41
  }
41
- if (options.format === "json") {
42
- const jsonOutput = filteredCommands.map((cmd) => ({
43
- name: cmd.name || "",
44
- description: cmd.description || "",
45
- aliases: cmd.aliasNames || []
46
- }));
42
+ if (usesJsonOutput(options)) {
43
+ const jsonOutput = filteredCommands.map(commandInventoryEntry).sort((a, b) => a.name.localeCompare(b.name));
47
44
  console.log(JSON.stringify({ commands: jsonOutput, total: jsonOutput.length }, null, 2));
48
45
  return;
49
46
  }
50
47
  if (options.grouped) {
51
48
  const groups = new Map;
52
49
  for (const cmd of filteredCommands) {
53
- const name = cmd.name || "";
50
+ const name = canonicalCommandName(cmd);
54
51
  if (!name)
55
52
  continue;
56
53
  let group = "General";
@@ -83,9 +80,9 @@ export function list(buddy) {
83
80
  });
84
81
  for (const [group, cmds] of sortedGroups) {
85
82
  console.log(bold(`${group}:`));
86
- cmds.sort((a, b) => (a.name || "").localeCompare(b.name || ""));
83
+ cmds.sort((a, b) => canonicalCommandName(a).localeCompare(canonicalCommandName(b)));
87
84
  for (const cmd of cmds) {
88
- const name = (cmd.name || "").padEnd(20), desc = cmd.description || "";
85
+ const name = canonicalCommandName(cmd).padEnd(20), desc = cmd.description || "";
89
86
  console.log(` ${green(name)} ${dim(desc)}`);
90
87
  }
91
88
  console.log("");
@@ -94,9 +91,9 @@ export function list(buddy) {
94
91
  console.log("");
95
92
  console.log(bold(green("Available Commands:")));
96
93
  console.log("");
97
- filteredCommands.sort((a, b) => (a.name || "").localeCompare(b.name || ""));
94
+ filteredCommands.sort((a, b) => canonicalCommandName(a).localeCompare(canonicalCommandName(b)));
98
95
  for (const cmd of filteredCommands) {
99
- const name = (cmd.name || "").padEnd(20), desc = cmd.description || "";
96
+ const name = canonicalCommandName(cmd).padEnd(20), desc = cmd.description || "";
100
97
  console.log(` ${green(name)} ${dim(desc)}`);
101
98
  }
102
99
  console.log("");
@@ -106,3 +103,38 @@ export function list(buddy) {
106
103
  });
107
104
  onUnknownSubcommand(buddy, "list");
108
105
  }
106
+ export function commandInventoryEntry(command) {
107
+ const entry = {
108
+ name: canonicalCommandName(command),
109
+ description: command.description,
110
+ aliases: [...command.aliasNames],
111
+ usage: command.usageLine,
112
+ arguments: command.args.map((argument) => ({
113
+ name: argument.value,
114
+ required: argument.required,
115
+ variadic: argument.variadic
116
+ })),
117
+ options: command.options.map((option) => ({
118
+ name: option.name,
119
+ flags: declaredOptionFlags(option.rawName),
120
+ description: option.description,
121
+ required: option.required === !0,
122
+ boolean: option.isBoolean === !0,
123
+ negated: option.negated,
124
+ ...option.config.default === void 0 ? {} : { default: option.config.default }
125
+ })),
126
+ examples: command.examples.map((example) => typeof example === "string" ? example : example("buddy"))
127
+ };
128
+ if (command.namespace)
129
+ entry.namespace = command.namespace;
130
+ return entry;
131
+ }
132
+ function canonicalCommandName(command) {
133
+ return command.namespace ? `${command.namespace}:${command.name}` : command.name;
134
+ }
135
+ function declaredOptionFlags(rawName) {
136
+ return [...rawName.matchAll(/-{1,2}([\w-]+)/g)].map((match) => match[1]);
137
+ }
138
+ function usesJsonOutput(options) {
139
+ return options.json === !0 || options.format === "json";
140
+ }
@@ -17,7 +17,7 @@ export function sanitizeLineCount(value) {
17
17
  const count = Number.parseInt(value || "50", 10);
18
18
  return String(Number.isFinite(count) ? Math.min(5000, Math.max(1, count)) : 50);
19
19
  }
20
- function shellQuote(value) {
20
+ function shellQuote(_value) {
21
21
  return `'${value.replace(/'/g, "'\\''")}'`;
22
22
  }
23
23
  async function resolveOperationalMailHost() {
@@ -2,7 +2,6 @@ import type { CLI, CliOptions } from '@stacksjs/types';
2
2
  export declare function setup(buddy: CLI): void;
3
3
  export declare function ensurePantryInstalled(): Promise<void>;
4
4
  export declare function ensurePantryDependencies(cwd: string): Promise<void>;
5
- export declare function ensureNodeDependencies(cwd: string): Promise<void>;
6
5
  export declare function ensureAppKey(cwd: string): Promise<void>;
7
6
  export declare function ensureIdeSettings(cwd: string): void;
8
7
  export declare function pantryDatabasePackage(connection: string): DatabasePackage | undefined;
@@ -1,4 +1,5 @@
1
1
  import { cpSync, existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
2
3
  import { join } from "node:path";
3
4
  import process from "node:process";
4
5
  import { runAction } from "@stacksjs/actions";
@@ -15,7 +16,7 @@ function getTimeoutMs(envVar, fallbackMs) {
15
16
  return value;
16
17
  return fallbackMs;
17
18
  }
18
- const PANTRY_CHECK_TIMEOUT_MS = getTimeoutMs("PANTRY_CHECK_TIMEOUT_MS", 15000), PANTRY_INSTALL_TIMEOUT_MS = getTimeoutMs("PANTRY_INSTALL_TIMEOUT_MS", 600000), PANTRY_DEPENDENCIES_TIMEOUT_MS = getTimeoutMs("PANTRY_DEPENDENCIES_TIMEOUT_MS", 1200000), BUN_INSTALL_TIMEOUT_MS = getTimeoutMs("BUN_INSTALL_TIMEOUT_MS", 600000), KEYGEN_TIMEOUT_MS = getTimeoutMs("KEYGEN_TIMEOUT_MS", 120000), AWS_CONFIG_TIMEOUT_MS = getTimeoutMs("AWS_CONFIG_TIMEOUT_MS", 900000);
19
+ const PANTRY_CHECK_TIMEOUT_MS = getTimeoutMs("PANTRY_CHECK_TIMEOUT_MS", 15000), PANTRY_INSTALL_TIMEOUT_MS = getTimeoutMs("PANTRY_INSTALL_TIMEOUT_MS", 600000), PANTRY_DEPENDENCIES_TIMEOUT_MS = getTimeoutMs("PANTRY_DEPENDENCIES_TIMEOUT_MS", 1200000), KEYGEN_TIMEOUT_MS = getTimeoutMs("KEYGEN_TIMEOUT_MS", 120000), AWS_CONFIG_TIMEOUT_MS = getTimeoutMs("AWS_CONFIG_TIMEOUT_MS", 900000);
19
20
  export function setup(buddy) {
20
21
  const descriptions = {
21
22
  setup: "This command ensures your project is setup correctly",
@@ -69,59 +70,41 @@ async function isPantryInstalled() {
69
70
  }
70
71
  }
71
72
  async function installPantry() {
72
- const result = await runCommand(p.frameworkPath("scripts/pantry-install"), {
73
+ const bundledInstaller = p.frameworkPath("scripts/pantry-install"), command = existsSync(bundledInstaller) ? [bundledInstaller] : ["sh", "-c", "curl -fsSL https://pantry.dev | bash"], result = await runCommand(command, {
73
74
  timeoutMs: PANTRY_INSTALL_TIMEOUT_MS
74
- });
75
- if (result.isOk)
75
+ }), localBin = join(homedir(), ".local", "bin");
76
+ if (!process.env.PATH?.split(":").includes(localBin))
77
+ process.env.PATH = `${localBin}:${process.env.PATH || ""}`;
78
+ if (result.isOk && await isPantryInstalled())
76
79
  return;
77
- handleError(result.error);
80
+ if (result.isErr)
81
+ handleError(result.error);
82
+ else
83
+ log.error("Pantry installed but is not available on PATH. Open a new shell and run `buddy setup` again.");
78
84
  process.exit(ExitCode.FatalError);
79
85
  }
80
86
  export async function ensurePantryInstalled() {
81
87
  if (await isPantryInstalled())
82
88
  return;
83
- const installer = p.frameworkPath("scripts/pantry-install");
84
- if (!existsSync(installer)) {
85
- log.debug("Pantry is not installed and no bundled installer is present; continuing without it.");
86
- return;
87
- }
89
+ log.info("Pantry is required. Installing it from https://pantry.dev...");
88
90
  await installPantry();
89
91
  }
90
92
  export async function ensurePantryDependencies(cwd) {
91
- if (!await isPantryInstalled()) {
92
- log.debug("Pantry not installed; skipping pantry dependency install (deps come from node_modules).");
93
- return;
94
- }
95
- log.info("Installing Pantry dependencies...");
93
+ await ensurePantryInstalled();
94
+ log.info("Installing project dependencies with Pantry...");
96
95
  const result = await runCommand("pantry install", {
97
96
  cwd,
98
97
  timeoutMs: PANTRY_DEPENDENCIES_TIMEOUT_MS
99
98
  });
100
- if (result.isOk) {
101
- log.success("Installed Pantry dependencies");
102
- return;
103
- }
104
- handleError(result.error);
105
- process.exit(ExitCode.FatalError);
106
- }
107
- export async function ensureNodeDependencies(cwd) {
108
- if (existsSync(join(cwd, "node_modules"))) {
109
- log.success("node_modules existed, skipping bun install");
110
- return;
111
- }
112
- log.info("Running bun install...");
113
- const result = await runCommand("bun install", {
114
- cwd,
115
- timeoutMs: BUN_INSTALL_TIMEOUT_MS
116
- }).catch((error) => {
117
- handleError(error);
118
- process.exit(ExitCode.FatalError);
119
- });
120
99
  if (result.isErr) {
121
100
  handleError(result.error);
122
101
  process.exit(ExitCode.FatalError);
123
102
  }
124
- log.success("Installed node dependencies");
103
+ if (existsSync(join(cwd, "package.json")) && !existsSync(join(cwd, "node_modules"))) {
104
+ log.error("Pantry completed without installing the project JavaScript dependencies.");
105
+ process.exit(ExitCode.FatalError);
106
+ }
107
+ log.success("Installed project dependencies with Pantry");
125
108
  }
126
109
  function hasAppKey(cwd) {
127
110
  const envPath = join(cwd, ".env");
@@ -167,7 +150,6 @@ async function runInitialMigration(cwd) {
167
150
  async function initializeProject(options) {
168
151
  const cwd = options.cwd || p.projectPath();
169
152
  await ensurePantryDependencies(cwd);
170
- await ensureNodeDependencies(cwd);
171
153
  await ensureEnvIsSet(options);
172
154
  if (!options.skipKeygen)
173
155
  await ensureAppKey(cwd);
@@ -11,13 +11,14 @@ export function stacks(buddy) {
11
11
  force: "Force overwrite existing files",
12
12
  dryRun: "Show what would be installed without making changes",
13
13
  conflict: "Conflict resolution strategy: skip, overwrite, or backup",
14
- verbose: "Enable verbose output"
14
+ verbose: "Enable verbose output",
15
+ project: "Target a specific Stacks project"
15
16
  };
16
- buddy.command("stack:install <name>", descriptions.install).option("--force", descriptions.force, { default: !1 }).option("--dry-run", descriptions.dryRun, { default: !1 }).option("--conflict <strategy>", descriptions.conflict, { default: "skip" }).option("--verbose", descriptions.verbose, { default: !1 }).example("buddy stack:install @stacksjs/blog").example("buddy stack:install blog --force").example("buddy stack:install blog --conflict backup --verbose").example("buddy stack:install blog --dry-run").action(async (name, options) => {
17
+ buddy.command("stack:install <name>", descriptions.install).option("--force", descriptions.force, { default: !1 }).option("--dry-run", descriptions.dryRun, { default: !1 }).option("--conflict <strategy>", descriptions.conflict, { default: "skip" }).option("-p, --project <path>", descriptions.project).option("--verbose", descriptions.verbose, { default: !1 }).example("buddy add calendar").example("buddy add table --force").example("buddy add calendar --conflict backup --verbose").example("buddy add table --dry-run").action(async (name, options) => {
17
18
  const perf = await intro("buddy stack:install");
18
19
  if (!name) {
19
20
  log.error("You need to specify a stack name.");
20
- log.info("Example: buddy stack:install @stacksjs/blog");
21
+ log.info("Example: buddy add calendar");
21
22
  process.exit(ExitCode.FatalError);
22
23
  }
23
24
  if (!await installStack({
@@ -25,6 +26,7 @@ export function stacks(buddy) {
25
26
  force: options.force,
26
27
  dryRun: options.dryRun,
27
28
  conflict: options.conflict || "skip",
29
+ project: options.project,
28
30
  verbose: options.verbose
29
31
  }) && !options.dryRun) {
30
32
  await outro("Failed to install stack", { startTime: perf, useSeconds: !0 });
@@ -33,7 +35,7 @@ export function stacks(buddy) {
33
35
  await outro(`Stack ${italic(name)} installed.`, { startTime: perf, useSeconds: !0 });
34
36
  process.exit(ExitCode.Success);
35
37
  });
36
- buddy.command("stack:uninstall <name>", descriptions.uninstall).option("--force", descriptions.force, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).example("buddy stack:uninstall blog").example("buddy stack:uninstall blog --force").action(async (name, options) => {
38
+ buddy.command("stack:uninstall <name>", descriptions.uninstall).option("--force", descriptions.force, { default: !1 }).option("-p, --project <path>", descriptions.project).option("--verbose", descriptions.verbose, { default: !1 }).example("buddy stack:uninstall blog").example("buddy stack:uninstall blog --force").action(async (name, options) => {
37
39
  const perf = await intro("buddy stack:uninstall");
38
40
  if (!name) {
39
41
  log.error("You need to specify a stack name.");
@@ -42,6 +44,7 @@ export function stacks(buddy) {
42
44
  if (!await uninstallStack({
43
45
  name,
44
46
  force: options.force,
47
+ project: options.project,
45
48
  verbose: options.verbose
46
49
  })) {
47
50
  await outro("Failed to uninstall stack", { startTime: perf, useSeconds: !0 });
@@ -50,10 +53,10 @@ export function stacks(buddy) {
50
53
  await outro(`Stack ${italic(name)} uninstalled.`, { startTime: perf, useSeconds: !0 });
51
54
  process.exit(ExitCode.Success);
52
55
  });
53
- buddy.command("stack:list", descriptions.list).alias("stack:ls").example("buddy stack:list").action(async () => {
54
- const perf = await intro("buddy stack:list"), entries = await listStacks();
56
+ buddy.command("stack:list", descriptions.list).alias("stack:ls").option("-p, --project <path>", descriptions.project).example("buddy stack:list").action(async (options) => {
57
+ const perf = await intro("buddy stack:list"), entries = await listStacks(options.project);
55
58
  if (entries.length === 0)
56
- log.info("No stacks found. Install one with: buddy stack:install <name>");
59
+ log.info("No stacks found. Install one with: buddy add <name>");
57
60
  else {
58
61
  log.info(`Found ${entries.length} stack(s):`);
59
62
  log.info("");
@@ -0,0 +1 @@
1
+ export declare function shouldSkipAppKeyCheck(requestedCommand: string, mode?: { isHelpFlag?: boolean, isHelpMode?: boolean }): boolean;
@@ -0,0 +1,35 @@
1
+ const APP_KEY_OPTIONAL_COMMANDS = [
2
+ "build",
3
+ "lint",
4
+ "lint:fix",
5
+ "test",
6
+ "test:types",
7
+ "test:unit",
8
+ "test:feature",
9
+ "typecheck",
10
+ "types:fix",
11
+ "types:generate",
12
+ "clean",
13
+ "fresh",
14
+ "about",
15
+ "doctor",
16
+ "list",
17
+ "setup",
18
+ "setup:ssl",
19
+ "setup:oh-my-zsh",
20
+ "deploy",
21
+ "serve",
22
+ "new",
23
+ "create",
24
+ "upgrade",
25
+ "update",
26
+ "migrate",
27
+ "seed",
28
+ "generate",
29
+ "make",
30
+ "key:generate",
31
+ "scaffold:crud"
32
+ ];
33
+ export function shouldSkipAppKeyCheck(requestedCommand, mode = {}) {
34
+ return Boolean(mode.isHelpFlag || mode.isHelpMode || APP_KEY_OPTIONAL_COMMANDS.some((command) => requestedCommand === command || requestedCommand.startsWith(`${command}:`)));
35
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/buddy",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.160",
5
+ "version": "0.70.162",
6
6
  "description": "Meet Buddy. The Stacks runtime.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -32,7 +32,7 @@
32
32
  "pwa",
33
33
  "modern",
34
34
  "library",
35
- "vue",
35
+ "stx",
36
36
  "web components",
37
37
  "typescript",
38
38
  "javascript",
@@ -92,52 +92,52 @@
92
92
  "prepublishOnly": "bun run build"
93
93
  },
94
94
  "dependencies": {
95
- "@stacksjs/actions": "^0.70.160",
96
- "@stacksjs/ai": "^0.70.160",
97
- "@stacksjs/alias": "^0.70.160",
98
- "@stacksjs/arrays": "^0.70.160",
99
- "@stacksjs/auth": "^0.70.160",
100
- "@stacksjs/build": "^0.70.160",
101
- "@stacksjs/cache": "^0.70.160",
102
- "@stacksjs/cli": "^0.70.160",
95
+ "@stacksjs/actions": "^0.70.162",
96
+ "@stacksjs/ai": "^0.70.162",
97
+ "@stacksjs/alias": "^0.70.162",
98
+ "@stacksjs/arrays": "^0.70.162",
99
+ "@stacksjs/auth": "^0.70.162",
100
+ "@stacksjs/build": "^0.70.162",
101
+ "@stacksjs/cache": "^0.70.162",
102
+ "@stacksjs/cli": "^0.70.162",
103
103
  "@stacksjs/clapp": "^0.2.12",
104
- "@stacksjs/cloud": "^0.70.160",
105
- "@stacksjs/collections": "^0.70.160",
106
- "@stacksjs/config": "^0.70.160",
107
- "@stacksjs/database": "^0.70.160",
108
- "@stacksjs/desktop": "^0.70.160",
109
- "@stacksjs/dns": "^0.70.160",
110
- "@stacksjs/email": "^0.70.160",
111
- "@stacksjs/enums": "^0.70.160",
112
- "@stacksjs/error-handling": "^0.70.160",
113
- "@stacksjs/events": "^0.70.160",
114
- "@stacksjs/git": "^0.70.160",
104
+ "@stacksjs/cloud": "^0.70.162",
105
+ "@stacksjs/collections": "^0.70.162",
106
+ "@stacksjs/config": "^0.70.162",
107
+ "@stacksjs/database": "^0.70.162",
108
+ "@stacksjs/desktop": "^0.70.162",
109
+ "@stacksjs/dns": "^0.70.162",
110
+ "@stacksjs/email": "^0.70.162",
111
+ "@stacksjs/enums": "^0.70.162",
112
+ "@stacksjs/error-handling": "^0.70.162",
113
+ "@stacksjs/events": "^0.70.162",
114
+ "@stacksjs/git": "^0.70.162",
115
115
  "@stacksjs/gitit": "^0.2.5",
116
- "@stacksjs/health": "^0.70.160",
116
+ "@stacksjs/health": "^0.70.162",
117
117
  "@stacksjs/dnsx": "^0.2.3",
118
118
  "@stacksjs/httx": "^0.1.10",
119
- "@stacksjs/lint": "^0.70.160",
120
- "@stacksjs/logging": "^0.70.160",
121
- "@stacksjs/notifications": "^0.70.160",
122
- "@stacksjs/objects": "^0.70.160",
123
- "@stacksjs/orm": "^0.70.160",
124
- "@stacksjs/path": "^0.70.160",
125
- "@stacksjs/payments": "^0.70.160",
126
- "@stacksjs/realtime": "^0.70.160",
127
- "@stacksjs/router": "^0.70.160",
119
+ "@stacksjs/lint": "^0.70.162",
120
+ "@stacksjs/logging": "^0.70.162",
121
+ "@stacksjs/notifications": "^0.70.162",
122
+ "@stacksjs/objects": "^0.70.162",
123
+ "@stacksjs/orm": "^0.70.162",
124
+ "@stacksjs/path": "^0.70.162",
125
+ "@stacksjs/payments": "^0.70.162",
126
+ "@stacksjs/realtime": "^0.70.162",
127
+ "@stacksjs/router": "^0.70.162",
128
128
  "@stacksjs/rpx": "^0.11.31",
129
- "@stacksjs/search-engine": "^0.70.160",
130
- "@stacksjs/security": "^0.70.160",
131
- "@stacksjs/server": "^0.70.160",
132
- "@stacksjs/storage": "^0.70.160",
133
- "@stacksjs/strings": "^0.70.160",
134
- "@stacksjs/testing": "^0.70.160",
135
- "@stacksjs/tunnel": "^0.70.160",
136
- "@stacksjs/types": "^0.70.160",
137
- "@stacksjs/ui": "^0.70.160",
138
- "@stacksjs/utils": "^0.70.160",
139
- "@stacksjs/validation": "^0.70.160",
140
- "@stacksjs/ts-cloud": "^0.7.49"
129
+ "@stacksjs/search-engine": "^0.70.162",
130
+ "@stacksjs/security": "^0.70.162",
131
+ "@stacksjs/server": "^0.70.162",
132
+ "@stacksjs/storage": "^0.70.162",
133
+ "@stacksjs/strings": "^0.70.162",
134
+ "@stacksjs/testing": "^0.70.162",
135
+ "@stacksjs/tunnel": "^0.70.162",
136
+ "@stacksjs/types": "^0.70.162",
137
+ "@stacksjs/ui": "^0.70.162",
138
+ "@stacksjs/utils": "^0.70.162",
139
+ "@stacksjs/validation": "^0.70.162",
140
+ "@stacksjs/ts-cloud": "^0.7.56"
141
141
  },
142
142
  "devDependencies": {
143
143
  "better-dx": "^0.2.17"