()
| 51 | } |
| 52 | |
| 53 | async function createPlugin() { |
| 54 | try { |
| 55 | console.log("🔌 Plugin Creator"); |
| 56 | console.log("This tool will help you create a new plugin.\n"); |
| 57 | |
| 58 | const parsed = parseArgs(); |
| 59 | |
| 60 | // Get plugin ID |
| 61 | let pluginId = parsed.name; |
| 62 | if (!pluginId) { |
| 63 | pluginId = await prompt("Plugin ID (lowercase, hyphens only): "); |
| 64 | } |
| 65 | |
| 66 | if (!pluginId) { |
| 67 | console.error("❌ Plugin ID is required"); |
| 68 | process.exit(1); |
| 69 | } |
| 70 | |
| 71 | if (!/^[a-z0-9-]+$/.test(pluginId)) { |
| 72 | console.error( |
| 73 | "❌ Plugin ID must contain only lowercase letters, numbers, and hyphens" |
| 74 | ); |
| 75 | process.exit(1); |
| 76 | } |
| 77 | |
| 78 | const pluginDir = path.join(PLUGINS_DIR, pluginId); |
| 79 | |
| 80 | // Check if plugin already exists |
| 81 | if (fs.existsSync(pluginDir)) { |
| 82 | console.log( |
| 83 | `⚠️ Plugin ${pluginId} already exists at ${pluginDir}` |
| 84 | ); |
| 85 | console.log("💡 Please edit that plugin instead or choose a different ID."); |
| 86 | process.exit(1); |
| 87 | } |
| 88 | |
| 89 | // Get display name |
| 90 | const defaultDisplayName = pluginId |
| 91 | .split("-") |
| 92 | .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) |
| 93 | .join(" "); |
| 94 | |
| 95 | let displayName = await prompt( |
| 96 | `Display name (default: ${defaultDisplayName}): ` |
| 97 | ); |
| 98 | if (!displayName.trim()) { |
| 99 | displayName = defaultDisplayName; |
| 100 | } |
| 101 | |
| 102 | // Get description |
| 103 | const defaultDescription = `A plugin for ${displayName.toLowerCase()}.`; |
| 104 | let description = await prompt( |
| 105 | `Description (default: ${defaultDescription}): ` |
| 106 | ); |
| 107 | if (!description.trim()) { |
| 108 | description = defaultDescription; |
| 109 | } |
| 110 |
no test coverage detected