import generateComponent from '../util/project/generateComponent.js';
import { withEmulsifySystem } from './hofs/withEmulsifySystem.js';
import CliError from '../lib/CliError.js';
export default async function componentCreate(name, options = {}) {
    if (!name?.trim()) {
        throw new CliError('Please specify a name for the new component.');
    }
    const { variantConf } = await withEmulsifySystem('create components');
    try {
        await generateComponent(variantConf, name, options);
    }
    catch (e) {
        const msg = e instanceof Error ? e.message : String(e);
        throw new CliError(`Unable to create the ${name} component: ${msg}`);
    }
}
