import { fileURLToPath } from 'node:url'; import { dirname, resolve } from 'node:path'; import { existsSync } from 'node:fs'; /** * Resolves the absolute path to the bundled assets directory. * * The compiled CLI lives at dist/cli/cli/assets-path.js. * The assets are copied to dist/assets/ during build. * So from this script's location, assets are at ../../assets/ */ export function getAssetsPath() { const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); // Navigate from dist/cli/cli/ up to dist/, then into assets/ const assetsPath = resolve(__dirname, '..', '..', 'assets'); if (!existsSync(assetsPath)) { throw new Error(`Assets directory not found at ${assetsPath}. Run "npm run build:all" to bundle assets.`); } return assetsPath; }