feat: add Drupal application module

This commit is contained in:
reaper
2026-08-14 22:41:10 -05:00
parent ee67f5ef20
commit 68237f8b68
13 changed files with 131 additions and 12 deletions
+5
View File
@@ -0,0 +1,5 @@
# Aurora Drupal module
Installs Drupal 11 from `drupal/recommended-project`, adds Drush, and performs an unattended site installation against the Aurora project database.
The project uses Drupal's recommended `web/` document root. The project toolbar provides a cache-rebuild action through Drush.
@@ -0,0 +1,39 @@
'use strict'
function containerUser() {
if (typeof process.getuid !== 'function') return []
return ['--user', `${process.getuid()}:${process.getgid()}`]
}
function compose(context, ...args) {
return ['compose', '-f', `${context.directory}/.aurora/compose.yaml`, ...args]
}
function phpExec(context, ...args) {
return compose(context, 'exec', '-T', ...containerUser(), '-e', 'HOME=/tmp', '-e', 'COMPOSER_HOME=/tmp/composer', 'php', ...args)
}
function databaseUrl(context) {
const driver = context.environment.database === 'postgres' ? 'pgsql' : 'mysql'
return `${driver}://db:db@db:3306/db`.replace(':3306/', context.environment.database === 'postgres' ? ':5432/' : ':3306/')
}
exports.projectCreate = async function projectCreate(context) {
const settings = context.settings
const siteName = String(settings.site_name || '').trim() || context.projectName
const temporaryProject = '/tmp/aurora-drupal-project'
await context.ensureRouter()
await context.run('Start project services', 'docker', compose(context, 'up', '-d', '--build', '--remove-orphans'))
await context.run('Download Drupal 11', 'docker', phpExec(context, 'sh', '-lc', `rm -rf ${temporaryProject} && composer create-project drupal/recommended-project:^11 ${temporaryProject} --no-interaction --no-progress && cp -a ${temporaryProject}/. /var/www/html/ && rm -rf ${temporaryProject}`))
await context.run('Install Drush', 'docker', phpExec(context, 'composer', 'require', 'drush/drush:^13', '--no-interaction', '--no-progress'))
await context.run('Install Drupal', 'docker', phpExec(context, 'vendor/bin/drush', 'site:install', String(settings.profile || 'standard'), `--db-url=${databaseUrl(context)}`, `--site-name=${siteName}`, `--account-name=${settings.admin_user}`, `--account-pass=${settings.admin_password}`, `--account-mail=${settings.admin_email}`, '--yes'))
await context.run('Prepare writable files', 'docker', phpExec(context, 'sh', '-lc', 'mkdir -p web/sites/default/files && chmod 0777 web/sites/default/files'))
await context.run('Verify Drupal', 'docker', phpExec(context, 'vendor/bin/drush', 'status', '--field=drupal-version'))
await context.setProjectMetadata({ drupalVersion: 'Drupal 11' })
await context.saveCredentials({ platform: context.moduleId, adminUrl: `${context.urls.https}/user/login`, username: String(settings.admin_user), password: String(settings.admin_password), email: String(settings.admin_email) })
}
exports.projectTool = async function projectTool(context) {
if (context.toolId !== 'rebuild-cache') throw new Error(`Unknown Drupal tool '${context.toolId}'`)
await context.run('Rebuild Drupal cache', 'docker', phpExec(context, 'vendor/bin/drush', 'cache:rebuild'))
}
@@ -0,0 +1,34 @@
{
"id": "drupal",
"name": "Drupal",
"version": "1.0.0",
"category": "application",
"description": "Drupal 11 CMS with Composer, Drush, and the recommended web-root layout.",
"main": "main/index.cjs",
"aurora": { "core": "2.0.0-alpha.24", "moduleApi": "1.0.0" },
"dependencies": [],
"conflicts": [],
"defaults": { "docroot": "web" },
"settings": [],
"creation": {
"databases": ["mariadb", "mysql", "postgres"],
"phpVersions": ["8.4", "8.3"],
"intro": {
"title": "Drupal 11 install",
"description": "Composer downloads Drupal and Drush, then Aurora configures the site automatically.",
"icon": "globe"
},
"setup": [
{ "id": "site_name", "label": "Site name", "type": "text", "default": "", "placeholder": "My Drupal Site", "required": true, "icon": "title", "span": 2 },
{ "id": "admin_user", "label": "Admin username", "type": "text", "default": "admin", "required": true, "icon": "user" },
{ "id": "admin_password", "label": "Admin password", "type": "text", "default": "", "required": true, "secret": true, "icon": "key" },
{ "id": "admin_email", "label": "Admin email", "type": "text", "default": "", "required": true, "placeholder": "[email protected]", "icon": "mail", "span": 2 },
{ "id": "profile", "label": "Installation profile", "type": "select", "default": "standard", "advanced": true, "icon": "settings", "options": ["standard", "minimal", "demo_umami"], "optionLabels": { "standard": "Standard", "minimal": "Minimal", "demo_umami": "Umami demo" } }
]
},
"project": {
"adminPath": "/admin/",
"summary": { "metadataKey": "drupalVersion", "labels": {}, "fallback": "Drupal 11" },
"tools": [{ "id": "rebuild-cache", "label": "Rebuild Drupal cache" }]
}
}
@@ -0,0 +1,7 @@
{
"name": "@aurora/module-drupal",
"version": "1.0.0",
"private": true,
"description": "Drupal application module for Aurora Dockside",
"files": ["manifest.json", "main", "README.md"]
}