ticketlens 0.1.1 → 0.1.3
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/bin/ticketlens.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import { run as runCache } from '../skills/jtb/scripts/lib/cache-manager.mjs';
|
|
|
20
20
|
import { printHelp, printProfiles } from '../skills/jtb/scripts/lib/help.mjs';
|
|
21
21
|
import { createStyler } from '../skills/jtb/scripts/lib/ansi.mjs';
|
|
22
22
|
import { readCliToken, saveCliToken, deleteCliToken } from '../skills/jtb/scripts/lib/cli-auth.mjs';
|
|
23
|
-
import { syncProfiles, getApiBase } from '../skills/jtb/scripts/lib/sync.mjs';
|
|
23
|
+
import { syncProfiles, getApiBase, getConsoleBase } from '../skills/jtb/scripts/lib/sync.mjs';
|
|
24
24
|
import { promptSecret, promptText } from '../skills/jtb/scripts/lib/prompt-helpers.mjs';
|
|
25
25
|
|
|
26
26
|
const args = process.argv.slice(2);
|
|
@@ -266,7 +266,7 @@ switch (command) {
|
|
|
266
266
|
const s = createStyler({ isTTY: process.stderr.isTTY });
|
|
267
267
|
process.stderr.write(`\n ${s.bold('TicketLens Login')}\n`);
|
|
268
268
|
process.stderr.write(` ${s.dim('─'.repeat(44))}\n`);
|
|
269
|
-
process.stderr.write(` ${s.dim(`Generate a CLI token at ${s.cyan(`${
|
|
269
|
+
process.stderr.write(` ${s.dim(`Generate a CLI token at ${s.cyan(`${getConsoleBase()}/console/account`)}`)}\n`);
|
|
270
270
|
process.stderr.write(` ${s.dim('then paste it below.')}\n\n`);
|
|
271
271
|
|
|
272
272
|
const token = await promptSecret(`CLI Token ${s.dim('(tl_…)')}:`, { stream: process.stderr });
|
package/package.json
CHANGED
|
@@ -41,25 +41,30 @@ export async function promptSecret(label, { stream = process.stderr, existingVal
|
|
|
41
41
|
while (true) {
|
|
42
42
|
stream.write(` ${label} `);
|
|
43
43
|
const value = await new Promise(res => {
|
|
44
|
-
let buf
|
|
44
|
+
let buf = '';
|
|
45
|
+
let stars = 0; // visual asterisk count — may differ from buf.length after a paste
|
|
45
46
|
const stdin = process.stdin;
|
|
46
47
|
stdin.setRawMode(true);
|
|
47
48
|
stdin.resume();
|
|
48
49
|
stdin.setEncoding('utf8');
|
|
49
|
-
function onData(
|
|
50
|
-
if (
|
|
50
|
+
function onData(chunk) {
|
|
51
|
+
if (chunk === '\r' || chunk === '\n') {
|
|
51
52
|
stdin.setRawMode(false);
|
|
52
53
|
stdin.pause();
|
|
53
54
|
stdin.removeListener('data', onData);
|
|
54
55
|
stream.write('\n');
|
|
55
56
|
res(buf);
|
|
56
|
-
} else if (
|
|
57
|
-
if (buf.length > 0) {
|
|
58
|
-
|
|
57
|
+
} else if (chunk === '\x7f' || chunk === '\x08') {
|
|
58
|
+
if (buf.length > 0) {
|
|
59
|
+
buf = buf.slice(0, -1);
|
|
60
|
+
if (stars > 0) { stars--; stream.write('\b \b'); }
|
|
61
|
+
}
|
|
62
|
+
} else if (chunk === '\x03') {
|
|
59
63
|
process.exit(0);
|
|
60
64
|
} else {
|
|
61
|
-
buf
|
|
62
|
-
|
|
65
|
+
buf += chunk;
|
|
66
|
+
stars += chunk.length;
|
|
67
|
+
stream.write('*'.repeat(chunk.length));
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
stdin.on('data', onData);
|
|
@@ -14,9 +14,11 @@ import {
|
|
|
14
14
|
} from './profile-resolver.mjs';
|
|
15
15
|
import { DEFAULT_CONFIG_DIR } from './config.mjs';
|
|
16
16
|
|
|
17
|
-
const DEFAULT_API_BASE = 'https://ticketlens.app';
|
|
17
|
+
const DEFAULT_API_BASE = 'https://api.ticketlens.app';
|
|
18
18
|
|
|
19
|
-
export const getApiBase
|
|
19
|
+
export const getApiBase = () => process.env.TICKETLENS_API_URL ?? DEFAULT_API_BASE;
|
|
20
|
+
// Strip the api. subdomain to get the console base URL (e.g. api.ticketlens.app → ticketlens.app)
|
|
21
|
+
export const getConsoleBase = () => getApiBase().replace('://api.', '://');
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Convert a server profile (snake_case) to the CLI profile shape (camelCase).
|