feat: add native Adminer database access
This commit is contained in:
@@ -68,6 +68,22 @@ http {
|
||||
server_name localhost;
|
||||
root "${quoteNginx(webroot)}";
|
||||
index index.php index.html;
|
||||
location = /__aurora/adminer/ {
|
||||
fastcgi_pass 127.0.0.1:${project.ports.php};
|
||||
fastcgi_param SCRIPT_FILENAME "${quoteNginx(join(directory, 'adminer.php'))}";
|
||||
fastcgi_param SCRIPT_NAME /__aurora/adminer/;
|
||||
fastcgi_param REQUEST_METHOD $request_method;
|
||||
fastcgi_param REQUEST_URI $request_uri;
|
||||
fastcgi_param QUERY_STRING $query_string;
|
||||
fastcgi_param CONTENT_TYPE $content_type;
|
||||
fastcgi_param CONTENT_LENGTH $content_length;
|
||||
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
||||
fastcgi_param SERVER_NAME $server_name;
|
||||
fastcgi_param SERVER_PORT $server_port;
|
||||
fastcgi_param HTTP_HOST $http_host;
|
||||
fastcgi_param REMOTE_ADDR $remote_addr;
|
||||
fastcgi_param REMOTE_PORT $remote_port;
|
||||
}
|
||||
location / { try_files $uri $uri/ /index.php?$query_string; }
|
||||
location ~ \\.php$ {
|
||||
fastcgi_pass 127.0.0.1:${project.ports.php};
|
||||
@@ -92,6 +108,30 @@ http {
|
||||
`
|
||||
}
|
||||
|
||||
export function renderNativeAdminerBootstrap(project: NativeProjectDefinition): string {
|
||||
const adminer = join(installedRoot(project), 'root', 'usr', 'share', 'aurora', 'adminer.php')
|
||||
return `<?php
|
||||
// Generated by Aurora Core. This endpoint binds only to the project's loopback server.
|
||||
?>
|
||||
<script>
|
||||
addEventListener('DOMContentLoaded', () => {
|
||||
const username = document.querySelector('input[name="auth[username]"]');
|
||||
if (!username) return;
|
||||
const form = username.form;
|
||||
form.querySelector('input[name="auth[server]"]').value = '127.0.0.1:${project.ports.database}';
|
||||
username.value = 'db';
|
||||
form.querySelector('input[name="auth[password]"]').value = 'db';
|
||||
form.querySelector('input[name="auth[db]"]').value = 'db';
|
||||
const permanent = form.querySelector('input[name="auth[permanent]"]');
|
||||
if (permanent) permanent.checked = true;
|
||||
form.submit();
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
require '${adminer.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}';
|
||||
`
|
||||
}
|
||||
|
||||
export function renderMariaDbConfig(
|
||||
project: NativeProjectDefinition,
|
||||
installedRuntimeRoot = runtimeRoot()
|
||||
@@ -128,6 +168,7 @@ export async function provisionNativeProject(project: NativeProjectDefinition):
|
||||
await Promise.all([
|
||||
writeFile(join(directory, 'config', 'php-fpm.conf'), renderPhpFpmConfig(project)),
|
||||
writeFile(join(directory, 'config', 'nginx.conf'), renderNginxConfig(project)),
|
||||
writeFile(join(directory, 'adminer.php'), renderNativeAdminerBootstrap(project)),
|
||||
writeFile(
|
||||
join(directory, 'config', 'mariadb.cnf'),
|
||||
renderMariaDbConfig(project, installedRoot(project))
|
||||
|
||||
Reference in New Issue
Block a user