UNPKG

bookr-cli

Version:

A terminal-based CLI tool to book time in Jira using the Tempo plugin by parsing your current Git branch name

45 lines • 1.64 kB
import { loadConfigFromFile } from '../utils/config.js'; async function main() { const config = loadConfigFromFile(); if (!config?.tempoApiToken) { console.error('āŒ No TEMPO_API_TOKEN found in config.'); process.exit(1); } if (!config?.email) { console.error('āŒ No JIRA_EMAIL found in config (used for account lookup).'); process.exit(1); } // You may need to hardcode or fetch your accountId here. For now, prompt the user to enter it. const accountId = process.argv[2]; if (!accountId) { console.error('Usage: node src/api/test-tempo-workload.js <accountId>'); process.exit(1); } const baseUrl = 'https://api.tempo.io/4'; const url = `${baseUrl}/workload-schemes/users/${encodeURIComponent(accountId)}`; console.log(`\nšŸ” Testing Tempo Workload API for accountId: ${accountId}`); console.log(`GET ${url}`); try { const response = await fetch(url, { method: 'GET', headers: { 'Authorization': `Bearer ${config.tempoApiToken}`, 'Accept': 'application/json', }, }); console.log(`Status: ${response.status} ${response.statusText}`); const text = await response.text(); try { const json = JSON.parse(text); console.log('Response JSON:', JSON.stringify(json, null, 2)); } catch { console.log('Response Text:', text); } } catch (err) { console.error('āŒ Error during fetch:', err); } } main(); //# sourceMappingURL=test-tempo-workload.js.map