brignano 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/publish.yml +1 -1
- package/demo.gif +0 -0
- package/dist/banner.js +57 -0
- package/dist/card.js +76 -118
- package/dist/cardBox.js +44 -0
- package/dist/data.js +34 -0
- package/dist/env.js +48 -0
- package/dist/live.js +40 -0
- package/dist/menu.js +73 -0
- package/dist/qrcode.js +8 -0
- package/dist/reveal.js +19 -0
- package/dist/vcard.js +40 -0
- package/package.json +18 -5
- package/readme.md +53 -38
- package/src/banner.ts +66 -0
- package/src/card.ts +81 -116
- package/src/cardBox.ts +64 -0
- package/src/data.ts +38 -0
- package/src/env.ts +69 -0
- package/src/live.ts +58 -0
- package/src/menu.ts +84 -0
- package/src/qrcode.ts +9 -0
- package/src/reveal.ts +25 -0
- package/src/types/qrcode-terminal.d.ts +13 -0
- package/src/vcard.ts +41 -0
- package/vhs/demo.tape +40 -0
package/.github/workflows/ci.yml
CHANGED
package/demo.gif
CHANGED
|
Binary file
|
package/dist/banner.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import figlet from 'figlet';
|
|
2
|
+
import gradient from 'gradient-string';
|
|
3
|
+
import { sleep } from './reveal.js';
|
|
4
|
+
// Brand palette — matches brignano.io's electric indigo/violet accent
|
|
5
|
+
// (violet-700 → violet-500 → violet-400). Reads well on a dark terminal.
|
|
6
|
+
const BRAND = ['#6d28d9', '#8b5cf6', '#a78bfa'];
|
|
7
|
+
// A longer ramp with a bright crest (violet-300) used for the shimmer sweep.
|
|
8
|
+
const SHIMMER = [
|
|
9
|
+
'#5b21b6',
|
|
10
|
+
'#6d28d9',
|
|
11
|
+
'#7c3aed',
|
|
12
|
+
'#8b5cf6',
|
|
13
|
+
'#a78bfa',
|
|
14
|
+
'#c4b5fd',
|
|
15
|
+
'#a78bfa',
|
|
16
|
+
'#8b5cf6',
|
|
17
|
+
'#7c3aed',
|
|
18
|
+
'#6d28d9',
|
|
19
|
+
];
|
|
20
|
+
function bannerArt(text) {
|
|
21
|
+
try {
|
|
22
|
+
return figlet.textSync(text, { font: 'ANSI Shadow' });
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return text.toUpperCase();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function paint(colors, art) {
|
|
29
|
+
try {
|
|
30
|
+
return gradient(colors).multiline(art);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return art;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Static gradient banner (used for the non-animated path).
|
|
37
|
+
export function renderBanner(text = 'brignano') {
|
|
38
|
+
return paint(BRAND, bannerArt(text));
|
|
39
|
+
}
|
|
40
|
+
// Animated splash: a violet highlight sweeps across the letters, then settles on
|
|
41
|
+
// the static brand gradient. Redraws in place via ANSI cursor moves, so it must
|
|
42
|
+
// only be called on a TTY (the caller gates this behind `shouldAnimate`).
|
|
43
|
+
export async function animateBanner(text = 'brignano', frames = 14, frameMs = 70) {
|
|
44
|
+
const art = bannerArt(text);
|
|
45
|
+
const lineCount = art.split('\n').length;
|
|
46
|
+
for (let i = 0; i < frames; i++) {
|
|
47
|
+
const offset = i % SHIMMER.length;
|
|
48
|
+
const rotated = SHIMMER.slice(offset).concat(SHIMMER.slice(0, offset));
|
|
49
|
+
if (i > 0)
|
|
50
|
+
process.stdout.write(`\u001b[${lineCount}A`);
|
|
51
|
+
process.stdout.write(`\r${paint(rotated, art)}\n`);
|
|
52
|
+
await sleep(frameMs);
|
|
53
|
+
}
|
|
54
|
+
// Settle on the canonical brand gradient.
|
|
55
|
+
process.stdout.write(`\u001b[${lineCount}A`);
|
|
56
|
+
process.stdout.write(`${renderBanner(text)}\n`);
|
|
57
|
+
}
|
package/dist/card.js
CHANGED
|
@@ -1,126 +1,84 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import boxen from 'boxen';
|
|
3
2
|
import chalk from 'chalk';
|
|
4
3
|
import inquirer from 'inquirer';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { animateBanner, renderBanner } from './banner.js';
|
|
5
|
+
import { renderCard } from './cardBox.js';
|
|
6
|
+
import { funFacts, pick, profile, taglines } from './data.js';
|
|
7
|
+
import { clearConsole, isInteractive, parseFlags, shouldAnimate, shouldFetchLive, } from './env.js';
|
|
8
|
+
import { fetchLive } from './live.js';
|
|
9
|
+
import { buildChoices, sendEmail, viewResume } from './menu.js';
|
|
10
|
+
import { renderQr } from './qrcode.js';
|
|
11
|
+
import { reveal, sleep } from './reveal.js';
|
|
12
|
+
import { writeAndOpenVCard } from './vcard.js';
|
|
13
|
+
function printHelp() {
|
|
14
|
+
console.log('\nUsage: npx brignano [options]\n');
|
|
15
|
+
console.log('Options:');
|
|
16
|
+
console.log(' -h, --help Show this help');
|
|
17
|
+
console.log(' -v, --view Open my resume in your browser');
|
|
18
|
+
console.log(' -e, --email Open your mail client to email me');
|
|
19
|
+
console.log(' --qr Print a scannable QR code to my website');
|
|
20
|
+
console.log(' --vcard Save my contact card (.vcf) and open it');
|
|
21
|
+
console.log(' --no-animation Render instantly, skip the reveal animation');
|
|
22
|
+
console.log(' --no-prompt Show the card only (non-interactive)');
|
|
23
|
+
console.log(' -d, --download Deprecated alias for --view\n');
|
|
24
|
+
}
|
|
25
|
+
async function main() {
|
|
26
|
+
const argv = process.argv.slice(2);
|
|
27
|
+
const flags = parseFlags(argv);
|
|
28
|
+
// Direct-action flags short-circuit the full experience.
|
|
29
|
+
if (flags.help)
|
|
30
|
+
return printHelp();
|
|
31
|
+
if (flags.view || flags.download) {
|
|
32
|
+
if (flags.download) {
|
|
33
|
+
console.warn('Note: --download is deprecated; opening the resume instead.');
|
|
10
34
|
}
|
|
11
|
-
|
|
35
|
+
return viewResume();
|
|
12
36
|
}
|
|
13
|
-
if (
|
|
14
|
-
|
|
37
|
+
if (flags.email)
|
|
38
|
+
return sendEmail();
|
|
39
|
+
if (flags.qr) {
|
|
40
|
+
console.log(await renderQr(profile.website));
|
|
41
|
+
console.log(chalk.gray(` ${profile.website}\n`));
|
|
42
|
+
return;
|
|
15
43
|
}
|
|
44
|
+
if (flags.vcard)
|
|
45
|
+
return writeAndOpenVCard();
|
|
46
|
+
const animate = shouldAnimate(flags);
|
|
47
|
+
const interactive = isInteractive(flags);
|
|
48
|
+
// Kick off the live fetch early (don't await yet) so its timeout budget
|
|
49
|
+
// overlaps the banner render. Skipped entirely when non-interactive/CI.
|
|
50
|
+
const livePromise = shouldFetchLive(flags) ? fetchLive() : Promise.resolve(null);
|
|
51
|
+
clearConsole();
|
|
52
|
+
// Banner first: an animated violet shimmer when we can animate, otherwise the
|
|
53
|
+
// static gradient.
|
|
54
|
+
if (animate) {
|
|
55
|
+
await animateBanner();
|
|
56
|
+
await sleep(120);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
console.log(renderBanner());
|
|
60
|
+
}
|
|
61
|
+
// Card, enriched with whatever the (bounded) live fetch returned.
|
|
62
|
+
const live = await livePromise;
|
|
63
|
+
const tagline = pick(taglines);
|
|
64
|
+
await reveal(renderCard({ live, tagline }), 30, animate);
|
|
65
|
+
console.log(`Tip: ${chalk.cyanBright.bold('cmd/ctrl + click')} the links above.`);
|
|
66
|
+
console.log(chalk.gray(` ${pick(funFacts)}\n`));
|
|
67
|
+
if (!interactive)
|
|
68
|
+
return;
|
|
69
|
+
const prompt = inquirer.createPromptModule();
|
|
70
|
+
const { action } = await prompt([
|
|
71
|
+
{
|
|
72
|
+
type: 'list',
|
|
73
|
+
name: 'action',
|
|
74
|
+
message: 'What would you like to do?',
|
|
75
|
+
choices: buildChoices(),
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
await action();
|
|
16
79
|
}
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type: 'list',
|
|
22
|
-
name: 'action',
|
|
23
|
-
message: 'What you want to do?',
|
|
24
|
-
choices: [
|
|
25
|
-
{
|
|
26
|
-
name: `Send me an ${chalk.green.bold('Email')}.`,
|
|
27
|
-
value: () => sendEmail(),
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: `View my ${chalk.magentaBright.bold('Resume')}.`,
|
|
31
|
-
value: () => viewResume(),
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: 'Just quit.',
|
|
35
|
-
value: () => {
|
|
36
|
-
console.log('Have a good day!\n');
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
function sendEmail() {
|
|
43
|
-
open('mailto:hi@brignano.io')
|
|
44
|
-
.then(() => {
|
|
45
|
-
console.log('\nDone, see you soon at inbox.\n');
|
|
46
|
-
})
|
|
47
|
-
.catch((err) => {
|
|
48
|
-
console.error('Failed to open mail client:', err && err.message ? err.message : err);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function viewResume() {
|
|
52
|
-
const resumeUrl = 'https://brignano.io/resume';
|
|
53
|
-
open(resumeUrl)
|
|
54
|
-
.then(() => {
|
|
55
|
-
console.log(`\nOpened resume: ${resumeUrl}\n`);
|
|
56
|
-
})
|
|
57
|
-
.catch((err) => {
|
|
58
|
-
console.error('Failed to open resume URL:', err && err.message ? err.message : err);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
const data = {
|
|
62
|
-
name: chalk.bold.green(' Anthony Brignano'),
|
|
63
|
-
handle: chalk.white('@brignano'),
|
|
64
|
-
work: `Senior Staff Software Engineer ${chalk.white('at')} ${chalk.hex('#3A5A78').bold('The Hartford')}`,
|
|
65
|
-
github: chalk.gray('https://github.com/') + chalk.green('brignano'),
|
|
66
|
-
linkedin: chalk.gray('https://linkedin.com/in/') + chalk.blue('brignano'),
|
|
67
|
-
web: chalk.cyan('https://brignano.io'),
|
|
68
|
-
npx: chalk.red('npx') + ' ' + chalk.white('brignano'),
|
|
69
|
-
labelWork: chalk.white.bold(' Work:'),
|
|
70
|
-
labelGitHub: chalk.white.bold(' GitHub:'),
|
|
71
|
-
labelLinkedIn: chalk.white.bold(' LinkedIn:'),
|
|
72
|
-
labelWeb: chalk.white.bold(' Website:'),
|
|
73
|
-
labelCard: chalk.white.bold(' Card:'),
|
|
74
|
-
};
|
|
75
|
-
const me = boxen([
|
|
76
|
-
`${data.name}`,
|
|
77
|
-
'',
|
|
78
|
-
`${data.labelWork} ${data.work}`,
|
|
79
|
-
'',
|
|
80
|
-
`${data.labelGitHub} ${data.github}`,
|
|
81
|
-
`${data.labelLinkedIn} ${data.linkedin}`,
|
|
82
|
-
`${data.labelWeb} ${data.web}`,
|
|
83
|
-
'',
|
|
84
|
-
`${data.labelCard} ${data.npx}`,
|
|
85
|
-
'',
|
|
86
|
-
`${chalk.italic("My inbox is always open. Whether you have a")}`,
|
|
87
|
-
`${chalk.italic("question or just want to say hi, I will try")}`,
|
|
88
|
-
`${chalk.italic("my best to get back to you! :)")}`,
|
|
89
|
-
].join('\n'), {
|
|
90
|
-
margin: 1,
|
|
91
|
-
float: 'center',
|
|
92
|
-
padding: 1,
|
|
93
|
-
borderStyle: 'single',
|
|
94
|
-
borderColor: 'green',
|
|
80
|
+
main().catch((err) => {
|
|
81
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
82
|
+
console.error(`Something went wrong: ${message}`);
|
|
83
|
+
process.exitCode = 1;
|
|
95
84
|
});
|
|
96
|
-
console.log(me);
|
|
97
|
-
const tip = [`Tip: Try ${chalk.cyanBright.bold('cmd/ctrl + click')} on the links above`, ''].join('\n');
|
|
98
|
-
console.log(tip);
|
|
99
|
-
// Simple argument parsing
|
|
100
|
-
const argv = process.argv.slice(2);
|
|
101
|
-
if (argv.includes('--help') || argv.includes('-h')) {
|
|
102
|
-
console.log('\nUsage: npx brignano [options]\n');
|
|
103
|
-
console.log('Options:');
|
|
104
|
-
console.log(' -h, --help Show this help');
|
|
105
|
-
console.log(' -v, --view Open resume in browser (https://brignano.io/resume)');
|
|
106
|
-
console.log(' -d, --download Deprecated: previously downloaded resume — now opens resume in browser');
|
|
107
|
-
console.log(' -e, --email Open mail client to email me');
|
|
108
|
-
console.log(' --no-prompt Show card only (non-interactive)\n');
|
|
109
|
-
}
|
|
110
|
-
else if (argv.includes('--view') || argv.includes('-v')) {
|
|
111
|
-
viewResume();
|
|
112
|
-
}
|
|
113
|
-
else if (argv.includes('--download') || argv.includes('-d')) {
|
|
114
|
-
console.warn('Warning: `--download` is deprecated and now opens the resume in your browser.');
|
|
115
|
-
viewResume();
|
|
116
|
-
}
|
|
117
|
-
else if (argv.includes('--email') || argv.includes('-e')) {
|
|
118
|
-
sendEmail();
|
|
119
|
-
}
|
|
120
|
-
else if (argv.includes('--no-prompt') || argv.includes('--quiet')) {
|
|
121
|
-
console.log('\nExiting in non-interactive mode (--no-prompt).');
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
|
-
prompt(questions).then((answer) => answer.action());
|
|
126
|
-
}
|
package/dist/cardBox.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import boxen from 'boxen';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { profile } from './data.js';
|
|
4
|
+
// Right-aligns labels to a common width so the values line up cleanly.
|
|
5
|
+
const LABEL_WIDTH = 10;
|
|
6
|
+
function label(text) {
|
|
7
|
+
return chalk.white.bold(text.padStart(LABEL_WIDTH) + ':');
|
|
8
|
+
}
|
|
9
|
+
// Builds the boxen business card. `live` is optional — when absent the live
|
|
10
|
+
// line is simply omitted, so the card looks intentional with or without network.
|
|
11
|
+
export function renderCard({ live, tagline }) {
|
|
12
|
+
// Violet accent matches brignano.io (violet-400 #a78bfa on dark).
|
|
13
|
+
const accent = chalk.hex('#a78bfa');
|
|
14
|
+
const lines = [
|
|
15
|
+
accent.bold(profile.fullName) + ' ' + chalk.gray(profile.handle),
|
|
16
|
+
'',
|
|
17
|
+
`${label('Work')} ${profile.title} ${chalk.gray('at')} ${chalk
|
|
18
|
+
.hex('#3A5A78')
|
|
19
|
+
.bold(profile.org)}`,
|
|
20
|
+
'',
|
|
21
|
+
`${label('GitHub')} ${chalk.gray('https://github.com/')}${chalk.green(profile.username)}`,
|
|
22
|
+
`${label('LinkedIn')} ${chalk.gray('https://linkedin.com/in/')}${chalk.blue(profile.username)}`,
|
|
23
|
+
`${label('Website')} ${chalk.cyan(profile.website)}`,
|
|
24
|
+
];
|
|
25
|
+
if (live) {
|
|
26
|
+
lines.push('');
|
|
27
|
+
const parts = [
|
|
28
|
+
`${chalk.yellow('★')} ${chalk.bold(live.followers)} followers`,
|
|
29
|
+
`${chalk.bold(live.publicRepos)} repos`,
|
|
30
|
+
];
|
|
31
|
+
if (live.latestRepo) {
|
|
32
|
+
parts.push(`latest: ${chalk.green(live.latestRepo.name)}`);
|
|
33
|
+
}
|
|
34
|
+
lines.push(`${label('Live')} ${chalk.gray(parts.join(' · '))}`);
|
|
35
|
+
}
|
|
36
|
+
lines.push('', `${label('Card')} ${chalk.red('npx')} ${chalk.white('brignano')}`, '', chalk.italic(tagline));
|
|
37
|
+
return boxen(lines.join('\n'), {
|
|
38
|
+
margin: 1,
|
|
39
|
+
float: 'center',
|
|
40
|
+
padding: 1,
|
|
41
|
+
borderStyle: 'round',
|
|
42
|
+
borderColor: 'gray',
|
|
43
|
+
});
|
|
44
|
+
}
|
package/dist/data.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Single source of truth for everything the card, vCard, QR and live modules need.
|
|
2
|
+
// Plain (uncolored) values live here; chalk styling is applied at render time.
|
|
3
|
+
export const profile = {
|
|
4
|
+
firstName: 'Anthony',
|
|
5
|
+
lastName: 'Brignano',
|
|
6
|
+
fullName: 'Anthony Brignano',
|
|
7
|
+
handle: '@brignano',
|
|
8
|
+
username: 'brignano',
|
|
9
|
+
title: 'Senior Staff Software Engineer',
|
|
10
|
+
org: 'The Hartford',
|
|
11
|
+
email: 'hi@brignano.io',
|
|
12
|
+
website: 'https://brignano.io',
|
|
13
|
+
resume: 'https://brignano.io/resume',
|
|
14
|
+
github: 'https://github.com/brignano',
|
|
15
|
+
linkedin: 'https://linkedin.com/in/brignano',
|
|
16
|
+
};
|
|
17
|
+
// Rotating taglines — one is picked per run so repeat visitors see variety.
|
|
18
|
+
export const taglines = [
|
|
19
|
+
'My inbox is always open. Ask a question or just say hi — I read everything.',
|
|
20
|
+
'Building reliable systems, mentoring engineers, and shipping things that last.',
|
|
21
|
+
"If it's worth automating, it's worth a clean abstraction. Let's build.",
|
|
22
|
+
'Self-hoster, spec-driven, and unreasonably fond of a tidy terminal.',
|
|
23
|
+
'Good engineering is mostly good taste applied consistently. Say hello.',
|
|
24
|
+
];
|
|
25
|
+
// Small easter-egg facts, shown occasionally below the card.
|
|
26
|
+
export const funFacts = [
|
|
27
|
+
'This card is open source — `npx brignano --help` shows every trick.',
|
|
28
|
+
'Tip: scan the QR with your phone to save my contact instantly.',
|
|
29
|
+
'The live stats above are pulled fresh from GitHub (with a strict timeout).',
|
|
30
|
+
];
|
|
31
|
+
// Deterministic-enough pick without Math.random (kept simple + dependency-free).
|
|
32
|
+
export function pick(items, seed = Date.now()) {
|
|
33
|
+
return items[Math.floor(seed / 1000) % items.length];
|
|
34
|
+
}
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Environment + capability detection. Keeps the render logic free of scattered
|
|
2
|
+
// `process.stdout.isTTY` checks and guarantees CI / piped output never hangs.
|
|
3
|
+
export function hasFlag(argv, names) {
|
|
4
|
+
return names.some((n) => argv.includes(n));
|
|
5
|
+
}
|
|
6
|
+
export function parseFlags(argv) {
|
|
7
|
+
return {
|
|
8
|
+
help: hasFlag(argv, ['--help', '-h']),
|
|
9
|
+
view: hasFlag(argv, ['--view', '-v']),
|
|
10
|
+
download: hasFlag(argv, ['--download', '-d']),
|
|
11
|
+
email: hasFlag(argv, ['--email', '-e']),
|
|
12
|
+
qr: hasFlag(argv, ['--qr']),
|
|
13
|
+
vcard: hasFlag(argv, ['--vcard', '--save-contact']),
|
|
14
|
+
noPrompt: hasFlag(argv, ['--no-prompt', '--quiet']),
|
|
15
|
+
noAnimation: hasFlag(argv, ['--no-animation']),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const isCI = () => Boolean(process.env.CI);
|
|
19
|
+
// True only when we can safely show an interactive inquirer prompt.
|
|
20
|
+
export function isInteractive(flags) {
|
|
21
|
+
return Boolean(process.stdout.isTTY && process.stdin.isTTY && !isCI() && !flags.noPrompt);
|
|
22
|
+
}
|
|
23
|
+
// True only when the reveal animation should play.
|
|
24
|
+
export function shouldAnimate(flags) {
|
|
25
|
+
return Boolean(process.stdout.isTTY &&
|
|
26
|
+
!isCI() &&
|
|
27
|
+
!flags.noPrompt &&
|
|
28
|
+
!flags.noAnimation &&
|
|
29
|
+
!process.env.NO_COLOR);
|
|
30
|
+
}
|
|
31
|
+
// True only when we should spend time on a live network fetch.
|
|
32
|
+
export function shouldFetchLive(flags) {
|
|
33
|
+
return isInteractive(flags);
|
|
34
|
+
}
|
|
35
|
+
export function clearConsole() {
|
|
36
|
+
const out = process.stdout;
|
|
37
|
+
if (typeof out.clear === 'function') {
|
|
38
|
+
try {
|
|
39
|
+
out.clear();
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
/* ignore */
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (process.stdout.isTTY) {
|
|
46
|
+
process.stdout.write('\u001b[2J\u001b[0f');
|
|
47
|
+
}
|
|
48
|
+
}
|
package/dist/live.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { profile } from './data.js';
|
|
2
|
+
const API = 'https://api.github.com';
|
|
3
|
+
const HEADERS = {
|
|
4
|
+
'User-Agent': 'npx-brignano',
|
|
5
|
+
Accept: 'application/vnd.github+json',
|
|
6
|
+
};
|
|
7
|
+
// Fetches live GitHub stats with a hard timeout. ANY failure (timeout, offline,
|
|
8
|
+
// non-200, rate-limit, parse error) resolves to null — this never throws and
|
|
9
|
+
// never blocks the card for longer than `timeoutMs`.
|
|
10
|
+
export async function fetchLive(timeoutMs = 1500) {
|
|
11
|
+
const controller = new AbortController();
|
|
12
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
13
|
+
try {
|
|
14
|
+
const [userRes, reposRes] = await Promise.all([
|
|
15
|
+
fetch(`${API}/users/${profile.username}`, {
|
|
16
|
+
headers: HEADERS,
|
|
17
|
+
signal: controller.signal,
|
|
18
|
+
}),
|
|
19
|
+
fetch(`${API}/users/${profile.username}/repos?sort=updated&per_page=1`, { headers: HEADERS, signal: controller.signal }),
|
|
20
|
+
]);
|
|
21
|
+
if (!userRes.ok || !reposRes.ok)
|
|
22
|
+
return null;
|
|
23
|
+
const user = (await userRes.json());
|
|
24
|
+
const repos = (await reposRes.json());
|
|
25
|
+
const latest = Array.isArray(repos) ? repos[0] : undefined;
|
|
26
|
+
return {
|
|
27
|
+
followers: user.followers ?? 0,
|
|
28
|
+
publicRepos: user.public_repos ?? 0,
|
|
29
|
+
latestRepo: latest?.name && latest?.html_url
|
|
30
|
+
? { name: latest.name, url: latest.html_url }
|
|
31
|
+
: undefined,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
}
|
|
40
|
+
}
|
package/dist/menu.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import clipboard from 'clipboardy';
|
|
3
|
+
import open from 'open';
|
|
4
|
+
import { profile } from './data.js';
|
|
5
|
+
import { renderQr } from './qrcode.js';
|
|
6
|
+
import { buildVCard, writeAndOpenVCard } from './vcard.js';
|
|
7
|
+
// --- Action helpers (kept as named functions so flags and the menu share them) ---
|
|
8
|
+
export async function copyEmail() {
|
|
9
|
+
try {
|
|
10
|
+
await clipboard.write(profile.email);
|
|
11
|
+
console.log(`\n${chalk.green('Copied')} ${profile.email} to your clipboard.\n`);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
// Clipboard access fails in headless/SSH environments — degrade gracefully.
|
|
15
|
+
console.log(`\nMy email is ${chalk.green(profile.email)} — drop me a line!\n`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function sendEmail() {
|
|
19
|
+
try {
|
|
20
|
+
await open(`mailto:${profile.email}`);
|
|
21
|
+
console.log('\nOpened your mail client — see you in the inbox.\n');
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
25
|
+
console.error(`Failed to open mail client: ${message}`);
|
|
26
|
+
console.error(`Reach me directly at ${profile.email}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export async function openUrl(url, label) {
|
|
30
|
+
try {
|
|
31
|
+
await open(url);
|
|
32
|
+
console.log(`\nOpened ${label}: ${url}\n`);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
36
|
+
console.error(`Failed to open ${label}: ${message}`);
|
|
37
|
+
console.error(`Here it is: ${url}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function viewResume() {
|
|
41
|
+
await openUrl(profile.resume, 'resume');
|
|
42
|
+
}
|
|
43
|
+
export async function showContactQr() {
|
|
44
|
+
const qr = await renderQr(buildVCard());
|
|
45
|
+
console.log('\nScan to save my contact:\n');
|
|
46
|
+
console.log(qr);
|
|
47
|
+
}
|
|
48
|
+
export function buildChoices() {
|
|
49
|
+
return [
|
|
50
|
+
{ name: `Copy my ${chalk.green.bold('email')} to clipboard`, value: copyEmail },
|
|
51
|
+
{ name: `Send me an ${chalk.green.bold('email')}`, value: sendEmail },
|
|
52
|
+
{
|
|
53
|
+
name: `Open my ${chalk.green.bold('GitHub')}`,
|
|
54
|
+
value: () => openUrl(profile.github, 'GitHub'),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: `Open my ${chalk.blue.bold('LinkedIn')}`,
|
|
58
|
+
value: () => openUrl(profile.linkedin, 'LinkedIn'),
|
|
59
|
+
},
|
|
60
|
+
{ name: `View my ${chalk.magentaBright.bold('resume')}`, value: viewResume },
|
|
61
|
+
{
|
|
62
|
+
name: `Save my ${chalk.cyan.bold('contact')} (.vcf)`,
|
|
63
|
+
value: writeAndOpenVCard,
|
|
64
|
+
},
|
|
65
|
+
{ name: `Show a ${chalk.yellow.bold('contact QR')} code`, value: showContactQr },
|
|
66
|
+
{
|
|
67
|
+
name: 'Just quit',
|
|
68
|
+
value: () => {
|
|
69
|
+
console.log('\nHave a great day!\n');
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
}
|
package/dist/qrcode.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import qrcode from 'qrcode-terminal';
|
|
2
|
+
// Promisified wrapper around qrcode-terminal's callback API. `small: true` keeps
|
|
3
|
+
// the code compact enough for most terminals.
|
|
4
|
+
export function renderQr(text) {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
qrcode.generate(text, { small: true }, (output) => resolve(output));
|
|
7
|
+
});
|
|
8
|
+
}
|
package/dist/reveal.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Tiny animation helpers — no dependencies. Line-by-line reveal is immune to the
|
|
2
|
+
// ANSI-escape-splitting problem a per-character typewriter would hit, and the
|
|
3
|
+
// total budget stays well under a second.
|
|
4
|
+
export function sleep(ms) {
|
|
5
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
6
|
+
}
|
|
7
|
+
// Prints `text` one line at a time, pausing `perLineMs` between lines.
|
|
8
|
+
// When `animate` is false, prints everything at once (CI / piped / --no-animation).
|
|
9
|
+
export async function reveal(text, perLineMs = 35, animate = true) {
|
|
10
|
+
if (!animate) {
|
|
11
|
+
console.log(text);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const lines = text.split('\n');
|
|
15
|
+
for (const line of lines) {
|
|
16
|
+
console.log(line);
|
|
17
|
+
await sleep(perLineMs);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/dist/vcard.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import open from 'open';
|
|
5
|
+
import { profile } from './data.js';
|
|
6
|
+
// Builds a valid vCard 3.0 string (broadest contact-app compatibility) with the
|
|
7
|
+
// spec-required CRLF line endings.
|
|
8
|
+
export function buildVCard() {
|
|
9
|
+
const lines = [
|
|
10
|
+
'BEGIN:VCARD',
|
|
11
|
+
'VERSION:3.0',
|
|
12
|
+
`N:${profile.lastName};${profile.firstName};;;`,
|
|
13
|
+
`FN:${profile.fullName}`,
|
|
14
|
+
`ORG:${profile.org}`,
|
|
15
|
+
`TITLE:${profile.title}`,
|
|
16
|
+
`EMAIL;TYPE=INTERNET,PREF:${profile.email}`,
|
|
17
|
+
`URL:${profile.website}`,
|
|
18
|
+
`X-SOCIALPROFILE;TYPE=github:${profile.github}`,
|
|
19
|
+
`X-SOCIALPROFILE;TYPE=linkedin:${profile.linkedin}`,
|
|
20
|
+
'NOTE:npx brignano',
|
|
21
|
+
'END:VCARD',
|
|
22
|
+
];
|
|
23
|
+
return lines.join('\r\n') + '\r\n';
|
|
24
|
+
}
|
|
25
|
+
// Writes the vCard to a temp file and asks the OS to open it (Contacts on
|
|
26
|
+
// macOS/iOS, the default handler elsewhere). On failure, prints the path so the
|
|
27
|
+
// user can open it manually — never throws.
|
|
28
|
+
export async function writeAndOpenVCard() {
|
|
29
|
+
const file = join(tmpdir(), 'anthony-brignano.vcf');
|
|
30
|
+
try {
|
|
31
|
+
writeFileSync(file, buildVCard(), 'utf8');
|
|
32
|
+
await open(file);
|
|
33
|
+
console.log(`\nSaved my contact card to: ${file}\n`);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
37
|
+
console.error(`\nCouldn't open the contact card automatically (${message}).`);
|
|
38
|
+
console.error(`It's saved here — open it manually: ${file}\n`);
|
|
39
|
+
}
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brignano",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/card.js",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=20"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
10
|
"brignano": "dist/card.js"
|
|
@@ -26,18 +26,31 @@
|
|
|
26
26
|
"url": "https://github.com/brignano/npx-brignano/issues"
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/brignano/npx-brignano#readme",
|
|
29
|
-
"keywords": [
|
|
29
|
+
"keywords": [
|
|
30
|
+
"npx",
|
|
31
|
+
"business-card",
|
|
32
|
+
"cli",
|
|
33
|
+
"brignano",
|
|
34
|
+
"resume",
|
|
35
|
+
"vcard"
|
|
36
|
+
],
|
|
30
37
|
"description": "A personal card for Anthony Brignano (@brignano)",
|
|
31
38
|
"dependencies": {
|
|
32
39
|
"boxen": "^6.0.0",
|
|
33
40
|
"chalk": "^5.2.0",
|
|
41
|
+
"clipboardy": "^5.0.0",
|
|
42
|
+
"figlet": "^1.11.0",
|
|
43
|
+
"gradient-string": "^3.0.0",
|
|
34
44
|
"inquirer": "^9.2.7",
|
|
35
|
-
"open": "^8.4.0"
|
|
45
|
+
"open": "^8.4.0",
|
|
46
|
+
"qrcode-terminal": "^0.12.0"
|
|
36
47
|
},
|
|
37
48
|
"devDependencies": {
|
|
38
49
|
"ts-node": "^10.9.1",
|
|
39
50
|
"typescript": "^5.1.6",
|
|
40
51
|
"@types/node": "^20.5.1",
|
|
41
|
-
"@types/inquirer": "^9.0.3"
|
|
52
|
+
"@types/inquirer": "^9.0.3",
|
|
53
|
+
"@types/figlet": "^1.7.0",
|
|
54
|
+
"@types/gradient-string": "^1.1.6"
|
|
42
55
|
}
|
|
43
56
|
}
|