Comparing version 1.1.0 to 1.2.0
#! /usr/bin/env node | ||
import { select } from "@inquirer/prompts"; | ||
import { select as ask } from "@inquirer/prompts"; | ||
import chalk from "chalk"; | ||
import boxen from "boxen"; | ||
import box from "boxen"; | ||
import open from "open"; | ||
process.on("SIGINT", bye); | ||
process.on("SIGTERM", bye); | ||
process.on("uncaughtException", (error) => { | ||
if (error.name === "ExitPromptError") { | ||
bye(); | ||
} | ||
else { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
}); | ||
const handle = "jomifepe"; | ||
const location = `${chalk.green("Po")}${chalk.yellow("rt")}${chalk.red("ugal")}`; | ||
const work = { | ||
company: "Prismic", | ||
role: "Software Engineer", | ||
}; | ||
export const data = { | ||
export const info = { | ||
handle, | ||
name: "José Pereira", | ||
location: "Portugal", | ||
contact: `contact@${handle}.dev`, | ||
tools: "TypeScript, React, Node.js", | ||
role: "Software Engineer", | ||
company: "Prismic", | ||
links: { | ||
web: `${chalk.grey("https://")}${chalk.magenta(handle)}${chalk.grey(".dev")}`, | ||
github: `${chalk.grey("https://github.com/")}${chalk.green(handle)}`, | ||
twitter: `${chalk.grey("https://twitter.com/")}${chalk.cyan(handle)}`, | ||
npm: `${chalk.grey("https://npmjs.com/~")}${chalk.red(handle)}`, | ||
linkedin: `${chalk.grey("https://linkedin.com/in/")}${chalk.blue(handle)}`, | ||
medium: `${chalk.grey("https://medium.com/@")}${chalk.white(handle)}`, | ||
dev: `${chalk.grey("https://dev.to/")}${chalk.white(handle)}`, | ||
web: `https://${handle}.dev`, | ||
github: `https://github.com/${handle}`, | ||
twitter: `https://twitter.com/${handle}`, | ||
npm: `https://npmjs.com/~${handle}`, | ||
linkedin: `https://linkedin.com/in/${handle}`, | ||
medium: `https://medium.com/@${handle}`, | ||
dev: `https://dev.to/${handle}`, | ||
}, | ||
@@ -37,18 +45,17 @@ npx: `npx ${handle}`, | ||
}; | ||
const me = boxen([ | ||
chalk.white(`${chalk.bold(data.name)} / ${chalk.green(chalk.bold(data.handle))}`), | ||
``, | ||
` ${chalk.white(`Location: ${chalk.bold(location)}`)}`, | ||
` ${chalk.white(`Work: ${work.role} at ${chalk.blueBright(chalk.bold(work.company))}`)}`, | ||
``, | ||
` ${chalk.white(`${linkLabels.web}: ${data.links.web}`)}`, | ||
` ${chalk.white(`${linkLabels.github}: ${data.links.github}`)}`, | ||
` ${chalk.white(`${linkLabels.twitter}: ${data.links.twitter}`)}`, | ||
` ${chalk.white(`${linkLabels.linkedin}: ${data.links.linkedin}`)}`, | ||
` ${chalk.white(`${linkLabels.npm}: ${data.links.npm}`)}`, | ||
` ${chalk.white(`${linkLabels.medium}: ${data.links.medium}`)}`, | ||
` ${chalk.white(`${linkLabels.dev}: ${data.links.dev}`)}`, | ||
``, | ||
` ${chalk.white(`Card: ${chalk.greenBright(data.npx)}`)}`, | ||
].join("\n"), { | ||
const card = `${chalk.white(`${chalk.bold(info.name)} / ${chalk.green(chalk.bold(info.handle))}`)} | ||
${chalk.white(`Location: ${tugaify(info.location)}`)} | ||
${chalk.white(`Work: ${info.role} at ${chalk.blueBright(chalk.bold(info.company))}`)} | ||
${chalk.white(`${linkLabels.web}: ${colorizeLink(info.links.web, "magenta")}`)} | ||
${chalk.white(`${linkLabels.github}: ${colorizeLink(info.links.github, "green")}`)} | ||
${chalk.white(`${linkLabels.twitter}: ${colorizeLink(info.links.twitter, "cyan")}`)} | ||
${chalk.white(`${linkLabels.linkedin}: ${colorizeLink(info.links.linkedin, "blue")}`)} | ||
${chalk.white(`${linkLabels.npm}: ${colorizeLink(info.links.npm, "red")}`)} | ||
${chalk.white(`${linkLabels.medium}: ${colorizeLink(info.links.medium, "white")}`)} | ||
${chalk.white(`${linkLabels.dev}: ${colorizeLink(info.links.dev, "white")}`)} | ||
${chalk.white(`Card: ${chalk.greenBright(info.npx)}`)}`; | ||
console.info(box(card, { | ||
margin: { top: 1, bottom: 1 }, | ||
@@ -59,5 +66,4 @@ padding: 1, | ||
width: 70, | ||
}); | ||
console.info(me); | ||
const option = await select({ | ||
})); | ||
const option = await ask({ | ||
message: "What do you want to do?", | ||
@@ -70,24 +76,39 @@ choices: [ | ||
}); | ||
console.log(); | ||
if (option === "email") { | ||
open(`mailto:${data.contact}`); | ||
console.log("📧 Looking forward to hearing from you!"); | ||
switch (option) { | ||
case "email": { | ||
open(`mailto:${info.contact}`); | ||
console.log("\n📧 Looking forward to hearing from you!\n"); | ||
break; | ||
} | ||
case "link": { | ||
const link = await ask({ | ||
message: "Which link do you want to open?", | ||
choices: Object.keys(info.links).map((link) => ({ | ||
value: link, | ||
name: linkLabels[link], | ||
})), | ||
}); | ||
open(info.links[link]); | ||
bye(); | ||
break; | ||
} | ||
case "quit": { | ||
bye(); | ||
break; | ||
} | ||
} | ||
else if (option === "link") { | ||
const link = await select({ | ||
message: "Which link do you want to open?", | ||
choices: Object.keys(data.links).map((link) => ({ | ||
value: link, | ||
name: linkLabels[link], | ||
})), | ||
function colorizeLink(link, style) { | ||
return chalk.grey(link.replace(new RegExp(info.handle, "gi"), (match) => chalk[style](match))); | ||
} | ||
function tugaify(value) { | ||
return value.replace(/portugal/gi, (match) => { | ||
return match | ||
.replace(/po/gi, (match) => chalk.green(match)) | ||
.replace(/rt/gi, (match) => chalk.yellow(match)) | ||
.replace(/ugal/gi, (match) => chalk.red(match)); | ||
}); | ||
open(stripChalk(data.links[link])); | ||
} | ||
else { | ||
console.log("👋 See you"); | ||
function bye() { | ||
console.log("\n👋 See you around.\n"); | ||
process.exit(0); | ||
} | ||
process.exit(0); | ||
function stripChalk(str) { | ||
// biome-ignore lint/suspicious/noControlCharactersInRegex: 🤷 | ||
return str.replace(/\u001B\[[0-9]{1,2}m/g, ""); | ||
} |
147
index.ts
#! /usr/bin/env node | ||
import { select } from "@inquirer/prompts"; | ||
import { select as ask } from "@inquirer/prompts"; | ||
import chalk from "chalk"; | ||
import boxen from "boxen"; | ||
import box from "boxen"; | ||
import open from "open"; | ||
process.on("SIGINT", bye); | ||
process.on("SIGTERM", bye); | ||
process.on("uncaughtException", (error) => { | ||
if (error.name === "ExitPromptError") { | ||
bye(); | ||
} else { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
}); | ||
const handle = "jomifepe"; | ||
const location = `${chalk.green("Po")}${chalk.yellow("rt")}${chalk.red("ugal")}`; | ||
const work = { | ||
company: "Prismic", | ||
role: "Software Engineer", | ||
}; | ||
export const data = { | ||
export const info = { | ||
handle, | ||
name: "José Pereira", | ||
location: "Portugal", | ||
contact: `contact@${handle}.dev`, | ||
tools: "TypeScript, React, Node.js", | ||
role: "Software Engineer", | ||
company: "Prismic", | ||
links: { | ||
web: `${chalk.grey("https://")}${chalk.magenta(handle)}${chalk.grey(".dev")}`, | ||
github: `${chalk.grey("https://github.com/")}${chalk.green(handle)}`, | ||
twitter: `${chalk.grey("https://twitter.com/")}${chalk.cyan(handle)}`, | ||
npm: `${chalk.grey("https://npmjs.com/~")}${chalk.red(handle)}`, | ||
linkedin: `${chalk.grey("https://linkedin.com/in/")}${chalk.blue(handle)}`, | ||
medium: `${chalk.grey("https://medium.com/@")}${chalk.white(handle)}`, | ||
dev: `${chalk.grey("https://dev.to/")}${chalk.white(handle)}`, | ||
web: `https://${handle}.dev`, | ||
github: `https://github.com/${handle}`, | ||
twitter: `https://twitter.com/${handle}`, | ||
npm: `https://npmjs.com/~${handle}`, | ||
linkedin: `https://linkedin.com/in/${handle}`, | ||
medium: `https://medium.com/@${handle}`, | ||
dev: `https://dev.to/${handle}`, | ||
}, | ||
@@ -33,3 +39,3 @@ npx: `npx ${handle}`, | ||
type Link = keyof typeof data.links; | ||
type Link = keyof typeof info.links; | ||
@@ -46,20 +52,19 @@ const linkLabels: Record<Link, string> = { | ||
const me = boxen( | ||
[ | ||
chalk.white(`${chalk.bold(data.name)} / ${chalk.green(chalk.bold(data.handle))}`), | ||
``, | ||
` ${chalk.white(`Location: ${chalk.bold(location)}`)}`, | ||
` ${chalk.white(`Work: ${work.role} at ${chalk.blueBright(chalk.bold(work.company))}`)}`, | ||
``, | ||
` ${chalk.white(`${linkLabels.web}: ${data.links.web}`)}`, | ||
` ${chalk.white(`${linkLabels.github}: ${data.links.github}`)}`, | ||
` ${chalk.white(`${linkLabels.twitter}: ${data.links.twitter}`)}`, | ||
` ${chalk.white(`${linkLabels.linkedin}: ${data.links.linkedin}`)}`, | ||
` ${chalk.white(`${linkLabels.npm}: ${data.links.npm}`)}`, | ||
` ${chalk.white(`${linkLabels.medium}: ${data.links.medium}`)}`, | ||
` ${chalk.white(`${linkLabels.dev}: ${data.links.dev}`)}`, | ||
``, | ||
` ${chalk.white(`Card: ${chalk.greenBright(data.npx)}`)}`, | ||
].join("\n"), | ||
{ | ||
const card = `${chalk.white(`${chalk.bold(info.name)} / ${chalk.green(chalk.bold(info.handle))}`)} | ||
${chalk.white(`Location: ${tugaify(info.location)}`)} | ||
${chalk.white(`Work: ${info.role} at ${chalk.blueBright(chalk.bold(info.company))}`)} | ||
${chalk.white(`${linkLabels.web}: ${colorizeLink(info.links.web, "magenta")}`)} | ||
${chalk.white(`${linkLabels.github}: ${colorizeLink(info.links.github, "green")}`)} | ||
${chalk.white(`${linkLabels.twitter}: ${colorizeLink(info.links.twitter, "cyan")}`)} | ||
${chalk.white(`${linkLabels.linkedin}: ${colorizeLink(info.links.linkedin, "blue")}`)} | ||
${chalk.white(`${linkLabels.npm}: ${colorizeLink(info.links.npm, "red")}`)} | ||
${chalk.white(`${linkLabels.medium}: ${colorizeLink(info.links.medium, "white")}`)} | ||
${chalk.white(`${linkLabels.dev}: ${colorizeLink(info.links.dev, "white")}`)} | ||
${chalk.white(`Card: ${chalk.greenBright(info.npx)}`)}`; | ||
console.info( | ||
box(card, { | ||
margin: { top: 1, bottom: 1 }, | ||
@@ -70,8 +75,6 @@ padding: 1, | ||
width: 70, | ||
}, | ||
}), | ||
); | ||
console.info(me); | ||
const option = await select<"email" | "link" | "quit">({ | ||
const option = await ask({ | ||
message: "What do you want to do?", | ||
@@ -82,36 +85,46 @@ choices: [ | ||
{ value: "quit", name: "Quit" }, | ||
], | ||
] as const, | ||
}); | ||
type LinkChoice = { | ||
value: Link; | ||
name: string; | ||
}; | ||
console.log(); | ||
if (option === "email") { | ||
open(`mailto:${data.contact}`); | ||
console.log("📧 Looking forward to hearing from you!"); | ||
} else if (option === "link") { | ||
const link = await select<Link>({ | ||
message: "Which link do you want to open?", | ||
choices: Object.keys(data.links).map( | ||
(link): LinkChoice => ({ | ||
switch (option) { | ||
case "email": { | ||
open(`mailto:${info.contact}`); | ||
console.log("\n📧 Looking forward to hearing from you!\n"); | ||
break; | ||
} | ||
case "link": { | ||
const link = await ask({ | ||
message: "Which link do you want to open?", | ||
choices: Object.keys(info.links).map((link) => ({ | ||
value: link as Link, | ||
name: linkLabels[link as Link], | ||
}), | ||
), | ||
}); | ||
})), | ||
}); | ||
open(stripChalk(data.links[link])); | ||
} else { | ||
console.log("👋 See you"); | ||
open(info.links[link]); | ||
bye(); | ||
break; | ||
} | ||
case "quit": { | ||
bye(); | ||
break; | ||
} | ||
} | ||
process.exit(0); | ||
function colorizeLink(link: string, style: "red" | "green" | "blue" | "magenta" | "cyan" | "white") { | ||
return chalk.grey(link.replace(new RegExp(info.handle, "gi"), (match) => chalk[style](match))); | ||
} | ||
function stripChalk(str: string): string { | ||
// biome-ignore lint/suspicious/noControlCharactersInRegex: 🤷 | ||
return str.replace(/\u001B\[[0-9]{1,2}m/g, ""); | ||
function tugaify(value: string) { | ||
return value.replace(/portugal/gi, (match) => { | ||
return match | ||
.replace(/po/gi, (match) => chalk.green(match)) | ||
.replace(/rt/gi, (match) => chalk.yellow(match)) | ||
.replace(/ugal/gi, (match) => chalk.red(match)); | ||
}); | ||
} | ||
function bye() { | ||
console.log("\n👋 See you around.\n"); | ||
process.exit(0); | ||
} |
{ | ||
"name": "jomifepe", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"author": "José Pereira <contact@jomifepe.dev>", | ||
@@ -13,4 +13,5 @@ "description": "My personal CLI business card", | ||
"scripts": { | ||
"build": "yarn clean && tsc", | ||
"dev": "tsc-watch --onSuccess 'node ./dist/index.js'", | ||
"build": "yarn clean && tsc", | ||
"start": "yarn build && node ./dist/index.js", | ||
"clean": "rimraf ./dist", | ||
@@ -17,0 +18,0 @@ "prepublish": "yarn build", |
@@ -8,3 +8,3 @@ ### Heyo 👋 | ||
```bash | ||
npx jomifepe | ||
npx jomifepe@latest | ||
``` | ||
@@ -14,12 +14,12 @@ | ||
[![linkedin logo](./img/linkedin-light.svg)](https://www.linkedin.com/in/jomifepe#gh-dark-mode-only) | ||
[![linkedin logo](./img/linkedin-dark.svg)](https://www.linkedin.com/in/jomifepe#gh-light-mode-only) | ||
[![linkedin logo](https://raw.githubusercontent.com/jomifepe/jomifepe/main/img/linkedin-light.svg)](https://www.linkedin.com/in/jomifepe#gh-dark-mode-only) | ||
[![linkedin logo](https://raw.githubusercontent.com/jomifepe/jomifepe/main/img/linkedin-dark.svg)](https://www.linkedin.com/in/jomifepe#gh-light-mode-only) | ||
| ||
[![twitter logo](./img/twitter-light.svg)](https://twitter.com/jomifepe#gh-dark-mode-only) | ||
[![twitter logo](./img/twitter-dark.svg)](https://twitter.com/jomifepe#gh-light-mode-only) | ||
[![twitter logo](https://raw.githubusercontent.com/jomifepe/jomifepe/main/img/twitter-light.svg)](https://twitter.com/jomifepe#gh-dark-mode-only) | ||
[![twitter logo](https://raw.githubusercontent.com/jomifepe/jomifepe/main/img/twitter-dark.svg)](https://twitter.com/jomifepe#gh-light-mode-only) | ||
| ||
[![dev logo](./img/dev-light.svg)](https://dev.to/jomifepe#gh-dark-mode-only) | ||
[![dev logo](./img/dev-dark.svg)](https://dev.to/jomifepe#gh-light-mode-only) | ||
[![dev logo](https://raw.githubusercontent.com/jomifepe/jomifepe/main/img/dev-light.svg)](https://dev.to/jomifepe#gh-dark-mode-only) | ||
[![dev logo](https://raw.githubusercontent.com/jomifepe/jomifepe/main/img/dev-dark.svg)](https://dev.to/jomifepe#gh-light-mode-only) | ||
| ||
[![medium logo](./img/medium-light.svg)](https://medium.com/@jomifepe#gh-dark-mode-only) | ||
[![medium logo](./img/medium-dark.svg)](https://medium.com/@jomifepe#gh-light-mode-only) | ||
[![medium logo](https://raw.githubusercontent.com/jomifepe/jomifepe/main/img/medium-light.svg)](https://medium.com/@jomifepe#gh-dark-mode-only) | ||
[![medium logo](https://raw.githubusercontent.com/jomifepe/jomifepe/main/img/medium-dark.svg)](https://medium.com/@jomifepe#gh-light-mode-only) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19908
251
1