chore: maintenance and cleanup

pull/4502/head
Divyansh Singh 8 months ago
parent 42f7ee2f12
commit 36bde803c8

@ -1,4 +1,4 @@
import fs from 'fs'
import fs from 'node:fs'
import { defineLoader } from 'vitepress'
type Data = Record<string, boolean>[]

@ -1,8 +1,8 @@
import getPort from 'get-port'
import type { Server } from 'node:net'
import { chromium, type BrowserServer } from 'playwright-chromium'
import { build, createServer, serve } from 'vitepress'
import type { ViteDevServer } from 'vite'
import type { Server } from 'net'
import { build, createServer, serve } from 'vitepress'
let browserServer: BrowserServer
let server: ViteDevServer | Server

@ -1,9 +1,9 @@
import fs from 'fs-extra'
import getPort from 'get-port'
import { nanoid } from 'nanoid'
import path from 'path'
import path from 'node:path'
import { fileURLToPath, URL } from 'node:url'
import { chromium } from 'playwright-chromium'
import { fileURLToPath, URL } from 'url'
import { createServer, scaffold, ScaffoldThemeType } from 'vitepress'
const tempDir = fileURLToPath(new URL('./.temp', import.meta.url))

@ -1,7 +1,7 @@
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vitest/config'
const dir = dirname(fileURLToPath(import.meta.url))

@ -1,15 +1,15 @@
import { defineConfig } from 'vitepress'
import {
groupIconMdPlugin,
groupIconVitePlugin,
localIconLoader
} from 'vitepress-plugin-group-icons'
import { search as esSearch } from './es'
import { search as faSearch } from './fa'
import { search as koSearch } from './ko'
import { search as ptSearch } from './pt'
import { search as ruSearch } from './ru'
import { search as zhSearch } from './zh'
import {
groupIconMdPlugin,
groupIconVitePlugin,
localIconLoader
} from 'vitepress-plugin-group-icons'
export const shared = defineConfig({
title: 'VitePress',

@ -15,6 +15,6 @@
"open-cli": "^8.0.0",
"postcss-rtlcss": "^5.6.0",
"vitepress": "workspace:*",
"vitepress-plugin-group-icons": "^1.3.2"
"vitepress-plugin-group-icons": "^1.3.4"
}
}

@ -1,34 +0,0 @@
/**
* vue-demi v0.14.7
* Copyright (c) 2020-present, Anthony Fu
* @license MIT
*/
import * as Vue from 'vue'
var isVue2 = false
var isVue3 = true
var Vue2 = undefined
function install() {}
export function set(target, key, val) {
if (Array.isArray(target)) {
target.length = Math.max(target.length, key)
target.splice(key, 1, val)
return val
}
target[key] = val
return val
}
export function del(target, key) {
if (Array.isArray(target)) {
target.splice(key, 1)
return
}
delete target[key]
}
export * from 'vue'
export { Vue, Vue2, isVue2, isVue3, install }

