create-better-t-stack 2.18.1 → 2.18.3

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.
Files changed (2) hide show
  1. package/dist/index.js +119 -26
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -3369,6 +3369,34 @@ function generateReproducibleCommand(config) {
3369
3369
  return `${baseCommand}${projectPathArg} ${flags.join(" ")}`;
3370
3370
  }
3371
3371
 
3372
+ //#endregion
3373
+ //#region src/utils/open-url.ts
3374
+ async function openUrl(url) {
3375
+ const platform = process.platform;
3376
+ let command;
3377
+ let args = [];
3378
+ if (platform === "darwin") {
3379
+ command = "open";
3380
+ args = [url];
3381
+ } else if (platform === "win32") {
3382
+ command = "cmd";
3383
+ args = [
3384
+ "/c",
3385
+ "start",
3386
+ "",
3387
+ url.replace(/&/g, "^&")
3388
+ ];
3389
+ } else {
3390
+ command = "xdg-open";
3391
+ args = [url];
3392
+ }
3393
+ try {
3394
+ await execa(command, args, { stdio: "ignore" });
3395
+ } catch {
3396
+ log.message(`Please open ${url} in your browser.`);
3397
+ }
3398
+ }
3399
+
3372
3400
  //#endregion
3373
3401
  //#region src/utils/render-title.ts
3374
3402
  const TITLE_TEXT = `
@@ -3413,6 +3441,40 @@ const renderTitle = () => {
3413
3441
  } else console.log(gradient(Object.values(catppuccinTheme)).multiline(TITLE_TEXT));
3414
3442
  };
3415
3443
 
3444
+ //#endregion
3445
+ //#region src/utils/sponsors.ts
3446
+ const SPONSORS_JSON_URL = "https://sponsors.amanv.dev/sponsors.json";
3447
+ async function fetchSponsors(url = SPONSORS_JSON_URL) {
3448
+ const s = spinner();
3449
+ s.start("Fetching sponsors…");
3450
+ const response = await fetch(url);
3451
+ if (!response.ok) {
3452
+ s.stop(pc.red(`Failed to fetch sponsors: ${response.statusText}`));
3453
+ throw new Error(`Failed to fetch sponsors: ${response.statusText}`);
3454
+ }
3455
+ const sponsors = await response.json();
3456
+ s.stop("Sponsors fetched successfully!");
3457
+ return sponsors;
3458
+ }
3459
+ function displaySponsors(sponsors) {
3460
+ if (sponsors.length === 0) {
3461
+ log.info("No sponsors found. You can be the first one! ✨");
3462
+ outro(pc.cyan("Visit https://github.com/sponsors/AmanVarshney01 to become a sponsor."));
3463
+ return;
3464
+ }
3465
+ sponsors.forEach((entry, idx) => {
3466
+ const sponsor = entry.sponsor;
3467
+ const displayName = sponsor.name ?? sponsor.login;
3468
+ const tier = entry.tierName ? ` (${entry.tierName})` : "";
3469
+ log.step(`${idx + 1}. ${pc.green(displayName)}${pc.yellow(tier)}`);
3470
+ log.message(` ${pc.dim("GitHub:")} https://github.com/${sponsor.login}`);
3471
+ const website = sponsor.websiteUrl ?? sponsor.linkUrl;
3472
+ if (website) log.message(` ${pc.dim("Website:")} ${website}`);
3473
+ });
3474
+ log.message("");
3475
+ outro(pc.magenta("Visit https://github.com/sponsors/AmanVarshney01 to become a sponsor."));
3476
+ }
3477
+
3416
3478
  //#endregion
3417
3479
  //#region src/validation.ts
3418
3480
  function processAndValidateFlags(options, providedFlags, projectName) {
@@ -3746,32 +3808,63 @@ async function createProjectHandler(input) {
3746
3808
  process.exit(1);
3747
3809
  }
3748
3810
  }
