@stacksjs/buddy 0.58.72 → 0.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-94f0ae38d2d27d78.js → chunk-32440b2561f1e29c.js} +568 -485
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +44 -613
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/changelog.d.ts +2 -0
- package/dist/commands/clean.d.ts +2 -0
- package/dist/commands/cloud.d.ts +2 -0
- package/dist/commands/commit.d.ts +2 -0
- package/dist/commands/configure.d.ts +2 -0
- package/dist/commands/create.d.ts +2 -0
- package/dist/commands/deploy.d.ts +2 -0
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dns.d.ts +2 -0
- package/dist/commands/domains.d.ts +2 -0
- package/dist/commands/fresh.d.ts +2 -0
- package/dist/commands/generate.d.ts +2 -0
- package/dist/commands/http.d.ts +2 -0
- package/dist/commands/index.d.ts +31 -0
- package/dist/commands/install.d.ts +2 -0
- package/dist/commands/key.d.ts +2 -0
- package/dist/commands/lint.d.ts +2 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/make.d.ts +2 -0
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/ports.d.ts +2 -0
- package/dist/commands/prepublish.d.ts +2 -0
- package/dist/commands/projects.d.ts +2 -0
- package/dist/commands/release.d.ts +2 -0
- package/dist/commands/seed.d.ts +2 -0
- package/dist/commands/setup.d.ts +4 -0
- package/dist/commands/test.d.ts +2 -0
- package/dist/commands/tinker.d.ts +2 -0
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/version.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -3
- package/dist/stacks +0 -0
- package/package.json +3 -5
- package/src/cli.ts +36 -31
- package/src/commands/add.ts +1 -1
- package/src/commands/commit.ts +1 -1
- package/src/commands/create.ts +6 -0
- package/src/commands/deploy.ts +1 -1
- package/src/commands/dev.ts +1 -3
- package/src/commands/generate.ts +10 -0
- package/src/commands/index.ts +2 -0
- package/src/commands/key.ts +1 -1
- package/src/commands/list.ts +1 -1
- package/src/commands/make.ts +28 -2
- package/src/commands/ports.ts +180 -0
- package/src/commands/prepublish.ts +1 -1
- package/src/commands/projects.ts +58 -0
- package/src/commands/setup.ts +8 -54
- package/src/commands/types.ts +1 -1
- package/src/commands/upgrade.ts +51 -4
- package/dist/chunk-59a9de11428ba763.js +0 -993
- /package/dist/{chunk-0455e53fab4244b1.js → chunk-970e033f764e29fc.js} +0 -0
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createConsola
|
|
3
|
-
} from "./chunk-59a9de11428ba763.js";
|
|
4
|
-
|
|
5
1
|
// src/commands/build.ts
|
|
6
2
|
import process from "process";
|
|
7
|
-
import {runAction} from "@stacksjs/actions";
|
|
3
|
+
import {runAction as runAction2} from "@stacksjs/actions";
|
|
8
4
|
import {intro, log, outro} from "@stacksjs/cli";
|
|
9
5
|
import {ExitCode} from "@stacksjs/types";
|
|
10
6
|
import {Action} from "@stacksjs/enums";
|
|
@@ -79,41 +75,41 @@ function build(buddy) {
|
|
|
79
75
|
answers = [answers];
|
|
80
76
|
options = answers.reduce((a, v) => ({ ...a, [v]: true }), {});
|
|
81
77
|
}
|
|
82
|
-
await
|
|
78
|
+
await runAction2(Action.BuildStacks, options);
|
|
83
79
|
process.exit(ExitCode.Success);
|
|
84
80
|
});
|
|
85
81
|
buddy.command("build:components", "Automagically build component libraries for production use & npm/CDN distribution").alias("prod:components").option("-c, --components", descriptions.components, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
86
82
|
log.debug("Running `buddy build:components` ...", options);
|
|
87
|
-
await
|
|
83
|
+
await runAction2(Action.BuildComponentLibs, options);
|
|
88
84
|
});
|
|
89
85
|
buddy.command("build:cli", descriptions.cli).alias("prod:cli").option("-b, --buddy", descriptions.buddy, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
90
86
|
log.debug("Running `buddy build:cli` ...", options);
|
|
91
|
-
await
|
|
87
|
+
await runAction2(Action.BuildCli, options);
|
|
92
88
|
});
|
|
93
89
|
buddy.command("build:server", descriptions.server).alias("prod:server").alias("build:docker").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
94
90
|
log.debug("Running `buddy build:server` ...", options);
|
|
95
|
-
await
|
|
91
|
+
await runAction2(Action.BuildServer, options);
|
|
96
92
|
});
|
|
97
93
|
buddy.command("build:functions", "Automagically build function library for npm/CDN distribution").option("-f, --functions", descriptions.functions, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
98
94
|
log.debug("Running `buddy `build:functions` ...", options);
|
|
99
|
-
await
|
|
95
|
+
await runAction2(Action.BuildFunctionLib, options);
|
|
100
96
|
});
|
|
101
97
|
buddy.command("build:vue-components", "Automagically build Vue component library for npm/CDN distribution").alias("build:vue").alias("prod:vue-components").alias("prod:vue").option("-v, --vue-components", descriptions.vueComponents, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).alias("build:vue").action(async (options) => {
|
|
102
98
|
log.debug("Running `buddy build:vue-components` ...", options);
|
|
103
|
-
await
|
|
99
|
+
await runAction2(Action.BuildVueComponentLib, options);
|
|
104
100
|
});
|
|
105
101
|
buddy.command("build:web-components", "Automagically build Web Component library for npm/CDN distribution").alias("build:wc").alias("prod:web-components").alias("prod:wc").option("-w, --web-components", descriptions.webComponents, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
106
102
|
log.debug("Running `buddy build:web-components` ...", options);
|
|
107
|
-
await
|
|
103
|
+
await runAction2(Action.BuildWebComponentLib, options);
|
|
108
104
|
});
|
|
109
105
|
buddy.command("build:docs", "Automagically build your documentation site.").alias("prod:docs").alias("build:documentation").alias("prod:documentation").option("-d, --docs", descriptions.docs, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
110
106
|
log.debug("Running `buddy build:docs` ...", options);
|
|
111
|
-
await
|
|
107
|
+
await runAction2(Action.BuildDocs, options);
|
|
112
108
|
});
|
|
113
109
|
buddy.command("build:core", "Automagically build the Stacks core.").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
114
110
|
log.debug("Running `buddy build:core` ...", options);
|
|
115
111
|
const startTime = await intro("buddy build:core");
|
|
116
|
-
const result = await
|
|
112
|
+
const result = await runAction2(Action.BuildCore, options);
|
|
117
113
|
if (result.isErr()) {
|
|
118
114
|
log.error("Failed to build the Stacks core.", result.error);
|
|
119
115
|
process.exit();
|
|
@@ -123,7 +119,7 @@ function build(buddy) {
|
|
|
123
119
|
buddy.command("build:desktop", descriptions.desktop).alias("prod:desktop").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
124
120
|
log.debug("Running `buddy build:desktop` ...", options);
|
|
125
121
|
const perf = await intro("buddy build:desktop");
|
|
126
|
-
const result = await
|
|
122
|
+
const result = await runAction2(Action.BuildDesktop, options);
|
|
127
123
|
if (result.isErr()) {
|
|
128
124
|
await outro("While running the build:desktop command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
129
125
|
process.exit();
|
|
@@ -135,7 +131,7 @@ function build(buddy) {
|
|
|
135
131
|
buddy.command("build:stacks", "Build the Stacks framework.").option("-s, --stacks", descriptions.framework, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
136
132
|
log.debug("Running `buddy build:stacks` ...", options);
|
|
137
133
|
const startTime = await intro("buddy build:stacks");
|
|
138
|
-
const result = await
|
|
134
|
+
const result = await runAction2(Action.BuildStacks, options);
|
|
139
135
|
if (result.isErr()) {
|
|
140
136
|
log.error("Failed to build Stacks.", result.error);
|
|
141
137
|
process.exit();
|
|
@@ -153,7 +149,7 @@ var hasNoOptions = function(options) {
|
|
|
153
149
|
|
|
154
150
|
// src/commands/changelog.ts
|
|
155
151
|
import process2 from "process";
|
|
156
|
-
import {runAction as
|
|
152
|
+
import {runAction as runAction3} from "@stacksjs/actions";
|
|
157
153
|
import {intro as intro2, log as log2, outro as outro2} from "@stacksjs/cli";
|
|
158
154
|
import {Action as Action2} from "@stacksjs/enums";
|
|
159
155
|
function changelog(buddy) {
|
|
@@ -167,7 +163,7 @@ function changelog(buddy) {
|
|
|
167
163
|
buddy.command("changelog", descriptions.changelog).option("-q, --quiet", descriptions.quiet, { default: false }).option("-d, --dry-run", descriptions.dryRun, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
168
164
|
log2.debug("Running `buddy changelog` ...", options);
|
|
169
165
|
const perf = await intro2("buddy changelog");
|
|
170
|
-
const result = await
|
|
166
|
+
const result = await runAction3(Action2.Changelog, options);
|
|
171
167
|
if (result.isErr()) {
|
|
172
168
|
await outro2("While running the changelog command, there was an issue", { ...options, startTime: perf, useSeconds: true }, result.error);
|
|
173
169
|
process2.exit();
|
|
@@ -184,7 +180,7 @@ function changelog(buddy) {
|
|
|
184
180
|
// src/commands/clean.ts
|
|
185
181
|
import process3 from "process";
|
|
186
182
|
import {ExitCode as ExitCode2} from "@stacksjs/types";
|
|
187
|
-
import {runAction as
|
|
183
|
+
import {runAction as runAction4} from "@stacksjs/actions";
|
|
188
184
|
import {intro as intro3, log as log3, outro as outro3} from "@stacksjs/cli";
|
|
189
185
|
import {Action as Action3} from "@stacksjs/enums";
|
|
190
186
|
function clean(buddy) {
|
|
@@ -196,7 +192,7 @@ function clean(buddy) {
|
|
|
196
192
|
buddy.command("clean", descriptions.clean).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
197
193
|
log3.debug("Running `buddy clean` ...", options);
|
|
198
194
|
const perf = await intro3("buddy clean");
|
|
199
|
-
const result = await
|
|
195
|
+
const result = await runAction4(Action3.Clean, options);
|
|
200
196
|
if (result.isErr()) {
|
|
201
197
|
await outro3("While running the clean command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
202
198
|
process3.exit(ExitCode2.FatalError);
|
|
@@ -416,88 +412,9 @@ function cloud2(buddy) {
|
|
|
416
412
|
}
|
|
417
413
|
|
|
418
414
|
// src/commands/commit.ts
|
|
419
|
-
import process6 from "process";
|
|
420
|
-
import {runCommit} from "@stacksjs/actions";
|
|
421
|
-
|
|
422
|
-
// /home/runner/work/stacks/stacks/storage/framework/core/logging/src/index.ts
|
|
423
415
|
import process5 from "process";
|
|
424
|
-
import {
|
|
425
|
-
import {
|
|
426
|
-
import {logsPath} from "@stacksjs/path";
|
|
427
|
-
import {buddyOptions, prompt as getPrompt} from "@stacksjs/cli";
|
|
428
|
-
function logLevel() {
|
|
429
|
-
const verboseRegex = /--verbose(?!(\s*=\s*false|\s+false))(\s+|=true)?($|\s)/;
|
|
430
|
-
if (verboseRegex.test(buddyOptions().trim()))
|
|
431
|
-
return 4;
|
|
432
|
-
return logConfig.level;
|
|
433
|
-
}
|
|
434
|
-
async function writeToLogFile(message) {
|
|
435
|
-
const formattedMessage = `[${new Date().toISOString()}] ${message}\n`;
|
|
436
|
-
try {
|
|
437
|
-
const file = Bun.file(logFilePath);
|
|
438
|
-
const writer = file.writer();
|
|
439
|
-
const text = await file.text();
|
|
440
|
-
writer.write(`${text}\n`);
|
|
441
|
-
writer.write(`${formattedMessage}\n`);
|
|
442
|
-
await writer.end();
|
|
443
|
-
} catch (error) {
|
|
444
|
-
const file = Bun.file(logFilePath);
|
|
445
|
-
const writer = file.writer();
|
|
446
|
-
writer.write(`${formattedMessage}\n`);
|
|
447
|
-
await writer.end();
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
function dump(...args) {
|
|
451
|
-
args.forEach((arg) => log5.debug(arg));
|
|
452
|
-
}
|
|
453
|
-
function dd(...args) {
|
|
454
|
-
args.forEach((arg) => log5.debug(arg));
|
|
455
|
-
process5.exit(ExitCode4.FatalError);
|
|
456
|
-
}
|
|
457
|
-
function echo(...args) {
|
|
458
|
-
console.log(...args);
|
|
459
|
-
}
|
|
460
|
-
var logger = createConsola({
|
|
461
|
-
level: logLevel()
|
|
462
|
-
});
|
|
463
|
-
var logFilePath = logsPath("console.log");
|
|
464
|
-
var log5 = {
|
|
465
|
-
async info(...arg) {
|
|
466
|
-
logger.info(...arg);
|
|
467
|
-
await writeToLogFile(`INFO: ${arg}`);
|
|
468
|
-
},
|
|
469
|
-
async success(msg) {
|
|
470
|
-
logger.success(msg);
|
|
471
|
-
await writeToLogFile(`SUCCESS: ${msg}`);
|
|
472
|
-
},
|
|
473
|
-
async error(err, options) {
|
|
474
|
-
handleError(err, options);
|
|
475
|
-
await writeToLogFile(`ERROR: ${err}`);
|
|
476
|
-
},
|
|
477
|
-
async warn(arg) {
|
|
478
|
-
logger.warn(arg);
|
|
479
|
-
await writeToLogFile(`WARN: ${arg}`);
|
|
480
|
-
},
|
|
481
|
-
async debug(...arg) {
|
|
482
|
-
if (process5.env.APP_ENV === "production" || process5.env.APP_ENV === "prod")
|
|
483
|
-
return await writeToLogFile(`DEBUG: ${arg}`);
|
|
484
|
-
logger.debug(arg);
|
|
485
|
-
await writeToLogFile(`DEBUG: ${arg}`);
|
|
486
|
-
},
|
|
487
|
-
async start(...arg) {
|
|
488
|
-
logger.start(arg);
|
|
489
|
-
await writeToLogFile(`START: ${arg}`);
|
|
490
|
-
},
|
|
491
|
-
box: logger.box,
|
|
492
|
-
get prompt() {
|
|
493
|
-
return getPrompt();
|
|
494
|
-
},
|
|
495
|
-
dump,
|
|
496
|
-
dd,
|
|
497
|
-
echo
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
// src/commands/commit.ts
|
|
416
|
+
import {runCommit} from "@stacksjs/actions";
|
|
417
|
+
import {log as log5} from "@stacksjs/logging";
|
|
501
418
|
function commit(buddy) {
|
|
502
419
|
const descriptions = {
|
|
503
420
|
commit: "Commit your stashed changes",
|
|
@@ -510,15 +427,15 @@ function commit(buddy) {
|
|
|
510
427
|
});
|
|
511
428
|
buddy.on("commit:*", () => {
|
|
512
429
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
513
|
-
|
|
430
|
+
process5.exit(1);
|
|
514
431
|
});
|
|
515
432
|
}
|
|
516
433
|
|
|
517
434
|
// src/commands/configure.ts
|
|
518
|
-
import
|
|
435
|
+
import process6 from "process";
|
|
519
436
|
import {log as log6, outro as outro5, runCommand as runCommand2} from "@stacksjs/cli";
|
|
520
437
|
import {path as p2} from "@stacksjs/path";
|
|
521
|
-
import {ExitCode as
|
|
438
|
+
import {ExitCode as ExitCode4} from "@stacksjs/types";
|
|
522
439
|
function configure(buddy) {
|
|
523
440
|
const descriptions = {
|
|
524
441
|
configure: "Configure options",
|
|
@@ -531,28 +448,28 @@ function configure(buddy) {
|
|
|
531
448
|
log6.debug("Running `buddy configure` ...", options);
|
|
532
449
|
if (options?.aws) {
|
|
533
450
|
await configureAws(options);
|
|
534
|
-
|
|
451
|
+
process6.exit(ExitCode4.Success);
|
|
535
452
|
}
|
|
536
453
|
log6.info("Not implemented yet. Please use the --aws flag to configure AWS.");
|
|
537
|
-
|
|
454
|
+
process6.exit(ExitCode4.Success);
|
|
538
455
|
});
|
|
539
|
-
buddy.command("configure:aws", descriptions.aws).option("-p, --project", descriptions.project, { default: false }).option("--profile", descriptions.profile, { default:
|
|
456
|
+
buddy.command("configure:aws", descriptions.aws).option("-p, --project", descriptions.project, { default: false }).option("--profile", descriptions.profile, { default: process6.env.AWS_PROFILE }).option("--verbose", descriptions.verbose, { default: false }).option("--access-key-id", "The AWS access key").option("--secret-access-key", "The AWS secret access key").option("--region", "The AWS region").option("--output", "The AWS output format").option("--quiet", "Suppress output").action(async (options) => {
|
|
540
457
|
log6.debug("Running `buddy configure:aws` ...", options);
|
|
541
458
|
await configureAws(options);
|
|
542
|
-
|
|
459
|
+
process6.exit(ExitCode4.Success);
|
|
543
460
|
});
|
|
544
461
|
buddy.on("configure:*", () => {
|
|
545
462
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
546
|
-
|
|
463
|
+
process6.exit(ExitCode4.FatalError);
|
|
547
464
|
});
|
|
548
465
|
}
|
|
549
466
|
async function configureAws(options) {
|
|
550
467
|
const startTime = performance.now();
|
|
551
|
-
const awsAccessKeyId = options?.accessKeyId ??
|
|
552
|
-
const awsSecretAccessKey = options?.secretAccessKey ??
|
|
468
|
+
const awsAccessKeyId = options?.accessKeyId ?? process6.env.AWS_ACCESS_KEY_ID;
|
|
469
|
+
const awsSecretAccessKey = options?.secretAccessKey ?? process6.env.AWS_SECRET_ACCESS_KEY;
|
|
553
470
|
const defaultRegion = "us-east-1";
|
|
554
471
|
const defaultOutputFormat = options?.output ?? "json";
|
|
555
|
-
const command = `aws configure --profile ${options?.profile ??
|
|
472
|
+
const command = `aws configure --profile ${options?.profile ?? process6.env.AWS_PROFILE}`;
|
|
556
473
|
const input = `${awsAccessKeyId}\n${awsSecretAccessKey}\n${defaultRegion}\n${defaultOutputFormat}\n`;
|
|
557
474
|
const result = await runCommand2(command, {
|
|
558
475
|
...options,
|
|
@@ -562,7 +479,7 @@ async function configureAws(options) {
|
|
|
562
479
|
});
|
|
563
480
|
if (result.isErr()) {
|
|
564
481
|
await outro5("While running the cloud command, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
565
|
-
|
|
482
|
+
process6.exit(ExitCode4.FatalError);
|
|
566
483
|
}
|
|
567
484
|
if (options?.quiet)
|
|
568
485
|
return;
|
|
@@ -570,14 +487,14 @@ async function configureAws(options) {
|
|
|
570
487
|
}
|
|
571
488
|
|
|
572
489
|
// src/commands/create.ts
|
|
573
|
-
import
|
|
574
|
-
import {ExitCode as
|
|
490
|
+
import process7 from "process";
|
|
491
|
+
import {ExitCode as ExitCode5} from "@stacksjs/types";
|
|
575
492
|
import {bold, cyan, dim, intro as intro5, log as log7, runCommand as runCommand3} from "@stacksjs/cli";
|
|
576
493
|
import {useOnline} from "@stacksjs/utils";
|
|
577
494
|
import {isFolder} from "@stacksjs/storage";
|
|
578
495
|
import {resolve} from "@stacksjs/path";
|
|
579
496
|
import {Action as Action4} from "@stacksjs/enums";
|
|
580
|
-
import {runAction as
|
|
497
|
+
import {runAction as runAction5} from "@stacksjs/actions";
|
|
581
498
|
function create(buddy) {
|
|
582
499
|
const descriptions = {
|
|
583
500
|
command: "Create a new Stacks project",
|
|
@@ -589,40 +506,43 @@ function create(buddy) {
|
|
|
589
506
|
functions: "Are you developing functions/composables?",
|
|
590
507
|
api: "Are you building an API?",
|
|
591
508
|
database: "Do you need a database?",
|
|
509
|
+
notifications: "Do you need notifications? e.g. email, SMS, push or chat notifications",
|
|
510
|
+
cache: "Do you need caching?",
|
|
511
|
+
email: "Do you need email?",
|
|
592
512
|
project: "Target a specific project",
|
|
593
513
|
verbose: "Enable verbose output"
|
|
594
514
|
};
|
|
595
|
-
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.views, { default: true }).option("-f, --functions", descriptions.functions, { default: true }).option("-a, --api", descriptions.api, { default: true }).option("-d, --database", descriptions.database, { default: true }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
515
|
+
buddy.command("new <name>", descriptions.command).alias("create <name>").option("-u, --ui", descriptions.ui, { default: true }).option("-c, --components", descriptions.components, { default: true }).option("-w, --web-components", descriptions.webComponents, { default: true }).option("-v, --vue", descriptions.vue, { default: true }).option("-p, --views", descriptions.views, { default: true }).option("-f, --functions", descriptions.functions, { default: true }).option("-a, --api", descriptions.api, { default: true }).option("-d, --database", descriptions.database, { default: true }).option("-ca, --cache", descriptions.cache, { default: false }).option("-e, --email", descriptions.email, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
596
516
|
log7.debug("Running `buddy new <name>` ...", options);
|
|
597
517
|
const startTime = await intro5("stacks new");
|
|
598
518
|
const name = options.name;
|
|
599
|
-
const
|
|
600
|
-
isFolderCheck(
|
|
519
|
+
const path5 = resolve(process7.cwd(), name);
|
|
520
|
+
isFolderCheck(path5);
|
|
601
521
|
onlineCheck();
|
|
602
|
-
const result = await download(name,
|
|
522
|
+
const result = await download(name, path5, options);
|
|
603
523
|
if (result.isErr()) {
|
|
604
524
|
log7.error(result.error);
|
|
605
|
-
|
|
525
|
+
process7.exit(ExitCode5.FatalError);
|
|
606
526
|
}
|
|
607
|
-
await ensureEnv(
|
|
608
|
-
await install(
|
|
527
|
+
await ensureEnv(path5, options);
|
|
528
|
+
await install(path5, options);
|
|
609
529
|
if (startTime) {
|
|
610
530
|
const time = performance.now() - startTime;
|
|
611
531
|
log7.success(dim(`[${time.toFixed(2)}ms] Completed`));
|
|
612
532
|
}
|
|
613
533
|
log7.info(bold("Welcome to the Stacks Framework! \u269B\uFE0F"));
|
|
614
534
|
log7.info("To learn more, visit https://stacksjs.org");
|
|
615
|
-
|
|
535
|
+
process7.exit(ExitCode5.Success);
|
|
616
536
|
});
|
|
617
537
|
buddy.on("new:*", () => {
|
|
618
538
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
619
|
-
|
|
539
|
+
process7.exit(1);
|
|
620
540
|
});
|
|
621
541
|
}
|
|
622
|
-
var isFolderCheck = function(
|
|
623
|
-
if (isFolder(
|
|
624
|
-
log7.error(`Path ${
|
|
625
|
-
|
|
542
|
+
var isFolderCheck = function(path5) {
|
|
543
|
+
if (isFolder(path5)) {
|
|
544
|
+
log7.error(`Path ${path5} already exists`);
|
|
545
|
+
process7.exit(ExitCode5.FatalError);
|
|
626
546
|
}
|
|
627
547
|
};
|
|
628
548
|
var onlineCheck = function() {
|
|
@@ -631,45 +551,45 @@ var onlineCheck = function() {
|
|
|
631
551
|
log7.info("It appears you are disconnected from the internet.");
|
|
632
552
|
log7.info("The Stacks setup requires a brief internet connection for setup.");
|
|
633
553
|
log7.info("For instance, it installs your dependencies from.");
|
|
634
|
-
|
|
554
|
+
process7.exit(ExitCode5.FatalError);
|
|
635
555
|
}
|
|
636
556
|
};
|
|
637
|
-
async function download(name,
|
|
557
|
+
async function download(name, path5, options) {
|
|
638
558
|
log7.info("Setting up your stack.");
|
|
639
559
|
const result = await runCommand3(`bunx giget stacks ${name}`, options);
|
|
640
|
-
log7.success(`Successfully scaffolded your project at ${cyan(
|
|
560
|
+
log7.success(`Successfully scaffolded your project at ${cyan(path5)}`);
|
|
641
561
|
return result;
|
|
642
562
|
}
|
|
643
|
-
async function ensureEnv(
|
|
563
|
+
async function ensureEnv(path5, options) {
|
|
644
564
|
log7.info("Ensuring your environment is ready...");
|
|
645
|
-
await runCommand3("pkgx --update ", { ...options, cwd:
|
|
565
|
+
await runCommand3("pkgx --update ", { ...options, cwd: path5 });
|
|
646
566
|
log7.success("Environment is ready");
|
|
647
567
|
}
|
|
648
|
-
async function install(
|
|
568
|
+
async function install(path5, options) {
|
|
649
569
|
log7.info("Installing & setting up Stacks");
|
|
650
|
-
let result = await runCommand3("bun install", { ...options, cwd:
|
|
570
|
+
let result = await runCommand3("bun install", { ...options, cwd: path5 });
|
|
651
571
|
if (result?.isErr()) {
|
|
652
572
|
log7.error(result.error);
|
|
653
|
-
|
|
573
|
+
process7.exit();
|
|
654
574
|
}
|
|
655
|
-
result = await runCommand3("cp .env.example .env", { ...options, cwd:
|
|
575
|
+
result = await runCommand3("cp .env.example .env", { ...options, cwd: path5 });
|
|
656
576
|
if (result?.isErr()) {
|
|
657
577
|
log7.error(result.error);
|
|
658
|
-
|
|
578
|
+
process7.exit(ExitCode5.FatalError);
|
|
659
579
|
}
|
|
660
|
-
await
|
|
661
|
-
result = await runCommand3("git init", { ...options, cwd:
|
|
580
|
+
await runAction5(Action4.KeyGenerate, { ...options, cwd: path5 });
|
|
581
|
+
result = await runCommand3("git init", { ...options, cwd: path5 });
|
|
662
582
|
if (result.isErr()) {
|
|
663
583
|
log7.error(result.error);
|
|
664
|
-
|
|
584
|
+
process7.exit(ExitCode5.FatalError);
|
|
665
585
|
}
|
|
666
586
|
log7.success("Installed & set-up \uD83D\uDE80");
|
|
667
587
|
}
|
|
668
588
|
|
|
669
589
|
// src/commands/deploy.ts
|
|
670
|
-
import
|
|
671
|
-
import {ExitCode as
|
|
672
|
-
import {runAction as
|
|
590
|
+
import process8 from "process";
|
|
591
|
+
import {ExitCode as ExitCode6} from "@stacksjs/types";
|
|
592
|
+
import {runAction as runAction6} from "@stacksjs/actions";
|
|
673
593
|
import {intro as intro6, italic as italic2, log as log8, outro as outro6, runCommand as runCommand4} from "@stacksjs/cli";
|
|
674
594
|
import {Action as Action5} from "@stacksjs/enums";
|
|
675
595
|
import {app} from "@stacksjs/config";
|
|
@@ -688,20 +608,20 @@ function deploy(buddy) {
|
|
|
688
608
|
log8.info("No domain found in your .env or ./config/app.ts");
|
|
689
609
|
log8.info("Please ensure your domain is properly configured.");
|
|
690
610
|
log8.info("For more info, check out the docs or join our Discord.");
|
|
691
|
-
|
|
611
|
+
process8.exit(ExitCode6.FatalError);
|
|
692
612
|
}
|
|
693
613
|
await checkIfAwsIsConfigured();
|
|
694
614
|
options.domain = await configureDomain(domain, options, startTime);
|
|
695
|
-
const result = await
|
|
615
|
+
const result = await runAction6(Action5.Deploy, options);
|
|
696
616
|
if (result.isErr()) {
|
|
697
617
|
await outro6("While running the `buddy deploy`, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
698
|
-
|
|
618
|
+
process8.exit(ExitCode6.FatalError);
|
|
699
619
|
}
|
|
700
620
|
await outro6("Project deployed.", { startTime, useSeconds: true });
|
|
701
621
|
});
|
|
702
622
|
buddy.on("deploy:*", () => {
|
|
703
623
|
log8.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
704
|
-
|
|
624
|
+
process8.exit(1);
|
|
705
625
|
});
|
|
706
626
|
}
|
|
707
627
|
async function configureDomain(domain, options, startTime) {
|
|
@@ -713,17 +633,17 @@ async function configureDomain(domain, options, startTime) {
|
|
|
713
633
|
console.log("");
|
|
714
634
|
log8.info(" \u27A1\uFE0F Example: `buddy deploy --domain example.com`");
|
|
715
635
|
console.log("");
|
|
716
|
-
|
|
636
|
+
process8.exit(ExitCode6.FatalError);
|
|
717
637
|
}
|
|
718
638
|
if (domain.includes("localhost")) {
|
|
719
639
|
log8.info("You are deploying to a local environment.");
|
|
720
|
-
log8.info("Please set your .env or ./config/app.ts properly.");
|
|
640
|
+
log8.info("Please set your .env or ./config/app.ts properly. The domain we are deploying cannot be a `localhost` domain.");
|
|
721
641
|
console.log("");
|
|
722
642
|
log8.info("Alternatively, specify a domain to deploy via the `--domain` flag.");
|
|
723
643
|
console.log("");
|
|
724
644
|
log8.info(" \u27A1\uFE0F Example: `buddy deploy --domain example.com`");
|
|
725
645
|
console.log("");
|
|
726
|
-
|
|
646
|
+
process8.exit(ExitCode6.FatalError);
|
|
727
647
|
}
|
|
728
648
|
if (await hasUserDomainBeenAddedToCloud(domain)) {
|
|
729
649
|
log8.info("Domain is properly configured");
|
|
@@ -744,10 +664,10 @@ async function configureDomain(domain, options, startTime) {
|
|
|
744
664
|
});
|
|
745
665
|
if (result.isErr()) {
|
|
746
666
|
await outro6("While running the `buddy deploy`, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
747
|
-
|
|
667
|
+
process8.exit(ExitCode6.FatalError);
|
|
748
668
|
}
|
|
749
669
|
await outro6("Added your domain.", { startTime, useSeconds: true });
|
|
750
|
-
|
|
670
|
+
process8.exit(ExitCode6.Success);
|
|
751
671
|
}
|
|
752
672
|
async function checkIfAwsIsConfigured() {
|
|
753
673
|
log8.info("Ensuring AWS is configured...");
|
|
@@ -757,16 +677,16 @@ async function checkIfAwsIsConfigured() {
|
|
|
757
677
|
if (result.isErr()) {
|
|
758
678
|
log8.error("AWS is not configured properly.");
|
|
759
679
|
log8.error("Please run `buddy configure:aws` to set up your AWS credentials.");
|
|
760
|
-
|
|
680
|
+
process8.exit(ExitCode6.FatalError);
|
|
761
681
|
}
|
|
762
682
|
log8.success("AWS is configured");
|
|
763
683
|
}
|
|
764
684
|
|
|
765
685
|
// src/commands/dev.ts
|
|
766
|
-
import
|
|
686
|
+
import process9 from "process";
|
|
767
687
|
import {Action as Action6} from "@stacksjs/enums";
|
|
768
688
|
import {
|
|
769
|
-
runAction as
|
|
689
|
+
runAction as runAction7,
|
|
770
690
|
runApiDevServer,
|
|
771
691
|
runComponentsDevServer,
|
|
772
692
|
runDashboardDevServer,
|
|
@@ -775,7 +695,7 @@ runDocsDevServer,
|
|
|
775
695
|
runFrontendDevServer,
|
|
776
696
|
runSystemTrayDevServer
|
|
777
697
|
} from "@stacksjs/actions";
|
|
778
|
-
import {ExitCode as
|
|
698
|
+
import {ExitCode as ExitCode7} from "@stacksjs/types";
|
|
779
699
|
import {intro as intro7, log as log9, outro as outro7, runCommand as runCommand5} from "@stacksjs/cli";
|
|
780
700
|
import {libsPath} from "@stacksjs/path";
|
|
781
701
|
function dev(buddy) {
|
|
@@ -845,7 +765,7 @@ function dev(buddy) {
|
|
|
845
765
|
await runDocsDevServer(options);
|
|
846
766
|
} else {
|
|
847
767
|
log9.error("Invalid option during interactive mode");
|
|
848
|
-
|
|
768
|
+
process9.exit(ExitCode7.InvalidArgument);
|
|
849
769
|
}
|
|
850
770
|
} else {
|
|
851
771
|
if (options.components)
|
|
@@ -857,7 +777,7 @@ function dev(buddy) {
|
|
|
857
777
|
}
|
|
858
778
|
await startDevelopmentServer(options);
|
|
859
779
|
outro7("Exited", { startTime: perf, useSeconds: true });
|
|
860
|
-
|
|
780
|
+
process9.exit(ExitCode7.Success);
|
|
861
781
|
});
|
|
862
782
|
buddy.command("dev:components", descriptions.components).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
863
783
|
log9.debug("Running `buddy dev:components` ...", options);
|
|
@@ -869,35 +789,35 @@ function dev(buddy) {
|
|
|
869
789
|
log9.info("buddy dev:components result", result);
|
|
870
790
|
if (result.isErr()) {
|
|
871
791
|
await outro7("While running the dev:components command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
872
|
-
|
|
792
|
+
process9.exit();
|
|
873
793
|
}
|
|
874
794
|
console.log("");
|
|
875
795
|
await outro7("Exited", { startTime: perf, useSeconds: true });
|
|
876
|
-
|
|
796
|
+
process9.exit(ExitCode7.Success);
|
|
877
797
|
});
|
|
878
798
|
buddy.command("dev:docs", descriptions.docs).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
879
799
|
log9.debug("Running `buddy dev:docs` ...", options);
|
|
880
800
|
const perf = await intro7("buddy dev:docs");
|
|
881
|
-
const result = await
|
|
801
|
+
const result = await runAction7(Action6.DevDocs, options);
|
|
882
802
|
if (result.isErr()) {
|
|
883
803
|
await outro7("While running the dev:docs command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
884
|
-
|
|
804
|
+
process9.exit();
|
|
885
805
|
}
|
|
886
806
|
console.log("");
|
|
887
807
|
await outro7("Exited", { startTime: perf, useSeconds: true });
|
|
888
|
-
|
|
808
|
+
process9.exit(ExitCode7.Success);
|
|
889
809
|
});
|
|
890
810
|
buddy.command("dev:desktop", descriptions.desktop).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
891
811
|
log9.debug("Running `buddy dev:desktop` ...", options);
|
|
892
812
|
const perf = await intro7("buddy dev:desktop");
|
|
893
|
-
const result = await
|
|
813
|
+
const result = await runAction7(Action6.DevDesktop, options);
|
|
894
814
|
if (result.isErr()) {
|
|
895
815
|
await outro7("While running the dev:desktop command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
896
|
-
|
|
816
|
+
process9.exit();
|
|
897
817
|
}
|
|
898
818
|
console.log("");
|
|
899
819
|
await outro7("Exited", { startTime: perf, useSeconds: true });
|
|
900
|
-
|
|
820
|
+
process9.exit(ExitCode7.Success);
|
|
901
821
|
});
|
|
902
822
|
buddy.command("dev:api", descriptions.api).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
903
823
|
log9.debug("Running `buddy dev:api` ...", options);
|
|
@@ -917,14 +837,14 @@ function dev(buddy) {
|
|
|
917
837
|
});
|
|
918
838
|
buddy.on("dev:*", () => {
|
|
919
839
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
920
|
-
|
|
840
|
+
process9.exit(1);
|
|
921
841
|
});
|
|
922
842
|
}
|
|
923
843
|
async function startDevelopmentServer(options) {
|
|
924
|
-
const result = await
|
|
844
|
+
const result = await runAction7(Action6.Dev, options);
|
|
925
845
|
if (result.isErr()) {
|
|
926
846
|
log9.error("While running the dev command, there was an issue", result.error);
|
|
927
|
-
|
|
847
|
+
process9.exit(ExitCode7.InvalidArgument);
|
|
928
848
|
}
|
|
929
849
|
}
|
|
930
850
|
var wantsInteractive = function(options) {
|
|
@@ -932,12 +852,12 @@ var wantsInteractive = function(options) {
|
|
|
932
852
|
};
|
|
933
853
|
|
|
934
854
|
// src/commands/domains.ts
|
|
935
|
-
import
|
|
936
|
-
import {runAction as
|
|
855
|
+
import process10 from "process";
|
|
856
|
+
import {runAction as runAction8} from "@stacksjs/actions";
|
|
937
857
|
import {bgCyan, bold as bold2, intro as intro8, italic as italic3, log as log10, outro as outro8, prompts as prompts2} from "@stacksjs/cli";
|
|
938
|
-
import {config as
|
|
858
|
+
import {config as config3} from "@stacksjs/config";
|
|
939
859
|
import {addDomain as addDomain2} from "@stacksjs/dns";
|
|
940
|
-
import {ExitCode as
|
|
860
|
+
import {ExitCode as ExitCode8} from "@stacksjs/types";
|
|
941
861
|
import {Action as Action7} from "@stacksjs/enums";
|
|
942
862
|
function domains(buddy) {
|
|
943
863
|
const descriptions = {
|
|
@@ -948,15 +868,15 @@ function domains(buddy) {
|
|
|
948
868
|
project: "Target a specific project",
|
|
949
869
|
verbose: "Enable verbose output"
|
|
950
870
|
};
|
|
951
|
-
const c =
|
|
871
|
+
const c = config3.dns.contactInfo;
|
|
952
872
|
buddy.command("domains:purchase <domain>", descriptions.purchase).option("--years <years>", "Number of years to purchase the domain for", { default: 1 }).option("--privacy", "Enable privacy protection", { default: true }).option("--auto-renew", "Enable auto-renew", { default: true }).option("--first-name <firstName>", "Registrant first name", { default: c?.firstName }).option("--last-name <lastName>", "Registrant last name", { default: c?.lastName }).option("--organization <organization>", "Registrant organization name", { default: c?.organizationName }).option("--address-line1 <address>", "Registrant address line 1", { default: c?.addressLine1 }).option("--address-line2 <address>", "Registrant address line 2", { default: c?.addressLine2 }).option("--city <city>", "Registrant city", { default: c?.city }).option("--state <state>", "Registrant state", { default: c?.state }).option("--country <country>", "Registrant country code", { default: c?.countryCode }).option("--zip <zip>", "Registrant zip", { default: c?.zip }).option("--phone <phone>", "Registrant phone", { default: c?.phoneNumber }).option("--email <email>", "Registrant email", { default: c?.email }).option("--admin-first-name <firstName>", "Admin first name", { default: c?.admin?.firstName || c?.firstName }).option("--admin-last-name <lastName>", "Admin last name", { default: c?.admin?.lastName || c?.lastName }).option("--admin-organization <organization>", "Admin organization", { default: c?.admin?.organizationName || c?.organizationName }).option("--admin-address-line1 <address>", "Admin address line 1", { default: c?.admin?.addressLine1 || c?.addressLine1 }).option("--admin-address-line2 <address>", "Admin address line 2", { default: c?.admin?.addressLine2 || c?.addressLine2 }).option("--admin-city <city>", "Admin city", { default: c?.admin?.city || c?.city }).option("--admin-state <state>", "Admin state", { default: c?.admin?.state || c?.state }).option("--admin-country <country>", "Admin country code", { default: c?.admin?.countryCode || c?.countryCode }).option("--admin-zip <zip>", "Admin zip", { default: c?.admin?.zip || c?.zip }).option("--admin-phone <phone>", "Admin phone number", { default: c?.admin?.phoneNumber || c?.phoneNumber }).option("--admin-email <email>", "Admin email", { default: c?.admin?.email || c?.email }).option("--tech-first-name <firstName>", "Tech first name", { default: c?.tech?.firstName || c?.firstName }).option("--tech-last-name <lastName>", "Tech last name", { default: c?.tech?.lastName || c?.lastName }).option("--tech-organization <organization>", "Tech organization name", { default: c?.tech?.organizationName || c?.organizationName }).option("--tech-address-line1 <address>", "Tech address line 1", { default: c?.tech?.addressLine1 || c?.addressLine1 }).option("--tech-address-line2 <address>", "Tech address line 2", { default: c?.tech?.addressLine2 || c?.addressLine2 }).option("--tech-city <city>", "Tech city", { default: c?.tech?.city || c?.city }).option("--tech-state <state>", "Tech state", { default: c?.tech?.state || c?.state }).option("--tech-country <country>", "Tech country", { default: c?.tech?.countryCode || c?.countryCode }).option("--tech-zip <zip>", "Tech zip", { default: c?.tech?.zip || c?.zip }).option("--tech-phone <phone>", "Tech phone", { default: c?.tech?.phoneNumber || c?.phoneNumber }).option("--tech-email <email>", "Tech email", { default: c?.tech?.email || c?.email }).option("--privacy-admin", "Enable privacy protection for admin", { default: c?.privacyAdmin || c?.privacy || true }).option("--privacy-tech", "Enable privacy protection for tech", { default: c?.privacyTech || c?.privacy || true }).option("--privacy-registrant", "Enable privacy protection for registrant", { default: c?.privacyRegistrant || c?.privacy || true }).option("--contact-type <type>", "Contact type", { default: "person" }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (domain, options) => {
|
|
953
873
|
log10.debug("Running `buddy domains:purchase <domain>` ...", options);
|
|
954
874
|
options.domain = domain;
|
|
955
875
|
const startTime = await intro8("buddy domains:purchase");
|
|
956
|
-
const result = await
|
|
876
|
+
const result = await runAction8(Action7.DomainsPurchase, options);
|
|
957
877
|
if (result.isErr()) {
|
|
958
878
|
await outro8("While running the domains:purchase command, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
959
|
-
|
|
879
|
+
process10.exit(ExitCode8.FatalError);
|
|
960
880
|
}
|
|
961
881
|
const { confirm } = await prompts2({
|
|
962
882
|
name: "confirm",
|
|
@@ -966,7 +886,7 @@ function domains(buddy) {
|
|
|
966
886
|
if (!confirm) {
|
|
967
887
|
await outro8(`Alrighty! ${italic3(domain)} was added to your account.`, { startTime, useSeconds: true, type: "success" });
|
|
968
888
|
log10.info(`Please note, you may need to validate your email address. Check your ${italic3(options.registrantEmail)} inbox.`);
|
|
969
|
-
|
|
889
|
+
process10.exit(ExitCode8.Success);
|
|
970
890
|
}
|
|
971
891
|
const { writeEnv } = await import("../../env/src/index.js");
|
|
972
892
|
writeEnv("APP_URL", domain);
|
|
@@ -976,7 +896,7 @@ function domains(buddy) {
|
|
|
976
896
|
\nThe next time you run ${bgCyan(italic3(bold2(" buddy deploy ")))}, your app will deploy to ${italic3(domain)}.
|
|
977
897
|
\n${italic3("You may need to deploy 2-3 times for the changes to take effect. Issue tracked here: https://github.com/stacksjs/stacks/issues/685")}`;
|
|
978
898
|
await outro8(message, { startTime, useSeconds: true, type: "info" });
|
|
979
|
-
|
|
899
|
+
process10.exit(ExitCode8.Success);
|
|
980
900
|
});
|
|
981
901
|
buddy.command("domains:add <domain>", descriptions.add).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
982
902
|
log10.debug("Running `buddy domains:add <domain>` ...", options);
|
|
@@ -987,14 +907,14 @@ function domains(buddy) {
|
|
|
987
907
|
});
|
|
988
908
|
if (result.isErr()) {
|
|
989
909
|
await outro8("While running the `buddy deploy`, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
990
|
-
|
|
910
|
+
process10.exit(ExitCode8.FatalError);
|
|
991
911
|
}
|
|
992
912
|
await outro8("Added your domain.", { startTime, useSeconds: true });
|
|
993
|
-
|
|
913
|
+
process10.exit(ExitCode8.Success);
|
|
994
914
|
});
|
|
995
915
|
buddy.command("domains:remove <domain>", descriptions.remove).option("--yes", descriptions.skip, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
996
916
|
log10.debug("Running `buddy domains:remove <domain>` ...", options);
|
|
997
|
-
const domain = options.domain ||
|
|
917
|
+
const domain = options.domain || config3.app.url;
|
|
998
918
|
const opts = { ...options, domain };
|
|
999
919
|
const startTime = await intro8("buddy domains:remove");
|
|
1000
920
|
if (!opts.yes) {
|
|
@@ -1005,27 +925,27 @@ function domains(buddy) {
|
|
|
1005
925
|
});
|
|
1006
926
|
if (!confirm) {
|
|
1007
927
|
await outro8("Cancelled the domains:remove command", { startTime, useSeconds: true, type: "info" });
|
|
1008
|
-
|
|
928
|
+
process10.exit(ExitCode8.Success);
|
|
1009
929
|
}
|
|
1010
930
|
}
|
|
1011
|
-
const result = await
|
|
931
|
+
const result = await runAction8(Action7.DomainsRemove, opts);
|
|
1012
932
|
if (result.isErr()) {
|
|
1013
933
|
await outro8("While running the domains:remove command, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
1014
|
-
|
|
934
|
+
process10.exit(ExitCode8.FatalError);
|
|
1015
935
|
}
|
|
1016
936
|
await outro8("Removed your domain DNS records.", { startTime, useSeconds: true });
|
|
1017
|
-
|
|
937
|
+
process10.exit(ExitCode8.Success);
|
|
1018
938
|
});
|
|
1019
939
|
buddy.on("domains:*", () => {
|
|
1020
940
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1021
|
-
|
|
941
|
+
process10.exit(1);
|
|
1022
942
|
});
|
|
1023
943
|
}
|
|
1024
944
|
|
|
1025
945
|
// src/commands/dns.ts
|
|
1026
|
-
import
|
|
1027
|
-
import {ExitCode as
|
|
1028
|
-
import {config as
|
|
946
|
+
import process11 from "process";
|
|
947
|
+
import {ExitCode as ExitCode9} from "@stacksjs/types";
|
|
948
|
+
import {config as config5} from "@stacksjs/config";
|
|
1029
949
|
import {log as log11, runCommand as runCommand6} from "@stacksjs/cli";
|
|
1030
950
|
function dns3(buddy) {
|
|
1031
951
|
const descriptions = {
|
|
@@ -1049,19 +969,19 @@ function dns3(buddy) {
|
|
|
1049
969
|
delete options.pretty;
|
|
1050
970
|
delete options.p;
|
|
1051
971
|
const optionsString = Object.entries(options).filter(([key, value]) => key !== "--" && key.length > 1 && value !== false).map(([key, value]) => `--${key} ${value}`).join(" ");
|
|
1052
|
-
await runCommand6(`dog ${domain ||
|
|
1053
|
-
|
|
972
|
+
await runCommand6(`dog ${domain || config5.app.url} ${optionsString}`);
|
|
973
|
+
process11.exit(ExitCode9.Success);
|
|
1054
974
|
});
|
|
1055
975
|
buddy.on("dns:*", () => {
|
|
1056
976
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1057
|
-
|
|
977
|
+
process11.exit(1);
|
|
1058
978
|
});
|
|
1059
979
|
}
|
|
1060
980
|
|
|
1061
981
|
// src/commands/fresh.ts
|
|
1062
|
-
import
|
|
1063
|
-
import {ExitCode as
|
|
1064
|
-
import {runAction as
|
|
982
|
+
import process12 from "process";
|
|
983
|
+
import {ExitCode as ExitCode10} from "@stacksjs/types";
|
|
984
|
+
import {runAction as runAction9} from "@stacksjs/actions";
|
|
1065
985
|
import {intro as intro9, log as log12, outro as outro9} from "@stacksjs/cli";
|
|
1066
986
|
import {Action as Action8} from "@stacksjs/enums";
|
|
1067
987
|
function fresh(buddy) {
|
|
@@ -1073,24 +993,25 @@ function fresh(buddy) {
|
|
|
1073
993
|
buddy.command("fresh", descriptions.fresh).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1074
994
|
log12.debug("Running `buddy fresh` ...", options);
|
|
1075
995
|
const perf = await intro9("buddy fresh");
|
|
1076
|
-
const result = await
|
|
996
|
+
const result = await runAction9(Action8.Fresh, { ...options, stdout: "inherit" });
|
|
1077
997
|
if (result.isErr()) {
|
|
1078
998
|
await outro9("While running `buddy fresh`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1079
|
-
|
|
999
|
+
process12.exit(ExitCode10.FatalError);
|
|
1080
1000
|
}
|
|
1081
1001
|
await outro9("Freshly reinstalled your dependencies", { startTime: perf, useSeconds: true });
|
|
1082
|
-
|
|
1002
|
+
process12.exit(ExitCode10.Success);
|
|
1083
1003
|
});
|
|
1084
1004
|
buddy.on("fresh:*", () => {
|
|
1085
1005
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1086
|
-
|
|
1006
|
+
process12.exit(1);
|
|
1087
1007
|
});
|
|
1088
1008
|
}
|
|
1089
1009
|
|
|
1090
1010
|
// src/commands/generate.ts
|
|
1091
|
-
import
|
|
1011
|
+
import process13 from "process";
|
|
1092
1012
|
import {
|
|
1093
1013
|
generateComponentMeta,
|
|
1014
|
+
generateCoreSymlink,
|
|
1094
1015
|
generateIdeHelpers,
|
|
1095
1016
|
generateLibEntries,
|
|
1096
1017
|
generateMigrations,
|
|
@@ -1101,7 +1022,7 @@ generateWebTypes,
|
|
|
1101
1022
|
invoke as startGenerationProcess
|
|
1102
1023
|
} from "@stacksjs/actions";
|
|
1103
1024
|
import {log as log13} from "@stacksjs/cli";
|
|
1104
|
-
import {ExitCode as
|
|
1025
|
+
import {ExitCode as ExitCode11} from "@stacksjs/types";
|
|
1105
1026
|
function generate(buddy) {
|
|
1106
1027
|
const descriptions = {
|
|
1107
1028
|
command: "Automagically build any of your libraries/packages for production use. Select any of the following packages",
|
|
@@ -1111,15 +1032,16 @@ function generate(buddy) {
|
|
|
1111
1032
|
customData: "Generate VS Code custom data (custom-elements.json) for IDEs",
|
|
1112
1033
|
ideHelpers: "Generate IDE helpers",
|
|
1113
1034
|
componentMeta: "Generate component meta information",
|
|
1035
|
+
coreSymlink: "Generate symlink of the core framework to the project root",
|
|
1114
1036
|
pkgx: "Generate the pkgx configuration file",
|
|
1115
1037
|
select: "What are you trying to generate?",
|
|
1116
1038
|
project: "Target a specific project",
|
|
1117
1039
|
verbose: "Enable verbose output"
|
|
1118
1040
|
};
|
|
1119
|
-
buddy.command("generate", descriptions.command).option("-t, --types", descriptions.types).option("-e, --entries", descriptions.entries).option("-w, --web-types", descriptions.webTypes).option("-c, --custom-data", descriptions.customData).option("-i, --ide-helpers", descriptions.ideHelpers).option("-c, --component-meta", descriptions.componentMeta).option("-p, --pkgx", descriptions.pkgx).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1041
|
+
buddy.command("generate", descriptions.command).option("-t, --types", descriptions.types).option("-e, --entries", descriptions.entries).option("-w, --web-types", descriptions.webTypes).option("-c, --custom-data", descriptions.customData).option("-i, --ide-helpers", descriptions.ideHelpers).option("-c, --component-meta", descriptions.componentMeta).option("-p, --pkgx", descriptions.pkgx).option("-p, --project", descriptions.project, { default: false }).option("--core-symlink", descriptions.coreSymlink).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1120
1042
|
log13.debug("Running `buddy generate` ...", options);
|
|
1121
1043
|
await startGenerationProcess(options);
|
|
1122
|
-
|
|
1044
|
+
process13.exit(ExitCode11.Success);
|
|
1123
1045
|
});
|
|
1124
1046
|
buddy.command("generate:types", descriptions.types).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).alias("types:generate").action(async (options) => {
|
|
1125
1047
|
log13.debug("Running `buddy generate:types` ...", options);
|
|
@@ -1153,16 +1075,20 @@ function generate(buddy) {
|
|
|
1153
1075
|
log13.debug("Running `buddy generate:migrations` ...", options);
|
|
1154
1076
|
generateMigrations();
|
|
1155
1077
|
});
|
|
1078
|
+
buddy.command("generate:core-symlink", "Generate core symlink. A shortcut for core developers.").action(async (options) => {
|
|
1079
|
+
log13.debug("Running `buddy core-symlink` ...", options);
|
|
1080
|
+
await generateCoreSymlink();
|
|
1081
|
+
});
|
|
1156
1082
|
buddy.on("generate:*", () => {
|
|
1157
1083
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1158
|
-
|
|
1084
|
+
process13.exit(1);
|
|
1159
1085
|
});
|
|
1160
1086
|
}
|
|
1161
1087
|
|
|
1162
1088
|
// src/commands/http.ts
|
|
1163
|
-
import
|
|
1164
|
-
import {ExitCode as
|
|
1165
|
-
import {config as
|
|
1089
|
+
import process14 from "process";
|
|
1090
|
+
import {ExitCode as ExitCode12} from "@stacksjs/types";
|
|
1091
|
+
import {config as config7} from "@stacksjs/config";
|
|
1166
1092
|
import {log as log14, runCommandSync as runCommandSync2} from "@stacksjs/cli";
|
|
1167
1093
|
function http(buddy) {
|
|
1168
1094
|
const descriptions = {
|
|
@@ -1173,18 +1099,18 @@ function http(buddy) {
|
|
|
1173
1099
|
buddy.command("http [domain]", descriptions.http).option("-p, --project", descriptions.project, { default: false }).action(async (domain, options) => {
|
|
1174
1100
|
log14.debug("Running `buddy http [domain]` ...", options);
|
|
1175
1101
|
const optionsString = Object.entries(options).filter(([key, value]) => key !== "--" && key.length > 1 && value !== false).map(([key, value]) => `--${key} ${value}`).join(" ");
|
|
1176
|
-
const command = `http GET ${domain ||
|
|
1102
|
+
const command = `http GET ${domain || config7.app.url} ${optionsString}`;
|
|
1177
1103
|
log14.info(`Running command: ${command}`);
|
|
1178
1104
|
await runCommandSync2(command);
|
|
1179
|
-
|
|
1105
|
+
process14.exit(ExitCode12.Success);
|
|
1180
1106
|
});
|
|
1181
1107
|
}
|
|
1182
1108
|
|
|
1183
1109
|
// src/commands/lint.ts
|
|
1184
|
-
import
|
|
1110
|
+
import process15 from "process";
|
|
1185
1111
|
import {intro as intro10, log as log15, outro as outro10} from "@stacksjs/cli";
|
|
1186
1112
|
import {Action as Action9} from "@stacksjs/enums";
|
|
1187
|
-
import {runAction as
|
|
1113
|
+
import {runAction as runAction10} from "@stacksjs/actions";
|
|
1188
1114
|
function lint(buddy) {
|
|
1189
1115
|
const descriptions = {
|
|
1190
1116
|
lint: "Automagically lints your project codebase",
|
|
@@ -1195,33 +1121,34 @@ function lint(buddy) {
|
|
|
1195
1121
|
buddy.command("lint", descriptions.lint).option("-f, --fix", descriptions.lintFix, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1196
1122
|
log15.debug("Running `buddy lint` ...", options);
|
|
1197
1123
|
const startTime = await intro10("buddy lint");
|
|
1198
|
-
const result = await
|
|
1124
|
+
const result = await runAction10(Action9.Lint, options);
|
|
1199
1125
|
if (result.isErr()) {
|
|
1200
1126
|
await outro10("While running `buddy lint`, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
1201
|
-
|
|
1127
|
+
process15.exit();
|
|
1202
1128
|
}
|
|
1203
1129
|
await outro10("Linted your project", { startTime, useSeconds: true });
|
|
1204
1130
|
});
|
|
1205
1131
|
buddy.command("lint:fix", descriptions.lintFix).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1206
1132
|
log15.debug("Running `buddy lint:fix` ...", options);
|
|
1207
1133
|
log15.info("Fixing lint errors...");
|
|
1208
|
-
const result = await
|
|
1134
|
+
const result = await runAction10(Action9.LintFix, { ...options });
|
|
1209
1135
|
if (result.isErr()) {
|
|
1210
1136
|
log15.error("There was an error lint fixing your code.", result.error);
|
|
1211
|
-
|
|
1137
|
+
process15.exit();
|
|
1212
1138
|
}
|
|
1213
1139
|
log15.success("Fixed lint errors");
|
|
1214
1140
|
});
|
|
1215
1141
|
buddy.on("lint:*", () => {
|
|
1216
1142
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1217
|
-
|
|
1143
|
+
process15.exit(1);
|
|
1218
1144
|
});
|
|
1219
1145
|
}
|
|
1220
1146
|
|
|
1221
1147
|
// src/commands/list.ts
|
|
1222
|
-
import
|
|
1148
|
+
import process16 from "process";
|
|
1223
1149
|
var {$ } = globalThis.Bun;
|
|
1224
1150
|
import {projectPath} from "@stacksjs/path";
|
|
1151
|
+
import {log as log16} from "@stacksjs/logging";
|
|
1225
1152
|
function list(buddy) {
|
|
1226
1153
|
const descriptions = {
|
|
1227
1154
|
list: "List all of the project-specific Buddy commands",
|
|
@@ -1229,7 +1156,7 @@ function list(buddy) {
|
|
|
1229
1156
|
verbose: "Enable verbose output"
|
|
1230
1157
|
};
|
|
1231
1158
|
buddy.command("list", descriptions.list).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1232
|
-
|
|
1159
|
+
log16.debug("Running `buddy list` ...", options);
|
|
1233
1160
|
$.cwd(projectPath());
|
|
1234
1161
|
const test = await $`buddy --help`.text();
|
|
1235
1162
|
const commandsSection = test.match(/Commands:.*?(?=For more info, run any command with the)/s)?.[0];
|
|
@@ -1242,13 +1169,13 @@ function list(buddy) {
|
|
|
1242
1169
|
});
|
|
1243
1170
|
buddy.on("list:*", () => {
|
|
1244
1171
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1245
|
-
|
|
1172
|
+
process16.exit(1);
|
|
1246
1173
|
});
|
|
1247
1174
|
}
|
|
1248
1175
|
|
|
1249
1176
|
// src/commands/install.ts
|
|
1250
|
-
import
|
|
1251
|
-
import {log as
|
|
1177
|
+
import process17 from "process";
|
|
1178
|
+
import {log as log17, runCommand as runCommand7} from "@stacksjs/cli";
|
|
1252
1179
|
import {path as p3} from "@stacksjs/path";
|
|
1253
1180
|
function install2(buddy) {
|
|
1254
1181
|
const descriptions = {
|
|
@@ -1257,7 +1184,7 @@ function install2(buddy) {
|
|
|
1257
1184
|
verbose: "Enable verbose output"
|
|
1258
1185
|
};
|
|
1259
1186
|
buddy.command("install", descriptions.install).option("-p, --project", descriptions.project, { default: false }).option("-v, --verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1260
|
-
|
|
1187
|
+
log17.debug("Running `buddy install` ...", options);
|
|
1261
1188
|
await runCommand7("bun install", {
|
|
1262
1189
|
...options,
|
|
1263
1190
|
cwd: p3.projectPath()
|
|
@@ -1265,15 +1192,15 @@ function install2(buddy) {
|
|
|
1265
1192
|
});
|
|
1266
1193
|
buddy.on("install:*", () => {
|
|
1267
1194
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1268
|
-
|
|
1195
|
+
process17.exit(1);
|
|
1269
1196
|
});
|
|
1270
1197
|
}
|
|
1271
1198
|
|
|
1272
1199
|
// src/commands/key.ts
|
|
1273
|
-
import
|
|
1274
|
-
import {intro as intro11, log as
|
|
1200
|
+
import process18 from "process";
|
|
1201
|
+
import {intro as intro11, log as log18, outro as outro11} from "@stacksjs/cli";
|
|
1202
|
+
import {runAction as runAction11} from "@stacksjs/actions";
|
|
1275
1203
|
import {Action as Action10} from "@stacksjs/enums";
|
|
1276
|
-
import {runAction as runAction10} from "@stacksjs/actions";
|
|
1277
1204
|
function key(buddy) {
|
|
1278
1205
|
const descriptions = {
|
|
1279
1206
|
command: "Generate & set the application key.",
|
|
@@ -1281,23 +1208,23 @@ function key(buddy) {
|
|
|
1281
1208
|
verbose: "Enable verbose output"
|
|
1282
1209
|
};
|
|
1283
1210
|
buddy.command("key:generate", descriptions.command).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1284
|
-
|
|
1211
|
+
log18.debug("Running `buddy key:generate` ...", options);
|
|
1285
1212
|
await intro11("buddy key:generate");
|
|
1286
|
-
const result = await
|
|
1213
|
+
const result = await runAction11(Action10.KeyGenerate, options);
|
|
1287
1214
|
if (result.isErr()) {
|
|
1288
|
-
|
|
1289
|
-
|
|
1215
|
+
log18.error("Failed to set random application key.", result.error);
|
|
1216
|
+
process18.exit();
|
|
1290
1217
|
}
|
|
1291
1218
|
await outro11("Random application key set.");
|
|
1292
1219
|
});
|
|
1293
1220
|
buddy.on("key:*", () => {
|
|
1294
1221
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1295
|
-
|
|
1222
|
+
process18.exit(1);
|
|
1296
1223
|
});
|
|
1297
1224
|
}
|
|
1298
1225
|
|
|
1299
1226
|
// src/commands/make.ts
|
|
1300
|
-
import
|
|
1227
|
+
import process19 from "process";
|
|
1301
1228
|
import {
|
|
1302
1229
|
createModel,
|
|
1303
1230
|
createNotification,
|
|
@@ -1309,9 +1236,11 @@ makeLanguage,
|
|
|
1309
1236
|
makePage,
|
|
1310
1237
|
makeStack
|
|
1311
1238
|
} from "@stacksjs/actions";
|
|
1312
|
-
import {intro as intro12, italic as italic4, outro as outro12} from "@stacksjs/cli";
|
|
1313
|
-
import {
|
|
1314
|
-
import {
|
|
1239
|
+
import {intro as intro12, italic as italic4, outro as outro12, runCommand as runCommand8} from "@stacksjs/cli";
|
|
1240
|
+
import {localUrl} from "@stacksjs/config";
|
|
1241
|
+
import {path as p4} from "@stacksjs/path";
|
|
1242
|
+
import {log as log19} from "@stacksjs/logging";
|
|
1243
|
+
import {ExitCode as ExitCode13} from "@stacksjs/types";
|
|
1315
1244
|
function make(buddy) {
|
|
1316
1245
|
const descriptions = {
|
|
1317
1246
|
model: "Create a new model",
|
|
@@ -1323,132 +1252,147 @@ function make(buddy) {
|
|
|
1323
1252
|
migration: "Create a new migration",
|
|
1324
1253
|
factory: "Create a new factory",
|
|
1325
1254
|
notification: "Create a new notification",
|
|
1326
|
-
stack: "Create a new
|
|
1255
|
+
stack: "Create a new stack",
|
|
1256
|
+
certificate: "Create a new SSL Certificate",
|
|
1327
1257
|
select: "What are you trying to make?",
|
|
1328
1258
|
project: "Target a specific project",
|
|
1329
1259
|
verbose: "Enable verbose output"
|
|
1330
1260
|
};
|
|
1331
1261
|
buddy.command("make", "The make command").option("-c, --component", descriptions.component, { default: false }).option("-p, --page", descriptions.page, { default: false }).option("-f, --function", descriptions.function, { default: false }).option("-l, --language", descriptions.language, { default: false }).option("-d, --database", descriptions.database, { default: false }).option("-m, --migration", descriptions.migration, { default: false }).option("-f, --factory", descriptions.factory, { default: false }).option("-n, --notification", descriptions.notification, { default: false }).option("-s, --stack", descriptions.stack, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1332
|
-
|
|
1262
|
+
log19.debug("Running `buddy make` ...", options);
|
|
1333
1263
|
const name = buddy.args[0];
|
|
1334
1264
|
if (!name) {
|
|
1335
|
-
|
|
1336
|
-
|
|
1265
|
+
log19.error("You need to specify a name. Read more about the documentation here.");
|
|
1266
|
+
process19.exit();
|
|
1337
1267
|
}
|
|
1338
1268
|
await invoke(options);
|
|
1339
|
-
|
|
1269
|
+
process19.exit(ExitCode13.Success);
|
|
1340
1270
|
});
|
|
1341
1271
|
buddy.command("make:component", descriptions.component).option("-n, --name", "The name of the component").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1342
|
-
|
|
1272
|
+
log19.debug("Running `buddy make:component` ...", options);
|
|
1343
1273
|
const name = buddy.args[0] || options.name;
|
|
1344
1274
|
options.name = name;
|
|
1345
1275
|
if (!name) {
|
|
1346
|
-
|
|
1347
|
-
|
|
1276
|
+
log19.error("You need to specify a name. Read more about the documentation here.");
|
|
1277
|
+
process19.exit();
|
|
1348
1278
|
}
|
|
1349
1279
|
await makeComponent(options);
|
|
1350
1280
|
});
|
|
1351
1281
|
buddy.command("make:database", descriptions.database).option("-n, --name", "The name of the database").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action((options) => {
|
|
1352
|
-
|
|
1282
|
+
log19.debug("Running `buddy make:database` ...", options);
|
|
1353
1283
|
const name = buddy.args[0] || options.name;
|
|
1354
1284
|
options.name = name;
|
|
1355
1285
|
if (!name) {
|
|
1356
|
-
|
|
1357
|
-
|
|
1286
|
+
log19.error("You need to specify a name. Read more about the documentation here.");
|
|
1287
|
+
process19.exit();
|
|
1358
1288
|
}
|
|
1359
1289
|
makeDatabase(options);
|
|
1360
1290
|
});
|
|
1361
1291
|
buddy.command("make:factory", descriptions.factory).option("-n, --name", "The name of the factory").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action((options) => {
|
|
1362
|
-
|
|
1292
|
+
log19.debug("Running `buddy make:factory` ...", options);
|
|
1363
1293
|
const name = buddy.args[0] || options.name;
|
|
1364
1294
|
options.name = name;
|
|
1365
1295
|
if (!name) {
|
|
1366
|
-
|
|
1367
|
-
|
|
1296
|
+
log19.error("You need to specify a name. Read more about the documentation here.");
|
|
1297
|
+
process19.exit();
|
|
1368
1298
|
}
|
|
1369
1299
|
});
|
|
1370
1300
|
buddy.command("make:view", descriptions.page).alias("make:page").option("-n, --name", "The name of the page").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1371
|
-
|
|
1301
|
+
log19.debug("Running `buddy make:view` ...", options);
|
|
1372
1302
|
const name = buddy.args[0] || options.name;
|
|
1373
1303
|
options.name = name;
|
|
1374
1304
|
if (!name) {
|
|
1375
|
-
|
|
1376
|
-
|
|
1305
|
+
log19.error("You need to specify a name. Read more about the documentation here.");
|
|
1306
|
+
process19.exit();
|
|
1377
1307
|
}
|
|
1378
1308
|
await makePage(options);
|
|
1379
1309
|
});
|
|
1380
1310
|
buddy.command("make:function", descriptions.function).option("-n, --name", "The name of the function").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1381
|
-
|
|
1311
|
+
log19.debug("Running `buddy make:function` ...", options);
|
|
1382
1312
|
await makeFunction(options);
|
|
1383
1313
|
});
|
|
1384
1314
|
buddy.command("make:lang", descriptions.language).option("-n, --name", "The name of the language").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1385
|
-
|
|
1315
|
+
log19.debug("Running `buddy make:lang` ...", options);
|
|
1386
1316
|
const name = buddy.args[0] || options.name;
|
|
1387
1317
|
options.name = name;
|
|
1388
1318
|
if (!name) {
|
|
1389
|
-
|
|
1390
|
-
|
|
1319
|
+
log19.error("You need to specify a name. Read more about the documentation here.");
|
|
1320
|
+
process19.exit();
|
|
1391
1321
|
}
|
|
1392
1322
|
await makeLanguage(options);
|
|
1393
1323
|
});
|
|
1394
1324
|
buddy.command("make:notification", descriptions.notification).option("-n, --name", "The name of the notification").option("-e, --email", "Is it an email notification?", { default: true }).option("-c, --chat", "Is it a chat notification?", { default: false }).option("-s, --sms", "Is it a SMS notification?", { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1395
|
-
|
|
1325
|
+
log19.debug("Running `buddy make:notification` ...", options);
|
|
1396
1326
|
const perf = await intro12("buddy make:notification");
|
|
1397
1327
|
const name = buddy.args[0] || options.name;
|
|
1398
1328
|
options.name = name;
|
|
1399
1329
|
if (!name) {
|
|
1400
|
-
|
|
1401
|
-
|
|
1330
|
+
log19.error("You need to specify a name. Read more about the documentation here.");
|
|
1331
|
+
process19.exit();
|
|
1402
1332
|
}
|
|
1403
1333
|
const result = await createNotification(options);
|
|
1404
1334
|
if (!result) {
|
|
1405
1335
|
await outro12("While running the make:notification command, there was an issue", { startTime: perf, useSeconds: true });
|
|
1406
|
-
|
|
1336
|
+
process19.exit();
|
|
1407
1337
|
}
|
|
1408
1338
|
await outro12(`Created your ${italic4(name)} notification.`, { startTime: perf, useSeconds: true });
|
|
1409
|
-
|
|
1339
|
+
process19.exit(ExitCode13.Success);
|
|
1410
1340
|
});
|
|
1411
1341
|
buddy.command("make:stack", descriptions.stack).option("-n, --name", "The name of the stack").option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action((options) => {
|
|
1412
|
-
|
|
1342
|
+
log19.debug("Running `buddy make:stack` ...", options);
|
|
1413
1343
|
const name = buddy.args[0] || options.name;
|
|
1414
1344
|
options.name = name;
|
|
1415
1345
|
if (!name) {
|
|
1416
|
-
|
|
1417
|
-
|
|
1346
|
+
log19.error("You need to specify a name. Read more about the documentation here.");
|
|
1347
|
+
process19.exit();
|
|
1418
1348
|
}
|
|
1419
1349
|
makeStack(options);
|
|
1420
1350
|
});
|
|
1421
1351
|
buddy.command("make:model", descriptions.model).option("-n, --name", "The name of the model").action(async (options) => {
|
|
1422
|
-
|
|
1352
|
+
log19.debug("Running `buddy make:model` ...", options);
|
|
1423
1353
|
const name = buddy.args[0] || options.name;
|
|
1424
1354
|
options.name = name;
|
|
1425
1355
|
if (!name) {
|
|
1426
|
-
|
|
1427
|
-
|
|
1356
|
+
log19.error("You need to specify a model name");
|
|
1357
|
+
process19.exit();
|
|
1428
1358
|
}
|
|
1429
1359
|
await createModel(options);
|
|
1430
1360
|
});
|
|
1431
1361
|
buddy.command("make:migration", descriptions.migration).option("-n, --name", "The name of the migration").option("-e, --env", "The environment to run the migration in", { default: "dev" }).action((options) => {
|
|
1432
|
-
|
|
1362
|
+
log19.debug("Running `buddy make:migration` ...", options);
|
|
1433
1363
|
const name = buddy.args[0] || options.name;
|
|
1434
1364
|
options.name = name;
|
|
1435
1365
|
if (!name) {
|
|
1436
|
-
|
|
1437
|
-
|
|
1366
|
+
log19.error("You need to specify a migration name");
|
|
1367
|
+
process19.exit();
|
|
1438
1368
|
}
|
|
1439
|
-
|
|
1369
|
+
log19.info(path, name);
|
|
1370
|
+
});
|
|
1371
|
+
buddy.command("make:certificate", descriptions.certificate).alias("make:cert").example("buddy make:certificate").action(async (options) => {
|
|
1372
|
+
log19.debug("Running `buddy make:certificate` ...", options);
|
|
1373
|
+
const domain = await localUrl();
|
|
1374
|
+
log19.info(`Creating SSL certificate...`);
|
|
1375
|
+
await runCommand8(`mkcert ${domain}`, {
|
|
1376
|
+
cwd: p4.projectStoragePath("keys")
|
|
1377
|
+
});
|
|
1378
|
+
log19.success("Certificate created");
|
|
1379
|
+
log19.info(`Installing SSL certificate...`);
|
|
1380
|
+
await runCommand8(`mkcert -install`, {
|
|
1381
|
+
cwd: p4.projectStoragePath("keys")
|
|
1382
|
+
});
|
|
1383
|
+
log19.success("Certificate installed");
|
|
1440
1384
|
});
|
|
1441
1385
|
buddy.on("make:*", () => {
|
|
1442
1386
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1443
|
-
|
|
1387
|
+
process19.exit(1);
|
|
1444
1388
|
});
|
|
1445
1389
|
}
|
|
1446
1390
|
|
|
1447
1391
|
// src/commands/migrate.ts
|
|
1448
|
-
import
|
|
1449
|
-
import {ExitCode as
|
|
1450
|
-
import {runAction as
|
|
1451
|
-
import {intro as intro13, log as
|
|
1392
|
+
import process20 from "process";
|
|
1393
|
+
import {ExitCode as ExitCode14} from "@stacksjs/types";
|
|
1394
|
+
import {runAction as runAction12} from "@stacksjs/actions";
|
|
1395
|
+
import {intro as intro13, log as log20, outro as outro13} from "@stacksjs/cli";
|
|
1452
1396
|
import {Action as Action11} from "@stacksjs/enums";
|
|
1453
1397
|
function migrate(buddy) {
|
|
1454
1398
|
const descriptions = {
|
|
@@ -1458,39 +1402,146 @@ function migrate(buddy) {
|
|
|
1458
1402
|
verbose: "Enable verbose output"
|
|
1459
1403
|
};
|
|
1460
1404
|
buddy.command("migrate", descriptions.migrate).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1461
|
-
|
|
1405
|
+
log20.debug("Running `buddy migrate` ...", options);
|
|
1462
1406
|
const perf = await intro13("buddy migrate");
|
|
1463
|
-
const result = await
|
|
1407
|
+
const result = await runAction12(Action11.Migrate, { ...options });
|
|
1464
1408
|
if (result.isErr()) {
|
|
1465
1409
|
await outro13("While running the migrate command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1466
|
-
|
|
1410
|
+
process20.exit();
|
|
1467
1411
|
}
|
|
1468
|
-
const APP_ENV =
|
|
1412
|
+
const APP_ENV = process20.env.APP_ENV || "local";
|
|
1469
1413
|
await outro13(`Migrated your ${APP_ENV} database.`, { startTime: perf, useSeconds: true });
|
|
1470
|
-
|
|
1414
|
+
process20.exit(ExitCode14.Success);
|
|
1471
1415
|
});
|
|
1472
1416
|
buddy.command("migrate:dns", descriptions.migrate).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1473
|
-
|
|
1417
|
+
log20.debug("Running `buddy migrate:dns` ...", options);
|
|
1474
1418
|
const perf = await intro13("buddy migrate:dns");
|
|
1475
|
-
const result = await
|
|
1419
|
+
const result = await runAction12(Action11.MigrateDns, { ...options });
|
|
1476
1420
|
if (result.isErr()) {
|
|
1477
1421
|
await outro13("While running the migrate:dns command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1478
|
-
|
|
1422
|
+
process20.exit();
|
|
1479
1423
|
}
|
|
1480
|
-
const APP_URL =
|
|
1424
|
+
const APP_URL = process20.env.APP_URL || "undefined";
|
|
1481
1425
|
await outro13(`Migrated your ${APP_URL} DNS.`, { startTime: perf, useSeconds: true });
|
|
1482
|
-
|
|
1426
|
+
process20.exit(ExitCode14.Success);
|
|
1483
1427
|
});
|
|
1484
1428
|
buddy.on("migrate:*", () => {
|
|
1429
|
+
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1430
|
+
process20.exit(1);
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
// src/commands/ports.ts
|
|
1435
|
+
import process21 from "process";
|
|
1436
|
+
import {ExitCode as ExitCode15} from "@stacksjs/types";
|
|
1437
|
+
import {ports as projectPorts} from "@stacksjs/config";
|
|
1438
|
+
import {log as log21} from "@stacksjs/logging";
|
|
1439
|
+
import {findProjectPath, path as p5, projectPath as projectPath2} from "@stacksjs/path";
|
|
1440
|
+
var {$: $2 } = globalThis.Bun;
|
|
1441
|
+
import {intro as intro14, italic as italic5, outro as outro14} from "@stacksjs/cli";
|
|
1442
|
+
import {findStacksProjects} from "@stacksjs/utils";
|
|
1443
|
+
function ports(buddy) {
|
|
1444
|
+
const descriptions = {
|
|
1445
|
+
command: "Let buddy check your project for potential issues and misconfigurations",
|
|
1446
|
+
ports: "Check if the ports are available",
|
|
1447
|
+
project: "Target a specific project",
|
|
1448
|
+
verbose: "Enable verbose output"
|
|
1449
|
+
};
|
|
1450
|
+
buddy.command("ports", descriptions.command).option("-l, --list", "List the used ports", { default: true }).option("-c, --check", "Check if the ports are available", { default: false }).option("-p, --project [name]", descriptions.project, { default: undefined }).option("-q, --quiet", "Use minimal output", { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1451
|
+
log21.debug("Running `buddy ports` ...", options);
|
|
1452
|
+
let perf;
|
|
1453
|
+
if (!options.quiet)
|
|
1454
|
+
perf = await intro14("buddy ports");
|
|
1455
|
+
if (options.project) {
|
|
1456
|
+
const path10 = await findProjectPath(options.project);
|
|
1457
|
+
log21.debug(`Path: ${path10}`);
|
|
1458
|
+
const ports2 = await getPortsForProjectPath(path10, options);
|
|
1459
|
+
log21.debug(`./buddy ports --quiet response for ${projectPath2}`, ports2);
|
|
1460
|
+
outputPorts(ports2, options);
|
|
1461
|
+
} else {
|
|
1462
|
+
outputPorts(projectPorts, options);
|
|
1463
|
+
}
|
|
1464
|
+
if (!options.quiet)
|
|
1465
|
+
await outro14("Exited", { startTime: perf, useSeconds: false });
|
|
1466
|
+
process21.exit(ExitCode15.Success);
|
|
1467
|
+
});
|
|
1468
|
+
buddy.command("ports:list", descriptions.ports).option("-p, --project [name]", descriptions.project, { default: undefined }).option("-q, --quiet", "Use minimal output", { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1469
|
+
log21.debug("Running `buddy ports:list` ...", options);
|
|
1470
|
+
let perf;
|
|
1471
|
+
if (!options.quiet)
|
|
1472
|
+
perf = await intro14("buddy ports:list");
|
|
1473
|
+
if (options.project) {
|
|
1474
|
+
if (!options.quiet)
|
|
1475
|
+
log21.info(`Listing ports for project: ${italic5(options.project)}`);
|
|
1476
|
+
const path10 = await findProjectPath(options.project);
|
|
1477
|
+
log21.debug(`Path: ${path10}`);
|
|
1478
|
+
const ports2 = await getPortsForProjectPath(path10, options);
|
|
1479
|
+
outputPorts(ports2, options);
|
|
1480
|
+
} else {
|
|
1481
|
+
outputPorts(projectPorts, options);
|
|
1482
|
+
}
|
|
1483
|
+
if (!options.quiet)
|
|
1484
|
+
await outro14("Exited", { startTime: perf, useSeconds: false });
|
|
1485
|
+
process21.exit(ExitCode15.Success);
|
|
1486
|
+
});
|
|
1487
|
+
buddy.command("ports:check", descriptions.ports).option("-p, --project [name]", descriptions.project, { default: projectPath2() }).option("-q, --quiet", "Use minimal output", { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1488
|
+
log21.debug("Running `buddy ports:check` ...", options);
|
|
1489
|
+
let perf;
|
|
1490
|
+
if (!options.quiet)
|
|
1491
|
+
perf = await intro14("buddy ports:check");
|
|
1492
|
+
const projects = await findStacksProjects(undefined, { quiet: true });
|
|
1493
|
+
log21.debug("Running `buddy ports`");
|
|
1494
|
+
log21.debug(`Found ${projects.length} projects`);
|
|
1495
|
+
log21.debug("Projects:", projects);
|
|
1496
|
+
const projectsPorts = {};
|
|
1497
|
+
for (const project of projects)
|
|
1498
|
+
projectsPorts[project] = await getPortsForProjectPath(project, options);
|
|
1499
|
+
log21.info("ProjectsPorts:", projectsPorts);
|
|
1500
|
+
if (!options.quiet)
|
|
1501
|
+
await outro14("Exited", { startTime: perf, useSeconds: false });
|
|
1502
|
+
process21.exit(ExitCode15.Success);
|
|
1503
|
+
});
|
|
1504
|
+
buddy.on("ports:*", () => {
|
|
1485
1505
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1486
1506
|
process21.exit(1);
|
|
1487
1507
|
});
|
|
1488
1508
|
}
|
|
1509
|
+
async function getPortsForProjectPath(path10, options) {
|
|
1510
|
+
if (!options.quiet)
|
|
1511
|
+
log21.info(`Checking ports for project: ${italic5(path10)}`);
|
|
1512
|
+
$2.cwd(path10);
|
|
1513
|
+
$2.env(await import(`${path10}/.env`));
|
|
1514
|
+
const projectList = await $2`./buddy projects:list --quiet`.text();
|
|
1515
|
+
log21.debug("ProjectListResponse", projectList);
|
|
1516
|
+
const projects = projectList.split("\n").filter((line) => line.startsWith(" - ")).map((line) => line.trim().substring(4));
|
|
1517
|
+
log21.debug("Projects:", projects);
|
|
1518
|
+
const ppath = options.project ?? p5.projectPath();
|
|
1519
|
+
let projectPath3 = projects.find((project) => project.includes(ppath));
|
|
1520
|
+
log21.debug(`Checking ports for project: ${projectPath3}`);
|
|
1521
|
+
if (projectPath3 === "" || !projectPath3)
|
|
1522
|
+
projectPath3 = p5.projectPath();
|
|
1523
|
+
log21.debug(`\$ Running: ./buddy ports:list --quiet via ${projectPath3}`);
|
|
1524
|
+
const response = await $2`./buddy ports:list --quiet`.json();
|
|
1525
|
+
log21.debug(`Response for ./buddy ports:list --quiet via ${projectPath3}`, response);
|
|
1526
|
+
let validJsonString = response.replace(/(\w+)(?=\s*:)/g, '"$1"');
|
|
1527
|
+
validJsonString = validJsonString.replace(/,(\s*})/g, "$1");
|
|
1528
|
+
const ports2 = JSON.parse(validJsonString);
|
|
1529
|
+
log21.debug(`Ports for ${projectPath3}`, ports2);
|
|
1530
|
+
return ports2;
|
|
1531
|
+
}
|
|
1532
|
+
var outputPorts = function(ports2, options) {
|
|
1533
|
+
if (!options.quiet)
|
|
1534
|
+
console.log("");
|
|
1535
|
+
console.log(ports2);
|
|
1536
|
+
if (!options.quiet)
|
|
1537
|
+
console.log("");
|
|
1538
|
+
};
|
|
1489
1539
|
|
|
1490
1540
|
// src/commands/prepublish.ts
|
|
1491
1541
|
import process22 from "process";
|
|
1492
1542
|
import {Action as Action12} from "@stacksjs/enums";
|
|
1493
|
-
import {runAction as
|
|
1543
|
+
import {runAction as runAction13} from "@stacksjs/actions";
|
|
1544
|
+
import {log as log22} from "@stacksjs/logging";
|
|
1494
1545
|
function prepublish(buddy) {
|
|
1495
1546
|
const descriptions = {
|
|
1496
1547
|
command: "Run your prepublish script",
|
|
@@ -1498,8 +1549,8 @@ function prepublish(buddy) {
|
|
|
1498
1549
|
verbose: "Enable verbose output"
|
|
1499
1550
|
};
|
|
1500
1551
|
buddy.command("prepublish", descriptions.command).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1501
|
-
|
|
1502
|
-
await
|
|
1552
|
+
log22.debug("Running `buddy prepublish` ...", options);
|
|
1553
|
+
await runAction13(Action12.Prepublish, options);
|
|
1503
1554
|
});
|
|
1504
1555
|
buddy.on("prepublish:*", () => {
|
|
1505
1556
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
@@ -1507,31 +1558,65 @@ function prepublish(buddy) {
|
|
|
1507
1558
|
});
|
|
1508
1559
|
}
|
|
1509
1560
|
|
|
1510
|
-
// src/commands/
|
|
1561
|
+
// src/commands/projects.ts
|
|
1511
1562
|
import process23 from "process";
|
|
1512
|
-
import {Action as Action13} from "@stacksjs/enums";
|
|
1513
1563
|
import {ExitCode as ExitCode16} from "@stacksjs/types";
|
|
1514
|
-
import {intro as
|
|
1515
|
-
import {
|
|
1564
|
+
import {intro as intro15, log as log23} from "@stacksjs/cli";
|
|
1565
|
+
import {findStacksProjects as findStacksProjects2} from "@stacksjs/utils";
|
|
1566
|
+
function projects(buddy) {
|
|
1567
|
+
const descriptions = {
|
|
1568
|
+
projects: "Find all Stacks projects on your system",
|
|
1569
|
+
verbose: "Enable verbose output"
|
|
1570
|
+
};
|
|
1571
|
+
buddy.command("projects", descriptions.projects).option("-q, --quiet", "Use minimal output", { default: false }).option("-l, --list", "List all local Stacks projects", { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1572
|
+
log23.debug("Running `buddy projects` ...", options);
|
|
1573
|
+
if (!options.quiet)
|
|
1574
|
+
await intro15("buddy projects");
|
|
1575
|
+
const projects2 = await findStacksProjects2(undefined, options);
|
|
1576
|
+
for (const project of projects2)
|
|
1577
|
+
console.log(" - ", project);
|
|
1578
|
+
process23.exit(ExitCode16.Success);
|
|
1579
|
+
});
|
|
1580
|
+
buddy.command("projects:list", descriptions.projects).option("-q, --quiet", "Use minimal output", { default: false }).option("-l, --list", "List all local Stacks projects", { default: true }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1581
|
+
log23.debug("Running `buddy projects` ...", options);
|
|
1582
|
+
if (!options.quiet)
|
|
1583
|
+
await intro15("buddy projects:list");
|
|
1584
|
+
const projects2 = await findStacksProjects2(undefined, options);
|
|
1585
|
+
for (const project of projects2)
|
|
1586
|
+
console.log(" - ", project);
|
|
1587
|
+
process23.exit(ExitCode16.Success);
|
|
1588
|
+
});
|
|
1589
|
+
buddy.on("projects:*", () => {
|
|
1590
|
+
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1591
|
+
process23.exit(1);
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
// src/commands/release.ts
|
|
1596
|
+
import process24 from "process";
|
|
1597
|
+
import {Action as Action13} from "@stacksjs/enums";
|
|
1598
|
+
import {ExitCode as ExitCode17} from "@stacksjs/types";
|
|
1599
|
+
import {intro as intro16, log as log24, outro as outro15} from "@stacksjs/cli";
|
|
1600
|
+
import {runAction as runAction14} from "@stacksjs/actions";
|
|
1516
1601
|
function release(buddy) {
|
|
1517
1602
|
buddy.command("release", descriptions.release).option("--dry-run", descriptions.dryRun, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1518
|
-
|
|
1603
|
+
log24.debug("Running `buddy release` ...", options);
|
|
1519
1604
|
if (options.dryRun)
|
|
1520
|
-
|
|
1521
|
-
const startTime = await
|
|
1522
|
-
const result = await
|
|
1605
|
+
log24.warn("Dry run enabled. No changes will be made or committed.");
|
|
1606
|
+
const startTime = await intro16("buddy release");
|
|
1607
|
+
const result = await runAction14(Action13.Release, {
|
|
1523
1608
|
stdin: "inherit",
|
|
1524
1609
|
...options
|
|
1525
1610
|
});
|
|
1526
1611
|
if (result.isErr()) {
|
|
1527
|
-
|
|
1528
|
-
|
|
1612
|
+
log24.error("Failed to release", result.error);
|
|
1613
|
+
process24.exit(ExitCode17.FatalError);
|
|
1529
1614
|
}
|
|
1530
|
-
await
|
|
1615
|
+
await outro15("Triggered CI/CD Release Workflow", { startTime, useSeconds: true });
|
|
1531
1616
|
});
|
|
1532
1617
|
buddy.on("release:*", () => {
|
|
1533
1618
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1534
|
-
|
|
1619
|
+
process24.exit(1);
|
|
1535
1620
|
});
|
|
1536
1621
|
}
|
|
1537
1622
|
var descriptions = {
|
|
@@ -1542,10 +1627,10 @@ var descriptions = {
|
|
|
1542
1627
|
};
|
|
1543
1628
|
|
|
1544
1629
|
// src/commands/seed.ts
|
|
1545
|
-
import
|
|
1546
|
-
import {ExitCode as
|
|
1547
|
-
import {runAction as
|
|
1548
|
-
import {intro as
|
|
1630
|
+
import process25 from "process";
|
|
1631
|
+
import {ExitCode as ExitCode18} from "@stacksjs/types";
|
|
1632
|
+
import {runAction as runAction15} from "@stacksjs/actions";
|
|
1633
|
+
import {intro as intro17, log as log25, outro as outro16} from "@stacksjs/cli";
|
|
1549
1634
|
import {Action as Action14} from "@stacksjs/enums";
|
|
1550
1635
|
function seed(buddy) {
|
|
1551
1636
|
const descriptions2 = {
|
|
@@ -1554,31 +1639,30 @@ function seed(buddy) {
|
|
|
1554
1639
|
verbose: "Enable verbose output"
|
|
1555
1640
|
};
|
|
1556
1641
|
buddy.command("seed", descriptions2.seed).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1557
|
-
|
|
1558
|
-
const perf = await
|
|
1559
|
-
const result = await
|
|
1642
|
+
log25.debug("Running `buddy seed` ...", options);
|
|
1643
|
+
const perf = await intro17("buddy seed");
|
|
1644
|
+
const result = await runAction15(Action14.Seed, options);
|
|
1560
1645
|
if (result.isErr()) {
|
|
1561
|
-
await
|
|
1562
|
-
|
|
1646
|
+
await outro16("While running the seed command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1647
|
+
process25.exit(ExitCode18.FatalError);
|
|
1563
1648
|
}
|
|
1564
|
-
const APP_ENV =
|
|
1565
|
-
await
|
|
1566
|
-
|
|
1649
|
+
const APP_ENV = process25.env.APP_ENV || "local";
|
|
1650
|
+
await outro16(`Seeded your ${APP_ENV} database.`, { startTime: perf, useSeconds: true });
|
|
1651
|
+
process25.exit(ExitCode18.Success);
|
|
1567
1652
|
});
|
|
1568
1653
|
buddy.on("seed:*", () => {
|
|
1569
1654
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1570
|
-
|
|
1655
|
+
process25.exit(1);
|
|
1571
1656
|
});
|
|
1572
1657
|
}
|
|
1573
1658
|
|
|
1574
1659
|
// src/commands/setup.ts
|
|
1575
|
-
import
|
|
1576
|
-
import {path as
|
|
1577
|
-
import {
|
|
1578
|
-
import {
|
|
1579
|
-
import {log as
|
|
1580
|
-
import {ExitCode as
|
|
1581
|
-
var {$: $2 } = globalThis.Bun;
|
|
1660
|
+
import process26 from "process";
|
|
1661
|
+
import {path as p6} from "@stacksjs/path";
|
|
1662
|
+
import {Action as Action15} from "@stacksjs/enums";
|
|
1663
|
+
import {handleError} from "@stacksjs/error-handling";
|
|
1664
|
+
import {log as log26, runCommand as runCommand9} from "@stacksjs/cli";
|
|
1665
|
+
import {ExitCode as ExitCode19} from "@stacksjs/types";
|
|
1582
1666
|
function setup(buddy) {
|
|
1583
1667
|
const descriptions2 = {
|
|
1584
1668
|
setup: "This command ensures your project is setup correctly",
|
|
@@ -1588,122 +1672,93 @@ function setup(buddy) {
|
|
|
1588
1672
|
verbose: "Enable verbose output"
|
|
1589
1673
|
};
|
|
1590
1674
|
buddy.command("setup", descriptions2.setup).alias("ensure").option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1591
|
-
|
|
1675
|
+
log26.debug("Running `buddy setup` ...", options);
|
|
1592
1676
|
if (!await isPkgxInstalled())
|
|
1593
1677
|
await installPkgx();
|
|
1594
1678
|
await optimizePkgxDeps();
|
|
1595
1679
|
await initializeProject(options);
|
|
1596
1680
|
});
|
|
1597
1681
|
buddy.command("setup:oh-my-zsh", descriptions2.ohMyZsh).alias("upgrade:oh-my-zsh").option("--verbose", descriptions2.verbose, { default: false }).action(async (_options) => {
|
|
1598
|
-
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
log22.info(`Setting up Oh My Zsh via ${zshrcPath}...`);
|
|
1604
|
-
$2.cwd(p4.dirname(zshrcPath));
|
|
1605
|
-
let data = await $2`cat ${p4.basename(zshrcPath)}`.text();
|
|
1606
|
-
const pluginLineRegex = /^(?!#).*plugins=\(([^)]+)\)/m;
|
|
1607
|
-
const match = data.match(pluginLineRegex);
|
|
1608
|
-
if (match) {
|
|
1609
|
-
const plugins = match[1]?.split(" ");
|
|
1610
|
-
if (!plugins) {
|
|
1611
|
-
log22.error("Maybe the plugins line in your .zshrc file could not be found? If this continues being an issue, please reach out to us on Discord.");
|
|
1612
|
-
process25.exit(ExitCode18.FatalError);
|
|
1613
|
-
}
|
|
1614
|
-
if (!plugins.includes("buddy")) {
|
|
1615
|
-
plugins.push("buddy");
|
|
1616
|
-
const newPluginLine = `plugins=(${plugins.join(" ")})`;
|
|
1617
|
-
data = data.replace(pluginLineRegex, newPluginLine);
|
|
1618
|
-
await writeFile(zshrcPath, data);
|
|
1619
|
-
log22.info(`Copying buddy zsh plugin ${pluginPath} to ${customPath}...`);
|
|
1620
|
-
await runCommand8(`mkdir -p ${customPath}`);
|
|
1621
|
-
await runCommand8(`cp -rf ${pluginPath} ${customPath}`);
|
|
1622
|
-
log22.success("Copied buddy zsh plugin");
|
|
1623
|
-
} else {
|
|
1624
|
-
log22.info("Buddy is already integrated in your shell, ensuring it is updated...");
|
|
1625
|
-
await runCommand8(`cp -rf ${pluginPath} ${customPath}`);
|
|
1626
|
-
log22.success("Updated buddy zsh plugin to latest version");
|
|
1627
|
-
}
|
|
1682
|
+
log26.debug("Running `buddy setup:oh-my-zsh` ...", _options);
|
|
1683
|
+
const result = await runAction(Action15.UpgradeShell);
|
|
1684
|
+
if (result.isErr()) {
|
|
1685
|
+
log26.error(result.error);
|
|
1686
|
+
process26.exit(ExitCode19.FatalError);
|
|
1628
1687
|
}
|
|
1629
|
-
log22.success("Oh My Zsh Setup Complete");
|
|
1630
|
-
log22.info("To see changes reflect, you may need to open a new terminal window");
|
|
1631
|
-
if (process25.env.TERM_PROGRAM === "vscode")
|
|
1632
|
-
log22.info("\u2318\u21E7P terminal.create.new.terminal");
|
|
1633
1688
|
});
|
|
1634
1689
|
buddy.on("setup:*", () => {
|
|
1635
1690
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1636
|
-
|
|
1691
|
+
process26.exit(ExitCode19.FatalError);
|
|
1637
1692
|
});
|
|
1638
1693
|
}
|
|
1639
1694
|
async function isPkgxInstalled() {
|
|
1640
|
-
const result = await
|
|
1695
|
+
const result = await runCommand9("pkgx --version", { silent: true });
|
|
1641
1696
|
if (result.isOk())
|
|
1642
1697
|
return true;
|
|
1643
1698
|
return false;
|
|
1644
1699
|
}
|
|
1645
1700
|
async function installPkgx() {
|
|
1646
|
-
const result = await
|
|
1701
|
+
const result = await runCommand9(p6.frameworkPath("scripts/pkgx-install"));
|
|
1647
1702
|
if (result.isOk())
|
|
1648
1703
|
return;
|
|
1649
|
-
|
|
1650
|
-
|
|
1704
|
+
handleError(result.error);
|
|
1705
|
+
process26.exit(ExitCode19.FatalError);
|
|
1651
1706
|
}
|
|
1652
1707
|
async function initializeProject(options) {
|
|
1653
|
-
|
|
1654
|
-
const result = await
|
|
1655
|
-
cwd: options.cwd ||
|
|
1708
|
+
log26.info("Installing dependencies...");
|
|
1709
|
+
const result = await runCommand9("bun install", {
|
|
1710
|
+
cwd: options.cwd || p6.projectPath()
|
|
1656
1711
|
});
|
|
1657
1712
|
if (result.isErr()) {
|
|
1658
|
-
|
|
1659
|
-
|
|
1713
|
+
handleError(result.error);
|
|
1714
|
+
process26.exit(ExitCode19.FatalError);
|
|
1660
1715
|
}
|
|
1661
|
-
|
|
1716
|
+
log26.success("Installed node_modules");
|
|
1662
1717
|
ensureEnvIsSet(options);
|
|
1663
|
-
const keyResult = await
|
|
1664
|
-
cwd: options.cwd ||
|
|
1718
|
+
const keyResult = await runCommand9("buddy key:generate", {
|
|
1719
|
+
cwd: options.cwd || p6.projectPath()
|
|
1665
1720
|
});
|
|
1666
1721
|
if (keyResult.isErr()) {
|
|
1667
|
-
|
|
1668
|
-
|
|
1722
|
+
handleError(keyResult.error);
|
|
1723
|
+
process26.exit(ExitCode19.FatalError);
|
|
1669
1724
|
}
|
|
1670
|
-
|
|
1671
|
-
const awsResult = await
|
|
1672
|
-
cwd: options.cwd ||
|
|
1725
|
+
log26.info("Ensuring AWS is connected...");
|
|
1726
|
+
const awsResult = await runCommand9("buddy configure:aws", {
|
|
1727
|
+
cwd: options.cwd || p6.projectPath()
|
|
1673
1728
|
});
|
|
1674
1729
|
if (awsResult.isErr()) {
|
|
1675
|
-
|
|
1676
|
-
|
|
1730
|
+
handleError(awsResult.error);
|
|
1731
|
+
process26.exit(ExitCode19.FatalError);
|
|
1677
1732
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1733
|
+
log26.success("Configured AWS");
|
|
1734
|
+
log26.success("Project is setup");
|
|
1735
|
+
log26.info("Happy coding! \uD83D\uDC99");
|
|
1681
1736
|
}
|
|
1682
1737
|
async function optimizePkgxDeps() {
|
|
1683
1738
|
return new Promise((resolve2) => setTimeout(resolve2, 300));
|
|
1684
1739
|
}
|
|
1685
1740
|
async function ensureEnvIsSet(options) {
|
|
1686
|
-
|
|
1687
|
-
if (storage.doesNotExist(
|
|
1688
|
-
const envResult = await
|
|
1689
|
-
cwd: options.cwd ||
|
|
1741
|
+
log26.info("Ensuring .env exists...");
|
|
1742
|
+
if (storage.doesNotExist(p6.projectPath(".env"))) {
|
|
1743
|
+
const envResult = await runCommand9("cp .env.example .env", {
|
|
1744
|
+
cwd: options.cwd || p6.projectPath()
|
|
1690
1745
|
});
|
|
1691
1746
|
if (envResult.isErr()) {
|
|
1692
|
-
|
|
1693
|
-
|
|
1747
|
+
handleError(envResult.error);
|
|
1748
|
+
process26.exit(ExitCode19.FatalError);
|
|
1694
1749
|
}
|
|
1695
|
-
|
|
1750
|
+
log26.success(".env created");
|
|
1696
1751
|
} else {
|
|
1697
|
-
|
|
1752
|
+
log26.success(".env existed");
|
|
1698
1753
|
}
|
|
1699
1754
|
}
|
|
1700
1755
|
|
|
1701
1756
|
// src/commands/test.ts
|
|
1702
|
-
import
|
|
1703
|
-
import {runAction as
|
|
1704
|
-
import {intro as
|
|
1705
|
-
import {projectPath as
|
|
1706
|
-
import {Action as
|
|
1757
|
+
import process27 from "process";
|
|
1758
|
+
import {runAction as runAction16} from "@stacksjs/actions";
|
|
1759
|
+
import {intro as intro18, outro as outro17} from "@stacksjs/cli";
|
|
1760
|
+
import {projectPath as projectPath3} from "@stacksjs/path";
|
|
1761
|
+
import {Action as Action16} from "@stacksjs/enums";
|
|
1707
1762
|
function test(buddy) {
|
|
1708
1763
|
const descriptions2 = {
|
|
1709
1764
|
command: "Runs your test suite",
|
|
@@ -1717,76 +1772,76 @@ function test(buddy) {
|
|
|
1717
1772
|
verbose: "Enable verbose output"
|
|
1718
1773
|
};
|
|
1719
1774
|
buddy.command("test", descriptions2.command).option("--ui", descriptions2.ui, { default: false }).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: true }).action(async (options) => {
|
|
1720
|
-
const perf = await
|
|
1721
|
-
const result = await
|
|
1775
|
+
const perf = await intro18("buddy test");
|
|
1776
|
+
const result = await runAction16(Action16.Test, { ...options, cwd: projectPath3() });
|
|
1722
1777
|
if (result.isErr()) {
|
|
1723
|
-
await
|
|
1724
|
-
|
|
1778
|
+
await outro17("While running `buddy test`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1779
|
+
process27.exit();
|
|
1725
1780
|
}
|
|
1726
|
-
await
|
|
1781
|
+
await outro17("Finished running tests", { startTime: perf, useSeconds: true });
|
|
1727
1782
|
});
|
|
1728
1783
|
buddy.command("test:unit", descriptions2.unit).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1729
|
-
const perf = await
|
|
1730
|
-
const result = await
|
|
1784
|
+
const perf = await intro18("buddy test:unit");
|
|
1785
|
+
const result = await runAction16(Action16.TestUnit, { ...options, verbose: true, cwd: projectPath3() });
|
|
1731
1786
|
if (result.isErr()) {
|
|
1732
|
-
await
|
|
1733
|
-
|
|
1787
|
+
await outro17("While running `buddy test:unit`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1788
|
+
process27.exit();
|
|
1734
1789
|
}
|
|
1735
|
-
await
|
|
1790
|
+
await outro17("Finished running unit tests", { startTime: perf, useSeconds: true });
|
|
1736
1791
|
});
|
|
1737
1792
|
buddy.command("test:feature", descriptions2.feature).option("--show-report", descriptions2.showReport, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1738
|
-
const perf = await
|
|
1793
|
+
const perf = await intro18("buddy test:feature");
|
|
1739
1794
|
let result;
|
|
1740
1795
|
if (options.showReport)
|
|
1741
|
-
result = await
|
|
1796
|
+
result = await runAction16(Action16.ShowFeatureTestReport, { ...options, verbose: true, cwd: projectPath3() });
|
|
1742
1797
|
else
|
|
1743
|
-
result = await
|
|
1798
|
+
result = await runAction16(Action16.TestFeature, { ...options, verbose: true, cwd: projectPath3() });
|
|
1744
1799
|
if (result.isErr()) {
|
|
1745
|
-
await
|
|
1746
|
-
|
|
1800
|
+
await outro17("While running `buddy test:feature`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1801
|
+
process27.exit();
|
|
1747
1802
|
}
|
|
1748
|
-
await
|
|
1803
|
+
await outro17("Finished running feature tests", { startTime: perf, useSeconds: true });
|
|
1749
1804
|
});
|
|
1750
1805
|
buddy.command("test:ui", descriptions2.command).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1751
|
-
const perf = await
|
|
1752
|
-
const result = await
|
|
1806
|
+
const perf = await intro18("buddy test:ui");
|
|
1807
|
+
const result = await runAction16(Action16.TestUi, { ...options, verbose: true, cwd: projectPath3() });
|
|
1753
1808
|
if (result.isErr()) {
|
|
1754
|
-
await
|
|
1755
|
-
|
|
1809
|
+
await outro17("While running `buddy test:ui`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1810
|
+
process27.exit();
|
|
1756
1811
|
}
|
|
1757
|
-
await
|
|
1812
|
+
await outro17("Finished running tests in the browser", { startTime: perf, useSeconds: true });
|
|
1758
1813
|
});
|
|
1759
1814
|
buddy.command("test:types", descriptions2.types).alias("typecheck").option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1760
|
-
const perf = await
|
|
1761
|
-
const result = await
|
|
1815
|
+
const perf = await intro18("buddy test:types");
|
|
1816
|
+
const result = await runAction16(Action16.Typecheck, { ...options, verbose: true, cwd: projectPath3() });
|
|
1762
1817
|
if (result.isErr()) {
|
|
1763
|
-
await
|
|
1764
|
-
|
|
1818
|
+
await outro17("While running `buddy test:types`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1819
|
+
process27.exit();
|
|
1765
1820
|
}
|
|
1766
|
-
await
|
|
1821
|
+
await outro17("Finished running typecheck", { startTime: perf, useSeconds: true });
|
|
1767
1822
|
});
|
|
1768
1823
|
buddy.command("test:coverage", descriptions2.coverage).action(async (options) => {
|
|
1769
|
-
const perf = await
|
|
1770
|
-
const result = await
|
|
1824
|
+
const perf = await intro18("buddy test:coverage");
|
|
1825
|
+
const result = await runAction16(Action16.TestCoverage, { ...options, cwd: projectPath3(), verbose: true });
|
|
1771
1826
|
if (result.isErr()) {
|
|
1772
|
-
await
|
|
1773
|
-
|
|
1827
|
+
await outro17("While running `buddy test:coverage`, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1828
|
+
process27.exit();
|
|
1774
1829
|
}
|
|
1775
|
-
await
|
|
1776
|
-
|
|
1830
|
+
await outro17("Generated the test coverage report", { startTime: perf, useSeconds: true });
|
|
1831
|
+
process27.exit();
|
|
1777
1832
|
});
|
|
1778
1833
|
buddy.on("test:*", () => {
|
|
1779
1834
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1780
|
-
|
|
1835
|
+
process27.exit(1);
|
|
1781
1836
|
});
|
|
1782
1837
|
}
|
|
1783
1838
|
|
|
1784
1839
|
// src/commands/tinker.ts
|
|
1785
|
-
import
|
|
1786
|
-
import {ExitCode as
|
|
1787
|
-
import {runAction as
|
|
1788
|
-
import {intro as
|
|
1789
|
-
import {Action as
|
|
1840
|
+
import process28 from "process";
|
|
1841
|
+
import {ExitCode as ExitCode20} from "@stacksjs/types";
|
|
1842
|
+
import {runAction as runAction17} from "@stacksjs/actions";
|
|
1843
|
+
import {intro as intro19, log as log27, outro as outro18} from "@stacksjs/cli";
|
|
1844
|
+
import {Action as Action17} from "@stacksjs/enums";
|
|
1790
1845
|
function tinker(buddy) {
|
|
1791
1846
|
const descriptions2 = {
|
|
1792
1847
|
tinker: "Tinker with your code",
|
|
@@ -1794,26 +1849,27 @@ function tinker(buddy) {
|
|
|
1794
1849
|
verbose: "Enable verbose output"
|
|
1795
1850
|
};
|
|
1796
1851
|
buddy.command("tinker", descriptions2.tinker).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1797
|
-
|
|
1798
|
-
const perf = await
|
|
1799
|
-
const result = await
|
|
1852
|
+
log27.debug("Running `buddy tinker` ...", options);
|
|
1853
|
+
const perf = await intro19("buddy tinker");
|
|
1854
|
+
const result = await runAction17(Action17.Tinker, options);
|
|
1800
1855
|
if (result.isErr()) {
|
|
1801
|
-
await
|
|
1802
|
-
|
|
1856
|
+
await outro18("While running the tinker command, there was an issue", { startTime: perf, useSeconds: true }, result.error || undefined);
|
|
1857
|
+
process28.exit();
|
|
1803
1858
|
}
|
|
1804
|
-
await
|
|
1805
|
-
|
|
1859
|
+
await outro18("Tinker mode exited.", { startTime: perf, useSeconds: true });
|
|
1860
|
+
process28.exit(ExitCode20.Success);
|
|
1806
1861
|
});
|
|
1807
1862
|
buddy.on("tinker:*", () => {
|
|
1808
1863
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1809
|
-
|
|
1864
|
+
process28.exit(1);
|
|
1810
1865
|
});
|
|
1811
1866
|
}
|
|
1812
1867
|
|
|
1813
1868
|
// src/commands/types.ts
|
|
1814
|
-
import
|
|
1869
|
+
import process29 from "process";
|
|
1815
1870
|
import {generateTypes as generateTypes2} from "@stacksjs/actions";
|
|
1816
|
-
|
|
1871
|
+
import {log as log28} from "@stacksjs/logging";
|
|
1872
|
+
function types21(buddy) {
|
|
1817
1873
|
const descriptions2 = {
|
|
1818
1874
|
generate: "Generate the types of & for your library/libraries",
|
|
1819
1875
|
fix: "wip",
|
|
@@ -1821,112 +1877,139 @@ function types20(buddy) {
|
|
|
1821
1877
|
verbose: "Enable verbose output"
|
|
1822
1878
|
};
|
|
1823
1879
|
buddy.command("types:generate", descriptions2.generate).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1824
|
-
|
|
1880
|
+
log28.debug("Running `buddy types:generate` ...", options);
|
|
1825
1881
|
await generateTypes2();
|
|
1826
1882
|
});
|
|
1827
1883
|
buddy.command("types:fix", descriptions2.fix).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async () => {
|
|
1828
1884
|
});
|
|
1829
1885
|
buddy.on("types:*", () => {
|
|
1830
1886
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1831
|
-
|
|
1887
|
+
process29.exit(1);
|
|
1832
1888
|
});
|
|
1833
1889
|
}
|
|
1834
1890
|
|
|
1835
1891
|
// src/commands/upgrade.ts
|
|
1836
|
-
import
|
|
1837
|
-
import {runAction as
|
|
1838
|
-
import {intro as
|
|
1839
|
-
import {ExitCode as
|
|
1840
|
-
import {Action as
|
|
1892
|
+
import process30 from "process";
|
|
1893
|
+
import {runAction as runAction18} from "@stacksjs/actions";
|
|
1894
|
+
import {intro as intro20, log as log29, outro as outro19} from "@stacksjs/cli";
|
|
1895
|
+
import {ExitCode as ExitCode21} from "@stacksjs/types";
|
|
1896
|
+
import {Action as Action18} from "@stacksjs/enums";
|
|
1841
1897
|
function upgrade(buddy) {
|
|
1842
1898
|
const descriptions2 = {
|
|
1843
1899
|
command: "Upgrade dependencies, framework, package manager, JS/TS runtime",
|
|
1844
1900
|
framework: "Upgrade the Stacks framework",
|
|
1845
1901
|
dependencies: "Upgrade your dependencies (pkgx.yaml & package.json)",
|
|
1846
1902
|
bun: "Upgrade Bun to the latest version",
|
|
1903
|
+
shell: "Upgrade the to the latest shell integration (currently only supports Oh My Zsh)",
|
|
1904
|
+
binary: "Upgrade the `stacks` binary to the latest version. Please note, the binary is moved to the `~/.stacks/bin` directory",
|
|
1847
1905
|
all: "Upgrade Node, package manager, project dependencies, and framework",
|
|
1848
1906
|
force: "Overwrite possible local updates with remote framework updates",
|
|
1849
1907
|
select: "What are you trying to upgrade?",
|
|
1850
1908
|
project: "Target a specific project",
|
|
1851
1909
|
verbose: "Enable verbose output"
|
|
1852
1910
|
};
|
|
1853
|
-
buddy.command("upgrade", descriptions2.command).option("-
|
|
1854
|
-
|
|
1855
|
-
const perf = await
|
|
1911
|
+
buddy.command("upgrade", descriptions2.command).option("-d, --dependencies", descriptions2.dependencies, { default: false }).option("-b, --bun", descriptions2.bun, { default: false }).option("-a, --all", descriptions2.all, { default: false }).option("-f, --force", descriptions2.force, { default: false }).option("--framework", descriptions2.framework, { default: false }).option("-p, --project", descriptions2.project, { default: false }).option("-s, --shell", descriptions2.shell, { default: false }).option("-b, --binary", descriptions2.binary, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).alias("update").example("buddy upgrade -a --verbose").action(async (options) => {
|
|
1912
|
+
log29.debug("Running `buddy upgrade` ...", options);
|
|
1913
|
+
const perf = await intro20("buddy upgrade");
|
|
1856
1914
|
if (hasNoOptions2(options)) {
|
|
1857
|
-
let answers = await
|
|
1915
|
+
let answers = await log29.prompt.require().multiselect(descriptions2.select, {
|
|
1858
1916
|
options: [
|
|
1859
1917
|
{ value: "dependencies", label: "Dependencies" },
|
|
1860
1918
|
{ value: "framework", label: "Framework" },
|
|
1861
|
-
{ value: "
|
|
1862
|
-
{ value: "
|
|
1919
|
+
{ value: "bun", label: "Bun" },
|
|
1920
|
+
{ value: "shell", label: "Shell" },
|
|
1921
|
+
{ value: "binary", label: "Binary" }
|
|
1863
1922
|
]
|
|
1864
1923
|
});
|
|
1865
1924
|
if (answers !== null)
|
|
1866
|
-
|
|
1925
|
+
process30.exit(ExitCode21.InvalidArgument);
|
|
1867
1926
|
if (isString(answers))
|
|
1868
1927
|
answers = [answers];
|
|
1869
1928
|
options = answers.reduce((a, v) => ({ ...a, [v]: true }), {});
|
|
1870
1929
|
}
|
|
1871
|
-
const result = await
|
|
1930
|
+
const result = await runAction18(Action18.Upgrade, options);
|
|
1872
1931
|
if (result.isErr()) {
|
|
1873
|
-
await
|
|
1874
|
-
|
|
1932
|
+
await outro19("While running the buddy:upgrade command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1933
|
+
process30.exit();
|
|
1875
1934
|
}
|
|
1876
|
-
await
|
|
1877
|
-
|
|
1935
|
+
await outro19("Upgrade complete.", { startTime: perf, useSeconds: true });
|
|
1936
|
+
process30.exit();
|
|
1878
1937
|
});
|
|
1879
1938
|
buddy.command("upgrade:framework", descriptions2.framework).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).example("buddy upgrade:framework --verbose").action(async (options) => {
|
|
1880
|
-
|
|
1881
|
-
await
|
|
1939
|
+
log29.debug("Running `buddy upgrade:framework` ...", options);
|
|
1940
|
+
await runAction18(Action18.Upgrade, options);
|
|
1882
1941
|
});
|
|
1883
1942
|
buddy.command("upgrade:dependencies", descriptions2.dependencies).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).alias("upgrade:deps").example("buddy upgrade:dependencies --verbose").action(async (options) => {
|
|
1884
|
-
|
|
1885
|
-
await
|
|
1943
|
+
log29.debug("Running `buddy upgrade:dependencies` ...", options);
|
|
1944
|
+
await runAction18(Action18.Upgrade, options);
|
|
1886
1945
|
});
|
|
1887
1946
|
buddy.command("upgrade:bun", descriptions2.bun).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1888
|
-
|
|
1889
|
-
const perf = await
|
|
1890
|
-
const result = await
|
|
1947
|
+
log29.debug("Running `buddy upgrade:bun` ...", options);
|
|
1948
|
+
const perf = await intro20("buddy upgrade:bun");
|
|
1949
|
+
const result = await runAction18(Action18.UpgradeBun, options);
|
|
1891
1950
|
if (result.isErr()) {
|
|
1892
|
-
await
|
|
1893
|
-
|
|
1951
|
+
await outro19("While running the buddy upgrade:bun command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1952
|
+
process30.exit();
|
|
1894
1953
|
}
|
|
1895
|
-
|
|
1954
|
+
process30.exit(ExitCode21.Success);
|
|
1896
1955
|
});
|
|
1897
1956
|
buddy.command("upgrade:all", descriptions2.all).option("-p, --project", descriptions2.project, { default: false }).option("--verbose", descriptions2.verbose, { default: false }).action(async (options) => {
|
|
1898
|
-
|
|
1899
|
-
await
|
|
1957
|
+
log29.debug("Running `buddy upgrade:all` ...", options);
|
|
1958
|
+
await runAction18(Action18.Upgrade, options);
|
|
1959
|
+
});
|
|
1960
|
+
buddy.command("upgrade:shell", descriptions2.shell).option("--verbose", descriptions2.verbose, { default: false }).example("buddy upgrade:shell").action(async (options) => {
|
|
1961
|
+
log29.debug("Running `buddy upgrade:shell` ...", options);
|
|
1962
|
+
const perf = await intro20("buddy upgrade:shell");
|
|
1963
|
+
const result = await runAction18(Action18.UpgradeShell, options);
|
|
1964
|
+
if (result.isErr()) {
|
|
1965
|
+
await outro19("While running the buddy upgrade:shell command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1966
|
+
process30.exit();
|
|
1967
|
+
}
|
|
1968
|
+
process30.exit(ExitCode21.Success);
|
|
1969
|
+
});
|
|
1970
|
+
buddy.command("upgrade:binary", descriptions2.binary).option("--verbose", descriptions2.verbose, { default: false }).example("buddy upgrade:binary").action(async (options) => {
|
|
1971
|
+
if (process30.getuid && process30.getuid() !== 0) {
|
|
1972
|
+
log29.warn("To upgrade the binary, you need to run this command with sudo, or as root.");
|
|
1973
|
+
process30.exit(0);
|
|
1974
|
+
}
|
|
1975
|
+
log29.debug("Running `buddy upgrade:binary` ...", options);
|
|
1976
|
+
const perf = await intro20("buddy upgrade:binary");
|
|
1977
|
+
const result = await runAction18(Action18.UpgradeBinary, options);
|
|
1978
|
+
if (result.isErr()) {
|
|
1979
|
+
await outro19("While running the buddy upgrade:binary command, there was an issue", { startTime: perf, useSeconds: true }, result.error);
|
|
1980
|
+
process30.exit();
|
|
1981
|
+
}
|
|
1982
|
+
process30.exit(ExitCode21.Success);
|
|
1900
1983
|
});
|
|
1901
1984
|
buddy.on("upgrade:*", () => {
|
|
1902
1985
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1903
|
-
|
|
1986
|
+
process30.exit(1);
|
|
1904
1987
|
});
|
|
1905
1988
|
}
|
|
1906
1989
|
var hasNoOptions2 = function(options) {
|
|
1907
|
-
return !options.framework && !options.dependencies && !options.
|
|
1990
|
+
return !options.framework && !options.dependencies && !options.bun && !options.shell && !options.binary && !options.all;
|
|
1908
1991
|
};
|
|
1909
1992
|
|
|
1910
1993
|
// src/commands/version.ts
|
|
1911
|
-
import
|
|
1912
|
-
import {bold as bold3, dim as dim2, green, intro as
|
|
1913
|
-
import {storage as
|
|
1994
|
+
import process31 from "process";
|
|
1995
|
+
import {bold as bold3, dim as dim2, green, intro as intro21, log as log30} from "@stacksjs/cli";
|
|
1996
|
+
import {storage as storage4} from "@stacksjs/storage";
|
|
1914
1997
|
function version(buddy) {
|
|
1915
1998
|
const descriptions2 = {
|
|
1916
1999
|
version: "Retrieving Stacks build version"
|
|
1917
2000
|
};
|
|
1918
2001
|
buddy.command("version", descriptions2.version).action(async () => {
|
|
1919
|
-
|
|
1920
|
-
await
|
|
1921
|
-
const pkg = await
|
|
2002
|
+
log30.debug("Running `buddy version` ...");
|
|
2003
|
+
await intro21("buddy version");
|
|
2004
|
+
const pkg = await storage4.readPackageJson("./package.json");
|
|
1922
2005
|
const bunVersion = "wip";
|
|
1923
2006
|
const stacksVersion = pkg.version;
|
|
1924
|
-
|
|
1925
|
-
|
|
2007
|
+
log30.info(green(bold3("@stacksjs/ ")) + dim2(` ${stacksVersion}`));
|
|
2008
|
+
log30.info(green(bold3("Bun: ")) + dim2(` ${bunVersion}`));
|
|
1926
2009
|
});
|
|
1927
2010
|
buddy.on("version:*", () => {
|
|
1928
2011
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
1929
|
-
|
|
2012
|
+
process31.exit(1);
|
|
1930
2013
|
});
|
|
1931
2014
|
}
|
|
1932
|
-
export { build, changelog, clean, cloud2 as cloud, commit, configure, create, deploy, dev, startDevelopmentServer, domains, dns3 as dns, fresh, generate, http, lint, list, install2 as install, key, make, migrate, prepublish, release, seed, setup, optimizePkgxDeps, ensureEnvIsSet, test, tinker,
|
|
2015
|
+
export { build, changelog, clean, cloud2 as cloud, commit, configure, create, deploy, dev, startDevelopmentServer, domains, dns3 as dns, fresh, generate, http, lint, list, install2 as install, key, make, migrate, ports, prepublish, projects, release, seed, setup, optimizePkgxDeps, ensureEnvIsSet, test, tinker, types21 as types, upgrade, version };
|