Conf files should be treated as a dict, file names are unique

This commit is contained in:
MattIPv4
2020-06-04 14:58:41 +01:00
parent 7444fa6f77
commit bc04209423
3 changed files with 39 additions and 35 deletions

View File

@@ -38,59 +38,56 @@ import drupalConf from './conf/drupal.conf';
import magentoConf from './conf/magento.conf';
export default (domains, global) => {
const files = [];
const files = {};
// Base nginx config
files.push(['nginx.conf', toConf(nginxConf(domains, global))]);
files['nginx.conf'] = toConf(nginxConf(domains, global));
// Modularised configs
if (global.tools.modularizedStructure.computed) {
// Domain config
for (const domain of domains) {
files.push([
`sites-${global.tools.symlinkVhost.computed ? 'available' : 'enabled'}/${domain.server.domain.computed}.conf`,
toConf(websiteConf(domain, domains, global)),
]);
files[`sites-${global.tools.symlinkVhost.computed ? 'available' : 'enabled'}/${domain.server.domain.computed}.conf`] = toConf(websiteConf(domain, domains, global));
}
// Let's encrypt
if (domains.some(d => d.https.certType.computed === 'letsEncrypt'))
files.push(['nginxconfig.io/letsencrypt.conf', toConf(letsEncryptConf(global))]);
files['nginxconfig.io/letsencrypt.conf'] = toConf(letsEncryptConf(global));
// Security
files.push(['nginxconfig.io/security.conf', toConf(securityConf(domains, global))]);
files['nginxconfig.io/security.conf'] = toConf(securityConf(domains, global));
// General
files.push(['nginxconfig.io/general.conf', toConf(generalConf(domains, global))]);
files['nginxconfig.io/general.conf'] = toConf(generalConf(domains, global));
// PHP
if (domains.some(d => d.php.php.computed))
files.push(['nginxconfig.io/php_fastcgi.conf', toConf(phpConf(domains, global))]);
files['nginxconfig.io/php_fastcgi.conf'] = toConf(phpConf(domains, global));
// Python
if (domains.some(d => d.python.python.computed))
files.push(['nginxconfig.io/python_uwsgi.conf', toConf(pythonConf(global))]);
files['nginxconfig.io/python_uwsgi.conf'] = toConf(pythonConf(global));
// Reverse proxy
if (domains.some(d => d.reverseProxy.reverseProxy.computed))
files.push(['nginxconfig.io/proxy.conf', toConf(proxyConf())]);
files['nginxconfig.io/proxy.conf'] = toConf(proxyConf());
// WordPress
if (domains.some(d => d.php.wordPressRules.computed))
files.push(['nginxconfig.io/wordpress.conf', toConf(wordPressConf(global))]);
files['nginxconfig.io/wordpress.conf'] = toConf(wordPressConf(global));
// Drupal
if (domains.some(d => d.php.drupalRules.computed))
files.push(['nginxconfig.io/drupal.conf', toConf(drupalConf(global))]);
files['nginxconfig.io/drupal.conf'] = toConf(drupalConf(global));
// Drupal
if (domains.some(d => d.php.magentoRules.computed))
files.push(['nginxconfig.io/magento.conf', toConf(magentoConf())]);
files['nginxconfig.io/magento.conf'] = toConf(magentoConf());
} else {
// PHP
if (domains.some(d => d.php.wordPressRules.computed))
files.push(['nginxconfig.io/php_fastcgi.conf', toConf(phpConf(domains, global))]);
files['nginxconfig.io/php_fastcgi.conf'] = toConf(phpConf(domains, global));
}
return files;