mirror of
https://github.com/Afilmory/afilmory
synced 2026-02-01 22:48:17 +00:00
- Introduced a migration system for manifest files to support versioning and backward compatibility. - Updated image processing to switch thumbnail format from WebP to JPEG for better compatibility. - Added new commands for manifest migration and improved thumbnail handling in the builder. - Enhanced documentation with architecture details and development commands. Signed-off-by: Innei <tukon479@gmail.com>
29 lines
918 B
TypeScript
29 lines
918 B
TypeScript
import fs from 'node:fs/promises'
|
|
import path from 'node:path'
|
|
|
|
import { migrateManifest } from '../packages/builder/src/manifest/migrate'
|
|
import { CURRENT_MANIFEST_VERSION } from '../packages/builder/src/manifest/version'
|
|
|
|
async function run() {
|
|
const manifestPath = path.resolve(
|
|
process.cwd(),
|
|
'src/data/photos-manifest.json',
|
|
)
|
|
try {
|
|
const raw = await fs.readFile(manifestPath, 'utf-8')
|
|
const parsed = JSON.parse(raw)
|
|
if (parsed?.version === CURRENT_MANIFEST_VERSION) {
|
|
console.info(`Manifest 已是 ${CURRENT_MANIFEST_VERSION},跳过迁移`)
|
|
return
|
|
}
|
|
const migrated = migrateManifest(parsed, CURRENT_MANIFEST_VERSION)
|
|
await fs.writeFile(manifestPath, JSON.stringify(migrated, null, 2))
|
|
console.info(`✅ Manifest 迁移完成 -> ${CURRENT_MANIFEST_VERSION}`)
|
|
} catch (e) {
|
|
console.error('❌ 迁移失败:', e)
|
|
process.exitCode = 1
|
|
}
|
|
}
|
|
|
|
run()
|