|
1 | 1 | ---
|
2 | 2 | title: '@commandkit/devtools'
|
3 | 3 | ---
|
| 4 | + |
| 5 | +The `@commandkit/devtools` plugin provides a comprehensive set of |
| 6 | +development tools and utilities designed to enhance your CommandKit |
| 7 | +development experience. It includes features like command inspection, |
| 8 | +performance monitoring, debugging tools, and a web-based interface for |
| 9 | +managing your Discord bot during development. |
| 10 | + |
| 11 | +:::warning |
| 12 | + |
| 13 | +This plugin is currently in early development and may not be fully |
| 14 | +stable. It is recommended to use it for testing and feedback purposes |
| 15 | +only. Features and APIs may change in future releases. |
| 16 | + |
| 17 | +::: |
| 18 | + |
| 19 | +## Features |
| 20 | + |
| 21 | +- **Command Inspection**: View and analyze all registered commands in |
| 22 | + your bot |
| 23 | +- **Performance Monitoring**: Track command execution times and |
| 24 | + performance metrics |
| 25 | +- **Debugging Tools**: Enhanced logging and debugging capabilities |
| 26 | +- **Web Interface**: Browser-based dashboard for managing your bot |
| 27 | +- **Real-time Updates**: Live updates of bot status and metrics |
| 28 | +- **Development Utilities**: Additional tools to streamline |
| 29 | + development workflow |
| 30 | + |
| 31 | +## Installation |
| 32 | + |
| 33 | +Install the devtools plugin using your preferred package manager: |
| 34 | + |
| 35 | +```sh npm2yarn |
| 36 | +npm install @commandkit/devtools@dev |
| 37 | +``` |
| 38 | + |
| 39 | +:::info |
| 40 | + |
| 41 | +Currently, the devtools plugin is only available as a development |
| 42 | +version. Use the `@dev` tag when installing to get the latest |
| 43 | +development build. |
| 44 | + |
| 45 | +::: |
| 46 | + |
| 47 | +## Setup |
| 48 | + |
| 49 | +Add the devtools plugin to your CommandKit configuration: |
| 50 | + |
| 51 | +```ts title="commandkit.config.ts" |
| 52 | +import { defineConfig } from 'commandkit'; |
| 53 | +import { devtools } from '@commandkit/devtools'; |
| 54 | + |
| 55 | +export default defineConfig({ |
| 56 | + plugins: [devtools()], |
| 57 | +}); |
| 58 | +``` |
| 59 | + |
| 60 | +That's it! The devtools plugin will automatically start when you run |
| 61 | +your application in development mode. |
| 62 | + |
| 63 | +## Using the devtools |
| 64 | + |
| 65 | +Once the plugin is installed and configured, the devtools interface |
| 66 | +will be available at `http://localhost:4356` when you start your |
| 67 | +application with `commandkit dev`. |
| 68 | + |
| 69 | +```bash |
| 70 | +npx commandkit dev |
| 71 | +``` |
| 72 | + |
| 73 | +The web interface provides access to all devtools features and allows |
| 74 | +you to: |
| 75 | + |
| 76 | +- Monitor your bot's status and performance |
| 77 | +- Inspect registered commands and their configurations |
| 78 | +- View real-time logs and debug information |
| 79 | +- Access development utilities and tools |
| 80 | + |
| 81 | +## Configuration Options |
| 82 | + |
| 83 | +The devtools plugin accepts several configuration options to customize |
| 84 | +its behavior: |
| 85 | + |
| 86 | +```ts title="commandkit.config.ts" |
| 87 | +import { defineConfig } from 'commandkit'; |
| 88 | +import { devtools } from '@commandkit/devtools'; |
| 89 | + |
| 90 | +export default defineConfig({ |
| 91 | + plugins: [ |
| 92 | + devtools({ |
| 93 | + // Custom port for the devtools interface |
| 94 | + port: 4356, |
| 95 | + |
| 96 | + // Enable or disable specific features |
| 97 | + features: { |
| 98 | + commandInspection: true, |
| 99 | + performanceMonitoring: true, |
| 100 | + debugging: true, |
| 101 | + }, |
| 102 | + |
| 103 | + // Additional configuration options |
| 104 | + enableLogging: true, |
| 105 | + }), |
| 106 | + ], |
| 107 | +}); |
| 108 | +``` |
| 109 | + |
| 110 | +### Configuration Properties |
| 111 | + |
| 112 | +- `port` (number): The port number for the devtools web interface |
| 113 | + (default: `4356`) |
| 114 | +- `features` (object): Enable or disable specific devtools features |
| 115 | +- `enableLogging` (boolean): Enable enhanced logging capabilities |
| 116 | + |
| 117 | +## Development Workflow |
| 118 | + |
| 119 | +The devtools plugin integrates seamlessly with CommandKit's |
| 120 | +development workflow: |
| 121 | + |
| 122 | +1. **Start Development**: Run `commandkit dev` to start your bot in |
| 123 | + development mode |
| 124 | +2. **Access Devtools**: Open `http://localhost:4356` in your browser |
| 125 | +3. **Monitor & Debug**: Use the web interface to monitor your bot and |
| 126 | + debug issues |
| 127 | +4. **Hot Reload**: Make changes to your code and see updates in |
| 128 | + real-time |
| 129 | + |
| 130 | +:::tip Development Only |
| 131 | + |
| 132 | +The devtools plugin is designed for development use only and should |
| 133 | +not be included in production builds. Consider using environment-based |
| 134 | +configuration to conditionally include the plugin: |
| 135 | + |
| 136 | +```ts title="commandkit.config.ts" |
| 137 | +import { defineConfig } from 'commandkit'; |
| 138 | +import { devtools } from '@commandkit/devtools'; |
| 139 | + |
| 140 | +export default defineConfig({ |
| 141 | + plugins: [ |
| 142 | + // Only include devtools in development |
| 143 | + ...(process.env.NODE_ENV === 'development' ? [devtools()] : []), |
| 144 | + ], |
| 145 | +}); |
| 146 | +``` |
| 147 | + |
| 148 | +::: |
| 149 | + |
| 150 | +## Preview |
| 151 | + |
| 152 | +The devtools interface provides a modern, intuitive dashboard for |
| 153 | +managing your Discord bot during development: |
| 154 | + |
| 155 | +<img |
| 156 | + src="/img/devtools.webp" |
| 157 | + alt="CommandKit DevTools Interface" |
| 158 | + width="100%" |
| 159 | +/> |
| 160 | + |
| 161 | +## Troubleshooting |
| 162 | + |
| 163 | +### Port Already in Use |
| 164 | + |
| 165 | +If port `4356` is already in use, you can specify a different port in |
| 166 | +the configuration: |
| 167 | + |
| 168 | +```ts |
| 169 | +devtools({ port: 4357 }); |
| 170 | +``` |
| 171 | + |
| 172 | +### Interface Not Loading |
| 173 | + |
| 174 | +Ensure that: |
| 175 | + |
| 176 | +1. The devtools plugin is properly configured |
| 177 | +2. Your application is running in development mode |
| 178 | +3. No firewall is blocking the specified port |
| 179 | +4. You're accessing the correct URL (`http://localhost:4356`) |
| 180 | + |
| 181 | +### Performance Issues |
| 182 | + |
| 183 | +If you experience performance issues: |
| 184 | + |
| 185 | +1. Disable unnecessary features in the configuration |
| 186 | +2. Reduce logging verbosity |
| 187 | +3. Consider using a different port |
| 188 | + |
| 189 | +## Feedback and Contributions |
| 190 | + |
| 191 | +As this plugin is in early development, your feedback is valuable for |
| 192 | +improving the devtools experience. Please report issues, suggest |
| 193 | +features, or contribute to the development through: |
| 194 | + |
| 195 | +- [GitHub Issues](https://github.com/underctrl-io/commandkit/issues) |
| 196 | +- [Discord Community](https://ctrl.lol/discord) |
0 commit comments