|
| 1 | +// Copy node/credential icon assets (png, svg) into dist, preserving paths. |
| 2 | +// |
| 3 | +// tsc only emits JS from TS and does not copy static assets, so without this |
| 4 | +// step the published package ships without the `file:hedy.png` icon that both |
| 5 | +// nodes declare. That regressed in 1.3.3 (built from a clean CI checkout) and |
| 6 | +// is fixed here. Run as part of `npm run build`. |
| 7 | +import { readdirSync, mkdirSync, copyFileSync, existsSync } from 'fs'; |
| 8 | +import { join } from 'path'; |
| 9 | + |
| 10 | +const SRC_DIRS = ['nodes', 'credentials']; |
| 11 | +const ASSET_EXTENSIONS = ['.png', '.svg']; |
| 12 | + |
| 13 | +let copied = 0; |
| 14 | + |
| 15 | +function walk(dir) { |
| 16 | + if (!existsSync(dir)) return; |
| 17 | + for (const entry of readdirSync(dir, { withFileTypes: true })) { |
| 18 | + const sourcePath = join(dir, entry.name); |
| 19 | + if (entry.isDirectory()) { |
| 20 | + walk(sourcePath); |
| 21 | + } else if (ASSET_EXTENSIONS.some((ext) => entry.name.endsWith(ext))) { |
| 22 | + const destPath = join('dist', sourcePath); |
| 23 | + mkdirSync(join('dist', dir), { recursive: true }); |
| 24 | + copyFileSync(sourcePath, destPath); |
| 25 | + copied++; |
| 26 | + console.log(`copy-icons: ${sourcePath} -> ${destPath}`); |
| 27 | + } |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +for (const dir of SRC_DIRS) walk(dir); |
| 32 | +console.log(`copy-icons: ${copied} asset(s) copied`); |
0 commit comments