Skip to content

Commit

Permalink
feat(nuxt): add box nanoid and uuid packages
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Jan 23, 2024
1 parent b719949 commit 4aba85c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/box/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"@types/uuid": "^8.3.0",
"@vee-validate/zod": "^4.12.4",
"@vueuse/core": "^10.7.2",
"@vueuse/nuxt": "^10.7.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"nanoid": "^5.0.4",
"notivue": "^2.1.1",
"nuxt-icon": "^0.6.8",
"pinia": "^2.1.7",
"radix-vue": "^1.3.2",
"slugify": "^1.6.6",
"tailwind-merge": "^2.2.0",
"tailwindcss-animate": "^1.0.7",
"uuid": "^9.0.1",
"vee-validate": "^4.12.4",
"zod": "^3.22.4"
},
Expand Down
32 changes: 32 additions & 0 deletions packages/nuxt/src/runtime/modules/box/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default definePergelModule<BoxOptions, ResolvedBoxOptions>({
neoconfetti: false,
googleFonts: false,
slugify: false,
nanoid: false,
uuid: false,
},
},
async setup({ nuxt, options }) {
Expand Down Expand Up @@ -385,6 +387,36 @@ export default definePergelModule<BoxOptions, ResolvedBoxOptions>({
addImportsDir(resolver.resolve('./composables/slugify'))
}

if (options.packages.nanoid) {
useNuxtImports(nuxt, {
presets: [
{
// imports: ['customAlphabet', 'customRandom', 'nanoid', 'random', 'urlAlphabet'] as Array<keyof typeof import('nanoid')>,
imports: [{
as: 'nanoid',
name: '*',
}],
from: 'nanoid',
},
],
})
}

if (options.packages.uuid) {
useNuxtImports(nuxt, {
presets: [
{
// imports: ['v1', 'v3', 'v4', 'v5', 'NIL', 'parse', 'stringify', 'validate', 'version'] as Array<keyof typeof import('uuid')>,
imports: [{
as: 'uuid',
name: '*',
}],
from: 'uuid',
},
],
})
}

addDownloadTemplate({
nuxt,
data: {
Expand Down
6 changes: 6 additions & 0 deletions packages/nuxt/src/runtime/modules/box/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export interface BoxOptions extends PergelModuleOptions {
}
defaults?: Parameters<typeof slugify>[1]
}

nanoid?: boolean

uuid?: boolean
}
}

Expand All @@ -116,5 +120,7 @@ export interface ResolvedBoxOptions extends ResolvedPergelModuleOptions {
}
defaults?: Parameters<typeof slugify>[1]
}
nanoid: boolean
uuid: boolean
}
}
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4aba85c

Please sign in to comment.