mirror of https://github.com/YunYouJun/valaxy
refactor: migrate picocolors to consola/utils colors
This commit is contained in:
parent
ba2c7be3af
commit
09ab70f077
|
@ -2,7 +2,7 @@
|
|||
"name": "valaxy-theme-custom",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@10.5.2",
|
||||
"packageManager": "pnpm@10.6.1",
|
||||
"author": {
|
||||
"email": "me@yunyoujun.cn",
|
||||
"name": "YunYouJun",
|
||||
|
|
|
@ -24,7 +24,7 @@ export interface ExampleSite {
|
|||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
site: ExampleSite
|
||||
site?: ExampleSite
|
||||
}>(),
|
||||
{
|
||||
site: () => ({
|
||||
|
|
15
package.json
15
package.json
|
@ -3,7 +3,7 @@
|
|||
"type": "module",
|
||||
"version": "0.22.13",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@10.5.2",
|
||||
"packageManager": "pnpm@10.6.1",
|
||||
"description": "📄 Vite & Vue powered static blog generator.",
|
||||
"author": {
|
||||
"email": "me@yunyoujun.cn",
|
||||
|
@ -82,21 +82,22 @@
|
|||
"valaxy-theme-yun": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^4.3.0",
|
||||
"@antfu/eslint-config": "^4.8.1",
|
||||
"@iconify-json/logos": "catalog:",
|
||||
"@iconify-json/vscode-icons": "catalog:",
|
||||
"@microsoft/api-extractor": "^7.51.1",
|
||||
"@playwright/test": "^1.50.1",
|
||||
"@playwright/test": "^1.51.0",
|
||||
"@types/debug": "^4.1.12",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/markdown-it-attrs": "^4.1.3",
|
||||
"@types/markdown-it-container": "^2.0.10",
|
||||
"@types/markdown-it-emoji": "^3.0.1",
|
||||
"@types/node": "^22.13.8",
|
||||
"@types/node": "^22.13.10",
|
||||
"@types/prompts": "^2.4.9",
|
||||
"@types/resolve": "^1.20.6",
|
||||
"bumpp": "^10.0.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^9.21.0",
|
||||
"eslint": "^9.22.0",
|
||||
"https-localhost": "^4.7.1",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^15.4.3",
|
||||
|
@ -110,8 +111,8 @@
|
|||
"tsx": "^4.19.3",
|
||||
"typescript": "catalog:",
|
||||
"unbuild": "catalog:",
|
||||
"vite-node": "^3.0.7",
|
||||
"vitest": "^3.0.7",
|
||||
"vite-node": "^3.0.8",
|
||||
"vitest": "^3.0.8",
|
||||
"vue-tsc": "2.2.0",
|
||||
"zx": "catalog:"
|
||||
},
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"consola": "catalog:",
|
||||
"execa": "9.0.2",
|
||||
"kolorist": "^1.8.0",
|
||||
"minimist": "^1.2.8",
|
||||
"prompts": "^2.4.2"
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { cyan, green, yellow } from 'kolorist'
|
||||
import { colors } from 'consola/utils'
|
||||
import { initTheme } from './theme'
|
||||
|
||||
export const renameFiles: Record<string, string> = {
|
||||
|
@ -13,7 +13,7 @@ export const TEMPLATES = [
|
|||
desc: 'For Most Users',
|
||||
message: 'Project name:',
|
||||
initial: 'valaxy-blog',
|
||||
color: cyan,
|
||||
color: colors.cyan,
|
||||
},
|
||||
{
|
||||
name: 'theme',
|
||||
|
@ -22,7 +22,7 @@ export const TEMPLATES = [
|
|||
message: 'Theme name: valaxy-theme-',
|
||||
initial: 'starter',
|
||||
prefix: 'valaxy-theme-',
|
||||
color: green,
|
||||
color: colors.green,
|
||||
customInit: async (options: {
|
||||
themeName?: string
|
||||
}) => {
|
||||
|
@ -38,7 +38,7 @@ export const TEMPLATES = [
|
|||
message: 'Addon name: valaxy-addon-',
|
||||
initial: 'template',
|
||||
prefix: 'valaxy-addon-',
|
||||
color: yellow,
|
||||
color: colors.yellow,
|
||||
},
|
||||
]
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable no-console */
|
||||
import { colors } from 'consola/utils'
|
||||
import { execa } from 'execa'
|
||||
import { blue, bold, cyan, dim, gray, green, yellow } from 'kolorist'
|
||||
import prompts from 'prompts'
|
||||
|
||||
const starterTheme = {
|
||||
|
@ -29,17 +29,17 @@ export async function initTheme(options: {
|
|||
|
||||
const targetDir = `valaxy-theme-${themeName!.trim()}`
|
||||
|
||||
console.log(` ${dim('npx')} ${gray('degit')} ${blue(starterTheme.repo)} ${yellow(targetDir)}`)
|
||||
console.log(` ${colors.dim('npx')} ${colors.gray('degit')} ${colors.blue(starterTheme.repo)} ${colors.yellow(targetDir)}`)
|
||||
await execa('npx', ['degit', starterTheme.repo, targetDir], { stdio: 'inherit' })
|
||||
|
||||
console.log()
|
||||
console.log(` ${bold('Check it')}:`)
|
||||
console.log(` ${colors.bold('Check it')}:`)
|
||||
console.log()
|
||||
console.log(`- Change ${bold('author')} name in ${yellow('LICENSE')} & ${green('package.json')} & ${blue('.github')}`)
|
||||
console.log(`- Change ${blue('valaxy.config.ts')} theme: ${yellow('starter')} to ${cyan(`${themeName}`)}`)
|
||||
console.log(`- Rename ${yellow(`valaxy-theme-${themeName}`)} to ${cyan(`valaxy-theme-${themeName}`)}`)
|
||||
console.log(`- Change ${colors.bold('author')} name in ${colors.yellow('LICENSE')} & ${colors.green('package.json')} & ${colors.blue('.github')}`)
|
||||
console.log(`- Change ${colors.blue('valaxy.config.ts')} theme: ${colors.yellow('starter')} to ${colors.cyan(`${themeName}`)}`)
|
||||
console.log(`- Rename ${colors.yellow(`valaxy-theme-${themeName}`)} to ${colors.cyan(`valaxy-theme-${themeName}`)}`)
|
||||
console.log()
|
||||
console.log(` ${cyan('✨')}`)
|
||||
console.log(` ${colors.cyan('✨')}`)
|
||||
console.log()
|
||||
|
||||
return `valaxy-theme-${themeName}`
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { dim, red } from 'kolorist'
|
||||
import { colors } from 'consola/utils'
|
||||
|
||||
/**
|
||||
* remove trailing slash
|
||||
|
@ -34,7 +34,7 @@ export function copyDir(srcDir: string, destDir: string) {
|
|||
|
||||
export function emptyDir(dir: string) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`\n ${red(`Removing`)} ${dim(dir)}`)
|
||||
console.log(`\n ${colors.red(`Removing`)} ${colors.dim(dir)}`)
|
||||
if (!fs.existsSync(dir))
|
||||
return
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ import fs from 'node:fs'
|
|||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { execa } from 'execa'
|
||||
|
||||
// only use it in create-valaxy
|
||||
import { blue, bold, cyan, dim, green, red, reset } from 'kolorist'
|
||||
import { colors } from 'consola/utils'
|
||||
|
||||
import { execa } from 'execa'
|
||||
import minimist from 'minimist'
|
||||
import prompts from 'prompts'
|
||||
import { version } from '../package.json'
|
||||
|
@ -22,7 +22,7 @@ const __filename = fileURLToPath(import.meta.url)
|
|||
|
||||
export async function init() {
|
||||
console.log()
|
||||
console.log(` ${bold('🌌 Valaxy')} ${blue(`v${version}`)}`)
|
||||
console.log(` ${colors.bold('🌌 Valaxy')} ${colors.blue(`v${version}`)}`)
|
||||
console.log()
|
||||
|
||||
const argTargetDir = formatTargetDir(argv._[0])
|
||||
|
@ -53,15 +53,15 @@ export async function init() {
|
|||
name: 'template',
|
||||
message:
|
||||
typeof argTemplate === 'string' && !TEMPLATE_CHOICES.includes(argTemplate)
|
||||
? reset(
|
||||
? colors.reset(
|
||||
`"${argTemplate}" isn't a valid template. Please choose from below: `,
|
||||
)
|
||||
: reset('Select a type:'),
|
||||
: colors.reset('Select a type:'),
|
||||
initial: 0,
|
||||
choices: TEMPLATES.map((template) => {
|
||||
const tColor = template.color
|
||||
return {
|
||||
title: tColor(template.display || template.name) + dim(` - ${template.desc}`),
|
||||
title: tColor(template.display || template.name) + colors.dim(` - ${template.desc}`),
|
||||
value: template,
|
||||
}
|
||||
}),
|
||||
|
@ -73,7 +73,7 @@ export async function init() {
|
|||
{
|
||||
type: argTargetDir ? null : 'text',
|
||||
name: 'projectName',
|
||||
message: reset(template.message),
|
||||
message: colors.reset(template.message),
|
||||
initial: template.initial,
|
||||
onState: (state) => {
|
||||
targetDir = formatTargetDir(template.prefix ? template.prefix + state.value : state.value) || (template.initial)
|
||||
|
@ -92,7 +92,7 @@ export async function init() {
|
|||
{
|
||||
type: (_, { overwrite }: { overwrite?: boolean }) => {
|
||||
if (overwrite === false)
|
||||
throw new Error(`${red('✖')} Operation cancelled`)
|
||||
throw new Error(`${colors.red('✖')} Operation cancelled`)
|
||||
|
||||
return null
|
||||
},
|
||||
|
@ -101,14 +101,14 @@ export async function init() {
|
|||
{
|
||||
type: () => (isValidPackageName(getProjectName()) ? null : 'text'),
|
||||
name: 'packageName',
|
||||
message: reset('Package name:'),
|
||||
message: colors.reset('Package name:'),
|
||||
initial: () => toValidPackageName(getProjectName()),
|
||||
validate: dir =>
|
||||
isValidPackageName(dir) || 'Invalid package.json name',
|
||||
},
|
||||
], {
|
||||
onCancel: () => {
|
||||
throw new Error(`${red('✖')} Operation cancelled`)
|
||||
throw new Error(`${colors.red('✖')} Operation cancelled`)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -168,15 +168,15 @@ export async function init() {
|
|||
write('package.json', `${JSON.stringify(pkg, null, 2)}\n`)
|
||||
}
|
||||
|
||||
console.log(` ${dim('📁')} ${dim(root)}`)
|
||||
console.log(` ${colors.dim('📁')} ${colors.dim(root)}`)
|
||||
console.log()
|
||||
console.log(dim(' Scaffolding project in ') + targetDir + dim(' ...'))
|
||||
console.log(colors.dim(' Scaffolding project in ') + targetDir + colors.dim(' ...'))
|
||||
|
||||
const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent)
|
||||
const pkgManager = pkgInfo ? pkgInfo.name : 'npm'
|
||||
|
||||
const related = path.relative(cwd, root)
|
||||
console.log(green(' Done.\n'))
|
||||
console.log(colors.green(' Done.\n'))
|
||||
|
||||
// addon not start
|
||||
if (template.name === 'addon')
|
||||
|
@ -226,21 +226,21 @@ export async function init() {
|
|||
await execa(agent, devArgs, { stdio: 'inherit', cwd: root })
|
||||
}
|
||||
else {
|
||||
console.log(dim('\n start it later by:\n'))
|
||||
console.log(colors.dim('\n start it later by:\n'))
|
||||
if (root !== cwd)
|
||||
console.log(` ${green('cd')} ${blue(related)}`)
|
||||
console.log(` ${colors.green('cd')} ${colors.blue(related)}`)
|
||||
|
||||
switch (pkgManager) {
|
||||
case 'yarn':
|
||||
console.log(` ${green('yarn')}`)
|
||||
console.log(` ${green('yarn')} dev`)
|
||||
console.log(` ${colors.green('yarn')}`)
|
||||
console.log(` ${colors.green('yarn')} dev`)
|
||||
break
|
||||
default:
|
||||
console.log(` ${green(pkgManager)} install`)
|
||||
console.log(` ${green(pkgManager)} run dev`)
|
||||
console.log(` ${colors.green(pkgManager)} install`)
|
||||
console.log(` ${colors.green(pkgManager)} run dev`)
|
||||
break
|
||||
}
|
||||
console.log()
|
||||
console.log(` ${cyan('✨')}`)
|
||||
console.log(` ${colors.cyan('✨')}`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,6 @@ export default defineBuildConfig({
|
|||
// in valaxy
|
||||
'valaxy',
|
||||
'valaxy/node',
|
||||
'vite',
|
||||
'gray-matter',
|
||||
'fs-extra',
|
||||
'fast-glob',
|
||||
'consola',
|
||||
],
|
||||
rollup: {
|
||||
dts: {
|
||||
|
|
|
@ -35,14 +35,14 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^5.1.4",
|
||||
"axios": "^1.8.1",
|
||||
"axios": "^1.8.2",
|
||||
"body-parser": "^2.1.0",
|
||||
"cors": "^2.8.5",
|
||||
"http-proxy-middleware": "^3.0.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
"pathe": "^2.0.3",
|
||||
"picocolors": "^1.1.1",
|
||||
"sirv": "^3.0.1",
|
||||
"valaxy": "workspace:*",
|
||||
"vite-dev-rpc": "^1.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -55,10 +55,10 @@
|
|||
"@types/wicg-file-system-access": "^2023.10.5",
|
||||
"gray-matter": "^4.0.3",
|
||||
"primevue": "^4.3.1",
|
||||
"splitpanes": "^3.1.8",
|
||||
"splitpanes": "^4.0.2",
|
||||
"typescript": "catalog:",
|
||||
"unbuild": "catalog:",
|
||||
"unplugin-vue-router": "^0.11.2",
|
||||
"unplugin-vue-router": "^0.12.0",
|
||||
"vite": "catalog:",
|
||||
"vue-i18n": "catalog:",
|
||||
"zod": "^3.24.2"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'
|
||||
import type { ClientFunctions, ServerFunctions } from '../../rpc'
|
||||
import type { ValaxyDevtoolsOptions } from './types'
|
||||
import c from 'picocolors'
|
||||
import { colors } from 'consola/utils'
|
||||
import sirv from 'sirv'
|
||||
import { createRPCServer } from 'vite-dev-rpc'
|
||||
import { NAMESPACE } from '../config'
|
||||
|
@ -45,9 +45,9 @@ export function ValaxyDevtools(options: ValaxyDevtoolsOptions = {}): Plugin {
|
|||
|
||||
_print()
|
||||
|
||||
const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
|
||||
const colorUrl = (url: string) => colors.green(url.replace(/:(\d+)\//, (_, port) => `:${colors.bold(port)}/`))
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(` ${c.green('➜')} ${c.bold('Inspect')}: ${colorUrl(`${host}${base}__inspect/`)}`)
|
||||
console.log(` ${colors.green('➜')} ${colors.bold('Inspect')}: ${colorUrl(`${host}${base}__inspect/`)}`)
|
||||
}
|
||||
|
||||
// register api to vite.server
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
withDefaults(defineProps<{
|
||||
show: boolean
|
||||
show?: boolean
|
||||
}>(), {
|
||||
show: false,
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
withDefaults(defineProps<{
|
||||
show: boolean
|
||||
show?: boolean
|
||||
}>(), {
|
||||
show: false,
|
||||
})
|
||||
|
|
|
@ -4,8 +4,8 @@ import type { ValaxyNode } from './types'
|
|||
import { join, resolve } from 'node:path'
|
||||
import consola from 'consola'
|
||||
|
||||
import { colors } from 'consola/utils'
|
||||
import fs from 'fs-extra'
|
||||
import colors from 'picocolors'
|
||||
import { mergeConfig as mergeViteConfig, build as viteBuild } from 'vite'
|
||||
import generateSitemap from 'vite-ssg-sitemap'
|
||||
import { build as viteSsgBuild } from 'vite-ssg/node'
|
||||
|
|
|
@ -5,7 +5,7 @@ import path from 'node:path'
|
|||
import process from 'node:process'
|
||||
import consola from 'consola'
|
||||
|
||||
import { yellow } from 'picocolors'
|
||||
import { colors } from 'consola/utils'
|
||||
import { mergeConfig } from 'vite'
|
||||
import { mergeViteConfigs, resolveOptions } from '..'
|
||||
import { createValaxyNode } from '../app'
|
||||
|
@ -74,7 +74,7 @@ export async function execBuild({ ssg, root, output, log }: { ssg: boolean, root
|
|||
consola.box('🌠 Start building...')
|
||||
try {
|
||||
if (ssg) {
|
||||
consola.info(`use ${yellow('vite-ssg')} to do ssg build...`)
|
||||
consola.info(`use ${colors.yellow('vite-ssg')} to do ssg build...`)
|
||||
|
||||
try {
|
||||
await ssgBuild(valaxyApp, viteConfig)
|
||||
|
|
|
@ -9,7 +9,6 @@ import * as readline from 'node:readline'
|
|||
import consola from 'consola'
|
||||
import { colors } from 'consola/utils'
|
||||
import ora from 'ora'
|
||||
import { blue, bold, cyan, dim, gray, green, underline, yellow } from 'picocolors'
|
||||
import { version } from 'valaxy/package.json'
|
||||
import { mergeConfig } from 'vite'
|
||||
import { mergeViteConfigs } from '../../common'
|
||||
|
@ -18,16 +17,16 @@ import { valaxyPrefix, vLogger } from '../../logger'
|
|||
import { createServer } from '../../server'
|
||||
|
||||
export function printInfo(options: ResolvedValaxyOptions, port?: number, remote?: string | boolean) {
|
||||
const themeVersion = blue(`v${options.config.themeConfig?.pkg?.version}`) || 'unknown'
|
||||
const themeVersion = colors.blue(`v${options.config.themeConfig?.pkg?.version}`) || 'unknown'
|
||||
|
||||
console.log()
|
||||
console.log(` ${bold('🌌 Valaxy')} ${blue(`v${version}`)}`)
|
||||
console.log(` ${colors.bold('🌌 Valaxy')} ${colors.blue(`v${version}`)}`)
|
||||
console.log()
|
||||
console.log(`${dim(' 🪐 theme ')} > ${(options.theme ? green(options.theme) : gray('none'))} (${themeVersion})`)
|
||||
console.log(` ${dim('📁')} ${dim(path.resolve(options.userRoot))}`)
|
||||
console.log(`${colors.dim(' 🪐 theme ')} > ${(options.theme ? colors.green(options.theme) : colors.gray('none'))} (${themeVersion})`)
|
||||
console.log(` ${colors.dim('📁')} ${colors.dim(path.resolve(options.userRoot))}`)
|
||||
if (port) {
|
||||
console.log()
|
||||
console.log(`${dim(' Preview ')} > ${cyan(`http://localhost:${bold(port)}/`)}`)
|
||||
console.log(`${colors.dim(' Preview ')} > ${colors.cyan(`http://localhost:${colors.bold(port)}/`)}`)
|
||||
|
||||
if (remote) {
|
||||
Object.values(os.networkInterfaces())
|
||||
|
@ -35,18 +34,18 @@ export function printInfo(options: ResolvedValaxyOptions, port?: number, remote?
|
|||
(v || [])
|
||||
.filter(details => details.family === 'IPv4' && !details.address.includes('127.0.0.1'))
|
||||
.forEach(({ address }) => {
|
||||
console.log(`${dim(' Network ')} > ${blue(`http://${address}:${bold(port)}/`)}`)
|
||||
console.log(`${colors.dim(' Network ')} > ${colors.blue(`http://${address}:${colors.bold(port)}/`)}`)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
console.log()
|
||||
const restart = `${underline('r')}${dim('estart')}`
|
||||
const edit = `${underline('e')}${dim('dit')}`
|
||||
const open = `${underline('o')}${dim('pen')}`
|
||||
const qr = `${underline('q')}${dim('r')}`
|
||||
const divider = `${dim(' | ')}`
|
||||
console.log(`${dim(' shortcuts ')} > ${restart}${divider}${open}${divider}${qr}${divider}${edit}`)
|
||||
const restart = `${colors.underline('r')}${colors.dim('estart')}`
|
||||
const edit = `${colors.underline('e')}${colors.dim('dit')}`
|
||||
const open = `${colors.underline('o')}${colors.dim('pen')}`
|
||||
const qr = `${colors.underline('q')}${colors.dim('r')}`
|
||||
const divider = `${colors.dim(' | ')}`
|
||||
console.log(`${colors.dim(' shortcuts ')} > ${restart}${divider}${open}${divider}${qr}${divider}${edit}`)
|
||||
}
|
||||
console.log()
|
||||
}
|
||||
|
@ -70,7 +69,7 @@ export async function initServer(valaxyApp: ValaxyNode, viteConfig: InlineConfig
|
|||
const server = await createServer(valaxyApp, viteConfigs, {
|
||||
async onConfigReload(newConfig, config, force = false) {
|
||||
if (force) {
|
||||
vLogger.info(`${yellow('force')} reload the server`)
|
||||
vLogger.info(`${colors.yellow('force')} reload the server`)
|
||||
initServer(valaxyApp, viteConfig)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ import { writeFile } from 'node:fs/promises'
|
|||
import { join, resolve } from 'node:path'
|
||||
import { ensureSuffix } from '@antfu/utils'
|
||||
import { consola } from 'consola'
|
||||
import { colors } from 'consola/utils'
|
||||
import dayjs from 'dayjs'
|
||||
import { render } from 'ejs'
|
||||
import { green, magenta } from 'picocolors'
|
||||
import { defaultPostTemplate, userRoot } from './constants'
|
||||
import { exists } from './fs'
|
||||
|
||||
|
@ -42,12 +42,12 @@ export async function create(data: CreatePostParams) {
|
|||
const content = await genLayoutTemplate(data)
|
||||
try {
|
||||
await writeFile(destinationPath, content, 'utf-8')
|
||||
consola.success(`[valaxy new]: successfully generated file ${magenta(destinationPath)}`)
|
||||
consola.success(`[valaxy new]: successfully generated file ${colors.magenta(destinationPath)}`)
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e)
|
||||
consola.error(`[valaxy new]: failed to write file ${destinationPath}`)
|
||||
consola.warn(`You should run ${green('valaxy new')} in your valaxy project root directory.`)
|
||||
consola.warn(`You should run ${colors.green('valaxy new')} in your valaxy project root directory.`)
|
||||
}
|
||||
return destinationPath
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import type { SiteConfig, UserSiteConfig } from 'valaxy/types'
|
||||
import { webcrypto } from 'node:crypto'
|
||||
import consola from 'consola'
|
||||
import { colors } from 'consola/utils'
|
||||
import { options as floatingVueOptions } from 'floating-vue'
|
||||
import { cyan, dim, yellow } from 'picocolors'
|
||||
import { countPerformanceTime } from '../utils/performance'
|
||||
import { loadConfigFromFile } from './utils'
|
||||
|
||||
|
@ -134,7 +134,7 @@ export async function resolveSiteConfig(root: string) {
|
|||
const duration = endCount()
|
||||
|
||||
if (userSiteConfig && siteConfigFile)
|
||||
consola.success(`Resolve ${cyan('siteConfig')} from ${dim(siteConfigFile)} ${yellow(duration)}`)
|
||||
consola.success(`Resolve ${colors.cyan('siteConfig')} from ${colors.dim(siteConfigFile)} ${colors.yellow(duration)}`)
|
||||
|
||||
return {
|
||||
siteConfig: userSiteConfig,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import type { DefaultTheme } from 'valaxy/types'
|
||||
import type { ResolvedValaxyOptions } from '../options'
|
||||
import type { ValaxyNodeConfig } from '../types'
|
||||
import { colors } from 'consola/utils' // updated import
|
||||
import defu from 'defu'
|
||||
import { cyan, dim } from 'picocolors'
|
||||
import { logger } from '../logger'
|
||||
import { loadConfigFromFile } from './utils'
|
||||
|
||||
|
@ -22,7 +22,7 @@ export async function resolveUserThemeConfig(options: ResolvedValaxyOptions) {
|
|||
let { config: userThemeConfig, configFile: themeConfigFile } = await resolveThemeConfigFromRoot(options.userRoot)
|
||||
|
||||
if (userThemeConfig && themeConfigFile)
|
||||
logger.info(`Resolve ${cyan('themeConfig')} from ${dim(themeConfigFile)}`)
|
||||
logger.info(`Resolve ${colors.cyan('themeConfig')} from ${colors.dim(themeConfigFile)}`) // updated code
|
||||
|
||||
if (options?.themeRoot) {
|
||||
// todo mount defaultThemeConfig
|
||||
|
|
|
@ -4,8 +4,8 @@ import type { UserValaxyNodeConfig, ValaxyNodeConfig } from '../types'
|
|||
import process from 'node:process'
|
||||
import { isFunction } from '@antfu/utils'
|
||||
import consola from 'consola'
|
||||
import { colors } from 'consola/utils'
|
||||
import { createDefu } from 'defu'
|
||||
import { cyan, dim, yellow } from 'picocolors'
|
||||
import { mergeConfig as mergeViteConfig } from 'vite'
|
||||
import { countPerformanceTime } from '../utils/performance'
|
||||
import { defaultSiteConfig } from './site'
|
||||
|
@ -109,7 +109,7 @@ export async function resolveValaxyConfig(options: ValaxyEntryOptions) {
|
|||
const duration = endCount()
|
||||
|
||||
if (configFile && userValaxyConfig && Object.keys(userValaxyConfig).length !== 0)
|
||||
consola.success(`Resolve ${cyan('userValaxyConfig')} from ${dim(configFile)} ${yellow(duration)}`)
|
||||
consola.success(`Resolve ${colors.cyan('userValaxyConfig')} from ${colors.dim(configFile)} ${colors.yellow(duration)}`)
|
||||
|
||||
const theme = options.theme || userValaxyConfig?.theme || 'yun'
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import type { ValaxyHooks, ValaxyNode } from '../types'
|
|||
import consola from 'consola'
|
||||
import { colors } from 'consola/utils'
|
||||
import ora from 'ora'
|
||||
import { magenta } from 'picocolors'
|
||||
|
||||
export const logger = consola.create({})
|
||||
|
||||
|
@ -18,7 +17,7 @@ export const vLogger = {
|
|||
* log for hook run
|
||||
*/
|
||||
export async function callHookWithLog(hookName: HookKeys<ValaxyHooks>, valaxyApp: ValaxyNode) {
|
||||
const hookNameStr = `${colors.cyan('[HOOK]')} ${magenta(hookName)}`
|
||||
const hookNameStr = `${colors.cyan('[HOOK]')} ${colors.magenta(hookName)}`
|
||||
const s = ora(`${hookNameStr} calling...`).start()
|
||||
await valaxyApp.hooks.callHook(hookName)
|
||||
s.succeed(`${hookNameStr} done.`)
|
||||
|
|
|
@ -3,11 +3,11 @@ import type { FuseListItem, PostFrontMatter } from 'valaxy/types'
|
|||
import type { Argv } from 'yargs'
|
||||
import path from 'node:path'
|
||||
import consola from 'consola'
|
||||
import { colors } from 'consola/utils'
|
||||
import fg from 'fast-glob'
|
||||
import fs from 'fs-extra'
|
||||
import matter from 'gray-matter'
|
||||
|
||||
import { cyan, dim } from 'picocolors'
|
||||
import matter from 'gray-matter'
|
||||
import { defineValaxyModule } from '.'
|
||||
import { commonOptions } from '../cli/options'
|
||||
import { resolveOptions } from '../options'
|
||||
|
@ -19,7 +19,7 @@ import { setEnvProd } from '../utils/env'
|
|||
* @param options
|
||||
*/
|
||||
export async function generateFuseList(options: ResolvedValaxyOptions) {
|
||||
consola.start(`Generate List for Fuse Search by (${cyan('fuse.js')}) ...`)
|
||||
consola.start(`Generate List for Fuse Search by (${colors.cyan('fuse.js')}) ...`)
|
||||
// generate
|
||||
const files = await fg(`${options.userRoot}/pages/posts/**/*.md`)
|
||||
|
||||
|
@ -30,7 +30,7 @@ export async function generateFuseList(options: ResolvedValaxyOptions) {
|
|||
const fmData = data as PostFrontMatter
|
||||
|
||||
if (fmData.draft) {
|
||||
consola.warn(`Ignore draft post: ${dim(i)}`)
|
||||
consola.warn(`Ignore draft post: ${colors.dim(i)}`)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -83,14 +83,14 @@ export async function execFuse(options: ResolvedValaxyOptions) {
|
|||
|
||||
await fs.ensureFile(publicFuseFile)
|
||||
fs.writeJSONSync(publicFuseFile, fuseList)
|
||||
consola.success(`Generate fuse list in ${dim(publicFolder)}`)
|
||||
consola.success(`Generate fuse list in ${colors.dim(publicFolder)}`)
|
||||
|
||||
// copy to dist
|
||||
const distFolder = path.resolve(options.userRoot, 'dist')
|
||||
const distFuseFile = path.resolve(distFolder, options.config.siteConfig.fuse.dataPath)
|
||||
await fs.ensureDir(distFolder)
|
||||
fs.writeJSONSync(distFuseFile, fuseList)
|
||||
consola.success(`Generate fuse list in ${dim(distFolder)}`)
|
||||
consola.success(`Generate fuse list in ${colors.dim(distFolder)}`)
|
||||
|
||||
try {
|
||||
const gitignorePath = path.resolve(options.userRoot, '.gitignore')
|
||||
|
@ -98,7 +98,7 @@ export async function execFuse(options: ResolvedValaxyOptions) {
|
|||
const ignorePath = publicRelativeFile.replace(/\\/g, '/')
|
||||
if (!gitignore.includes(ignorePath)) {
|
||||
await fs.appendFile(gitignorePath, `\n# valaxy fuse\n${ignorePath}\n`)
|
||||
consola.success(`Add ${dim(ignorePath)} to ${dim('.gitignore')}`)
|
||||
consola.success(`Add ${colors.dim(ignorePath)} to ${colors.dim('.gitignore')}`)
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
|
|
@ -5,12 +5,12 @@ import { dirname } from 'node:path'
|
|||
import process from 'node:process'
|
||||
import { ensureSuffix, uniq } from '@antfu/utils'
|
||||
import consola from 'consola'
|
||||
// import defu from 'defu'
|
||||
import { colors } from 'consola/utils'
|
||||
import _debug from 'debug'
|
||||
import fg from 'fast-glob'
|
||||
import fs from 'fs-extra'
|
||||
import { resolve } from 'pathe'
|
||||
// import defu from 'defu'
|
||||
import { blue, cyan, magenta, yellow } from 'picocolors'
|
||||
import { getRollupOptions } from './build/bundle'
|
||||
import {
|
||||
defaultValaxyConfig,
|
||||
|
@ -189,7 +189,7 @@ export async function resolveOptions(
|
|||
const clientRoot = resolve(pkgRoot, 'client')
|
||||
const userRoot = resolve(options.userRoot || process.cwd())
|
||||
|
||||
consola.start(`Resolve ${magenta('valaxy')} config ...`)
|
||||
consola.start(`Resolve ${colors.magenta('valaxy')} config ...`)
|
||||
const [resolvedValaxy, resolvedSite, resolvedTheme, pages] = await Promise.all([
|
||||
resolveValaxyConfig(options),
|
||||
resolveSiteConfig(options.userRoot),
|
||||
|
@ -277,6 +277,6 @@ export async function resolveThemeValaxyConfig(options: ResolvedValaxyOptions) {
|
|||
const duration = endCount()
|
||||
|
||||
if (themeValaxyConfig)
|
||||
consola.success(`Resolve ${cyan('valaxy.config.ts')} from ${blue(`theme(${options.theme})`)} ${yellow(duration)}`)
|
||||
consola.success(`Resolve ${colors.cyan('valaxy.config.ts')} from ${colors.blue(`theme(${options.theme})`)} ${colors.yellow(duration)}`)
|
||||
return themeValaxyConfig
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ import {
|
|||
transformerNotationFocus,
|
||||
transformerNotationHighlight,
|
||||
} from '@shikijs/transformers'
|
||||
import { colors } from 'consola/utils'
|
||||
// ref vitepress
|
||||
import { customAlphabet } from 'nanoid'
|
||||
import c from 'picocolors'
|
||||
import {
|
||||
addClassToHast,
|
||||
createHighlighter,
|
||||
|
@ -145,7 +145,7 @@ export async function highlight(
|
|||
|
||||
if (!loadLanguage(lang)) {
|
||||
logger.warn(
|
||||
c.yellow(
|
||||
colors.yellow(
|
||||
`\nThe language '${lang}' is not loaded, falling back to '${defaultLang}' for syntax highlighting.`,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import consola from 'consola'
|
||||
import { cyan, red, yellow } from 'picocolors'
|
||||
import { colors } from 'consola/utils'
|
||||
|
||||
/**
|
||||
* replace hexo tag, conflict with markdown-it-attrs
|
||||
|
@ -7,7 +7,7 @@ import { cyan, red, yellow } from 'picocolors'
|
|||
export function transformHexoTags(code: string, id: string) {
|
||||
if (code.includes('{%') && code.includes('%}')) {
|
||||
consola.error(
|
||||
`${`${id}\n`} Please ${red('remove')} ${cyan('{% %}')}, because it conflicts with ${yellow('markdown-it-attrs')}.`,
|
||||
`${`${id}\n`} Please ${colors.red('remove')} ${colors.cyan('{% %}')}, because it conflicts with ${colors.yellow('markdown-it-attrs')}.`,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ import type { PageDataPayload } from '../../../types'
|
|||
import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../../options'
|
||||
import type { ValaxyNodeConfig } from '../../types'
|
||||
import consola from 'consola'
|
||||
import { colors } from 'consola/utils'
|
||||
import fs from 'fs-extra'
|
||||
import { join, relative, resolve } from 'pathe'
|
||||
import { dim, yellow } from 'picocolors'
|
||||
import { defaultSiteConfig, mergeValaxyConfig, resolveSiteConfig, resolveUserThemeConfig } from '../../config'
|
||||
import { replaceArrMerge } from '../../config/merge'
|
||||
import { vLogger } from '../../logger'
|
||||
|
@ -225,7 +225,7 @@ export async function createValaxyLoader(options: ResolvedValaxyOptions, serverO
|
|||
data: payload,
|
||||
})
|
||||
|
||||
vLogger.success(`${yellow('[HMR]')} ${file} ${dim(`updated in ${endCount()}`)}`)
|
||||
vLogger.success(`${colors.yellow('[HMR]')} ${file} ${colors.dim(`updated in ${endCount()}`)}`)
|
||||
ctx.read = () => code
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import type { ValaxyAddonResolver, ValaxyAddons } from '../types'
|
||||
import process from 'node:process'
|
||||
import { colors } from 'consola/utils'
|
||||
import defu from 'defu'
|
||||
import fs from 'fs-extra'
|
||||
import ora from 'ora'
|
||||
import { resolve } from 'pathe'
|
||||
import { blue, cyan, dim, yellow } from 'picocolors'
|
||||
import { logger } from '../logger'
|
||||
import { getModuleRoot } from './root'
|
||||
|
||||
|
@ -13,7 +13,7 @@ export interface ReadAddonModuleOptions {
|
|||
}
|
||||
|
||||
export async function parseAddons(addons: ValaxyAddons, userRoot = process.cwd()) {
|
||||
const spinner = ora(`Resolve ${cyan('addons')} from ${dim(userRoot)}`).start()
|
||||
const spinner = ora(`Resolve ${colors.cyan('addons')} from ${colors.dim(userRoot)}`).start()
|
||||
|
||||
const resolvers: Record<string, ValaxyAddonResolver> = {}
|
||||
const mergeResolver = (resolver?: ValaxyAddonResolver) => {
|
||||
|
@ -35,7 +35,7 @@ export async function parseAddons(addons: ValaxyAddons, userRoot = process.cwd()
|
|||
const resolvedAddons = Object.values(resolvers).filter(item => item.enable)
|
||||
resolvedAddons.forEach((addon, i) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(` ${i === resolvedAddons.length - 1 ? '└─' : '├─'} ${yellow(addon.name)} ${blue(`v${addon.pkg?.version}`)}${addon.global ? cyan(' (global)') : ''} ${dim(addon.pkg.homepage || addon.pkg.repository?.url || addon.pkg.repository || '')}`)
|
||||
console.log(` ${i === resolvedAddons.length - 1 ? '└─' : '├─'} ${colors.yellow(addon.name)} ${colors.blue(`v${addon.pkg?.version}`)}${addon.global ? colors.cyan(' (global)') : ''} ${colors.dim(addon.pkg.homepage || addon.pkg.repository?.url || addon.pkg.repository || '')}`)
|
||||
})
|
||||
return resolvedAddons
|
||||
}
|
||||
|
|
|
@ -67,9 +67,9 @@
|
|||
"@intlify/unplugin-vue-i18n": "^6.0.3",
|
||||
"@shikijs/transformers": "^3.1.0",
|
||||
"@types/katex": "^0.16.7",
|
||||
"@unhead/addons": "^1.11.20",
|
||||
"@unhead/schema-org": "^1.11.20",
|
||||
"@unhead/vue": "^1.11.20",
|
||||
"@unhead/addons": "^2.0.0-rc.9",
|
||||
"@unhead/schema-org": "^2.0.0-rc.9",
|
||||
"@unhead/vue": "^2.0.0-rc.9",
|
||||
"@valaxyjs/devtools": "workspace:*",
|
||||
"@valaxyjs/utils": "workspace:*",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
|
@ -78,7 +78,7 @@
|
|||
"@vueuse/integrations": "12.0.0-beta.1",
|
||||
"beasties": "^0.2.0",
|
||||
"birpc": "^2.2.0",
|
||||
"consola": "^3.4.0",
|
||||
"consola": "catalog:",
|
||||
"cross-spawn": "^7.0.6",
|
||||
"css-i18n": "^0.0.5",
|
||||
"dayjs": "^1.11.13",
|
||||
|
@ -86,6 +86,7 @@
|
|||
"defu": "^6.1.4",
|
||||
"ejs": "^3.1.10",
|
||||
"escape-html": "^1.0.3",
|
||||
"fast-glob": "^3.3.3",
|
||||
"feed": "^4.2.2",
|
||||
"floating-vue": "^5.2.2",
|
||||
"fs-extra": "^11.3.0",
|
||||
|
@ -121,10 +122,11 @@
|
|||
"sass": "^1.85.1",
|
||||
"shiki": "^3.1.0",
|
||||
"star-markdown-css": "^0.5.3",
|
||||
"table": "^6.9.0",
|
||||
"unocss": "^66.0.0",
|
||||
"unplugin-vue-components": "28.0.0",
|
||||
"unplugin-vue-markdown": "^28.3.1",
|
||||
"unplugin-vue-router": "^0.11.2",
|
||||
"unplugin-vue-router": "^0.12.0",
|
||||
"vanilla-lazyload": "^19.1.3",
|
||||
"vite": "catalog:",
|
||||
"vite-dev-rpc": "^1.0.7",
|
||||
|
@ -161,7 +163,6 @@
|
|||
"diacritics": "^1.3.0",
|
||||
"gh-pages": "^6.3.0",
|
||||
"https-localhost": "^4.7.1",
|
||||
"rollup-plugin-visualizer": "^5.14.0",
|
||||
"table": "^6.9.0"
|
||||
"rollup-plugin-visualizer": "^5.14.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { globSync } from 'tinyglobby'
|
|||
import { defineConfig } from 'tsup'
|
||||
import pkg from './package.json'
|
||||
|
||||
export default defineConfig((options) => {
|
||||
export default defineConfig((_options) => {
|
||||
return {
|
||||
entry: [
|
||||
'node/index.ts',
|
||||
|
@ -15,7 +15,7 @@ export default defineConfig((options) => {
|
|||
clean: true,
|
||||
dts: true,
|
||||
format: ['esm'],
|
||||
minify: !options.watch,
|
||||
// minify: !options.watch,
|
||||
external: [
|
||||
'/@valaxyjs/',
|
||||
'/@valaxyjs/config',
|
||||
|
|
2261
pnpm-lock.yaml
2261
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -15,8 +15,9 @@ catalog:
|
|||
'@iconify-json/vscode-icons': ^1.2.16
|
||||
typescript: ^5.8.2
|
||||
unbuild: ^3.5.0
|
||||
vite: ^6.2.0
|
||||
vue-i18n: ^11.1.1
|
||||
zx: ^8.3.2
|
||||
vite: ^6.2.1
|
||||
vue-i18n: ^11.1.2
|
||||
zx: ^8.4.0
|
||||
consola: ^3.4.0
|
||||
onlyBuiltDependencies:
|
||||
- vue-demi
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"picocolors": "^1.1.1",
|
||||
"zx": "catalog:"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,11 @@ import { readFileSync } from 'node:fs'
|
|||
import process from 'node:process'
|
||||
import { versionBump } from 'bumpp'
|
||||
import consola from 'consola'
|
||||
import { colors } from 'consola/utils'
|
||||
import minimist from 'minimist'
|
||||
import pc from 'picocolors'
|
||||
import { $ } from 'zx'
|
||||
import { packages, updateTemplateVersions } from './utils'
|
||||
|
||||
const { cyan, gray, yellow } = pc
|
||||
|
||||
const args = minimist(process.argv.slice(2))
|
||||
export const isDryRun = !!args.dry
|
||||
|
||||
|
@ -32,7 +30,7 @@ async function main() {
|
|||
consola.info('Updating packages version...')
|
||||
pkgPaths.forEach((pkgPath) => {
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
||||
consola.info(`${cyan(pkg.name)} ${gray(`v${pkg.version}`)} -> ${yellow(`v${newVersion}`)}`)
|
||||
consola.info(`${colors.cyan(pkg.name)} ${colors.gray(`v${pkg.version}`)} -> ${colors.yellow(`v${newVersion}`)}`)
|
||||
})
|
||||
|
||||
console.log()
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { readFile, writeFile } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
import consola from 'consola'
|
||||
import pc from 'picocolors'
|
||||
import { colors } from 'consola/utils'
|
||||
|
||||
const { cyan, gray, yellow } = pc
|
||||
const { cyan, gray, yellow } = colors
|
||||
|
||||
export const packages = [
|
||||
// @valaxyjs/devtools
|
||||
|
|
Loading…
Reference in New Issue