@hesed/conni 0.7.1 → 0.8.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 +48 -22
- package/dist/commands/conni/auth/add.d.ts +2 -15
- package/dist/commands/conni/auth/add.js +7 -60
- package/dist/commands/conni/auth/delete.d.ts +2 -0
- package/dist/commands/conni/auth/delete.js +2 -0
- package/dist/commands/conni/auth/list.d.ts +2 -20
- package/dist/commands/conni/auth/list.js +2 -36
- package/dist/commands/conni/auth/profile.d.ts +2 -11
- package/dist/commands/conni/auth/profile.js +2 -23
- package/dist/commands/conni/auth/test.d.ts +2 -12
- package/dist/commands/conni/auth/test.js +7 -37
- package/dist/commands/conni/auth/update.d.ts +2 -15
- package/dist/commands/conni/auth/update.js +7 -83
- package/dist/commands/conni/content/attachment-download.js +5 -5
- package/dist/commands/conni/content/attachment.js +5 -5
- package/dist/commands/conni/content/comment-delete.js +5 -5
- package/dist/commands/conni/content/comment-update.js +5 -5
- package/dist/commands/conni/content/comment.js +5 -5
- package/dist/commands/conni/content/create.js +5 -7
- package/dist/commands/conni/content/delete.js +5 -5
- package/dist/commands/conni/content/get.js +5 -5
- package/dist/commands/conni/content/search.js +5 -5
- package/dist/commands/conni/content/update.js +5 -5
- package/dist/commands/conni/space/get.js +5 -5
- package/dist/commands/conni/space/list.js +5 -5
- package/dist/conni/conni-api.d.ts +2 -14
- package/dist/conni/conni-client.d.ts +17 -95
- package/dist/conni/conni-client.js +17 -115
- package/oclif.manifest.json +139 -94
- package/package.json +2 -2
- package/dist/config.d.ts +0 -14
- package/dist/config.js +0 -83
- package/dist/format.d.ts +0 -4
- package/dist/format.js +0 -10
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ $ npm install -g @hesed/conni
|
|
|
26
26
|
$ conni COMMAND
|
|
27
27
|
running command...
|
|
28
28
|
$ conni (--version)
|
|
29
|
-
@hesed/conni/0.
|
|
29
|
+
@hesed/conni/0.8.0 linux-x64 node-v24.15.0
|
|
30
30
|
$ conni --help [COMMAND]
|
|
31
31
|
USAGE
|
|
32
32
|
$ conni COMMAND
|
|
@@ -38,6 +38,7 @@ USAGE
|
|
|
38
38
|
|
|
39
39
|
<!-- commands -->
|
|
40
40
|
* [`conni conni auth add`](#conni-conni-auth-add)
|
|
41
|
+
* [`conni conni auth delete`](#conni-conni-auth-delete)
|
|
41
42
|
* [`conni conni auth list`](#conni-conni-auth-list)
|
|
42
43
|
* [`conni conni auth profile`](#conni-conni-auth-profile)
|
|
43
44
|
* [`conni conni auth test`](#conni-conni-auth-test)
|
|
@@ -57,7 +58,7 @@ USAGE
|
|
|
57
58
|
|
|
58
59
|
## `conni conni auth add`
|
|
59
60
|
|
|
60
|
-
Add
|
|
61
|
+
Add Confluence authentication
|
|
61
62
|
|
|
62
63
|
```
|
|
63
64
|
USAGE
|
|
@@ -67,13 +68,13 @@ FLAGS
|
|
|
67
68
|
-e, --email=<value> Account email
|
|
68
69
|
-p, --profile=<value> Profile name
|
|
69
70
|
-t, --token=<value> (required) API Token
|
|
70
|
-
-u, --url=<value> (required)
|
|
71
|
+
-u, --url=<value> (required) Confluence instance URL (start with https://)
|
|
71
72
|
|
|
72
73
|
GLOBAL FLAGS
|
|
73
74
|
--json Format output as json.
|
|
74
75
|
|
|
75
76
|
DESCRIPTION
|
|
76
|
-
Add
|
|
77
|
+
Add Confluence authentication
|
|
77
78
|
|
|
78
79
|
EXAMPLES
|
|
79
80
|
$ conni conni auth add
|
|
@@ -81,7 +82,32 @@ EXAMPLES
|
|
|
81
82
|
$ conni conni auth add --profile work
|
|
82
83
|
```
|
|
83
84
|
|
|
84
|
-
_See code: [src/commands/conni/auth/add.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
85
|
+
_See code: [src/commands/conni/auth/add.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/auth/add.ts)_
|
|
86
|
+
|
|
87
|
+
## `conni conni auth delete`
|
|
88
|
+
|
|
89
|
+
Delete an authentication profile
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
USAGE
|
|
93
|
+
$ conni conni auth delete [--json] [-p <value>]
|
|
94
|
+
|
|
95
|
+
FLAGS
|
|
96
|
+
-p, --profile=<value> Profile name to delete
|
|
97
|
+
|
|
98
|
+
GLOBAL FLAGS
|
|
99
|
+
--json Format output as json.
|
|
100
|
+
|
|
101
|
+
DESCRIPTION
|
|
102
|
+
Delete an authentication profile
|
|
103
|
+
|
|
104
|
+
EXAMPLES
|
|
105
|
+
$ conni conni auth delete
|
|
106
|
+
|
|
107
|
+
$ conni conni auth delete --profile work
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
_See code: [src/commands/conni/auth/delete.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/auth/delete.ts)_
|
|
85
111
|
|
|
86
112
|
## `conni conni auth list`
|
|
87
113
|
|
|
@@ -101,7 +127,7 @@ EXAMPLES
|
|
|
101
127
|
$ conni conni auth list
|
|
102
128
|
```
|
|
103
129
|
|
|
104
|
-
_See code: [src/commands/conni/auth/list.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
130
|
+
_See code: [src/commands/conni/auth/list.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/auth/list.ts)_
|
|
105
131
|
|
|
106
132
|
## `conni conni auth profile`
|
|
107
133
|
|
|
@@ -126,7 +152,7 @@ EXAMPLES
|
|
|
126
152
|
$ conni conni auth profile --default work
|
|
127
153
|
```
|
|
128
154
|
|
|
129
|
-
_See code: [src/commands/conni/auth/profile.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
155
|
+
_See code: [src/commands/conni/auth/profile.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/auth/profile.ts)_
|
|
130
156
|
|
|
131
157
|
## `conni conni auth test`
|
|
132
158
|
|
|
@@ -151,7 +177,7 @@ EXAMPLES
|
|
|
151
177
|
$ conni conni auth test --profile work
|
|
152
178
|
```
|
|
153
179
|
|
|
154
|
-
_See code: [src/commands/conni/auth/test.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
180
|
+
_See code: [src/commands/conni/auth/test.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/auth/test.ts)_
|
|
155
181
|
|
|
156
182
|
## `conni conni auth update`
|
|
157
183
|
|
|
@@ -165,7 +191,7 @@ FLAGS
|
|
|
165
191
|
-e, --email=<value> Account email
|
|
166
192
|
-p, --profile=<value> Profile name to update (default: "default")
|
|
167
193
|
-t, --token=<value> (required) API Token
|
|
168
|
-
-u, --url=<value> (required)
|
|
194
|
+
-u, --url=<value> (required) Confluence instance URL (start with https://)
|
|
169
195
|
|
|
170
196
|
GLOBAL FLAGS
|
|
171
197
|
--json Format output as json.
|
|
@@ -179,7 +205,7 @@ EXAMPLES
|
|
|
179
205
|
$ conni conni auth update --profile work
|
|
180
206
|
```
|
|
181
207
|
|
|
182
|
-
_See code: [src/commands/conni/auth/update.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
208
|
+
_See code: [src/commands/conni/auth/update.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/auth/update.ts)_
|
|
183
209
|
|
|
184
210
|
## `conni conni content attachment PAGEID FILE`
|
|
185
211
|
|
|
@@ -204,7 +230,7 @@ EXAMPLES
|
|
|
204
230
|
$ conni conni content attachment 123456 ./document.pdf
|
|
205
231
|
```
|
|
206
232
|
|
|
207
|
-
_See code: [src/commands/conni/content/attachment.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
233
|
+
_See code: [src/commands/conni/content/attachment.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/attachment.ts)_
|
|
208
234
|
|
|
209
235
|
## `conni conni content attachment-download ATTACHMENTID [OUTPUTPATH]`
|
|
210
236
|
|
|
@@ -231,7 +257,7 @@ EXAMPLES
|
|
|
231
257
|
$ conni conni content attachment-download att12345 ./document.pdf
|
|
232
258
|
```
|
|
233
259
|
|
|
234
|
-
_See code: [src/commands/conni/content/attachment-download.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
260
|
+
_See code: [src/commands/conni/content/attachment-download.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/attachment-download.ts)_
|
|
235
261
|
|
|
236
262
|
## `conni conni content comment PAGEID BODY`
|
|
237
263
|
|
|
@@ -265,7 +291,7 @@ EXAMPLES
|
|
|
265
291
|
$ conni conni content comment 123456 "$(cat content.md)"
|
|
266
292
|
```
|
|
267
293
|
|
|
268
|
-
_See code: [src/commands/conni/content/comment.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
294
|
+
_See code: [src/commands/conni/content/comment.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/comment.ts)_
|
|
269
295
|
|
|
270
296
|
## `conni conni content comment-delete ID`
|
|
271
297
|
|
|
@@ -289,7 +315,7 @@ EXAMPLES
|
|
|
289
315
|
$ conni conni content comment-delete 1544224770
|
|
290
316
|
```
|
|
291
317
|
|
|
292
|
-
_See code: [src/commands/conni/content/comment-delete.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
318
|
+
_See code: [src/commands/conni/content/comment-delete.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/comment-delete.ts)_
|
|
293
319
|
|
|
294
320
|
## `conni conni content comment-update ID BODY`
|
|
295
321
|
|
|
@@ -323,7 +349,7 @@ EXAMPLES
|
|
|
323
349
|
$ conni conni content comment-update 1544224770 "$(cat content.md)"
|
|
324
350
|
```
|
|
325
351
|
|
|
326
|
-
_See code: [src/commands/conni/content/comment-update.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
352
|
+
_See code: [src/commands/conni/content/comment-update.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/comment-update.ts)_
|
|
327
353
|
|
|
328
354
|
## `conni conni content create`
|
|
329
355
|
|
|
@@ -370,7 +396,7 @@ FLAG DESCRIPTIONS
|
|
|
370
396
|
Content fields in key=value format. Use @file to read value from a file (e.g. body=@content.xml)
|
|
371
397
|
```
|
|
372
398
|
|
|
373
|
-
_See code: [src/commands/conni/content/create.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
399
|
+
_See code: [src/commands/conni/content/create.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/create.ts)_
|
|
374
400
|
|
|
375
401
|
## `conni conni content delete PAGEID`
|
|
376
402
|
|
|
@@ -394,7 +420,7 @@ EXAMPLES
|
|
|
394
420
|
$ conni conni content delete 1543634992
|
|
395
421
|
```
|
|
396
422
|
|
|
397
|
-
_See code: [src/commands/conni/content/delete.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
423
|
+
_See code: [src/commands/conni/content/delete.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/delete.ts)_
|
|
398
424
|
|
|
399
425
|
## `conni conni content get PAGEID`
|
|
400
426
|
|
|
@@ -418,7 +444,7 @@ EXAMPLES
|
|
|
418
444
|
$ conni conni content get 1544060948
|
|
419
445
|
```
|
|
420
446
|
|
|
421
|
-
_See code: [src/commands/conni/content/get.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
447
|
+
_See code: [src/commands/conni/content/get.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/get.ts)_
|
|
422
448
|
|
|
423
449
|
## `conni conni content search CQL`
|
|
424
450
|
|
|
@@ -446,7 +472,7 @@ EXAMPLES
|
|
|
446
472
|
$ conni conni content search 'created > startOfMonth()' --limit=5 --expand=body,version
|
|
447
473
|
```
|
|
448
474
|
|
|
449
|
-
_See code: [src/commands/conni/content/search.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
475
|
+
_See code: [src/commands/conni/content/search.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/search.ts)_
|
|
450
476
|
|
|
451
477
|
## `conni conni content update PAGEID`
|
|
452
478
|
|
|
@@ -486,7 +512,7 @@ EXAMPLES
|
|
|
486
512
|
$ conni conni content update 1076199489 --fields body=@storage.xml representation=storage --full-width
|
|
487
513
|
```
|
|
488
514
|
|
|
489
|
-
_See code: [src/commands/conni/content/update.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
515
|
+
_See code: [src/commands/conni/content/update.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/content/update.ts)_
|
|
490
516
|
|
|
491
517
|
## `conni conni space get SPACEKEY`
|
|
492
518
|
|
|
@@ -510,7 +536,7 @@ EXAMPLES
|
|
|
510
536
|
$ conni conni space get DEV
|
|
511
537
|
```
|
|
512
538
|
|
|
513
|
-
_See code: [src/commands/conni/space/get.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
539
|
+
_See code: [src/commands/conni/space/get.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/space/get.ts)_
|
|
514
540
|
|
|
515
541
|
## `conni conni space list`
|
|
516
542
|
|
|
@@ -531,5 +557,5 @@ EXAMPLES
|
|
|
531
557
|
$ conni conni space list
|
|
532
558
|
```
|
|
533
559
|
|
|
534
|
-
_See code: [src/commands/conni/space/list.ts](https://github.com/hesedcasa/conni/blob/v0.
|
|
560
|
+
_See code: [src/commands/conni/space/list.ts](https://github.com/hesedcasa/conni/blob/v0.8.0/src/commands/conni/space/list.ts)_
|
|
535
561
|
<!-- commandsstop -->
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default class AuthAdd extends Command {
|
|
4
|
-
static args: {};
|
|
5
|
-
static description: string;
|
|
6
|
-
static enableJsonFlag: boolean;
|
|
7
|
-
static examples: string[];
|
|
8
|
-
static flags: {
|
|
9
|
-
email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
-
url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
};
|
|
14
|
-
run(): Promise<ApiResult>;
|
|
15
|
-
}
|
|
1
|
+
declare const _default: typeof import("@oclif/core").Command;
|
|
2
|
+
export default _default;
|
|
@@ -1,61 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Command, Flags } from '@oclif/core';
|
|
3
|
-
import { action } from '@oclif/core/ux';
|
|
4
|
-
import { default as fs } from 'fs-extra';
|
|
5
|
-
import { default as path } from 'node:path';
|
|
1
|
+
import { createAuthAddCommand } from '@hesed/plugin-lib';
|
|
6
2
|
import { clearClients, testConnection } from '../../../conni/conni-client.js';
|
|
7
|
-
export default
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
'<%= config.bin %> <%= command.id %> --profile work',
|
|
14
|
-
];
|
|
15
|
-
static flags = {
|
|
16
|
-
email: Flags.string({ char: 'e', description: 'Account email', required: false }),
|
|
17
|
-
profile: Flags.string({ char: 'p', description: 'Profile name', required: false }),
|
|
18
|
-
token: Flags.string({ char: 't', description: 'API Token', required: !process.stdout.isTTY }),
|
|
19
|
-
url: Flags.string({
|
|
20
|
-
char: 'u',
|
|
21
|
-
description: 'Atlassian URL (start with https://)',
|
|
22
|
-
required: !process.stdout.isTTY,
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
async run() {
|
|
26
|
-
const { flags } = await this.parse(AuthAdd);
|
|
27
|
-
const profileName = flags.profile ?? (process.stdout.isTTY ? await input({ message: 'Profile name:', required: true }) : 'default');
|
|
28
|
-
const apiToken = flags.token ?? (await input({ message: 'API Token:', required: true }));
|
|
29
|
-
const email = flags.email ?? (await input({ message: 'Account email:', required: false }));
|
|
30
|
-
const host = flags.url ?? (await input({ message: 'Atlassian instance URL (start with https://):', required: true }));
|
|
31
|
-
const configFilePath = path.join(this.config.configDir, 'conni-config.json');
|
|
32
|
-
let existing = {};
|
|
33
|
-
try {
|
|
34
|
-
existing = await fs.readJSON(configFilePath);
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
// file doesn't exist yet
|
|
38
|
-
}
|
|
39
|
-
const profiles = (existing.profiles ?? (existing.auth ? { default: existing.auth } : {}));
|
|
40
|
-
if (profileName in profiles) {
|
|
41
|
-
this.error(`Profile '${profileName}' already exists. Use 'conni auth update' to modify it.`);
|
|
42
|
-
}
|
|
43
|
-
profiles[profileName] = { apiToken, ...(email && { email }), host };
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
|
-
const { auth: _auth, ...rest } = existing;
|
|
46
|
-
await fs.writeJSON(configFilePath, { ...rest, profiles }, { mode: 0o600 });
|
|
47
|
-
action.start('Authenticating');
|
|
48
|
-
const result = await testConnection({ apiToken, ...(email && { email }), host });
|
|
49
|
-
clearClients();
|
|
50
|
-
if (result.success) {
|
|
51
|
-
action.stop('✓ successful');
|
|
52
|
-
const profileSuffix = profileName === 'default' ? '' : ` as profile '${profileName}'`;
|
|
53
|
-
this.log(`Authentication added${profileSuffix} successfully`);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
action.stop('✗ failed');
|
|
57
|
-
this.error('Authentication is invalid. Please check your email, token, and URL.');
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
3
|
+
export default createAuthAddCommand({
|
|
4
|
+
clearClients,
|
|
5
|
+
hasHostFlag: true,
|
|
6
|
+
serviceName: 'Confluence',
|
|
7
|
+
testConnection,
|
|
8
|
+
});
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
apiToken: string;
|
|
4
|
-
default?: boolean;
|
|
5
|
-
email?: string;
|
|
6
|
-
host: string;
|
|
7
|
-
name: string;
|
|
8
|
-
}
|
|
9
|
-
interface ListResult {
|
|
10
|
-
profiles: ProfileInfo[];
|
|
11
|
-
}
|
|
12
|
-
export default class AuthList extends Command {
|
|
13
|
-
static args: {};
|
|
14
|
-
static description: string;
|
|
15
|
-
static enableJsonFlag: boolean;
|
|
16
|
-
static examples: string[];
|
|
17
|
-
static flags: {};
|
|
18
|
-
run(): Promise<ListResult>;
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
1
|
+
declare const _default: typeof import("@oclif/core").Command;
|
|
2
|
+
export default _default;
|
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export default class AuthList extends Command {
|
|
4
|
-
static args = {};
|
|
5
|
-
static description = 'List authentication profiles';
|
|
6
|
-
static enableJsonFlag = true;
|
|
7
|
-
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
8
|
-
static flags = {};
|
|
9
|
-
async run() {
|
|
10
|
-
await this.parse(AuthList);
|
|
11
|
-
const profiles = await readProfiles(this.config.configDir, this.log.bind(this));
|
|
12
|
-
if (!profiles || Object.keys(profiles).length === 0) {
|
|
13
|
-
this.log('No authentication profiles found. Run auth:add to add one.');
|
|
14
|
-
return { profiles: [] };
|
|
15
|
-
}
|
|
16
|
-
const defaultProfile = await getDefaultProfile(this.config.configDir);
|
|
17
|
-
const profileList = Object.entries(profiles).map(([name, auth]) => ({
|
|
18
|
-
...(auth.email && { email: auth.email }),
|
|
19
|
-
...(name === defaultProfile && { default: true }),
|
|
20
|
-
apiToken: `${auth.apiToken.slice(0, 3)}...${auth.apiToken.slice(-4)}`,
|
|
21
|
-
host: auth.host,
|
|
22
|
-
name,
|
|
23
|
-
}));
|
|
24
|
-
for (const profile of profileList) {
|
|
25
|
-
const details = [
|
|
26
|
-
` host: ${profile.host}`,
|
|
27
|
-
` token: ${profile.apiToken}`,
|
|
28
|
-
profile.email ? ` email: ${profile.email}` : '',
|
|
29
|
-
]
|
|
30
|
-
.filter(Boolean)
|
|
31
|
-
.join('\n');
|
|
32
|
-
this.log(`${profile.name}${profile.default ? ' (default):' : ':'}\n${details}`);
|
|
33
|
-
}
|
|
34
|
-
return { profiles: profileList };
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
import { createAuthListCommand } from '@hesed/plugin-lib';
|
|
2
|
+
export default createAuthListCommand({ hasHostFlag: true });
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default
|
|
3
|
-
static args: {};
|
|
4
|
-
static description: string;
|
|
5
|
-
static enableJsonFlag: boolean;
|
|
6
|
-
static examples: string[];
|
|
7
|
-
static flags: {
|
|
8
|
-
default: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
1
|
+
declare const _default: typeof import("@oclif/core").Command;
|
|
2
|
+
export default _default;
|
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export default class AuthProfile extends Command {
|
|
4
|
-
static args = {};
|
|
5
|
-
static description = 'Set or show the default authentication profile';
|
|
6
|
-
static enableJsonFlag = true;
|
|
7
|
-
static examples = [
|
|
8
|
-
'<%= config.bin %> <%= command.id %>',
|
|
9
|
-
'<%= config.bin %> <%= command.id %> --default work',
|
|
10
|
-
];
|
|
11
|
-
static flags = {
|
|
12
|
-
default: Flags.string({ description: 'Profile name to set as default', required: false }),
|
|
13
|
-
};
|
|
14
|
-
async run() {
|
|
15
|
-
const { flags } = await this.parse(AuthProfile);
|
|
16
|
-
if (flags.default) {
|
|
17
|
-
await setDefaultProfile(this.config.configDir, flags.default, this.log.bind(this));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const current = await getDefaultProfile(this.config.configDir);
|
|
21
|
-
this.log(current);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
import { createAuthProfileCommand } from '@hesed/plugin-lib';
|
|
2
|
+
export default createAuthProfileCommand();
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default class AuthTest extends Command {
|
|
4
|
-
static args: {};
|
|
5
|
-
static description: string;
|
|
6
|
-
static enableJsonFlag: boolean;
|
|
7
|
-
static examples: string[];
|
|
8
|
-
static flags: {
|
|
9
|
-
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
};
|
|
11
|
-
run(): Promise<ApiResult>;
|
|
12
|
-
}
|
|
1
|
+
declare const _default: typeof import("@oclif/core").Command;
|
|
2
|
+
export default _default;
|
|
@@ -1,38 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { action } from '@oclif/core/ux';
|
|
3
|
-
import { readConfig } from '../../../config.js';
|
|
1
|
+
import { createAuthTestCommand } from '@hesed/plugin-lib';
|
|
4
2
|
import { clearClients, testConnection } from '../../../conni/conni-client.js';
|
|
5
|
-
export default
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'<%= config.bin %> <%= command.id %> --profile work',
|
|
12
|
-
];
|
|
13
|
-
static flags = {
|
|
14
|
-
profile: Flags.string({ char: 'p', description: 'Authentication profile name', required: false }),
|
|
15
|
-
};
|
|
16
|
-
async run() {
|
|
17
|
-
const { flags } = await this.parse(AuthTest);
|
|
18
|
-
const config = await readConfig(this.config.configDir, this.log.bind(this), flags.profile);
|
|
19
|
-
if (!config) {
|
|
20
|
-
return {
|
|
21
|
-
error: 'Missing authentication config',
|
|
22
|
-
success: false,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
action.start('Authenticating connection');
|
|
26
|
-
const result = await testConnection(config.auth);
|
|
27
|
-
clearClients();
|
|
28
|
-
if (result.success) {
|
|
29
|
-
action.stop('✓ successful');
|
|
30
|
-
this.log('Successful connect to Confluence');
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
action.stop('✗ failed');
|
|
34
|
-
this.error('Failed to connect to Confluence.');
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
3
|
+
export default createAuthTestCommand({
|
|
4
|
+
clearClients,
|
|
5
|
+
hasHostFlag: true,
|
|
6
|
+
serviceName: 'Confluence',
|
|
7
|
+
testConnection,
|
|
8
|
+
});
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default class AuthUpdate extends Command {
|
|
4
|
-
static args: {};
|
|
5
|
-
static description: string;
|
|
6
|
-
static enableJsonFlag: boolean;
|
|
7
|
-
static examples: string[];
|
|
8
|
-
static flags: {
|
|
9
|
-
email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
-
url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
};
|
|
14
|
-
run(): Promise<ApiResult | void>;
|
|
15
|
-
}
|
|
1
|
+
declare const _default: typeof import("@oclif/core").Command;
|
|
2
|
+
export default _default;
|
|
@@ -1,84 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Command, Flags } from '@oclif/core';
|
|
3
|
-
import { action } from '@oclif/core/ux';
|
|
4
|
-
import { default as fs } from 'fs-extra';
|
|
5
|
-
import { default as path } from 'node:path';
|
|
1
|
+
import { createAuthUpdateCommand } from '@hesed/plugin-lib';
|
|
6
2
|
import { clearClients, testConnection } from '../../../conni/conni-client.js';
|
|
7
|
-
export default
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
'<%= config.bin %> <%= command.id %> --profile work',
|
|
14
|
-
];
|
|
15
|
-
static flags = {
|
|
16
|
-
email: Flags.string({ char: 'e', description: 'Account email', required: false }),
|
|
17
|
-
profile: Flags.string({ char: 'p', description: 'Profile name to update (default: "default")', required: false }),
|
|
18
|
-
token: Flags.string({ char: 't', description: 'API Token', required: !process.stdout.isTTY }),
|
|
19
|
-
url: Flags.string({
|
|
20
|
-
char: 'u',
|
|
21
|
-
description: 'Atlassian instance URL (start with https://)',
|
|
22
|
-
required: !process.stdout.isTTY,
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
async run() {
|
|
26
|
-
const { flags } = await this.parse(AuthUpdate);
|
|
27
|
-
const profileName = flags.profile ?? 'default';
|
|
28
|
-
const configFilePath = path.join(this.config.configDir, 'conni-config.json');
|
|
29
|
-
let existing;
|
|
30
|
-
try {
|
|
31
|
-
existing = await fs.readJSON(configFilePath);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
35
|
-
if (msg.toLowerCase().includes('no such file or directory')) {
|
|
36
|
-
this.log('Run auth:add instead');
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
this.log(msg);
|
|
40
|
-
}
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
// Migrate legacy {auth: {...}} into profiles.default, then read current profile
|
|
44
|
-
const legacyAuth = existing.auth;
|
|
45
|
-
const profiles = (existing.profiles ?? (legacyAuth ? { default: legacyAuth } : {}));
|
|
46
|
-
if (!profiles[profileName]) {
|
|
47
|
-
this.error(`Profile '${profileName}' does not exist. Use 'conni auth add' to create it.`);
|
|
48
|
-
}
|
|
49
|
-
const current = profiles[profileName] ?? {};
|
|
50
|
-
const apiToken = flags.token ?? (await input({ default: current.apiToken, message: 'API Token:', prefill: 'tab', required: true }));
|
|
51
|
-
const email = flags.email ?? (await input({ default: current.email, message: 'Account email:', prefill: 'tab', required: false }));
|
|
52
|
-
const host = flags.url ??
|
|
53
|
-
(await input({
|
|
54
|
-
default: current.host,
|
|
55
|
-
message: 'Atlassian instance URL (start with https://):',
|
|
56
|
-
prefill: 'tab',
|
|
57
|
-
required: true,
|
|
58
|
-
}));
|
|
59
|
-
const answer = await confirm({ message: 'Override existing config?' });
|
|
60
|
-
if (!answer) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
64
|
-
const { auth: _, ...rest } = existing;
|
|
65
|
-
const updatedConfig = {
|
|
66
|
-
...rest,
|
|
67
|
-
profiles: { ...profiles, [profileName]: { apiToken, ...(email && { email }), host } },
|
|
68
|
-
};
|
|
69
|
-
await fs.writeJSON(configFilePath, updatedConfig, { mode: 0o600 });
|
|
70
|
-
action.start('Authenticating');
|
|
71
|
-
const result = await testConnection({ apiToken, ...(email && { email }), host });
|
|
72
|
-
clearClients();
|
|
73
|
-
if (result.success) {
|
|
74
|
-
action.stop('✓ successful');
|
|
75
|
-
const profileSuffix = profileName === 'default' ? '' : ` for profile '${profileName}'`;
|
|
76
|
-
this.log(`Authentication${profileSuffix} updated successfully`);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
action.stop('✗ failed');
|
|
80
|
-
this.error('Authentication is invalid. Please check your email, token, and URL.');
|
|
81
|
-
}
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
3
|
+
export default createAuthUpdateCommand({
|
|
4
|
+
clearClients,
|
|
5
|
+
hasHostFlag: true,
|
|
6
|
+
serviceName: 'Confluence',
|
|
7
|
+
testConnection,
|
|
8
|
+
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
3
|
import { action } from '@oclif/core/ux';
|
|
3
|
-
import { readConfig } from '../../../config.js';
|
|
4
4
|
import { clearClients, downloadAttachment } from '../../../conni/conni-client.js';
|
|
5
|
-
import { formatAsToon } from '../../../format.js';
|
|
6
5
|
export default class ContentDownloadAttachment extends Command {
|
|
7
6
|
static args = {
|
|
8
7
|
attachmentId: Args.string({ description: 'Attachment ID', required: true }),
|
|
@@ -19,15 +18,16 @@ export default class ContentDownloadAttachment extends Command {
|
|
|
19
18
|
};
|
|
20
19
|
async run() {
|
|
21
20
|
const { args, flags } = await this.parse(ContentDownloadAttachment);
|
|
22
|
-
const
|
|
23
|
-
|
|
21
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
22
|
+
const auth = await loadAuthConfig();
|
|
23
|
+
if (!auth) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
if (!args.outputPath) {
|
|
27
27
|
args.outputPath = process.cwd();
|
|
28
28
|
}
|
|
29
29
|
action.start(`Downloading attachment "${args.attachmentId}" to ""`);
|
|
30
|
-
const result = await downloadAttachment(
|
|
30
|
+
const result = await downloadAttachment(auth, args.attachmentId, args.outputPath);
|
|
31
31
|
clearClients();
|
|
32
32
|
if (result.success) {
|
|
33
33
|
action.stop('✓ Successfully uploaded');
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
3
|
import { action } from '@oclif/core/ux';
|
|
3
|
-
import { readConfig } from '../../../config.js';
|
|
4
4
|
import { addAttachment, clearClients } from '../../../conni/conni-client.js';
|
|
5
|
-
import { formatAsToon } from '../../../format.js';
|
|
6
5
|
export default class ContentAttachment extends Command {
|
|
7
6
|
/* eslint-disable perfectionist/sort-objects */
|
|
8
7
|
static args = {
|
|
@@ -18,12 +17,13 @@ export default class ContentAttachment extends Command {
|
|
|
18
17
|
};
|
|
19
18
|
async run() {
|
|
20
19
|
const { args, flags } = await this.parse(ContentAttachment);
|
|
21
|
-
const
|
|
22
|
-
|
|
20
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
21
|
+
const auth = await loadAuthConfig();
|
|
22
|
+
if (!auth) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
action.start(`Uploading attachment "${args.file}" to page ${args.pageId}`);
|
|
26
|
-
const result = await addAttachment(
|
|
26
|
+
const result = await addAttachment(auth, args.pageId, args.file);
|
|
27
27
|
clearClients();
|
|
28
28
|
if (result.success) {
|
|
29
29
|
action.stop('✓ Successfully uploaded');
|