create-search-indexを多少改善
This commit is contained in:
parent
8bed0ad423
commit
89cc6a0908
|
@ -45,7 +45,7 @@ export type SearchIndexItem = {
|
||||||
label: string;
|
label: string;
|
||||||
keywords: string | string[];
|
keywords: string | string[];
|
||||||
icon?: string;
|
icon?: string;
|
||||||
children?: (SearchIndexItem[] | string);
|
children?: SearchIndexItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 関連するノードタイプの定数化
|
// 関連するノードタイプの定数化
|
||||||
|
@ -749,13 +749,19 @@ function extractUsageInfoFromTemplateAst(
|
||||||
if (!templateAst) return allMarkers;
|
if (!templateAst) return allMarkers;
|
||||||
|
|
||||||
// マーカーの基本情報を収集
|
// マーカーの基本情報を収集
|
||||||
function collectMarkers(node: any, parentId: string | null = null) {
|
function collectMarkers(node: VueAstNode, parentId: string | null = null) {
|
||||||
if (node.type === 1 && node.tag === 'SearchMarker') {
|
if (node.type === 1 && node.tag === 'SearchMarker') {
|
||||||
// マーカーID取得
|
// マーカーID取得
|
||||||
const markerIdProp = node.props?.find((p: any) => p.name === 'markerId');
|
const markerIdProp = node.props?.find((p: any) => p.name === 'markerId');
|
||||||
const markerId = markerIdProp?.value?.content ||
|
const markerId = markerIdProp?.value?.content ||
|
||||||
node.__markerId;
|
node.__markerId;
|
||||||
|
|
||||||
|
// SearchMarkerにマーカーIDがない場合はエラー
|
||||||
|
if (markerId == null) {
|
||||||
|
logger.error(`Marker ID not found for node: ${JSON.stringify(node)}`);
|
||||||
|
throw new Error(`Marker ID not found in file ${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
// マーカー基本情報
|
// マーカー基本情報
|
||||||
const markerInfo: SearchIndexItem = {
|
const markerInfo: SearchIndexItem = {
|
||||||
id: markerId,
|
id: markerId,
|
||||||
|
@ -833,29 +839,22 @@ function extractUsageInfoFromTemplateAst(
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
const parent = markerMap.get(parentId);
|
const parent = markerMap.get(parentId);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
if (!parent.children) parent.children = [];
|
|
||||||
if (Array.isArray(parent.children)) {
|
|
||||||
parent.children.push(markerId);
|
|
||||||
} else {
|
|
||||||
parent.children = [markerId];
|
|
||||||
}
|
|
||||||
childrenIds.add(markerId);
|
childrenIds.add(markerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 子ノードを処理
|
// 子ノードを処理
|
||||||
if (node.children && Array.isArray(node.children)) {
|
if (node.children && Array.isArray(node.children)) {
|
||||||
node.children.forEach((child: any) => {
|
node.children.forEach((child: VueAstNode) => {
|
||||||
collectMarkers(child, markerId);
|
collectMarkers(child, markerId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return markerId;
|
return markerId;
|
||||||
}
|
}
|
||||||
|
// SearchMarkerでない場合は再帰的に子ノードを処理
|
||||||
// 子ノードを処理
|
else if (node.children && Array.isArray(node.children)) {
|
||||||
if (node.children && Array.isArray(node.children)) {
|
node.children.forEach((child: VueAstNode) => {
|
||||||
node.children.forEach((child: any) => {
|
|
||||||
collectMarkers(child, parentId);
|
collectMarkers(child, parentId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -869,7 +868,7 @@ function extractUsageInfoFromTemplateAst(
|
||||||
}
|
}
|
||||||
|
|
||||||
// バインドプロパティの処理を修正する関数
|
// バインドプロパティの処理を修正する関数
|
||||||
function extractNodeBindings(node: any): Record<string, any> {
|
function extractNodeBindings(node: VueAstNode): Record<keyof SearchIndexItem, any> {
|
||||||
const bindings: Record<string, any> = {};
|
const bindings: Record<string, any> = {};
|
||||||
|
|
||||||
if (!node.props || !Array.isArray(node.props)) return bindings;
|
if (!node.props || !Array.isArray(node.props)) return bindings;
|
||||||
|
@ -1048,7 +1047,7 @@ export async function analyzeVueProps(options: {
|
||||||
filename: filePath,
|
filename: filePath,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (errors.length) {
|
if (errors.length > 0) {
|
||||||
logger.error(`Compile Error: ${filePath}, ${errors}`);
|
logger.error(`Compile Error: ${filePath}, ${errors}`);
|
||||||
continue; // エラーが発生したファイルはスキップ
|
continue; // エラーが発生したファイルはスキップ
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue