refactor: defineValaxyAddon and simply valaxy-addon-waline

This commit is contained in:
YunYouJun 2022-11-25 01:01:15 +08:00
parent 2a25edf133
commit 8d0621d842
30 changed files with 169 additions and 384 deletions

View File

@ -116,14 +116,6 @@ export default defineConfig<ThemeConfig>({
comment: {
enable: true,
waline: {
enable: true,
serverURL: 'https://waline.yunyoujun.cn',
},
twikoo: {
// enable: true,
envId: 'https://twikoo.vercel.app',
},
},
sponsor: {

View File

@ -18,3 +18,5 @@ categories:
- [ ] `App.vue` 如果插件作者希望插件被使用时立刻全局挂载,可以将内容放置于 `valaxy-addon-<name>/App.vue` 中,并设置 `package.json``global: true`
- `components`: 放置于 `components` 文件夹下的组件将会被自动注册,但不会被挂载。用户可以手动加载使用。
用户如何配置 global

View File

@ -149,21 +149,9 @@ const { headers, handleClick } = useOutline()
而由于评论系统各不相同,如 Hexo 等主题开发者们通常需在主题侧重复实现多款评论系统。
这显然是繁琐的。
Valaxy 决定通过插件中心化地提供各类封装好的评论钩子函数。
Valaxy 决定通过插件中心化地提供各类封装好的评论组件和辅助函数。
譬如主题开发者,可以`valaxy-addon-waline` 中导入 `useWaline` 来快速实现 [Waline](https://waline.js.org/) 评论系统的集成。
譬如主题开发者,可以借助 `valaxy-addon-waline` 来快速实现 [Waline](https://waline.js.org/) 评论系统的集成。
而用户则可以使用相同的配置穿梭漫游于不同的主题之间。
启用 `valaxy-addon-waline` 插件时,`<WalineClient />` 组件将会被自动注册。
```vue
<!-- YunWaline -->
<script lang="ts" setup>
import { useConfig } from 'valaxy'
const config = useConfig()
</script>
<template>
<WalineClient w="full" :server-u-r-l="config.comment.waline.serverURL" :cdn="config.cdn.prefix" />
</template>
```
> 集成参见 [valaxy-addon-waline](https://github.com/YunYouJun/valaxy/blob/main/packages/valaxy-addon-waline/README.md)。

View File

@ -50,7 +50,7 @@
"lint-staged": "^13.0.3",
"prompts": "^2.4.2",
"rimraf": "^3.0.2",
"tsup": "^6.2.3",
"tsup": "^6.5.0",
"tsx": "^3.12.1",
"typescript": "^4.9.3",
"valaxy": "workspace:*",

View File

@ -37,7 +37,9 @@ async function init() {
const packageName = await getValidPackageName(targetDir)
const root = path.join(cwd, targetDir)
if (!fs.existsSync(root)) { fs.mkdirSync(root, { recursive: true }) }
if (!fs.existsSync(root)) {
fs.mkdirSync(root, { recursive: true })
}
else {
const existing = fs.readdirSync(root)
if (existing.length) {

View File

@ -6,5 +6,38 @@ valaxy-addon-waline 是基于 Waline 的一个 Valaxy 插件。
## 如何集成
启用 `valaxy-addon-waline` 插件时,`<WalineClient />` 组件将会被自动注册。
```vue
<!-- YunWaline -->
<script lang="ts" setup>
import { useAddonWaline } from 'valaxy-addon-waline'
const addon = useAddonWaline()
</script>
<template>
<WalineClient w="full" :options="addon.options" />
</template>
```
启用 Waline 评论。
```ts
``
import { defineValaxyConfig } from 'valaxy'
import { addonWaline } from 'valaxy-addon-waline/node'
export default defineValaxyConfig({
// 启用评论
comment: {
enable: true
},
// 设置 valaxy-addon-waline 配置项
addons: [
addonWaline({
options: {
serverURL: 'https://your-waline-url',
}
}),
],
})
```

View File

@ -14,10 +14,10 @@ const props = defineProps<{
options: WalineOptions
}>()
const { locale } = useI18n()
const emoji = computed(() => getEmojis(props.options.cdn))
const route = useRoute()
const { locale } = useI18n()
const path = computed(() => route.path)
const emoji = computed(() => getEmojis(props.options.cdn))
</script>
<template>

View File

@ -1,11 +1,17 @@
import type { ValaxyAddonLike } from 'valaxy'
import { defineValaxyAddon } from 'valaxy'
import type { WalineOptions } from '../types'
// todo
// defineValaxyAddon
export function addonWaline(options: WalineOptions) {
return ['valaxy-addon-waline', {
enable: true,
options,
}] as [string, ValaxyAddonLike]
}
// export function addonWaline(options: WalineOptions) {
// return ['valaxy-addon-waline', {
// enable: true,
// options,
// }] as [string, ValaxyAddonLike]
// }
export const addonWaline = defineValaxyAddon<WalineOptions>(options => ({
name: 'valaxy-addon-waline',
enable: true,
options,
}))

View File

@ -1,6 +1,6 @@
{
"name": "valaxy-addon-waline",
"version": "0.0.2",
"version": "0.0.3",
"description": "Waline Composition API for Valaxy",
"keywords": [
"valaxy",

View File

@ -1,6 +1,6 @@
export * from './options'
export const getEmojis = (cdn = 'https://unpkg.com') => {
export const getEmojis = (cdn = '//unpkg.com/') => {
return [
`${cdn}@waline/emojis/bilibili/`,
`${cdn}@waline/emojis/qq/`,

View File

@ -1,8 +1,13 @@
import { computed } from 'vue'
import type { ValaxyAddon } from 'valaxy'
import { useConfig } from 'valaxy'
import type { WalineOptions } from '../types'
export function useWalineOptions() {
/**
* get addon config
* @returns
*/
export function useAddonWaline() {
const config = useConfig()
return computed(() => config.value.runtime.addons['valaxy-addon-waline'].options as WalineOptions)
return computed(() => config.value.runtime.addons['valaxy-addon-waline'] as ValaxyAddon<WalineOptions>)
}

View File

@ -1,6 +1,7 @@
<script lang="ts" setup>
import type { PageData, Post } from 'valaxy'
import { useConfig, usePostTitle } from 'valaxy'
import { useAddonWaline } from 'valaxy-addon-waline'
import { StyleValue, computed, defineAsyncComponent } from 'vue'
import { usePostProperty } from '../composables'
@ -15,13 +16,14 @@ const title = usePostTitle(computed(() => props.frontmatter))
const aside = computed(() => props.frontmatter.aside !== false)
const YunWaline = config.value.runtime.addons['valaxy-addon-waline'].enable
const YunWaline = useAddonWaline()
? defineAsyncComponent(() => import('./YunWaline.vue'))
: () => null
const YunTwikoo = config.value.runtime.addons['valaxy-addon-twikoo']?.enable
? defineAsyncComponent(() => import('./YunTwikoo.vue'))
: () => null
// todo: refactor
// const YunTwikoo = useAddonWaline()
// ? defineAsyncComponent(() => import('./YunTwikoo.vue'))
// : () => null
</script>
<template>
@ -57,8 +59,8 @@ const YunTwikoo = config.value.runtime.addons['valaxy-addon-twikoo']?.enable
<slot v-if="config.comment.enable && frontmatter.comment !== false" name="comment">
<YunCard w="full" p="4" class="comment sm:p-6 lg:px-12 xl:px-16" :class="frontmatter.nav === false ? 'mt-4' : 0">
<YunWaline v-if="config.comment.waline.enable" />
<YunTwikoo v-if="config.comment.twikoo.enable" />
<YunWaline />
<!-- <YunTwikoo /> -->
</YunCard>
</slot>

View File

@ -19,7 +19,9 @@ watch(() => props.posts, () => {
props.posts.forEach((post) => {
if (post.date) {
const year = parseInt(formatDate(post.date, 'YYYY'))
if (postList.value[year]) { postList.value[year].push(post) }
if (postList.value[year]) {
postList.value[year].push(post)
}
else {
years.value.push(year)
postList.value[year] = [post]

View File

@ -1,8 +1,8 @@
<script lang="ts" setup>
import { useConfig, useTwikoo } from 'valaxy'
// import { useConfig, useTwikoo } from 'valaxy'
const config = useConfig()
useTwikoo(config.value.comment.twikoo)
// const config = useConfig()
// useTwikoo(config.value.comment.twikoo)
</script>
<template>

View File

@ -1,8 +1,8 @@
<script lang="ts" setup>
import { useWalineOptions } from 'valaxy-addon-waline'
const walineOptions = useWalineOptions()
import { useAddonWaline } from 'valaxy-addon-waline'
const addon = useAddonWaline()
</script>
<template>
<WalineClient w="full" :options="walineOptions" />
<WalineClient w="full" :options="addon.options" />
</template>

View File

@ -30,7 +30,6 @@ function ThemeVitePlugin(options: ResolvedValaxyOptions<ThemeConfig>): Plugin {
export default defineTheme<ThemeConfig>((options) => {
return {
themeConfig: defaultThemeConfig,
addons: ['valaxy-addon-waline'],
vite: {
plugins: [ThemeVitePlugin(options)],
},

View File

@ -15,7 +15,7 @@ import type { DefaultThemeConfig, SiteConfig as ValaxySiteConfig } from 'valaxy/
* @param data
* @returns
*/
function parse<T=any>(data: string): T {
function parse<T = any>(data: string): T {
const parsed = JSON.parse(data)
return (__DEV__ ? readonly(parsed) : parsed) as T
}

View File

@ -0,0 +1,17 @@
import type { DefaultThemeConfig, ValaxyAddon } from '../../types'
import type { ResolvedValaxyOptions } from '../options'
import type { ValaxyConfig } from '../types'
export function defineValaxyAddon<AddonOptions = {}>(addonFunc: (addonOptions: AddonOptions, valaxyOptions?: ResolvedValaxyOptions) => ValaxyAddon) {
return addonFunc
}
export const defineAddon = defineValaxyAddon
export type ValaxyConfigExtendKey = 'vite' | 'vue' | 'unocss' | 'unocssPresets' | 'markdown' | 'extendMd' | 'addons'
export type ValaxyPickConfig = Pick<ValaxyConfig, ValaxyConfigExtendKey>
export type ValaxyTheme<ThemeConfig = DefaultThemeConfig> = ValaxyPickConfig & { themeConfig?: ThemeConfig }
export function defineTheme<ThemeConfig = DefaultThemeConfig>(
theme: ValaxyTheme<ThemeConfig> | ((options: ResolvedValaxyOptions<ThemeConfig>) => ValaxyTheme<ThemeConfig>),
) {
return theme
}

View File

@ -1,8 +1,9 @@
import type { VitePluginConfig as UnoCssConfig } from 'unocss/vite'
import type { Awaitable } from '@antfu/utils'
import type { DefaultThemeConfig, SiteConfig, UserSiteConfig } from '../types'
import type { ResolvedValaxyOptions } from './options'
import type { UserConfig, ValaxyAddonResolver, ValaxyConfig } from './types'
import type { SiteConfig, UserSiteConfig } from '../../types'
import type { UserConfig } from '../types'
export * from './addon'
/**
* Type site helper
@ -23,24 +24,10 @@ export function defineSiteWithTheme<ThemeConfig>(
/**
* Type valaxy config helper
*/
export function defineConfig<ThemeConfig>(config: UserConfig<ThemeConfig>) {
export function defineValaxyConfig<ThemeConfig>(config: UserConfig<ThemeConfig>) {
return config
}
export type ValaxyConfigExtendKey = 'vite' | 'vue' | 'unocss' | 'unocssPresets' | 'markdown' | 'extendMd' | 'addons'
export type ValaxyPickConfig = Pick<ValaxyConfig, ValaxyConfigExtendKey>
export type ValaxyTheme<ThemeConfig = DefaultThemeConfig> = ValaxyPickConfig & { themeConfig?: ThemeConfig }
export function defineTheme<ThemeConfig = DefaultThemeConfig>(
theme: ValaxyTheme<ThemeConfig> | ((options: ResolvedValaxyOptions<ThemeConfig>) => ValaxyTheme<ThemeConfig>),
) {
return theme
}
export function defineAddon(
addon: ValaxyPickConfig | ((addonOptions: ValaxyAddonResolver, valaxyOptions: ResolvedValaxyOptions) => ValaxyPickConfig),
) {
return addon
}
export const defineConfig = defineValaxyConfig
export const defaultSiteConfig: SiteConfig = {
mode: 'auto',
@ -97,14 +84,6 @@ export const defaultSiteConfig: SiteConfig = {
comment: {
enable: false,
waline: {
enable: false,
serverURL: '',
},
twikoo: {
enable: false,
envId: 'https://twikoo.vercel.app',
},
},
cdn: {

View File

@ -107,7 +107,10 @@ function math_inline(state: any, silent: boolean) {
}
function math_block(state: any, start: number, end: number, silent: boolean) {
let firstLine; let lastLine; let next; let lastPos
let firstLine
let lastLine
let next
let lastPos
let found = false
let pos = state.bMarks[start] + state.tShift[start]
let max = state.eMarks[start]

View File

@ -9,7 +9,7 @@ import { resolveImportPath } from './utils'
import { mergeValaxyConfig, resolveAddonConfig, resolveValaxyConfig, resolveValaxyConfigFromRoot } from './utils/config'
import type { ValaxyAddonResolver, ValaxyConfig } from './types'
import { defaultSiteConfig } from './config'
import { parseAddonOptions } from './utils/addons'
import { parseAddons } from './utils/addons'
import { getThemeRoot } from './utils/theme'
// for cli entry
@ -124,7 +124,7 @@ export async function resolveOptions(options: ValaxyEntryOptions, mode: Resolved
let valaxyConfig = mergeValaxyConfig(userValaxyConfig, themeValaxyConfig)
// resolve addon valaxyConfig
const addons = await parseAddonOptions(valaxyConfig.addons || [], valaxyOptions.userRoot)
const addons = await parseAddons(valaxyConfig.addons || [], valaxyOptions.userRoot)
const addonValaxyConfig = await resolveAddonConfig(addons, valaxyOptions)
valaxyConfig = mergeValaxyConfig(valaxyConfig, addonValaxyConfig)

View File

@ -117,13 +117,17 @@ export async function build(options: ResolvedValaxyOptions) {
types.forEach((type) => {
let data = ''
let name = `${path}/${config.feed?.name || 'feed'}.${type}`
if (type === 'xml') { data = feed.rss2() }
if (type === 'xml') {
data = feed.rss2()
}
else if (type === 'atom') {
if (!config.feed?.name)
name = `${path}/atom.xml`
data = feed.atom1()
}
else if (type === 'json') { data = feed.json1() }
else if (type === 'json') {
data = feed.json1()
}
fs.writeFileSync(name, data, 'utf-8')
consola.info(`${type}: ${name}`)
})

View File

@ -46,11 +46,11 @@ export interface ValaxyExtendConfig {
excerpt?: string
path: string
}) => void
addons?: ValaxyAddonOptions
addons?: ValaxyAddons
}
export type ValaxyAddonLike = ValaxyAddon | false | null | undefined
export type ValaxyAddonOptions = ([string, ValaxyAddonLike] | string | (() => [string, ValaxyAddonLike]))[] | Record<string, ValaxyAddonLike>
export type ValaxyAddons = ValaxyAddon[] | Record<string, ValaxyAddonLike>
export type ValaxyAddonFn<ThemeConfig = DefaultThemeConfig> = (addonOptions: ValaxyAddonResolver, valaxyOptions: ResolvedValaxyOptions<ThemeConfig>) => ValaxyConfig | Promise<ValaxyConfig>
export type ValaxyAddonExport<ThemeConfig = DefaultThemeConfig> = ValaxyConfig<ThemeConfig> | ValaxyAddonFn<ThemeConfig>

View File

@ -2,36 +2,29 @@ import { resolve } from 'path'
import fs from 'fs-extra'
import consola from 'consola'
import defu from 'defu'
import type { ValaxyAddonLike, ValaxyAddonOptions, ValaxyAddonResolver } from '../types'
import type { ValaxyAddonResolver, ValaxyAddons } from '../types'
import { getModuleRoot } from './root'
export interface ReadAddonModuleOptions {
cwd?: string
extends?: Partial<ValaxyAddonResolver>
}
export async function parseAddonOptions(options: ValaxyAddonOptions, userRoot = process.cwd()) {
export async function parseAddons(addons: ValaxyAddons, userRoot = process.cwd()) {
const resolvers: Record<string, ValaxyAddonResolver > = {}
const mergeResolver = (resolver?: ValaxyAddonResolver) => {
if (resolver)
resolvers[resolver.name] = defu(resolvers[resolver.name] || {}, resolver)
}
if (Array.isArray(options)) {
for (const option of options) {
if (typeof option === 'string') {
mergeResolver(await readAddonModule(option, { cwd: userRoot }))
if (Array.isArray(addons)) {
for (const addon of addons) {
if (typeof addon === 'string') {
mergeResolver(await readAddonModule(addon, { cwd: userRoot }))
continue
}
if (Array.isArray(option)) {
const [name, like] = option
mergeResolver(await readAddonModule(name, { cwd: userRoot, extends: parseAddonLike(like) }))
}
if (typeof addon === 'object')
mergeResolver(defu(await readAddonModule(addon.name, { cwd: userRoot }), addon || {}))
}
}
else if (typeof options === 'object') {
for (const [name, like] of Object.entries(options))
mergeResolver(await readAddonModule(name, { cwd: userRoot, extends: parseAddonLike(like) }))
}
return Object.values(resolvers).filter(item => item.enable)
}
@ -61,16 +54,7 @@ export async function readAddonModule(name: string, options: ReadAddonModuleOpti
options: {},
props: {},
}
return defu(resolver, options.extends || {})
}
export function parseAddonLike(like: ValaxyAddonLike) {
const option: Partial<ValaxyAddonResolver> = { enable: true }
if (like === false)
option.enable = false
if (typeof like === 'object')
Object.assign(option, like)
return option
return resolver
}
/**

View File

@ -45,7 +45,7 @@ export const mergeValaxyConfig = createDefu((obj: any, key, value) => {
*/
export async function resolveValaxyConfigFromRoot(root: string, options?: ResolvedValaxyOptions) {
return loadConfigFromFiles<ValaxyConfig>('valaxy.config', {
rewrite<F=ValaxyConfig | ValaxyConfigFn>(c: F) {
rewrite<F = ValaxyConfig | ValaxyConfigFn>(c: F) {
return (typeof c === 'function' ? c(options || {} as ResolvedValaxyOptions) : c)
},
cwd: root,

View File

@ -15,6 +15,8 @@ export function getGitTimestamp(file: string, type: 'created' | 'updated' = 'upd
child.on('close', () => {
resolve(+new Date(output))
})
child.on('error', () => { resolve(0) })
child.on('error', () => {
resolve(0)
})
})
}

View File

@ -1,6 +1,9 @@
export interface ValaxyAddon {
enable: boolean
export interface ValaxyAddon<AddonOptions = Record<string, any>> {
name: string
/**
* be global component
*/
global?: boolean
props?: Record<string, any>
options?: Record<string, any>
options?: AddonOptions
}

View File

@ -144,14 +144,6 @@ export interface SiteConfig<T = DefaultThemeConfig> {
*/
comment: {
enable: boolean
waline: {
enable: boolean
serverURL: string
}
twikoo: {
enable: boolean
envId: string
}
}
/**
@ -233,6 +225,9 @@ export interface SiteConfig<T = DefaultThemeConfig> {
}[]
}
/**
* Generated Runtime Config
*/
runtime: {
addons: Record<string, ValaxyAddon>
}

View File

@ -15,7 +15,7 @@ importers:
lint-staged: ^13.0.3
prompts: ^2.4.2
rimraf: ^3.0.2
tsup: ^6.2.3
tsup: ^6.5.0
tsx: ^3.12.1
typescript: ^4.9.3
valaxy: workspace:*
@ -37,7 +37,7 @@ importers:
lint-staged: 13.0.3
prompts: 2.4.2
rimraf: 3.0.2
tsup: 6.2.3_typescript@4.9.3
tsup: 6.5.0_typescript@4.9.3
tsx: 3.12.1
typescript: 4.9.3
valaxy: link:packages/valaxy
@ -650,15 +650,6 @@ packages:
requiresBuild: true
optional: true
/@esbuild/linux-loong64/0.15.7:
resolution: {integrity: sha512-IKznSJOsVUuyt7cDzzSZyqBEcZe+7WlBqTVXiF1OXP/4Nm387ToaXZ0fyLwI1iBlI/bzpxVq411QE2/Bt2XWWw==}
engines: {node: '>=12'}
cpu: [loong64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@eslint/eslintrc/1.3.3:
resolution: {integrity: sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@ -1934,8 +1925,8 @@ packages:
resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==}
dev: true
/anymatch/3.1.2:
resolution: {integrity: sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==}
/anymatch/3.1.3:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
dependencies:
normalize-path: 3.0.0
@ -2075,13 +2066,13 @@ packages:
semver: 7.3.8
dev: true
/bundle-require/3.1.0_esbuild@0.15.7:
resolution: {integrity: sha512-IIXtAO7fKcwPHNPt9kY/WNVJqy7NDy6YqJvv6ENH0TOZoJ+yjpEsn1w40WKZbR2ibfu5g1rfgJTvmFHpm5aOMA==}
/bundle-require/3.1.2_esbuild@0.15.15:
resolution: {integrity: sha512-Of6l6JBAxiyQ5axFxUM6dYeP/W7X2Sozeo/4EYB9sJhL+dqL7TKjg+shwxp6jlu/6ZSERfsYtIpSJ1/x3XkAEA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
peerDependencies:
esbuild: '>=0.13'
dependencies:
esbuild: 0.15.7
esbuild: 0.15.15
load-tsconfig: 0.2.3
dev: true
@ -2202,7 +2193,7 @@ packages:
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
engines: {node: '>= 8.10.0'}
dependencies:
anymatch: 3.1.2
anymatch: 3.1.3
braces: 3.0.2
glob-parent: 5.1.2
is-binary-path: 2.1.0
@ -2854,15 +2845,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-android-64/0.15.7:
resolution: {integrity: sha512-p7rCvdsldhxQr3YHxptf1Jcd86dlhvc3EQmQJaZzzuAxefO9PvcI0GLOa5nCWem1AJ8iMRu9w0r5TG8pHmbi9w==}
engines: {node: '>=12'}
cpu: [x64]
os: [android]
requiresBuild: true
dev: true
optional: true
/esbuild-android-arm64/0.15.15:
resolution: {integrity: sha512-attlyhD6Y22jNyQ0fIIQ7mnPvDWKw7k6FKnsXlBvQE6s3z6s6cuEHcSgoirquQc7TmZgVCK5fD/2uxmRN+ZpcQ==}
engines: {node: '>=12'}
@ -2871,15 +2853,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-android-arm64/0.15.7:
resolution: {integrity: sha512-L775l9ynJT7rVqRM5vo+9w5g2ysbOCfsdLV4CWanTZ1k/9Jb3IYlQ06VCI1edhcosTYJRECQFJa3eAvkx72eyQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [android]
requiresBuild: true
dev: true
optional: true
/esbuild-darwin-64/0.15.15:
resolution: {integrity: sha512-ohZtF8W1SHJ4JWldsPVdk8st0r9ExbAOSrBOh5L+Mq47i696GVwv1ab/KlmbUoikSTNoXEhDzVpxUR/WIO19FQ==}
engines: {node: '>=12'}
@ -2888,15 +2861,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-darwin-64/0.15.7:
resolution: {integrity: sha512-KGPt3r1c9ww009t2xLB6Vk0YyNOXh7hbjZ3EecHoVDxgtbUlYstMPDaReimKe6eOEfyY4hBEEeTvKwPsiH5WZg==}
engines: {node: '>=12'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/esbuild-darwin-arm64/0.15.15:
resolution: {integrity: sha512-P8jOZ5zshCNIuGn+9KehKs/cq5uIniC+BeCykvdVhx/rBXSxmtj3CUIKZz4sDCuESMbitK54drf/2QX9QHG5Ag==}
engines: {node: '>=12'}
@ -2905,15 +2869,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-darwin-arm64/0.15.7:
resolution: {integrity: sha512-kBIHvtVqbSGajN88lYMnR3aIleH3ABZLLFLxwL2stiuIGAjGlQW741NxVTpUHQXUmPzxi6POqc9npkXa8AcSZQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/esbuild-freebsd-64/0.15.15:
resolution: {integrity: sha512-KkTg+AmDXz1IvA9S1gt8dE24C8Thx0X5oM0KGF322DuP+P3evwTL9YyusHAWNsh4qLsR80nvBr/EIYs29VSwuA==}
engines: {node: '>=12'}
@ -2922,15 +2877,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-freebsd-64/0.15.7:
resolution: {integrity: sha512-hESZB91qDLV5MEwNxzMxPfbjAhOmtfsr9Wnuci7pY6TtEh4UDuevmGmkUIjX/b+e/k4tcNBMf7SRQ2mdNuK/HQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [freebsd]
requiresBuild: true
dev: true
optional: true
/esbuild-freebsd-arm64/0.15.15:
resolution: {integrity: sha512-FUcML0DRsuyqCMfAC+HoeAqvWxMeq0qXvclZZ/lt2kLU6XBnDA5uKTLUd379WYEyVD4KKFctqWd9tTuk8C/96g==}
engines: {node: '>=12'}
@ -2939,15 +2885,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-freebsd-arm64/0.15.7:
resolution: {integrity: sha512-dLFR0ChH5t+b3J8w0fVKGvtwSLWCv7GYT2Y2jFGulF1L5HftQLzVGN+6pi1SivuiVSmTh28FwUhi9PwQicXI6Q==}
engines: {node: '>=12'}
cpu: [arm64]
os: [freebsd]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-32/0.15.15:
resolution: {integrity: sha512-q28Qn5pZgHNqug02aTkzw5sW9OklSo96b5nm17Mq0pDXrdTBcQ+M6Q9A1B+dalFeynunwh/pvfrNucjzwDXj+Q==}
engines: {node: '>=12'}
@ -2956,15 +2893,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-linux-32/0.15.7:
resolution: {integrity: sha512-v3gT/LsONGUZcjbt2swrMjwxo32NJzk+7sAgtxhGx1+ZmOFaTRXBAi1PPfgpeo/J//Un2jIKm/I+qqeo4caJvg==}
engines: {node: '>=12'}
cpu: [ia32]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-64/0.15.15:
resolution: {integrity: sha512-217KPmWMirkf8liO+fj2qrPwbIbhNTGNVtvqI1TnOWJgcMjUWvd677Gq3fTzXEjilkx2yWypVnTswM2KbXgoAg==}
engines: {node: '>=12'}
@ -2973,15 +2901,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-linux-64/0.15.7:
resolution: {integrity: sha512-LxXEfLAKwOVmm1yecpMmWERBshl+Kv5YJ/1KnyAr6HRHFW8cxOEsEfisD3sVl/RvHyW//lhYUVSuy9jGEfIRAQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-arm/0.15.15:
resolution: {integrity: sha512-RYVW9o2yN8yM7SB1yaWr378CwrjvGCyGybX3SdzPHpikUHkME2AP55Ma20uNwkNyY2eSYFX9D55kDrfQmQBR4w==}
engines: {node: '>=12'}
@ -2990,15 +2909,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-linux-arm/0.15.7:
resolution: {integrity: sha512-JKgAHtMR5f75wJTeuNQbyznZZa+pjiUHV7sRZp42UNdyXC6TiUYMW/8z8yIBAr2Fpad8hM1royZKQisqPABPvQ==}
engines: {node: '>=12'}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-arm64/0.15.15:
resolution: {integrity: sha512-/ltmNFs0FivZkYsTzAsXIfLQX38lFnwJTWCJts0IbCqWZQe+jjj0vYBNbI0kmXLb3y5NljiM5USVAO1NVkdh2g==}
engines: {node: '>=12'}
@ -3007,15 +2917,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-linux-arm64/0.15.7:
resolution: {integrity: sha512-P3cfhudpzWDkglutWgXcT2S7Ft7o2e3YDMrP1n0z2dlbUZghUkKCyaWw0zhp4KxEEzt/E7lmrtRu/pGWnwb9vw==}
engines: {node: '>=12'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-mips64le/0.15.15:
resolution: {integrity: sha512-PksEPb321/28GFFxtvL33yVPfnMZihxkEv5zME2zapXGp7fA1X2jYeiTUK+9tJ/EGgcNWuwvtawPxJG7Mmn86A==}
engines: {node: '>=12'}
@ -3024,15 +2925,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-linux-mips64le/0.15.7:
resolution: {integrity: sha512-T7XKuxl0VpeFLCJXub6U+iybiqh0kM/bWOTb4qcPyDDwNVhLUiPcGdG2/0S7F93czUZOKP57YiLV8YQewgLHKw==}
engines: {node: '>=12'}
cpu: [mips64el]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-ppc64le/0.15.15:
resolution: {integrity: sha512-ek8gJBEIhcpGI327eAZigBOHl58QqrJrYYIZBWQCnH3UnXoeWMrMZLeeZL8BI2XMBhP+sQ6ERctD5X+ajL/AIA==}
engines: {node: '>=12'}
@ -3041,15 +2933,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-linux-ppc64le/0.15.7:
resolution: {integrity: sha512-6mGuC19WpFN7NYbecMIJjeQgvDb5aMuvyk0PDYBJrqAEMkTwg3Z98kEKuCm6THHRnrgsdr7bp4SruSAxEM4eJw==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-riscv64/0.15.15:
resolution: {integrity: sha512-H5ilTZb33/GnUBrZMNJtBk7/OXzDHDXjIzoLXHSutwwsLxSNaLxzAaMoDGDd/keZoS+GDBqNVxdCkpuiRW4OSw==}
engines: {node: '>=12'}
@ -3058,15 +2941,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-linux-riscv64/0.15.7:
resolution: {integrity: sha512-uUJsezbswAYo/X7OU/P+PuL/EI9WzxsEQXDekfwpQ23uGiooxqoLFAPmXPcRAt941vjlY9jtITEEikWMBr+F/g==}
engines: {node: '>=12'}
cpu: [riscv64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-s390x/0.15.15:
resolution: {integrity: sha512-jKaLUg78mua3rrtrkpv4Or2dNTJU7bgHN4bEjT4OX4GR7nLBSA9dfJezQouTxMmIW7opwEC5/iR9mpC18utnxQ==}
engines: {node: '>=12'}
@ -3075,15 +2949,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-linux-s390x/0.15.7:
resolution: {integrity: sha512-+tO+xOyTNMc34rXlSxK7aCwJgvQyffqEM5MMdNDEeMU3ss0S6wKvbBOQfgd5jRPblfwJ6b+bKiz0g5nABpY0QQ==}
engines: {node: '>=12'}
cpu: [s390x]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-netbsd-64/0.15.15:
resolution: {integrity: sha512-aOvmF/UkjFuW6F36HbIlImJTTx45KUCHJndtKo+KdP8Dhq3mgLRKW9+6Ircpm8bX/RcS3zZMMmaBLkvGY06Gvw==}
engines: {node: '>=12'}
@ -3092,15 +2957,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-netbsd-64/0.15.7:
resolution: {integrity: sha512-yVc4Wz+Pu3cP5hzm5kIygNPrjar/v5WCSoRmIjCPWfBVJkZNb5brEGKUlf+0Y759D48BCWa0WHrWXaNy0DULTQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
requiresBuild: true
dev: true
optional: true
/esbuild-openbsd-64/0.15.15:
resolution: {integrity: sha512-HFFX+WYedx1w2yJ1VyR1Dfo8zyYGQZf1cA69bLdrHzu9svj6KH6ZLK0k3A1/LFPhcEY9idSOhsB2UyU0tHPxgQ==}
engines: {node: '>=12'}
@ -3109,15 +2965,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-openbsd-64/0.15.7:
resolution: {integrity: sha512-GsimbwC4FSR4lN3wf8XmTQ+r8/0YSQo21rWDL0XFFhLHKlzEA4SsT1Tl8bPYu00IU6UWSJ+b3fG/8SB69rcuEQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
requiresBuild: true
dev: true
optional: true
/esbuild-sunos-64/0.15.15:
resolution: {integrity: sha512-jOPBudffG4HN8yJXcK9rib/ZTFoTA5pvIKbRrt3IKAGMq1EpBi4xoVoSRrq/0d4OgZLaQbmkHp8RO9eZIn5atA==}
engines: {node: '>=12'}
@ -3126,15 +2973,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-sunos-64/0.15.7:
resolution: {integrity: sha512-8CDI1aL/ts0mDGbWzjEOGKXnU7p3rDzggHSBtVryQzkSOsjCHRVe0iFYUuhczlxU1R3LN/E7HgUO4NXzGGP/Ag==}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
requiresBuild: true
dev: true
optional: true
/esbuild-windows-32/0.15.15:
resolution: {integrity: sha512-MDkJ3QkjnCetKF0fKxCyYNBnOq6dmidcwstBVeMtXSgGYTy8XSwBeIE4+HuKiSsG6I/mXEb++px3IGSmTN0XiA==}
engines: {node: '>=12'}
@ -3143,15 +2981,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-windows-32/0.15.7:
resolution: {integrity: sha512-cOnKXUEPS8EGCzRSFa1x6NQjGhGsFlVgjhqGEbLTPsA7x4RRYiy2RKoArNUU4iR2vHmzqS5Gr84MEumO/wxYKA==}
engines: {node: '>=12'}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: true
optional: true
/esbuild-windows-64/0.15.15:
resolution: {integrity: sha512-xaAUIB2qllE888SsMU3j9nrqyLbkqqkpQyWVkfwSil6BBPgcPk3zOFitTTncEKCLTQy3XV9RuH7PDj3aJDljWA==}
engines: {node: '>=12'}
@ -3160,15 +2989,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-windows-64/0.15.7:
resolution: {integrity: sha512-7MI08Ec2sTIDv+zH6StNBKO+2hGUYIT42GmFyW6MBBWWtJhTcQLinKS6ldIN1d52MXIbiJ6nXyCJ+LpL4jBm3Q==}
engines: {node: '>=12'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/esbuild-windows-arm64/0.15.15:
resolution: {integrity: sha512-ttuoCYCIJAFx4UUKKWYnFdrVpoXa3+3WWkXVI6s09U+YjhnyM5h96ewTq/WgQj9LFSIlABQvadHSOQyAVjW5xQ==}
engines: {node: '>=12'}
@ -3177,15 +2997,6 @@ packages:
requiresBuild: true
optional: true
/esbuild-windows-arm64/0.15.7:
resolution: {integrity: sha512-R06nmqBlWjKHddhRJYlqDd3Fabx9LFdKcjoOy08YLimwmsswlFBJV4rXzZCxz/b7ZJXvrZgj8DDv1ewE9+StMw==}
engines: {node: '>=12'}
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/esbuild/0.15.15:
resolution: {integrity: sha512-TEw/lwK4Zzld9x3FedV6jy8onOUHqcEX3ADFk4k+gzPUwrxn8nWV62tH0udo8jOtjFodlEfc4ypsqX3e+WWO6w==}
engines: {node: '>=12'}
@ -3215,35 +3026,6 @@ packages:
esbuild-windows-64: 0.15.15
esbuild-windows-arm64: 0.15.15
/esbuild/0.15.7:
resolution: {integrity: sha512-7V8tzllIbAQV1M4QoE52ImKu8hT/NLGlGXkiDsbEU5PS6K8Mn09ZnYoS+dcmHxOS9CRsV4IRAMdT3I67IyUNXw==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
optionalDependencies:
'@esbuild/linux-loong64': 0.15.7
esbuild-android-64: 0.15.7
esbuild-android-arm64: 0.15.7
esbuild-darwin-64: 0.15.7
esbuild-darwin-arm64: 0.15.7
esbuild-freebsd-64: 0.15.7
esbuild-freebsd-arm64: 0.15.7
esbuild-linux-32: 0.15.7
esbuild-linux-64: 0.15.7
esbuild-linux-arm: 0.15.7
esbuild-linux-arm64: 0.15.7
esbuild-linux-mips64le: 0.15.7
esbuild-linux-ppc64le: 0.15.7
esbuild-linux-riscv64: 0.15.7
esbuild-linux-s390x: 0.15.7
esbuild-netbsd-64: 0.15.7
esbuild-openbsd-64: 0.15.7
esbuild-sunos-64: 0.15.7
esbuild-windows-32: 0.15.7
esbuild-windows-64: 0.15.7
esbuild-windows-arm64: 0.15.7
dev: true
/escalade/3.1.1:
resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==}
engines: {node: '>=6'}
@ -5823,14 +5605,6 @@ packages:
glob: 7.2.3
dev: true
/rollup/2.79.0:
resolution: {integrity: sha512-x4KsrCgwQ7ZJPcFA/SUu6QVcYlO7uRLfLAy0DSA4NS2eG8japdbpM50ToH7z4iObodRYOJ0soneF0iaQRJ6zhA==}
engines: {node: '>=10.0.0'}
hasBin: true
optionalDependencies:
fsevents: 2.3.2
dev: true
/rollup/2.79.1:
resolution: {integrity: sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==}
engines: {node: '>=10.0.0'}
@ -5838,6 +5612,14 @@ packages:
optionalDependencies:
fsevents: 2.3.2
/rollup/3.4.0:
resolution: {integrity: sha512-4g8ZrEFK7UbDvy3JF+d5bLiC8UKkS3n/27/cnVeESwB1LVPl6MoPL32/6+SCQ1vHTp6Mvp2veIHtwELhi+uXEw==}
engines: {node: '>=14.18.0', npm: '>=8.0.0'}
hasBin: true
optionalDependencies:
fsevents: 2.3.2
dev: true
/run-parallel/1.2.0:
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
dependencies:
@ -6268,8 +6050,8 @@ packages:
acorn: 8.8.1
dev: true
/sucrase/3.27.0:
resolution: {integrity: sha512-IjpEeFzOWCGrB/e2DnPawkFajW6ONFFgs+lQT1+Ts5Z5ZM9gPnxpDh0q8tu7HVLt6IfRiUTbSsjfhqjHOP/cwQ==}
/sucrase/3.29.0:
resolution: {integrity: sha512-bZPAuGA5SdFHuzqIhTAqt9fvNEo9rESqXIG3oiKdF8K4UmkQxC4KlNL3lVyAErXp+mPvUqZ5l13qx6TrDIGf3A==}
engines: {node: '>=8'}
hasBin: true
dependencies:
@ -6441,8 +6223,8 @@ packages:
/tslib/2.4.0:
resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==}
/tsup/6.2.3_typescript@4.9.3:
resolution: {integrity: sha512-J5Pu2Dx0E1wlpIEsVFv9ryzP1pZ1OYsJ2cBHZ7GrKteytNdzaSz5hmLX7/nAxtypq+jVkVvA79d7S83ETgHQ5w==}
/tsup/6.5.0_typescript@4.9.3:
resolution: {integrity: sha512-36u82r7rYqRHFkD15R20Cd4ercPkbYmuvRkz3Q1LCm5BsiFNUgpo36zbjVhCOgvjyxNBWNKHsaD5Rl8SykfzNA==}
engines: {node: '>=14'}
hasBin: true
peerDependencies:
@ -6457,19 +6239,19 @@ packages:
typescript:
optional: true
dependencies:
bundle-require: 3.1.0_esbuild@0.15.7
bundle-require: 3.1.2_esbuild@0.15.15
cac: 6.7.14
chokidar: 3.5.3
debug: 4.3.4
esbuild: 0.15.7
esbuild: 0.15.15
execa: 5.1.1
globby: 11.1.0
joycon: 3.1.1
postcss-load-config: 3.1.4
resolve-from: 5.0.0
rollup: 2.79.0
rollup: 3.4.0
source-map: 0.8.0-beta.0
sucrase: 3.27.0
sucrase: 3.29.0
tree-kill: 1.2.2
typescript: 4.9.3
transitivePeerDependencies:

View File

@ -1,4 +1,4 @@
import { getAddonRoot, parseAddonLike, parseAddonOptions, readAddonModule } from '../packages/valaxy/node/utils/addons'
import { getAddonRoot, parseAddonLike, readAddonModule } from '../packages/valaxy/node/utils/addons'
describe('addon parse', () => {
it('addon:like:boolean', () => {
@ -7,12 +7,6 @@ describe('addon parse', () => {
expect(option).toEqual(result)
})
it('addon:like:object', () => {
const option = parseAddonLike({ global: false, options: { a: 123 } })
const result = { enable: true, global: false, options: { a: 123 } }
expect(option).toEqual(result)
})
it('addon:read:module', async () => {
const options = await readAddonModule('./test/fixtures/addon', { cwd: process.cwd() })
const result = {
@ -25,13 +19,4 @@ describe('addon parse', () => {
}
expect(options).toEqual(result)
})
it('addon:parse:cover', async () => {
const addons = await parseAddonOptions([
['./test/fixtures/addon', { global: true }],
['./test/fixtures/addon', { global: false }],
])
expect(addons[0].global).toBeFalsy()
expect(addons.length).toEqual(1)
})
})