@aaronshaf/confluence-cli 0.1.15

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 (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -0
  3. package/package.json +73 -0
  4. package/src/cli/commands/attachments.ts +113 -0
  5. package/src/cli/commands/clone.ts +188 -0
  6. package/src/cli/commands/comments.ts +56 -0
  7. package/src/cli/commands/create.ts +58 -0
  8. package/src/cli/commands/delete.ts +46 -0
  9. package/src/cli/commands/doctor.ts +161 -0
  10. package/src/cli/commands/duplicate-check.ts +89 -0
  11. package/src/cli/commands/file-rename.ts +113 -0
  12. package/src/cli/commands/folder-hierarchy.ts +241 -0
  13. package/src/cli/commands/info.ts +56 -0
  14. package/src/cli/commands/labels.ts +53 -0
  15. package/src/cli/commands/move.ts +23 -0
  16. package/src/cli/commands/open.ts +145 -0
  17. package/src/cli/commands/pull.ts +241 -0
  18. package/src/cli/commands/push-errors.ts +40 -0
  19. package/src/cli/commands/push.ts +699 -0
  20. package/src/cli/commands/search.ts +62 -0
  21. package/src/cli/commands/setup.ts +124 -0
  22. package/src/cli/commands/spaces.ts +42 -0
  23. package/src/cli/commands/status.ts +88 -0
  24. package/src/cli/commands/tree.ts +190 -0
  25. package/src/cli/help.ts +425 -0
  26. package/src/cli/index.ts +413 -0
  27. package/src/cli/utils/browser.ts +34 -0
  28. package/src/cli/utils/progress-reporter.ts +49 -0
  29. package/src/cli.ts +6 -0
  30. package/src/lib/config.ts +156 -0
  31. package/src/lib/confluence-client/attachment-operations.ts +221 -0
  32. package/src/lib/confluence-client/client.ts +653 -0
  33. package/src/lib/confluence-client/comment-operations.ts +60 -0
  34. package/src/lib/confluence-client/folder-operations.ts +203 -0
  35. package/src/lib/confluence-client/index.ts +47 -0
  36. package/src/lib/confluence-client/label-operations.ts +102 -0
  37. package/src/lib/confluence-client/page-operations.ts +270 -0
  38. package/src/lib/confluence-client/search-operations.ts +60 -0
  39. package/src/lib/confluence-client/types.ts +329 -0
  40. package/src/lib/confluence-client/user-operations.ts +58 -0
  41. package/src/lib/dependency-sorter.ts +233 -0
  42. package/src/lib/errors.ts +237 -0
  43. package/src/lib/file-scanner.ts +195 -0
  44. package/src/lib/formatters.ts +314 -0
  45. package/src/lib/health-check.ts +204 -0
  46. package/src/lib/markdown/converter.ts +427 -0
  47. package/src/lib/markdown/frontmatter.ts +116 -0
  48. package/src/lib/markdown/html-converter.ts +398 -0
  49. package/src/lib/markdown/index.ts +21 -0
  50. package/src/lib/markdown/link-converter.ts +189 -0
  51. package/src/lib/markdown/reference-updater.ts +251 -0
  52. package/src/lib/markdown/slugify.ts +32 -0
  53. package/src/lib/page-state.ts +195 -0
  54. package/src/lib/resolve-page-target.ts +33 -0
  55. package/src/lib/space-config.ts +264 -0
  56. package/src/lib/sync/cleanup.ts +50 -0
  57. package/src/lib/sync/folder-path.ts +61 -0
  58. package/src/lib/sync/index.ts +2 -0
  59. package/src/lib/sync/link-resolution-pass.ts +139 -0
  60. package/src/lib/sync/sync-engine.ts +681 -0
  61. package/src/lib/sync/sync-specific.ts +221 -0
  62. package/src/lib/sync/types.ts +42 -0
  63. package/src/test/attachments.test.ts +68 -0
  64. package/src/test/clone.test.ts +373 -0
  65. package/src/test/comments.test.ts +53 -0
  66. package/src/test/config.test.ts +209 -0
  67. package/src/test/confluence-client.test.ts +535 -0
  68. package/src/test/delete.test.ts +39 -0
  69. package/src/test/dependency-sorter.test.ts +384 -0
  70. package/src/test/errors.test.ts +199 -0
  71. package/src/test/file-rename.test.ts +305 -0
  72. package/src/test/file-scanner.test.ts +331 -0
  73. package/src/test/folder-hierarchy.test.ts +337 -0
  74. package/src/test/formatters.test.ts +213 -0
  75. package/src/test/html-converter.test.ts +399 -0
  76. package/src/test/info.test.ts +56 -0
  77. package/src/test/labels.test.ts +70 -0
  78. package/src/test/link-conversion-integration.test.ts +189 -0
  79. package/src/test/link-converter.test.ts +413 -0
  80. package/src/test/link-resolution-pass.test.ts +368 -0
  81. package/src/test/markdown.test.ts +443 -0
  82. package/src/test/mocks/handlers.ts +228 -0
  83. package/src/test/move.test.ts +53 -0
  84. package/src/test/msw-schema-validation.ts +151 -0
  85. package/src/test/page-state.test.ts +542 -0
  86. package/src/test/push.test.ts +551 -0
  87. package/src/test/reference-updater.test.ts +293 -0
  88. package/src/test/resolve-page-target.test.ts +55 -0
  89. package/src/test/search.test.ts +64 -0
  90. package/src/test/setup-msw.ts +75 -0
  91. package/src/test/space-config.test.ts +516 -0
  92. package/src/test/spaces.test.ts +53 -0
  93. package/src/test/sync-engine.test.ts +486 -0
  94. package/src/types/turndown-plugin-gfm.d.ts +9 -0
@@ -0,0 +1,425 @@
1
+ import chalk from 'chalk';
2
+
3
+ export function showSetupHelp(): void {
4
+ console.log(`
5
+ ${chalk.bold('cn setup - Configure Confluence credentials')}
6
+
7
+ ${chalk.yellow('Usage:')}
8
+ cn setup
9
+
10
+ ${chalk.yellow('Description:')}
11
+ Interactive setup wizard that configures:
12
+ - Confluence Cloud URL (https://*.atlassian.net)
13
+ - Email address
14
+ - API token (create at https://id.atlassian.com/manage/api-tokens)
15
+
16
+ Stores configuration securely in ~/.cn/config.json with 600 permissions.
17
+
18
+ ${chalk.yellow('Options:')}
19
+ --help Show this help message
20
+
21
+ ${chalk.yellow('Examples:')}
22
+ cn setup Start interactive setup
23
+ `);
24
+ }
25
+
26
+ export function showCloneHelp(): void {
27
+ console.log(`
28
+ ${chalk.bold('cn clone - Clone one or more Confluence spaces to new folders')}
29
+
30
+ ${chalk.yellow('Usage:')}
31
+ cn clone <SPACE_KEY> [SPACE_KEY...]
32
+
33
+ ${chalk.yellow('Description:')}
34
+ Creates new directories and initializes them for Confluence spaces.
35
+ Similar to "git clone" - sets up everything needed to pull pages.
36
+ Each space is cloned into a directory named after its space key.
37
+
38
+ ${chalk.yellow('Arguments:')}
39
+ SPACE_KEY One or more Confluence space keys (required)
40
+
41
+ ${chalk.yellow('Options:')}
42
+ --help Show this help message
43
+
44
+ ${chalk.yellow('Examples:')}
45
+ cn clone DOCS Clone DOCS space to ./DOCS/
46
+ cn clone ABC DEF GHI Clone multiple spaces to ./ABC/, ./DEF/, ./GHI/
47
+ cn clone ENG PROD TEST Clone three spaces sequentially
48
+ `);
49
+ }
50
+
51
+ export function showPullHelp(): void {
52
+ console.log(`
53
+ ${chalk.bold('cn pull - Pull Confluence space to local folder')}
54
+
55
+ ${chalk.yellow('Usage:')}
56
+ cn pull [options]
57
+
58
+ ${chalk.yellow('Description:')}
59
+ Pulls pages from Confluence to the current directory.
60
+ Must be run in a directory initialized with "cn clone".
61
+
62
+ ${chalk.yellow('Modes:')}
63
+ ${chalk.cyan('Smart pull (default)')}
64
+ Only pulls pages that have changed since last pull.
65
+ Compares version numbers to detect modifications.
66
+ Handles renames and moves automatically.
67
+
68
+ ${chalk.cyan('Full pull (--force)')}
69
+ Re-downloads all pages regardless of local state.
70
+ Use when local state may be corrupted or out of sync.
71
+
72
+ ${chalk.cyan('Page-specific pull (--page)')}
73
+ Force re-download specific pages regardless of version.
74
+ Useful for re-converting pages after converter improvements.
75
+
76
+ ${chalk.yellow('Options:')}
77
+ --dry-run Show what would be pulled without making changes
78
+ --force Full re-pull, ignore local state
79
+ --page <path-or-id> Force resync specific page (can use multiple times)
80
+ --depth <n> Limit depth
81
+ --help Show this help message
82
+
83
+ ${chalk.yellow('Examples:')}
84
+ cn pull Smart pull (only changes)
85
+ cn pull --dry-run Preview changes
86
+ cn pull --force Full re-pull all pages
87
+ cn pull --page ./docs/page.md Force resync specific file
88
+ cn pull --page 123456 --page 789 Force resync multiple pages by ID
89
+ `);
90
+ }
91
+
92
+ export function showPushHelp(): void {
93
+ console.log(`
94
+ ${chalk.bold('cn push - Push local markdown files to Confluence')}
95
+
96
+ ${chalk.yellow('Usage:')}
97
+ cn push [file] [options]
98
+
99
+ ${chalk.yellow('Description:')}
100
+ Push local markdown files to Confluence.
101
+
102
+ With a file argument: pushes that single file.
103
+ Without arguments: scans for changed files and prompts y/n for each.
104
+
105
+ ${chalk.yellow('Arguments:')}
106
+ file Path to markdown file (optional)
107
+
108
+ ${chalk.yellow('Options:')}
109
+ --force Ignore version conflicts and overwrite
110
+ --dry-run Preview changes without pushing
111
+ --help Show this help message
112
+
113
+ ${chalk.yellow('Examples:')}
114
+ cn push Scan and prompt for all changed files
115
+ cn push --dry-run Preview what would be pushed
116
+ cn push ./docs/page.md Push single page
117
+ cn push ./docs/page.md --force Force push (ignore version conflict)
118
+
119
+ ${chalk.yellow('Notes:')}
120
+ - New files (no page_id) will be created on Confluence
121
+ - Modified files are detected by comparing file mtime vs synced_at
122
+ - Only basic markdown elements are fully supported
123
+ - Files are automatically renamed to match page titles (except index.md/README.md)
124
+ `);
125
+ }
126
+
127
+ export function showStatusHelp(): void {
128
+ console.log(`
129
+ ${chalk.bold('cn status - Check connection and sync status')}
130
+
131
+ ${chalk.yellow('Usage:')}
132
+ cn status [options]
133
+
134
+ ${chalk.yellow('Description:')}
135
+ Shows the current configuration, connection status, and sync state.
136
+
137
+ ${chalk.yellow('Options:')}
138
+ --xml Output in XML format for LLM parsing
139
+ --help Show this help message
140
+
141
+ ${chalk.yellow('Examples:')}
142
+ cn status Show status with colored output
143
+ cn status --xml Show status in XML format
144
+ `);
145
+ }
146
+
147
+ export function showTreeHelp(): void {
148
+ console.log(`
149
+ ${chalk.bold('cn tree - Display page hierarchy')}
150
+
151
+ ${chalk.yellow('Usage:')}
152
+ cn tree [space-key] [options]
153
+
154
+ ${chalk.yellow('Description:')}
155
+ Displays the page hierarchy for a space as an ASCII tree.
156
+ If no space key is provided, uses the space in the current directory.
157
+
158
+ ${chalk.yellow('Options:')}
159
+ --remote Fetch live from API (default)
160
+ --local Use cached sync state
161
+ --depth <n> Limit tree depth
162
+ --xml Output in XML format for LLM parsing
163
+ --help Show this help message
164
+
165
+ ${chalk.yellow('Examples:')}
166
+ cn tree Show tree for current directory's space
167
+ cn tree DOCS Show tree for DOCS space
168
+ cn tree --depth 2 Limit to 2 levels deep
169
+ cn tree --xml Output in XML format
170
+ `);
171
+ }
172
+
173
+ export function showOpenHelp(): void {
174
+ console.log(`
175
+ ${chalk.bold('cn open - Open page in browser')}
176
+
177
+ ${chalk.yellow('Usage:')}
178
+ cn open [page]
179
+ cn open [options]
180
+
181
+ ${chalk.yellow('Description:')}
182
+ Opens a Confluence page in your default browser.
183
+ Without arguments, opens the space home page.
184
+
185
+ ${chalk.yellow('Arguments:')}
186
+ page Page title, file path, or page ID
187
+
188
+ ${chalk.yellow('Options:')}
189
+ --space <key> Specify space key
190
+ --help Show this help message
191
+
192
+ ${chalk.yellow('Examples:')}
193
+ cn open Open space home
194
+ cn open "Getting Started" Open page by title
195
+ cn open ./docs/page.md Open page from local file
196
+ cn open 123456789 Open page by ID
197
+ `);
198
+ }
199
+
200
+ export function showSpacesHelp(): void {
201
+ console.log(`
202
+ ${chalk.bold('cn spaces - List available Confluence spaces')}
203
+
204
+ ${chalk.yellow('Usage:')}
205
+ cn spaces [options]
206
+
207
+ ${chalk.yellow('Options:')}
208
+ --xml Output in XML format
209
+ --help Show this help message
210
+ `);
211
+ }
212
+
213
+ export function showSearchHelp(): void {
214
+ console.log(`
215
+ ${chalk.bold('cn search - Search pages using CQL')}
216
+
217
+ ${chalk.yellow('Usage:')}
218
+ cn search <query> [options]
219
+
220
+ ${chalk.yellow('Arguments:')}
221
+ query Search query string (required)
222
+
223
+ ${chalk.yellow('Options:')}
224
+ --space <key> Narrow search to a specific space
225
+ --limit <n> Maximum results (default: 10)
226
+ --xml Output in XML format
227
+ --help Show this help message
228
+
229
+ ${chalk.yellow('Examples:')}
230
+ cn search "authentication"
231
+ cn search "api" --space DOCS
232
+ `);
233
+ }
234
+
235
+ export function showInfoHelp(): void {
236
+ console.log(`
237
+ ${chalk.bold('cn info - Show page info and labels')}
238
+
239
+ ${chalk.yellow('Usage:')}
240
+ cn info <id|file> [options]
241
+
242
+ ${chalk.yellow('Arguments:')}
243
+ id|file Page ID or path to local .md file
244
+
245
+ ${chalk.yellow('Options:')}
246
+ --xml Output in XML format
247
+ --help Show this help message
248
+ `);
249
+ }
250
+
251
+ export function showCreateHelp(): void {
252
+ console.log(`
253
+ ${chalk.bold('cn create - Create a new Confluence page')}
254
+
255
+ ${chalk.yellow('Usage:')}
256
+ cn create <title> [options]
257
+
258
+ ${chalk.yellow('Arguments:')}
259
+ title Page title (required)
260
+
261
+ ${chalk.yellow('Options:')}
262
+ --space <key> Space key (required if not in cloned dir)
263
+ --parent <id> Parent page ID
264
+ --open Open page in browser after creation
265
+ --help Show this help message
266
+ `);
267
+ }
268
+
269
+ export function showDeleteHelp(): void {
270
+ console.log(`
271
+ ${chalk.bold('cn delete - Delete a Confluence page')}
272
+
273
+ ${chalk.yellow('Usage:')}
274
+ cn delete <id> [options]
275
+
276
+ ${chalk.yellow('Arguments:')}
277
+ id Page ID (required)
278
+
279
+ ${chalk.yellow('Options:')}
280
+ --force Skip confirmation prompt
281
+ --help Show this help message
282
+ `);
283
+ }
284
+
285
+ export function showCommentsHelp(): void {
286
+ console.log(`
287
+ ${chalk.bold('cn comments - Show footer comments for a page')}
288
+
289
+ ${chalk.yellow('Usage:')}
290
+ cn comments <id|file> [options]
291
+
292
+ ${chalk.yellow('Arguments:')}
293
+ id|file Page ID or path to local .md file
294
+
295
+ ${chalk.yellow('Options:')}
296
+ --xml Output in XML format
297
+ --help Show this help message
298
+ `);
299
+ }
300
+
301
+ export function showLabelsHelp(): void {
302
+ console.log(`
303
+ ${chalk.bold('cn labels - Manage page labels')}
304
+
305
+ ${chalk.yellow('Usage:')}
306
+ cn labels <id|file> [options]
307
+
308
+ ${chalk.yellow('Arguments:')}
309
+ id|file Page ID or path to local .md file
310
+
311
+ ${chalk.yellow('Options:')}
312
+ --add <label> Add a label
313
+ --remove <label> Remove a label
314
+ --xml Output in XML format
315
+ --help Show this help message
316
+ `);
317
+ }
318
+
319
+ export function showMoveHelp(): void {
320
+ console.log(`
321
+ ${chalk.bold('cn move - Move a page to a new parent')}
322
+
323
+ ${chalk.yellow('Usage:')}
324
+ cn move <id|file> <parentId>
325
+
326
+ ${chalk.yellow('Arguments:')}
327
+ id|file Page ID or path to local .md file
328
+ parentId Target parent page ID
329
+
330
+ ${chalk.yellow('Options:')}
331
+ --help Show this help message
332
+ `);
333
+ }
334
+
335
+ export function showAttachmentsHelp(): void {
336
+ console.log(`
337
+ ${chalk.bold('cn attachments - Manage page attachments')}
338
+
339
+ ${chalk.yellow('Usage:')}
340
+ cn attachments <id|file> [options]
341
+
342
+ ${chalk.yellow('Arguments:')}
343
+ id|file Page ID or path to local .md file
344
+
345
+ ${chalk.yellow('Options:')}
346
+ --upload <file> Upload a file as attachment
347
+ --download <id> Download an attachment by ID
348
+ --delete <id> Delete an attachment by ID
349
+ --xml Output in XML format
350
+ --help Show this help message
351
+ `);
352
+ }
353
+
354
+ export function showDoctorHelp(): void {
355
+ console.log(`
356
+ ${chalk.bold('cn doctor - Health check for synced spaces')}
357
+
358
+ ${chalk.yellow('Usage:')}
359
+ cn doctor [options]
360
+
361
+ ${chalk.yellow('Description:')}
362
+ Scans the current directory for common issues:
363
+ - Duplicate page_ids (same page in multiple files)
364
+ - Orphaned files (local files without Confluence pages)
365
+ - Version mismatches
366
+
367
+ ${chalk.yellow('Options:')}
368
+ --fix Auto-fix issues (delete stale files)
369
+ --xml Output in XML format for LLM parsing
370
+ --help Show this help message
371
+
372
+ ${chalk.yellow('Examples:')}
373
+ cn doctor Run health check interactively
374
+ cn doctor --fix Auto-fix all detected issues
375
+ cn doctor --xml Output results in XML format
376
+ `);
377
+ }
378
+
379
+ export function showHelp(): void {
380
+ console.log(`
381
+ ${chalk.bold('cn - Confluence CLI')}
382
+
383
+ Sync Confluence spaces to local markdown files.
384
+
385
+ ${chalk.yellow('Commands:')}
386
+ cn setup Configure Confluence credentials
387
+ cn clone Clone a space to a new folder
388
+ cn pull Pull space to local folder
389
+ cn push Push local file to Confluence
390
+ cn status Check connection and sync status
391
+ cn tree Display page hierarchy
392
+ cn open Open page in browser
393
+ cn doctor Health check for sync issues
394
+ cn search Search pages using CQL
395
+ cn spaces List available spaces
396
+ cn info Show page info and labels
397
+ cn create Create a new page
398
+ cn delete Delete a page
399
+ cn comments Show page comments
400
+ cn labels Manage page labels
401
+ cn move Move a page to a new parent
402
+ cn attachments Manage page attachments
403
+
404
+ ${chalk.yellow('Global Options:')}
405
+ --help, -h Show help message
406
+ --version, -v Show version number
407
+ --verbose Enable verbose output
408
+ --xml Output in XML format (where supported)
409
+
410
+ ${chalk.yellow('Environment Variables:')}
411
+ CN_CONFIG_PATH Override config file location
412
+ CN_DEBUG Enable debug logging
413
+ NO_COLOR Disable colored output
414
+
415
+ ${chalk.yellow('Examples:')}
416
+ cn setup Configure credentials
417
+ cn clone DOCS Clone DOCS space to ./DOCS
418
+ cn pull Pull changes
419
+ cn tree Show page hierarchy
420
+ cn open "My Page" Open page in browser
421
+
422
+ ${chalk.gray('For more information on a command, run: cn <command> --help')}
423
+ ${chalk.gray('Confluence REST API reference: https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/')}
424
+ `);
425
+ }