ui-thing 0.0.5 → 0.0.7

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,72 +1,72 @@
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
- .action(async (options: InitOptions) => {
23
- // Get nuxt config
24
- const cfg = await getNuxtConfig();
25
- // Get ui config
26
- let uiConfig: UIConfig = await getUIConfig(options);
27
- // Add tailwindcss
28
- await fse.writeFile(uiConfig.tailwindConfigLocation, TAILWIND_CONFIG_JS, "utf-8");
29
- // create css path if it does not exist
30
- // add css file
31
- fse.writeFileSync(
32
- uiConfig.tailwindCSSLocation,
33
- createCSS(uiConfig.theme.toUpperCase() as any),
34
- "utf-8"
35
- );
36
- // Add init modules ot nuxt cinfig
37
- addModuleToConfig(cfg.nuxtConfig, INIT_MODULES);
38
- // Configure modules in nuxt config
39
- cfg.defaultExport.tailwindcss = defu(cfg.defaultExport.tailwindcss, { exposeConfig: true });
40
- cfg.defaultExport.colorMode = defu(cfg.defaultExport.colorMode, { classSuffix: "" });
41
- cfg.defaultExport.typescript = defu(cfg.defaultExport.typescript, { shim: false });
42
- cfg.defaultExport.imports ||= {};
43
- cfg.defaultExport.imports.imports ||= [];
44
- const tvExists = cfg.defaultExport.imports.imports.find(
45
- (i: any) => i.from === "tailwind-variants" && i.name === "tv"
46
- );
47
- if (!tvExists) {
48
- cfg.defaultExport.imports.imports.push({ from: "tailwind-variants", name: "tv" });
49
- }
50
- const variantPropsExists = cfg.defaultExport.imports.imports.find(
51
- (i: any) => i.from === "tailwind-variants" && i.name === "VariantProps"
52
- );
53
- if (!variantPropsExists) {
54
- cfg.defaultExport.imports.imports.push({
55
- from: "tailwind-variants",
56
- name: "VariantProps",
57
- type: true,
58
- });
59
- }
60
- // Wriet changes to nuxt config
61
- await updateConfig(cfg.nuxtConfig, "nuxt.config.ts");
62
- // instal deps
63
- await installPackages(uiConfig.packageManager, INIT_DEPS, INIT_DEV_DEPS);
64
- // Add prettier config
65
- await addPrettierConfig();
66
-
67
- printFancyBoxMessage(
68
- "Initialized",
69
- { title: "Complete" },
70
- `Feel free to start adding components with the ${kleur.bgWhite(" add ")} command.`
71
- );
72
- });
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
+ .action(async (options: InitOptions) => {
23
+ // Get nuxt config
24
+ const cfg = await getNuxtConfig();
25
+ // Get ui config
26
+ let uiConfig: UIConfig = await getUIConfig(options);
27
+ // Add tailwindcss
28
+ await fse.writeFile(uiConfig.tailwindConfigLocation, TAILWIND_CONFIG_JS, "utf-8");
29
+ // create css path if it does not exist
30
+ // add css file
31
+ fse.writeFileSync(
32
+ uiConfig.tailwindCSSLocation,
33
+ createCSS(uiConfig.theme.toUpperCase() as any),
34
+ "utf-8"
35
+ );
36
+ // Add init modules ot nuxt cinfig
37
+ addModuleToConfig(cfg.nuxtConfig, INIT_MODULES);
38
+ // Configure modules in nuxt config
39
+ cfg.defaultExport.tailwindcss = defu(cfg.defaultExport.tailwindcss, { exposeConfig: true });
40
+ cfg.defaultExport.colorMode = defu(cfg.defaultExport.colorMode, { classSuffix: "" });
41
+ cfg.defaultExport.typescript = defu(cfg.defaultExport.typescript, { shim: false });
42
+ cfg.defaultExport.imports ||= {};
43
+ cfg.defaultExport.imports.imports ||= [];
44
+ const tvExists = cfg.defaultExport.imports.imports.find(
45
+ (i: any) => i.from === "tailwind-variants" && i.name === "tv"
46
+ );
47
+ if (!tvExists) {
48
+ cfg.defaultExport.imports.imports.push({ from: "tailwind-variants", name: "tv" });
49
+ }
50
+ const variantPropsExists = cfg.defaultExport.imports.imports.find(
51
+ (i: any) => i.from === "tailwind-variants" && i.name === "VariantProps"
52
+ );
53
+ if (!variantPropsExists) {
54
+ cfg.defaultExport.imports.imports.push({
55
+ from: "tailwind-variants",
56
+ name: "VariantProps",
57
+ type: true,
58
+ });
59
+ }
60
+ // Wriet changes to nuxt config
61
+ await updateConfig(cfg.nuxtConfig, "nuxt.config.ts");
62
+ // instal deps
63
+ await installPackages(uiConfig.packageManager, INIT_DEPS, INIT_DEV_DEPS);
64
+ // Add prettier config
65
+ await addPrettierConfig();
66
+
67
+ printFancyBoxMessage(
68
+ "Initialized",
69
+ { title: "Complete" },
70
+ `Feel free to start adding components with the ${kleur.bgWhite(" add ")} command.`
71
+ );
72
+ });
@@ -1,47 +1,47 @@
1
- import { Command } from "commander";
2
- import prompts from "prompts";
3
-
4
- import { addPrettierConfig } from "../utils/addPrettierConfig";
5
- import { installPackages } from "../utils/installPackages";
6
- import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
7
-
8
- export const addPrettier = new Command()
9
- .command("prettier")
10
- .name("prettier")
11
- .description("Add prettier to your project.")
12
- .action(async () => {
13
- const added = await addPrettierConfig(undefined, false);
14
- if (!added) {
15
- printFancyBoxMessage(
16
- "Not Added",
17
- { title: "Prettier Not Added", borderColor: "red" },
18
- `Prettier config was not added.`
19
- );
20
- return;
21
- }
22
-
23
- const { pkgManager } = await prompts({
24
- name: "pkgManager",
25
- type: "select",
26
- message: "Which package manager are you using?",
27
- choices: [
28
- { title: "npm", value: "npm" },
29
- { title: "yarn", value: "yarn" },
30
- { title: "pnpm", value: "pnpm" },
31
- { title: "bun", value: "bun" },
32
- ],
33
- });
34
- if (!pkgManager) return process.exit(0);
35
-
36
- // install prettier dep
37
- await installPackages(pkgManager, undefined, [
38
- "prettier",
39
- "prettier-plugin-tailwindcss",
40
- "@ianvs/prettier-plugin-sort-imports",
41
- ]);
42
- printFancyBoxMessage(
43
- "All Done!",
44
- { title: "Prettier Added" },
45
- `A .prettierrc file has been added to your project and the code formatted. Enjoy!`
46
- );
47
- });
1
+ import { Command } from "commander";
2
+ import prompts from "prompts";
3
+
4
+ import { addPrettierConfig } from "../utils/addPrettierConfig";
5
+ import { installPackages } from "../utils/installPackages";
6
+ import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
7
+
8
+ export const addPrettier = new Command()
9
+ .command("prettier")
10
+ .name("prettier")
11
+ .description("Add prettier to your project.")
12
+ .action(async () => {
13
+ const added = await addPrettierConfig(undefined, false);
14
+ if (!added) {
15
+ printFancyBoxMessage(
16
+ "Not Added",
17
+ { title: "Prettier Not Added", borderColor: "red" },
18
+ `Prettier config was not added.`
19
+ );
20
+ return;
21
+ }
22
+
23
+ const { pkgManager } = await prompts({
24
+ name: "pkgManager",
25
+ type: "select",
26
+ message: "Which package manager are you using?",
27
+ choices: [
28
+ { title: "npm", value: "npm" },
29
+ { title: "yarn", value: "yarn" },
30
+ { title: "pnpm", value: "pnpm" },
31
+ { title: "bun", value: "bun" },
32
+ ],
33
+ });
34
+ if (!pkgManager) return process.exit(0);
35
+
36
+ // install prettier dep
37
+ await installPackages(pkgManager, undefined, [
38
+ "prettier",
39
+ "prettier-plugin-tailwindcss",
40
+ "@ianvs/prettier-plugin-sort-imports",
41
+ ]);
42
+ printFancyBoxMessage(
43
+ "All Done!",
44
+ { title: "Prettier Added" },
45
+ `A .prettierrc file has been added to your project and the code formatted. Enjoy!`
46
+ );
47
+ });
@@ -1,61 +1,61 @@
1
- import { Command } from "commander";
2
- import { consola } from "consola";
3
- import fse from "fs-extra";
4
- import _ from "lodash";
5
- import prompts from "prompts";
6
-
7
- import { createCSS } from "../templates/css";
8
- import { compareUIConfig } from "../utils/compareUIConfig";
9
- import { getUIConfig } from "../utils/config";
10
- import { CSS_THEME_OPTIONS } from "../utils/constants";
11
- import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
12
-
13
- export const theme = new Command()
14
- .command("theme")
15
- .name("theme")
16
- .description("Add a new theme to your project.")
17
- .action(async () => {
18
- // Get ui config
19
- let uiConfig = await getUIConfig();
20
- let uiConfigIsCorrect = await compareUIConfig();
21
- if (!uiConfigIsCorrect) {
22
- uiConfig = await getUIConfig({ force: true });
23
- }
24
- if (_.isEmpty(uiConfig)) {
25
- consola.info("Config file not set. Exiting...");
26
- process.exit(0);
27
- }
28
- const { theme } = await prompts([
29
- {
30
- name: "theme",
31
- type: "autocomplete",
32
- message: "Which theme do you want to add?",
33
- choices: CSS_THEME_OPTIONS,
34
- },
35
- ]);
36
- if (!theme) {
37
- console.log("No theme selected. Exiting...");
38
- return process.exit(0);
39
- }
40
- if (fse.existsSync(uiConfig.tailwindCSSLocation)) {
41
- const { force } = await prompts([
42
- {
43
- name: "force",
44
- type: "confirm",
45
- message: "Do you want to overwrite your current css file?",
46
- initial: true,
47
- },
48
- ]);
49
- if (!force) {
50
- console.log("Exiting...");
51
- return process.exit(0);
52
- }
53
- }
54
- fse.writeFileSync(uiConfig.tailwindCSSLocation, createCSS(theme.toUpperCase() as any), "utf-8");
55
-
56
- printFancyBoxMessage(
57
- `${_.capitalize(theme)}`,
58
- { title: "New Theme Added" },
59
- `${_.capitalize(theme)} theme has been added to ${uiConfig.tailwindCSSLocation}`
60
- );
61
- });
1
+ import { Command } from "commander";
2
+ import { consola } from "consola";
3
+ import fse from "fs-extra";
4
+ import _ from "lodash";
5
+ import prompts from "prompts";
6
+
7
+ import { createCSS } from "../templates/css";
8
+ import { compareUIConfig } from "../utils/compareUIConfig";
9
+ import { getUIConfig } from "../utils/config";
10
+ import { CSS_THEME_OPTIONS } from "../utils/constants";
11
+ import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
12
+
13
+ export const theme = new Command()
14
+ .command("theme")
15
+ .name("theme")
16
+ .description("Add a new theme to your project.")
17
+ .action(async () => {
18
+ // Get ui config
19
+ let uiConfig = await getUIConfig();
20
+ let uiConfigIsCorrect = await compareUIConfig();
21
+ if (!uiConfigIsCorrect) {
22
+ uiConfig = await getUIConfig({ force: true });
23
+ }
24
+ if (_.isEmpty(uiConfig)) {
25
+ consola.info("Config file not set. Exiting...");
26
+ process.exit(0);
27
+ }
28
+ const { theme } = await prompts([
29
+ {
30
+ name: "theme",
31
+ type: "autocomplete",
32
+ message: "Which theme do you want to add?",
33
+ choices: CSS_THEME_OPTIONS,
34
+ },
35
+ ]);
36
+ if (!theme) {
37
+ console.log("No theme selected. Exiting...");
38
+ return process.exit(0);
39
+ }
40
+ if (fse.existsSync(uiConfig.tailwindCSSLocation)) {
41
+ const { force } = await prompts([
42
+ {
43
+ name: "force",
44
+ type: "confirm",
45
+ message: "Do you want to overwrite your current css file?",
46
+ initial: true,
47
+ },
48
+ ]);
49
+ if (!force) {
50
+ console.log("Exiting...");
51
+ return process.exit(0);
52
+ }
53
+ }
54
+ fse.writeFileSync(uiConfig.tailwindCSSLocation, createCSS(theme.toUpperCase() as any), "utf-8");
55
+
56
+ printFancyBoxMessage(
57
+ `${_.capitalize(theme)}`,
58
+ { title: "New Theme Added" },
59
+ `${_.capitalize(theme)} theme has been added to ${uiConfig.tailwindCSSLocation}`
60
+ );
61
+ });