UNPKG

browser-plugin-creator

Version:

A modern scaffolding tool for creating browser extensions with ease

56 lines (55 loc) 2.25 kB
import chalk from 'chalk'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const templates = [ { name: 'basic-popup', description: '基础弹窗扩展,适合初学者', features: ['弹窗页面', '基础样式', 'Manifest V3'], framework: ['Vanilla JS', 'CSS'], difficulty: '简单' }, { name: 'content-script', description: '内容脚本扩展,可操作网页内容', features: ['内容脚本', 'DOM操作', '消息通信'], framework: ['Vanilla JS', 'TypeScript'], difficulty: '中等' }, { name: 'full-featured', description: '完整功能扩展,包含所有核心功能', features: ['弹窗', '内容脚本', '后台脚本', '选项页面'], framework: ['React', 'TypeScript', 'Webpack'], difficulty: '高级' }, { name: 'devtools', description: '开发者工具扩展,集成到浏览器DevTools', features: ['DevTools面板', '网络监控', '性能分析'], framework: ['React', 'TypeScript'], difficulty: '高级' }, { name: 'side-panel', description: '侧边栏扩展,使用Chrome Side Panel API', features: ['侧边栏', '持久化存储', '现代化UI'], framework: ['Vue 3', 'TypeScript'], difficulty: '中等' } ]; export async function listTemplates() { console.log(chalk.blue('\n📋 可用模板:\n')); templates.forEach((template, index) => { console.log(chalk.yellow(`${index + 1}. ${template.name}`)); console.log(chalk.white(` ${template.description}`)); console.log(chalk.gray(` 功能: ${template.features.join(', ')}`)); console.log(chalk.gray(` 技术栈: ${template.framework.join(', ')}`)); console.log(chalk.gray(` 难度: ${template.difficulty}\n`)); }); console.log(chalk.cyan('使用示例:')); console.log(chalk.white(' browser-plugin-creator create my-extension --template basic-popup')); console.log(chalk.white(' browser-plugin-creator create my-extension -t full-featured\n')); }