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