3749
- const router = t.router({ init: t.procedure.meta({
3750
- description: "Create a new Better-T Stack project",
3751
- default: true
3752
- }).input(zod.tuple([ProjectNameSchema.optional(), zod.object({
3753
- yes: zod.boolean().optional().default(false).describe("Use default configuration"),
3754
- database: DatabaseSchema.optional(),
3755
- orm: ORMSchema.optional(),
3756
- auth: zod.boolean().optional(),
3757
- frontend: zod.array(FrontendSchema).optional(),
3758
- addons: zod.array(AddonsSchema).optional(),
3759
- examples: zod.array(ExamplesSchema).optional(),
3760
- git: zod.boolean().optional(),
3761
- packageManager: PackageManagerSchema.optional(),
3762
- install: zod.boolean().optional(),
3763
- dbSetup: DatabaseSetupSchema.optional(),
3764
- backend: BackendSchema.optional(),
3765
- runtime: RuntimeSchema.optional(),
3766
- api: APISchema.optional()
3767
- }).optional().default({})])).mutation(async ({ input }) => {
3768
- const [projectName, options] = input;
3769
- const combinedInput = {
3770
- projectName,
3771
- ...options
3772
- };
3773
- await createProjectHandler(combinedInput);
3774
- }) });
3811
+ const router = t.router({
3812
+ init: t.procedure.meta({
3813
+ description: "Create a new Better-T Stack project",
3814
+ default: true
3815
+ }).input(zod.tuple([ProjectNameSchema.optional(), zod.object({
3816
+ yes: zod.boolean().optional().default(false).describe("Use default configuration"),
3817
+ database: DatabaseSchema.optional(),
3818
+ orm: ORMSchema.optional(),
3819
+ auth: zod.boolean().optional(),
3820
+ frontend: zod.array(FrontendSchema).optional(),
3821
+ addons: zod.array(AddonsSchema).optional(),
3822
+ examples: zod.array(ExamplesSchema).optional(),
3823
+ git: zod.boolean().optional(),
3824
+ packageManager: PackageManagerSchema.optional(),
3825
+ install: zod.boolean().optional(),
3826
+ dbSetup: DatabaseSetupSchema.optional(),
3827
+ backend: BackendSchema.optional(),
3828
+ runtime: RuntimeSchema.optional(),
3829
+ api: APISchema.optional()
3830
+ }).optional().default({})])).mutation(async ({ input }) => {
3831
+ const [projectName, options] = input;
3832
+ const combinedInput = {
3833
+ projectName,
3834
+ ...options
3835
+ };
3836
+ await createProjectHandler(combinedInput);
3837
+ }),
3838
+ sponsors: t.procedure.meta({ description: "Show Better-T Stack sponsors" }).mutation(async () => {
3839
+ try {
3840
+ renderTitle();
3841
+ intro(pc.magenta("Better-T Stack Sponsors"));
3842
+ const sponsors = await fetchSponsors();
3843
+ displaySponsors(sponsors);
3844
+ } catch (error) {
3845
+ consola$1.error(error);
3846
+ process.exit(1);
3847
+ }
3848
+ }),
3849
+ docs: t.procedure.meta({ description: "Open Better-T Stack documentation" }).mutation(async () => {
3850
+ const DOCS_URL = "https://better-t-stack.dev/docs";
3851
+ try {
3852
+ await openUrl(DOCS_URL);
3853
+ log.success(pc.blue("Opened docs in your default browser."));
3854
+ } catch {
3855
+ log.message(`Please visit ${DOCS_URL}`);
3856
+ }
3857
+ }),
3858
+ builder: t.procedure.meta({ description: "Open the web-based stack builder" }).mutation(async () => {
3859
+ const BUILDER_URL = "https://better-t-stack.dev/new";
3860
+ try {
3861
+ await openUrl(BUILDER_URL);
3862
+ log.success(pc.blue("Opened builder in your default browser."));
3863
+ } catch {
3864
+ log.message(`Please visit ${BUILDER_URL}`);
3865
+ }
3866
+ })
3867
+ });
3775
3868
  createCli({
3776
3869
  router,
3777
3870
  name: "create-better-t-stack",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "2.18.1",
3
+ "version": "2.18.3",
4
4
  "description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,7 +43,7 @@
43
43
  "url": "git+https://github.com/AmanVarshney01/create-better-t-stack.git",
44
44
  "directory": "apps/cli"
45
45
  },
46
- "homepage": "https://better-t-stack.amanv.dev/",
46
+ "homepage": "https://better-t-stack.dev/",
47
47
  "scripts": {
48
48
  "build": "tsdown",
49
49
  "dev": "tsdown --watch",