From 6c4f9cd375c9fe99268f73a31cd9fac5848691e9 Mon Sep 17 00:00:00 2001 From: hyperz111 Date: Sat, 2 Aug 2025 15:15:16 +0700 Subject: [PATCH 1/8] feat(init): validation to make sure config directory is inside cwd --- src/node/init/init.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/node/init/init.ts b/src/node/init/init.ts index 711205416fe6..7bb8aa83ed3b 100644 --- a/src/node/init/init.ts +++ b/src/node/init/init.ts @@ -10,6 +10,7 @@ import { import fs from 'fs-extra' import template from 'lodash.template' import path from 'node:path' +import process from 'node:process' import { fileURLToPath } from 'node:url' import c from 'picocolors' import { slash } from '../shared' @@ -49,9 +50,24 @@ export async function init(root?: string) { message: 'Where should VitePress initialize the config?', initialValue: './', defaultValue: './', - validate() { - // TODO make sure directory is inside - return undefined + validate(value) { + const cwd = slash(process.cwd()) + const dir = slash(value as string) + + const cwdRE = new RegExp( + `^${dir.endsWith('/') ? `${cwd}/` : cwd}`, + 'u' + ) + // If give absolute path, use that path instead + const absolutePath = + (process.platform === 'win32' && /^[A-Z]:/i.test(dir)) || + /^\//.test(dir) + ? dir + : path.join(cwd, dir) + + return !cwdRE.test(absolutePath) + ? 'Please init your config inside this directory.' + : undefined } }) }, From dc323925aa896a1b6f4b85a18a1600ecf9a54d87 Mon Sep 17 00:00:00 2001 From: Artea Date: Sun, 3 Aug 2025 21:54:05 +0800 Subject: [PATCH 2/8] chore(devtool): remove `as any` (#4881) --- src/client/app/devtools.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/client/app/devtools.ts b/src/client/app/devtools.ts index 54998fb13b29..cbc0fd3b3a5b 100644 --- a/src/client/app/devtools.ts +++ b/src/client/app/devtools.ts @@ -21,8 +21,7 @@ export const setupDevtools = ( componentStateTypes: [COMPONENT_STATE_TYPE] }, (api) => { - // TODO: remove any - api.on.inspectComponent((payload: any) => { + api.on.inspectComponent((payload) => { payload.instanceData.state.push({ type: COMPONENT_STATE_TYPE, key: 'route', From 4d89e139f3d6b8ada67fe6e079e8bd07756d7ffb Mon Sep 17 00:00:00 2001 From: Artea Date: Sun, 3 Aug 2025 23:59:47 +0800 Subject: [PATCH 3/8] refactor: `VPMenu` related component use generic type for component (#4883) --- src/client/theme-default/components/VPFlyout.vue | 5 +++-- src/client/theme-default/components/VPMenu.vue | 5 +++-- src/client/theme-default/components/VPMenuGroup.vue | 7 ++++--- src/client/theme-default/components/VPMenuLink.vue | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/client/theme-default/components/VPFlyout.vue b/src/client/theme-default/components/VPFlyout.vue index 7ce5616220b7..c05c579cfe23 100644 --- a/src/client/theme-default/components/VPFlyout.vue +++ b/src/client/theme-default/components/VPFlyout.vue @@ -1,4 +1,5 @@ - diff --git a/src/client/theme-default/components/VPMenuGroup.vue b/src/client/theme-default/components/VPMenuGroup.vue index 11f867149a72..7d12eb7570e6 100644 --- a/src/client/theme-default/components/VPMenuGroup.vue +++ b/src/client/theme-default/components/VPMenuGroup.vue @@ -1,9 +1,10 @@ - @@ -11,7 +12,7 @@ defineProps<{

{{ text }}

-