@kud/jira-cli 0.4.0 → 0.5.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 +5 -1
- package/dist/{chunk-5MFNIQDW.js → chunk-QEOE2RPV.js} +54 -51
- package/dist/index.js +7 -27
- package/dist/tui-TWKZI63D.js +825 -0
- package/package.json +5 -5
- package/dist/tui-UKK2JQS3.js +0 -603
package/README.md
CHANGED
|
@@ -49,7 +49,11 @@ Run `jira` with no arguments:
|
|
|
49
49
|
jira
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
Your
|
|
52
|
+
Your issues as a board: three tabs — **To do**, **In progress**, **Done** — filed by Jira's status *category*, so it works on any instance without knowing what your board calls its columns. Rows hang under their epic, carry a type pill, a priority glyph (`▲` high, `▼` low) and how long since they last moved. Closed work from the last fortnight is on the Done tab; `a` loads everything.
|
|
53
|
+
|
|
54
|
+
`↑↓` to move, `⇥` to switch tab, `enter` to open, `?` for the legend, `r` to refresh, `q` to quit.
|
|
55
|
+
|
|
56
|
+
`/` searches. Plain words narrow the list as you type and, on `enter`, run as `text ~ "…"` within your issues — so a match in a comment counts too. Anything shaped like JQL (`status = Done`, `labels in (a, b)`, `ORDER BY …`) is sent as-is and replaces the scope; the tag at the end of the line says which reading it took, and `⇥` flips it. A query Jira rejects shows Jira's own message under the box and keeps your text for editing. `esc` clears the search.
|
|
53
57
|
|
|
54
58
|
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
59
|
|
|
@@ -1,52 +1,8 @@
|
|
|
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
1
|
// src/commands/context.ts
|
|
49
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createJiraClient,
|
|
4
|
+
loadConfig
|
|
5
|
+
} from "@kud/jira";
|
|
50
6
|
|
|
51
7
|
// src/output/format.ts
|
|
52
8
|
var identity = (s) => s;
|
|
@@ -105,13 +61,60 @@ var printJson = (value) => {
|
|
|
105
61
|
`);
|
|
106
62
|
};
|
|
107
63
|
|
|
64
|
+
// src/jql.ts
|
|
65
|
+
var jqlEscape = (value) => `"${value.replace(/"/g, '\\"')}"`;
|
|
66
|
+
var buildJql = (options, defaultProject) => {
|
|
67
|
+
if (options.jql) return options.jql;
|
|
68
|
+
const clauses = [];
|
|
69
|
+
if (options.mine) clauses.push("assignee = currentUser()");
|
|
70
|
+
else if (options.assignee)
|
|
71
|
+
clauses.push(
|
|
72
|
+
options.assignee === "none" ? "assignee IS EMPTY" : `assignee = ${jqlEscape(options.assignee)}`
|
|
73
|
+
);
|
|
74
|
+
const project = options.project ?? defaultProject;
|
|
75
|
+
if (project) clauses.push(`project = ${jqlEscape(project)}`);
|
|
76
|
+
if (options.status) clauses.push(`status = ${jqlEscape(options.status)}`);
|
|
77
|
+
if (options.label) clauses.push(`labels = ${jqlEscape(options.label)}`);
|
|
78
|
+
if (options.sprint)
|
|
79
|
+
clauses.push(
|
|
80
|
+
options.sprint === "current" ? "sprint IN openSprints()" : `sprint = ${jqlEscape(options.sprint)}`
|
|
81
|
+
);
|
|
82
|
+
if (clauses.length === 0) clauses.push("assignee = currentUser()");
|
|
83
|
+
return `${clauses.join(" AND ")} ORDER BY updated DESC`;
|
|
84
|
+
};
|
|
85
|
+
var WORD_OPS = [
|
|
86
|
+
String.raw`\s+(not\s+)?in\s*\(`,
|
|
87
|
+
String.raw`\s+is\s+(not\s+)?(empty|null)\b`,
|
|
88
|
+
String.raw`\s+was\s+(not\s+)?(in\s*\(|"|'|empty|null)`,
|
|
89
|
+
String.raw`\s+changed\s*(by|after|before|during|on|from|to|$)`
|
|
90
|
+
].join("|");
|
|
91
|
+
var JQL_SHAPE = new RegExp(
|
|
92
|
+
String.raw`^\(?\s*(not\s+)?\(?\s*[\w.\-[\]"]+\s*(=|!=|~|!~|<=|>=|<|>|` + WORD_OPS + ")",
|
|
93
|
+
"i"
|
|
94
|
+
);
|
|
95
|
+
var ORDER_ONLY = /^order\s+by\s/i;
|
|
96
|
+
var looksLikeJql = (input) => {
|
|
97
|
+
const s = input.trim();
|
|
98
|
+
return JQL_SHAPE.test(s) || ORDER_ONLY.test(s);
|
|
99
|
+
};
|
|
100
|
+
var LUCENE_SPECIALS = /([+\-&|!(){}[\]^~*?:\\])/g;
|
|
101
|
+
var textClause = (words) => `text ~ ${jqlEscape(words.replace(LUCENE_SPECIALS, "\\$1"))}`;
|
|
102
|
+
var searchJql = (input, { mode = "auto", scope } = {}) => {
|
|
103
|
+
const trimmed = input.trim();
|
|
104
|
+
const isJql = mode === "jql" || mode === "auto" && looksLikeJql(trimmed);
|
|
105
|
+
if (isJql) return { jql: trimmed, mode: "jql" };
|
|
106
|
+
const clauses = [scope, textClause(trimmed)].filter(Boolean);
|
|
107
|
+
return { jql: `${clauses.join(" AND ")} ORDER BY updated DESC`, mode: "text" };
|
|
108
|
+
};
|
|
109
|
+
|
|
108
110
|
export {
|
|
109
111
|
table,
|
|
110
112
|
truncate,
|
|
111
|
-
configPath,
|
|
112
|
-
readFileConfig,
|
|
113
113
|
exitError,
|
|
114
114
|
isExitError,
|
|
115
115
|
context,
|
|
116
|
-
printJson
|
|
116
|
+
printJson,
|
|
117
|
+
buildJql,
|
|
118
|
+
looksLikeJql,
|
|
119
|
+
searchJql
|
|
117
120
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
buildJql,
|
|
4
4
|
context,
|
|
5
5
|
exitError,
|
|
6
6
|
isExitError,
|
|
7
7
|
printJson,
|
|
8
|
-
readFileConfig,
|
|
9
8
|
table,
|
|
10
9
|
truncate
|
|
11
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QEOE2RPV.js";
|
|
12
11
|
|
|
13
12
|
// src/index.ts
|
|
14
13
|
import { realpathSync } from "fs";
|
|
15
14
|
import { createRequire } from "module";
|
|
16
15
|
import { fileURLToPath } from "url";
|
|
17
16
|
import { Command } from "commander";
|
|
18
|
-
import { isJiraApiError } from "@kud/jira";
|
|
17
|
+
import { configPath as configPath2, isJiraApiError } from "@kud/jira";
|
|
19
18
|
|
|
20
19
|
// src/commands/attachment.ts
|
|
21
20
|
import { writeFileSync } from "fs";
|
|
@@ -391,26 +390,6 @@ var registerIssueWriteCommands = (issue) => {
|
|
|
391
390
|
};
|
|
392
391
|
|
|
393
392
|
// src/commands/issue.ts
|
|
394
|
-
var jqlEscape = (value) => `"${value.replace(/"/g, '\\"')}"`;
|
|
395
|
-
var buildJql = (options, defaultProject) => {
|
|
396
|
-
if (options.jql) return options.jql;
|
|
397
|
-
const clauses = [];
|
|
398
|
-
if (options.mine) clauses.push("assignee = currentUser()");
|
|
399
|
-
else if (options.assignee)
|
|
400
|
-
clauses.push(
|
|
401
|
-
options.assignee === "none" ? "assignee IS EMPTY" : `assignee = ${jqlEscape(options.assignee)}`
|
|
402
|
-
);
|
|
403
|
-
const project = options.project ?? defaultProject;
|
|
404
|
-
if (project) clauses.push(`project = ${jqlEscape(project)}`);
|
|
405
|
-
if (options.status) clauses.push(`status = ${jqlEscape(options.status)}`);
|
|
406
|
-
if (options.label) clauses.push(`labels = ${jqlEscape(options.label)}`);
|
|
407
|
-
if (options.sprint)
|
|
408
|
-
clauses.push(
|
|
409
|
-
options.sprint === "current" ? "sprint IN openSprints()" : `sprint = ${jqlEscape(options.sprint)}`
|
|
410
|
-
);
|
|
411
|
-
if (clauses.length === 0) clauses.push("assignee = currentUser()");
|
|
412
|
-
return `${clauses.join(" AND ")} ORDER BY updated DESC`;
|
|
413
|
-
};
|
|
414
393
|
var issueColumns = (ctx) => [
|
|
415
394
|
{ header: "KEY", value: (i) => i.key },
|
|
416
395
|
{ header: "STATUS", value: (i) => i.fields.status?.name ?? "\u2014" },
|
|
@@ -737,6 +716,7 @@ var registerProjectCommands = (program2) => {
|
|
|
737
716
|
// src/commands/misc.ts
|
|
738
717
|
import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
739
718
|
import { dirname } from "path";
|
|
719
|
+
import { configPath, readFileConfig } from "@kud/jira";
|
|
740
720
|
var registerSearchCommand = (program2) => {
|
|
741
721
|
program2.command("search <jql>").description("run a raw JQL query").option("-n, --limit <n>", "maximum issues to return", "50").option("--json", "emit JSON").action(async (jql, options) => {
|
|
742
722
|
const ctx = context();
|
|
@@ -851,7 +831,7 @@ Setup:
|
|
|
851
831
|
id.atlassian.com/manage-profile/security/api-tokens
|
|
852
832
|
jira init --base-url myorg.atlassian.net --email you@example.com
|
|
853
833
|
|
|
854
|
-
Everything else lives in ${
|
|
834
|
+
Everything else lives in ${configPath2()}, and any of it can be
|
|
855
835
|
overridden with ATLASSIAN_BASE_URL / ATLASSIAN_USER_EMAIL.
|
|
856
836
|
|
|
857
837
|
Examples:
|
|
@@ -908,7 +888,7 @@ var interactiveArgs = (argv) => {
|
|
|
908
888
|
var main = async () => {
|
|
909
889
|
const { screen, mock, isBare } = interactiveArgs(process.argv);
|
|
910
890
|
if (screen === "list" && isBare) {
|
|
911
|
-
const { SCREENS } = await import("./tui-
|
|
891
|
+
const { SCREENS } = await import("./tui-TWKZI63D.js");
|
|
912
892
|
process.stdout.write(`${SCREENS.join("\n")}
|
|
913
893
|
`);
|
|
914
894
|
return;
|
|
@@ -918,7 +898,7 @@ var main = async () => {
|
|
|
918
898
|
program.outputHelp();
|
|
919
899
|
return;
|
|
920
900
|
}
|
|
921
|
-
const { runTui } = await import("./tui-
|
|
901
|
+
const { runTui } = await import("./tui-TWKZI63D.js");
|
|
922
902
|
const [, key] = (screen ?? "").split(":");
|
|
923
903
|
await runTui({
|
|
924
904
|
screen: screen?.startsWith("detail") ? "detail" : "issues",
|