ui-thing 0.1.44 → 0.1.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-thing",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "CLI used to add Nuxt 3 components to a project",
5
5
  "keywords": [
6
6
  "cli",
@@ -11,6 +11,7 @@ import { compareUIConfig } from "../utils/compareUIConfig";
11
11
  import { addModuleToConfig, getNuxtConfig, getUIConfig, updateConfig } from "../utils/config";
12
12
  import { fileExists } from "../utils/fileExists";
13
13
  import { installPackages } from "../utils/installPackages";
14
+ import { installValidator } from "../utils/installValidator";
14
15
  import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
15
16
  import { promptUserForComponents } from "../utils/promptForComponents";
16
17
  import { writeFile } from "../utils/writeFile";
@@ -281,6 +282,21 @@ export const add = new Command()
281
282
  }
282
283
  }
283
284
 
285
+ // check if any of the components has the `askValidator` property set to true
286
+ let shouldAskValidator = false;
287
+ // Check if any component has askValidator set to true
288
+ for (const component of found) {
289
+ if (component.askValidator) {
290
+ shouldAskValidator = true;
291
+ break;
292
+ }
293
+ }
294
+
295
+ if (shouldAskValidator) {
296
+ // Ask the user for their choice of validator
297
+ await installValidator(uiConfig.packageManager);
298
+ }
299
+
284
300
  printFancyBoxMessage(
285
301
  "All Done!",
286
302
  { title: "Components Added" },
@@ -0,0 +1,35 @@
1
+ import prompts from "prompts";
2
+
3
+ import { installPackages } from "./installPackages";
4
+
5
+ export const installValidator = async (packageManager: string) => {
6
+ // Depending on the selected validator, install the corresponding packages
7
+ const validatorPackages = {
8
+ yup: ["yup", "@vee-validate/yup"],
9
+ zod: ["zod", "@vee-validate/zod"],
10
+ joi: ["joi", "@vee-validate/joi"],
11
+ valibot: ["valibot", "@vee-validate/valibot"],
12
+ };
13
+
14
+ const { validator }: { validator: keyof typeof validatorPackages } = await prompts({
15
+ type: "select",
16
+ name: "validator",
17
+ message: "Choose the validator package to use with Vee Validate: ",
18
+ choices: [
19
+ { title: "Yup", value: "yup" },
20
+ { title: "Zod", value: "zod" },
21
+ { title: "Joi", value: "joi" },
22
+ { title: "Valibot", value: "valibot" },
23
+ ],
24
+ });
25
+ if (!validator) {
26
+ console.log("No validator package selected");
27
+ return;
28
+ }
29
+ console.log(`Selected ${validator} as the validator package`);
30
+
31
+ if (validatorPackages[validator]) {
32
+ await installPackages(packageManager, validatorPackages[validator]);
33
+ }
34
+ return validator;
35
+ };