import {consola} from 'consola' import {colors} from 'consola/utils' import {defineNuxtModule} from '@nuxt/kit' import {validateLicense} from './license' import pkg from '../../package.json' export default defineNuxtModule({ meta: { name: 'bloggrify-epoxia', configKey: 'bloggrify-epoxia', }, setup (options, nuxt) { /** * License */ const theme = pkg.theme || { env: 'BLOGGRIFY_EPOXIA_LICENSE', link: 'https://eventuallycoding.lemonsqueezy.com/checkout' } const key = process.env[theme.env] || '' if (nuxt.options.dev || nuxt.options._prepare || nuxt.options.test) { if (nuxt.options.dev && !key) { consola.box( colors.greenBright('Bloggrify - epoxia') + '\n\n' + `Missing \`${theme.env}\` env variable, please add it to your \`.env\`.` + '\n\n' + colors.blueBright(`Purchase Epoxia theme at ${theme.link} to build your app in production.`) ) } return } nuxt.hook('build:before', async () => { await validateLicense({ key, theme, dir: nuxt.options.rootDir }) }) } })