ui-thing 0.0.30 → 0.1.1

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.
@@ -1,73 +1,73 @@
1
- import { Command } from "commander";
2
- import { defu } from "defu";
3
- import fse from "fs-extra";
4
- import kleur from "kleur";
5
-
6
- import { createCSS } from "../templates/css";
7
- import { TAILWIND_CONFIG_JS } from "../templates/tailwind";
8
- import { InitOptions, UIConfig } from "../types";
9
- import { addPrettierConfig } from "../utils/addPrettierConfig";
10
- import { addModuleToConfig, getNuxtConfig, getUIConfig, updateConfig } from "../utils/config";
11
- import { INIT_DEPS, INIT_DEV_DEPS, INIT_MODULES } from "../utils/constants";
12
- import { installPackages } from "../utils/installPackages";
13
- import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
14
-
15
- export const init = new Command()
16
- .command("init")
17
- .name("init")
18
- .description(
19
- "Initialize UI Thing in your Nuxt3 project. This will: 1. Create a tailwind.config.js file 2. Update your nuxt.config.ts file 3. Add the necessary dependencies 4. Create a ui-thing.config.ts file with the default configuration"
20
- )
21
- .option("-f --force", "Overwrite config file if it exists.", false)
22
- .option("-y --yes", "Skip prompts and use default values.", false)
23
- .action(async (options: InitOptions) => {
24
- // Get nuxt config
25
- const cfg = await getNuxtConfig();
26
- // Get ui config
27
- let uiConfig: UIConfig = await getUIConfig(options);
28
- // Add tailwindcss
29
- await fse.writeFile(uiConfig.tailwindConfigLocation, TAILWIND_CONFIG_JS, "utf-8");
30
- // create css path if it does not exist
31
- // add css file
32
- fse.writeFileSync(
33
- uiConfig.tailwindCSSLocation,
34
- createCSS(uiConfig.theme.toUpperCase() as any),
35
- "utf-8"
36
- );
37
- // Add init modules ot nuxt cinfig
38
- addModuleToConfig(cfg.nuxtConfig, INIT_MODULES);
39
- // Configure modules in nuxt config
40
- cfg.defaultExport.tailwindcss = defu(cfg.defaultExport.tailwindcss, { exposeConfig: true });
41
- cfg.defaultExport.colorMode = defu(cfg.defaultExport.colorMode, { classSuffix: "" });
42
- cfg.defaultExport.typescript = defu(cfg.defaultExport.typescript, { shim: false });
43
- cfg.defaultExport.imports ||= {};
44
- cfg.defaultExport.imports.imports ||= [];
45
- const tvExists = cfg.defaultExport.imports.imports.find(
46
- (i: any) => i.from === "tailwind-variants" && i.name === "tv"
47
- );
48
- if (!tvExists) {
49
- cfg.defaultExport.imports.imports.push({ from: "tailwind-variants", name: "tv" });
50
- }
51
- const variantPropsExists = cfg.defaultExport.imports.imports.find(
52
- (i: any) => i.from === "tailwind-variants" && i.name === "VariantProps"
53
- );
54
- if (!variantPropsExists) {
55
- cfg.defaultExport.imports.imports.push({
56
- from: "tailwind-variants",
57
- name: "VariantProps",
58
- type: true,
59
- });
60
- }
61
- // Write changes to nuxt config
62
- await updateConfig(cfg.nuxtConfig, "nuxt.config.ts");
63
- // instal deps
64
- await installPackages(uiConfig.packageManager, INIT_DEPS, INIT_DEV_DEPS);
65
- // Add prettier config
66
- await addPrettierConfig();
67
-
68
- printFancyBoxMessage(
69
- "Initialized",
70
- { title: "Complete" },
71
- `Feel free to start adding components with the ${kleur.bgWhite(" add ")} command.`
72
- );
73
- });
1
+ import { Command } from "commander";
2
+ import { defu } from "defu";
3
+ import fse from "fs-extra";
4
+ import kleur from "kleur";
5
+
6
+ import { createCSS } from "../templates/css";
7
+ import { TAILWIND_CONFIG_JS } from "../templates/tailwind";
8
+ import { InitOptions, UIConfig } from "../types";
9
+ import { addPrettierConfig } from "../utils/addPrettierConfig";
10
+ import { addModuleToConfig, getNuxtConfig, getUIConfig, updateConfig } from "../utils/config";
11
+ import { INIT_DEPS, INIT_DEV_DEPS, INIT_MODULES } from "../utils/constants";
12
+ import { installPackages } from "../utils/installPackages";
13
+ import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
14
+
15
+ export const init = new Command()
16
+ .command("init")
17
+ .name("init")
18
+ .description(
19
+ "Initialize UI Thing in your Nuxt3 project. This will: 1. Create a tailwind.config.js file 2. Update your nuxt.config.ts file 3. Add the necessary dependencies 4. Create a ui-thing.config.ts file with the default configuration"
20
+ )
21
+ .option("-f --force", "Overwrite config file if it exists.", false)
22
+ .option("-y --yes", "Skip prompts and use default values.", false)
23
+ .action(async (options: InitOptions) => {
24
+ // Get nuxt config
25
+ const cfg = await getNuxtConfig();
26
+ // Get ui config
27
+ let uiConfig: UIConfig = await getUIConfig(options);
28
+ // Add tailwindcss
29
+ await fse.writeFile(uiConfig.tailwindConfigLocation, TAILWIND_CONFIG_JS, "utf-8");
30
+ // create css path if it does not exist
31
+ // add css file
32
+ fse.writeFileSync(
33
+ uiConfig.tailwindCSSLocation,
34
+ createCSS(uiConfig.theme.toUpperCase() as any),
35
+ "utf-8"
36
+ );
37
+ // Add init modules ot nuxt cinfig
38
+ addModuleToConfig(cfg.nuxtConfig, INIT_MODULES);
39
+ // Configure modules in nuxt config
40
+ cfg.defaultExport.tailwindcss = defu(cfg.defaultExport.tailwindcss, { exposeConfig: true });
41
+ cfg.defaultExport.colorMode = defu(cfg.defaultExport.colorMode, { classSuffix: "" });
42
+ cfg.defaultExport.typescript = defu(cfg.defaultExport.typescript, { shim: false });
43
+ cfg.defaultExport.imports ||= {};
44
+ cfg.defaultExport.imports.imports ||= [];
45
+ const tvExists = cfg.defaultExport.imports.imports.find(
46
+ (i: any) => i.from === "tailwind-variants" && i.name === "tv"
47
+ );
48
+ if (!tvExists) {
49
+ cfg.defaultExport.imports.imports.push({ from: "tailwind-variants", name: "tv" });
50
+ }
51
+ const variantPropsExists = cfg.defaultExport.imports.imports.find(
52
+ (i: any) => i.from === "tailwind-variants" && i.name === "VariantProps"
53
+ );
54
+ if (!variantPropsExists) {
55
+ cfg.defaultExport.imports.imports.push({
56
+ from: "tailwind-variants",
57
+ name: "VariantProps",
58
+ type: true,
59
+ });
60
+ }
61
+ // Write changes to nuxt config
62
+ await updateConfig(cfg.nuxtConfig, "nuxt.config.ts");
63
+ // instal deps
64
+ await installPackages(uiConfig.packageManager, INIT_DEPS, INIT_DEV_DEPS);
65
+ // Add prettier config
66
+ await addPrettierConfig();
67
+
68
+ printFancyBoxMessage(
69
+ "Initialized",
70
+ { title: "Complete" },
71
+ `Feel free to start adding components with the ${kleur.bgWhite(" add ")} command.`
72
+ );
73
+ });