refactor: clean up dead code and redundant checks
This commit is contained in:
parent
177c724fdf
commit
8a716964bb
3 changed files with 12 additions and 10 deletions
|
|
@ -191,7 +191,6 @@ export async function runCli(
|
||||||
|
|
||||||
// If help is requested for a specific command, show command-specific help
|
// If help is requested for a specific command, show command-specific help
|
||||||
if (wantsCommandHelp) {
|
if (wantsCommandHelp) {
|
||||||
const isHelpFlag = (arg: string) => arg === "--help" || arg === "-h";
|
|
||||||
const actualSubcommand = isHelpFlag(subcommand) ? undefined : subcommand;
|
const actualSubcommand = isHelpFlag(subcommand) ? undefined : subcommand;
|
||||||
showCommandHelp(command, cmdConf, actualSubcommand);
|
showCommandHelp(command, cmdConf, actualSubcommand);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -86,17 +86,13 @@ function collectResults(
|
||||||
addResult("Database URL format", isDbValid, isDbValid ? "valid" : "invalid");
|
addResult("Database URL format", isDbValid, isDbValid ? "valid" : "invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
const isConfigured =
|
const isForgejoConfigured =
|
||||||
config.forgejoBaseUrl && config.forgejoPat && config.forgejoBotUsername;
|
config.forgejoBaseUrl && config.forgejoPat && config.forgejoBotUsername;
|
||||||
|
|
||||||
if (!isConfigured) {
|
if (isForgejoConfigured) {
|
||||||
return results;
|
addResult("Forgejo configured", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { forgejoBaseUrl, forgejoPat, forgejoBotUsername } = config;
|
|
||||||
|
|
||||||
addResult("Forgejo configured", true);
|
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,13 +182,20 @@ async function verifyResults(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forgejoResults.length < 3) {
|
if (forgejoResults.length === 0) {
|
||||||
s.stop("No Forgejo configuration");
|
s.stop("No Forgejo configuration");
|
||||||
p.cancel(`${c.red("Error:")} Forgejo not configured`);
|
p.cancel(`${c.red("Error:")} Forgejo not configured`);
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (forgejoResults.length < 3) {
|
||||||
|
s.stop("Incomplete Forgejo checks");
|
||||||
|
p.cancel(`${c.red("Error:")} Could not complete all Forgejo checks`);
|
||||||
|
process.exitCode = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
s.stop("Verification complete");
|
s.stop("Verification complete");
|
||||||
|
|
||||||
const reachability = forgejoResults[0]!;
|
const reachability = forgejoResults[0]!;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export async function checkForgejoReachability(
|
||||||
): Promise<CheckResult> {
|
): Promise<CheckResult> {
|
||||||
try {
|
try {
|
||||||
const response = await fetchWithTimeout(baseUrl, { method: "GET" });
|
const response = await fetchWithTimeout(baseUrl, { method: "GET" });
|
||||||
if (response.ok || response.status === 200) {
|
if (response.ok) {
|
||||||
return createCheckResult("Forgejo reachability", true);
|
return createCheckResult("Forgejo reachability", true);
|
||||||
}
|
}
|
||||||
return createCheckResult(
|
return createCheckResult(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue