@tenderlead/cli 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/bin/tenderlead.js +19 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,9 +21,13 @@ Sign in with Google or an emailed sign-in link, then create a scoped token under
|
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
export TENDERLEAD_API_TOKEN="paste-token-here"
|
|
24
|
+
tenderlead whoami
|
|
24
25
|
tenderlead brief
|
|
25
26
|
```
|
|
26
27
|
|
|
28
|
+
`whoami` confirms which account and token the CLI is using (masked email, plan,
|
|
29
|
+
token label, scopes and expiry). It works with any valid token.
|
|
30
|
+
|
|
27
31
|
Use JSON output for scripts and agents:
|
|
28
32
|
|
|
29
33
|
```bash
|
package/bin/tenderlead.js
CHANGED
|
@@ -17,6 +17,7 @@ function usage() {
|
|
|
17
17
|
return [
|
|
18
18
|
'Usage:',
|
|
19
19
|
' tenderlead login',
|
|
20
|
+
' tenderlead whoami [--json]',
|
|
20
21
|
' tenderlead brief [--json]',
|
|
21
22
|
' tenderlead tenders search [--query <text>] [--recommendation bid|skip] [--all] [--limit <1-50>] [--json]',
|
|
22
23
|
' tenderlead tender score <contract-id> [--json]',
|
|
@@ -60,6 +61,7 @@ function usage() {
|
|
|
60
61
|
function parseArgs(argv) {
|
|
61
62
|
const command = argv[2];
|
|
62
63
|
if (command === 'login') return { command: 'login' };
|
|
64
|
+
if (command === 'whoami') return parseJsonOnlyArgs(argv, 3, { command: 'whoami', json: false });
|
|
63
65
|
if (command === 'brief') {
|
|
64
66
|
const options = { command: 'brief', json: false };
|
|
65
67
|
for (let index = 3; index < argv.length; index += 1) {
|
|
@@ -346,6 +348,19 @@ function line(value, fallback) {
|
|
|
346
348
|
return text || fallback;
|
|
347
349
|
}
|
|
348
350
|
|
|
351
|
+
function formatWhoami(payload) {
|
|
352
|
+
const token = payload.token || {};
|
|
353
|
+
const rows = [
|
|
354
|
+
['Account', line(payload.email, 'unknown')],
|
|
355
|
+
['Plan', `${line(payload.plan_tier, 'unknown')} (${line(payload.plan_status, 'unknown')})`],
|
|
356
|
+
['Token', line(token.label, 'unnamed')],
|
|
357
|
+
['Scopes', Array.isArray(token.scopes) && token.scopes.length ? token.scopes.join(', ') : 'none'],
|
|
358
|
+
['Expires', token.expires_at ? String(token.expires_at).slice(0, 10) : 'unknown'],
|
|
359
|
+
];
|
|
360
|
+
const width = Math.max(...rows.map(([label]) => label.length));
|
|
361
|
+
return rows.map(([label, value]) => `${label.padEnd(width)} ${value}`).join('\n');
|
|
362
|
+
}
|
|
363
|
+
|
|
349
364
|
function formatBrief(payload) {
|
|
350
365
|
const rows = Array.isArray(payload.opportunities) ? payload.opportunities : [];
|
|
351
366
|
const lines = ['# TenderLead daily brief', '', `Generated: ${line(payload.generated_at, 'Not recorded')}`, `Plan: ${line(payload.tier, 'Not recorded')}`, '', '## Opportunities', ''];
|
|
@@ -406,6 +421,8 @@ async function apiRequest(path, options = {}, fetchImpl = fetch) {
|
|
|
406
421
|
return body;
|
|
407
422
|
}
|
|
408
423
|
|
|
424
|
+
async function fetchWhoami(fetchImpl = fetch) { return apiRequest('/api/cli/whoami', {}, fetchImpl); }
|
|
425
|
+
|
|
409
426
|
async function fetchBrief(_options, fetchImpl = fetch) {
|
|
410
427
|
return apiRequest('/v1/briefs/daily', {}, fetchImpl);
|
|
411
428
|
}
|
|
@@ -689,6 +706,7 @@ async function main() {
|
|
|
689
706
|
console.log('TenderLead Settings opened. Sign in, create the required scoped token, then set TENDERLEAD_API_TOKEN in your shell.');
|
|
690
707
|
return;
|
|
691
708
|
}
|
|
709
|
+
if (options.command === 'whoami') return printPayload(await fetchWhoami(), options.json, formatWhoami);
|
|
692
710
|
if (options.command === 'brief') {
|
|
693
711
|
const brief = await fetchBrief(options);
|
|
694
712
|
console.log(options.json ? JSON.stringify(brief, null, 2) : formatBrief(brief));
|
|
@@ -821,7 +839,7 @@ if (require.main === module) {
|
|
|
821
839
|
}
|
|
822
840
|
|
|
823
841
|
module.exports = {
|
|
824
|
-
parseArgs, openLogin, formatBrief, formatTenders, formatScore, fetchBrief, searchTenders, scoreTender, fetchProfile, updateProfile,
|
|
842
|
+
parseArgs, openLogin, fetchWhoami, formatWhoami, formatBrief, formatTenders, formatScore, fetchBrief, searchTenders, scoreTender, fetchProfile, updateProfile,
|
|
825
843
|
validateProfile, readProfileFile, profileTemplate, profileDiff, formatProfile,
|
|
826
844
|
formatProfileDiff, confirmApply, confirmWord, readJsonFile, contentTypeForFile, appendFiles,
|
|
827
845
|
fetchPipeline, addPipelineItem, updatePipelineItem, removePipelineItem, fetchInsights, sendTenderFeedback, sendProductFeedback,
|
package/package.json
CHANGED