@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.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;
@@ -571,7 +739,7 @@ function createComponentsJson() {
571
739
  lib: "@/lib",
572
740
  hooks: "@/hooks"
573
741
  },
574
- registries: { farm: { url: "https://farmjs.dev/r/{name}.json" } }
742
+ registries: { farm: { url: UI_REGISTRY_URL_TEMPLATE } }
575
743
  };
576
744
  }
577
745
  function mergeComponentsJson(current, defaults) {
@@ -614,169 +782,6 @@ import type { AppIntegrations } from "./integrations";
614
782
  export const { api, apiClient } = createIntegrations<AppIntegrations>();
615
783
  `;
616
784
  }
617
- function shadcnComponentTemplate(component) {
618
- switch (component) {
619
- case "badge": return `import * as React from "react";
620
- import { cva, type VariantProps } from "class-variance-authority";
621
- import { cn } from "@/lib/utils";
622
-
623
- const badgeVariants = cva(
624
- "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",
625
- {
626
- variants: {
627
- variant: {
628
- default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
629
- secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
630
- outline: "text-foreground",
631
- },
632
- },
633
- defaultVariants: {
634
- variant: "default",
635
- },
636
- },
637
- );
638
-
639
- export interface BadgeProps
640
- extends React.HTMLAttributes<HTMLDivElement>,
641
- VariantProps<typeof badgeVariants> {}
642
-
643
- export function Badge({ className, variant, ...props }: BadgeProps) {
644
- return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
645
- }
646
-
647
- export { badgeVariants };
648
- `;
649
- case "button": return `import * as React from "react";
650
- import { cva, type VariantProps } from "class-variance-authority";
651
- import { cn } from "@/lib/utils";
652
-
653
- const buttonVariants = cva(
654
- "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",
655
- {
656
- variants: {
657
- variant: {
658
- default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
659
- secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
660
- outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
661
- ghost: "hover:bg-accent hover:text-accent-foreground",
662
- },
663
- size: {
664
- default: "h-9 px-4 py-2",
665
- sm: "h-8 rounded-md px-3 text-xs",
666
- lg: "h-10 rounded-md px-8",
667
- },
668
- },
669
- defaultVariants: {
670
- variant: "default",
671
- size: "default",
672
- },
673
- },
674
- );
675
-
676
- export interface ButtonProps
677
- extends React.ButtonHTMLAttributes<HTMLButtonElement>,
678
- VariantProps<typeof buttonVariants> {}
679
-
680
- export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
681
- ({ className, variant, size, ...props }, ref) => {
682
- return (
683
- <button
684
- className={cn(buttonVariants({ variant, size, className }))}
685
- ref={ref}
686
- {...props}
687
- />
688
- );
689
- },
690
- );
691
- Button.displayName = "Button";
692
-
693
- export { buttonVariants };
694
- `;
695
- case "card": return `import * as React from "react";
696
- import { cn } from "@/lib/utils";
697
-
698
- export const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
699
- ({ className, ...props }, ref) => (
700
- <div
701
- ref={ref}
702
- className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)}
703
- {...props}
704
- />
705
- ),
706
- );
707
- Card.displayName = "Card";
708
-
709
- export const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
710
- ({ className, ...props }, ref) => (
711
- <div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
712
- ),
713
- );
714
- CardHeader.displayName = "CardHeader";
715
-
716
- export const CardTitle = React.forwardRef<HTMLHeadingElement, React.HTMLAttributes<HTMLHeadingElement>>(
717
- ({ className, ...props }, ref) => (
718
- <h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-normal", className)} {...props} />
719
- ),
720
- );
721
- CardTitle.displayName = "CardTitle";
722
-
723
- export const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
724
- ({ className, ...props }, ref) => (
725
- <p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
726
- ),
727
- );
728
- CardDescription.displayName = "CardDescription";
729
-
730
- export const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
731
- ({ className, ...props }, ref) => (
732
- <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
733
- ),
734
- );
735
- CardContent.displayName = "CardContent";
736
-
737
- export const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
738
- ({ className, ...props }, ref) => (
739
- <div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
740
- ),
741
- );
742
- CardFooter.displayName = "CardFooter";
743
- `;
744
- case "input": return `import * as React from "react";
745
- import { cn } from "@/lib/utils";
746
-
747
- export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
748
-
749
- export const Input = React.forwardRef<HTMLInputElement, InputProps>(
750
- ({ className, type, ...props }, ref) => (
751
- <input
752
- type={type}
753
- className={cn(
754
- "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",
755
- className,
756
- )}
757
- ref={ref}
758
- {...props}
759
- />
760
- ),
761
- );
762
- Input.displayName = "Input";
763
- `;
764
- case "label": return `import * as React from "react";
765
- import { cn } from "@/lib/utils";
766
-
767
- export const Label = React.forwardRef<HTMLLabelElement, React.LabelHTMLAttributes<HTMLLabelElement>>(
768
- ({ className, ...props }, ref) => (
769
- <label
770
- ref={ref}
771
- className={cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", className)}
772
- {...props}
773
- />
774
- ),
775
- );
776
- Label.displayName = "Label";
777
- `;
778
- }
779
- }
780
785
  function billingPricingTemplate(input) {
781
786
  return `"use client";
782
787