ukmadlz
Version:
Developer Advocate and Software Engineer for Hire (opinions and views are my own)
106 lines (100 loc) • 3.31 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BASE_URL = void 0;
exports.showBio = showBio;
exports.showTalks = showTalks;
exports.showJobs = showJobs;
exports.showPosts = showPosts;
exports.showHelp = showHelp;
exports.main = main;
const package_json_1 = __importDefault(require("../package.json"));
exports.BASE_URL = process.env.UKMADLZ_API_URL || "https://elsmore.me/api";
async function showBio() {
const [socialRes, jobsRes] = await Promise.all([
fetch(`${exports.BASE_URL}/social.json`),
fetch(`${exports.BASE_URL}/jobs.json`),
]);
const { data } = await socialRes.json();
const { data: jobs } = await jobsRes.json();
const currentJob = jobs.find((j) => j.current);
const jobLine = currentJob
? `\n Currently: ${currentJob.title} at ${currentJob.company}\n`
: "";
const theMeBit = `
Mike Elsmore is available for hire for software development, MVPs, Developer Experience and Developer Relations related work.
${jobLine}
For a day job he's usually talking about stuff, building stuff (occasionally SDKs), and trying share stuff.
Mike hacks and speaks about topics such as ${package_json_1.default.keywords.join(", ")}.
E-mail: <${data.email}>
Website: <${data.url}>
${data.socials.map((s) => ` ${s.name}: <${s.url}>`).join("\n")}
`;
console.log(theMeBit);
}
async function showTalks() {
const res = await fetch(`${exports.BASE_URL}/talks.json`);
const { data } = await res.json();
const output = data
.map((t) => ` ${t.title} — ${t.event} (${t.date})\n ${t.url}`)
.join("\n\n");
console.log(output);
}
async function showJobs() {
const res = await fetch(`${exports.BASE_URL}/jobs.json`);
const { data } = await res.json();
const output = data
.map((j) => {
const end = j.end_date ?? "Present";
return ` ${j.title} — ${j.company} (${j.start_date} to ${end})`;
})
.join("\n");
console.log(output);
}
async function showPosts() {
const res = await fetch(`${exports.BASE_URL}/posts.json`);
const { data } = await res.json();
const output = data
.map((p) => ` ${p.title} (${p.published_date})\n ${p.url}`)
.join("\n\n");
console.log(output);
}
function showHelp() {
console.log(`ukmadlz v${package_json_1.default.version}
Usage: ukmadlz [command]
Commands:
(none) Show bio and social links (default)
jobs List job history
talks List recent talks
posts List recent blog posts
Options:
--help, -h Show this help message`);
}
async function main() {
const command = process.argv[2];
switch (command) {
case "--help":
case "-h":
case "help":
showHelp();
break;
case "jobs":
await showJobs();
break;
case "talks":
await showTalks();
break;
case "posts":
await showPosts();
break;
default:
await showBio();
break;
}
}
if (require.main === module) {
main();
}