@farm.js/create-app 0.1.0-beta.104 → 0.1.0-beta.106

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/index.mjs CHANGED
@@ -10,6 +10,174 @@ import { randomUUID } from "node:crypto";
10
10
  import { request } from "node:http";
11
11
  import { request as request$1 } from "node:https";
12
12
  import os from "node:os";
13
+ function shadcnComponentTemplate(component) {
14
+ switch (component) {
15
+ case "badge": return `import * as React from "react";
16
+ import { cva, type VariantProps } from "class-variance-authority";
17
+ import { cn } from "@/lib/utils";
18
+
19
+ const badgeVariants = cva(
20
+ "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",
21
+ {
22
+ variants: {
23
+ variant: {
24
+ default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
25
+ secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
26
+ outline: "text-foreground",
27
+ },
28
+ },
29
+ defaultVariants: {
30
+ variant: "default",
31
+ },
32
+ },
33
+ );
34
+
35
+ export interface BadgeProps
36
+ extends React.HTMLAttributes<HTMLDivElement>,
37
+ VariantProps<typeof badgeVariants> {}
38
+
39
+ export function Badge({ className, variant, ...props }: BadgeProps) {
40
+ return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
41
+ }
42
+
43
+ export { badgeVariants };
44
+ `;
45
+ case "button": return `import * as React from "react";
46
+ import { cva, type VariantProps } from "class-variance-authority";
47
+ import { cn } from "@/lib/utils";
48
+
49
+ const buttonVariants = cva(
50
+ "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",
51
+ {
52
+ variants: {
53
+ variant: {
54
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
55
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
56
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
57
+ ghost: "hover:bg-accent hover:text-accent-foreground",
58
+ },
59
+ size: {
60
+ default: "h-9 px-4 py-2",
61
+ sm: "h-8 rounded-md px-3 text-xs",
62
+ lg: "h-10 rounded-md px-8",
63
+ },
64
+ },
65
+ defaultVariants: {
66
+ variant: "default",
67
+ size: "default",
68
+ },
69
+ },
70
+ );
71
+
72
+ export interface ButtonProps
73
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
74
+ VariantProps<typeof buttonVariants> {}
75
+
76
+ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
77
+ ({ className, variant, size, ...props }, ref) => {
78
+ return (
79
+ <button
80
+ className={cn(buttonVariants({ variant, size, className }))}
81
+ ref={ref}
82
+ {...props}
83
+ />
84
+ );
85
+ },
86
+ );
87
+ Button.displayName = "Button";
88
+
89
+ export { buttonVariants };
90
+ `;
91
+ case "card": return `import * as React from "react";
92
+ import { cn } from "@/lib/utils";
93
+
94
+ export const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
95
+ ({ className, ...props }, ref) => (
96
+ <div
97
+ ref={ref}
98
+ className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)}
99
+ {...props}
100
+ />
101
+ ),
102
+ );
103
+ Card.displayName = "Card";
104
+
105
+ export const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
106
+ ({ className, ...props }, ref) => (
107
+ <div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
108
+ ),
109
+ );
110
+ CardHeader.displayName = "CardHeader";
111
+
112
+ export const CardTitle = React.forwardRef<HTMLHeadingElement, React.HTMLAttributes<HTMLHeadingElement>>(
113
+ ({ className, ...props }, ref) => (
114
+ <h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-normal", className)} {...props} />
115
+ ),
116
+ );
117
+ CardTitle.displayName = "CardTitle";
118
+
119
+ export const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
120
+ ({ className, ...props }, ref) => (
121
+ <p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
122
+ ),
123
+ );
124
+ CardDescription.displayName = "CardDescription";
125
+
126
+ export const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
127
+ ({ className, ...props }, ref) => (
128
+ <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
129
+ ),
130
+ );
131
+ CardContent.displayName = "CardContent";
132
+
133
+ export const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
134
+ ({ className, ...props }, ref) => (
135
+ <div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
136
+ ),
137
+ );
138
+ CardFooter.displayName = "CardFooter";
139
+ `;
140
+ case "input": return `import * as React from "react";
141
+ import { cn } from "@/lib/utils";
142
+
143
+ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
144
+
145
+ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
146
+ ({ className, type, ...props }, ref) => (
147
+ <input
148
+ type={type}
149
+ className={cn(
150
+ "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",
151
+ className,
152
+ )}
153
+ ref={ref}
154
+ {...props}
155
+ />
156
+ ),
157
+ );
158
+ Input.displayName = "Input";
159
+ `;
160
+ case "label": return `import * as React from "react";
161
+ import { cn } from "@/lib/utils";
162
+
163
+ export const Label = React.forwardRef<HTMLLabelElement, React.LabelHTMLAttributes<HTMLLabelElement>>(
164
+ ({ className, ...props }, ref) => (
165
+ <label
166
+ ref={ref}
167
+ className={cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", className)}
168
+ {...props}
169
+ />
170
+ ),
171
+ );
172
+ Label.displayName = "Label";
173
+ `;
174
+ }
175
+ }
176
+ //#endregion
177
+ //#region ../farm-cli/src/ui-registry.ts
178
+ /** Value written into a generated `components.json` as `registries.farm.url`. */
179
+ const UI_REGISTRY_URL_TEMPLATE = "https://farmjs.dev/r/{name}.json";
180
+ //#endregion
13
181
  //#region ../farm-cli/src/ui-feature-registry.ts
