Skip to content

Commit

Permalink
fix: typo and colors
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfrosty committed Jan 3, 2025
1 parent ccbbc96 commit a4f64a4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-geese-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"solana": patch
---

fix typo and make spinner fail text red
78 changes: 37 additions & 41 deletions src/lib/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import {
import shellExec from "shell-exec";
import ora from "ora";
import { TOOL_CONFIG } from "@/const/setup";
import picocolors from "picocolors";

/**
* Check to see which debian/ubuntu dependencies
*/
export async function checkDebianDependenciesInstalled(
exitWhenMissing: boolean = true,
printInstallCommand: boolean = true,
): Promise<string[] | void> {
export async function checkDebianDependenciesInstalled(): Promise<
string[] | void
> {
const deps: string[] = [
"build-essential",
"pkg-config",
Expand Down Expand Up @@ -63,19 +63,6 @@ export async function checkDebianDependenciesInstalled(
});

if (missingDeps.length == 0) return;

if (printInstallCommand) {
console.log(
"sudo apt update && sudo apt install -y",
missingDeps.join(" "),
);
}

if (exitWhenMissing) {
console.error("Missing dependencies:", missingDeps.join(" "));
process.exit(0);
}

return missingDeps;
}

Expand All @@ -93,12 +80,21 @@ export async function installRust({ version }: InstallCommandPropsBase = {}) {
// if the user's system does not have `apt`, skip this check
if (os == "linux" && (await checkCommand(`apt --version`))) {
spinner.text = `Checking for required linux dependencies`;
const missingDeps = await checkDebianDependenciesInstalled(true, true);
const missingDeps = await checkDebianDependenciesInstalled();
if (missingDeps && missingDeps.length > 0) {
throw (
`Your system is missing required system dependencies: ` +
missingDeps.join(" ")
spinner.fail(
picocolors.red(`Missing dependencies: ${missingDeps.join(" ")}`),
);

console.log(
"Install the missing dependencies using the following command:",
);
console.log(
"sudo apt update && sudo apt install -y",
missingDeps.join(" "),
);

process.exit(0);
}
}

Expand Down Expand Up @@ -129,11 +125,11 @@ export async function installRust({ version }: InstallCommandPropsBase = {}) {
spinner.succeed(`rust ${installedVersion} installed`);
return installedVersion;
} else {
spinner.fail("rust failed to install");
spinner.fail(picocolors.red("rust failed to install"));
return false;
}
} catch (err) {
spinner.fail("Unable to install rust");
spinner.fail(picocolors.red("Unable to install rust"));

if (typeof err == "string") console.error(err);
else if (err instanceof Error) console.error(err.message);
Expand Down Expand Up @@ -187,11 +183,11 @@ export async function installSolana({
spinner.succeed(`solana ${installedVersion} installed`);
return installedVersion;
} else {
spinner.fail("solana failed to install");
spinner.fail(picocolors.red("solana failed to install"));
return false;
}
} catch (err) {
spinner.fail("Unable to install the Solana CLI tool suite");
spinner.fail(picocolors.red("Unable to install the Solana CLI tool suite"));
if (typeof err == "string") console.error(err);
else if (err instanceof Error) console.error(err.message);
else console.error(err.message);
Expand Down Expand Up @@ -237,11 +233,11 @@ export async function installAnchorVersionManager({
spinner.succeed(`avm ${installedVersion} installed`);
return installedVersion;
} else {
spinner.fail("avm failed to install");
spinner.fail(picocolors.red("avm failed to install"));
return false;
}
} catch (err) {
spinner.fail("Unable to install avm");
spinner.fail(picocolors.red("Unable to install avm"));
if (typeof err == "string") console.error(err);
else if (err instanceof Error) console.error(err.message);
else console.error(err.message);
Expand Down Expand Up @@ -318,11 +314,11 @@ export async function installAnchorUsingAvm({
spinner.succeed(`anchor ${installedVersion} installed using avm`);
return installedVersion;
} else {
spinner.fail("anchor failed to install");
spinner.fail(picocolors.red("anchor failed to install"));
return false;
}
} catch (err) {
spinner.fail("Unable to install anchor using avm");
spinner.fail(picocolors.red("Unable to install anchor using avm"));
if (typeof err == "string") console.error(err);
else if (err instanceof Error) console.error(err.message);
else console.error(err.message);
Expand Down Expand Up @@ -354,11 +350,11 @@ export async function installYarn({}: InstallCommandPropsBase = {}) {
spinner.succeed(`yarn ${installedVersion} installed`);
return installedVersion;
} else {
spinner.fail("yarn package manager failed to install");
spinner.fail(picocolors.red("yarn package manager failed to install"));
return false;
}
} catch (err) {
spinner.fail("Unable to install yarn package manager");
spinner.fail(picocolors.red("Unable to install yarn package manager"));
if (typeof err == "string") console.error(err);
else if (err instanceof Error) console.error(err.message);
else console.error(err.message);
Expand All @@ -381,7 +377,7 @@ export async function installMucho({}: InstallCommandPropsBase = {}) {
return true;
}

spinner.text = `Installing the2 mucho cli`;
spinner.text = `Installing the mucho cli`;
await shellExec(`npm install -g mucho`);

spinner.text = "Verifying mucho was installed";
Expand All @@ -390,11 +386,11 @@ export async function installMucho({}: InstallCommandPropsBase = {}) {
spinner.succeed(`mucho ${installedVersion} installed`);
return installedVersion;
} else {
spinner.fail("mucho cli failed to install");
spinner.fail(picocolors.red("mucho cli failed to install"));
return false;
}
} catch (err) {
spinner.fail("Unable to install the mucho cli");
spinner.fail(picocolors.red("Unable to install the mucho cli"));
if (typeof err == "string") console.error(err);
else if (err instanceof Error) console.error(err.message);
else console.error(err.message);
Expand Down Expand Up @@ -422,7 +418,7 @@ export async function installTrident({
if (verifyParentCommand) {
const isParentInstalled = await installedToolVersion("rust");
if (!isParentInstalled) {
spinner.fail("Rust/cargo was not found");
spinner.fail(picocolors.red("Rust/cargo was not found"));
throw "parent command not found";
}
}
Expand All @@ -447,11 +443,11 @@ export async function installTrident({
spinner.succeed(`trident ${installedVersion} installed`);
return installedVersion;
} else {
spinner.fail("trident failed to install");
spinner.fail(picocolors.red("trident failed to install"));
return false;
}
} catch (err) {
spinner.fail("Unable to install the trident fuzzer");
spinner.fail(picocolors.red("Unable to install the trident fuzzer"));
if (typeof err == "string") console.error(err);
else if (err instanceof Error) console.error(err.message);
else console.error(err.message);
Expand Down Expand Up @@ -534,11 +530,11 @@ export async function installZest({
spinner.succeed(`zest ${installedVersion} installed`);
return installedVersion;
} else {
spinner.fail("zest failed to install");
spinner.fail(picocolors.red("zest failed to install"));
return false;
}
} catch (err) {
spinner.fail("Unable to install zest");
spinner.fail(picocolors.red("Unable to install zest"));
if (typeof err == "string") console.error(err);
else if (err instanceof Error) console.error(err.message);
else console.error(err.message);
Expand Down Expand Up @@ -611,11 +607,11 @@ export async function installSolanaVerify({
await isDockerInstalled();
return installedVersion;
} else {
spinner.fail("solana-verify failed to install");
spinner.fail(picocolors.red("solana-verify failed to install"));
return false;
}
} catch (err) {
spinner.fail("Unable to install solana-verify");
spinner.fail(picocolors.red("Unable to install solana-verify"));
if (typeof err == "string") console.error(err);
else if (err instanceof Error) console.error(err.message);
else console.error(err.message);
Expand Down

0 comments on commit a4f64a4

Please sign in to comment.