@farm.js/create-app 0.1.0-beta.98 → 0.1.0
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/README.md +18 -7
- package/dist/index.js +298 -167
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +298 -167
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/_renderers/preact/package.json +4 -4
- package/templates/_renderers/preact/src/lib/api.ts +1 -1
- package/templates/_renderers/solid/package.json +4 -4
- package/templates/_renderers/solid/src/lib/api.ts +1 -1
- package/templates/_renderers/svelte/package.json +4 -4
- package/templates/_renderers/svelte/src/lib/api.ts +1 -1
- package/templates/_renderers/vue/package.json +4 -4
- package/templates/_renderers/vue/src/lib/api.ts +1 -1
- package/templates/auth/README.md +1 -1
- package/templates/auth/package.json +7 -7
- package/templates/auth/pnpm-workspace.yaml +1 -3
- package/templates/basic/package.json +6 -6
- package/templates/basic/pnpm-workspace.yaml +3 -0
- package/templates/better-auth/README.md +1 -1
- package/templates/better-auth/package.json +7 -7
- package/templates/better-auth/pnpm-workspace.yaml +1 -4
- package/templates/react-compiler/README.md +1 -1
- package/templates/react-compiler/package.json +7 -7
- package/templates/react-compiler/pnpm-workspace.yaml +3 -0
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Create a new FARMJS application
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
See [Stability and Support](https://farmjs.dev/docs/stability) for what this package guarantees.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
PNPM_CONFIG_DLX_CACHE_MAX_AGE=0 PNPM_CONFIG_MINIMUM_RELEASE_AGE_EXCLUDE='["@farm.js/*"]' pnpm create @farm.js/app my-app --template basic
|
|
9
9
|
cd my-app
|
|
10
10
|
pnpm dev
|
|
11
11
|
```
|
|
@@ -15,13 +15,24 @@ automatically. Every starter also registers the official
|
|
|
15
15
|
[`@farm.js/devtools`](https://farmjs.dev/docs/plugins/devtools) workspace, available at
|
|
16
16
|
`/__farm/devtools` (or `Command/Ctrl + Shift + .`) during `pnpm dev`. The command explicitly selects the minimal Basic starter. Use `pnpm create`, not
|
|
17
17
|
`pnpm add`; pnpm resolves this initializer command to the published `@farm.js/create-app` package.
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
`PNPM_CONFIG_DLX_CACHE_MAX_AGE=0` refreshes pnpm's one-day `create`/`dlx` cache so the `beta`
|
|
19
|
+
dist-tag is resolved on every run. `PNPM_CONFIG_MINIMUM_RELEASE_AGE_EXCLUDE` keeps pnpm's default
|
|
20
|
+
release-age protection enabled for third-party packages while allowing newly published
|
|
21
|
+
`@farm.js/*` betas. Generated pnpm projects preserve that scoped exclusion. Pass `--skip-install`
|
|
22
|
+
when you only want to generate the project files.
|
|
23
|
+
|
|
24
|
+
In PowerShell, set the same variables before running the command:
|
|
25
|
+
|
|
26
|
+
```powershell
|
|
27
|
+
$env:PNPM_CONFIG_DLX_CACHE_MAX_AGE = "0"
|
|
28
|
+
$env:PNPM_CONFIG_MINIMUM_RELEASE_AGE_EXCLUDE = '["@farm.js/*"]'
|
|
29
|
+
pnpm create @farm.js/app my-app --template basic
|
|
30
|
+
```
|
|
20
31
|
|
|
21
32
|
Choose React, Preact, Solid, Vue, or Svelte for the Basic and Better Auth starters:
|
|
22
33
|
|
|
23
34
|
```bash
|
|
24
|
-
|
|
35
|
+
PNPM_CONFIG_DLX_CACHE_MAX_AGE=0 PNPM_CONFIG_MINIMUM_RELEASE_AGE_EXCLUDE='["@farm.js/*"]' pnpm create @farm.js/app my-app --template better-auth --renderer solid
|
|
25
36
|
```
|
|
26
37
|
|
|
27
38
|
React remains the default when `--renderer` is omitted. The interactive Basic and Better Auth
|
|
@@ -30,7 +41,7 @@ flows also offer a renderer chooser.
|
|
|
30
41
|
List every starter:
|
|
31
42
|
|
|
32
43
|
```bash
|
|
33
|
-
|
|
44
|
+
PNPM_CONFIG_DLX_CACHE_MAX_AGE=0 PNPM_CONFIG_MINIMUM_RELEASE_AGE_EXCLUDE='["@farm.js/*"]' pnpm create @farm.js/app --list-templates
|
|
34
45
|
```
|
|
35
46
|
|
|
36
47
|
Available templates:
|
|
@@ -45,7 +56,7 @@ home page, and setup documentation. Better Auth has renderer-native UI for all f
|
|
|
45
56
|
other integration templates currently use React. For example:
|
|
46
57
|
|
|
47
58
|
```bash
|
|
48
|
-
|
|
59
|
+
PNPM_CONFIG_DLX_CACHE_MAX_AGE=0 PNPM_CONFIG_MINIMUM_RELEASE_AGE_EXCLUDE='["@farm.js/*"]' pnpm create @farm.js/app stripe-app --template stripe
|
|
49
60
|
```
|
|
50
61
|
|
|
51
62
|
See the [FARMJS repository](https://github.com/farming-labs/farm.js) for documentation, examples, and support.
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,174 @@ let node_http = require("node:http");
|
|
|
17
17
|
let node_https = require("node:https");
|
|
18
18
|
let node_os = require("node:os");
|
|
19
19
|
node_os = require_rolldown_runtime.__toESM(node_os);
|
|
20
|
+
function shadcnComponentTemplate(component) {
|
|
21
|
+
switch (component) {
|
|
22
|
+
case "badge": return `import * as React from "react";
|
|
23
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
24
|
+
import { cn } from "@/lib/utils";
|
|
25
|
+
|
|
26
|
+
const badgeVariants = cva(
|
|
27
|
+
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
28
|
+
{
|
|
29
|
+
variants: {
|
|
30
|
+
variant: {
|
|
31
|
+
default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
|
|
32
|
+
secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
33
|
+
outline: "text-foreground",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
variant: "default",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export interface BadgeProps
|
|
43
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
44
|
+
VariantProps<typeof badgeVariants> {}
|
|
45
|
+
|
|
46
|
+
export function Badge({ className, variant, ...props }: BadgeProps) {
|
|
47
|
+
return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { badgeVariants };
|
|
51
|
+
`;
|
|
52
|
+
case "button": return `import * as React from "react";
|
|
53
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
54
|
+
import { cn } from "@/lib/utils";
|
|
55
|
+
|
|
56
|
+
const buttonVariants = cva(
|
|
57
|
+
"inline-flex h-9 items-center justify-center whitespace-nowrap rounded-md px-4 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
58
|
+
{
|
|
59
|
+
variants: {
|
|
60
|
+
variant: {
|
|
61
|
+
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
62
|
+
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
63
|
+
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
64
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
65
|
+
},
|
|
66
|
+
size: {
|
|
67
|
+
default: "h-9 px-4 py-2",
|
|
68
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
69
|
+
lg: "h-10 rounded-md px-8",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
defaultVariants: {
|
|
73
|
+
variant: "default",
|
|
74
|
+
size: "default",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export interface ButtonProps
|
|
80
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
81
|
+
VariantProps<typeof buttonVariants> {}
|
|
82
|
+
|
|
83
|
+
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
84
|
+
({ className, variant, size, ...props }, ref) => {
|
|
85
|
+
return (
|
|
86
|
+
<button
|
|
87
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
88
|
+
ref={ref}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
Button.displayName = "Button";
|
|
95
|
+
|
|
96
|
+
export { buttonVariants };
|
|
97
|
+
`;
|
|
98
|
+
case "card": return `import * as React from "react";
|
|
99
|
+
import { cn } from "@/lib/utils";
|
|
100
|
+
|
|
101
|
+
export const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
102
|
+
({ className, ...props }, ref) => (
|
|
103
|
+
<div
|
|
104
|
+
ref={ref}
|
|
105
|
+
className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
),
|
|
109
|
+
);
|
|
110
|
+
Card.displayName = "Card";
|
|
111
|
+
|
|
112
|
+
export const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
113
|
+
({ className, ...props }, ref) => (
|
|
114
|
+
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
|
115
|
+
),
|
|
116
|
+
);
|
|
117
|
+
CardHeader.displayName = "CardHeader";
|
|
118
|
+
|
|
119
|
+
export const CardTitle = React.forwardRef<HTMLHeadingElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
|
120
|
+
({ className, ...props }, ref) => (
|
|
121
|
+
<h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-normal", className)} {...props} />
|
|
122
|
+
),
|
|
123
|
+
);
|
|
124
|
+
CardTitle.displayName = "CardTitle";
|
|
125
|
+
|
|
126
|
+
export const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
|
127
|
+
({ className, ...props }, ref) => (
|
|
128
|
+
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
129
|
+
),
|
|
130
|
+
);
|
|
131
|
+
CardDescription.displayName = "CardDescription";
|
|
132
|
+
|
|
133
|
+
export const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
134
|
+
({ className, ...props }, ref) => (
|
|
135
|
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
136
|
+
),
|
|
137
|
+
);
|
|
138
|
+
CardContent.displayName = "CardContent";
|
|
139
|
+
|
|
140
|
+
export const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
141
|
+
({ className, ...props }, ref) => (
|
|
142
|
+
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
CardFooter.displayName = "CardFooter";
|
|
146
|
+
`;
|
|
147
|
+
case "input": return `import * as React from "react";
|
|
148
|
+
import { cn } from "@/lib/utils";
|
|
149
|
+
|
|
150
|
+
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
|
|
151
|
+
|
|
152
|
+
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
153
|
+
({ className, type, ...props }, ref) => (
|
|
154
|
+
<input
|
|
155
|
+
type={type}
|
|
156
|
+
className={cn(
|
|
157
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
158
|
+
className,
|
|
159
|
+
)}
|
|
160
|
+
ref={ref}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
),
|
|
164
|
+
);
|
|
165
|
+
Input.displayName = "Input";
|
|
166
|
+
`;
|
|
167
|
+
case "label": return `import * as React from "react";
|
|
168
|
+
import { cn } from "@/lib/utils";
|
|
169
|
+
|
|
170
|
+
export const Label = React.forwardRef<HTMLLabelElement, React.LabelHTMLAttributes<HTMLLabelElement>>(
|
|
171
|
+
({ className, ...props }, ref) => (
|
|
172
|
+
<label
|
|
173
|
+
ref={ref}
|
|
174
|
+
className={cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", className)}
|
|
175
|
+
{...props}
|
|
176
|
+
/>
|
|
177
|
+
),
|
|
178
|
+
);
|
|
179
|
+
Label.displayName = "Label";
|
|
180
|
+
`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region ../farm-cli/src/ui-registry.ts
|
|
185
|
+
/** Value written into a generated `components.json` as `registries.farm.url`. */
|
|
186
|
+
const UI_REGISTRY_URL_TEMPLATE = "https://farmjs.dev/r/{name}.json";
|
|
187
|
+
//#endregion
|
|
20
188
|
//#region ../farm-cli/src/ui-feature-registry.ts
|
|
21
189
|
async function installUIFeature(input) {
|
|
22
190
|
const feature = input.definition.ui;
|
|
@@ -259,6 +427,16 @@ function unkeyApiKeysUIFeature() {
|
|
|
259
427
|
]
|
|
260
428
|
};
|
|
261
429
|
}
|
|
430
|
+
function sanityContentUIFeature() {
|
|
431
|
+
return {
|
|
432
|
+
name: "sanity-content",
|
|
433
|
+
description: "Sanity content list UI",
|
|
434
|
+
components: ["badge", "card"],
|
|
435
|
+
needsApiClient: false,
|
|
436
|
+
notes: ["Open \"/integrations/sanity\" to check the Sanity connection."],
|
|
437
|
+
files: () => [componentFile("sanity-content-console.tsx", sanityContentTemplate()), integrationPageFile("sanity", "SanityContentConsole")]
|
|
438
|
+
};
|
|
439
|
+
}
|
|
262
440
|
function billingUIFeature(input) {
|
|
263
441
|
return {
|
|
264
442
|
name: `${input.provider}-billing`,
|
|
@@ -561,7 +739,7 @@ function createComponentsJson() {
|
|
|
561
739
|
lib: "@/lib",
|
|
562
740
|
hooks: "@/hooks"
|
|
563
741
|
},
|
|
564
|
-
registries: { farm: { url:
|
|
742
|
+
registries: { farm: { url: UI_REGISTRY_URL_TEMPLATE } }
|
|
565
743
|
};
|
|
566
744
|
}
|
|
567
745
|
function mergeComponentsJson(current, defaults) {
|
|
@@ -604,169 +782,6 @@ import type { AppIntegrations } from "./integrations";
|
|
|
604
782
|
export const { api, apiClient } = createIntegrations<AppIntegrations>();
|
|
605
783
|
`;
|
|
606
784
|
}
|
|
607
|
-
function shadcnComponentTemplate(component) {
|
|
608
|
-
switch (component) {
|
|
609
|
-
case "badge": return `import * as React from "react";
|
|
610
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
611
|
-
import { cn } from "@/lib/utils";
|
|
612
|
-
|
|
613
|
-
const badgeVariants = cva(
|
|
614
|
-
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
615
|
-
{
|
|
616
|
-
variants: {
|
|
617
|
-
variant: {
|
|
618
|
-
default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
|
|
619
|
-
secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
620
|
-
outline: "text-foreground",
|
|
621
|
-
},
|
|
622
|
-
},
|
|
623
|
-
defaultVariants: {
|
|
624
|
-
variant: "default",
|
|
625
|
-
},
|
|
626
|
-
},
|
|
627
|
-
);
|
|
628
|
-
|
|
629
|
-
export interface BadgeProps
|
|
630
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
631
|
-
VariantProps<typeof badgeVariants> {}
|
|
632
|
-
|
|
633
|
-
export function Badge({ className, variant, ...props }: BadgeProps) {
|
|
634
|
-
return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
export { badgeVariants };
|
|
638
|
-
`;
|
|
639
|
-
case "button": return `import * as React from "react";
|
|
640
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
641
|
-
import { cn } from "@/lib/utils";
|
|
642
|
-
|
|
643
|
-
const buttonVariants = cva(
|
|
644
|
-
"inline-flex h-9 items-center justify-center whitespace-nowrap rounded-md px-4 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
645
|
-
{
|
|
646
|
-
variants: {
|
|
647
|
-
variant: {
|
|
648
|
-
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
649
|
-
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
650
|
-
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
651
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
652
|
-
},
|
|
653
|
-
size: {
|
|
654
|
-
default: "h-9 px-4 py-2",
|
|
655
|
-
sm: "h-8 rounded-md px-3 text-xs",
|
|
656
|
-
lg: "h-10 rounded-md px-8",
|
|
657
|
-
},
|
|
658
|
-
},
|
|
659
|
-
defaultVariants: {
|
|
660
|
-
variant: "default",
|
|
661
|
-
size: "default",
|
|
662
|
-
},
|
|
663
|
-
},
|
|
664
|
-
);
|
|
665
|
-
|
|
666
|
-
export interface ButtonProps
|
|
667
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
668
|
-
VariantProps<typeof buttonVariants> {}
|
|
669
|
-
|
|
670
|
-
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
671
|
-
({ className, variant, size, ...props }, ref) => {
|
|
672
|
-
return (
|
|
673
|
-
<button
|
|
674
|
-
className={cn(buttonVariants({ variant, size, className }))}
|
|
675
|
-
ref={ref}
|
|
676
|
-
{...props}
|
|
677
|
-
/>
|
|
678
|
-
);
|
|
679
|
-
},
|
|
680
|
-
);
|
|
681
|
-
Button.displayName = "Button";
|
|
682
|
-
|
|
683
|
-
export { buttonVariants };
|
|
684
|
-
`;
|
|
685
|
-
case "card": return `import * as React from "react";
|
|
686
|
-
import { cn } from "@/lib/utils";
|
|
687
|
-
|
|
688
|
-
export const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
689
|
-
({ className, ...props }, ref) => (
|
|
690
|
-
<div
|
|
691
|
-
ref={ref}
|
|
692
|
-
className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)}
|
|
693
|
-
{...props}
|
|
694
|
-
/>
|
|
695
|
-
),
|
|
696
|
-
);
|
|
697
|
-
Card.displayName = "Card";
|
|
698
|
-
|
|
699
|
-
export const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
700
|
-
({ className, ...props }, ref) => (
|
|
701
|
-
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
|
702
|
-
),
|
|
703
|
-
);
|
|
704
|
-
CardHeader.displayName = "CardHeader";
|
|
705
|
-
|
|
706
|
-
export const CardTitle = React.forwardRef<HTMLHeadingElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
|
707
|
-
({ className, ...props }, ref) => (
|
|
708
|
-
<h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-normal", className)} {...props} />
|
|
709
|
-
),
|
|
710
|
-
);
|
|
711
|
-
CardTitle.displayName = "CardTitle";
|
|
712
|
-
|
|
713
|
-
export const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
|
714
|
-
({ className, ...props }, ref) => (
|
|
715
|
-
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
716
|
-
),
|
|
717
|
-
);
|
|
718
|
-
CardDescription.displayName = "CardDescription";
|
|
719
|
-
|
|
720
|
-
export const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
721
|
-
({ className, ...props }, ref) => (
|
|
722
|
-
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
723
|
-
),
|
|
724
|
-
);
|
|
725
|
-
CardContent.displayName = "CardContent";
|
|
726
|
-
|
|
727
|
-
export const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
728
|
-
({ className, ...props }, ref) => (
|
|
729
|
-
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
|
730
|
-
),
|
|
731
|
-
);
|
|
732
|
-
CardFooter.displayName = "CardFooter";
|
|
733
|
-
`;
|
|
734
|
-
case "input": return `import * as React from "react";
|
|
735
|
-
import { cn } from "@/lib/utils";
|
|
736
|
-
|
|
737
|
-
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
|
|
738
|
-
|
|
739
|
-
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
740
|
-
({ className, type, ...props }, ref) => (
|
|
741
|
-
<input
|
|
742
|
-
type={type}
|
|
743
|
-
className={cn(
|
|
744
|
-
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
745
|
-
className,
|
|
746
|
-
)}
|
|
747
|
-
ref={ref}
|
|
748
|
-
{...props}
|
|
749
|
-
/>
|
|
750
|
-
),
|
|
751
|
-
);
|
|
752
|
-
Input.displayName = "Input";
|
|
753
|
-
`;
|
|
754
|
-
case "label": return `import * as React from "react";
|
|
755
|
-
import { cn } from "@/lib/utils";
|
|
756
|
-
|
|
757
|
-
export const Label = React.forwardRef<HTMLLabelElement, React.LabelHTMLAttributes<HTMLLabelElement>>(
|
|
758
|
-
({ className, ...props }, ref) => (
|
|
759
|
-
<label
|
|
760
|
-
ref={ref}
|
|
761
|
-
className={cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", className)}
|
|
762
|
-
{...props}
|
|
763
|
-
/>
|
|
764
|
-
),
|
|
765
|
-
);
|
|
766
|
-
Label.displayName = "Label";
|
|
767
|
-
`;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
785
|
function billingPricingTemplate(input) {
|
|
771
786
|
return `"use client";
|
|
772
787
|
|
|
@@ -1666,6 +1681,40 @@ export function UnkeyApiKeysConsole() {
|
|
|
1666
1681
|
}
|
|
1667
1682
|
`;
|
|
1668
1683
|
}
|
|
1684
|
+
function sanityContentTemplate() {
|
|
1685
|
+
return `import { Badge } from "@/components/ui/badge";
|
|
1686
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
1687
|
+
|
|
1688
|
+
export function SanityContentConsole() {
|
|
1689
|
+
return (
|
|
1690
|
+
<main className="min-h-screen bg-background px-6 py-12 text-foreground">
|
|
1691
|
+
<section className="mx-auto flex w-full max-w-3xl flex-col gap-6">
|
|
1692
|
+
<div className="space-y-3">
|
|
1693
|
+
<Badge variant="secondary">Sanity</Badge>
|
|
1694
|
+
<h1 className="text-3xl font-semibold tracking-normal">Content</h1>
|
|
1695
|
+
</div>
|
|
1696
|
+
<Card>
|
|
1697
|
+
<CardHeader>
|
|
1698
|
+
<CardTitle className="text-xl">Connected to Sanity</CardTitle>
|
|
1699
|
+
<CardDescription>
|
|
1700
|
+
Query documents with createServerQuery and invalidate them from the Sanity webhook.
|
|
1701
|
+
</CardDescription>
|
|
1702
|
+
</CardHeader>
|
|
1703
|
+
<CardContent className="space-y-3">
|
|
1704
|
+
<code className="block overflow-x-auto rounded-md border bg-muted/30 p-3 text-xs">
|
|
1705
|
+
cms.fetch('*[_type == "post"]{"{"} title {"}"}')
|
|
1706
|
+
</code>
|
|
1707
|
+
<p className="text-sm text-muted-foreground">
|
|
1708
|
+
Point a Sanity webhook at /api/sanity/webhook to keep cached pages fresh.
|
|
1709
|
+
</p>
|
|
1710
|
+
</CardContent>
|
|
1711
|
+
</Card>
|
|
1712
|
+
</section>
|
|
1713
|
+
</main>
|
|
1714
|
+
);
|
|
1715
|
+
}
|
|
1716
|
+
`;
|
|
1717
|
+
}
|
|
1669
1718
|
function unkeyProtectedRouteTemplate() {
|
|
1670
1719
|
return `export function GET() {
|
|
1671
1720
|
return Response.json({
|
|
@@ -1836,7 +1885,7 @@ export const auth0Integration = auth0({
|
|
|
1836
1885
|
exportName: "clerkIntegration",
|
|
1837
1886
|
description: "Clerk auth provider and protected route middleware",
|
|
1838
1887
|
env: ["NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY", "CLERK_SECRET_KEY"],
|
|
1839
|
-
dependencies: { "@clerk/react": "^6.
|
|
1888
|
+
dependencies: { "@clerk/react": "^6.4.3" },
|
|
1840
1889
|
ui: clerkAuthUIFeature(),
|
|
1841
1890
|
template: () => `import { clerk } from "@farm.js/clerk";
|
|
1842
1891
|
|
|
@@ -2208,6 +2257,43 @@ export const unkeyIntegration = unkey({
|
|
|
2208
2257
|
console.log("[unkey]", event.phase, event.route?.path || "none");
|
|
2209
2258
|
},
|
|
2210
2259
|
});
|
|
2260
|
+
`
|
|
2261
|
+
},
|
|
2262
|
+
{
|
|
2263
|
+
provider: "sanity",
|
|
2264
|
+
aliases: ["cms", "sanity-cms"],
|
|
2265
|
+
defaultKey: "cms",
|
|
2266
|
+
packageName: "@farm.js/sanity",
|
|
2267
|
+
fileName: "sanity",
|
|
2268
|
+
exportName: "sanityIntegration",
|
|
2269
|
+
description: "Sanity content with server queries, CDN images, and webhook cache invalidation",
|
|
2270
|
+
env: [
|
|
2271
|
+
"SANITY_PROJECT_ID",
|
|
2272
|
+
"SANITY_DATASET",
|
|
2273
|
+
"SANITY_API_READ_TOKEN",
|
|
2274
|
+
"SANITY_WEBHOOK_SECRET"
|
|
2275
|
+
],
|
|
2276
|
+
dependencies: { "@sanity/client": "^8.4.0" },
|
|
2277
|
+
ui: sanityContentUIFeature(),
|
|
2278
|
+
template: () => `import { sanity } from "@farm.js/sanity";
|
|
2279
|
+
|
|
2280
|
+
export const sanityIntegration = sanity({
|
|
2281
|
+
projectId: process.env.SANITY_PROJECT_ID,
|
|
2282
|
+
dataset: process.env.SANITY_DATASET,
|
|
2283
|
+
token: process.env.SANITY_API_READ_TOKEN,
|
|
2284
|
+
// The webhook fires before Sanity's CDN updates, so reads go through the API.
|
|
2285
|
+
useCdn: false,
|
|
2286
|
+
webhook: {
|
|
2287
|
+
secret: process.env.SANITY_WEBHOOK_SECRET,
|
|
2288
|
+
onChange(payload) {
|
|
2289
|
+
console.log("[sanity]", payload._type, payload._id);
|
|
2290
|
+
return undefined;
|
|
2291
|
+
},
|
|
2292
|
+
},
|
|
2293
|
+
log(event) {
|
|
2294
|
+
console.log("[sanity]", event.phase, event.route?.path || "none");
|
|
2295
|
+
},
|
|
2296
|
+
});
|
|
2211
2297
|
`
|
|
2212
2298
|
}
|
|
2213
2299
|
];
|
|
@@ -2547,6 +2633,7 @@ const FARM_TELEMETRY_TEMPLATES = [
|
|
|
2547
2633
|
"jobs-trigger",
|
|
2548
2634
|
"polar",
|
|
2549
2635
|
"resend",
|
|
2636
|
+
"sanity",
|
|
2550
2637
|
"stripe",
|
|
2551
2638
|
"supabase",
|
|
2552
2639
|
"unkey",
|
|
@@ -3164,6 +3251,7 @@ async function createApp(projectName, options = {}) {
|
|
|
3164
3251
|
await fs_promises.default.mkdir(projectPath, { recursive: true });
|
|
3165
3252
|
const integrationResult = await copyTemplate(template, projectPath, renderer);
|
|
3166
3253
|
await updatePackageJson(projectPath, projectName, packageManager);
|
|
3254
|
+
await updatePackageManagerInstructions(projectPath, packageManager.name);
|
|
3167
3255
|
require_utils.logger.success(`🚜 Created ${projectName}`);
|
|
3168
3256
|
if (!options.skipInstall) {
|
|
3169
3257
|
require_utils.logger.info(`Installing dependencies with ${packageManager.name}...`);
|
|
@@ -3176,7 +3264,7 @@ async function createApp(projectName, options = {}) {
|
|
|
3176
3264
|
if (options.skipInstall) require_utils.logger.info(` ${packageManager.name} install`);
|
|
3177
3265
|
require_utils.logger.info(` ${getDevCommand(packageManager.name)}`);
|
|
3178
3266
|
require_utils.logger.info("");
|
|
3179
|
-
for (const instruction of templateDetails[template]?.instructions ?? []) require_utils.logger.info(instruction);
|
|
3267
|
+
for (const instruction of templateDetails[template]?.instructions ?? []) require_utils.logger.info(rewritePackageManagerCommands(instruction, packageManager.name));
|
|
3180
3268
|
if (integrationResult) {
|
|
3181
3269
|
const details = templateDetails[template].integration;
|
|
3182
3270
|
require_utils.logger.info(`Open ${details.route} for the ${details.label} starter.`);
|
|
@@ -3217,6 +3305,14 @@ async function copyTemplate(template, projectPath, renderer) {
|
|
|
3217
3305
|
}
|
|
3218
3306
|
async function applyRendererTemplate(projectPath, renderer, basePackageJson) {
|
|
3219
3307
|
const rendererTemplatePath = path.default.join(__dirname, "..", "templates", "_renderers", renderer);
|
|
3308
|
+
await Promise.all([
|
|
3309
|
+
fs_promises.default.rm(path.default.join(projectPath, "docs.config.ts"), { force: true }),
|
|
3310
|
+
fs_promises.default.rm(path.default.join(projectPath, "docs.json"), { force: true }),
|
|
3311
|
+
fs_promises.default.rm(path.default.join(projectPath, "src", "app", "docs"), {
|
|
3312
|
+
recursive: true,
|
|
3313
|
+
force: true
|
|
3314
|
+
})
|
|
3315
|
+
]);
|
|
3220
3316
|
if (renderer === "vue" || renderer === "svelte") await Promise.all([
|
|
3221
3317
|
fs_promises.default.rm(path.default.join(projectPath, "src", "app", "page.tsx"), { force: true }),
|
|
3222
3318
|
fs_promises.default.rm(path.default.join(projectPath, "src", "app", "layout.tsx"), { force: true }),
|
|
@@ -3234,7 +3330,13 @@ function mergeRendererPackageJson(base, renderer) {
|
|
|
3234
3330
|
...base.devDependencies,
|
|
3235
3331
|
...renderer.devDependencies
|
|
3236
3332
|
};
|
|
3237
|
-
for (const name of [
|
|
3333
|
+
for (const name of [
|
|
3334
|
+
"@farming-labs/docs",
|
|
3335
|
+
"@farming-labs/farmjs",
|
|
3336
|
+
"@farming-labs/theme",
|
|
3337
|
+
"react",
|
|
3338
|
+
"react-dom"
|
|
3339
|
+
]) delete dependencies[name];
|
|
3238
3340
|
for (const name of ["@types/react", "@types/react-dom"]) delete devDependencies[name];
|
|
3239
3341
|
return {
|
|
3240
3342
|
...base,
|
|
@@ -3460,6 +3562,35 @@ function getDevCommand(packageManager) {
|
|
|
3460
3562
|
if (packageManager === "npm" || packageManager === "bun") return `${packageManager} run dev`;
|
|
3461
3563
|
return `${packageManager} dev`;
|
|
3462
3564
|
}
|
|
3565
|
+
function getRunCommand(packageManager, script) {
|
|
3566
|
+
if (packageManager === "npm" || packageManager === "bun") return `${packageManager} run ${script}`;
|
|
3567
|
+
return `${packageManager} ${script}`;
|
|
3568
|
+
}
|
|
3569
|
+
function rewritePackageManagerCommands(content, packageManager) {
|
|
3570
|
+
let output = content.replace(/\bpnpm install\b/g, `${packageManager} install`);
|
|
3571
|
+
output = output.replace(/\bpnpm run (dev|auth:migrate|type-check|build|check|deploy|experiment)\b/g, (match, script) => packageManager === "pnpm" ? match : getRunCommand(packageManager, script));
|
|
3572
|
+
return output.replace(/\bpnpm (dev|auth:migrate|type-check|build|check|deploy|experiment)\b/g, (_match, script) => getRunCommand(packageManager, script));
|
|
3573
|
+
}
|
|
3574
|
+
async function updatePackageManagerInstructions(projectPath, packageManager) {
|
|
3575
|
+
await Promise.all([
|
|
3576
|
+
"package.json",
|
|
3577
|
+
"README.md",
|
|
3578
|
+
"farm.config.ts",
|
|
3579
|
+
"src/app/page.tsx",
|
|
3580
|
+
"src/app/page.jsx",
|
|
3581
|
+
"src/app/page.vue",
|
|
3582
|
+
"src/app/page.svelte"
|
|
3583
|
+
].map(async (file) => {
|
|
3584
|
+
const entryPath = path.default.join(projectPath, file);
|
|
3585
|
+
try {
|
|
3586
|
+
const content = await fs_promises.default.readFile(entryPath, "utf8");
|
|
3587
|
+
const nextContent = rewritePackageManagerCommands(content, packageManager);
|
|
3588
|
+
if (nextContent !== content) await fs_promises.default.writeFile(entryPath, nextContent, "utf8");
|
|
3589
|
+
} catch (error) {
|
|
3590
|
+
if (error.code !== "ENOENT") throw error;
|
|
3591
|
+
}
|
|
3592
|
+
}));
|
|
3593
|
+
}
|
|
3463
3594
|
//#endregion
|
|
3464
3595
|
exports.createApp = createApp;
|
|
3465
3596
|
exports.detectPackageManager = detectPackageManager;
|