jiradc-cli 1.0.16-gd08a3c3.1 → 1.0.17
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/index.js +106 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1500,6 +1500,111 @@ Examples:
|
|
|
1500
1500
|
update3(sprint);
|
|
1501
1501
|
}
|
|
1502
1502
|
|
|
1503
|
+
// src/commands/token/client.ts
|
|
1504
|
+
import { JiraClient as JiraClient2 } from "jira-data-center-client";
|
|
1505
|
+
function getTokenClient(options2 = {}) {
|
|
1506
|
+
const baseUrl = process.env.JIRA_URL;
|
|
1507
|
+
const username = options2.basicUsername ?? process.env.JIRA_BASIC_USERNAME;
|
|
1508
|
+
const password = options2.basicPassword ?? process.env.JIRA_BASIC_PASSWORD;
|
|
1509
|
+
if (!baseUrl || !username || !password) {
|
|
1510
|
+
const missing = [
|
|
1511
|
+
...!baseUrl ? ["JIRA_URL"] : [],
|
|
1512
|
+
...!username ? ["JIRA_BASIC_USERNAME (or --basic-username)"] : [],
|
|
1513
|
+
...!password ? ["JIRA_BASIC_PASSWORD (or --basic-password)"] : []
|
|
1514
|
+
];
|
|
1515
|
+
process.stderr.write(
|
|
1516
|
+
`${JSON.stringify({
|
|
1517
|
+
error: `Missing required credentials: ${missing.join(", ")}`,
|
|
1518
|
+
hint: "Set JIRA_BASIC_USERNAME and JIRA_BASIC_PASSWORD in your shell profile, or pass --basic-username / --basic-password."
|
|
1519
|
+
})}
|
|
1520
|
+
`
|
|
1521
|
+
);
|
|
1522
|
+
process.exit(1);
|
|
1523
|
+
}
|
|
1524
|
+
const client = new JiraClient2({ baseUrl });
|
|
1525
|
+
return { client, username, password };
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
// src/commands/token/create.ts
|
|
1529
|
+
function create4(parent) {
|
|
1530
|
+
parent.command("create").description("Create a Personal Access Token. The secret is returned exactly once.").requiredOption("--name <name>", "Token name").option(
|
|
1531
|
+
"--expiration-duration <days>",
|
|
1532
|
+
"Token lifetime in days. Omit for a non-expiring token (admin policy permitting).",
|
|
1533
|
+
positiveInt
|
|
1534
|
+
).option("--basic-username <u>", "Override $JIRA_BASIC_USERNAME").option(
|
|
1535
|
+
"--basic-password <p>",
|
|
1536
|
+
"Override $JIRA_BASIC_PASSWORD (caution: visible in process table; prefer the env var)"
|
|
1537
|
+
).addHelpText(
|
|
1538
|
+
"after",
|
|
1539
|
+
`
|
|
1540
|
+
Examples:
|
|
1541
|
+
$ jiradc token create --name my-pat # non-expiring
|
|
1542
|
+
$ jiradc token create --name svc-token --expiration-duration 365
|
|
1543
|
+
`
|
|
1544
|
+
).action(async (opts) => {
|
|
1545
|
+
const { client, username, password } = getTokenClient({
|
|
1546
|
+
basicUsername: opts.basicUsername,
|
|
1547
|
+
basicPassword: opts.basicPassword
|
|
1548
|
+
});
|
|
1549
|
+
const result = await client.accessTokens.create({
|
|
1550
|
+
username,
|
|
1551
|
+
password,
|
|
1552
|
+
name: opts.name,
|
|
1553
|
+
expirationDuration: opts.expirationDuration
|
|
1554
|
+
});
|
|
1555
|
+
output(result);
|
|
1556
|
+
});
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
// src/commands/token/list.ts
|
|
1560
|
+
function list6(parent) {
|
|
1561
|
+
parent.command("list").description("List Personal Access Tokens owned by the authenticated user (secrets not included)").option("--basic-username <u>", "Override $JIRA_BASIC_USERNAME").option(
|
|
1562
|
+
"--basic-password <p>",
|
|
1563
|
+
"Override $JIRA_BASIC_PASSWORD (caution: visible in process table; prefer the env var)"
|
|
1564
|
+
).action(async (opts) => {
|
|
1565
|
+
const { client, username, password } = getTokenClient({
|
|
1566
|
+
basicUsername: opts.basicUsername,
|
|
1567
|
+
basicPassword: opts.basicPassword
|
|
1568
|
+
});
|
|
1569
|
+
output(await client.accessTokens.list({ username, password }));
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
// src/commands/token/revoke.ts
|
|
1574
|
+
function revoke(parent) {
|
|
1575
|
+
parent.command("revoke").description("Revoke a Personal Access Token by id").requiredOption("--id <tokenId>", "Token id to revoke", positiveInt).option("--basic-username <u>", "Override $JIRA_BASIC_USERNAME").option(
|
|
1576
|
+
"--basic-password <p>",
|
|
1577
|
+
"Override $JIRA_BASIC_PASSWORD (caution: visible in process table; prefer the env var)"
|
|
1578
|
+
).action(async (opts) => {
|
|
1579
|
+
const { client, username, password } = getTokenClient({
|
|
1580
|
+
basicUsername: opts.basicUsername,
|
|
1581
|
+
basicPassword: opts.basicPassword
|
|
1582
|
+
});
|
|
1583
|
+
await client.accessTokens.revoke({ username, password, tokenId: opts.id });
|
|
1584
|
+
output({ revoked: opts.id });
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
// src/commands/token/index.ts
|
|
1589
|
+
function registerTokenCommands(program2) {
|
|
1590
|
+
const token = program2.command("token").description("Personal Access Token management").addHelpText(
|
|
1591
|
+
"after",
|
|
1592
|
+
`
|
|
1593
|
+
Examples:
|
|
1594
|
+
$ jiradc token list
|
|
1595
|
+
$ jiradc token create --name my-pat
|
|
1596
|
+
$ jiradc token revoke --id 173
|
|
1597
|
+
|
|
1598
|
+
Auth:
|
|
1599
|
+
Requires JIRA_BASIC_USERNAME + JIRA_BASIC_PASSWORD
|
|
1600
|
+
(or --basic-username / --basic-password on any subcommand).
|
|
1601
|
+
`
|
|
1602
|
+
);
|
|
1603
|
+
create4(token);
|
|
1604
|
+
list6(token);
|
|
1605
|
+
revoke(token);
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1503
1608
|
// src/commands/user/get.ts
|
|
1504
1609
|
function get3(parent) {
|
|
1505
1610
|
parent.command("get <username>").description("Get a user profile by exact username or key").option("--by-key", "Treat the positional argument as a user key instead of a username").addHelpText("after", "\nExamples:\n jiradc user get jsmith\n jiradc user get JIRAUSER10100 --by-key").action(async (identifier, opts) => {
|
|
@@ -1602,6 +1707,7 @@ registerBoardCommands(program);
|
|
|
1602
1707
|
registerSprintCommands(program);
|
|
1603
1708
|
registerFieldCommands(program);
|
|
1604
1709
|
registerUserCommands(program);
|
|
1710
|
+
registerTokenCommands(program);
|
|
1605
1711
|
try {
|
|
1606
1712
|
await program.parseAsync();
|
|
1607
1713
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jiradc-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"publish": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"commander": "^13.1.0",
|
|
15
|
-
"jira-data-center-client": "1.0.
|
|
15
|
+
"jira-data-center-client": "1.0.35"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "24.10.4",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"tsx": "^4.19.2",
|
|
23
23
|
"typescript": "^5.7.2",
|
|
24
24
|
"vitest": "^4.0.16",
|
|
25
|
-
"config-
|
|
26
|
-
"config-
|
|
25
|
+
"config-typescript": "0.0.0",
|
|
26
|
+
"config-eslint": "0.0.0"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=22.0.0"
|