@stacksjs/buddy 0.58.56 → 0.58.58
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-d52e40a990b45728.js → chunk-e9c0ec1a3b7be088.js} +120 -92
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/commands/configure.ts +38 -27
- package/src/commands/deploy.ts +81 -56
- package/src/commands/setup.ts +11 -9
|
@@ -416,45 +416,25 @@ function commit(buddy) {
|
|
|
416
416
|
import process6 from "process";
|
|
417
417
|
import {log as log4, outro as outro5, runCommand as runCommand2} from "@stacksjs/cli";
|
|
418
418
|
import {path as p2} from "@stacksjs/path";
|
|
419
|
-
import {config as config2} from "@stacksjs/config";
|
|
420
419
|
import {ExitCode as ExitCode5} from "@stacksjs/types";
|
|
421
420
|
function configure(buddy) {
|
|
422
421
|
const descriptions = {
|
|
423
422
|
configure: "Configure options",
|
|
424
423
|
aws: "Configure the AWS connection",
|
|
425
424
|
project: "Target a specific project",
|
|
425
|
+
profile: "The AWS profile to use",
|
|
426
426
|
verbose: "Enable verbose output"
|
|
427
427
|
};
|
|
428
428
|
buddy.command("configure", descriptions.configure).option("--aws", descriptions.aws, { default: false }).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
429
429
|
if (options?.aws) {
|
|
430
|
-
|
|
431
|
-
const result = await runCommand2("aws configure", {
|
|
432
|
-
...options,
|
|
433
|
-
cwd: p2.projectPath(),
|
|
434
|
-
stdin: "inherit"
|
|
435
|
-
});
|
|
436
|
-
if (result.isErr()) {
|
|
437
|
-
await outro5("While running the configure command, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
438
|
-
process6.exit(ExitCode5.FatalError);
|
|
439
|
-
}
|
|
440
|
-
await outro5("Exited", { startTime, useSeconds: true });
|
|
430
|
+
await configureAws(options);
|
|
441
431
|
process6.exit(ExitCode5.Success);
|
|
442
432
|
}
|
|
443
433
|
log4.info("Not implemented yet. Please use the --aws flag to configure AWS.");
|
|
444
434
|
process6.exit(ExitCode5.Success);
|
|
445
435
|
});
|
|
446
|
-
buddy.command("configure:aws", descriptions.aws).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
447
|
-
|
|
448
|
-
const result = await runCommand2(`aws configure --profile ${config2.app.url}`, {
|
|
449
|
-
...options,
|
|
450
|
-
cwd: p2.cloudPath(),
|
|
451
|
-
stdin: "inherit"
|
|
452
|
-
});
|
|
453
|
-
if (result.isErr()) {
|
|
454
|
-
await outro5("While running the cloud command, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
455
|
-
process6.exit(ExitCode5.FatalError);
|
|
456
|
-
}
|
|
457
|
-
await outro5("Exited", { startTime, useSeconds: true });
|
|
436
|
+
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) => {
|
|
437
|
+
await configureAws(options);
|
|
458
438
|
process6.exit(ExitCode5.Success);
|
|
459
439
|
});
|
|
460
440
|
buddy.on("configure:*", () => {
|
|
@@ -462,6 +442,28 @@ function configure(buddy) {
|
|
|
462
442
|
process6.exit(ExitCode5.FatalError);
|
|
463
443
|
});
|
|
464
444
|
}
|
|
445
|
+
async function configureAws(options) {
|
|
446
|
+
const startTime = performance.now();
|
|
447
|
+
const awsAccessKeyId = options?.accessKeyId ?? process6.env.AWS_ACCESS_KEY_ID;
|
|
448
|
+
const awsSecretAccessKey = options?.secretAccessKey ?? process6.env.AWS_SECRET_ACCESS_KEY;
|
|
449
|
+
const defaultRegion = "us-east-1";
|
|
450
|
+
const defaultOutputFormat = options?.output ?? "json";
|
|
451
|
+
const command = `aws configure --profile ${options.profile ?? process6.env.AWS_PROFILE}`;
|
|
452
|
+
const input = `${awsAccessKeyId}\n${awsSecretAccessKey}\n${defaultRegion}\n${defaultOutputFormat}\n`;
|
|
453
|
+
const result = await runCommand2(command, {
|
|
454
|
+
...options,
|
|
455
|
+
cwd: p2.projectPath(),
|
|
456
|
+
stdin: "pipe",
|
|
457
|
+
input
|
|
458
|
+
});
|
|
459
|
+
if (result.isErr()) {
|
|
460
|
+
await outro5("While running the cloud command, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
461
|
+
process6.exit(ExitCode5.FatalError);
|
|
462
|
+
}
|
|
463
|
+
if (options.quiet)
|
|
464
|
+
return;
|
|
465
|
+
await outro5("Exited", { startTime, useSeconds: true });
|
|
466
|
+
}
|
|
465
467
|
|
|
466
468
|
// src/commands/create.ts
|
|
467
469
|
import process7 from "process";
|
|
@@ -563,7 +565,7 @@ async function install(path5, options) {
|
|
|
563
565
|
import process8 from "process";
|
|
564
566
|
import {ExitCode as ExitCode7} from "@stacksjs/types";
|
|
565
567
|
import {runAction as runAction5} from "@stacksjs/actions";
|
|
566
|
-
import {intro as intro6, italic as italic2, log as log6, outro as outro6} from "@stacksjs/cli";
|
|
568
|
+
import {intro as intro6, italic as italic2, log as log6, outro as outro6, runCommand as runCommand4} from "@stacksjs/cli";
|
|
567
569
|
import {Action as Action5} from "@stacksjs/enums";
|
|
568
570
|
import {app} from "@stacksjs/config";
|
|
569
571
|
import {addDomain, hasUserDomainBeenAddedToCloud} from "@stacksjs/dns";
|
|
@@ -577,62 +579,82 @@ function deploy(buddy) {
|
|
|
577
579
|
const startTime = await intro6("buddy deploy");
|
|
578
580
|
const domain = options.domain || app.url;
|
|
579
581
|
if (!domain) {
|
|
580
|
-
log6.info("
|
|
581
|
-
log6.info("Please
|
|
582
|
-
|
|
583
|
-
log6.info("Alternatively, specify a domain to deploy via the `--domain` flag.");
|
|
584
|
-
console.log("");
|
|
585
|
-
log6.info(" \u27A1\uFE0F Example: `buddy deploy --domain example.com`");
|
|
586
|
-
console.log("");
|
|
587
|
-
process8.exit(ExitCode7.FatalError);
|
|
588
|
-
}
|
|
589
|
-
if (domain.includes("localhost")) {
|
|
590
|
-
log6.info("You are deploying to a local environment.");
|
|
591
|
-
log6.info("Please set your .env or ./config/app.ts properly.");
|
|
592
|
-
console.log("");
|
|
593
|
-
log6.info("Alternatively, specify a domain to deploy via the `--domain` flag.");
|
|
594
|
-
console.log("");
|
|
595
|
-
log6.info(" \u27A1\uFE0F Example: `buddy deploy --domain example.com`");
|
|
596
|
-
console.log("");
|
|
582
|
+
log6.info("No domain found in your .env or ./config/app.ts");
|
|
583
|
+
log6.info("Please ensure your domain is properly configured.");
|
|
584
|
+
log6.info("For more info, check out the docs or join our Discord.");
|
|
597
585
|
process8.exit(ExitCode7.FatalError);
|
|
598
586
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
log6.info(`${italic2("This may take a while...")}`);
|
|
603
|
-
options.domain = domain;
|
|
604
|
-
const result2 = await runAction5(Action5.Deploy, options);
|
|
605
|
-
if (result2.isErr()) {
|
|
606
|
-
await outro6("While running the `buddy deploy`, there was an issue", { startTime, useSeconds: true }, result2.error);
|
|
607
|
-
process8.exit(ExitCode7.FatalError);
|
|
608
|
-
}
|
|
609
|
-
await outro6("Deployment succeeded.", { startTime, useSeconds: true });
|
|
610
|
-
process8.exit(ExitCode7.Success);
|
|
611
|
-
}
|
|
612
|
-
console.log("");
|
|
613
|
-
log6.info(` \uD83D\uDC4B It appears to be your first ${italic2(domain)} deployment.`);
|
|
614
|
-
console.log("");
|
|
615
|
-
log6.info(italic2("Let\u2019s ensure it is all connected properly."));
|
|
616
|
-
log6.info(italic2("One moment..."));
|
|
617
|
-
console.log("");
|
|
618
|
-
options.domain = domain;
|
|
619
|
-
const result = await addDomain({
|
|
620
|
-
...options,
|
|
621
|
-
deploy: true,
|
|
622
|
-
startTime
|
|
623
|
-
});
|
|
587
|
+
await checkIfAwsIsConfigured();
|
|
588
|
+
options.domain = await configureDomain(domain, options, startTime);
|
|
589
|
+
const result = await runAction5(Action5.Deploy, options);
|
|
624
590
|
if (result.isErr()) {
|
|
625
591
|
await outro6("While running the `buddy deploy`, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
626
592
|
process8.exit(ExitCode7.FatalError);
|
|
627
593
|
}
|
|
628
|
-
await outro6("
|
|
629
|
-
process8.exit(ExitCode7.Success);
|
|
594
|
+
await outro6("Project deployed.", { startTime, useSeconds: true });
|
|
630
595
|
});
|
|
631
596
|
buddy.on("deploy:*", () => {
|
|
632
597
|
log6.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
633
598
|
process8.exit(1);
|
|
634
599
|
});
|
|
635
600
|
}
|
|
601
|
+
async function configureDomain(domain, options, startTime) {
|
|
602
|
+
if (!domain) {
|
|
603
|
+
log6.info("We could not identify a domain to deploy to.");
|
|
604
|
+
log6.info("Please set your .env or ./config/app.ts properly.");
|
|
605
|
+
console.log("");
|
|
606
|
+
log6.info("Alternatively, specify a domain to deploy via the `--domain` flag.");
|
|
607
|
+
console.log("");
|
|
608
|
+
log6.info(" \u27A1\uFE0F Example: `buddy deploy --domain example.com`");
|
|
609
|
+
console.log("");
|
|
610
|
+
process8.exit(ExitCode7.FatalError);
|
|
611
|
+
}
|
|
612
|
+
if (domain.includes("localhost")) {
|
|
613
|
+
log6.info("You are deploying to a local environment.");
|
|
614
|
+
log6.info("Please set your .env or ./config/app.ts properly.");
|
|
615
|
+
console.log("");
|
|
616
|
+
log6.info("Alternatively, specify a domain to deploy via the `--domain` flag.");
|
|
617
|
+
console.log("");
|
|
618
|
+
log6.info(" \u27A1\uFE0F Example: `buddy deploy --domain example.com`");
|
|
619
|
+
console.log("");
|
|
620
|
+
process8.exit(ExitCode7.FatalError);
|
|
621
|
+
}
|
|
622
|
+
if (await hasUserDomainBeenAddedToCloud(domain)) {
|
|
623
|
+
log6.info("Domain is properly configured");
|
|
624
|
+
log6.info("Your cloud is deploying...");
|
|
625
|
+
log6.info(`${italic2("This may take a while...")}`);
|
|
626
|
+
return domain;
|
|
627
|
+
}
|
|
628
|
+
console.log("");
|
|
629
|
+
log6.info(` \uD83D\uDC4B It appears to be your first ${italic2(domain)} deployment.`);
|
|
630
|
+
console.log("");
|
|
631
|
+
log6.info(italic2("Let\u2019s ensure it is all connected properly."));
|
|
632
|
+
log6.info(italic2("One moment..."));
|
|
633
|
+
console.log("");
|
|
634
|
+
const result = await addDomain({
|
|
635
|
+
...options,
|
|
636
|
+
deploy: true,
|
|
637
|
+
startTime
|
|
638
|
+
});
|
|
639
|
+
if (result.isErr()) {
|
|
640
|
+
await outro6("While running the `buddy deploy`, there was an issue", { startTime, useSeconds: true }, result.error);
|
|
641
|
+
process8.exit(ExitCode7.FatalError);
|
|
642
|
+
}
|
|
643
|
+
await outro6("Added your domain.", { startTime, useSeconds: true });
|
|
644
|
+
process8.exit(ExitCode7.Success);
|
|
645
|
+
}
|
|
646
|
+
async function checkIfAwsIsConfigured() {
|
|
647
|
+
log6.info("Ensuring AWS is configured...");
|
|
648
|
+
const result = await runCommand4("buddy configure:aws --quiet", {
|
|
649
|
+
silent: true
|
|
650
|
+
});
|
|
651
|
+
if (result.isErr()) {
|
|
652
|
+
log6.error("AWS is not configured properly.");
|
|
653
|
+
log6.error("Please run `buddy configure:aws` to set up your AWS credentials.");
|
|
654
|
+
process8.exit(ExitCode7.FatalError);
|
|
655
|
+
}
|
|
656
|
+
log6.success("AWS is configured");
|
|
657
|
+
}
|
|
636
658
|
|
|
637
659
|
// src/commands/dev.ts
|
|
638
660
|
import process9 from "process";
|
|
@@ -648,7 +670,7 @@ runFrontendDevServer,
|
|
|
648
670
|
runSystemTrayDevServer
|
|
649
671
|
} from "@stacksjs/actions";
|
|
650
672
|
import {ExitCode as ExitCode8} from "@stacksjs/types";
|
|
651
|
-
import {intro as intro7, log as log7, outro as outro7, prompt as prompt2, runCommand as
|
|
673
|
+
import {intro as intro7, log as log7, outro as outro7, prompt as prompt2, runCommand as runCommand5} from "@stacksjs/cli";
|
|
652
674
|
import {libsPath} from "@stacksjs/path";
|
|
653
675
|
function dev(buddy) {
|
|
654
676
|
const descriptions = {
|
|
@@ -732,7 +754,7 @@ function dev(buddy) {
|
|
|
732
754
|
});
|
|
733
755
|
buddy.command("dev:components", descriptions.components).option("-p, --project", descriptions.project, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
734
756
|
const perf = await intro7("buddy dev:components");
|
|
735
|
-
const result = await
|
|
757
|
+
const result = await runCommand5("bun run dev", {
|
|
736
758
|
cwd: libsPath("components/vue")
|
|
737
759
|
});
|
|
738
760
|
if (options.verbose)
|
|
@@ -799,7 +821,7 @@ var wantsInteractive = function(options) {
|
|
|
799
821
|
import process10 from "process";
|
|
800
822
|
import {runAction as runAction7} from "@stacksjs/actions";
|
|
801
823
|
import {bgCyan, bold as bold2, intro as intro8, italic as italic3, outro as outro8, prompts as prompts2} from "@stacksjs/cli";
|
|
802
|
-
import {config as
|
|
824
|
+
import {config as config3} from "@stacksjs/config";
|
|
803
825
|
import {addDomain as addDomain2} from "@stacksjs/dns";
|
|
804
826
|
import {ExitCode as ExitCode9} from "@stacksjs/types";
|
|
805
827
|
import {Action as Action7} from "@stacksjs/enums";
|
|
@@ -812,7 +834,7 @@ function domains(buddy) {
|
|
|
812
834
|
project: "Target a specific project",
|
|
813
835
|
verbose: "Enable verbose output"
|
|
814
836
|
};
|
|
815
|
-
const c =
|
|
837
|
+
const c = config3.dns.contactInfo;
|
|
816
838
|
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) => {
|
|
817
839
|
options.domain = domain;
|
|
818
840
|
const startTime = await intro8("buddy domains:purchase");
|
|
@@ -855,7 +877,7 @@ function domains(buddy) {
|
|
|
855
877
|
process10.exit(ExitCode9.Success);
|
|
856
878
|
});
|
|
857
879
|
buddy.command("domains:remove <domain>", descriptions.remove).option("--yes", descriptions.skip, { default: false }).option("--verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
858
|
-
const domain = options.domain ||
|
|
880
|
+
const domain = options.domain || config3.app.url;
|
|
859
881
|
const opts = { ...options, domain };
|
|
860
882
|
const startTime = await intro8("buddy domains:remove");
|
|
861
883
|
if (!opts.yes) {
|
|
@@ -886,8 +908,8 @@ function domains(buddy) {
|
|
|
886
908
|
// src/commands/dns.ts
|
|
887
909
|
import process11 from "process";
|
|
888
910
|
import {ExitCode as ExitCode10} from "@stacksjs/types";
|
|
889
|
-
import {config as
|
|
890
|
-
import {runCommand as
|
|
911
|
+
import {config as config5} from "@stacksjs/config";
|
|
912
|
+
import {runCommand as runCommand6} from "@stacksjs/cli";
|
|
891
913
|
function dns3(buddy) {
|
|
892
914
|
const descriptions = {
|
|
893
915
|
dns: "Lists the DNS records for a domain",
|
|
@@ -909,7 +931,7 @@ function dns3(buddy) {
|
|
|
909
931
|
delete options.pretty;
|
|
910
932
|
delete options.p;
|
|
911
933
|
const optionsString = Object.entries(options).filter(([key, value]) => key !== "--" && key.length > 1 && value !== false).map(([key, value]) => `--${key} ${value}`).join(" ");
|
|
912
|
-
await
|
|
934
|
+
await runCommand6(`dog ${domain || config5.app.url} ${optionsString}`);
|
|
913
935
|
process11.exit(ExitCode10.Success);
|
|
914
936
|
});
|
|
915
937
|
}
|
|
@@ -1057,7 +1079,7 @@ var hasNoOptions2 = function(options) {
|
|
|
1057
1079
|
// src/commands/http.ts
|
|
1058
1080
|
import process15 from "process";
|
|
1059
1081
|
import {ExitCode as ExitCode14} from "@stacksjs/types";
|
|
1060
|
-
import {config as
|
|
1082
|
+
import {config as config7} from "@stacksjs/config";
|
|
1061
1083
|
import {runCommandSync as runCommandSync2} from "@stacksjs/cli";
|
|
1062
1084
|
function http(buddy) {
|
|
1063
1085
|
const descriptions = {
|
|
@@ -1067,7 +1089,7 @@ function http(buddy) {
|
|
|
1067
1089
|
};
|
|
1068
1090
|
buddy.command("http [domain]", descriptions.http).option("-p, --project", descriptions.project, { default: false }).action(async (domain, options) => {
|
|
1069
1091
|
const optionsString = Object.entries(options).filter(([key, value]) => key !== "--" && key.length > 1 && value !== false).map(([key, value]) => `--${key} ${value}`).join(" ");
|
|
1070
|
-
const command = `http GET ${domain ||
|
|
1092
|
+
const command = `http GET ${domain || config7.app.url} ${optionsString}`;
|
|
1071
1093
|
console.log(`Running command: ${command}`);
|
|
1072
1094
|
runCommandSync2(command);
|
|
1073
1095
|
process15.exit(ExitCode14.Success);
|
|
@@ -1158,7 +1180,7 @@ function inspire(buddy) {
|
|
|
1158
1180
|
|
|
1159
1181
|
// src/commands/install.ts
|
|
1160
1182
|
import process19 from "process";
|
|
1161
|
-
import {runCommand as
|
|
1183
|
+
import {runCommand as runCommand7} from "@stacksjs/cli";
|
|
1162
1184
|
import {path as p3} from "@stacksjs/path";
|
|
1163
1185
|
function install2(buddy) {
|
|
1164
1186
|
const descriptions = {
|
|
@@ -1167,7 +1189,7 @@ function install2(buddy) {
|
|
|
1167
1189
|
verbose: "Enable verbose output"
|
|
1168
1190
|
};
|
|
1169
1191
|
buddy.command("install", descriptions.install).option("-p, --project", descriptions.project, { default: false }).option("-v, --verbose", descriptions.verbose, { default: false }).action(async (options) => {
|
|
1170
|
-
await
|
|
1192
|
+
await runCommand7("bun install", {
|
|
1171
1193
|
...options,
|
|
1172
1194
|
cwd: p3.projectPath()
|
|
1173
1195
|
});
|
|
@@ -1486,7 +1508,7 @@ import process26 from "process";
|
|
|
1486
1508
|
import {path as p4} from "@stacksjs/path";
|
|
1487
1509
|
import {handleError} from "@stacksjs/error-handling";
|
|
1488
1510
|
import {writeFile} from "@stacksjs/storage";
|
|
1489
|
-
import {log as log12, runCommand as
|
|
1511
|
+
import {log as log12, runCommand as runCommand8} from "@stacksjs/cli";
|
|
1490
1512
|
import {ExitCode as ExitCode20} from "@stacksjs/types";
|
|
1491
1513
|
var {$: $2 } = globalThis.Bun;
|
|
1492
1514
|
function setup(buddy) {
|
|
@@ -1521,18 +1543,17 @@ function setup(buddy) {
|
|
|
1521
1543
|
data = data.replace(pluginLineRegex, newPluginLine);
|
|
1522
1544
|
await writeFile(zshrcPath, data);
|
|
1523
1545
|
log12.info(`Copying buddy zsh plugin ${pluginPath} to ${customPath}...`);
|
|
1524
|
-
await
|
|
1525
|
-
await
|
|
1546
|
+
await runCommand8(`mkdir -p ${customPath}`);
|
|
1547
|
+
await runCommand8(`cp -rf ${pluginPath} ${customPath}`);
|
|
1526
1548
|
log12.success("Copied buddy zsh plugin");
|
|
1527
1549
|
} else {
|
|
1528
1550
|
log12.info("buddy is already integrated in your shell, updating...");
|
|
1529
|
-
await
|
|
1551
|
+
await runCommand8(`cp -rf ${pluginPath} ${customPath}`);
|
|
1530
1552
|
log12.success("Updated buddy zsh plugin");
|
|
1531
1553
|
}
|
|
1532
1554
|
}
|
|
1533
|
-
log12.success("Oh My Zsh setup complete
|
|
1555
|
+
log12.success("Oh My Zsh setup complete");
|
|
1534
1556
|
log12.info("To see changes reflect, you may need to:");
|
|
1535
|
-
log12.info("\u2318\u21E7P workbench.action.reloadWindow");
|
|
1536
1557
|
});
|
|
1537
1558
|
buddy.on("setup:*", () => {
|
|
1538
1559
|
console.error("Invalid command: %s\nSee --help for a list of available commands.", buddy.args.join(" "));
|
|
@@ -1540,13 +1561,13 @@ function setup(buddy) {
|
|
|
1540
1561
|
});
|
|
1541
1562
|
}
|
|
1542
1563
|
async function isPkgxInstalled() {
|
|
1543
|
-
const result = await
|
|
1564
|
+
const result = await runCommand8("pkgx --version", { silent: true });
|
|
1544
1565
|
if (result.isOk())
|
|
1545
1566
|
return true;
|
|
1546
1567
|
return false;
|
|
1547
1568
|
}
|
|
1548
1569
|
async function installPkgx() {
|
|
1549
|
-
const result = await
|
|
1570
|
+
const result = await runCommand8(p4.frameworkPath("scripts/pkgx-install"));
|
|
1550
1571
|
if (result.isOk())
|
|
1551
1572
|
return;
|
|
1552
1573
|
handleError(result.error);
|
|
@@ -1554,7 +1575,7 @@ async function installPkgx() {
|
|
|
1554
1575
|
}
|
|
1555
1576
|
async function initializeProject(options) {
|
|
1556
1577
|
log12.info("Installing dependencies...");
|
|
1557
|
-
const result = await
|
|
1578
|
+
const result = await runCommand8("bun install", {
|
|
1558
1579
|
cwd: options.cwd || p4.projectPath()
|
|
1559
1580
|
});
|
|
1560
1581
|
if (result.isErr()) {
|
|
@@ -1564,7 +1585,7 @@ async function initializeProject(options) {
|
|
|
1564
1585
|
log12.success("Installed node_modules");
|
|
1565
1586
|
log12.info("Ensuring .env exists...");
|
|
1566
1587
|
if (storage.doesNotExist(p4.projectPath(".env"))) {
|
|
1567
|
-
const envResult = await
|
|
1588
|
+
const envResult = await runCommand8("cp .env.example .env", {
|
|
1568
1589
|
cwd: options.cwd || p4.projectPath()
|
|
1569
1590
|
});
|
|
1570
1591
|
if (envResult.isErr()) {
|
|
@@ -1575,7 +1596,7 @@ async function initializeProject(options) {
|
|
|
1575
1596
|
} else {
|
|
1576
1597
|
log12.success(".env existed");
|
|
1577
1598
|
}
|
|
1578
|
-
const keyResult = await
|
|
1599
|
+
const keyResult = await runCommand8("buddy key:generate", {
|
|
1579
1600
|
cwd: options.cwd || p4.projectPath()
|
|
1580
1601
|
});
|
|
1581
1602
|
if (keyResult.isErr()) {
|
|
@@ -1583,6 +1604,13 @@ async function initializeProject(options) {
|
|
|
1583
1604
|
process26.exit(ExitCode20.FatalError);
|
|
1584
1605
|
}
|
|
1585
1606
|
log12.info("Ensuring AWS is connected...");
|
|
1607
|
+
const awsResult = await runCommand8("buddy configure:aws", {
|
|
1608
|
+
cwd: options.cwd || p4.projectPath()
|
|
1609
|
+
});
|
|
1610
|
+
if (awsResult.isErr()) {
|
|
1611
|
+
handleError(awsResult.error);
|
|
1612
|
+
process26.exit(ExitCode20.FatalError);
|
|
1613
|
+
}
|
|
1586
1614
|
log12.success("Configured AWS");
|
|
1587
1615
|
log12.success("Project is setup");
|
|
1588
1616
|
log12.info("Happy coding! \uD83D\uDC99");
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,6 @@ import process from 'node:process'
|
|
|
2
2
|
import type { CLI, ConfigureOptions } from '@stacksjs/types'
|
|
3
3
|
import { log, outro, runCommand } from '@stacksjs/cli'
|
|
4
4
|
import { path as p } from '@stacksjs/path'
|
|
5
|
-
import { config } from '@stacksjs/config'
|
|
6
5
|
import { ExitCode } from '@stacksjs/types'
|
|
7
6
|
|
|
8
7
|
export function configure(buddy: CLI) {
|
|
@@ -10,6 +9,7 @@ export function configure(buddy: CLI) {
|
|
|
10
9
|
configure: 'Configure options',
|
|
11
10
|
aws: 'Configure the AWS connection',
|
|
12
11
|
project: 'Target a specific project',
|
|
12
|
+
profile: 'The AWS profile to use',
|
|
13
13
|
verbose: 'Enable verbose output',
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -20,19 +20,7 @@ export function configure(buddy: CLI) {
|
|
|
20
20
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
21
21
|
.action(async (options?: ConfigureOptions) => {
|
|
22
22
|
if (options?.aws) {
|
|
23
|
-
|
|
24
|
-
const result = await runCommand('aws configure', {
|
|
25
|
-
...options,
|
|
26
|
-
cwd: p.projectPath(),
|
|
27
|
-
stdin: 'inherit',
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
if (result.isErr()) {
|
|
31
|
-
await outro('While running the configure command, there was an issue', { startTime, useSeconds: true }, result.error)
|
|
32
|
-
process.exit(ExitCode.FatalError)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
await outro('Exited', { startTime, useSeconds: true })
|
|
23
|
+
await configureAws(options)
|
|
36
24
|
process.exit(ExitCode.Success)
|
|
37
25
|
}
|
|
38
26
|
|
|
@@ -43,21 +31,15 @@ export function configure(buddy: CLI) {
|
|
|
43
31
|
buddy
|
|
44
32
|
.command('configure:aws', descriptions.aws)
|
|
45
33
|
.option('-p, --project', descriptions.project, { default: false })
|
|
34
|
+
.option('--profile', descriptions.profile, { default: process.env.AWS_PROFILE })
|
|
46
35
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
36
|
+
.option('--access-key-id', 'The AWS access key')
|
|
37
|
+
.option('--secret-access-key', 'The AWS secret access key')
|
|
38
|
+
.option('--region', 'The AWS region')
|
|
39
|
+
.option('--output', 'The AWS output format')
|
|
40
|
+
.option('--quiet', 'Suppress output')
|
|
47
41
|
.action(async (options?: ConfigureOptions) => {
|
|
48
|
-
|
|
49
|
-
const result = await runCommand(`aws configure --profile ${config.app.url}`, {
|
|
50
|
-
...options,
|
|
51
|
-
cwd: p.cloudPath(),
|
|
52
|
-
stdin: 'inherit',
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
if (result.isErr()) {
|
|
56
|
-
await outro('While running the cloud command, there was an issue', { startTime, useSeconds: true }, result.error)
|
|
57
|
-
process.exit(ExitCode.FatalError)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
await outro('Exited', { startTime, useSeconds: true })
|
|
42
|
+
await configureAws(options)
|
|
61
43
|
process.exit(ExitCode.Success)
|
|
62
44
|
})
|
|
63
45
|
|
|
@@ -66,3 +48,32 @@ export function configure(buddy: CLI) {
|
|
|
66
48
|
process.exit(ExitCode.FatalError)
|
|
67
49
|
})
|
|
68
50
|
}
|
|
51
|
+
|
|
52
|
+
async function configureAws(options: ConfigureOptions) {
|
|
53
|
+
const startTime = performance.now()
|
|
54
|
+
|
|
55
|
+
const awsAccessKeyId = options?.accessKeyId ?? process.env.AWS_ACCESS_KEY_ID
|
|
56
|
+
const awsSecretAccessKey = options?.secretAccessKey ?? process.env.AWS_SECRET_ACCESS_KEY
|
|
57
|
+
const defaultRegion = 'us-east-1' // we only support `us-east-1` for now
|
|
58
|
+
const defaultOutputFormat = options?.output ?? 'json'
|
|
59
|
+
|
|
60
|
+
const command = `aws configure --profile ${options.profile ?? process.env.AWS_PROFILE}`
|
|
61
|
+
const input = `${awsAccessKeyId}\n${awsSecretAccessKey}\n${defaultRegion}\n${defaultOutputFormat}\n`
|
|
62
|
+
|
|
63
|
+
const result = await runCommand(command, {
|
|
64
|
+
...options,
|
|
65
|
+
cwd: p.projectPath(),
|
|
66
|
+
stdin: 'pipe', // set stdin mode to 'pipe' to write to it
|
|
67
|
+
input, // the actual input to write
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
if (result.isErr()) {
|
|
71
|
+
await outro('While running the cloud command, there was an issue', { startTime, useSeconds: true }, result.error)
|
|
72
|
+
process.exit(ExitCode.FatalError)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (options.quiet)
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
await outro('Exited', { startTime, useSeconds: true })
|
|
79
|
+
}
|
package/src/commands/deploy.ts
CHANGED
|
@@ -3,7 +3,7 @@ import process from 'node:process'
|
|
|
3
3
|
import { ExitCode } from '@stacksjs/types'
|
|
4
4
|
import type { CLI, DeployOptions } from '@stacksjs/types'
|
|
5
5
|
import { runAction } from '@stacksjs/actions'
|
|
6
|
-
import { intro, italic, log, outro } from '@stacksjs/cli'
|
|
6
|
+
import { intro, italic, log, outro, runCommand } from '@stacksjs/cli'
|
|
7
7
|
import { Action } from '@stacksjs/enums'
|
|
8
8
|
import { app } from '@stacksjs/config'
|
|
9
9
|
import { addDomain, hasUserDomainBeenAddedToCloud } from '@stacksjs/dns'
|
|
@@ -25,72 +25,24 @@ export function deploy(buddy: CLI) {
|
|
|
25
25
|
const domain = options.domain || app.url
|
|
26
26
|
|
|
27
27
|
if (!domain) {
|
|
28
|
-
log.info('
|
|
29
|
-
log.info('Please
|
|
30
|
-
|
|
31
|
-
log.info('Alternatively, specify a domain to deploy via the `--domain` flag.')
|
|
32
|
-
console.log('')
|
|
33
|
-
log.info(' ➡️ Example: `buddy deploy --domain example.com`')
|
|
34
|
-
console.log('')
|
|
28
|
+
log.info('No domain found in your .env or ./config/app.ts')
|
|
29
|
+
log.info('Please ensure your domain is properly configured.')
|
|
30
|
+
log.info('For more info, check out the docs or join our Discord.')
|
|
35
31
|
process.exit(ExitCode.FatalError)
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
// TODO: add check for whether the local APP_ENV is getting deployed, if so, ask if the user meant to deploy `dev`
|
|
40
|
-
if (domain.includes('localhost')) {
|
|
41
|
-
log.info('You are deploying to a local environment.')
|
|
42
|
-
log.info('Please set your .env or ./config/app.ts properly.')
|
|
43
|
-
console.log('')
|
|
44
|
-
log.info('Alternatively, specify a domain to deploy via the `--domain` flag.')
|
|
45
|
-
console.log('')
|
|
46
|
-
log.info(' ➡️ Example: `buddy deploy --domain example.com`')
|
|
47
|
-
console.log('')
|
|
48
|
-
process.exit(ExitCode.FatalError)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (await hasUserDomainBeenAddedToCloud(domain)) {
|
|
52
|
-
log.info('Domain is properly configured')
|
|
53
|
-
log.info('Your cloud is deploying...')
|
|
54
|
-
|
|
55
|
-
log.info(`${italic('This may take a while...')}`)
|
|
56
|
-
options.domain = domain
|
|
34
|
+
await checkIfAwsIsConfigured()
|
|
57
35
|
|
|
58
|
-
|
|
59
|
-
const result = await runAction(Action.Deploy, options)
|
|
60
|
-
|
|
61
|
-
if (result.isErr()) {
|
|
62
|
-
await outro('While running the `buddy deploy`, there was an issue', { startTime, useSeconds: true }, result.error)
|
|
63
|
-
process.exit(ExitCode.FatalError)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
await outro('Deployment succeeded.', { startTime, useSeconds: true })
|
|
67
|
-
|
|
68
|
-
process.exit(ExitCode.Success)
|
|
69
|
-
}
|
|
36
|
+
options.domain = await configureDomain(domain, options, startTime)
|
|
70
37
|
|
|
71
|
-
|
|
72
|
-
// and then exit the process with prompts for the user to update their nameservers
|
|
73
|
-
console.log('')
|
|
74
|
-
log.info(` 👋 It appears to be your first ${italic(domain)} deployment.`)
|
|
75
|
-
console.log('')
|
|
76
|
-
log.info(italic('Let’s ensure it is all connected properly.'))
|
|
77
|
-
log.info(italic('One moment...'))
|
|
78
|
-
console.log('')
|
|
79
|
-
|
|
80
|
-
options.domain = domain
|
|
81
|
-
const result = await addDomain({
|
|
82
|
-
...options,
|
|
83
|
-
deploy: true,
|
|
84
|
-
startTime,
|
|
85
|
-
})
|
|
38
|
+
const result = await runAction(Action.Deploy, options)
|
|
86
39
|
|
|
87
40
|
if (result.isErr()) {
|
|
88
41
|
await outro('While running the `buddy deploy`, there was an issue', { startTime, useSeconds: true }, result.error)
|
|
89
42
|
process.exit(ExitCode.FatalError)
|
|
90
43
|
}
|
|
91
44
|
|
|
92
|
-
await outro('
|
|
93
|
-
process.exit(ExitCode.Success)
|
|
45
|
+
await outro('Project deployed.', { startTime, useSeconds: true })
|
|
94
46
|
})
|
|
95
47
|
|
|
96
48
|
buddy.on('deploy:*', () => {
|
|
@@ -98,3 +50,76 @@ export function deploy(buddy: CLI) {
|
|
|
98
50
|
process.exit(1)
|
|
99
51
|
})
|
|
100
52
|
}
|
|
53
|
+
|
|
54
|
+
async function configureDomain(domain: string, options: DeployOptions, startTime: number) {
|
|
55
|
+
if (!domain) {
|
|
56
|
+
log.info('We could not identify a domain to deploy to.')
|
|
57
|
+
log.info('Please set your .env or ./config/app.ts properly.')
|
|
58
|
+
console.log('')
|
|
59
|
+
log.info('Alternatively, specify a domain to deploy via the `--domain` flag.')
|
|
60
|
+
console.log('')
|
|
61
|
+
log.info(' ➡️ Example: `buddy deploy --domain example.com`')
|
|
62
|
+
console.log('')
|
|
63
|
+
process.exit(ExitCode.FatalError)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// TODO: we can improve this check at some point, otherwise domains that legitimately include the word localhost will fail
|
|
67
|
+
// TODO: add check for whether the local APP_ENV is getting deployed, if so, ask if the user meant to deploy `dev`
|
|
68
|
+
if (domain.includes('localhost')) {
|
|
69
|
+
log.info('You are deploying to a local environment.')
|
|
70
|
+
log.info('Please set your .env or ./config/app.ts properly.')
|
|
71
|
+
console.log('')
|
|
72
|
+
log.info('Alternatively, specify a domain to deploy via the `--domain` flag.')
|
|
73
|
+
console.log('')
|
|
74
|
+
log.info(' ➡️ Example: `buddy deploy --domain example.com`')
|
|
75
|
+
console.log('')
|
|
76
|
+
process.exit(ExitCode.FatalError)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (await hasUserDomainBeenAddedToCloud(domain)) {
|
|
80
|
+
log.info('Domain is properly configured')
|
|
81
|
+
log.info('Your cloud is deploying...')
|
|
82
|
+
|
|
83
|
+
log.info(`${italic('This may take a while...')}`)
|
|
84
|
+
|
|
85
|
+
return domain
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// if the domain hasn't been added to the user's (AWS) cloud, we will add it for them
|
|
89
|
+
// and then exit the process with prompts for the user to update their nameservers
|
|
90
|
+
console.log('')
|
|
91
|
+
log.info(` 👋 It appears to be your first ${italic(domain)} deployment.`)
|
|
92
|
+
console.log('')
|
|
93
|
+
log.info(italic('Let’s ensure it is all connected properly.'))
|
|
94
|
+
log.info(italic('One moment...'))
|
|
95
|
+
console.log('')
|
|
96
|
+
|
|
97
|
+
const result = await addDomain({
|
|
98
|
+
...options,
|
|
99
|
+
deploy: true,
|
|
100
|
+
startTime,
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
if (result.isErr()) {
|
|
104
|
+
await outro('While running the `buddy deploy`, there was an issue', { startTime, useSeconds: true }, result.error)
|
|
105
|
+
process.exit(ExitCode.FatalError)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
await outro('Added your domain.', { startTime, useSeconds: true })
|
|
109
|
+
process.exit(ExitCode.Success)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function checkIfAwsIsConfigured() {
|
|
113
|
+
log.info('Ensuring AWS is configured...')
|
|
114
|
+
const result = await runCommand('buddy configure:aws --quiet', {
|
|
115
|
+
silent: true,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
if (result.isErr()) {
|
|
119
|
+
log.error('AWS is not configured properly.')
|
|
120
|
+
log.error('Please run `buddy configure:aws` to set up your AWS credentials.')
|
|
121
|
+
process.exit(ExitCode.FatalError)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
log.success('AWS is configured')
|
|
125
|
+
}
|
package/src/commands/setup.ts
CHANGED
|
@@ -79,9 +79,11 @@ export function setup(buddy: CLI) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
log.success('Oh My Zsh setup complete
|
|
82
|
+
log.success('Oh My Zsh setup complete')
|
|
83
83
|
log.info('To see changes reflect, you may need to:')
|
|
84
|
-
|
|
84
|
+
// if on vscode show the message
|
|
85
|
+
// log.info('⌘⇧P workbench.action.reloadWindow')
|
|
86
|
+
// else show the message
|
|
85
87
|
})
|
|
86
88
|
|
|
87
89
|
buddy.on('setup:*', () => {
|
|
@@ -149,14 +151,14 @@ async function initializeProject(options: CliOptions): Promise<void> {
|
|
|
149
151
|
|
|
150
152
|
log.info('Ensuring AWS is connected...')
|
|
151
153
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
const awsResult = await runCommand('buddy configure:aws', {
|
|
155
|
+
cwd: options.cwd || p.projectPath(),
|
|
156
|
+
})
|
|
155
157
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
if (awsResult.isErr()) {
|
|
159
|
+
handleError(awsResult.error)
|
|
160
|
+
process.exit(ExitCode.FatalError)
|
|
161
|
+
}
|
|
160
162
|
|
|
161
163
|
log.success('Configured AWS')
|
|
162
164
|
|