24 lines
610 B
JavaScript
Executable File
24 lines
610 B
JavaScript
Executable File
import { LinearClient } from "@linear/sdk";
|
|
|
|
export function getClient() {
|
|
const apiKey = process.env.LINEAR_API_KEY;
|
|
if (!apiKey) {
|
|
console.error("Error: LINEAR_API_KEY environment variable is required.");
|
|
console.error(
|
|
"Generate one at: https://linear.app/settings/api (Personal API keys)"
|
|
);
|
|
process.exit(1);
|
|
}
|
|
return new LinearClient({ apiKey });
|
|
}
|
|
|
|
export function formatDate(date) {
|
|
if (!date) return "";
|
|
return new Date(date).toISOString().split("T")[0];
|
|
}
|
|
|
|
export function truncate(str, len = 120) {
|
|
if (!str) return "";
|
|
return str.length > len ? str.slice(0, len) + "…" : str;
|
|
}
|