-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·64 lines (49 loc) · 2.99 KB
/
cli.js
File metadata and controls
executable file
·64 lines (49 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
import chalk from 'chalk';
import { getRandomContent } from './index.js';
const purple = chalk.hex('#C27AFF');
const green = chalk.hex('#05DF72');
const yellow = chalk.hex('#FFDF20');
const orange = chalk.hex('#FF8904');
const cyan = chalk.cyan;
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
async function showMessage() {
console.error('\n');
console.error(cyan('// Frontend Masters'));
console.error(cyan('// Level up your skills'));
console.error('');
const item = getRandomContent();
const isTip = item.type === 'Tip';
const title = isTip ? '💡 FRONTEND MASTERS' : '🎓 FEATURED PATH';
const label = isTip ? 'Tip: ' : '';
await sleep(200);
console.error(yellow('┌─────────────────────────────────────────────────────────────────┐'));
// Center the title
const titleStr = title;
const tPadLeft = Math.floor((65 - titleStr.length) / 2);
const tPadRight = 65 - titleStr.length - tPadLeft;
console.error(yellow('│') + ' '.repeat(tPadLeft) + chalk.bold.white(titleStr) + ' '.repeat(tPadRight) + yellow('│'));
console.error(yellow('│') + ' ' + yellow('│'));
// Format category centered
const categoryStr = `Category: ${item.category}`;
const paddingLeft = Math.floor((65 - categoryStr.length) / 2);
const paddingRight = 65 - categoryStr.length - paddingLeft;
console.error(yellow('│') + ' '.repeat(paddingLeft) + orange(categoryStr) + ' '.repeat(paddingRight) + yellow('│'));
console.error(yellow('│') + ' ' + yellow('│'));
console.error(yellow('└─────────────────────────────────────────────────────────────────┘'));
console.error('\n');
console.error(chalk.bold.white(label + item.content));
console.error('\n');
await sleep(100);
console.error(purple(isTip ? '🚀 Start the Path:' : '🚀 Start Learning:'));
console.error(chalk.underline.cyan(item.link));
console.error('\n');
console.error(purple('═══════════════════════════════════════════════════════════════════'));
console.error('\n');
console.error(' ' + chalk.bold.white('👉 Browse all learning paths:'));
console.error(' ' + chalk.underline.cyan('https://frontendmasters.com/learn/'));
console.error('\n');
console.error(purple('═══════════════════════════════════════════════════════════════════'));
console.error('\n');
}
showMessage().catch(console.error);