import fs from 'fs/promises'; import { execSync } from 'child_process'; /** * Build the CLI tool wrapper that users can run via npx */ export async function buildCliWrapper(): Promise { console.log('\nBuilding CLI tool...'); // Compile the TypeScript CLI to JavaScript using tsc // Using --outDir dist preserves the source directory structure naturally console.log('Compiling CLI to JavaScript...'); execSync( 'npx tsc src/cli/buildTheme.ts src/formats/cssThemeWithOverridesFormat.ts src/parsers/crossBrandParser.ts --outDir dist --module Node16 --moduleResolution Node16 --target ES2022 --lib ES2022 --types node --skipLibCheck --ignoreConfig', { stdio: 'inherit' }, ); // Make the CLI executable await fs.chmod('dist/cli/buildTheme.js', 0o755); console.log('✔︎ dist/cli/buildTheme.js'); }