Split project-type setup into pluggable registry; add WordPress admin link and delete flow
This commit is contained in:
+24
-20
@@ -34,8 +34,13 @@ export function registerCreateIpc(): void {
|
||||
// the web container. Kept as two separate tracked operations rather than
|
||||
// one combined command so each phase's terminal:exit event correctly owns
|
||||
// its own status-bar/toast lifecycle (see useCreateProject.ts).
|
||||
ipcMain.handle('create:downloadWordpress', (event, operationId: string, directory: string) =>
|
||||
runStreamed(operationId, ['wp', 'core', 'download'], event.sender, { cwd: directory })
|
||||
ipcMain.handle(
|
||||
'create:downloadWordpress',
|
||||
(event, operationId: string, directory: string, locale: string) => {
|
||||
const args = ['wp', 'core', 'download']
|
||||
if (locale.trim() && locale.trim() !== 'en_US') args.push(`--locale=${locale.trim()}`)
|
||||
return runStreamed(operationId, args, event.sender, { cwd: directory })
|
||||
}
|
||||
)
|
||||
|
||||
ipcMain.handle(
|
||||
@@ -48,23 +53,22 @@ export function registerCreateIpc(): void {
|
||||
title: string,
|
||||
adminUser: string,
|
||||
adminPassword: string,
|
||||
adminEmail: string
|
||||
) =>
|
||||
runStreamed(
|
||||
operationId,
|
||||
[
|
||||
'wp',
|
||||
'core',
|
||||
'install',
|
||||
`--url=${siteUrl}`,
|
||||
`--title=${title}`,
|
||||
`--admin_user=${adminUser}`,
|
||||
`--admin_password=${adminPassword}`,
|
||||
`--admin_email=${adminEmail}`,
|
||||
'--skip-email'
|
||||
],
|
||||
event.sender,
|
||||
{ cwd: directory }
|
||||
)
|
||||
adminEmail: string,
|
||||
multisite: 'none' | 'subdirectory' | 'subdomain'
|
||||
) => {
|
||||
const args = [
|
||||
'wp',
|
||||
'core',
|
||||
multisite === 'none' ? 'install' : 'multisite-install',
|
||||
`--url=${siteUrl}`,
|
||||
`--title=${title}`,
|
||||
`--admin_user=${adminUser}`,
|
||||
`--admin_password=${adminPassword}`,
|
||||
`--admin_email=${adminEmail}`,
|
||||
'--skip-email'
|
||||
]
|
||||
if (multisite === 'subdomain') args.push('--subdomains')
|
||||
return runStreamed(operationId, args, event.sender, { cwd: directory })
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,8 +11,12 @@ export function registerProjectsIpc(): void {
|
||||
ipcMain.handle('projects:stop', (event, operationId: string, name: string) =>
|
||||
runStreamed(operationId, ['stop', name], event.sender)
|
||||
)
|
||||
// `-y` matters here beyond convenience: we spawn `ddev` with no stdin
|
||||
// wired up (see commandRunner.ts), so any confirmation prompt ddev tries
|
||||
// to show — e.g. when a database type change requires it — would hang the
|
||||
// operation forever with no way for the user to answer it.
|
||||
ipcMain.handle('projects:restart', (event, operationId: string, name: string) =>
|
||||
runStreamed(operationId, ['restart', name], event.sender)
|
||||
runStreamed(operationId, ['restart', name, '-y'], event.sender)
|
||||
)
|
||||
// Removes DDEV's project registration + containers + database (auto-
|
||||
// snapshotted first, unless omitted) — does not touch the project's files
|
||||
@@ -20,4 +24,33 @@ export function registerProjectsIpc(): void {
|
||||
ipcMain.handle('projects:delete', (event, operationId: string, name: string) =>
|
||||
runStreamed(operationId, ['delete', name, '--yes'], event.sender)
|
||||
)
|
||||
|
||||
// Reconfigures a project's PHP version, web server, database, or Xdebug
|
||||
// state via `ddev config` (writes .ddev/config.yaml) — callers are
|
||||
// expected to follow a successful call with a restart (if the project is
|
||||
// running) to actually apply it, same two-phase pattern as create.ts.
|
||||
ipcMain.handle(
|
||||
'projects:updateEnvironment',
|
||||
(
|
||||
event,
|
||||
operationId: string,
|
||||
name: string,
|
||||
approot: string,
|
||||
updates: {
|
||||
phpVersion?: string
|
||||
webserverType?: string
|
||||
database?: string
|
||||
xdebugEnabled?: boolean
|
||||
}
|
||||
) => {
|
||||
const args = ['config', `--project-name=${name}`]
|
||||
if (updates.phpVersion) args.push(`--php-version=${updates.phpVersion}`)
|
||||
if (updates.webserverType) args.push(`--webserver-type=${updates.webserverType}`)
|
||||
if (updates.database) args.push(`--database=${updates.database}`)
|
||||
if (updates.xdebugEnabled !== undefined) {
|
||||
args.push(`--xdebug-enabled=${updates.xdebugEnabled}`)
|
||||
}
|
||||
return runStreamed(operationId, args, event.sender, { cwd: approot })
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user