confluencedc-cli 1.0.6 → 1.0.8

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -7
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -6,6 +6,28 @@ import { Command } from "commander";
6
6
 
7
7
  // src/utils/client.ts
8
8
  import { ConfluenceClient } from "confluence-data-center-client";
9
+
10
+ // src/utils/credentials.ts
11
+ function getCredentialInfo() {
12
+ const baseUrl = process.env.CONFLUENCE_URL;
13
+ const token = process.env.CONFLUENCE_TOKEN;
14
+ return {
15
+ environment: {
16
+ CONFLUENCE_URL: {
17
+ value: baseUrl ?? null,
18
+ description: "Your Confluence Server base URL (e.g., https://confluence.example.com)"
19
+ },
20
+ CONFLUENCE_TOKEN: {
21
+ value: token ? "<set>" : null,
22
+ description: "Personal Access Token"
23
+ }
24
+ },
25
+ tokenUrl: `${baseUrl ?? "https://confluence.example.com"}/plugins/personalaccesstokens/usertokens.action`,
26
+ hint: "Export environment variables in your shell profile (e.g., ~/.zshrc)."
27
+ };
28
+ }
29
+
30
+ // src/utils/client.ts
9
31
  function getClient() {
10
32
  const baseUrl = process.env.CONFLUENCE_URL;
11
33
  const token = process.env.CONFLUENCE_TOKEN;
@@ -14,11 +36,7 @@ function getClient() {
14
36
  process.stderr.write(
15
37
  `${JSON.stringify({
16
38
  error: `Missing required environment variables: ${missing.join(", ")}`,
17
- setup: {
18
- CONFLUENCE_URL: "Your Confluence Server base URL (e.g., https://confluence.example.com)",
19
- CONFLUENCE_TOKEN: "Personal Access Token \u2014 generate in Confluence > Profile > Personal Access Tokens"
20
- },
21
- hint: "Export these in your shell profile (e.g., ~/.zshrc)."
39
+ ...getCredentialInfo()
22
40
  })}
23
41
  `
24
42
  );
@@ -47,8 +65,12 @@ function stripResponse(obj) {
47
65
  }
48
66
 
49
67
  // src/utils/output.ts
68
+ var prettyPrint = false;
69
+ function setPretty(value) {
70
+ prettyPrint = value;
71
+ }
50
72
  function output(data) {
51
- process.stdout.write(`${JSON.stringify(stripResponse(data), null, 2)}
73
+ process.stdout.write(`${JSON.stringify(stripResponse(data), null, prettyPrint ? 2 : void 0)}
52
74
  `);
53
75
  }
54
76
  function handleError(err) {
@@ -69,7 +91,7 @@ function handleError(err) {
69
91
  process.stderr.write(
70
92
  `${JSON.stringify({
71
93
  error: "Authentication failed (HTTP 401)",
72
- hint: "Verify that CONFLUENCE_URL and CONFLUENCE_TOKEN are set correctly. The token may be expired or invalid."
94
+ ...getCredentialInfo()
73
95
  })}
74
96
  `
75
97
  );
@@ -579,6 +601,10 @@ ${styleText("bold", "Examples:")}
579
601
  ${DIM}$${RESET} confluencedc attachment list 12345
580
602
  `
581
603
  );
604
+ program.option("--pretty", "Pretty-print JSON output");
605
+ program.hook("preAction", (thisCommand) => {
606
+ if (thisCommand.optsWithGlobals().pretty) setPretty(true);
607
+ });
582
608
  registerSearchCommands(program);
583
609
  registerPageCommands(program);
584
610
  registerCommentCommands(program);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "confluencedc-cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "publish": true,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,8 +22,8 @@
22
22
  "tsx": "^4.19.2",
23
23
  "typescript": "^5.7.2",
24
24
  "vitest": "^4.0.16",
25
- "config-typescript": "0.0.0",
26
- "config-eslint": "0.0.0"
25
+ "config-eslint": "0.0.0",
26
+ "config-typescript": "0.0.0"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">=22.0.0"