tsjobs
Version:
CLI typescript job board
80 lines (78 loc) • 3.1 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// src/index.ts
var import_citty = require("citty");
var import_axios = __toESM(require("axios"), 1);
var import_enquirer = __toESM(require("enquirer"), 1);
var main = (0, import_citty.defineCommand)({
meta: {
name: "tsjobs",
version: "1.0.0",
description: "Curated typescript jobs in your terminal"
},
run: async () => {
try {
const res = await import_axios.default.get("https://typescript.jobs/api/job");
const data = res.data;
const locations = data.locations;
if (locations.length === 0) {
console.log("No job locations found.");
return;
}
const answer = await import_enquirer.default.prompt([
{
type: "select",
name: "location",
message: "Choose a location",
choices: locations
}
]);
const selectedLocation = answer.location;
const locationRes = await import_axios.default.get(`https://typescript.jobs/api/job?location=${encodeURIComponent(selectedLocation)}`);
const locationJobs = locationRes.data.jobs;
if (locationJobs.length === 0) {
console.log(`No jobs found for ${selectedLocation}.`);
return;
}
console.log(`
\u{1F3AF} Jobs in ${selectedLocation}:
`);
locationJobs.forEach((job, index) => {
console.log(`${index + 1}. \u{1F4CC} ${job.title} @ ${job.company_name}`);
console.log(` \u{1F30D} Location: ${selectedLocation} ${job.remote}`);
console.log(` \u{1F517} Apply: ${job.company_job_listing_url}`);
console.log(` \u{1F50E} See more: ${job.full_details}
`);
});
} catch (error) {
let errorMessage = "\u274C Failed to fetch job data";
if (error instanceof Error) {
errorMessage = error.message;
}
console.error("\u274C Failed to fetch job data:", errorMessage);
}
}
});
(0, import_citty.runMain)(main);