14
182
  async function installUIFeature(input) {
15
183
  const feature = input.definition.ui;
@@ -564,7 +732,7 @@ function createComponentsJson() {
564
732
  lib: "@/lib",
565
733
  hooks: "@/hooks"
566
734
  },
567
- registries: { farm: { url: "https://farmjs.dev/r/{name}.json" } }
735
+ registries: { farm: { url: UI_REGISTRY_URL_TEMPLATE } }
568
736
  };
569
737
  }
570
738
  function mergeComponentsJson(current, defaults) {
@@ -607,169 +775,6 @@ import type { AppIntegrations } from "./integrations";
607
775
  export const { api, apiClient } = createIntegrations<AppIntegrations>();
608
776
  `;
609
777
  }
610
- function shadcnComponentTemplate(component) {
611
- switch (component) {
612
- case "badge": return `import * as React from "react";
613
- import { cva, type VariantProps } from "class-variance-authority";
614
- import { cn } from "@/lib/utils";
615
-
616
- const badgeVariants = cva(
617
- "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",
618
- {
619
- variants: {
620
- variant: {
621
- default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
622
- secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
623
- outline: "text-foreground",
624
- },
625
- },
626
- defaultVariants: {
627
- variant: "default",
628
- },
629
- },
630
- );
631
-
632
- export interface BadgeProps
633
- extends React.HTMLAttributes<HTMLDivElement>,
634
- VariantProps<typeof badgeVariants> {}
635
-
636
- export function Badge({ className, variant, ...props }: BadgeProps) {
637
- return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
638
- }
639
-
640
- export { badgeVariants };
641
- `;
642
- case "button": return `import * as React from "react";
643
- import { cva, type VariantProps } from "class-variance-authority";
644
- import { cn } from "@/lib/utils";
645
-
646
- const buttonVariants = cva(
647
- "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",
648
- {
649
- variants: {
650
- variant: {
651
- default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
652
- secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
653
- outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
654
- ghost: "hover:bg-accent hover:text-accent-foreground",
655
- },
656
- size: {
657
- default: "h-9 px-4 py-2",
658
- sm: "h-8 rounded-md px-3 text-xs",
659
- lg: "h-10 rounded-md px-8",
660
- },
661
- },
662
- defaultVariants: {
663
- variant: "default",
664
- size: "default",
665
- },
666
- },
667
- );
668
-
669
- export interface ButtonProps
670
- extends React.ButtonHTMLAttributes<HTMLButtonElement>,
671
- VariantProps<typeof buttonVariants> {}
672
-
673
- export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
674
- ({ className, variant, size, ...props }, ref) => {
675
- return (
676
- <button
677
- className={cn(buttonVariants({ variant, size, className }))}
678
- ref={ref}
679
- {...props}
680
- />
681
- );
682
- },
683
- );
684
- Button.displayName = "Button";
685
-
686
- export { buttonVariants };
687
- `;
688
- case "card": return `import * as React from "react";
689
- import { cn } from "@/lib/utils";
690
-
691
- export const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
692
- ({ className, ...props }, ref) => (
693
- <div
694
- ref={ref}
695
- className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)}
696
- {...props}
697
- />
698
- ),
699
- );
700
- Card.displayName = "Card";
701
-
702
- export const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
703
- ({ className, ...props }, ref) => (
704
- <div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
705
- ),
706
- );
707
- CardHeader.displayName = "CardHeader";
708
-
709
- export const CardTitle = React.forwardRef<HTMLHeadingElement, React.HTMLAttributes<HTMLHeadingElement>>(
710
- ({ className, ...props }, ref) => (
711
- <h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-normal", className)} {...props} />
712
- ),
713
- );
714
- CardTitle.displayName = "CardTitle";
715
-
716
- export const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
717
- ({ className, ...props }, ref) => (
718
- <p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
719
- ),
720
- );
721
- CardDescription.displayName = "CardDescription";
722
-
723
- export const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
724
- ({ className, ...props }, ref) => (
725
- <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
726
- ),
727
- );
728
- CardContent.displayName = "CardContent";
729
-
730
- export const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
731
- ({ className, ...props }, ref) => (
732
- <div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
733
- ),
734
- );
735
- CardFooter.displayName = "CardFooter";
736
- `;
737
- case "input": return `import * as React from "react";
738
- import { cn } from "@/lib/utils";
739
-
740
- export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
741
-
742
- export const Input = React.forwardRef<HTMLInputElement, InputProps>(
743
- ({ className, type, ...props }, ref) => (
744
- <input
745
- type={type}
746
- className={cn(
747
- "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",
748
- className,
749
- )}
750
- ref={ref}
751
- {...props}
752
- />
753
- ),
754
- );
755
- Input.displayName = "Input";
756
- `;
757
- case "label": return `import * as React from "react";
758
- import { cn } from "@/lib/utils";
759
-
760
- export const Label = React.forwardRef<HTMLLabelElement, React.LabelHTMLAttributes<HTMLLabelElement>>(
761
- ({ className, ...props }, ref) => (
762
- <label
763
- ref={ref}
764
- className={cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", className)}
765
- {...props}
766
- />
767
- ),
768
- );
769
- Label.displayName = "Label";
770
- `;
771
- }
772
- }
773
778
  function billingPricingTemplate(input) {
774
779
  return `"use client";
775
780