<commit_before>import { join, resolve, dirname } from 'path';
import fs from 'fs-extra';

export default function createProject({ projectPath, config }) {
    try {
        if (config.type === 'library') {
            const basePath = join(__dirname, '../../boilerplates/project/library');
            fs.copySync(basePath, projectPath);
            fs.writeFileSync(join(projectPath, '.vd', 'project.json'), JSON.stringify(config, null, 2));
        } else {
            const basePath = join(__dirname, '../../boilerplates/project', config.type);
            let dirConfig = config.directory || {};
            // console.log(basePath, projectPath);
            if (!fs.existsSync(basePath)) {
                return console.error(`${basePath} not found`);
            }
            // fs.copy(basePath, projectPath, (err) => {
            //     console.log(err);
            // });
            // fs.mkdirsSync(projectPath);
            fs.copySync(basePath, projectPath);

            dirConfig = config.directory.development;
            dirConfig.source = dirConfig.envName;
            const appPath = join(projectPath, 'src', 'App.js');
            fs.writeFileSync(join(projectPath, '.vd', 'project.json'), JSON.stringify(config, null, 2));
            if (config.routerType !== 'BrowserRouter') {
                const str = fs.readFileSync(appPath, 'utf8');
                fs.writeFileSync(appPath, str.replace('BrowserRouter', 'HashRouter'))
            }
        }
    } catch (error) {
        // fs.removeSync(projectPath);
        throw error;
    }<commit_msg>create failed remove dir<commit_after>import { join, resolve, dirname } from 'path';
import fs from 'fs-extra';

export default function createProject({ projectPath, config }) {
    try {
        if (config.type === 'library') {
            const basePath = join(__dirname, '../../boilerplates/project/library');
            fs.copySync(basePath, projectPath);
            fs.writeFileSync(join(projectPath, '.vd', 'project.json'), JSON.stringify(config, null, 2));
        } else {
            const basePath = join(__dirname, '../../boilerplates/project', config.type);
            let dirConfig = config.directory || {};
            // console.log(basePath, projectPath);
            if (!fs.existsSync(basePath)) {
                return console.error(`${basePath} not found`);
            }
            // fs.copy(basePath, projectPath, (err) => {
            //     console.log(err);
            // });
            // fs.mkdirsSync(projectPath);
            fs.copySync(basePath, projectPath);

            dirConfig = config.directory.development;
            dirConfig.source = dirConfig.envName;
            const appPath = join(projectPath, 'src', 'App.js');
            fs.writeFileSync(join(projectPath, '.vd', 'project.json'), JSON.stringify(config, null, 2));
            if (config.routerType !== 'BrowserRouter') {
                const str = fs.readFileSync(appPath, 'utf8');
                fs.writeFileSync(appPath, str.replace('BrowserRouter', 'HashRouter'))
            }
        }
    } catch (error) {
        fs.removeSync(projectPath);
        throw error;
    }
{'fraction_non_alphanumeric': 0.14718888186986734, 'fraction_numerical': 0.0018951358180669614, 'mean_word_length': 2.0897560975609757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5964783', 'n_tokens_mistral': 865, 'n_tokens_neox': 849, 'n_words': 175}