From 49261626490fd7883cea5c0ebcdefe3a588ddc45 Mon Sep 17 00:00:00 2001 From: rca <_@r0m.me> Date: Mon, 1 Dec 2025 16:53:03 +0900 Subject: [PATCH] chore: adjust asset/meta logging --- src/cli.ts | 1 + src/pipeline/assetManager.ts | 23 ++++++++++++++++------- src/pipeline/loadMeta.ts | 32 ++++++++++++++++++++++++++------ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 0c2f490..11a904e 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -15,6 +15,7 @@ async function runPipeline() { await prepareWorkspace(); const assetManager = new AssetManager(); const { outputPath: markdownPath, orderedFiles } = await concatMarkdown(assetManager); + assetManager.report(); await injectToc(markdownPath); await renderMarkdownToHtml(markdownPath, WORK_MARKDOWN_HTML, assetManager, orderedFiles); const meta = await loadMeta(); diff --git a/src/pipeline/assetManager.ts b/src/pipeline/assetManager.ts index 97deca3..389e3ae 100644 --- a/src/pipeline/assetManager.ts +++ b/src/pipeline/assetManager.ts @@ -61,7 +61,7 @@ function extractImageSources(tokens: Token[]) { export class AssetManager { private assetMap = new Map(); - private copiedTargets = new Set(); + private copiedCount = 0; private key(filePath: string, src: string) { return `${filePath}::${src}`; @@ -99,13 +99,12 @@ export class AssetManager { const segments = splitSegments(relativeFromDocuments); const { targetRelativePosix, targetPath } = buildTarget(segments); + const targetRelativePath = path.relative('.', targetPath); - if (!this.copiedTargets.has(targetPath)) { - await ensureDir(path.dirname(targetPath)); - await fs.copyFile(absoluteSource, targetPath); - this.copiedTargets.add(targetPath); - logger.succ(`画像をコピー: ${path.relative('.', targetPath)} (元: ${relativeFromDocuments})`); - } + logAssetCopyStart(relativeFromDocuments, targetRelativePath); + await ensureDir(path.dirname(targetPath)); + await fs.copyFile(absoluteSource, targetPath); + this.copiedCount++; this.assetMap.set(this.key(filePath, rawSource), targetRelativePosix); if (rawSource !== normalized) { @@ -119,4 +118,14 @@ export class AssetManager { this.assetMap.get(this.key(filePath, normalizeSource(src))) ); } + + report() { + logger.succ(`asset copy total: ${this.copiedCount} file(s)`); + } +} + +function logAssetCopyStart(source: string, target: string) { + logger.info('├─ asset copy'); + logger.info(`│ ├─ src: ${abbreviate(source)}`); + logger.info(`│ └─ dst: ${abbreviate(target)}`); } diff --git a/src/pipeline/loadMeta.ts b/src/pipeline/loadMeta.ts index a387123..3bdbd84 100644 --- a/src/pipeline/loadMeta.ts +++ b/src/pipeline/loadMeta.ts @@ -11,6 +11,7 @@ export interface DocumentMetaSection { published?: string; pubDate?: string; copyright?: string; + description?: string; } export interface DocumentMeta { @@ -59,12 +60,14 @@ function buildSection(value: unknown): DocumentMetaSection | undefined { const published = pickString(record.published); const pubDate = pickString(record.pubDate); const copyright = pickString(record.copyright); + const description = pickString(record.description); if (title) section.title = title; if (author) section.author = author; if (published) section.published = published; if (pubDate) section.pubDate = pubDate; if (copyright) section.copyright = copyright; + if (description) section.description = description; return Object.keys(section).length > 0 ? section : undefined; } @@ -102,21 +105,38 @@ export async function loadMeta(): Promise { logger.info(`メタ情報ファイル ${filename} を読み込みます`); const meta = await loadYamlMeta(fullPath); logMetaInfo(meta, filename); + logger.succ('メタ情報の読み込みが完了しました'); return meta; } } logger.info('メタ情報ファイルが見つからなかったため、テンプレートのデフォルト値を使用します'); logMetaInfo(DEFAULT_META, 'default'); + logger.succ('メタ情報の読み込みが完了しました'); return DEFAULT_META; } function logMetaInfo(meta: DocumentMeta, source: string) { - logger.info(`\tsource: ${source}`); - logger.info(`\ttitle: ${meta.title}`); - logger.info(`\tauthor: ${meta.author}`); - logger.info(`\tpublished: ${meta.published}`); + logger.info(`├─ meta source: ${source}`); + logger.info(`│ ├─ title: ${meta.title}`); + logger.info(`│ ├─ author: ${meta.author}`); + logger.info(`│ ├─ published: ${meta.published}`); if (meta.description) { - logger.info(`\tdescription: ${meta.description}`); + logger.info(`│ ├─ description: ${meta.description}`); } - logger.info(`\tcopyright: ${meta.copyright}`); + logger.info(`│ └─ copyright: ${meta.copyright}`); + logSection('frontCover', meta.frontCover); + logSection('backCover', meta.backCover); +} + +function logSection(label: string, section?: DocumentMetaSection) { + if (!section) { + return; + } + logger.info(`├─ ${label}:`); + if (section.title) logger.info(`│ ├─ title: ${section.title}`); + if (section.author) logger.info(`│ ├─ author: ${section.author}`); + if (section.published) logger.info(`│ ├─ published: ${section.published}`); + if (section.pubDate) logger.info(`│ ├─ pubDate: ${section.pubDate}`); + if (section.description) logger.info(`│ ├─ description: ${section.description}`); + if (section.copyright) logger.info(`│ └─ copyright: ${section.copyright}`); }