UNPKG

@wilboerht/blog-template

Version:
58 lines (48 loc) 1.54 kB
import fs from 'fs-extra'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const rootDir = path.join(__dirname, '..'); const templateDir = path.join(rootDir, 'template'); async function setupTemplate() { try { // Create template directory await fs.ensureDir(templateDir); // Copy necessary files to template directory const filesToCopy = [ 'docs', 'scripts', 'docs/.vitepress', 'tsconfig.json', '.eslintrc.json', '.prettierrc', 'package.json', 'README.md' ]; console.log('Creating template directory...'); for (const file of filesToCopy) { const sourcePath = path.join(rootDir, file); const targetPath = path.join(templateDir, file); console.log(`Copying ${file}...`); if (await fs.pathExists(sourcePath)) { await fs.copy(sourcePath, targetPath, { filter: (src) => { return !src.includes('node_modules') && !src.includes('.git') && !src.includes('dist') && !src.includes('cache'); } }); console.log(`✓ Copied ${file}`); } else { console.log(`⚠ Warning: ${file} not found`); } } console.log('\nTemplate directory created successfully! ✨'); } catch (err) { console.error('Error creating template:', err); process.exit(1); } } setupTemplate();