@eslamdevui/ui 3.2.0-beta.2 → 3.2.0
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/.nuxt/ui/alert.ts +0 -5
- package/.nuxt/ui/badge.ts +0 -5
- package/.nuxt/ui/button-group.ts +0 -13
- package/.nuxt/ui/button.ts +0 -5
- package/.nuxt/ui/carousel.ts +0 -5
- package/.nuxt/ui/content-surround.ts +0 -5
- package/.nuxt/ui/dashboard-navbar.ts +0 -5
- package/.nuxt/ui/dashboard-sidebar-collapse.ts +0 -5
- package/.nuxt/ui/dashboard-sidebar-toggle.ts +0 -5
- package/.nuxt/ui/dashboard-sidebar.ts +0 -10
- package/.nuxt/ui/index.ts +1 -48
- package/.nuxt/ui/input-menu.ts +0 -9
- package/.nuxt/ui/input-number.ts +0 -5
- package/.nuxt/ui/input-tags.ts +0 -9
- package/.nuxt/ui/input.ts +0 -9
- package/.nuxt/ui/select-menu.ts +0 -9
- package/.nuxt/ui/select.ts +0 -9
- package/.nuxt/ui/textarea.ts +0 -9
- package/.nuxt/ui/toast.ts +0 -5
- package/LICENSE.md +9 -9
- package/README.md +147 -147
- package/cli/commands/make/component.mjs +95 -95
- package/cli/commands/make/index.mjs +14 -14
- package/cli/commands/make/locale.mjs +64 -64
- package/cli/index.mjs +15 -15
- package/cli/package.json +13 -13
- package/cli/templates.mjs +236 -236
- package/cli/utils.mjs +31 -31
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Accordion.vue +36 -36
- package/dist/runtime/components/Alert.vue +46 -46
- package/dist/runtime/components/App.vue +10 -10
- package/dist/runtime/components/Avatar.vue +27 -27
- package/dist/runtime/components/AvatarGroup.vue +4 -4
- package/dist/runtime/components/Badge.vue +16 -16
- package/dist/runtime/components/Breadcrumb.vue +32 -32
- package/dist/runtime/components/Button.vue +28 -28
- package/dist/runtime/components/ButtonGroup.vue +3 -3
- package/dist/runtime/components/Calendar.vue +74 -74
- package/dist/runtime/components/Card.vue +13 -13
- package/dist/runtime/components/Carousel.vue +58 -58
- package/dist/runtime/components/ChatMessage.vue +35 -35
- package/dist/runtime/components/ChatMessages.vue +55 -55
- package/dist/runtime/components/ChatPrompt.vue +26 -26
- package/dist/runtime/components/ChatPromptSubmit.vue +10 -10
- package/dist/runtime/components/Checkbox.vue +33 -33
- package/dist/runtime/components/CheckboxGroup.vue +32 -32
- package/dist/runtime/components/Chip.vue +11 -11
- package/dist/runtime/components/Collapsible.vue +9 -9
- package/dist/runtime/components/ColorPicker.vue +30 -30
- package/dist/runtime/components/CommandPalette.vue +117 -117
- package/dist/runtime/components/Container.vue +3 -3
- package/dist/runtime/components/ContextMenu.vue +22 -22
- package/dist/runtime/components/ContextMenuContent.vue +105 -105
- package/dist/runtime/components/DashboardGroup.vue +3 -3
- package/dist/runtime/components/DashboardNavbar.vue +40 -40
- package/dist/runtime/components/DashboardPanel.vue +27 -27
- package/dist/runtime/components/DashboardResizeHandle.vue +7 -7
- package/dist/runtime/components/DashboardSearch.vue +20 -20
- package/dist/runtime/components/DashboardSearchButton.vue +43 -43
- package/dist/runtime/components/DashboardSidebar.vue +74 -74
- package/dist/runtime/components/DashboardSidebarCollapse.vue +7 -7
- package/dist/runtime/components/DashboardSidebarToggle.vue +7 -7
- package/dist/runtime/components/Drawer.vue +55 -55
- package/dist/runtime/components/DropdownMenu.vue +24 -24
- package/dist/runtime/components/DropdownMenuContent.vue +107 -107
- package/dist/runtime/components/Error.vue +22 -22
- package/dist/runtime/components/Form.vue +8 -8
- package/dist/runtime/components/FormField.vue +37 -37
- package/dist/runtime/components/Icon.vue +1 -1
- package/dist/runtime/components/Input.vue +34 -34
- package/dist/runtime/components/InputMenu.vue +163 -163
- package/dist/runtime/components/InputNumber.vue +49 -49
- package/dist/runtime/components/InputTags.vue +55 -55
- package/dist/runtime/components/Kbd.vue +5 -5
- package/dist/runtime/components/Link.vue +14 -14
- package/dist/runtime/components/LinkBase.vue +8 -8
- package/dist/runtime/components/Modal.vue +69 -69
- package/dist/runtime/components/NavigationMenu.vue +166 -166
- package/dist/runtime/components/OverlayProvider.vue +9 -9
- package/dist/runtime/components/Pagination.vue +47 -47
- package/dist/runtime/components/PinInput.vue +20 -20
- package/dist/runtime/components/Popover.vue +17 -17
- package/dist/runtime/components/Progress.vue +19 -19
- package/dist/runtime/components/RadioGroup.vue +43 -43
- package/dist/runtime/components/Select.vue +96 -96
- package/dist/runtime/components/SelectMenu.vue +130 -130
- package/dist/runtime/components/Separator.vue +15 -15
- package/dist/runtime/components/Skeleton.vue +10 -10
- package/dist/runtime/components/Slideover.vue +76 -76
- package/dist/runtime/components/Slider.vue +27 -27
- package/dist/runtime/components/Stepper.vue +51 -51
- package/dist/runtime/components/Switch.vue +33 -33
- package/dist/runtime/components/Table.vue +77 -77
- package/dist/runtime/components/Tabs.vue +37 -37
- package/dist/runtime/components/Textarea.vue +33 -33
- package/dist/runtime/components/Timeline.vue +38 -38
- package/dist/runtime/components/Toast.vue +69 -69
- package/dist/runtime/components/Toaster.vue +28 -28
- package/dist/runtime/components/Tooltip.vue +19 -19
- package/dist/runtime/components/Tree.vue +60 -60
- package/dist/runtime/components/color-mode/ColorModeAvatar.vue +2 -2
- package/dist/runtime/components/color-mode/ColorModeButton.vue +16 -16
- package/dist/runtime/components/color-mode/ColorModeImage.vue +2 -2
- package/dist/runtime/components/color-mode/ColorModeSelect.vue +19 -19
- package/dist/runtime/components/color-mode/ColorModeSwitch.vue +19 -19
- package/dist/runtime/components/content/ContentNavigation.vue +109 -109
- package/dist/runtime/components/content/ContentSearch.vue +25 -25
- package/dist/runtime/components/content/ContentSearchButton.vue +38 -38
- package/dist/runtime/components/content/ContentSearchButton.vue.d.ts +12 -12
- package/dist/runtime/components/content/ContentSurround.vue +29 -29
- package/dist/runtime/components/content/ContentSurround.vue.d.ts +59 -59
- package/dist/runtime/components/content/ContentToc.vue +68 -68
- package/dist/runtime/components/content/ContentToc.vue.d.ts +88 -88
- package/dist/runtime/components/locale/LocaleSelect.vue +20 -20
- package/dist/runtime/components/prose/A.vue +3 -3
- package/dist/runtime/components/prose/Accordion.vue +5 -5
- package/dist/runtime/components/prose/AccordionItem.vue +5 -5
- package/dist/runtime/components/prose/Badge.vue +3 -3
- package/dist/runtime/components/prose/Blockquote.vue +3 -3
- package/dist/runtime/components/prose/Callout.vue +27 -27
- package/dist/runtime/components/prose/Card.vue +43 -43
- package/dist/runtime/components/prose/CardGroup.vue +3 -3
- package/dist/runtime/components/prose/Code.vue +3 -3
- package/dist/runtime/components/prose/CodeCollapse.vue +16 -16
- package/dist/runtime/components/prose/CodeGroup.vue +15 -15
- package/dist/runtime/components/prose/CodeIcon.vue +1 -1
- package/dist/runtime/components/prose/CodePreview.vue +9 -9
- package/dist/runtime/components/prose/CodeTree.vue +61 -61
- package/dist/runtime/components/prose/Collapsible.vue +15 -15
- package/dist/runtime/components/prose/Em.vue +1 -1
- package/dist/runtime/components/prose/Field.vue +23 -23
- package/dist/runtime/components/prose/FieldGroup.vue +3 -3
- package/dist/runtime/components/prose/H1.vue +6 -6
- package/dist/runtime/components/prose/H2.vue +10 -10
- package/dist/runtime/components/prose/H3.vue +10 -10
- package/dist/runtime/components/prose/H4.vue +6 -6
- package/dist/runtime/components/prose/Hr.vue +1 -1
- package/dist/runtime/components/prose/Icon.vue +1 -1
- package/dist/runtime/components/prose/Img.vue +8 -8
- package/dist/runtime/components/prose/Kbd.vue +1 -1
- package/dist/runtime/components/prose/Li.vue +3 -3
- package/dist/runtime/components/prose/Ol.vue +3 -3
- package/dist/runtime/components/prose/P.vue +3 -3
- package/dist/runtime/components/prose/Pre.vue +20 -20
- package/dist/runtime/components/prose/Script.vue +3 -3
- package/dist/runtime/components/prose/Steps.vue +3 -3
- package/dist/runtime/components/prose/Strong.vue +3 -3
- package/dist/runtime/components/prose/Table.vue +5 -5
- package/dist/runtime/components/prose/Tabs.vue +14 -14
- package/dist/runtime/components/prose/TabsItem.vue +5 -5
- package/dist/runtime/components/prose/Tbody.vue +3 -3
- package/dist/runtime/components/prose/Td.vue +3 -3
- package/dist/runtime/components/prose/Th.vue +3 -3
- package/dist/runtime/components/prose/Thead.vue +3 -3
- package/dist/runtime/components/prose/Tr.vue +3 -3
- package/dist/runtime/components/prose/Ul.vue +3 -3
- package/dist/runtime/components/prose/callout/Caution.vue +3 -3
- package/dist/runtime/components/prose/callout/Note.vue +3 -3
- package/dist/runtime/components/prose/callout/Tip.vue +3 -3
- package/dist/runtime/components/prose/callout/Warning.vue +3 -3
- package/dist/runtime/inertia/components/Link.vue +12 -12
- package/dist/runtime/inertia/components/LinkBase.vue +15 -15
- package/dist/runtime/types/app.config.d.ts +6 -6
- package/dist/runtime/vue/components/Icon.vue +1 -1
- package/dist/runtime/vue/components/Link.vue +31 -31
- package/dist/runtime/vue/components/color-mode/ColorModeButton.vue +7 -7
- package/dist/runtime/vue/components/color-mode/ColorModeSelect.vue +7 -7
- package/dist/runtime/vue/components/color-mode/ColorModeSwitch.vue +7 -7
- package/package.json +1 -1
- package/vue-plugin.d.ts +5 -5
- package/.nuxt/ui/content/content-navigation.ts +0 -339
- package/.nuxt/ui/content/content-search-button.ts +0 -6
- package/.nuxt/ui/content/content-search.ts +0 -6
- package/.nuxt/ui/content/content-surround.ts +0 -39
- package/.nuxt/ui/content/content-toc.ts +0 -150
- package/.nuxt/ui/content/index.ts +0 -5
- package/.nuxt/ui/error.ts +0 -9
- package/.nuxt/ui/prose/a.ts +0 -6
- package/.nuxt/ui/prose/accordion-item.ts +0 -3
- package/.nuxt/ui/prose/accordion.ts +0 -6
- package/.nuxt/ui/prose/badge.ts +0 -3
- package/.nuxt/ui/prose/blockquote.ts +0 -3
- package/.nuxt/ui/prose/callout.ts +0 -129
- package/.nuxt/ui/prose/card-group.ts +0 -3
- package/.nuxt/ui/prose/card.ts +0 -119
- package/.nuxt/ui/prose/code-collapse.ts +0 -19
- package/.nuxt/ui/prose/code-group.ts +0 -13
- package/.nuxt/ui/prose/code-icon.ts +0 -66
- package/.nuxt/ui/prose/code-preview.ts +0 -14
- package/.nuxt/ui/prose/code-tree.ts +0 -28
- package/.nuxt/ui/prose/code.ts +0 -27
- package/.nuxt/ui/prose/collapsible.ts +0 -12
- package/.nuxt/ui/prose/em.ts +0 -3
- package/.nuxt/ui/prose/field-group.ts +0 -3
- package/.nuxt/ui/prose/field.ts +0 -11
- package/.nuxt/ui/prose/h1.ts +0 -6
- package/.nuxt/ui/prose/h2.ts +0 -14
- package/.nuxt/ui/prose/h3.ts +0 -14
- package/.nuxt/ui/prose/h4.ts +0 -6
- package/.nuxt/ui/prose/hr.ts +0 -3
- package/.nuxt/ui/prose/icon.ts +0 -3
- package/.nuxt/ui/prose/img.ts +0 -3
- package/.nuxt/ui/prose/index.ts +0 -41
- package/.nuxt/ui/prose/kbd.ts +0 -3
- package/.nuxt/ui/prose/li.ts +0 -3
- package/.nuxt/ui/prose/ol.ts +0 -3
- package/.nuxt/ui/prose/p.ts +0 -3
- package/.nuxt/ui/prose/pre.ts +0 -17
- package/.nuxt/ui/prose/steps.ts +0 -19
- package/.nuxt/ui/prose/strong.ts +0 -3
- package/.nuxt/ui/prose/table.ts +0 -6
- package/.nuxt/ui/prose/tabs-item.ts +0 -3
- package/.nuxt/ui/prose/tabs.ts +0 -5
- package/.nuxt/ui/prose/tbody.ts +0 -3
- package/.nuxt/ui/prose/td.ts +0 -3
- package/.nuxt/ui/prose/th.ts +0 -3
- package/.nuxt/ui/prose/thead.ts +0 -3
- package/.nuxt/ui/prose/tr.ts +0 -3
- package/.nuxt/ui/prose/ul.ts +0 -3
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import { existsSync, promises as fsp } from 'node:fs'
|
|
2
|
-
import { resolve } from 'pathe'
|
|
3
|
-
import { defineCommand } from 'citty'
|
|
4
|
-
import { consola } from 'consola'
|
|
5
|
-
import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
|
|
6
|
-
import { appendFile, sortFile } from '../../utils.mjs'
|
|
7
|
-
import templates from '../../templates.mjs'
|
|
8
|
-
|
|
9
|
-
export default defineCommand({
|
|
10
|
-
meta: {
|
|
11
|
-
name: 'component',
|
|
12
|
-
description: 'Make a new component.'
|
|
13
|
-
},
|
|
14
|
-
args: {
|
|
15
|
-
name: {
|
|
16
|
-
type: 'positional',
|
|
17
|
-
required: true,
|
|
18
|
-
description: 'Name of the component.'
|
|
19
|
-
},
|
|
20
|
-
primitive: {
|
|
21
|
-
type: 'boolean',
|
|
22
|
-
description: 'Create a primitive component.'
|
|
23
|
-
},
|
|
24
|
-
pro: {
|
|
25
|
-
type: 'boolean',
|
|
26
|
-
description: 'Create a pro component.'
|
|
27
|
-
},
|
|
28
|
-
prose: {
|
|
29
|
-
type: 'boolean',
|
|
30
|
-
description: 'Create a prose component (with --pro).'
|
|
31
|
-
},
|
|
32
|
-
content: {
|
|
33
|
-
type: 'boolean',
|
|
34
|
-
description: 'Create a content component (with --pro).'
|
|
35
|
-
},
|
|
36
|
-
template: {
|
|
37
|
-
type: 'string',
|
|
38
|
-
description: 'Only generate template.'
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
async setup({ args }) {
|
|
42
|
-
const name = args.name
|
|
43
|
-
if (!name) {
|
|
44
|
-
consola.error('`name` argument is missing!')
|
|
45
|
-
process.exit(1)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (args.prose && !args.pro) {
|
|
49
|
-
consola.error('`--prose` flag can only be used with `--pro` flag!')
|
|
50
|
-
process.exit(1)
|
|
51
|
-
}
|
|
52
|
-
if (args.content && !args.pro) {
|
|
53
|
-
consola.error('`--content` flag can only be used with `--pro` flag!')
|
|
54
|
-
process.exit(1)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const path = resolve('.')
|
|
58
|
-
|
|
59
|
-
for (const template of Object.keys(templates)) {
|
|
60
|
-
if (args.template && template !== args.template) {
|
|
61
|
-
continue
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const { filename, contents } = templates[template](args)
|
|
65
|
-
if (!contents) {
|
|
66
|
-
continue
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const filePath = resolve(path, filename)
|
|
70
|
-
|
|
71
|
-
if (existsSync(filePath)) {
|
|
72
|
-
consola.error(`🚨 ${filePath} already exists!`)
|
|
73
|
-
continue
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
await fsp.writeFile(filePath, contents.trim() + '\n')
|
|
77
|
-
|
|
78
|
-
consola.success(`🪄 Generated ${filePath}!`)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (args.template) {
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const themePath = resolve(path, `src/theme/${args.prose ? 'prose/' : ''}${args.content ? 'content/' : ''}index.ts`)
|
|
86
|
-
await appendFile(themePath, `export { default as ${camelCase(name)} } from './${kebabCase(name)}'`)
|
|
87
|
-
await sortFile(themePath)
|
|
88
|
-
|
|
89
|
-
if (!args.prose) {
|
|
90
|
-
const typesPath = resolve(path, 'src/runtime/types/index.ts')
|
|
91
|
-
await appendFile(typesPath, `export * from '../components/${args.content ? 'content/' : ''}${splitByCase(name).map(p => upperFirst(p)).join('')}.vue'`)
|
|
92
|
-
await sortFile(typesPath)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
})
|
|
1
|
+
import { existsSync, promises as fsp } from 'node:fs'
|
|
2
|
+
import { resolve } from 'pathe'
|
|
3
|
+
import { defineCommand } from 'citty'
|
|
4
|
+
import { consola } from 'consola'
|
|
5
|
+
import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
|
|
6
|
+
import { appendFile, sortFile } from '../../utils.mjs'
|
|
7
|
+
import templates from '../../templates.mjs'
|
|
8
|
+
|
|
9
|
+
export default defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: 'component',
|
|
12
|
+
description: 'Make a new component.'
|
|
13
|
+
},
|
|
14
|
+
args: {
|
|
15
|
+
name: {
|
|
16
|
+
type: 'positional',
|
|
17
|
+
required: true,
|
|
18
|
+
description: 'Name of the component.'
|
|
19
|
+
},
|
|
20
|
+
primitive: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
description: 'Create a primitive component.'
|
|
23
|
+
},
|
|
24
|
+
pro: {
|
|
25
|
+
type: 'boolean',
|
|
26
|
+
description: 'Create a pro component.'
|
|
27
|
+
},
|
|
28
|
+
prose: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
description: 'Create a prose component (with --pro).'
|
|
31
|
+
},
|
|
32
|
+
content: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
description: 'Create a content component (with --pro).'
|
|
35
|
+
},
|
|
36
|
+
template: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'Only generate template.'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
async setup({ args }) {
|
|
42
|
+
const name = args.name
|
|
43
|
+
if (!name) {
|
|
44
|
+
consola.error('`name` argument is missing!')
|
|
45
|
+
process.exit(1)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (args.prose && !args.pro) {
|
|
49
|
+
consola.error('`--prose` flag can only be used with `--pro` flag!')
|
|
50
|
+
process.exit(1)
|
|
51
|
+
}
|
|
52
|
+
if (args.content && !args.pro) {
|
|
53
|
+
consola.error('`--content` flag can only be used with `--pro` flag!')
|
|
54
|
+
process.exit(1)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const path = resolve('.')
|
|
58
|
+
|
|
59
|
+
for (const template of Object.keys(templates)) {
|
|
60
|
+
if (args.template && template !== args.template) {
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const { filename, contents } = templates[template](args)
|
|
65
|
+
if (!contents) {
|
|
66
|
+
continue
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const filePath = resolve(path, filename)
|
|
70
|
+
|
|
71
|
+
if (existsSync(filePath)) {
|
|
72
|
+
consola.error(`🚨 ${filePath} already exists!`)
|
|
73
|
+
continue
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
await fsp.writeFile(filePath, contents.trim() + '\n')
|
|
77
|
+
|
|
78
|
+
consola.success(`🪄 Generated ${filePath}!`)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (args.template) {
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const themePath = resolve(path, `src/theme/${args.prose ? 'prose/' : ''}${args.content ? 'content/' : ''}index.ts`)
|
|
86
|
+
await appendFile(themePath, `export { default as ${camelCase(name)} } from './${kebabCase(name)}'`)
|
|
87
|
+
await sortFile(themePath)
|
|
88
|
+
|
|
89
|
+
if (!args.prose) {
|
|
90
|
+
const typesPath = resolve(path, 'src/runtime/types/index.ts')
|
|
91
|
+
await appendFile(typesPath, `export * from '../components/${args.content ? 'content/' : ''}${splitByCase(name).map(p => upperFirst(p)).join('')}.vue'`)
|
|
92
|
+
await sortFile(typesPath)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineCommand } from 'citty'
|
|
2
|
-
import component from './component.mjs'
|
|
3
|
-
import locale from './locale.mjs'
|
|
4
|
-
|
|
5
|
-
export default defineCommand({
|
|
6
|
-
meta: {
|
|
7
|
-
name: 'make',
|
|
8
|
-
description: 'Commands to create new Nuxt UI entities.'
|
|
9
|
-
},
|
|
10
|
-
subCommands: {
|
|
11
|
-
component,
|
|
12
|
-
locale
|
|
13
|
-
}
|
|
14
|
-
})
|
|
1
|
+
import { defineCommand } from 'citty'
|
|
2
|
+
import component from './component.mjs'
|
|
3
|
+
import locale from './locale.mjs'
|
|
4
|
+
|
|
5
|
+
export default defineCommand({
|
|
6
|
+
meta: {
|
|
7
|
+
name: 'make',
|
|
8
|
+
description: 'Commands to create new Nuxt UI entities.'
|
|
9
|
+
},
|
|
10
|
+
subCommands: {
|
|
11
|
+
component,
|
|
12
|
+
locale
|
|
13
|
+
}
|
|
14
|
+
})
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { existsSync, promises as fsp } from 'node:fs'
|
|
2
|
-
import { resolve } from 'pathe'
|
|
3
|
-
import { consola } from 'consola'
|
|
4
|
-
import { appendFile, sortFile, normalizeLocale } from '../../utils.mjs'
|
|
5
|
-
import { defineCommand } from 'citty'
|
|
6
|
-
|
|
7
|
-
export default defineCommand({
|
|
8
|
-
meta: {
|
|
9
|
-
name: 'locale',
|
|
10
|
-
description: 'Make a new locale.'
|
|
11
|
-
},
|
|
12
|
-
args: {
|
|
13
|
-
code: {
|
|
14
|
-
description: 'Locale code to create. For example: en.',
|
|
15
|
-
required: true
|
|
16
|
-
},
|
|
17
|
-
name: {
|
|
18
|
-
description: 'Locale name to create. For example: English.',
|
|
19
|
-
required: true
|
|
20
|
-
},
|
|
21
|
-
dir: {
|
|
22
|
-
description: 'Locale direction. For example: rtl.',
|
|
23
|
-
default: 'ltr'
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
async setup({ args }) {
|
|
27
|
-
const path = resolve('.')
|
|
28
|
-
const localePath = resolve(path, `src/runtime/locale`)
|
|
29
|
-
|
|
30
|
-
const originLocaleFilePath = resolve(localePath, 'en.ts')
|
|
31
|
-
const newLocaleFilePath = resolve(localePath, `${args.code}.ts`)
|
|
32
|
-
|
|
33
|
-
// Validate locale code
|
|
34
|
-
if (existsSync(newLocaleFilePath)) {
|
|
35
|
-
consola.error(`🚨 ${args.code} already exists!`)
|
|
36
|
-
process.exit(1)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!['ltr', 'rtl'].includes(args.dir)) {
|
|
40
|
-
consola.error(`🚨 Direction ${args.dir} not supported!`)
|
|
41
|
-
process.exit(1)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!args.code.match(/^[a-z]{2}(?:_[a-z]{2,4})?$/)) {
|
|
45
|
-
consola.error(`🚨 ${args.code} is not a valid locale code!\nExample: en or en_us`)
|
|
46
|
-
process.exit(1)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Create new locale export
|
|
50
|
-
const localeExportFile = resolve(localePath, `index.ts`)
|
|
51
|
-
await appendFile(localeExportFile, `export { default as ${args.code} } from './${args.code}'`)
|
|
52
|
-
await sortFile(localeExportFile)
|
|
53
|
-
|
|
54
|
-
// Create new locale file
|
|
55
|
-
await fsp.copyFile(originLocaleFilePath, newLocaleFilePath)
|
|
56
|
-
const localeFile = await fsp.readFile(newLocaleFilePath, 'utf-8')
|
|
57
|
-
const rewrittenLocaleFile = localeFile
|
|
58
|
-
.replace(/name: '(.*)',/, `name: '${args.name}',`)
|
|
59
|
-
.replace(/code: '(.*)',/, `code: '${normalizeLocale(args.code)}',${(args.dir && args.dir !== 'ltr') ? `\n dir: '${args.dir}',` : ''}`)
|
|
60
|
-
await fsp.writeFile(newLocaleFilePath, rewrittenLocaleFile)
|
|
61
|
-
|
|
62
|
-
consola.success(`🪄 Generated ${newLocaleFilePath}`)
|
|
63
|
-
}
|
|
64
|
-
})
|
|
1
|
+
import { existsSync, promises as fsp } from 'node:fs'
|
|
2
|
+
import { resolve } from 'pathe'
|
|
3
|
+
import { consola } from 'consola'
|
|
4
|
+
import { appendFile, sortFile, normalizeLocale } from '../../utils.mjs'
|
|
5
|
+
import { defineCommand } from 'citty'
|
|
6
|
+
|
|
7
|
+
export default defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name: 'locale',
|
|
10
|
+
description: 'Make a new locale.'
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
code: {
|
|
14
|
+
description: 'Locale code to create. For example: en.',
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
name: {
|
|
18
|
+
description: 'Locale name to create. For example: English.',
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
dir: {
|
|
22
|
+
description: 'Locale direction. For example: rtl.',
|
|
23
|
+
default: 'ltr'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
async setup({ args }) {
|
|
27
|
+
const path = resolve('.')
|
|
28
|
+
const localePath = resolve(path, `src/runtime/locale`)
|
|
29
|
+
|
|
30
|
+
const originLocaleFilePath = resolve(localePath, 'en.ts')
|
|
31
|
+
const newLocaleFilePath = resolve(localePath, `${args.code}.ts`)
|
|
32
|
+
|
|
33
|
+
// Validate locale code
|
|
34
|
+
if (existsSync(newLocaleFilePath)) {
|
|
35
|
+
consola.error(`🚨 ${args.code} already exists!`)
|
|
36
|
+
process.exit(1)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!['ltr', 'rtl'].includes(args.dir)) {
|
|
40
|
+
consola.error(`🚨 Direction ${args.dir} not supported!`)
|
|
41
|
+
process.exit(1)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!args.code.match(/^[a-z]{2}(?:_[a-z]{2,4})?$/)) {
|
|
45
|
+
consola.error(`🚨 ${args.code} is not a valid locale code!\nExample: en or en_us`)
|
|
46
|
+
process.exit(1)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Create new locale export
|
|
50
|
+
const localeExportFile = resolve(localePath, `index.ts`)
|
|
51
|
+
await appendFile(localeExportFile, `export { default as ${args.code} } from './${args.code}'`)
|
|
52
|
+
await sortFile(localeExportFile)
|
|
53
|
+
|
|
54
|
+
// Create new locale file
|
|
55
|
+
await fsp.copyFile(originLocaleFilePath, newLocaleFilePath)
|
|
56
|
+
const localeFile = await fsp.readFile(newLocaleFilePath, 'utf-8')
|
|
57
|
+
const rewrittenLocaleFile = localeFile
|
|
58
|
+
.replace(/name: '(.*)',/, `name: '${args.name}',`)
|
|
59
|
+
.replace(/code: '(.*)',/, `code: '${normalizeLocale(args.code)}',${(args.dir && args.dir !== 'ltr') ? `\n dir: '${args.dir}',` : ''}`)
|
|
60
|
+
await fsp.writeFile(newLocaleFilePath, rewrittenLocaleFile)
|
|
61
|
+
|
|
62
|
+
consola.success(`🪄 Generated ${newLocaleFilePath}`)
|
|
63
|
+
}
|
|
64
|
+
})
|
package/cli/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { defineCommand, runMain } from 'citty'
|
|
3
|
-
import make from './commands/make/index.mjs'
|
|
4
|
-
|
|
5
|
-
const main = defineCommand({
|
|
6
|
-
meta: {
|
|
7
|
-
name: 'nuxt-ui',
|
|
8
|
-
description: 'Nuxt UI CLI'
|
|
9
|
-
},
|
|
10
|
-
subCommands: {
|
|
11
|
-
make
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
runMain(main)
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineCommand, runMain } from 'citty'
|
|
3
|
+
import make from './commands/make/index.mjs'
|
|
4
|
+
|
|
5
|
+
const main = defineCommand({
|
|
6
|
+
meta: {
|
|
7
|
+
name: 'nuxt-ui',
|
|
8
|
+
description: 'Nuxt UI CLI'
|
|
9
|
+
},
|
|
10
|
+
subCommands: {
|
|
11
|
+
make
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
runMain(main)
|
package/cli/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@eslamdevui/ui-cli",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"exports": {
|
|
5
|
-
".": "./index.mjs"
|
|
6
|
-
},
|
|
7
|
-
"dependencies": {
|
|
8
|
-
"citty": "^0.1.6",
|
|
9
|
-
"consola": "^3.4.2",
|
|
10
|
-
"pathe": "^2.0.3",
|
|
11
|
-
"scule": "^1.3.0"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@eslamdevui/ui-cli",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"exports": {
|
|
5
|
+
".": "./index.mjs"
|
|
6
|
+
},
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"citty": "^0.1.6",
|
|
9
|
+
"consola": "^3.4.2",
|
|
10
|
+
"pathe": "^2.0.3",
|
|
11
|
+
"scule": "^1.3.0"
|
|
12
|
+
}
|
|
13
|
+
}
|