pipe-kan 0.23.5 → 0.24.1
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/dist/pipe-kan.js +53 -21
- package/package.json +1 -1
package/dist/pipe-kan.js
CHANGED
|
@@ -244,12 +244,13 @@ function takeValue(list, index, flag) {
|
|
|
244
244
|
return [glued, index];
|
|
245
245
|
return [list[index + 1] ?? "", index + 1];
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function parseFlags(flags) {
|
|
248
248
|
const list = tokens(flags.trim() || DEFAULT_FLAGS);
|
|
249
249
|
let assignee = "";
|
|
250
250
|
let epic = "";
|
|
251
251
|
let type = "";
|
|
252
252
|
let raw = "";
|
|
253
|
+
let projectsValue = "";
|
|
253
254
|
const statusEq = [];
|
|
254
255
|
const statusNeq = [];
|
|
255
256
|
for (let i = 0;i < list.length; i++) {
|
|
@@ -277,6 +278,10 @@ function flagsToJql(flags) {
|
|
|
277
278
|
statusEq.push(status);
|
|
278
279
|
continue;
|
|
279
280
|
}
|
|
281
|
+
if (token === "--projects") {
|
|
282
|
+
[projectsValue, i] = takeValue(list, i, "--projects");
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
280
285
|
if (token === "-q" || token === "--jql") {
|
|
281
286
|
raw = list[++i] ?? "";
|
|
282
287
|
continue;
|
|
@@ -285,9 +290,12 @@ function flagsToJql(flags) {
|
|
|
285
290
|
raw = token.slice(2);
|
|
286
291
|
}
|
|
287
292
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
293
|
+
const projects = projectsValue.split(",").map((p) => p.trim().toUpperCase()).filter(Boolean);
|
|
294
|
+
if (raw) {
|
|
295
|
+
return { jql: raw, projects };
|
|
296
|
+
}
|
|
297
|
+
const projectClause = projects.length ? `project in (${projects.map((p) => `"${p}"`).join(", ")})` : 'project="DEMO"';
|
|
298
|
+
const clauses = [projectClause];
|
|
291
299
|
if (assignee)
|
|
292
300
|
clauses.push(`assignee="${assignee}"`);
|
|
293
301
|
if (type)
|
|
@@ -298,7 +306,18 @@ function flagsToJql(flags) {
|
|
|
298
306
|
clauses.push(`status="${status}"`);
|
|
299
307
|
for (const status of statusNeq)
|
|
300
308
|
clauses.push(`status!="${status}"`);
|
|
301
|
-
return clauses.join(" AND ");
|
|
309
|
+
return { jql: clauses.join(" AND "), projects };
|
|
310
|
+
}
|
|
311
|
+
function flagsToJql(flags) {
|
|
312
|
+
return parseFlags(flags).jql;
|
|
313
|
+
}
|
|
314
|
+
function argvToFlags(argv) {
|
|
315
|
+
const args = argv.slice(2);
|
|
316
|
+
if (args.length === 0)
|
|
317
|
+
return "";
|
|
318
|
+
if (args.length === 1 && !args[0].startsWith("-"))
|
|
319
|
+
return args[0];
|
|
320
|
+
return args.join(" ");
|
|
302
321
|
}
|
|
303
322
|
|
|
304
323
|
// src/store.ts
|
|
@@ -430,6 +449,12 @@ Available states for issue ${key}: ${available}`
|
|
|
430
449
|
}
|
|
431
450
|
|
|
432
451
|
// src/cli.ts
|
|
452
|
+
function projectClause(flags) {
|
|
453
|
+
const { projects } = parseFlags(flags || DEFAULT_FLAGS);
|
|
454
|
+
if (!projects.length)
|
|
455
|
+
return 'project="DEMO"';
|
|
456
|
+
return `project in (${projects.map((p) => `"${p}"`).join(", ")})`;
|
|
457
|
+
}
|
|
433
458
|
function emptyList(text) {
|
|
434
459
|
return /no result found/i.test(text);
|
|
435
460
|
}
|
|
@@ -446,18 +471,18 @@ function issueKey(issue) {
|
|
|
446
471
|
function hasPaginate(args) {
|
|
447
472
|
return args.some((arg) => arg === "--paginate" || arg.startsWith("--paginate="));
|
|
448
473
|
}
|
|
449
|
-
function createStoreCli(store) {
|
|
474
|
+
function createStoreCli(store, defaultFlags = DEFAULT_FLAGS) {
|
|
450
475
|
return {
|
|
451
476
|
async list(flags) {
|
|
452
|
-
const issues = store.list(flagsToJql(flags ||
|
|
477
|
+
const issues = store.list(flagsToJql(flags || defaultFlags));
|
|
453
478
|
return JSON.stringify(issues, null, 2);
|
|
454
479
|
},
|
|
455
|
-
async listEpics() {
|
|
456
|
-
const issues = store.list(
|
|
480
|
+
async listEpics(queryFlags = defaultFlags) {
|
|
481
|
+
const issues = store.list(`${projectClause(queryFlags || defaultFlags)} AND type="Epic"`);
|
|
457
482
|
return JSON.stringify(issues, null, 2);
|
|
458
483
|
},
|
|
459
|
-
async listEpic(key) {
|
|
460
|
-
const issues = store.list(
|
|
484
|
+
async listEpic(key, queryFlags = defaultFlags) {
|
|
485
|
+
const issues = store.list(`${projectClause(queryFlags || defaultFlags)} AND parent="${key}"`);
|
|
461
486
|
return JSON.stringify(issues, null, 2);
|
|
462
487
|
},
|
|
463
488
|
async listChildren(keys) {
|
|
@@ -496,6 +521,7 @@ function resolveJiraBin(bin = process.env.JIRA_BIN ?? "jira", pathVar = process.
|
|
|
496
521
|
function createJiraCli(opts = {}) {
|
|
497
522
|
const bin = opts.bin ?? "jira";
|
|
498
523
|
const retryDelayMs = opts.retryDelayMs ?? 1000;
|
|
524
|
+
const defaultFlags = opts.flags ?? DEFAULT_FLAGS;
|
|
499
525
|
function fmt(args) {
|
|
500
526
|
return args.filter((arg) => arg !== "--raw").map((arg, i, all) => all[i - 1] === "-q" && arg.length > 48 ? `${arg.slice(0, 48)}…` : arg).join(" ");
|
|
501
527
|
}
|
|
@@ -585,15 +611,17 @@ function createJiraCli(opts = {}) {
|
|
|
585
611
|
const extra = (flags || DEFAULT_FLAGS).split(/\s+/).filter(Boolean);
|
|
586
612
|
return JSON.stringify(await listOnce(["issue", "list", ...extra, "--raw"]));
|
|
587
613
|
},
|
|
588
|
-
async listEpics() {
|
|
589
|
-
|
|
614
|
+
async listEpics(queryFlags = defaultFlags) {
|
|
615
|
+
const clause = projectClause(queryFlags || defaultFlags);
|
|
616
|
+
return listAll(["issue", "list", "-q", `${clause} AND type="Epic"`]);
|
|
590
617
|
},
|
|
591
|
-
async listEpic(key) {
|
|
618
|
+
async listEpic(key, queryFlags = defaultFlags) {
|
|
619
|
+
const clause = projectClause(queryFlags || defaultFlags);
|
|
592
620
|
return listAll([
|
|
593
621
|
"issue",
|
|
594
622
|
"list",
|
|
595
623
|
"-q",
|
|
596
|
-
|
|
624
|
+
`${clause} AND (parent="${key}" OR "Epic Link"="${key}")`
|
|
597
625
|
]);
|
|
598
626
|
},
|
|
599
627
|
async listChildren(keys) {
|
|
@@ -922,7 +950,7 @@ function createApp(opts) {
|
|
|
922
950
|
console.log("Refresh");
|
|
923
951
|
try {
|
|
924
952
|
const issues = await cli.list(flags);
|
|
925
|
-
const epics = await cli.listEpics();
|
|
953
|
+
const epics = await cli.listEpics(flags);
|
|
926
954
|
const nextPayload = JSON.parse(issues);
|
|
927
955
|
const nextEpics = JSON.parse(epics);
|
|
928
956
|
const keys = issuesToBoard(nextEpics).epics.map((epic) => epic.key);
|
|
@@ -973,7 +1001,7 @@ function createApp(opts) {
|
|
|
973
1001
|
if (columns.length)
|
|
974
1002
|
return { columns, epics: [] };
|
|
975
1003
|
}
|
|
976
|
-
return stampMissingEpic(issuesToBoard(JSON.parse(await cli.listEpic(epic))), epic);
|
|
1004
|
+
return stampMissingEpic(issuesToBoard(JSON.parse(await cli.listEpic(epic, flags))), epic);
|
|
977
1005
|
},
|
|
978
1006
|
async move(key, status) {
|
|
979
1007
|
const result = await tryMove(key, status);
|
|
@@ -1010,18 +1038,20 @@ function createApp(opts) {
|
|
|
1010
1038
|
// src/boot.ts
|
|
1011
1039
|
async function createBoardApp(opts) {
|
|
1012
1040
|
const env = opts.env ?? process.env;
|
|
1041
|
+
const flags = opts.flags ?? "";
|
|
1013
1042
|
const store = IssueStore.fromRaw(opts.raw);
|
|
1014
1043
|
const bin = resolveJiraBin(env.JIRA_BIN ?? "jira", env.PATH ?? "");
|
|
1015
1044
|
const cli = bin ? createJiraCli({
|
|
1016
1045
|
bin,
|
|
1017
1046
|
configPath: env.JIRA_CONFIG_FILE,
|
|
1018
|
-
token: env.JIRA_API_TOKEN
|
|
1019
|
-
|
|
1047
|
+
token: env.JIRA_API_TOKEN,
|
|
1048
|
+
flags
|
|
1049
|
+
}) : createStoreCli(store, flags);
|
|
1020
1050
|
const app = createApp({ store, cli });
|
|
1021
1051
|
if (opts.piped) {
|
|
1022
1052
|
app.hydrate(opts.raw);
|
|
1023
1053
|
} else {
|
|
1024
|
-
const local = createStoreCli(store);
|
|
1054
|
+
const local = createStoreCli(store, flags);
|
|
1025
1055
|
app.hydrate(JSON.parse(await local.list(app.flags)), { fromStore: true });
|
|
1026
1056
|
}
|
|
1027
1057
|
return { app, store, kind: bin ? "jira" : "store" };
|
|
@@ -12049,9 +12079,11 @@ function announce(line) {
|
|
|
12049
12079
|
async function runServer(opts) {
|
|
12050
12080
|
const piped = await readPipe();
|
|
12051
12081
|
const raw = piped ?? JSON.parse(readFileSync4(join8(opts.root, "fixtures/issues.json"), "utf8"));
|
|
12082
|
+
const flags = argvToFlags(process.argv);
|
|
12052
12083
|
const { app, store, kind } = await createBoardApp({
|
|
12053
12084
|
raw,
|
|
12054
|
-
piped: Boolean(piped)
|
|
12085
|
+
piped: Boolean(piped),
|
|
12086
|
+
flags
|
|
12055
12087
|
});
|
|
12056
12088
|
const server = createServer((req, res) => {
|
|
12057
12089
|
if (handleRequest(req, res, { app, store }))
|