import fs from 'fs/promises';
import { Args, Command } from '@oclif/core';
import path from 'path';
import { PACKAGE_JSON_TEMPLATE, TEMPLATE_PATH } from '../lib/constants.js';
export class Create extends Command {
    static args = {
        path: Args.string({
            description: 'The path where the project will be initialized.',
            required: true,
        }),
    };
    static description = 'Initialize a new Checkout extensions project.';
    static examples = ['<%= config.bin %> <%= command.id %>'];
    static flags = {};
    async run() {
        const { args } = await this.parse(Create);
        const projectPath = path.resolve(args.path);
        const packageJsonTemplate = path.resolve(projectPath, PACKAGE_JSON_TEMPLATE);
        try {
            const packageJson = path.resolve(projectPath, 'package.json');
            await fs.mkdir(projectPath, {
                recursive: true,
            });
            await fs.cp(TEMPLATE_PATH, projectPath, {
                recursive: true,
            });
            await fs.rename(packageJsonTemplate, packageJson);
        }
        catch (error) {
            console.error('An error occurred while setting up your extensions project:', error);
        }
    }
}
//# sourceMappingURL=create.js.map