@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.
- package/bin/create-farm-app.js +1 -0
- package/dist/index.js +68 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -18
- package/dist/index.mjs.map +1 -1
- package/dist/utils.js +2 -1
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +2 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/_renderers/solid/farm.config.ts +12 -0
- package/templates/_renderers/solid/package.json +26 -0
- package/templates/_renderers/solid/src/app/api/greeting/route.ts +15 -0
- package/templates/_renderers/solid/src/app/layout.tsx +15 -0
- package/templates/_renderers/solid/src/app/page.tsx +56 -0
- package/templates/_renderers/solid/src/app/solid.css +22 -0
- package/templates/_renderers/solid/src/components/resource-links.tsx +71 -0
- package/templates/_renderers/solid/src/lib/api-client.ts +4 -0
- package/templates/_renderers/solid/src/lib/api.generated.ts +7 -0
- package/templates/_renderers/solid/tsconfig.json +25 -0
- package/templates/_renderers/vue/farm.config.ts +12 -0
- package/templates/_renderers/vue/package.json +27 -0
- package/templates/_renderers/vue/src/app/api/greeting/route.ts +15 -0
- package/templates/_renderers/vue/src/app/layout.vue +21 -0
- package/templates/_renderers/vue/src/app/page.vue +69 -0
- package/templates/_renderers/vue/src/app/vue.css +26 -0
- package/templates/_renderers/vue/src/components/resource-links.vue +33 -0
- package/templates/_renderers/vue/src/env.d.ts +7 -0
- package/templates/_renderers/vue/src/lib/api-client.ts +4 -0
- package/templates/_renderers/vue/src/lib/api.generated.ts +7 -0
- package/templates/_renderers/vue/tsconfig.json +23 -0
- package/templates/auth/package.json +3 -3
- package/templates/basic/package.json +2 -2
- package/templates/basic/src/app/layout.tsx +1 -1
- package/templates/better-auth/package.json +3 -3
package/bin/create-farm-app.js
CHANGED
|
@@ -10,6 +10,7 @@ program
|
|
|
10
10
|
.version(version)
|
|
11
11
|
.argument("[project-name]", "Name of the project")
|
|
12
12
|
.option("-t, --template <template>", "Template to use")
|
|
13
|
+
.option("-r, --renderer <renderer>", "Rendering library to use (react, solid, or vue)")
|
|
13
14
|
.option("--list-templates", "List all available starter templates")
|
|
14
15
|
.option("--typescript", "Use TypeScript template")
|
|
15
16
|
.option("--skip-install", "Skip installing dependencies")
|
package/dist/index.js
CHANGED
|
@@ -2529,22 +2529,22 @@ function escapeRegExp(input) {
|
|
|
2529
2529
|
//#region src/index.ts
|
|
2530
2530
|
const templateDetails = {
|
|
2531
2531
|
basic: {
|
|
2532
|
-
title: "
|
|
2532
|
+
title: "Basic starter",
|
|
2533
2533
|
description: "A minimal Farm.js app with built-in Tailwind support",
|
|
2534
2534
|
instructions: ["Tailwind is enabled by default. You only need postcss config for custom plugins."]
|
|
2535
2535
|
},
|
|
2536
2536
|
auth: {
|
|
2537
|
-
title: "
|
|
2537
|
+
title: "Auth starter",
|
|
2538
2538
|
description: "Farm.js-native auth with local SQLite, secure sessions, and protected routes",
|
|
2539
2539
|
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."]
|
|
2540
2540
|
},
|
|
2541
2541
|
"better-auth": {
|
|
2542
|
-
title: "
|
|
2542
|
+
title: "Better Auth starter",
|
|
2543
2543
|
description: "Better Auth with Postgres, secure sessions, and protected routes",
|
|
2544
2544
|
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."]
|
|
2545
2545
|
},
|
|
2546
2546
|
ai: integrationTemplate({
|
|
2547
|
-
title: "
|
|
2547
|
+
title: "AI starter",
|
|
2548
2548
|
description: "AI SDK chat route with a ready-to-use chat interface",
|
|
2549
2549
|
provider: "ai",
|
|
2550
2550
|
label: "AI",
|
|
@@ -2552,7 +2552,7 @@ const templateDetails = {
|
|
|
2552
2552
|
docsPath: "/docs/integrations"
|
|
2553
2553
|
}),
|
|
2554
2554
|
auth0: integrationTemplate({
|
|
2555
|
-
title: "
|
|
2555
|
+
title: "Auth0 starter",
|
|
2556
2556
|
description: "Auth0 login, sessions, protected routes, and account controls",
|
|
2557
2557
|
provider: "auth0",
|
|
2558
2558
|
label: "Auth0",
|
|
@@ -2560,7 +2560,7 @@ const templateDetails = {
|
|
|
2560
2560
|
docsPath: "/docs/integrations/auth/auth0"
|
|
2561
2561
|
}),
|
|
2562
2562
|
authjs: integrationTemplate({
|
|
2563
|
-
title: "
|
|
2563
|
+
title: "Auth.js starter",
|
|
2564
2564
|
description: "Auth.js with GitHub OAuth and Farm-owned route mounting",
|
|
2565
2565
|
provider: "authjs",
|
|
2566
2566
|
label: "Auth.js",
|
|
@@ -2568,7 +2568,7 @@ const templateDetails = {
|
|
|
2568
2568
|
docsPath: "/docs/integrations/auth/authjs"
|
|
2569
2569
|
}),
|
|
2570
2570
|
autumn: integrationTemplate({
|
|
2571
|
-
title: "
|
|
2571
|
+
title: "Autumn starter",
|
|
2572
2572
|
description: "Autumn products, checkout, billing state, and customer portal",
|
|
2573
2573
|
provider: "autumn",
|
|
2574
2574
|
label: "Autumn",
|
|
@@ -2576,7 +2576,7 @@ const templateDetails = {
|
|
|
2576
2576
|
docsPath: "/docs/integrations/autumn"
|
|
2577
2577
|
}),
|
|
2578
2578
|
clerk: integrationTemplate({
|
|
2579
|
-
title: "
|
|
2579
|
+
title: "Clerk starter",
|
|
2580
2580
|
description: "Clerk authentication, account entry points, and protected routes",
|
|
2581
2581
|
provider: "clerk",
|
|
2582
2582
|
label: "Clerk",
|
|
@@ -2584,7 +2584,7 @@ const templateDetails = {
|
|
|
2584
2584
|
docsPath: "/docs/integrations/auth/clerk"
|
|
2585
2585
|
}),
|
|
2586
2586
|
"jobs-inngest": integrationTemplate({
|
|
2587
|
-
title: "
|
|
2587
|
+
title: "Inngest starter",
|
|
2588
2588
|
description: "Typed background jobs backed by Inngest",
|
|
2589
2589
|
provider: "jobs-inngest",
|
|
2590
2590
|
label: "Inngest",
|
|
@@ -2592,7 +2592,7 @@ const templateDetails = {
|
|
|
2592
2592
|
docsPath: "/docs/integrations/inngest"
|
|
2593
2593
|
}),
|
|
2594
2594
|
"jobs-trigger": integrationTemplate({
|
|
2595
|
-
title: "
|
|
2595
|
+
title: "Trigger.dev starter",
|
|
2596
2596
|
description: "Typed background jobs backed by Trigger.dev",
|
|
2597
2597
|
provider: "jobs-trigger",
|
|
2598
2598
|
label: "Trigger.dev",
|
|
@@ -2600,7 +2600,7 @@ const templateDetails = {
|
|
|
2600
2600
|
docsPath: "/docs/integrations/trigger"
|
|
2601
2601
|
}),
|
|
2602
2602
|
polar: integrationTemplate({
|
|
2603
|
-
title: "
|
|
2603
|
+
title: "Polar starter",
|
|
2604
2604
|
description: "Polar products, checkout, billing state, and customer portal",
|
|
2605
2605
|
provider: "polar",
|
|
2606
2606
|
label: "Polar",
|
|
@@ -2608,7 +2608,7 @@ const templateDetails = {
|
|
|
2608
2608
|
docsPath: "/docs/integrations/polar"
|
|
2609
2609
|
}),
|
|
2610
2610
|
resend: integrationTemplate({
|
|
2611
|
-
title: "
|
|
2611
|
+
title: "Resend starter",
|
|
2612
2612
|
description: "Resend templates, delivery, scheduling, and webhooks",
|
|
2613
2613
|
provider: "resend",
|
|
2614
2614
|
label: "Resend",
|
|
@@ -2616,7 +2616,7 @@ const templateDetails = {
|
|
|
2616
2616
|
docsPath: "/docs/integrations/email"
|
|
2617
2617
|
}),
|
|
2618
2618
|
stripe: integrationTemplate({
|
|
2619
|
-
title: "
|
|
2619
|
+
title: "Stripe starter",
|
|
2620
2620
|
description: "Stripe products, checkout, billing portal, and webhooks",
|
|
2621
2621
|
provider: "stripe",
|
|
2622
2622
|
label: "Stripe",
|
|
@@ -2624,7 +2624,7 @@ const templateDetails = {
|
|
|
2624
2624
|
docsPath: "/docs/integrations/stripe"
|
|
2625
2625
|
}),
|
|
2626
2626
|
supabase: integrationTemplate({
|
|
2627
|
-
title: "
|
|
2627
|
+
title: "Supabase starter",
|
|
2628
2628
|
description: "Supabase authentication, sessions, OAuth, and protected routes",
|
|
2629
2629
|
provider: "supabase",
|
|
2630
2630
|
label: "Supabase",
|
|
@@ -2632,7 +2632,7 @@ const templateDetails = {
|
|
|
2632
2632
|
docsPath: "/docs/integrations/auth/supabase"
|
|
2633
2633
|
}),
|
|
2634
2634
|
unkey: integrationTemplate({
|
|
2635
|
-
title: "
|
|
2635
|
+
title: "Unkey starter",
|
|
2636
2636
|
description: "Unkey API key creation, verification, and route protection",
|
|
2637
2637
|
provider: "unkey",
|
|
2638
2638
|
label: "Unkey",
|
|
@@ -2640,7 +2640,7 @@ const templateDetails = {
|
|
|
2640
2640
|
docsPath: "/docs/integrations/unkey"
|
|
2641
2641
|
}),
|
|
2642
2642
|
workos: integrationTemplate({
|
|
2643
|
-
title: "
|
|
2643
|
+
title: "WorkOS starter",
|
|
2644
2644
|
description: "WorkOS AuthKit, organization sessions, and protected routes",
|
|
2645
2645
|
provider: "workos",
|
|
2646
2646
|
label: "WorkOS",
|
|
@@ -2721,6 +2721,46 @@ async function createApp(projectName, options = {}) {
|
|
|
2721
2721
|
require_utils.logger.error(`Unknown template "${template}". Available: ${templates.map((t) => `"${t}"`).join(", ")}`);
|
|
2722
2722
|
process.exit(1);
|
|
2723
2723
|
}
|
|
2724
|
+
let renderer = options.renderer?.toLowerCase();
|
|
2725
|
+
if (renderer && renderer !== "react" && renderer !== "solid" && renderer !== "vue") {
|
|
2726
|
+
require_utils.logger.error(`Unknown renderer "${options.renderer}". Available: "react", "solid", "vue".`);
|
|
2727
|
+
process.exit(1);
|
|
2728
|
+
}
|
|
2729
|
+
if (!renderer && !options.template && template === "basic") {
|
|
2730
|
+
const response = await (0, prompts.default)({
|
|
2731
|
+
type: "select",
|
|
2732
|
+
name: "renderer",
|
|
2733
|
+
message: "Which rendering library would you like to use?",
|
|
2734
|
+
choices: [
|
|
2735
|
+
{
|
|
2736
|
+
title: "React",
|
|
2737
|
+
value: "react",
|
|
2738
|
+
description: "The default FARMJS renderer"
|
|
2739
|
+
},
|
|
2740
|
+
{
|
|
2741
|
+
title: "Solid",
|
|
2742
|
+
value: "solid",
|
|
2743
|
+
description: "Fine-grained reactivity with Solid"
|
|
2744
|
+
},
|
|
2745
|
+
{
|
|
2746
|
+
title: "Vue",
|
|
2747
|
+
value: "vue",
|
|
2748
|
+
description: "Vue SFCs with server rendering and hydration"
|
|
2749
|
+
}
|
|
2750
|
+
],
|
|
2751
|
+
initial: 0
|
|
2752
|
+
});
|
|
2753
|
+
if (!response.renderer) {
|
|
2754
|
+
require_utils.logger.error("Operation cancelled.");
|
|
2755
|
+
process.exit(1);
|
|
2756
|
+
}
|
|
2757
|
+
renderer = response.renderer;
|
|
2758
|
+
}
|
|
2759
|
+
renderer ||= "react";
|
|
2760
|
+
if (renderer !== "react" && template !== "basic") {
|
|
2761
|
+
require_utils.logger.error(`The "${template}" integration starter currently targets React. Use --template basic with --renderer ${renderer}.`);
|
|
2762
|
+
process.exit(1);
|
|
2763
|
+
}
|
|
2724
2764
|
let useTypeScript = options.typescript;
|
|
2725
2765
|
if (useTypeScript === void 0) {
|
|
2726
2766
|
const response = await (0, prompts.default)({
|
|
@@ -2750,7 +2790,7 @@ async function createApp(projectName, options = {}) {
|
|
|
2750
2790
|
}
|
|
2751
2791
|
require_utils.logger.info(`Creating FARMJS app in ${projectPath}`);
|
|
2752
2792
|
await fs_promises.default.mkdir(projectPath, { recursive: true });
|
|
2753
|
-
const integrationResult = await copyTemplate(template, projectPath, useTypeScript);
|
|
2793
|
+
const integrationResult = await copyTemplate(template, projectPath, useTypeScript, renderer);
|
|
2754
2794
|
await updatePackageJson(projectPath, projectName, packageManager);
|
|
2755
2795
|
require_utils.logger.success(`🚜 Created ${projectName}`);
|
|
2756
2796
|
if (!options.skipInstall) {
|
|
@@ -2772,13 +2812,23 @@ async function createApp(projectName, options = {}) {
|
|
|
2772
2812
|
for (const note of integrationResult.notes) require_utils.logger.info(note);
|
|
2773
2813
|
}
|
|
2774
2814
|
}
|
|
2775
|
-
async function copyTemplate(template, projectPath, useTypeScript) {
|
|
2815
|
+
async function copyTemplate(template, projectPath, useTypeScript, renderer) {
|
|
2776
2816
|
const details = templateDetails[template];
|
|
2777
2817
|
await copyDir(path.default.join(__dirname, "..", "templates", details?.integration ? "basic" : template), projectPath);
|
|
2778
2818
|
if (useTypeScript) {
|
|
2779
2819
|
const tsTemplatePath = path.default.join(__dirname, "..", "templates", "_typescript");
|
|
2780
2820
|
if (await dirExists(tsTemplatePath)) await copyDir(tsTemplatePath, projectPath);
|
|
2781
2821
|
}
|
|
2822
|
+
if (renderer === "solid") await copyDir(path.default.join(__dirname, "..", "templates", "_renderers", "solid"), projectPath);
|
|
2823
|
+
if (renderer === "vue") {
|
|
2824
|
+
const rendererTemplatePath = path.default.join(__dirname, "..", "templates", "_renderers", "vue");
|
|
2825
|
+
await Promise.all([
|
|
2826
|
+
fs_promises.default.rm(path.default.join(projectPath, "src", "app", "page.tsx"), { force: true }),
|
|
2827
|
+
fs_promises.default.rm(path.default.join(projectPath, "src", "app", "layout.tsx"), { force: true }),
|
|
2828
|
+
fs_promises.default.rm(path.default.join(projectPath, "src", "components", "resource-links.tsx"), { force: true })
|
|
2829
|
+
]);
|
|
2830
|
+
await copyDir(rendererTemplatePath, projectPath);
|
|
2831
|
+
}
|
|
2782
2832
|
if (!details?.integration) return;
|
|
2783
2833
|
const result = await addFarmIntegration({
|
|
2784
2834
|
root: projectPath,
|