Skip to content

Commit a215640

Browse files
committed
chore: use remove old generation
1 parent fbb5cf1 commit a215640

File tree

6 files changed

+1
-1133
lines changed

6 files changed

+1
-1133
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"build": "pnpm build-pre && pnpm -r build && pnpm build-assets",
2525
"build-storybook": "pnpm --filter frontend build-storybook",
2626
"build-misskey-js-with-types": "pnpm build-pre && pnpm --filter backend... --filter=!misskey-js build && pnpm --filter backend generate-api-json --no-build && ncp packages/backend/built/api.json packages/misskey-js/generator/api.json && pnpm --filter misskey-js update-autogen-code && pnpm --filter misskey-js build && pnpm --filter misskey-js api",
27-
"build-frontend-search-index": "pnpm --filter frontend build-search-index",
2827
"start": "pnpm check:connect && cd packages/backend && node ./built/boot/entry.js",
2928
"start:test": "ncp ./.github/misskey/test.yml ./.config/test.yml && cd packages/backend && cross-env NODE_ENV=test node ./built/boot/entry.js",
3029
"init": "pnpm migrate",

packages/frontend/lib/vite-plugin-create-search-index.ts

+1-121
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export type SearchIndexItem = {
5252

5353
export type Options = {
5454
targetFilePaths: string[],
55-
exportFilePath: string,
5655
mainVirtualModule: string,
5756
modulesToHmrOnUpdate: string[],
5857
fileVirtualModulePrefix?: string,
@@ -352,49 +351,6 @@ function countMarkers(markers: SearchIndexItem[]): { totalMarkers: number, total
352351
return { totalMarkers, totalChildren };
353352
}
354353

355-
/**
356-
* 最終的なTypeScriptファイルを出力
357-
*/
358-
function writeOutputFile(outputPath: string, tsOutput: string): void {
359-
try {
360-
//fs.writeFileSync(outputPath, tsOutput, 'utf-8');
361-
// 強制的に出力させるためにViteロガーを使わない
362-
console.log(`Successfully wrote search index to ${outputPath}`);
363-
} catch (error) {
364-
logger.error('[create-search-index]: error writing output: ', error);
365-
}
366-
}
367-
368-
/**
369-
* TypeScriptコード生成
370-
*/
371-
function generateTypeScriptCode(resolvedRootMarkers: SearchIndexItem[]): string {
372-
return `
373-
/*
374-
* SPDX-FileCopyrightText: syuilo and misskey-project
375-
* SPDX-License-Identifier: AGPL-3.0-only
376-
*/
377-
378-
// This file was automatically generated by create-search-index.
379-
// Do not edit this file.
380-
381-
import { i18n } from '@/i18n.js';
382-
383-
export type SearchIndexItem = {
384-
id: string;
385-
path?: string;
386-
label: string;
387-
keywords: string[];
388-
icon?: string;
389-
children?: SearchIndexItem[];
390-
};
391-
392-
export const searchIndexes: SearchIndexItem[] = ${customStringify(resolvedRootMarkers)} as const;
393-
394-
export type SearchIndex = typeof searchIndexes;
395-
`;
396-
}
397-
398354
/**
399355
* TypeScriptコード生成
400356
*/
@@ -1161,32 +1117,6 @@ function parseArrayExpression(expr: string): any[] {
11611117
}
11621118
}
11631119

1164-
export async function analyzeVueProps(options: Options, assigner: MarkerIdAssigner): Promise<void> {
1165-
initLogger(options);
1166-
1167-
// 対象ファイルパスを glob で展開
1168-
const filePaths = options.targetFilePaths.reduce<string[]>((acc, filePathPattern) => {
1169-
const matchedFiles = glob.sync(filePathPattern);
1170-
return [...acc, ...matchedFiles];
1171-
}, []);
1172-
1173-
logger.info(`Found ${filePaths.length} matching files to analyze`);
1174-
const files: [string, string][] = filePaths.map(filePath => {
1175-
const absolutePath = path.join(process.cwd(), filePath);
1176-
const id = absolutePath.replace(/\\/g, '/'); // 絶対パスに変換
1177-
const code = assigner.getCached(id); // options 経由でキャッシュ参照
1178-
if (!code) { // キャッシュミスの場合
1179-
logger.error(`Error: No cached code found for: ${id}.`); // エラーログ
1180-
throw new Error(`No cached code found for: ${id}.`); // エラーを投げる
1181-
}
1182-
return [id, code.code];
1183-
});
1184-
analyzeVuePropsByFiles({
1185-
exportFilePath: options.exportFilePath,
1186-
files,
1187-
})
1188-
}
1189-
11901120
export function collectFileMarkers(files: [id: string, code: string][]): AnalysisResult {
11911121
const allMarkers: SearchIndexItem[] = [];
11921122
for (const [id, code] of files) {
@@ -1220,12 +1150,6 @@ export function collectFileMarkers(files: [id: string, code: string][]): Analysi
12201150
};
12211151
}
12221152

1223-
export function analyzeVuePropsByFiles(options: Pick<Options, 'exportFilePath'> & {
1224-
files: [id: string, code: string][]
1225-
}): void {
1226-
writeOutputFile(options.exportFilePath, generateTypeScriptCode(collectSearchItemIndexes([collectFileMarkers(options.files)])));
1227-
}
1228-
12291153
interface MarkerRelation {
12301154
parentId?: string;
12311155
markerId: string;
@@ -1478,27 +1402,6 @@ export class MarkerIdAssigner {
14781402
}
14791403
}
14801404

1481-
export async function generateSearchIndex(options: Options, assigner: MarkerIdAssigner) {
1482-
const filePaths = options.targetFilePaths.reduce<string[]>((acc, filePathPattern) => {
1483-
const matchedFiles = glob.sync(filePathPattern);
1484-
return [...acc, ...matchedFiles];
1485-
}, []);
1486-
1487-
const files: [string, string][] = [];
1488-
1489-
for (const filePath of filePaths) {
1490-
const id = path.resolve(filePath); // 絶対パスに変換
1491-
const code = fs.readFileSync(filePath, 'utf-8'); // ファイル内容を読み込む
1492-
const transformed = assigner.processFile(normalizePath(id), code);
1493-
files.push([id, transformed.code]);
1494-
}
1495-
1496-
analyzeVuePropsByFiles({
1497-
exportFilePath: options.exportFilePath,
1498-
files,
1499-
})
1500-
}
1501-
15021405
// Rollup プラグインとして export
15031406
export default function pluginCreateSearchIndex(options: Options): PluginOption {
15041407
const assigner = new MarkerIdAssigner();
@@ -1509,22 +1412,12 @@ export default function pluginCreateSearchIndex(options: Options): PluginOption
15091412
}
15101413

15111414
function createSearchIndex(options: Options, assigner: MarkerIdAssigner): Plugin {
1512-
const isDevServer = process.env.NODE_ENV === 'development'; // 開発サーバーかどうか
1513-
15141415
initLogger(options); // ロガーを初期化
15151416

15161417
return {
15171418
name: 'createSearchIndex',
15181419
enforce: 'pre',
15191420

1520-
async buildStart() {
1521-
if (!isDevServer) {
1522-
return;
1523-
}
1524-
1525-
await generateSearchIndex(options, assigner);
1526-
},
1527-
15281421
watchChange(id) {
15291422
assigner.onInvalidate(id);
15301423
},
@@ -1554,20 +1447,7 @@ function createSearchIndex(options: Options, assigner: MarkerIdAssigner): Plugin
15541447
return;
15551448
}
15561449

1557-
// ファイルの内容が変更された場合は再処理を行う
1558-
const hasContentChanged = true; // TODO
1559-
1560-
const transformed = assigner.processFile(id, code);
1561-
1562-
if (isDevServer && hasContentChanged) {
1563-
await analyzeVueProps(options, assigner); // ファイルが変更されたときのみ分析を実行
1564-
}
1565-
1566-
return transformed;
1567-
},
1568-
1569-
async writeBundle() {
1570-
await analyzeVueProps(options, assigner); // ビルド時にも analyzeVueProps を実行
1450+
return assigner.processFile(id, code);
15711451
},
15721452
};
15731453
}

packages/frontend/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"scripts": {
66
"watch": "vite",
77
"build": "vite build",
8-
"build-search-index": "vite-node --config \"./vite-node.config.ts\" \"./scripts/generate-search-index.ts\"",
98
"storybook-dev": "nodemon --verbose --watch src --ext \"mdx,ts,vue\" --ignore \"*.stories.ts\" --exec \"pnpm build-storybook-pre && pnpm exec storybook dev -p 6006 --ci\"",
109
"build-storybook-pre": "(tsc -p .storybook || echo done.) && node .storybook/generate.js && node .storybook/preload-locale.js && node .storybook/preload-theme.js",
1110
"build-storybook": "pnpm build-storybook-pre && storybook build --webpack-stats-json storybook-static",

packages/frontend/scripts/generate-search-index.ts

-16
This file was deleted.

0 commit comments

Comments
 (0)