@kud/jira-cli 0.2.0 → 0.3.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 +15 -1
- package/dist/chunk-5MFNIQDW.js +117 -0
- package/dist/index.js +84 -568
- package/dist/tui-4JIAFCJF.js +593 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Jira on the command line. Reads issues, comments and **attachments** as plain text, so you can pipe them into anything.
|
|
4
4
|
|
|
5
|
-
Black and white output, `--json` on every read, stable exit codes.
|
|
5
|
+
Black and white output, `--json` on every read, stable exit codes. Every subcommand is plain and pipeable — the interactive view lives behind the bare `jira` command and nowhere else.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -41,6 +41,20 @@ Descriptions and comments render as Markdown, with embedded files named rather t
|
|
|
41
41
|
jira issue view ABC-123 --comments
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
## The interactive view
|
|
45
|
+
|
|
46
|
+
Run `jira` with no arguments:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
jira
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Your open issues, newest first. `↑↓` to move, `enter` to open, `a` to include closed ones, `r` to refresh, `q` to quit.
|
|
53
|
+
|
|
54
|
+
Inside an issue, `←→` switches between description, comments and attachments — descriptions and comments render as real Markdown, and attachments are listed with the comment or description each was embedded in. `t` transitions, `c` comments, `a` assigns to you, `o` opens the browser, `esc` goes back. Writes ask before they act.
|
|
55
|
+
|
|
56
|
+
Ink is loaded only for this view, via a dynamic import, so `jira issue list | grep` never pays for it. Piped or redirected, bare `jira` prints help instead of opening a UI.
|
|
57
|
+
|
|
44
58
|
## Using it alongside the Atlassian MCP
|
|
45
59
|
|
|
46
60
|
The Atlassian MCP returns an issue's fields and comments, but **not** the content of its attachments — it can tell you a file is there and nothing more. When the answer to a ticket is inside a screenshot, a log or a CSV, that is the gap this fills:
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import { normalizeBaseUrl } from "@kud/jira";
|
|
6
|
+
var configPath = () => process.env["JIRA_CONFIG_FILE"] || join(
|
|
7
|
+
process.env["XDG_CONFIG_HOME"] || join(homedir(), ".config"),
|
|
8
|
+
"jira",
|
|
9
|
+
"config.json"
|
|
10
|
+
);
|
|
11
|
+
var readFileConfig = (path = configPath()) => {
|
|
12
|
+
let raw;
|
|
13
|
+
try {
|
|
14
|
+
raw = readFileSync(path, "utf8");
|
|
15
|
+
} catch {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
if (parsed.customFields && !Array.isArray(parsed.customFields))
|
|
20
|
+
throw new Error(`${path}: customFields must be an array of {id,label}`);
|
|
21
|
+
if ("token" in parsed || "apiToken" in parsed)
|
|
22
|
+
throw new Error(
|
|
23
|
+
`${path} contains a token. Tokens belong in ATLASSIAN_API_TOKEN, not in a file that gets shared and backed up \u2014 remove it.`
|
|
24
|
+
);
|
|
25
|
+
return parsed;
|
|
26
|
+
};
|
|
27
|
+
var loadConfig = (env = process.env, path = configPath()) => {
|
|
28
|
+
const file = readFileConfig(path);
|
|
29
|
+
const baseUrl = env["ATLASSIAN_BASE_URL"] || file.baseUrl;
|
|
30
|
+
const email = env["ATLASSIAN_USER_EMAIL"] || file.email;
|
|
31
|
+
const token = env["ATLASSIAN_API_TOKEN"];
|
|
32
|
+
const missing = [
|
|
33
|
+
["ATLASSIAN_BASE_URL", baseUrl],
|
|
34
|
+
["ATLASSIAN_USER_EMAIL", email],
|
|
35
|
+
["ATLASSIAN_API_TOKEN", token]
|
|
36
|
+
].filter(([, v]) => !v).map(([k]) => k);
|
|
37
|
+
if (missing.length > 0) return { missing };
|
|
38
|
+
return {
|
|
39
|
+
config: {
|
|
40
|
+
...file,
|
|
41
|
+
baseUrl: normalizeBaseUrl(baseUrl),
|
|
42
|
+
email,
|
|
43
|
+
token
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/commands/context.ts
|
|
49
|
+
import { createJiraClient } from "@kud/jira";
|
|
50
|
+
|
|
51
|
+
// src/output/format.ts
|
|
52
|
+
var identity = (s) => s;
|
|
53
|
+
var wrap = (open, close) => (s) => `\x1B[${open}m${s}\x1B[${close}m`;
|
|
54
|
+
var palette = (isTty, env = process.env) => {
|
|
55
|
+
const on = isTty && !env["NO_COLOR"] && env["TERM"] !== "dumb";
|
|
56
|
+
const c = (open, close) => on ? wrap(open, close) : identity;
|
|
57
|
+
return {
|
|
58
|
+
on,
|
|
59
|
+
dim: c("2", "22"),
|
|
60
|
+
bold: c("1", "22")
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
var ANSI = /\u001b\[[0-9;]*m/g;
|
|
64
|
+
var width = (s) => s.replace(ANSI, "").length;
|
|
65
|
+
var pad = (s, to) => s + " ".repeat(Math.max(0, to - width(s)));
|
|
66
|
+
var table = (rows, columns) => {
|
|
67
|
+
if (rows.length === 0) return "";
|
|
68
|
+
const cells = rows.map((r) => columns.map((c) => c.value(r)));
|
|
69
|
+
const widths = columns.map(
|
|
70
|
+
(c, i) => Math.max(width(c.header), ...cells.map((row) => width(row[i])))
|
|
71
|
+
);
|
|
72
|
+
const line = (values) => values.map((v, i) => {
|
|
73
|
+
const w = widths[i];
|
|
74
|
+
return columns[i]?.align === "right" ? " ".repeat(Math.max(0, w - width(v))) + v : pad(v, w);
|
|
75
|
+
}).join(" ").trimEnd();
|
|
76
|
+
return [line(columns.map((c) => c.header)), ...cells.map(line)].join("\n");
|
|
77
|
+
};
|
|
78
|
+
var truncate = (s, max) => s.length <= max ? s : `${s.slice(0, Math.max(0, max - 1))}\u2026`;
|
|
79
|
+
|
|
80
|
+
// src/commands/context.ts
|
|
81
|
+
var exitError = (code, message) => Object.assign(new Error(message), { name: "ExitError", code });
|
|
82
|
+
var isExitError = (e) => e instanceof Error && e.name === "ExitError";
|
|
83
|
+
var context = () => {
|
|
84
|
+
const loaded = loadConfig();
|
|
85
|
+
if ("missing" in loaded) {
|
|
86
|
+
throw exitError(
|
|
87
|
+
2,
|
|
88
|
+
`missing environment variables: ${loaded.missing.join(", ")}
|
|
89
|
+
|
|
90
|
+
Set them, then retry:
|
|
91
|
+
export ATLASSIAN_BASE_URL=myorg.atlassian.net
|
|
92
|
+
export ATLASSIAN_USER_EMAIL=you@example.com
|
|
93
|
+
export ATLASSIAN_API_TOKEN=... # id.atlassian.com/manage-profile/security/api-tokens`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
const { config } = loaded;
|
|
97
|
+
return {
|
|
98
|
+
config,
|
|
99
|
+
client: createJiraClient(config),
|
|
100
|
+
out: palette(process.stdout.isTTY === true)
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
var printJson = (value) => {
|
|
104
|
+
process.stdout.write(`${JSON.stringify(value, null, 2)}
|
|
105
|
+
`);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
table,
|
|
110
|
+
truncate,
|
|
111
|
+
configPath,
|
|
112
|
+
readFileConfig,
|
|
113
|
+
exitError,
|
|
114
|
+
isExitError,
|
|
115
|
+
context,
|
|
116
|
+
printJson
|
|
117
|
+
};
|