@farm.js/create-app 0.1.0-beta.25 → 0.1.0-beta.28

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 (35) hide show
  1. package/bin/create-farm-app.js +1 -0
  2. package/dist/index.js +68 -18
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +68 -18
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/utils.js +2 -1
  7. package/dist/utils.js.map +1 -1
  8. package/dist/utils.mjs +2 -1
  9. package/dist/utils.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/templates/_renderers/solid/farm.config.ts +12 -0
  12. package/templates/_renderers/solid/package.json +26 -0
  13. package/templates/_renderers/solid/src/app/api/greeting/route.ts +15 -0
  14. package/templates/_renderers/solid/src/app/layout.tsx +15 -0
  15. package/templates/_renderers/solid/src/app/page.tsx +56 -0
  16. package/templates/_renderers/solid/src/app/solid.css +22 -0
  17. package/templates/_renderers/solid/src/components/resource-links.tsx +71 -0
  18. package/templates/_renderers/solid/src/lib/api-client.ts +4 -0
  19. package/templates/_renderers/solid/src/lib/api.generated.ts +7 -0
  20. package/templates/_renderers/solid/tsconfig.json +25 -0
  21. package/templates/_renderers/vue/farm.config.ts +12 -0
  22. package/templates/_renderers/vue/package.json +27 -0
  23. package/templates/_renderers/vue/src/app/api/greeting/route.ts +15 -0
  24. package/templates/_renderers/vue/src/app/layout.vue +21 -0
  25. package/templates/_renderers/vue/src/app/page.vue +69 -0
  26. package/templates/_renderers/vue/src/app/vue.css +26 -0
  27. package/templates/_renderers/vue/src/components/resource-links.vue +33 -0
  28. package/templates/_renderers/vue/src/env.d.ts +7 -0
  29. package/templates/_renderers/vue/src/lib/api-client.ts +4 -0
  30. package/templates/_renderers/vue/src/lib/api.generated.ts +7 -0
  31. package/templates/_renderers/vue/tsconfig.json +23 -0
  32. package/templates/auth/package.json +3 -3
  33. package/templates/basic/package.json +2 -2
  34. package/templates/basic/src/app/layout.tsx +1 -1
  35. package/templates/better-auth/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -2523,22 +2523,22 @@ function escapeRegExp(input) {
2523
2523
  //#region src/index.ts
2524
2524
  const templateDetails = {
2525
2525
  basic: {
2526
- title: "Farm.js Basic",
2526
+ title: "Basic starter",
2527
2527
  description: "A minimal Farm.js app with built-in Tailwind support",
2528
2528
  instructions: ["Tailwind is enabled by default. You only need postcss config for custom plugins."]
2529
2529
  },
2530
2530
  auth: {
2531
- title: "Farm.js Auth",
2531
+ title: "Auth starter",
2532
2532
  description: "Farm.js-native auth with local SQLite, secure sessions, and protected routes",
2533
2533
  instructions: ["FARMJS Auth uses local SQLite automatically; no auth environment variables are needed locally.", "For production, set FARM_AUTH_URL, FARM_AUTH_SECRET, and DATABASE_URL, then run the auth:migrate script."]
2534
2534
  },
2535
2535
  "better-auth": {
2536
- title: "Farm.js Better Auth",
2536
+ title: "Better Auth starter",
2537
2537
  description: "Better Auth with Postgres, secure sessions, and protected routes",
2538
2538
  instructions: ["Before starting, copy .env.example to .env.local and set DATABASE_URL and BETTER_AUTH_SECRET.", "Better Auth migrations run automatically when the auth instance starts."]
2539
2539
  },
2540
2540
  ai: integrationTemplate({
2541
- title: "Farm.js AI",
2541
+ title: "AI starter",
2542
2542
  description: "AI SDK chat route with a ready-to-use chat interface",
2543
2543
  provider: "ai",
2544
2544
  label: "AI",
@@ -2546,7 +2546,7 @@ const templateDetails = {
2546
2546
  docsPath: "/docs/integrations"
2547
2547
  }),
2548
2548
  auth0: integrationTemplate({
2549
- title: "Farm.js Auth0",
2549
+ title: "Auth0 starter",
2550
2550
  description: "Auth0 login, sessions, protected routes, and account controls",
2551
2551
  provider: "auth0",
2552
2552
  label: "Auth0",
@@ -2554,7 +2554,7 @@ const templateDetails = {
2554
2554
  docsPath: "/docs/integrations/auth/auth0"
2555
2555
  }),
2556
2556
  authjs: integrationTemplate({
2557
- title: "Farm.js Auth.js",
2557
+ title: "Auth.js starter",
2558
2558
  description: "Auth.js with GitHub OAuth and Farm-owned route mounting",
2559
2559
  provider: "authjs",
2560
2560
  label: "Auth.js",
@@ -2562,7 +2562,7 @@ const templateDetails = {
2562
2562
  docsPath: "/docs/integrations/auth/authjs"
2563
2563
  }),
2564
2564
  autumn: integrationTemplate({
2565
- title: "Farm.js Autumn",
2565
+ title: "Autumn starter",
2566
2566
  description: "Autumn products, checkout, billing state, and customer portal",
2567
2567
  provider: "autumn",
2568
2568
  label: "Autumn",
@@ -2570,7 +2570,7 @@ const templateDetails = {
2570
2570
  docsPath: "/docs/integrations/autumn"
2571
2571
  }),
2572
2572
  clerk: integrationTemplate({
2573
- title: "Farm.js Clerk",
2573
+ title: "Clerk starter",
2574
2574
  description: "Clerk authentication, account entry points, and protected routes",
2575
2575
  provider: "clerk",
2576
2576
  label: "Clerk",
@@ -2578,7 +2578,7 @@ const templateDetails = {
2578
2578
  docsPath: "/docs/integrations/auth/clerk"
2579
2579
  }),
2580
2580
  "jobs-inngest": integrationTemplate({
2581
- title: "Farm.js Inngest",
2581
+ title: "Inngest starter",
2582
2582
  description: "Typed background jobs backed by Inngest",
2583
2583
  provider: "jobs-inngest",
2584
2584
  label: "Inngest",
@@ -2586,7 +2586,7 @@ const templateDetails = {
2586
2586
  docsPath: "/docs/integrations/inngest"
2587
2587
  }),
2588
2588
  "jobs-trigger": integrationTemplate({
2589
- title: "Farm.js Trigger.dev",
2589
+ title: "Trigger.dev starter",
2590
2590
  description: "Typed background jobs backed by Trigger.dev",
2591
2591
  provider: "jobs-trigger",
2592
2592
  label: "Trigger.dev",
@@ -2594,7 +2594,7 @@ const templateDetails = {
2594
2594
  docsPath: "/docs/integrations/trigger"
2595
2595
  }),
2596
2596
  polar: integrationTemplate({
2597
- title: "Farm.js Polar",
2597
+ title: "Polar starter",
2598
2598
  description: "Polar products, checkout, billing state, and customer portal",
2599
2599
  provider: "polar",
2600
2600
  label: "Polar",
@@ -2602,7 +2602,7 @@ const templateDetails = {
2602
2602
  docsPath: "/docs/integrations/polar"
2603
2603
  }),
2604
2604
  resend: integrationTemplate({
2605
- title: "Farm.js Resend",
2605
+ title: "Resend starter",
2606
2606
  description: "Resend templates, delivery, scheduling, and webhooks",
2607
2607
  provider: "resend",
2608
2608
  label: "Resend",
@@ -2610,7 +2610,7 @@ const templateDetails = {
2610
2610
  docsPath: "/docs/integrations/email"
2611
2611
  }),
2612
2612
  stripe: integrationTemplate({
2613
- title: "Farm.js Stripe",
2613
+ title: "Stripe starter",
2614
2614
  description: "Stripe products, checkout, billing portal, and webhooks",
2615
2615
  provider: "stripe",
2616
2616
  label: "Stripe",
@@ -2618,7 +2618,7 @@ const templateDetails = {
2618
2618
  docsPath: "/docs/integrations/stripe"
2619
2619
  }),
2620
2620
  supabase: integrationTemplate({
2621
- title: "Farm.js Supabase",
2621
+ title: "Supabase starter",
2622
2622
  description: "Supabase authentication, sessions, OAuth, and protected routes",
2623
2623
  provider: "supabase",
2624
2624
  label: "Supabase",
@@ -2626,7 +2626,7 @@ const templateDetails = {
2626
2626
  docsPath: "/docs/integrations/auth/supabase"
2627
2627
  }),
2628
2628
  unkey: integrationTemplate({
2629
- title: "Farm.js Unkey",
2629
+ title: "Unkey starter",
2630
2630
  description: "Unkey API key creation, verification, and route protection",
2631
2631
  provider: "unkey",
2632
2632
  label: "Unkey",
@@ -2634,7 +2634,7 @@ const templateDetails = {
2634
2634
  docsPath: "/docs/integrations/unkey"
2635
2635
  }),
2636
2636
  workos: integrationTemplate({
2637
- title: "Farm.js WorkOS",
2637
+ title: "WorkOS starter",
2638
2638
  description: "WorkOS AuthKit, organization sessions, and protected routes",
2639
2639
  provider: "workos",
2640
2640
  label: "WorkOS",
@@ -2715,6 +2715,46 @@ async function createApp(projectName, options = {}) {
2715
2715
  logger.error(`Unknown template "${template}". Available: ${templates.map((t) => `"${t}"`).join(", ")}`);
2716
2716
  process.exit(1);
2717
2717
  }
2718
+ let renderer = options.renderer?.toLowerCase();
2719
+ if (renderer && renderer !== "react" && renderer !== "solid" && renderer !== "vue") {
2720
+ logger.error(`Unknown renderer "${options.renderer}". Available: "react", "solid", "vue".`);
2721
+ process.exit(1);
2722
+ }
2723
+ if (!renderer && !options.template && template === "basic") {
2724
+ const response = await prompts({
2725
+ type: "select",
2726
+ name: "renderer",
2727
+ message: "Which rendering library would you like to use?",
2728
+ choices: [
2729
+ {
2730
+ title: "React",
2731
+ value: "react",
2732
+ description: "The default FARMJS renderer"
2733
+ },
2734
+ {
2735
+ title: "Solid",
2736
+ value: "solid",
2737
+ description: "Fine-grained reactivity with Solid"
2738
+ },
2739
+ {
2740
+ title: "Vue",
2741
+ value: "vue",
2742
+ description: "Vue SFCs with server rendering and hydration"
2743
+ }
2744
+ ],
2745
+ initial: 0
2746
+ });
2747
+ if (!response.renderer) {
2748
+ logger.error("Operation cancelled.");
2749
+ process.exit(1);
2750
+ }
2751
+ renderer = response.renderer;
2752
+ }
2753
+ renderer ||= "react";
2754
+ if (renderer !== "react" && template !== "basic") {
2755
+ logger.error(`The "${template}" integration starter currently targets React. Use --template basic with --renderer ${renderer}.`);
2756
+ process.exit(1);
2757
+ }
2718
2758
  let useTypeScript = options.typescript;
2719
2759
  if (useTypeScript === void 0) {
2720
2760
  const response = await prompts({
@@ -2744,7 +2784,7 @@ async function createApp(projectName, options = {}) {
2744
2784
  }
2745
2785
  logger.info(`Creating FARMJS app in ${projectPath}`);
2746
2786
  await fs.mkdir(projectPath, { recursive: true });
2747
- const integrationResult = await copyTemplate(template, projectPath, useTypeScript);
2787
+ const integrationResult = await copyTemplate(template, projectPath, useTypeScript, renderer);
2748
2788
  await updatePackageJson(projectPath, projectName, packageManager);
2749
2789
  logger.success(`🚜 Created ${projectName}`);
2750
2790
  if (!options.skipInstall) {
@@ -2766,13 +2806,23 @@ async function createApp(projectName, options = {}) {
2766
2806
  for (const note of integrationResult.notes) logger.info(note);
2767
2807
  }
2768
2808
  }
2769
- async function copyTemplate(template, projectPath, useTypeScript) {
2809
+ async function copyTemplate(template, projectPath, useTypeScript, renderer) {
2770
2810
  const details = templateDetails[template];
2771
2811
  await copyDir(path.join(__dirname, "..", "templates", details?.integration ? "basic" : template), projectPath);
2772
2812
  if (useTypeScript) {
2773
2813
  const tsTemplatePath = path.join(__dirname, "..", "templates", "_typescript");
2774
2814
  if (await dirExists(tsTemplatePath)) await copyDir(tsTemplatePath, projectPath);
2775
2815
  }
2816
+ if (renderer === "solid") await copyDir(path.join(__dirname, "..", "templates", "_renderers", "solid"), projectPath);
2817
+ if (renderer === "vue") {
2818
+ const rendererTemplatePath = path.join(__dirname, "..", "templates", "_renderers", "vue");
2819
+ await Promise.all([
2820
+ fs.rm(path.join(projectPath, "src", "app", "page.tsx"), { force: true }),
2821
+ fs.rm(path.join(projectPath, "src", "app", "layout.tsx"), { force: true }),
2822
+ fs.rm(path.join(projectPath, "src", "components", "resource-links.tsx"), { force: true })
2823
+ ]);
2824
+ await copyDir(rendererTemplatePath, projectPath);
2825
+ }
2776
2826
  if (!details?.integration) return;
2777
2827
  const result = await addFarmIntegration({
2778
2828
  root: projectPath,