Skip to content

Commit e019d8c

Browse files
Clean up (#63)
2 parents c433b91 + 60c2f42 commit e019d8c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.changeset/fair-parrots-drive.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eth-tech-tree": patch
3+
---
4+
5+
sort challenges, grey out challenges that don't exist, other styling changes

src/utils/tree.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ function getNodeLabel(node: TreeNode, depth: string = ""): string {
3737
if (isHeader) {
3838
return `${depth} ${chalk.blue(label)}`;
3939
} else if (!unlocked) {
40-
return `${depth} ${label} 🔒`;
40+
return `${depth} ${chalk.dim(label)}`;
4141
} else if (isChallenge) {
42-
return `${depth} ${label} ${completed ? "🏆" : "🗝️"}`;
42+
return `${depth} ${label} ${completed ? "🏆" : ""}`;
4343
} else if (isQuiz) {
4444
return `${depth} ${label} 📜`;
4545
} else if (isCapstoneProject) {
@@ -60,7 +60,7 @@ async function selectNode(node: TreeNode): Promise<void> {
6060
// - Show instructions for completing the challenge including a simple command to test their code
6161
// submit project, check if project passes tests then send proof of completion to the BG server, if it passes, mark the challenge as completed
6262
if (node.type !== "header" && !node.unlocked) {
63-
console.log("This challenge is locked because it doesn't exist yet... 😅");
63+
console.log("This challenge doesn't exist yet. 🤔 Consider contributing to the project here: https://github.com/BuidlGuidl/eth-tech-tree-challenges");
6464
await pressEnterToContinue();
6565
console.clear();
6666
await startVisualization(header);
@@ -233,12 +233,14 @@ export function buildTree(): TreeNode {
233233
return { label, name, level, type, actions, completed, childrenNames, parentName, unlocked, message: description };
234234
});
235235
const nestedChallenges = nestingMagic(transformedChallenges);
236+
237+
const sortedByUnlocked = nestedChallenges.sort((a: TreeNode, b: TreeNode) => {return a.unlocked ? -1 : 1});
236238

237239
tree.push({
238240
type: "header",
239241
label: `${tag} ${chalk.green(`(${completedCount}/${filteredChallenges.length})`)}`,
240242
name: `${tag.toLowerCase()}`,
241-
children: nestedChallenges,
243+
children: sortedByUnlocked,
242244
recursive: true
243245
});
244246
}

0 commit comments

Comments
 (0)