From 55715d9fa4c433fc35cf191eb4dd92f61d13d145 Mon Sep 17 00:00:00 2001 From: reaper Date: Fri, 14 Aug 2026 13:47:25 -0500 Subject: [PATCH] feat: add MySQL database support --- packages/aurora-module-wordpress/manifest.json | 4 ++-- packages/aurora-module-wordpress/package.json | 2 +- src/main/auroraEngine.ts | 10 ++++++---- src/main/ipc/database.ts | 9 +++++++-- .../src/components/create/CreateProjectModal.tsx | 4 ++-- src/shared/types.ts | 4 ++-- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/aurora-module-wordpress/manifest.json b/packages/aurora-module-wordpress/manifest.json index 0d1b66d..0d7c731 100644 --- a/packages/aurora-module-wordpress/manifest.json +++ b/packages/aurora-module-wordpress/manifest.json @@ -1,7 +1,7 @@ { "id": "wordpress", "name": "WordPress", - "version": "1.1.0", + "version": "1.2.0", "category": "application", "description": "WordPress CMS provisioning and WP-CLI tooling.", "main": "main/index.cjs", @@ -11,7 +11,7 @@ "defaults": { "docroot": "" }, "settings": [], "creation": { - "databases": ["mariadb"], + "databases": ["mariadb", "mysql"], "intro": { "title": "WordPress install", "description": "Core downloads automatically and the project starts for setup.", "icon": "globe" }, "setup": [ { "id": "title", "label": "Site title", "type": "text", "default": "", "placeholder": "My WordPress Site", "icon": "title", "span": 2 }, diff --git a/packages/aurora-module-wordpress/package.json b/packages/aurora-module-wordpress/package.json index 5da9dda..41abb3b 100644 --- a/packages/aurora-module-wordpress/package.json +++ b/packages/aurora-module-wordpress/package.json @@ -1,6 +1,6 @@ { "name": "@aurora/module-wordpress", - "version": "1.1.0", + "version": "1.2.0", "private": true, "description": "WordPress application module for Aurora Dockside", "files": ["manifest.json", "main", "README.md"] diff --git a/src/main/auroraEngine.ts b/src/main/auroraEngine.ts index 9a3b775..5cb5f49 100644 --- a/src/main/auroraEngine.ts +++ b/src/main/auroraEngine.ts @@ -17,7 +17,7 @@ type AuroraConfig = { php: string node: string webserver: 'nginx' | 'apache' - database: 'mariadb' | 'postgres' + database: 'mariadb' | 'mysql' | 'postgres' databaseVersion: string modules: string[] moduleSettings?: Record> @@ -113,7 +113,9 @@ async function renderModuleService(module: AuroraModuleManifest, config: AuroraC async function renderCompose(c: AuroraConfig): Promise { const db = c.database === 'postgres' ? ` db:\n image: postgres:${c.databaseVersion}\n environment:\n POSTGRES_DB: db\n POSTGRES_USER: db\n POSTGRES_PASSWORD: db\n volumes:\n - db_data:/var/lib/postgresql/data\n healthcheck:\n test: [\"CMD-SHELL\", \"pg_isready -U db -d db\"]\n interval: 3s\n timeout: 3s\n retries: 20` - : ` db:\n image: mariadb:${c.databaseVersion}\n environment:\n MARIADB_DATABASE: db\n MARIADB_USER: db\n MARIADB_PASSWORD: db\n MARIADB_ROOT_PASSWORD: root\n volumes:\n - db_data:/var/lib/mysql\n healthcheck:\n test: [\"CMD\", \"healthcheck.sh\", \"--connect\", \"--innodb_initialized\"]\n interval: 3s\n timeout: 3s\n retries: 20` + : c.database === 'mysql' + ? ` db:\n image: mysql:${c.databaseVersion}\n environment:\n MYSQL_DATABASE: db\n MYSQL_USER: db\n MYSQL_PASSWORD: db\n MYSQL_ROOT_PASSWORD: root\n volumes:\n - db_data:/var/lib/mysql\n healthcheck:\n test: [\"CMD-SHELL\", \"mysqladmin ping -h localhost -uroot -proot --silent\"]\n interval: 3s\n timeout: 3s\n retries: 20` + : ` db:\n image: mariadb:${c.databaseVersion}\n environment:\n MARIADB_DATABASE: db\n MARIADB_USER: db\n MARIADB_PASSWORD: db\n MARIADB_ROOT_PASSWORD: root\n volumes:\n - db_data:/var/lib/mysql\n healthcheck:\n test: [\"CMD\", \"healthcheck.sh\", \"--connect\", \"--innodb_initialized\"]\n interval: 3s\n timeout: 3s\n retries: 20` const coreServices: Record = { redis: { id: 'redis', name: 'Redis', version: '1.0.0', category: 'service', description: '', dependencies: [], conflicts: [], settings: [], aurora: { core: CORE_VERSION, moduleApi: MODULE_API_VERSION }, compose: { service: 'redis', image: 'redis:8-alpine', ports: [6379] } }, mailpit: { id: 'mailpit', name: 'Mailpit', version: '1.0.0', category: 'tool', description: '', dependencies: [], conflicts: [], settings: [], aurora: { core: CORE_VERSION, moduleApi: MODULE_API_VERSION }, compose: { service: 'mailpit', image: 'axllent/mailpit:latest', ports: [8025, 1025] } } @@ -239,7 +241,7 @@ export async function updateEnvironment(root:string, updates:{phpVersion?:string if(updates.webserverType === 'nginx' || updates.webserverType === 'nginx-fpm') c.webserver='nginx' if(updates.webserverType === 'apache' || updates.webserverType === 'apache-fpm') c.webserver='apache' if(typeof updates.xdebugEnabled === 'boolean') c.xdebug=updates.xdebugEnabled - if(updates.database){const [kind,version]=updates.database.split(':'); if(kind==='mariadb'||kind==='postgres'){c.database=kind;c.databaseVersion=version||c.databaseVersion}} + if(updates.database){const [kind,version]=updates.database.split(':'); if(kind==='mariadb'||kind==='mysql'||kind==='postgres'){c.database=kind;c.databaseVersion=version||c.databaseVersion}} if(updates.primaryProtocol === 'http' || updates.primaryProtocol === 'https') c.primaryProtocol = updates.primaryProtocol await writeConfig(root,c); await writeWebServerConfig(root,c); await writePhpDockerfile(root, c.xdebug === true) } @@ -331,7 +333,7 @@ export async function scaffoldApplicationModule(_name: string, moduleId: string) export async function getProjectRoot(name:string):Promise{const r=await loadRegistry();if(!r.projects[name])throw new Error(`Project ${name} not found`);return r.projects[name]} -export async function getProjectConfigByRoot(root: string): Promise<{ database: 'mariadb' | 'postgres'; databaseVersion: string; name: string }> { +export async function getProjectConfigByRoot(root: string): Promise<{ database: 'mariadb' | 'mysql' | 'postgres'; databaseVersion: string; name: string }> { const config = await readConfig(root) return { database: config.database, databaseVersion: config.databaseVersion, name: config.name } } diff --git a/src/main/ipc/database.ts b/src/main/ipc/database.ts index 0c8e64d..c482168 100644 --- a/src/main/ipc/database.ts +++ b/src/main/ipc/database.ts @@ -16,18 +16,23 @@ function safeSnapshotName(value?: string): string { return safe || fallback } -function dbCommand(type: 'mariadb' | 'postgres', mode: 'dump' | 'restore'): { command: string; args: string[] } { +function dbCommand(type: 'mariadb' | 'mysql' | 'postgres', mode: 'dump' | 'restore'): { command: string; args: string[] } { if (type === 'postgres') { return mode === 'dump' ? { command: 'pg_dump', args: ['-U', 'db', '-d', 'db', '--clean', '--if-exists'] } : { command: 'psql', args: ['-U', 'db', '-d', 'db', '-v', 'ON_ERROR_STOP=1'] } } + if (type === 'mysql') { + return mode === 'dump' + ? { command: 'mysqldump', args: ['-udb', '-pdb', '--single-transaction', '--routines', '--triggers', 'db'] } + : { command: 'mysql', args: ['-udb', '-pdb', 'db'] } + } return mode === 'dump' ? { command: 'mariadb-dump', args: ['-udb', '-pdb', '--single-transaction', '--routines', '--triggers', 'db'] } : { command: 'mariadb', args: ['-udb', '-pdb', 'db'] } } -function runDatabasePipe(root: string, type: 'mariadb' | 'postgres', mode: 'dump' | 'restore', filePath: string): Promise { +function runDatabasePipe(root: string, type: 'mariadb' | 'mysql' | 'postgres', mode: 'dump' | 'restore', filePath: string): Promise { return new Promise((resolve, reject) => { const db = dbCommand(type, mode) const child = spawn('docker', ['compose', '-f', composeFile(root), 'exec', '-T', 'db', db.command, ...db.args], { diff --git a/src/renderer/src/components/create/CreateProjectModal.tsx b/src/renderer/src/components/create/CreateProjectModal.tsx index 48f8623..a92fa02 100644 --- a/src/renderer/src/components/create/CreateProjectModal.tsx +++ b/src/renderer/src/components/create/CreateProjectModal.tsx @@ -42,7 +42,7 @@ export function CreateProjectModal({ onClose }: { onClose: () => void }): React. const [phpVersion, setPhpVersion] = useState('8.4') const [nodeVersion, setNodeVersion] = useState('24') const [webServer, setWebServer] = useState<'nginx' | 'apache'>('nginx') - const [database, setDatabase] = useState<'mariadb' | 'postgres'>('mariadb') + const [database, setDatabase] = useState<'mariadb' | 'mysql' | 'postgres'>('mariadb') const [databaseVersion, setDatabaseVersion] = useState('11.8') const [adminer, setAdminer] = useState(true) const [redis, setRedis] = useState(false) @@ -275,7 +275,7 @@ export function CreateProjectModal({ onClose }: { onClose: () => void }): React.
-
+
{[['Adminer',adminer,setAdminer],['Redis',redis,setRedis],['Mailpit',mailpit,setMailpit],['Xdebug',xdebug,setXdebug]].map(([label,value,setter])=>)}
diff --git a/src/shared/types.ts b/src/shared/types.ts index 2232900..8618810 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -88,7 +88,7 @@ export interface AuroraStackOptions { phpVersion: string nodeVersion: string webServer: 'nginx' | 'apache' - database: 'mariadb' | 'postgres' + database: 'mariadb' | 'mysql' | 'postgres' databaseVersion: string adminer: boolean redis: boolean @@ -143,7 +143,7 @@ export interface AuroraModuleManifest { settings: AuroraModuleSetting[] aurora: { core: string; moduleApi: string } creation?: { - databases?: Array<'mariadb' | 'postgres'> + databases?: Array<'mariadb' | 'mysql' | 'postgres'> setup?: AuroraModuleSetting[] intro?: { title: string; description: string; icon?: string } }