ui-thing 0.0.28 → 0.0.30
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/CHANGELOG.md +25 -0
- package/dist/index.js +213 -66
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/add.ts +18 -11
- package/src/commands/init.ts +1 -0
- package/src/comps.ts +58 -0
- package/src/types.ts +1 -1
- package/src/utils/config.ts +17 -1
- package/src/utils/promptForComponents.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui-thing",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"description": "CLI used to add Nuxt 3 components to a project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"boxen": "^7.1.1",
|
|
46
46
|
"build": "^0.1.4",
|
|
47
47
|
"c12": "^1.9.0",
|
|
48
|
-
"commander": "^
|
|
48
|
+
"commander": "^12.0.0",
|
|
49
49
|
"defu": "^6.1.4",
|
|
50
50
|
"execa": "^8.0.1",
|
|
51
51
|
"figlet": "^1.7.0",
|
package/src/commands/add.ts
CHANGED
|
@@ -30,8 +30,9 @@ export const add = new Command()
|
|
|
30
30
|
.name("add")
|
|
31
31
|
.command("add")
|
|
32
32
|
.description("Add a list of components to your project.")
|
|
33
|
+
.option("-a --all", "Add all components to your project.", false)
|
|
33
34
|
.argument("[componentNames...]", "Components that you want to add.")
|
|
34
|
-
.action(async (components: Array<string
|
|
35
|
+
.action(async (components: Array<string>, options: { all?: boolean }) => {
|
|
35
36
|
// Get nuxt config
|
|
36
37
|
const cfg = await getNuxtConfig();
|
|
37
38
|
// Get ui config
|
|
@@ -48,7 +49,7 @@ export const add = new Command()
|
|
|
48
49
|
let componentNames = components;
|
|
49
50
|
// if no components are passed, prompt the user to select components
|
|
50
51
|
if (componentNames.length === 0) {
|
|
51
|
-
const response = await promptUserForComponents();
|
|
52
|
+
const response = await promptUserForComponents(options.all);
|
|
52
53
|
if ((response && response.length === 0) || !response) {
|
|
53
54
|
consola.info("No components selected. Exiting...");
|
|
54
55
|
process.exit(0);
|
|
@@ -277,16 +278,22 @@ export const add = new Command()
|
|
|
277
278
|
|
|
278
279
|
// check if the foundDeps & foundDevDeps lists are not empty, ask the user to install them
|
|
279
280
|
if (foundDeps.length > 0 || foundDevDeps.length > 0) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
name: "confirmInstall",
|
|
283
|
-
message: `Do you want to install the following packages: ${kleur.cyan(
|
|
284
|
-
foundDeps.join(", ")
|
|
285
|
-
)} ${kleur.cyan(foundDevDeps.join(", "))}`,
|
|
286
|
-
initial: true,
|
|
287
|
-
});
|
|
288
|
-
if (confirmInstall) {
|
|
281
|
+
// if the all option was passed, install the packages without asking
|
|
282
|
+
if (options.all) {
|
|
289
283
|
await installPackages(uiConfig.packageManager, foundDeps, foundDevDeps);
|
|
284
|
+
} else {
|
|
285
|
+
// Ask the user to install the packages
|
|
286
|
+
const { confirmInstall } = await prompts({
|
|
287
|
+
type: "confirm",
|
|
288
|
+
name: "confirmInstall",
|
|
289
|
+
message: `Do you want to install the following packages: ${kleur.cyan(
|
|
290
|
+
foundDeps.join(", ")
|
|
291
|
+
)} ${kleur.cyan(foundDevDeps.join(", "))}`,
|
|
292
|
+
initial: true,
|
|
293
|
+
});
|
|
294
|
+
if (confirmInstall) {
|
|
295
|
+
await installPackages(uiConfig.packageManager, foundDeps, foundDevDeps);
|
|
296
|
+
}
|
|
290
297
|
}
|
|
291
298
|
}
|
|
292
299
|
|
package/src/commands/init.ts
CHANGED
|
@@ -19,6 +19,7 @@ export const init = new Command()
|
|
|
19
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
20
|
)
|
|
21
21
|
.option("-f --force", "Overwrite config file if it exists.", false)
|
|
22
|
+
.option("-y --yes", "Skip prompts and use default values.", false)
|
|
22
23
|
.action(async (options: InitOptions) => {
|
|
23
24
|
// Get nuxt config
|
|
24
25
|
const cfg = await getNuxtConfig();
|
package/src/comps.ts
CHANGED
|
@@ -795,6 +795,64 @@ export default [
|
|
|
795
795
|
composables: [],
|
|
796
796
|
plugins: [],
|
|
797
797
|
},
|
|
798
|
+
{
|
|
799
|
+
name: "Drawer",
|
|
800
|
+
value: "drawer",
|
|
801
|
+
deps: ["vaul-vue"],
|
|
802
|
+
files: [
|
|
803
|
+
{
|
|
804
|
+
fileName: "Drawer/Close.vue",
|
|
805
|
+
dirPath: "components/UI",
|
|
806
|
+
fileContent:
|
|
807
|
+
'<template>\n <DrawerClose v-bind="props">\n <slot />\n </DrawerClose>\n</template>\n\n<script lang="ts" setup>\n import { DrawerClose } from "vaul-vue";\n\n interface Props\n extends /* @vue-ignore */ Partial<Pick<InstanceType<typeof DrawerClose>, "$props">> {}\n const props = defineProps<Props>();\n</script>\n',
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
fileName: "Drawer/Content.vue",
|
|
811
|
+
dirPath: "components/UI",
|
|
812
|
+
fileContent:
|
|
813
|
+
'<template>\n <UiDrawerPortal>\n <slot name="overlay">\n <UiDrawerOverlay />\n </slot>\n <slot name="content">\n <DrawerContent v-bind="{ ...props, ...$attrs }" :class="styles({ class: props.class })">\n <slot name="knob">\n <div\n className="mx-auto cursor-grab active:cursor-grabbing my-5 h-2 w-[60px] rounded-full bg-muted"\n />\n </slot>\n <slot />\n </DrawerContent>\n </slot>\n </UiDrawerPortal>\n</template>\n\n<script lang="ts" setup>\n import { DrawerContent } from "vaul-vue";\n\n defineOptions({ inheritAttrs: false });\n\n interface Props\n extends /* @vue-ignore */ Partial<Pick<InstanceType<typeof DrawerContent>, "$props">> {}\n\n const props = defineProps<Props & { class?: any }>();\n const styles = tv({\n base: "fixed bottom-0 left-0 right-0 z-50 mt-24 flex h-auto max-h-[95%] flex-col rounded-t-[10px] border bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/40",\n });\n</script>\n',
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
fileName: "Drawer/Description.vue",
|
|
817
|
+
dirPath: "components/UI",
|
|
818
|
+
fileContent:
|
|
819
|
+
'<template>\n <DrawerDescription v-bind="props" :class="styles({ class: props.class })">\n <slot>\n {{ props.text }}\n </slot>\n </DrawerDescription>\n</template>\n\n<script lang="ts" setup>\n import { DrawerDescription } from "vaul-vue";\n\n interface Props\n extends /* @vue-ignore */ Partial<Pick<InstanceType<typeof DrawerDescription>, "$props">> {\n class?: any;\n text?: string;\n }\n\n const props = defineProps<Props>();\n\n const styles = tv({\n base: "text-sm text-muted-foreground",\n });\n</script>\n',
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
fileName: "Drawer/Drawer.vue",
|
|
823
|
+
dirPath: "components/UI",
|
|
824
|
+
fileContent:
|
|
825
|
+
'<template>\n <DrawerRoot v-bind="props">\n <slot />\n </DrawerRoot>\n</template>\n\n<script lang="ts" setup>\n import { DrawerRoot } from "vaul-vue";\n\n interface Props\n extends /* @vue-ignore */ Partial<Pick<InstanceType<typeof DrawerRoot>, "$props">> {}\n const props = defineProps<Props>();\n</script>\n',
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
fileName: "Drawer/Overlay.vue",
|
|
829
|
+
dirPath: "components/UI",
|
|
830
|
+
fileContent:
|
|
831
|
+
'<template>\n <DrawerOverlay v-bind="props" :class="styles({ class: props.class })" />\n</template>\n\n<script lang="ts" setup>\n import { DrawerOverlay } from "vaul-vue";\n\n interface Props\n extends /* @vue-ignore */ Partial<Pick<InstanceType<typeof DrawerOverlay>, "$props">> {}\n\n const props = defineProps<Props & { class?: any }>();\n\n const styles = tv({\n base: "fixed inset-0 z-50 bg-black/40 backdrop-blur",\n });\n</script>\n',
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
fileName: "Drawer/Portal.vue",
|
|
835
|
+
dirPath: "components/UI",
|
|
836
|
+
fileContent:
|
|
837
|
+
'<template>\n <DrawerPortal v-bind="props">\n <slot />\n </DrawerPortal>\n</template>\n\n<script lang="ts" setup>\n import { DrawerPortal } from "vaul-vue";\n\n interface Props\n extends /* @vue-ignore */ Partial<Pick<InstanceType<typeof DrawerPortal>, "$props">> {}\n\n const props = defineProps<Props>();\n</script>\n',
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
fileName: "Drawer/Title.vue",
|
|
841
|
+
dirPath: "components/UI",
|
|
842
|
+
fileContent:
|
|
843
|
+
'<template>\n <DrawerTitle v-bind="props" :class="styles({ class: props.class })">\n <slot>\n {{ props.text }}\n </slot>\n </DrawerTitle>\n</template>\n\n<script lang="ts" setup>\n import { DrawerTitle } from "vaul-vue";\n\n interface Props\n extends /* @vue-ignore */ Partial<Pick<InstanceType<typeof DrawerTitle>, "$props">> {\n class?: any;\n text?: string;\n }\n\n const props = defineProps<Props>();\n\n const styles = tv({\n base: "text-lg font-semibold leading-none tracking-tight",\n });\n</script>\n',
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
fileName: "Drawer/Trigger.vue",
|
|
847
|
+
dirPath: "components/UI",
|
|
848
|
+
fileContent:
|
|
849
|
+
'<template>\n <DrawerTrigger v-bind="props">\n <slot />\n </DrawerTrigger>\n</template>\n\n<script lang="ts" setup>\n import { DrawerTrigger } from "vaul-vue";\n\n interface Props\n extends /* @vue-ignore */ Partial<Pick<InstanceType<typeof DrawerTrigger>, "$props">> {}\n\n const props = defineProps<Props>();\n</script>\n',
|
|
850
|
+
},
|
|
851
|
+
],
|
|
852
|
+
utils: [],
|
|
853
|
+
composables: [],
|
|
854
|
+
plugins: [],
|
|
855
|
+
},
|
|
798
856
|
{
|
|
799
857
|
name: "Dropdown Menu",
|
|
800
858
|
value: "dropdown-menu",
|
package/src/types.ts
CHANGED
package/src/utils/config.ts
CHANGED
|
@@ -12,6 +12,17 @@ import { initPrompts } from "./uiConfigPrompt";
|
|
|
12
12
|
|
|
13
13
|
const currentDir = process.cwd();
|
|
14
14
|
const uiConfigFilename = "ui-thing.config.ts";
|
|
15
|
+
const defaultConfig = {
|
|
16
|
+
theme: "zinc",
|
|
17
|
+
tailwindCSSLocation: "assets/css/tailwind.css",
|
|
18
|
+
tailwindConfigLocation: "tailwind.config.js",
|
|
19
|
+
componentsLocation: "components/Ui",
|
|
20
|
+
composablesLocation: "composables",
|
|
21
|
+
utilsLocation: "utils",
|
|
22
|
+
force: true,
|
|
23
|
+
useDefaultFilename: true,
|
|
24
|
+
packageManager: "npm",
|
|
25
|
+
};
|
|
15
26
|
|
|
16
27
|
export const getNuxtConfig = async () => {
|
|
17
28
|
if (!fse.existsSync("nuxt.config.ts")) {
|
|
@@ -28,7 +39,12 @@ export const getUIConfig = async (options?: InitOptions) => {
|
|
|
28
39
|
let uiConfig: UIConfig = {} as UIConfig;
|
|
29
40
|
|
|
30
41
|
if (!configFileExists || options?.force) {
|
|
31
|
-
|
|
42
|
+
// if option yes is passed, use default values
|
|
43
|
+
if (options?.yes) {
|
|
44
|
+
uiConfig = defaultConfig;
|
|
45
|
+
} else {
|
|
46
|
+
uiConfig = await initPrompts();
|
|
47
|
+
}
|
|
32
48
|
await fse.writeFile(uiConfigFilename, `export default ${JSON.stringify(uiConfig, null, 2)}`);
|
|
33
49
|
// Check if user chose pnpm as package manager
|
|
34
50
|
if (uiConfig.packageManager === "pnpm") {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import ora from "ora";
|
|
2
1
|
import prompts from "prompts";
|
|
3
2
|
|
|
4
3
|
import allComponents from "../comps";
|
|
5
4
|
import { Component } from "../types";
|
|
6
5
|
|
|
7
|
-
export const promptUserForComponents = async (): Promise<string[]> => {
|
|
6
|
+
export const promptUserForComponents = async (all?: boolean): Promise<string[]> => {
|
|
7
|
+
// If all is true, return all components
|
|
8
|
+
if (all) return allComponents.map((c: Component) => c.value);
|
|
8
9
|
const { components } = await prompts({
|
|
9
10
|
type: "autocompleteMultiselect",
|
|
10
11
|
name: "components",
|