@stacksjs/buddy 0.70.88 → 0.70.90
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/dist/cli.d.ts +1 -0
- package/dist/cli.js +165 -0
- package/dist/commands/about.d.ts +2 -0
- package/dist/commands/about.js +35 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.js +33 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +68 -0
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/build.js +153 -0
- package/dist/commands/cd.d.ts +20 -0
- package/dist/commands/cd.js +39 -0
- package/dist/commands/changelog.d.ts +2 -0
- package/dist/commands/changelog.js +32 -0
- package/dist/commands/clean.d.ts +2 -0
- package/dist/commands/clean.js +37 -0
- package/dist/commands/cloud.d.ts +2 -0
- package/dist/commands/cloud.js +503 -0
- package/dist/commands/commit.d.ts +2 -0
- package/dist/commands/commit.js +16 -0
- package/dist/commands/completion.d.ts +2 -0
- package/dist/commands/completion.js +143 -0
- package/dist/commands/config-migrate.d.ts +26 -0
- package/dist/commands/config-migrate.js +94 -0
- package/dist/commands/configure.d.ts +2 -0
- package/dist/commands/configure.js +48 -0
- package/dist/commands/create.d.ts +2 -0
- package/dist/commands/create.js +141 -0
- package/dist/commands/deploy.d.ts +107 -0
- package/dist/commands/deploy.js +1439 -0
- package/dist/commands/dev.d.ts +10 -0
- package/dist/commands/dev.js +907 -0
- package/dist/commands/dns.d.ts +2 -0
- package/dist/commands/dns.js +102 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +285 -0
- package/dist/commands/domains.d.ts +2 -0
- package/dist/commands/domains.js +159 -0
- package/dist/commands/email.d.ts +2 -0
- package/dist/commands/email.js +524 -0
- package/dist/commands/env.d.ts +2 -0
- package/dist/commands/env.js +246 -0
- package/dist/commands/extension.d.ts +8 -0
- package/dist/commands/extension.js +78 -0
- package/dist/commands/features.d.ts +180 -0
- package/dist/commands/features.js +422 -0
- package/dist/commands/fresh.d.ts +2 -0
- package/dist/commands/fresh.js +39 -0
- package/dist/commands/generate.d.ts +2 -0
- package/dist/commands/generate.js +104 -0
- package/dist/commands/http.d.ts +2 -0
- package/dist/commands/http.js +33 -0
- package/dist/commands/index.d.ts +53 -0
- package/dist/commands/index.js +53 -0
- package/dist/commands/install.d.ts +2 -0
- package/dist/commands/install.js +22 -0
- package/dist/commands/key.d.ts +2 -0
- package/dist/commands/key.js +23 -0
- package/dist/commands/lint.d.ts +2 -0
- package/dist/commands/lint.js +46 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.js +108 -0
- package/dist/commands/mail.d.ts +2 -0
- package/dist/commands/mail.js +693 -0
- package/dist/commands/maintenance.d.ts +2 -0
- package/dist/commands/maintenance.js +141 -0
- package/dist/commands/make.d.ts +2 -0
- package/dist/commands/make.js +375 -0
- package/dist/commands/migrate-project.d.ts +2 -0
- package/dist/commands/migrate-project.js +49 -0
- package/dist/commands/migrate.d.ts +4 -0
- package/dist/commands/migrate.js +455 -0
- package/dist/commands/outdated.d.ts +2 -0
- package/dist/commands/outdated.js +19 -0
- package/dist/commands/package.d.ts +2 -0
- package/dist/commands/package.js +17 -0
- package/dist/commands/phone.d.ts +2 -0
- package/dist/commands/phone.js +188 -0
- package/dist/commands/ports.d.ts +2 -0
- package/dist/commands/ports.js +118 -0
- package/dist/commands/prepublish.d.ts +2 -0
- package/dist/commands/prepublish.js +17 -0
- package/dist/commands/projects.d.ts +2 -0
- package/dist/commands/projects.js +29 -0
- package/dist/commands/publish.d.ts +2 -0
- package/dist/commands/publish.js +172 -0
- package/dist/commands/queue.d.ts +2 -0
- package/dist/commands/queue.js +248 -0
- package/dist/commands/release.d.ts +2 -0
- package/dist/commands/release.js +30 -0
- package/dist/commands/route.d.ts +2 -0
- package/dist/commands/route.js +21 -0
- package/dist/commands/saas.d.ts +2 -0
- package/dist/commands/saas.js +25 -0
- package/dist/commands/schedule.d.ts +2 -0
- package/dist/commands/schedule.js +61 -0
- package/dist/commands/search.d.ts +2 -0
- package/dist/commands/search.js +84 -0
- package/dist/commands/seed.d.ts +2 -0
- package/dist/commands/seed.js +71 -0
- package/dist/commands/serve.d.ts +25 -0
- package/dist/commands/serve.js +182 -0
- package/dist/commands/setup.d.ts +12 -0
- package/dist/commands/setup.js +215 -0
- package/dist/commands/share.d.ts +2 -0
- package/dist/commands/share.js +214 -0
- package/dist/commands/sms.d.ts +2 -0
- package/dist/commands/sms.js +328 -0
- package/dist/commands/stacks.d.ts +2 -0
- package/dist/commands/stacks.js +69 -0
- package/dist/commands/telemetry.d.ts +2 -0
- package/dist/commands/telemetry.js +74 -0
- package/dist/commands/test.d.ts +2 -0
- package/dist/commands/test.js +130 -0
- package/dist/commands/tinker.d.ts +2 -0
- package/dist/commands/tinker.js +37 -0
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands/types.js +18 -0
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/upgrade.js +98 -0
- package/dist/commands/version.d.ts +2 -0
- package/dist/commands/version.js +16 -0
- package/dist/config.d.ts +43 -0
- package/dist/config.js +223 -0
- package/dist/custom-cli.d.ts +1 -0
- package/dist/custom-cli.js +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lazy-commands.d.ts +61 -0
- package/dist/lazy-commands.js +188 -0
- package/dist/migrators/index.d.ts +9 -0
- package/dist/migrators/index.js +62 -0
- package/dist/migrators/laravel/index.d.ts +2 -0
- package/dist/migrators/laravel/index.js +148 -0
- package/dist/migrators/laravel/migrations.d.ts +52 -0
- package/dist/migrators/laravel/migrations.js +232 -0
- package/dist/migrators/laravel/models.d.ts +34 -0
- package/dist/migrators/laravel/models.js +134 -0
- package/dist/migrators/rails/index.d.ts +2 -0
- package/dist/migrators/rails/index.js +11 -0
- package/dist/migrators/types.d.ts +44 -0
- package/dist/migrators/types.js +0 -0
- package/package.json +2 -2
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { cli, log } from "@stacksjs/cli";
|
|
4
|
+
import { path as p } from "@stacksjs/path";
|
|
5
|
+
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 = [
|
|
6
|
+
"build",
|
|
7
|
+
"lint",
|
|
8
|
+
"lint:fix",
|
|
9
|
+
"test",
|
|
10
|
+
"test:types",
|
|
11
|
+
"test:unit",
|
|
12
|
+
"test:feature",
|
|
13
|
+
"typecheck",
|
|
14
|
+
"types:fix",
|
|
15
|
+
"types:generate",
|
|
16
|
+
"clean",
|
|
17
|
+
"fresh",
|
|
18
|
+
"about",
|
|
19
|
+
"doctor",
|
|
20
|
+
"setup",
|
|
21
|
+
"setup:ssl",
|
|
22
|
+
"setup:oh-my-zsh",
|
|
23
|
+
"deploy",
|
|
24
|
+
"serve",
|
|
25
|
+
"new",
|
|
26
|
+
"create",
|
|
27
|
+
"migrate",
|
|
28
|
+
"seed",
|
|
29
|
+
"generate",
|
|
30
|
+
"make",
|
|
31
|
+
"key:generate",
|
|
32
|
+
"scaffold:crud"
|
|
33
|
+
].some((cmd) => requestedCommand === cmd || requestedCommand.startsWith(`${cmd}:`)) || isHelpFlag || isHelpMode, needsFullSetup = !isVersionOnly;
|
|
34
|
+
if (needsFullSetup) {
|
|
35
|
+
const reportFatal = (label, error) => {
|
|
36
|
+
log.debug(`Buddy ${label}`);
|
|
37
|
+
try {
|
|
38
|
+
process.stderr.write(`
|
|
39
|
+
[buddy] ${label}: ${error?.stack ?? String(error)}
|
|
40
|
+
`);
|
|
41
|
+
} catch {}
|
|
42
|
+
log.error(error);
|
|
43
|
+
return process.exit(1);
|
|
44
|
+
};
|
|
45
|
+
process.on("uncaughtException", (error) => reportFatal("uncaughtException", error));
|
|
46
|
+
process.on("unhandledRejection", (error) => reportFatal("unhandledRejection", error));
|
|
47
|
+
}
|
|
48
|
+
async function main() {
|
|
49
|
+
const buddy = cli("buddy"), configPath = "./buddy.config.js";
|
|
50
|
+
try {
|
|
51
|
+
await Bun.file(configPath).text();
|
|
52
|
+
const { applyBuddyConfig } = await import("./config.js");
|
|
53
|
+
await applyBuddyConfig(buddy);
|
|
54
|
+
} catch {}
|
|
55
|
+
if (needsFullSetup) {
|
|
56
|
+
const { loadCommands, getCommandsToLoad, markLoaded } = await import("./lazy-commands.js"), { setup } = await import("./commands/setup.js");
|
|
57
|
+
setup(buddy);
|
|
58
|
+
markLoaded(buddy, "setup");
|
|
59
|
+
if (!skipAppKeyCheck) {
|
|
60
|
+
const { runAction } = await import("@stacksjs/actions"), { Action } = await import("@stacksjs/enums"), { ensureProjectIsInitialized } = await import("@stacksjs/utils");
|
|
61
|
+
if (!await ensureProjectIsInitialized()) {
|
|
62
|
+
log.info("Your `APP_KEY` is not yet set");
|
|
63
|
+
log.info("Generating application key...");
|
|
64
|
+
const result = await runAction(Action.KeyGenerate);
|
|
65
|
+
if (result.isErr) {
|
|
66
|
+
log.error("Failed to set random application key.", result.error);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const commandsToLoad = getCommandsToLoad(args);
|
|
72
|
+
await loadCommands(commandsToLoad, buddy);
|
|
73
|
+
await dynamicImports(buddy);
|
|
74
|
+
} else {
|
|
75
|
+
const { loadCommand } = await import("./lazy-commands.js");
|
|
76
|
+
await loadCommand("version", buddy);
|
|
77
|
+
}
|
|
78
|
+
buddy.help();
|
|
79
|
+
if (args.length === 0 && process.stdin.isTTY && !buddy.isNoInteraction)
|
|
80
|
+
await showInteractiveMenu(buddy);
|
|
81
|
+
else
|
|
82
|
+
buddy.parse();
|
|
83
|
+
}
|
|
84
|
+
async function showInteractiveMenu(buddy) {
|
|
85
|
+
const { bold, green, intro } = await import("@stacksjs/cli"), { select } = await import("@stacksjs/cli");
|
|
86
|
+
await intro("buddy");
|
|
87
|
+
console.log(bold(green("What would you like to do?")));
|
|
88
|
+
console.log("");
|
|
89
|
+
const choice = await select({
|
|
90
|
+
message: "Select a command:",
|
|
91
|
+
choices: [
|
|
92
|
+
{ value: "dev", label: "Start development server" },
|
|
93
|
+
{ value: "build", label: "Build for production" },
|
|
94
|
+
{ value: "test", label: "Run tests" },
|
|
95
|
+
{ value: "list", label: "List all commands" },
|
|
96
|
+
{ value: "doctor", label: "Run health checks" },
|
|
97
|
+
{ value: "about", label: "Show system information" },
|
|
98
|
+
{ value: "help", label: "Show help" },
|
|
99
|
+
{ value: "exit", label: "Exit" }
|
|
100
|
+
],
|
|
101
|
+
initial: 0
|
|
102
|
+
});
|
|
103
|
+
console.log("");
|
|
104
|
+
if (choice === "exit")
|
|
105
|
+
process.exit(0);
|
|
106
|
+
else if (choice === "help")
|
|
107
|
+
buddy.outputHelp();
|
|
108
|
+
else {
|
|
109
|
+
process.argv = ["bun", "buddy", choice];
|
|
110
|
+
buddy.parse();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
await main();
|
|
114
|
+
async function dynamicImports(buddy) {
|
|
115
|
+
const { fs } = await import("@stacksjs/storage"), commandsDir = p.appPath("Commands");
|
|
116
|
+
try {
|
|
117
|
+
const registry = (await import(p.appPath("Commands.ts"))).default || {};
|
|
118
|
+
for (const [signature, config] of Object.entries(registry)) {
|
|
119
|
+
const commandConfig = typeof config === "string" ? { file: config, enabled: !0 } : config;
|
|
120
|
+
if (commandConfig.enabled === !1)
|
|
121
|
+
continue;
|
|
122
|
+
const commandPath = `${commandsDir}/${commandConfig.file}.ts`;
|
|
123
|
+
if (!fs.existsSync(commandPath)) {
|
|
124
|
+
log.debug(`Command file not found: ${commandPath} (registered as '${signature}')`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const dynamicImport = await import(commandPath);
|
|
129
|
+
if (typeof dynamicImport.default === "function") {
|
|
130
|
+
dynamicImport.default(buddy);
|
|
131
|
+
if (commandConfig.aliases && Array.isArray(commandConfig.aliases))
|
|
132
|
+
for (const alias of commandConfig.aliases)
|
|
133
|
+
buddy.alias(signature, alias);
|
|
134
|
+
} else
|
|
135
|
+
log.error(`Expected a default export function in ${commandConfig.file}.ts, but got:`, dynamicImport.default);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
log.error(`Failed to load command ${commandConfig.file}:`, error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} catch {
|
|
141
|
+
if (!fs.existsSync(commandsDir)) {
|
|
142
|
+
log.debug("app/Commands directory not found, skipping user commands");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
log.debug("Commands.ts not found, using auto-discovery");
|
|
146
|
+
const commandFiles = fs.readdirSync(commandsDir).filter((file) => file.endsWith(".ts"));
|
|
147
|
+
for (const file of commandFiles) {
|
|
148
|
+
const commandPath = `${commandsDir}/${file}`;
|
|
149
|
+
try {
|
|
150
|
+
const dynamicImport = await import(commandPath);
|
|
151
|
+
if (typeof dynamicImport.default === "function")
|
|
152
|
+
dynamicImport.default(buddy);
|
|
153
|
+
else
|
|
154
|
+
log.debug(`Skipping ${file} \u2014 no default export function`);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
log.error(`Failed to load command ${file}:`, error);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const listenerImport = await import(p.listenersPath("Console.ts"));
|
|
162
|
+
if (typeof listenerImport.default === "function")
|
|
163
|
+
listenerImport.default(buddy);
|
|
164
|
+
} catch {}
|
|
165
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { bold, dim, green, intro, log, onUnknownSubcommand } from "@stacksjs/cli";
|
|
3
|
+
import { storage } from "@stacksjs/storage";
|
|
4
|
+
export function about(buddy) {
|
|
5
|
+
buddy.command("about", "Display diagnostic information about Stacks").action(async () => {
|
|
6
|
+
log.debug("Running `buddy about` ...");
|
|
7
|
+
await intro("buddy about");
|
|
8
|
+
try {
|
|
9
|
+
const stacksVersion = (await storage.readPackageJson("./package.json")).version || "unknown", bunVersion = process.versions.bun || "N/A", nodeVersion = process.versions.node || "N/A", os = process.platform, arch = process.arch, osVersion = process.version, env = process.env.NODE_ENV || process.env.APP_ENV || "development";
|
|
10
|
+
log.info("");
|
|
11
|
+
log.info(green(bold("Stacks Framework")));
|
|
12
|
+
log.info(dim("\u2500".repeat(50)));
|
|
13
|
+
log.info("");
|
|
14
|
+
log.info(bold("Version Information:"));
|
|
15
|
+
log.info(` Stacks: ${dim(stacksVersion)}`);
|
|
16
|
+
log.info(` Bun: ${dim(bunVersion)}`);
|
|
17
|
+
if (nodeVersion !== "N/A")
|
|
18
|
+
log.info(` Node: ${dim(nodeVersion)}`);
|
|
19
|
+
log.info("");
|
|
20
|
+
log.info(bold("Environment:"));
|
|
21
|
+
log.info(` Mode: ${dim(env)}`);
|
|
22
|
+
log.info(` OS: ${dim(`${os} ${arch}`)}`);
|
|
23
|
+
log.info(` Runtime: ${dim(osVersion)}`);
|
|
24
|
+
log.info("");
|
|
25
|
+
log.info(bold("Configuration:"));
|
|
26
|
+
log.info(` Cache: ${dim("file")}`);
|
|
27
|
+
log.info(` Debug: ${dim(process.env.DEBUG ? "enabled" : "disabled")}`);
|
|
28
|
+
log.info("");
|
|
29
|
+
} catch (error) {
|
|
30
|
+
log.error("Failed to retrieve system information:", error);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
onUnknownSubcommand(buddy, "about");
|
|
35
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { runAdd } from "@stacksjs/actions";
|
|
3
|
+
import { log } from "@stacksjs/logging";
|
|
4
|
+
import { ExitCode } from "@stacksjs/types";
|
|
5
|
+
import { onUnknownSubcommand } from "@stacksjs/cli";
|
|
6
|
+
export function add(buddy) {
|
|
7
|
+
const descriptions = {
|
|
8
|
+
add: "Add a stack to your project (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);
|
|
21
|
+
process.exit(ExitCode.Success);
|
|
22
|
+
});
|
|
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
|
+
onUnknownSubcommand(buddy, "add");
|
|
30
|
+
}
|
|
31
|
+
function hasNoOptions(options) {
|
|
32
|
+
return !options.all && !options.table && !options.calendar;
|
|
33
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { runAction } from "@stacksjs/actions";
|
|
3
|
+
import { intro, log, onUnknownSubcommand, outro } from "@stacksjs/cli";
|
|
4
|
+
import { Action } from "@stacksjs/enums";
|
|
5
|
+
import { ExitCode } from "@stacksjs/types";
|
|
6
|
+
export function auth(buddy) {
|
|
7
|
+
const descriptions = {
|
|
8
|
+
setup: "Set up authentication (migrations + personal access client)",
|
|
9
|
+
token: "Create a personal access client token",
|
|
10
|
+
client: "Create a new OAuth client",
|
|
11
|
+
prune: "Prune expired and revoked tokens",
|
|
12
|
+
project: "Target a specific project",
|
|
13
|
+
verbose: "Enable verbose output"
|
|
14
|
+
};
|
|
15
|
+
buddy.command("auth:setup", descriptions.setup).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
16
|
+
log.debug("Running `buddy auth:setup` ...", options);
|
|
17
|
+
const perf = await intro("buddy auth:setup"), result = await runAction(Action.AuthSetup, options);
|
|
18
|
+
if (result.isErr) {
|
|
19
|
+
await outro("While setting up authentication, there was an issue", { startTime: perf, useSeconds: !0 }, result.error);
|
|
20
|
+
process.exit(ExitCode.FatalError);
|
|
21
|
+
}
|
|
22
|
+
await outro("Authentication setup completed successfully.", {
|
|
23
|
+
startTime: perf,
|
|
24
|
+
useSeconds: !0
|
|
25
|
+
});
|
|
26
|
+
process.exit(ExitCode.Success);
|
|
27
|
+
});
|
|
28
|
+
buddy.command("auth:token", descriptions.token).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
29
|
+
log.debug("Running `buddy auth:token` ...", options);
|
|
30
|
+
const perf = await intro("buddy auth:token"), result = await runAction(Action.CreatePersonalAccessClient, options);
|
|
31
|
+
if (result.isErr) {
|
|
32
|
+
await outro("While creating the personal access client token, there was an issue", { startTime: perf, useSeconds: !0 }, result.error);
|
|
33
|
+
process.exit(ExitCode.FatalError);
|
|
34
|
+
}
|
|
35
|
+
await outro("Personal access client token created successfully.", {
|
|
36
|
+
startTime: perf,
|
|
37
|
+
useSeconds: !0
|
|
38
|
+
});
|
|
39
|
+
process.exit(ExitCode.Success);
|
|
40
|
+
});
|
|
41
|
+
buddy.command("auth:client", descriptions.client).option("-n, --name [name]", "Client name", { default: "OAuth Client" }).option("-r, --redirect [redirect]", "Redirect URI", { default: "http://localhost" }).option("--personal", "Create a personal access client", { default: !1 }).option("--password", "Create a password grant client", { default: !1 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
42
|
+
log.debug("Running `buddy auth:client` ...", options);
|
|
43
|
+
const perf = await intro("buddy auth:client"), result = await runAction(Action.AuthClient, options);
|
|
44
|
+
if (result.isErr) {
|
|
45
|
+
await outro("While creating the OAuth client, there was an issue", { startTime: perf, useSeconds: !0 }, result.error);
|
|
46
|
+
process.exit(ExitCode.FatalError);
|
|
47
|
+
}
|
|
48
|
+
await outro("OAuth client created successfully.", {
|
|
49
|
+
startTime: perf,
|
|
50
|
+
useSeconds: !0
|
|
51
|
+
});
|
|
52
|
+
process.exit(ExitCode.Success);
|
|
53
|
+
});
|
|
54
|
+
buddy.command("auth:prune", descriptions.prune).option("--expired", "Prune expired tokens (default: true)", { default: !0 }).option("--revoked", "Prune revoked tokens (default: true)", { default: !0 }).option("-d, --days [days]", "Prune revoked tokens older than N days", { default: 7 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
55
|
+
log.debug("Running `buddy auth:prune` ...", options);
|
|
56
|
+
const perf = await intro("buddy auth:prune"), result = await runAction(Action.AuthPrune, options);
|
|
57
|
+
if (result.isErr) {
|
|
58
|
+
await outro("While pruning tokens, there was an issue", { startTime: perf, useSeconds: !0 }, result.error);
|
|
59
|
+
process.exit(ExitCode.FatalError);
|
|
60
|
+
}
|
|
61
|
+
await outro("Token pruning completed successfully.", {
|
|
62
|
+
startTime: perf,
|
|
63
|
+
useSeconds: !0
|
|
64
|
+
});
|
|
65
|
+
process.exit(ExitCode.Success);
|
|
66
|
+
});
|
|
67
|
+
onUnknownSubcommand(buddy, "auth");
|
|
68
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { intro, log, onUnknownSubcommand, outro } from "@stacksjs/cli";
|
|
3
|
+
import { Action } from "@stacksjs/enums";
|
|
4
|
+
import { ExitCode } from "@stacksjs/types";
|
|
5
|
+
let _runAction;
|
|
6
|
+
async function runAction(...args) {
|
|
7
|
+
if (!_runAction)
|
|
8
|
+
_runAction = (await import("@stacksjs/actions")).runAction;
|
|
9
|
+
return _runAction(...args);
|
|
10
|
+
}
|
|
11
|
+
export function build(buddy) {
|
|
12
|
+
const descriptions = {
|
|
13
|
+
build: "Build any of your libraries (packages) for production use",
|
|
14
|
+
components: "Build your component library",
|
|
15
|
+
webComponents: "Build your framework agnostic web component library",
|
|
16
|
+
elements: "An alias to the -w flag",
|
|
17
|
+
buddy: "Build the Buddy binary",
|
|
18
|
+
functions: "Build your function library",
|
|
19
|
+
desktop: "Build the Desktop Application",
|
|
20
|
+
pages: "Build your frontend",
|
|
21
|
+
docs: "Build your documentation",
|
|
22
|
+
framework: "Build Stacks framework",
|
|
23
|
+
cli: "Automagically build the CLI",
|
|
24
|
+
server: "Build the Stacks cloud server (Docker image)",
|
|
25
|
+
frontendStatic: "Build the prerendered marketing/public static site (storage/framework/frontend-dist)",
|
|
26
|
+
select: "What are you trying to build?",
|
|
27
|
+
project: "Target a specific project",
|
|
28
|
+
verbose: "Enable verbose output"
|
|
29
|
+
};
|
|
30
|
+
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
|
+
log.debug("Running `buddy build` ...", options);
|
|
32
|
+
switch (server) {
|
|
33
|
+
case "components":
|
|
34
|
+
options.components = !0;
|
|
35
|
+
break;
|
|
36
|
+
case "web-components":
|
|
37
|
+
options.webComponents = !0;
|
|
38
|
+
break;
|
|
39
|
+
case "functions":
|
|
40
|
+
options.functions = !0;
|
|
41
|
+
break;
|
|
42
|
+
case "views":
|
|
43
|
+
options.views = !0;
|
|
44
|
+
break;
|
|
45
|
+
case "docs":
|
|
46
|
+
options.docs = !0;
|
|
47
|
+
break;
|
|
48
|
+
case "buddy":
|
|
49
|
+
options.buddy = !0;
|
|
50
|
+
break;
|
|
51
|
+
case "cli":
|
|
52
|
+
options.buddy = !0;
|
|
53
|
+
break;
|
|
54
|
+
case "stacks":
|
|
55
|
+
options.stacks = !0;
|
|
56
|
+
break;
|
|
57
|
+
case "server":
|
|
58
|
+
options.server = !0;
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
if (hasNoOptions(options))
|
|
64
|
+
options.stacks = !0;
|
|
65
|
+
if (options.docs)
|
|
66
|
+
await runAction(Action.BuildDocs);
|
|
67
|
+
if (options.components)
|
|
68
|
+
await runAction(Action.BuildComponentLibs);
|
|
69
|
+
if (options.webComponents)
|
|
70
|
+
await runAction(Action.BuildWebComponentLib);
|
|
71
|
+
if (options.functions)
|
|
72
|
+
await runAction(Action.BuildFunctionLib);
|
|
73
|
+
if (options.views)
|
|
74
|
+
await runAction(Action.BuildViews);
|
|
75
|
+
if (options.stacks)
|
|
76
|
+
await runAction(Action.BuildStacks);
|
|
77
|
+
if (options.buddy)
|
|
78
|
+
await runAction(Action.BuildCli);
|
|
79
|
+
if (options.server)
|
|
80
|
+
await runAction(Action.BuildServer);
|
|
81
|
+
process.exit(ExitCode.Success);
|
|
82
|
+
});
|
|
83
|
+
buddy.command("build:components", "Automagically build component libraries for production use & npm/CDN distribution").alias("prod:components").option("-c, --components", descriptions.components, { default: !0 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
84
|
+
log.debug("Running `buddy build:components` ...", options);
|
|
85
|
+
await runAction(Action.BuildComponentLibs, options);
|
|
86
|
+
});
|
|
87
|
+
buddy.command("build:cli", descriptions.cli).alias("prod:cli").option("-b, --buddy", descriptions.buddy, { default: !0 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
88
|
+
log.debug("Running `buddy build:cli` ...", options);
|
|
89
|
+
await runAction(Action.BuildCli, options);
|
|
90
|
+
});
|
|
91
|
+
buddy.command("build:server", descriptions.server).alias("prod:server").alias("build:docker").option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
92
|
+
log.debug("Running `buddy build:server` ...", options);
|
|
93
|
+
await runAction(Action.BuildServer, options);
|
|
94
|
+
});
|
|
95
|
+
buddy.command("build:functions", "Automagically build function library for npm/CDN distribution").option("-f, --functions", descriptions.functions, { default: !0 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
96
|
+
log.debug("Running `buddy build:functions` ...", options);
|
|
97
|
+
await runAction(Action.BuildFunctionLib, options);
|
|
98
|
+
});
|
|
99
|
+
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, {
|
|
100
|
+
default: !0
|
|
101
|
+
}).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
102
|
+
log.debug("Running `buddy build:web-components` ...", options);
|
|
103
|
+
await runAction(Action.BuildWebComponentLib, options);
|
|
104
|
+
});
|
|
105
|
+
buddy.command("build:frontend", descriptions.pages).alias("build:pages").alias("build:views").alias("prod:frontend").option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
106
|
+
log.debug("Running `buddy build:frontend` ...", options);
|
|
107
|
+
await runAction(Action.BuildViews, options);
|
|
108
|
+
});
|
|
109
|
+
buddy.command("build:docs", "Automagically build your documentation site.").alias("prod:docs").alias("build:documentation").alias("prod:documentation").option("-d, --docs", descriptions.docs, { default: !0 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
110
|
+
log.debug("Running `buddy build:docs` ...", options);
|
|
111
|
+
await runAction(Action.BuildDocs, options);
|
|
112
|
+
});
|
|
113
|
+
buddy.command("build:frontend-static", descriptions.frontendStatic).alias("build:public").alias("prod:frontend-static").option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
114
|
+
log.debug("Running `buddy build:frontend-static` ...", options);
|
|
115
|
+
await runAction(Action.BuildFrontendStatic, options);
|
|
116
|
+
});
|
|
117
|
+
buddy.command("build:core", "Automagically build the Stacks core.").option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
118
|
+
log.debug("Running `buddy build:core` ...", options);
|
|
119
|
+
const startTime = await intro("buddy build:core"), result = await runAction(Action.BuildCore, options);
|
|
120
|
+
if (result.isErr) {
|
|
121
|
+
log.error("Failed to build the Stacks core.", result.error);
|
|
122
|
+
process.exit(ExitCode.FatalError);
|
|
123
|
+
}
|
|
124
|
+
await outro("Core packages built successfully", {
|
|
125
|
+
startTime,
|
|
126
|
+
useSeconds: !0
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
buddy.command("build:desktop", descriptions.desktop).alias("prod:desktop").option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
130
|
+
log.debug("Running `buddy build:desktop` ...", options);
|
|
131
|
+
const perf = await intro("buddy build:desktop"), result = await runAction(Action.BuildDesktop, options);
|
|
132
|
+
if (result.isErr) {
|
|
133
|
+
await outro("While running the build:desktop command, there was an issue", { startTime: perf, useSeconds: !0 }, result.error);
|
|
134
|
+
process.exit(ExitCode.FatalError);
|
|
135
|
+
}
|
|
136
|
+
console.log("");
|
|
137
|
+
await outro("Exited", { startTime: perf, useSeconds: !0 });
|
|
138
|
+
process.exit(ExitCode.Success);
|
|
139
|
+
});
|
|
140
|
+
buddy.command("build:stacks", "Build the Stacks framework.").option("-s, --stacks", descriptions.framework, { default: !0 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
141
|
+
log.debug("Running `buddy build:stacks` ...", options);
|
|
142
|
+
const startTime = await intro("buddy build:stacks"), result = await runAction(Action.BuildStacks, options);
|
|
143
|
+
if (result.isErr) {
|
|
144
|
+
log.error("Failed to build Stacks.", result.error);
|
|
145
|
+
process.exit(ExitCode.FatalError);
|
|
146
|
+
}
|
|
147
|
+
await outro("Stacks built successfully", { startTime, useSeconds: !0 });
|
|
148
|
+
});
|
|
149
|
+
onUnknownSubcommand(buddy, "build");
|
|
150
|
+
}
|
|
151
|
+
function hasNoOptions(options) {
|
|
152
|
+
return !options.components && !options.webComponents && !options.elements && !options.functions && !options.views && !options.docs && !options.stacks && !options.buddy && !options.server;
|
|
153
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CLI } from '@stacksjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* `buddy cd <name>` — resolve the absolute path of a Stacks project by name.
|
|
4
|
+
*
|
|
5
|
+
* A child process can't mutate its parent shell's cwd, so this command
|
|
6
|
+
* prints the resolved path to stdout rather than calling `chdir()`. Users
|
|
7
|
+
* who want true `cd` behavior add a shell wrapper to their rc:
|
|
8
|
+
*
|
|
9
|
+
* bcd() { eval "$(buddy cd "$1" --eval)"; }
|
|
10
|
+
*
|
|
11
|
+
* Then `bcd my-project` actually changes the shell's directory.
|
|
12
|
+
*
|
|
13
|
+
* The underlying scan (`findStacksProjects`) excludes `~/Documents`,
|
|
14
|
+
* `~/Library`, `~/Pictures`, `~/.Trash` by default. Users with projects
|
|
15
|
+
* outside `~/` can point the scan at a specific root via `--root <dir>`
|
|
16
|
+
* or the `STACKS_PROJECTS_ROOT` env var.
|
|
17
|
+
*
|
|
18
|
+
* stacksjs/stacks#527.
|
|
19
|
+
*/
|
|
20
|
+
export declare function cd(buddy: CLI): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { ExitCode } from "@stacksjs/types";
|
|
4
|
+
import { findStacksProjects } from "@stacksjs/utils";
|
|
5
|
+
export function cd(buddy) {
|
|
6
|
+
buddy.command("cd [name]", "Print the absolute path of a Stacks project by name").option("--eval", 'Emit `cd "path"` instead of just the path \u2014 pair with `eval "$(buddy cd <name> --eval)"` for real shell-cd', { default: !1 }).option("--root <dir>", "Search root for the project scan (overrides STACKS_PROJECTS_ROOT and the home-dir default)").option("--verbose", "Enable verbose output", { default: !1 }).action(async (name, options) => {
|
|
7
|
+
if (!name) {
|
|
8
|
+
process.stderr.write(`Usage: buddy cd <project-name> [--eval] [--root <dir>]
|
|
9
|
+
`);
|
|
10
|
+
process.stderr.write('Tip: add `bcd() { eval "$(buddy cd "$1" --eval)"; }` to your shell rc to make this act like a real `cd`.\n');
|
|
11
|
+
process.exit(ExitCode.FatalError);
|
|
12
|
+
}
|
|
13
|
+
const root = options.root ?? process.env.STACKS_PROJECTS_ROOT ?? void 0, projects = await findStacksProjects(root, { quiet: !0 }), needle = name.toLowerCase(), exact = projects.filter((p) => basename(p).toLowerCase() === needle), matches = exact.length > 0 ? exact : projects.filter((p) => basename(p).toLowerCase().includes(needle));
|
|
14
|
+
if (matches.length === 0) {
|
|
15
|
+
process.stderr.write(`No Stacks project matched: ${name}
|
|
16
|
+
`);
|
|
17
|
+
if (!root)
|
|
18
|
+
process.stderr.write(`(Scanned home dir, excluding ~/Documents, ~/Library, ~/Pictures, ~/.Trash. Set STACKS_PROJECTS_ROOT or pass --root <dir> to scan elsewhere.)
|
|
19
|
+
`);
|
|
20
|
+
process.exit(ExitCode.FatalError);
|
|
21
|
+
}
|
|
22
|
+
if (matches.length > 1) {
|
|
23
|
+
process.stderr.write(`Ambiguous project name "${name}". Matches:
|
|
24
|
+
`);
|
|
25
|
+
for (const m of matches)
|
|
26
|
+
process.stderr.write(` - ${basename(m)} \u2192 ${m}
|
|
27
|
+
`);
|
|
28
|
+
process.exit(ExitCode.FatalError);
|
|
29
|
+
}
|
|
30
|
+
const dest = matches[0];
|
|
31
|
+
if (options.eval)
|
|
32
|
+
process.stdout.write(`cd ${JSON.stringify(dest)}
|
|
33
|
+
`);
|
|
34
|
+
else
|
|
35
|
+
process.stdout.write(`${dest}
|
|
36
|
+
`);
|
|
37
|
+
process.exit(ExitCode.Success);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { runAction } from "@stacksjs/actions";
|
|
3
|
+
import { intro, log, onUnknownSubcommand, outro } from "@stacksjs/cli";
|
|
4
|
+
import { Action } from "@stacksjs/enums";
|
|
5
|
+
import { ExitCode } from "@stacksjs/types";
|
|
6
|
+
export function changelog(buddy) {
|
|
7
|
+
const descriptions = {
|
|
8
|
+
changelog: "Create a CHANGELOG.md file",
|
|
9
|
+
quiet: "Minimal output",
|
|
10
|
+
dryRun: "Do not write the file, just output the changes",
|
|
11
|
+
from: "Start git revision for generated changelog",
|
|
12
|
+
project: "Target a specific project",
|
|
13
|
+
to: "End git revision for generated changelog",
|
|
14
|
+
verbose: "Enable verbose output",
|
|
15
|
+
version: "Version heading to use for the generated changelog entry"
|
|
16
|
+
};
|
|
17
|
+
buddy.command("changelog", descriptions.changelog).option("-q, --quiet", descriptions.quiet, { default: !1 }).option("-d, --dry-run", descriptions.dryRun, { default: !1 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--from <revision>", descriptions.from).option("--to <revision>", descriptions.to).option("--version <version>", descriptions.version).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
18
|
+
log.debug("Running `buddy changelog` ...", options);
|
|
19
|
+
const perf = await intro("buddy changelog"), result = await runAction(Action.Changelog, options);
|
|
20
|
+
if (result.isErr) {
|
|
21
|
+
await outro("While running the changelog command, there was an issue", { ...options, startTime: perf, useSeconds: !0 }, result.error);
|
|
22
|
+
process.exit(ExitCode.FatalError);
|
|
23
|
+
}
|
|
24
|
+
await outro("Generated CHANGELOG.md", {
|
|
25
|
+
...options,
|
|
26
|
+
startTime: perf,
|
|
27
|
+
useSeconds: !0,
|
|
28
|
+
type: "success"
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
onUnknownSubcommand(buddy, "changelog");
|
|
32
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { runAction } from "@stacksjs/actions";
|
|
3
|
+
import { intro, log, onUnknownSubcommand, outro } from "@stacksjs/cli";
|
|
4
|
+
import { Action } from "@stacksjs/enums";
|
|
5
|
+
import { ExitCode } from "@stacksjs/types";
|
|
6
|
+
export function clean(buddy) {
|
|
7
|
+
const descriptions = {
|
|
8
|
+
clean: "Removes all node_modules & lock files",
|
|
9
|
+
project: "Target a specific project",
|
|
10
|
+
verbose: "Enable verbose output"
|
|
11
|
+
};
|
|
12
|
+
buddy.command("clean", descriptions.clean).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
|
|
13
|
+
log.debug("Running `buddy clean` ...", options);
|
|
14
|
+
if (!buddy.isForce && !buddy.isNoInteraction) {
|
|
15
|
+
const { confirm } = await import("@stacksjs/cli");
|
|
16
|
+
if (!await confirm({
|
|
17
|
+
message: "This will remove all node_modules and lock files. Continue?",
|
|
18
|
+
initial: !1
|
|
19
|
+
})) {
|
|
20
|
+
log.info("Clean cancelled");
|
|
21
|
+
process.exit(ExitCode.Success);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const perf = await intro("buddy clean"), result = await runAction(Action.Clean, options);
|
|
25
|
+
if (result.isErr) {
|
|
26
|
+
await outro("While running the clean command, there was an issue", { startTime: perf, useSeconds: !0 }, result.error);
|
|
27
|
+
process.exit(ExitCode.FatalError);
|
|
28
|
+
}
|
|
29
|
+
await outro("Cleaned up", {
|
|
30
|
+
startTime: perf,
|
|
31
|
+
useSeconds: !0,
|
|
32
|
+
message: "Cleaned up"
|
|
33
|
+
});
|
|
34
|
+
process.exit(ExitCode.Success);
|
|
35
|
+
});
|
|
36
|
+
onUnknownSubcommand(buddy, "clean");
|
|
37
|
+
}
|