|
1 | 1 | #!/usr/bin/env node
|
2 |
| -// 👆 Used to tell Node.js that this is a CLI tool |
3 | 2 |
|
4 |
| -// Pull in our modules |
5 |
| -const chalk = require('chalk') |
6 | 3 | const boxen = require('boxen')
|
| 4 | +const chalk = require('chalk') |
| 5 | +const leftPad = require('left-pad') |
7 | 6 |
|
8 |
| -// Define options for Boxen |
9 |
| -const options = { |
| 7 | +const boxenOptions = { |
10 | 8 | padding: 1,
|
11 | 9 | margin: 1,
|
12 |
| - borderStyle: 'round' |
| 10 | + borderStyle: 'round', |
13 | 11 | }
|
14 | 12 |
|
15 |
| -// Text + chalk definitions |
16 |
| -const data = { |
17 |
| - name: chalk.white('Tierney Cyren /'), |
18 |
| - handle: chalk.cyan('bitandbang'), |
19 |
| - work: chalk.white('Senior Cloud Developer Advocate at Microsoft'), |
20 |
| - twitter: chalk.cyan('https://twitter.com/bitandbang'), |
21 |
| - github: chalk.cyan('https://github.com/bnb'), |
22 |
| - linkedin: chalk.cyan('https://linkedin.com/in/bitandbang'), |
23 |
| - web: chalk.cyan('https://bnb.im'), |
24 |
| - npx: chalk.white('npx bitandbang'), |
25 |
| - labelWork: chalk.white.bold(' Work:'), |
26 |
| - labelTwitter: chalk.white.bold(' Twitter:'), |
27 |
| - labelGitHub: chalk.white.bold(' GitHub:'), |
28 |
| - labelLinkedIn: chalk.white.bold(' LinkedIn:'), |
29 |
| - labelWeb: chalk.white.bold(' Web:'), |
30 |
| - labelCard: chalk.white.bold(' Card:') |
31 |
| -} |
32 |
| - |
33 |
| -// Actual strings we're going to output |
34 | 13 | const newline = '\n'
|
35 |
| -const heading = `${data.name} ${data.handle}` |
36 |
| -const working = `${data.labelWork} ${data.work}` |
37 |
| -const twittering = `${data.labelTwitter} ${data.twitter}` |
38 |
| -const githubing = `${data.labelGitHub} ${data.github}` |
39 |
| -const linkedining = `${data.labelLinkedIn} ${data.linkedin}` |
40 |
| -const webing = `${data.labelWeb} ${data.web}` |
41 |
| -const carding = `${data.labelCard} ${data.npx}` |
| 14 | +const formatLabel = value => chalk.white.bold(leftPad(value, 12) + ':') |
| 15 | +const formatLink = value => chalk.cyan(value) |
| 16 | + |
| 17 | +const data = [ |
| 18 | + { |
| 19 | + label: chalk.white.bold('Michael Stramel'), |
| 20 | + value: '', |
| 21 | + }, |
| 22 | + { |
| 23 | + label: '', |
| 24 | + value: |
| 25 | + chalk.white('Software Engineer') + |
| 26 | + chalk.gray(' @ Coolfire Solutions') + |
| 27 | + newline, |
| 28 | + }, |
| 29 | + { |
| 30 | + label: formatLabel('Twitter'), |
| 31 | + value: formatLink('https://twitter.com/stramel89'), |
| 32 | + }, |
| 33 | + { |
| 34 | + label: formatLabel('GitHub'), |
| 35 | + value: formatLink('https://github.com/stramel'), |
| 36 | + }, |
| 37 | + { |
| 38 | + label: formatLabel('LinkedIn'), |
| 39 | + value: formatLink('https://linkedin.com/in/stramel'), |
| 40 | + }, |
| 41 | + { |
| 42 | + label: formatLabel('Website'), |
| 43 | + value: 'COMING SOON', |
| 44 | + }, |
| 45 | + { |
| 46 | + label: newline + chalk.cyan(leftPad('$', 13)), |
| 47 | + value: chalk.white('npx stramel'), |
| 48 | + }, |
| 49 | +] |
42 | 50 |
|
43 |
| -// Put all our output together into a single variable so we can use boxen effectively |
44 |
| -const output = heading + newline + newline + working + newline + twittering + newline + githubing + newline + linkedining + newline + webing + newline + newline + carding |
| 51 | +const output = data |
| 52 | + .map(({ label, value }) => `${label}${label && ' '}${value}`) |
| 53 | + .join(newline) |
45 | 54 |
|
46 |
| -console.log(chalk.green(boxen(output, options))) |
| 55 | +console.log(chalk.green(boxen(output, boxenOptions))) |
0 commit comments