()
| 21 | const SNAP_DIR = join(ROOT, "snapshots"); |
| 22 | |
| 23 | async function main() { |
| 24 | const args = process.argv.slice(2); |
| 25 | const isUpdate = args.includes("--update"); |
| 26 | const isVerify = args.includes("--verify"); |
| 27 | const isList = args.includes("--list"); |
| 28 | |
| 29 | // Dynamic imports (built output) |
| 30 | const core = await import(join(ROOT, "packages/core/dist/index.js")); |
| 31 | const galleryScenes = await import(join(ROOT, "examples/gallery/dist/scenes.js")); |
| 32 | |
| 33 | const { |
| 34 | captureSnapshot, |
| 35 | serializeSnapshot, |
| 36 | parseSnapshot, |
| 37 | diffSnapshots, |
| 38 | darkTheme, |
| 39 | lightTheme, |
| 40 | nordTheme, |
| 41 | } = core; |
| 42 | |
| 43 | const { scenes } = galleryScenes; |
| 44 | |
| 45 | if (isList) { |
| 46 | console.log("Available scenes:"); |
| 47 | for (const scene of scenes) { |
| 48 | console.log(` ${scene.name} — ${scene.title}`); |
| 49 | } |
| 50 | process.exit(0); |
| 51 | } |
| 52 | |
| 53 | // Parse scene filter |
| 54 | const sceneFilter = []; |
| 55 | for (let i = 0; i < args.length; i++) { |
| 56 | if (args[i] === "--scene" && args[i + 1]) { |
| 57 | sceneFilter.push(args[i + 1]); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // Parse theme filter |
| 62 | const themeFilter = []; |
| 63 | for (let i = 0; i < args.length; i++) { |
| 64 | if (args[i] === "--theme" && args[i + 1]) { |
| 65 | themeFilter.push(args[i + 1]); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | const themes = { |
| 70 | dark: darkTheme, |
| 71 | light: lightTheme, |
| 72 | nord: nordTheme, |
| 73 | }; |
| 74 | |
| 75 | const themeNames = |
| 76 | themeFilter.length > 0 ? themeFilter.filter((t) => t in themes) : Object.keys(themes); |
| 77 | |
| 78 | const scenesToProcess = |
| 79 | sceneFilter.length > 0 ? scenes.filter((s) => sceneFilter.includes(s.name)) : scenes; |
| 80 |
no test coverage detected