@betterstart/cli 0.1.47 → 0.1.48
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/cli.js +38 -8
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2643,13 +2643,28 @@ function escapeQuotes(str) {
|
|
|
2643
2643
|
return str.replace(/'/g, "\\'");
|
|
2644
2644
|
}
|
|
2645
2645
|
function buildComponentSource(p7) {
|
|
2646
|
+
const queryClientImport = p7.hasFileUpload ? `
|
|
2647
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'` : "";
|
|
2648
|
+
const queryClientSetup = p7.hasFileUpload ? `
|
|
2649
|
+
const queryClient = new QueryClient()
|
|
2650
|
+
` : "";
|
|
2651
|
+
const formComponentDecl = p7.hasFileUpload ? `function ${p7.pascal}FormInner` : `export function ${p7.pascal}Form`;
|
|
2652
|
+
const exportWrapper = p7.hasFileUpload ? `
|
|
2653
|
+
export function ${p7.pascal}Form() {
|
|
2654
|
+
return (
|
|
2655
|
+
<QueryClientProvider client={queryClient}>
|
|
2656
|
+
<${p7.pascal}FormInner />
|
|
2657
|
+
</QueryClientProvider>
|
|
2658
|
+
)
|
|
2659
|
+
}
|
|
2660
|
+
` : "";
|
|
2646
2661
|
return `'use client'
|
|
2647
2662
|
|
|
2648
2663
|
import { zodResolver } from '@hookform/resolvers/zod'
|
|
2649
2664
|
import { Check, ChevronLeft, ChevronRight } from 'lucide-react'
|
|
2650
2665
|
import { useState } from 'react'
|
|
2651
2666
|
${p7.rhfImport}
|
|
2652
|
-
import { z } from 'zod/v3'
|
|
2667
|
+
import { z } from 'zod/v3'${queryClientImport}
|
|
2653
2668
|
import { create${p7.pascal}Submission } from '@cms/actions/${p7.kebab}-form'
|
|
2654
2669
|
import { Button } from '${p7.buttonImport}'
|
|
2655
2670
|
import {
|
|
@@ -2679,10 +2694,10 @@ ${p7.zodFields}
|
|
|
2679
2694
|
})
|
|
2680
2695
|
|
|
2681
2696
|
type FormValues = z.infer<typeof formSchema>
|
|
2682
|
-
|
|
2697
|
+
${queryClientSetup}
|
|
2683
2698
|
${p7.stepsConst}
|
|
2684
2699
|
|
|
2685
|
-
|
|
2700
|
+
${formComponentDecl}() {
|
|
2686
2701
|
const [currentStep, setCurrentStep] = useState(0)
|
|
2687
2702
|
const [completedSteps, setCompletedSteps] = useState<Set<number>>(new Set())
|
|
2688
2703
|
const [submitted, setSubmitted] = useState(false)
|
|
@@ -2829,7 +2844,7 @@ ${p7.stepContentBlocks}
|
|
|
2829
2844
|
</Form>
|
|
2830
2845
|
)
|
|
2831
2846
|
}
|
|
2832
|
-
`;
|
|
2847
|
+
${exportWrapper}`;
|
|
2833
2848
|
}
|
|
2834
2849
|
|
|
2835
2850
|
// src/generators/form-pipeline/form-component-single.ts
|
|
@@ -2868,12 +2883,27 @@ ${buildFieldArrayDecls(listFields)}
|
|
|
2868
2883
|
const selectImport = resolveUiImport(cwd, "select");
|
|
2869
2884
|
const radioGroupImport = resolveUiImport(cwd, "radio-group");
|
|
2870
2885
|
const mediaUploadImport = resolveUiImport(cwd, "media-upload-field");
|
|
2886
|
+
const queryClientImport = hasFileUpload ? `
|
|
2887
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'` : "";
|
|
2888
|
+
const queryClientSetup = hasFileUpload ? `
|
|
2889
|
+
const queryClient = new QueryClient()
|
|
2890
|
+
` : "";
|
|
2891
|
+
const formComponentDecl = hasFileUpload ? `function ${pascal}FormInner` : `export function ${pascal}Form`;
|
|
2892
|
+
const exportWrapper = hasFileUpload ? `
|
|
2893
|
+
export function ${pascal}Form() {
|
|
2894
|
+
return (
|
|
2895
|
+
<QueryClientProvider client={queryClient}>
|
|
2896
|
+
<${pascal}FormInner />
|
|
2897
|
+
</QueryClientProvider>
|
|
2898
|
+
)
|
|
2899
|
+
}
|
|
2900
|
+
` : "";
|
|
2871
2901
|
const content = `'use client'
|
|
2872
2902
|
|
|
2873
2903
|
import { zodResolver } from '@hookform/resolvers/zod'
|
|
2874
2904
|
import { useState } from 'react'
|
|
2875
2905
|
${rhfImport}
|
|
2876
|
-
import { z } from 'zod/v3'
|
|
2906
|
+
import { z } from 'zod/v3'${queryClientImport}
|
|
2877
2907
|
import { create${pascal}Submission } from '@cms/actions/${kebab}-form'
|
|
2878
2908
|
import { Button } from '${buttonImport}'
|
|
2879
2909
|
import {
|
|
@@ -2902,8 +2932,8 @@ ${zodFields}
|
|
|
2902
2932
|
})
|
|
2903
2933
|
|
|
2904
2934
|
type FormValues = z.infer<typeof formSchema>
|
|
2905
|
-
|
|
2906
|
-
|
|
2935
|
+
${queryClientSetup}
|
|
2936
|
+
${formComponentDecl}() {
|
|
2907
2937
|
const [submitted, setSubmitted] = useState(false)
|
|
2908
2938
|
const [submitting, setSubmitting] = useState(false)
|
|
2909
2939
|
|
|
@@ -2955,7 +2985,7 @@ ${fieldJSX}
|
|
|
2955
2985
|
</Form>
|
|
2956
2986
|
)
|
|
2957
2987
|
}
|
|
2958
|
-
`;
|
|
2988
|
+
${exportWrapper}`;
|
|
2959
2989
|
fs9.writeFileSync(filePath, content, "utf-8");
|
|
2960
2990
|
return { files: [path9.relative(cwd, filePath)] };
|
|
2961
2991
|
}
|