chore:little fixes and formating and linting and patches

This commit is contained in:
2026-03-31 15:50:54 +02:00
parent a1ce71ffb6
commit 9b197abcfa
815 changed files with 22960 additions and 8982 deletions

View File

@@ -36,11 +36,11 @@ function generatePassword(length: number) {
function writeCaddyfile(domainName: string, basicAuthPassword: string) {
const caddyfileTemplatePath = path.resolve(
__dirname,
import.meta.dirname,
'caddy',
'Caddyfile.template',
'Caddyfile.template'
);
const caddyfilePath = path.resolve(__dirname, 'caddy', 'Caddyfile');
const caddyfilePath = path.resolve(import.meta.dirname, 'caddy', 'Caddyfile');
fs.writeFileSync(
caddyfilePath,
fs
@@ -48,12 +48,12 @@ function writeCaddyfile(domainName: string, basicAuthPassword: string) {
.replaceAll('$DOMAIN_NAME', domainName.replace(/https?:\/\//, ''))
.replaceAll(
'$BASIC_AUTH_PASSWORD',
bcrypt.hashSync(basicAuthPassword, 10),
bcrypt.hashSync(basicAuthPassword, 10)
)
.replaceAll(
'$SSL_CONFIG',
domainName.includes('localhost:443') ? '\n\ttls internal' : '',
),
domainName.includes('localhost:443') ? '\n\ttls internal' : ''
)
);
}
@@ -76,18 +76,24 @@ const stripTrailingSlash = (str: string) =>
str.endsWith('/') ? str.slice(0, -1) : str;
function searchAndReplaceDockerCompose(replacements: [string, string][]) {
const dockerComposePath = path.resolve(__dirname, 'docker-compose.yml');
const dockerComposePath = path.resolve(
import.meta.dirname,
'docker-compose.yml'
);
const dockerComposeContent = fs.readFileSync(dockerComposePath, 'utf-8');
const dockerComposeReplaced = replacements.reduce(
(acc, [search, replace]) => acc.replaceAll(search, replace),
dockerComposeContent,
dockerComposeContent
);
fs.writeFileSync(dockerComposePath, dockerComposeReplaced);
}
function removeServiceFromDockerCompose(serviceName: string) {
const dockerComposePath = path.resolve(__dirname, 'docker-compose.yml');
const dockerComposePath = path.resolve(
import.meta.dirname,
'docker-compose.yml'
);
const dockerComposeContent = fs.readFileSync(dockerComposePath, 'utf-8');
// Parse the YAML file
@@ -109,7 +115,7 @@ function removeServiceFromDockerCompose(serviceName: string) {
if (Array.isArray(serviceConfig.depends_on)) {
// Handle legacy array format
serviceConfig.depends_on = serviceConfig.depends_on.filter(
(dep) => dep !== serviceName,
(dep) => dep !== serviceName
);
} else {
// Handle new object format
@@ -139,8 +145,8 @@ function removeServiceFromDockerCompose(serviceName: string) {
}
function writeEnvFile(envs: EnvVars) {
const envTemplatePath = path.resolve(__dirname, '.env.template');
const envPath = path.resolve(__dirname, '.env');
const envTemplatePath = path.resolve(import.meta.dirname, '.env.template');
const envPath = path.resolve(import.meta.dirname, '.env');
const envTemplate = fs.readFileSync(envTemplatePath, 'utf-8');
const newEnvFile = envTemplate
@@ -161,7 +167,7 @@ function writeEnvFile(envs: EnvVars) {
.filter((line) => {
return !line.includes('=""');
})
.join('\n'),
.join('\n')
);
}
@@ -189,11 +195,11 @@ async function initiateOnboarding() {
];
console.log(
'******************************************************************************\n',
'******************************************************************************\n'
);
console.log(message.join('\n'));
console.log(
'\n******************************************************************************',
'\n******************************************************************************'
);
// Domain name
@@ -388,8 +394,8 @@ async function initiateOnboarding() {
console.log('Updating docker-compose.yml file...\n');
fs.copyFileSync(
path.resolve(__dirname, 'docker-compose.template.yml'),
path.resolve(__dirname, 'docker-compose.yml'),
path.resolve(import.meta.dirname, 'docker-compose.template.yml'),
path.resolve(import.meta.dirname, 'docker-compose.yml')
);
if (envs.CLICKHOUSE_URL) {
@@ -434,7 +440,7 @@ async function initiateOnboarding() {
`Start OpenPanel with "./start" inside the self-hosting directory`,
'',
'',
].join('\n'),
].join('\n')
);
}