@ -33,9 +33,6 @@
"./theme-without-fonts": {
"types": "./theme-without-fonts.d.ts",
"default": "./dist/client/theme-default/without-fonts.js"
},
"./vue-demi": {
"default": "./lib/vue-demi.mjs"
}
},
"main": "dist/node/index.js",
@ -100,25 +97,25 @@
"dependencies": {
"@docsearch/css": "^3.8.2",
"@docsearch/js": "^3.8.2",
"@iconify-json/simple-icons": "^1.2.18",
"@shikijs/core": "^1.26.1",
"@shikijs/transformers": "^1.26.1",
"@shikijs/types": "^1.26.1",
"@iconify-json/simple-icons": "^1.2.20",
"@shikijs/core": "^1.27.2",
"@shikijs/transformers": "^1.27.2",
"@shikijs/types": "^1.27.2",
"@types/markdown-it": "^14.1.2",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/devtools-api": "^7.6.8",
"@vue/devtools-api": "^7.7.0",
"@vue/shared": "^3.5.13",
"@vueuse/core": "^12.3.0",
"@vueuse/integrations": "^12.3.0",
"focus-trap": "^7.6.2",
"@vueuse/core": "^12.4.0",
"@vueuse/integrations": "^12.4.0",
"focus-trap": "^7.6.4",
"mark.js": "8.11.1",
"minisearch": "^7.1.1",
"shiki": "^1.26.1",
"shiki": "^1.27.2",
"vite": "^5.4.11",
"vue": "^3.5.13"
},
"devDependencies": {
"@clack/prompts": "^0.9.0",
"@clack/prompts": "^0.9.1",
"@iconify/utils": "^2.2.1",
"@mdit-vue/plugin-component": "^2.1.3",
"@mdit-vue/plugin-frontmatter": "^2.1.3",
@ -143,7 +140,7 @@
"@types/markdown-it-emoji": "^3.0.1",
"@types/micromatch": "^4.0.9",
"@types/minimist": "^1.2.5",
"@types/node": "^22.10.5",
"@types/node": "^22.10.7",
"@types/postcss-prefix-selector": "^1.16.3",
"@types/prompts": "^2.4.9",
"chokidar": "^4.0.3",
@ -152,10 +149,10 @@
"debug": "^4.4.0",
"esbuild": "^0.24.2",
"execa": "^9.5.2",
"fs-extra": "^11.2.0",
"fs-extra": "^11.3.0",
"get-port": "^7.1.0",
"gray-matter": "^4.0.3",
"lint-staged": "^15.3.0",
"lint-staged": "^15.4.0",
"lodash.template": "^4.5.0",
"lru-cache": "^11.0.2",
"markdown-it": "^14.1.0",
@ -179,7 +176,7 @@
"prompts": "^2.4.2",
"punycode": "^2.3.1",
"rimraf": "^6.0.1",
"rollup": "^4.30.0",
"rollup": "^4.30.1",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
"semver": "^7.6.3",
@ -188,10 +185,10 @@
"sitemap": "^8.0.0",
"synckit": "^0.9.2",
"tinyglobby": "^0.2.10",
"typescript": "^5.7.2",
"vitest": "^2.1.8",
"typescript": "^5.7.3",
"vitest": "^3.0.0",
"vue-tsc": "^2.2.0",
"wait-on": "^8.0.1"
"wait-on": "^8.0.2"
},
"peerDependencies": {
"markdown-it-mathjax3": "^4",
@ -205,7 +202,7 @@
"optional": true
}
},
"packageManager": "pnpm@9.15.3",
"packageManager": "pnpm@9.15.4",
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [

File diff suppressed because it is too large Load Diff

@ -1,10 +1,10 @@
import * as fs from 'node:fs/promises'
import { builtinModules, createRequire } from 'node:module'
import alias from '@rollup/plugin-alias'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import * as fs from 'node:fs/promises'
import { builtinModules, createRequire } from 'node:module'
import { type RollupOptions, defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'

@ -1,7 +1,7 @@
import { readFileSync, writeFileSync } from 'fs'
import { resolve } from 'path'
import { fileURLToPath } from 'url'
import { createRequire } from 'module'
import { readFileSync, writeFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { createRequire } from 'node:module'
import c from 'picocolors'
import prompts from 'prompts'
import { execa } from 'execa'

@ -1,4 +1,4 @@
import { defineComponent, ref, onMounted } from 'vue'
import { defineComponent, onMounted, ref } from 'vue'
export const ClientOnly = defineComponent({
setup(_, { slots }) {

@ -1,5 +1,5 @@
import { defineComponent, h, watch } from 'vue'
import { useData, useRoute } from 'vitepress'
import { defineComponent, h, watch } from 'vue'
import { contentUpdatedCallbacks } from '../utils'
const runCbs = () => contentUpdatedCallbacks.forEach((fn) => fn())

@ -1,9 +1,9 @@
import { watchEffect, type Ref } from 'vue'
import {
type HeadConfig,
type SiteData,
createTitle,
mergeHead
mergeHead,
type HeadConfig,
type SiteData
} from '../../shared'
import type { Route } from '../router'

@ -1,8 +1,8 @@
// Customized pre-fetch for page chunks based on
// https://github.com/GoogleChromeLabs/quicklink
import { useRoute } from '../router'
import { onMounted, onUnmounted, watch } from 'vue'
import { useRoute } from '../router'
import { inBrowser, pathToFile } from '../utils'
const hasFetched = new Set<string>()

@ -1,7 +1,7 @@
import { setupDevToolsPlugin } from '@vue/devtools-api'
import type { App } from 'vue'
import type { Router } from './router'
import type { VitePressData } from './data'
import type { Router } from './router'
const COMPONENT_STATE_TYPE = 'VitePress'

@ -1,7 +1,7 @@
// entry for SSR
import { createApp } from './index'
import { renderToString } from 'vue/server-renderer'
import type { SSGContext } from '../shared'
import { createApp } from './index'
export async function render(path: string) {
const { app, router } = await createApp()

@ -1,6 +1,6 @@
import type { App, Ref, Component } from 'vue'
import type { Router } from './router'
import type { App, Component, Ref } from 'vue'
import type { Awaitable, SiteData } from '../shared'
import type { Router } from './router'
export interface EnhanceAppContext {
app: App

@ -1,10 +1,3 @@
import { siteDataRef } from './data'
import {
inBrowser,
EXTERNAL_URL_RE,
sanitizeFileName,
type Awaitable
} from '../shared'
import {
h,
onMounted,
@ -12,8 +5,15 @@ import {
shallowRef,
type AsyncComponentLoader
} from 'vue'
import {
EXTERNAL_URL_RE,
inBrowser,
sanitizeFileName,
type Awaitable
} from '../shared'
import { siteDataRef } from './data'
export { inBrowser, escapeHtml as _escapeHtml } from '../shared'
export { escapeHtml as _escapeHtml, inBrowser } from '../shared'
/**
* Join two paths by resolving the slash collision.

@ -12,17 +12,17 @@ export type { EnhanceAppContext, Theme } from './app/theme'
export type { HeadConfig, Header, PageData, SiteData } from '../../types/shared'
// composables
export { useData, dataSymbol } from './app/data'
export { dataSymbol, useData } from './app/data'
export { useRoute, useRouter } from './app/router'
// utilities
export {
inBrowser,
onContentUpdated,
_escapeHtml,
defineClientComponent,
withBase,
getScrollOffset,
_escapeHtml
inBrowser,
onContentUpdated,
withBase
} from './app/utils'
// components

@ -1,4 +1,4 @@
import { type Ref, ref, watch, readonly, onUnmounted } from 'vue'
import { onUnmounted, readonly, type Ref, ref, watch } from 'vue'
import { inBrowser } from '../../shared'
interface UseFlyoutOptions {

@ -1,5 +1,5 @@
import { ref, watch } from 'vue'
import { useRoute } from 'vitepress'
import { ref, watch } from 'vue'
export function useNav() {
const isScreenOpen = ref(false)

@ -1,7 +1,7 @@
import { computed } from 'vue'
import { useData } from './data'
import { isActive } from '../../shared'
import { getSidebar, getFlatSideBarLinks } from '../support/sidebar'
import { getFlatSideBarLinks, getSidebar } from '../support/sidebar'
import { useData } from './data'
export function usePrevNext() {
const { page, theme, frontmatter } = useData()

@ -1,6 +1,6 @@
import type { DefaultTheme } from 'vitepress/theme'
import { ensureStartingSlash } from './utils'
import { isActive } from '../../shared'
import { ensureStartingSlash } from './utils'
export interface SidebarLink {
text: string

@ -1,6 +1,6 @@
import { withBase } from 'vitepress'
import { useData } from '../composables/data'
import { isExternal, treatAsHtml } from '../../shared'
import { useData } from '../composables/data'
export function throttleAndDebounce(fn: () => void, delay: number): () => void {
let timeoutId: NodeJS.Timeout
@ -17,7 +17,7 @@ export function throttleAndDebounce(fn: () => void, delay: number): () => void {
}
export function ensureStartingSlash(path: string): string {
return /^\//.test(path) ? path : `/${path}`
return path.startsWith('/') ? path : `/${path}`
}
export function normalizeLink(url: string): string {

@ -31,8 +31,8 @@ export { default as VPTeamPage } from './components/VPTeamPage.vue'
export { default as VPTeamPageSection } from './components/VPTeamPageSection.vue'
export { default as VPTeamPageTitle } from './components/VPTeamPageTitle.vue'
export { useSidebar } from './composables/sidebar'
export { useLocalNav } from './composables/local-nav'
export { useSidebar } from './composables/sidebar'
const theme: Theme = {
Layout,

@ -1,6 +1,6 @@
import { createRequire } from 'module'
import { resolve, join } from 'path'
import { fileURLToPath } from 'url'
import { createRequire } from 'node:module'
import { join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { Alias, AliasOptions } from 'vite'
import type { SiteConfig } from './config'
@ -41,10 +41,6 @@ export function resolveAliases(
{
find: /^vitepress\/theme$/,
replacement: join(DIST_CLIENT_PATH, '/theme-default/index.js')
},
{
find: /^vue-demi$/,
replacement: require.resolve('vitepress/vue-demi')
}
]

@ -1,6 +1,6 @@
import fs from 'fs-extra'
import path from 'path'
import { fileURLToPath } from 'url'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import {
build,
normalizePath,
@ -30,7 +30,6 @@ const excludedModules = [
'node_modules/@vueuse/core/',
'node_modules/@vueuse/shared/',
'node_modules/vue/',
'node_modules/vue-demi/',
clientDir
]

@ -1,6 +1,6 @@
import fs from 'fs-extra'
import matter from 'gray-matter'
import path from 'path'
import path from 'node:path'
import {
SitemapStream,
type EnumChangefreq,

@ -1,7 +1,7 @@
import { isBooleanAttr } from '@vue/shared'
import fs from 'fs-extra'
import path from 'path'
import { pathToFileURL } from 'url'
import path from 'node:path'
import { pathToFileURL } from 'node:url'
import { normalizePath, transformWithEsbuild, type Rollup } from 'vite'
import { version } from '../../../package.json'
import type { SiteConfig } from '../config'

@ -1,6 +1,6 @@
import _debug from 'debug'
import fs from 'fs-extra'
import path from 'path'
import path from 'node:path'
import c from 'picocolors'
import {
createLogger,

@ -1,9 +1,9 @@
import fs from 'fs-extra'
import path from 'path'
import { glob, type GlobOptions } from 'tinyglobby'
import type { SiteConfig } from './config'
import matter from 'gray-matter'
import path from 'node:path'
import { glob, type GlobOptions } from 'tinyglobby'
import { normalizePath } from 'vite'
import type { SiteConfig } from './config'
import { createMarkdownRenderer } from './markdown/markdown'
export interface ContentOptions<T = ContentData[]> {

@ -1,17 +1,17 @@
import {
cancel,
confirm,
group,
intro,
outro,
group,
text,
select,
cancel,
confirm
text
} from '@clack/prompts'
import fs from 'fs-extra'
import path from 'path'
import { cyan, bold, yellow } from 'picocolors'
import { fileURLToPath } from 'url'
import template from 'lodash.template'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { bold, cyan, yellow } from 'picocolors'
export enum ScaffoldThemeType {
Default = 'default theme',

@ -14,17 +14,17 @@ import { sfcPlugin, type SfcPluginOptions } from '@mdit-vue/plugin-sfc'
import { titlePlugin } from '@mdit-vue/plugin-title'
import { tocPlugin, type TocPluginOptions } from '@mdit-vue/plugin-toc'
import { slugify } from '@mdit-vue/shared'
import type {
LanguageInput,
ShikiTransformer,
ThemeRegistrationAny
} from '@shikijs/types'
import type { Options } from 'markdown-it'
import MarkdownIt from 'markdown-it'
import anchorPlugin from 'markdown-it-anchor'
import attrsPlugin from 'markdown-it-attrs'
import { full as emojiPlugin } from 'markdown-it-emoji'
import type { BuiltinTheme, Highlighter } from 'shiki'
import type {
LanguageInput,
ShikiTransformer,
ThemeRegistrationAny
} from '@shikijs/types'
import type { Logger } from 'vite'
import { containerPlugin, type ContainerOptions } from './plugins/containers'
import { gitHubAlertsPlugin } from './plugins/githubAlerts'

@ -2,7 +2,7 @@ import type MarkdownIt from 'markdown-it'
import type { ContainerOptions } from './containers'
const markerRE =
/^\[\!(TIP|NOTE|INFO|IMPORTANT|WARNING|CAUTION|DANGER)\]([^\n\r]*)/i
/^\[!(TIP|NOTE|INFO|IMPORTANT|WARNING|CAUTION|DANGER)\]([^\n\r]*)/i
export const gitHubAlertsPlugin = (
md: MarkdownIt,

@ -3,7 +3,7 @@
// 2. normalize internal links to end with `.html`
import type MarkdownIt from 'markdown-it'
import { URL } from 'url'
import { URL } from 'node:url'
import {
EXTERNAL_URL_RE,
isExternal,
@ -92,7 +92,7 @@ export const linkPlugin = (
}
// ensure leading . for relative paths
if (!url.startsWith('/') && !/^\.\//.test(url)) {
if (!url.startsWith('/') && !url.startsWith('./')) {
url = './' + url
}

@ -1,7 +1,7 @@
import fs from 'fs-extra'
import type MarkdownIt from 'markdown-it'
import type { RuleBlock } from 'markdown-it/lib/parser_block.mjs'
import path from 'path'
import path from 'node:path'
import type { MarkdownEnv } from '../../shared'
/**

@ -2,7 +2,7 @@ import { resolveTitleFromToken } from '@mdit-vue/shared'
import _debug from 'debug'
import fs from 'fs-extra'
import { LRUCache } from 'lru-cache'
import path from 'path'
import path from 'node:path'
import type { SiteConfig } from './config'
import {
createMarkdownRenderer,

@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'
import c from 'picocolors'
import {
mergeConfig,

@ -1,3 +1,7 @@
import fs from 'fs-extra'
import path from 'node:path'
import c from 'picocolors'
import { glob } from 'tinyglobby'
import {
loadConfigFromFile,
normalizePath,
@ -5,10 +9,6 @@ import {
type Plugin,
type ViteDevServer
} from 'vite'
import fs from 'fs-extra'
import c from 'picocolors'
import path from 'path'
import { glob } from 'tinyglobby'
import { type SiteConfig, type UserConfig } from '../siteConfig'
import { resolveRewrites } from './rewritesPlugin'
@ -148,7 +148,7 @@ export const dynamicRoutesPlugin = async (
const mods = config.dynamicRoutes.fileToModulesMap[ctx.file]
if (mods) {
// path loader module or deps updated, reset loaded routes
if (!/\.md$/.test(ctx.file)) {
if (!ctx.file.endsWith('.md')) {
Object.assign(
config,
await resolvePages(config.srcDir, config.userConfig, config.logger)

@ -1,8 +1,8 @@
import _debug from 'debug'
import fs from 'fs-extra'
import MiniSearch from 'minisearch'
import path from 'node:path'
import pMap from 'p-map'
import path from 'path'
import type { Plugin, ViteDevServer } from 'vite'
import type { SiteConfig } from '../config'
import { createMarkdownRenderer } from '../markdown/markdown'

@ -1,5 +1,5 @@
import type { Plugin } from 'vite'
import { compile, match } from 'path-to-regexp'
import type { Plugin } from 'vite'
import type { SiteConfig, UserConfig } from '../siteConfig'
export function resolveRewrites(

@ -1,12 +1,12 @@
import { isMatch } from 'micromatch'
import path, { dirname, resolve } from 'node:path'
import { glob } from 'tinyglobby'
import {
type Plugin,
type ViteDevServer,
loadConfigFromFile,
normalizePath
} from 'vite'
import path, { dirname, resolve } from 'path'
import { isMatch } from 'micromatch'
import { glob } from 'tinyglobby'
const loaderMatch = /\.data\.m?(j|t)s($|\?)/

@ -1,6 +1,6 @@
import compression from '@polka/compression'
import fs from 'fs-extra'
import path from 'path'
import path from 'node:path'
import polka, { type IOptions } from 'polka'
import sirv from 'sirv'
import { resolveConfig } from '../config'

@ -1,7 +1,7 @@
import type { ViteDevServer } from 'vite'
import c from 'picocolors'
import { clearCache } from './markdownToVue'
import type { ViteDevServer } from 'vite'
import { disposeMdItInstance } from './markdown/markdown'
import { clearCache } from './markdownToVue'
type CreateDevServer = () => Promise<void>

@ -1,6 +1,6 @@
import { spawn } from 'cross-spawn'
import fs from 'fs-extra'
import { basename, dirname } from 'path'
import { basename, dirname } from 'node:path'
const cache = new Map<string, number>()

@ -1,6 +1,6 @@
import fs from 'fs-extra'
import matter from 'gray-matter'
import path from 'path'
import path from 'node:path'
import c from 'picocolors'
import { findRegion } from '../markdown/plugins/snippet'
import { slash } from '../shared'

@ -10,8 +10,8 @@ export type {
MarkdownEnv,
PageData,
PageDataPayload,
SSGContext,
SiteData
SiteData,
SSGContext
} from '../../types/shared'
export const EXTERNAL_URL_RE = /^(?:[a-z]+:|\/\/)/i

2
types/index.d.ts vendored

@ -1,3 +1,3 @@
export * from './shared.js'
export * from '../dist/client/index.js'
export * from '../dist/node/index.js'
export * from './shared.js'

Loading…
Cancel
Save