Skip to content

Commit a4f64a4

Browse files
committed
fix: typo and colors
1 parent ccbbc96 commit a4f64a4

File tree

2 files changed

+42
-41
lines changed

2 files changed

+42
-41
lines changed

.changeset/eight-geese-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"solana": patch
3+
---
4+
5+
fix typo and make spinner fail text red

src/lib/install.ts

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import {
1212
import shellExec from "shell-exec";
1313
import ora from "ora";
1414
import { TOOL_CONFIG } from "@/const/setup";
15+
import picocolors from "picocolors";
1516

1617
/**
1718
* Check to see which debian/ubuntu dependencies
1819
*/
19-
export async function checkDebianDependenciesInstalled(
20-
exitWhenMissing: boolean = true,
21-
printInstallCommand: boolean = true,
22-
): Promise<string[] | void> {
20+
export async function checkDebianDependenciesInstalled(): Promise<
21+
string[] | void
22+
> {
2323
const deps: string[] = [
2424
"build-essential",
2525
"pkg-config",
@@ -63,19 +63,6 @@ export async function checkDebianDependenciesInstalled(
6363
});
6464

6565
if (missingDeps.length == 0) return;
66-
67-
if (printInstallCommand) {
68-
console.log(
69-
"sudo apt update && sudo apt install -y",
70-
missingDeps.join(" "),
71-
);
72-
}
73-
74-
if (exitWhenMissing) {
75-
console.error("Missing dependencies:", missingDeps.join(" "));
76-
process.exit(0);
77-
}
78-
7966
return missingDeps;
8067
}
8168

@@ -93,12 +80,21 @@ export async function installRust({ version }: InstallCommandPropsBase = {}) {
9380
// if the user's system does not have `apt`, skip this check
9481
if (os == "linux" && (await checkCommand(`apt --version`))) {
9582
spinner.text = `Checking for required linux dependencies`;
96-
const missingDeps = await checkDebianDependenciesInstalled(true, true);
83+
const missingDeps = await checkDebianDependenciesInstalled();
9784
if (missingDeps && missingDeps.length > 0) {
98-
throw (
99-
`Your system is missing required system dependencies: ` +
100-
missingDeps.join(" ")
85+
spinner.fail(
86+
picocolors.red(`Missing dependencies: ${missingDeps.join(" ")}`),
87+
);
88+
89+
console.log(
90+
"Install the missing dependencies using the following command:",
10191
);
92+
console.log(
93+
"sudo apt update && sudo apt install -y",
94+
missingDeps.join(" "),
95+
);
96+
97+
process.exit(0);
10298
}
10399
}
104100

@@ -129,11 +125,11 @@ export async function installRust({ version }: InstallCommandPropsBase = {}) {
129125
spinner.succeed(`rust ${installedVersion} installed`);
130126
return installedVersion;
131127
} else {
132-
spinner.fail("rust failed to install");
128+
spinner.fail(picocolors.red("rust failed to install"));
133129
return false;
134130
}
135131
} catch (err) {
136-
spinner.fail("Unable to install rust");
132+
spinner.fail(picocolors.red("Unable to install rust"));
137133

138134
if (typeof err == "string") console.error(err);
139135
else if (err instanceof Error) console.error(err.message);
@@ -187,11 +183,11 @@ export async function installSolana({
187183
spinner.succeed(`solana ${installedVersion} installed`);
188184
return installedVersion;
189185
} else {
190-
spinner.fail("solana failed to install");
186+
spinner.fail(picocolors.red("solana failed to install"));
191187
return false;
192188
}
193189
} catch (err) {
194-
spinner.fail("Unable to install the Solana CLI tool suite");
190+
spinner.fail(picocolors.red("Unable to install the Solana CLI tool suite"));
195191
if (typeof err == "string") console.error(err);
196192
else if (err instanceof Error) console.error(err.message);
197193
else console.error(err.message);
@@ -237,11 +233,11 @@ export async function installAnchorVersionManager({
237233
spinner.succeed(`avm ${installedVersion} installed`);
238234
return installedVersion;
239235
} else {
240-
spinner.fail("avm failed to install");
236+
spinner.fail(picocolors.red("avm failed to install"));
241237
return false;
242238
}
243239
} catch (err) {
244-
spinner.fail("Unable to install avm");
240+
spinner.fail(picocolors.red("Unable to install avm"));
245241
if (typeof err == "string") console.error(err);
246242
else if (err instanceof Error) console.error(err.message);
247243
else console.error(err.message);
@@ -318,11 +314,11 @@ export async function installAnchorUsingAvm({
318314
spinner.succeed(`anchor ${installedVersion} installed using avm`);
319315
return installedVersion;
320316
} else {
321-
spinner.fail("anchor failed to install");
317+
spinner.fail(picocolors.red("anchor failed to install"));
322318
return false;
323319
}
324320
} catch (err) {
325-
spinner.fail("Unable to install anchor using avm");
321+
spinner.fail(picocolors.red("Unable to install anchor using avm"));
326322
if (typeof err == "string") console.error(err);
327323
else if (err instanceof Error) console.error(err.message);
328324
else console.error(err.message);
@@ -354,11 +350,11 @@ export async function installYarn({}: InstallCommandPropsBase = {}) {
354350
spinner.succeed(`yarn ${installedVersion} installed`);
355351
return installedVersion;
356352
} else {
357-
spinner.fail("yarn package manager failed to install");
353+
spinner.fail(picocolors.red("yarn package manager failed to install"));
358354
return false;
359355
}
360356
} catch (err) {
361-
spinner.fail("Unable to install yarn package manager");
357+
spinner.fail(picocolors.red("Unable to install yarn package manager"));
362358
if (typeof err == "string") console.error(err);
363359
else if (err instanceof Error) console.error(err.message);
364360
else console.error(err.message);
@@ -381,7 +377,7 @@ export async function installMucho({}: InstallCommandPropsBase = {}) {
381377
return true;
382378
}
383379

384-
spinner.text = `Installing the2 mucho cli`;
380+
spinner.text = `Installing the mucho cli`;
385381
await shellExec(`npm install -g mucho`);
386382

387383
spinner.text = "Verifying mucho was installed";
@@ -390,11 +386,11 @@ export async function installMucho({}: InstallCommandPropsBase = {}) {
390386
spinner.succeed(`mucho ${installedVersion} installed`);
391387
return installedVersion;
392388
} else {
393-
spinner.fail("mucho cli failed to install");
389+
spinner.fail(picocolors.red("mucho cli failed to install"));
394390
return false;
395391
}
396392
} catch (err) {
397-
spinner.fail("Unable to install the mucho cli");
393+
spinner.fail(picocolors.red("Unable to install the mucho cli"));
398394
if (typeof err == "string") console.error(err);
399395
else if (err instanceof Error) console.error(err.message);
400396
else console.error(err.message);
@@ -422,7 +418,7 @@ export async function installTrident({
422418
if (verifyParentCommand) {
423419
const isParentInstalled = await installedToolVersion("rust");
424420
if (!isParentInstalled) {
425-
spinner.fail("Rust/cargo was not found");
421+
spinner.fail(picocolors.red("Rust/cargo was not found"));
426422
throw "parent command not found";
427423
}
428424
}
@@ -447,11 +443,11 @@ export async function installTrident({
447443
spinner.succeed(`trident ${installedVersion} installed`);
448444
return installedVersion;
449445
} else {
450-
spinner.fail("trident failed to install");
446+
spinner.fail(picocolors.red("trident failed to install"));
451447
return false;
452448
}
453449
} catch (err) {
454-
spinner.fail("Unable to install the trident fuzzer");
450+
spinner.fail(picocolors.red("Unable to install the trident fuzzer"));
455451
if (typeof err == "string") console.error(err);
456452
else if (err instanceof Error) console.error(err.message);
457453
else console.error(err.message);
@@ -534,11 +530,11 @@ export async function installZest({
534530
spinner.succeed(`zest ${installedVersion} installed`);
535531
return installedVersion;
536532
} else {
537-
spinner.fail("zest failed to install");
533+
spinner.fail(picocolors.red("zest failed to install"));
538534
return false;
539535
}
540536
} catch (err) {
541-
spinner.fail("Unable to install zest");
537+
spinner.fail(picocolors.red("Unable to install zest"));
542538
if (typeof err == "string") console.error(err);
543539
else if (err instanceof Error) console.error(err.message);
544540
else console.error(err.message);
@@ -611,11 +607,11 @@ export async function installSolanaVerify({
611607
await isDockerInstalled();
612608
return installedVersion;
613609
} else {
614-
spinner.fail("solana-verify failed to install");
610+
spinner.fail(picocolors.red("solana-verify failed to install"));
615611
return false;
616612
}
617613
} catch (err) {
618-
spinner.fail("Unable to install solana-verify");
614+
spinner.fail(picocolors.red("Unable to install solana-verify"));
619615
if (typeof err == "string") console.error(err);
620616
else if (err instanceof Error) console.error(err.message);
621617
else console.error(err.message);

0 commit comments

Comments
 (0)