Skip to content

Commit eb7e47f

Browse files
committed
Refactor database plugins to use functional plugin creation
1 parent 577018b commit eb7e47f

24 files changed

+710
-780
lines changed

PROJECT.md

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ This document outlines the planned features, improvements, and tasks for V2 of t
4242
- [ ] Create example plugins
4343

4444
### Plugin System Architecture 🔌
45-
- [ ] Design core plugin system:
46-
- [ ] Create plugin interface definitions
47-
- [ ] Implement plugin registry
48-
- [ ] Add plugin validation system
49-
- [ ] Create plugin loading mechanism
45+
- [x] Design core plugin system:
46+
- [x] Create plugin interface definitions
47+
- [x] Implement plugin registry
48+
- [x] Add plugin validation system
49+
- [x] Create plugin loading mechanism
5050
- [ ] Add plugin dependency resolution
5151

52-
- [ ] Core Plugin Types (Everything is a plugin):
53-
- [ ] Database plugins
54-
- [ ] Question sets for each database
55-
- [ ] Database-specific configuration templates
56-
- [ ] Validation rules
57-
- [ ] Environment variable handling
52+
- [x] Core Plugin Types (Everything is a plugin):
53+
- [x] Database plugins
54+
- [x] Question sets for each database
55+
- [x] Database-specific configuration templates
56+
- [x] Validation rules
57+
- [x] Environment variable handling
5858
- [ ] Provider plugins
5959
- [ ] Configuration plugins
6060
- [ ] Template plugins
@@ -146,8 +146,8 @@ This document outlines the planned features, improvements, and tasks for V2 of t
146146
### 3. Database Support 🗄️
147147
- [ ] Implement support for official Strapi databases:
148148
- [ ] PostgreSQL
149-
- [ ] MySQL
150-
- [ ] MariaDB
149+
- [x] MySQL
150+
- [x] MariaDB
151151
- [ ] SQLite (with bind mount support)
152152
- [ ] Add .env file parsing for existing configurations
153153
- [ ] Implement database backup functionality
@@ -237,16 +237,38 @@ This document outlines the planned features, improvements, and tasks for V2 of t
237237
- [x] Interactive UI with Ink
238238
- [x] Basic flow implementation
239239
- [x] Node.js version management
240-
- [ ] Database configuration
240+
- [x] Plugin system architecture
241+
- [x] MySQL plugin implementation
242+
- [x] MariaDB plugin implementation
243+
- [ ] PostgreSQL plugin implementation
244+
- [ ] SQLite plugin implementation
241245
- [ ] Docker file generation
242246
- [ ] Environment handling
243-
- [ ] Plugin system
244247
245248
### Next Steps
246-
1. Implement Docker file generation based on selected options
247-
2. Add environment variable management
248-
3. Create database configuration handlers
249-
4. Implement plugin system for extensibility
249+
1. Complete Database Plugins
250+
- Implement PostgreSQL plugin
251+
- Implement SQLite plugin
252+
- Add database migration support
253+
- Add backup functionality
254+
255+
2. Docker Template System
256+
- Create database-specific Docker templates
257+
- Implement development environment templates
258+
- Implement production environment templates
259+
- Add template validation system
260+
261+
3. Testing & Quality Assurance
262+
- Implement unit tests for existing plugins
263+
- Add integration tests for database configurations
264+
- Set up test coverage reporting
265+
- Add automated testing in CI/CD
266+
267+
4. Documentation
268+
- Update README with new plugin system
269+
- Add plugin development guide
270+
- Create database plugin examples
271+
- Add troubleshooting guide
250272
251273
### 5. Project Detection & Configuration 🔍
252274
- [x] Improve Strapi version detection

src/plugins/core/plugin-manager.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { BaseDatabasePlugin } from '../databases/core/base-plugin';
1+
import { DatabasePlugin } from '../databases/core/base-plugin';
22
import { DatabaseAnswers, Question } from '../databases/core/types';
33
import { PostgreSQLPlugin } from '../databases/postgresql';
44
import { MySQLPlugin } from '../databases/mysql';
55
import { MariaDBPlugin } from '../databases/mariadb';
66
import { SQLitePlugin } from '../databases/sqlite';
77

88
export class PluginManager {
9-
private plugins: Map<string, BaseDatabasePlugin>;
9+
private plugins: Map<string, DatabasePlugin>;
1010

1111
constructor() {
1212
this.plugins = new Map();
@@ -16,14 +16,14 @@ export class PluginManager {
1616
private loadBuiltinPlugins(): void {
1717
// Load built-in plugins
1818
const builtinPlugins = [
19-
new PostgreSQLPlugin(),
20-
new MySQLPlugin(),
21-
new MariaDBPlugin(),
22-
new SQLitePlugin()
23-
] as BaseDatabasePlugin[];
19+
PostgreSQLPlugin,
20+
MySQLPlugin,
21+
MariaDBPlugin,
22+
SQLitePlugin
23+
];
2424

2525
for (const plugin of builtinPlugins) {
26-
this.plugins.set(plugin.constructor.name.toLowerCase().replace('plugin', ''), plugin);
26+
this.plugins.set(plugin.config.name.toLowerCase(), plugin);
2727
}
2828
}
2929

@@ -37,7 +37,7 @@ export class PluginManager {
3737
/**
3838
* Get a plugin by database type
3939
*/
40-
getPlugin(type: string): BaseDatabasePlugin | undefined {
40+
getPlugin(type: string): DatabasePlugin | undefined {
4141
return this.plugins.get(type.toLowerCase());
4242
}
4343

src/plugins/databases/base.ts

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)