@hesed/conni 0.7.2 → 0.9.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.
Files changed (34) hide show
  1. package/README.md +63 -37
  2. package/dist/commands/conni/auth/add.d.ts +2 -15
  3. package/dist/commands/conni/auth/add.js +7 -60
  4. package/dist/commands/conni/auth/delete.d.ts +2 -0
  5. package/dist/commands/conni/auth/delete.js +2 -0
  6. package/dist/commands/conni/auth/list.d.ts +2 -20
  7. package/dist/commands/conni/auth/list.js +2 -36
  8. package/dist/commands/conni/auth/profile.d.ts +2 -11
  9. package/dist/commands/conni/auth/profile.js +2 -23
  10. package/dist/commands/conni/auth/test.d.ts +2 -12
  11. package/dist/commands/conni/auth/test.js +7 -37
  12. package/dist/commands/conni/auth/update.d.ts +2 -15
  13. package/dist/commands/conni/auth/update.js +7 -83
  14. package/dist/commands/conni/content/attachment-download.js +6 -6
  15. package/dist/commands/conni/content/attachment.js +6 -6
  16. package/dist/commands/conni/content/comment-delete.js +6 -6
  17. package/dist/commands/conni/content/comment-update.js +6 -6
  18. package/dist/commands/conni/content/comment.js +6 -6
  19. package/dist/commands/conni/content/create.js +6 -8
  20. package/dist/commands/conni/content/delete.js +6 -6
  21. package/dist/commands/conni/content/get.js +6 -6
  22. package/dist/commands/conni/content/search.js +6 -6
  23. package/dist/commands/conni/content/update.js +6 -6
  24. package/dist/commands/conni/space/get.js +6 -6
  25. package/dist/commands/conni/space/list.js +6 -6
  26. package/dist/conni/conni-api.d.ts +2 -14
  27. package/dist/conni/conni-client.d.ts +17 -95
  28. package/dist/conni/conni-client.js +17 -115
  29. package/oclif.manifest.json +82 -39
  30. package/package.json +2 -2
  31. package/dist/config.d.ts +0 -14
  32. package/dist/config.js +0 -83
  33. package/dist/format.d.ts +0 -4
  34. 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.7.2 linux-x64 node-v24.14.1
29
+ @hesed/conni/0.9.0 linux-x64 node-v24.16.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,31 +58,56 @@ USAGE
57
58
 
58
59
  ## `conni conni auth add`
59
60
 
60
- Add Atlassian authentication
61
+ Add Confluence authentication
61
62
 
62
63
  ```
63
64
  USAGE
64
- $ conni conni auth add -t <value> -u <value> [--json] [-e <value>] [-p <value>]
65
+ $ conni conni auth add -p <value> -t <value> -e <value> -u <value> [--json]
65
66
 
66
67
  FLAGS
67
- -e, --email=<value> Account email
68
- -p, --profile=<value> Profile name
69
- -t, --token=<value> (required) API Token
70
- -u, --url=<value> (required) Atlassian URL (start with https://)
68
+ -e, --email=<value> (required) Account email
69
+ -p, --profile=<value> (required) Profile name
70
+ -t, --apiToken=<value> (required) API Token
71
+ -u, --host=<value> (required) Confluence instance URL
71
72
 
72
73
  GLOBAL FLAGS
73
74
  --json Format output as json.
74
75
 
75
76
  DESCRIPTION
76
- Add Atlassian authentication
77
+ Add Confluence authentication
77
78
 
78
79
  EXAMPLES
79
80
  $ conni conni auth add
80
81
 
81
- $ conni conni auth add --profile work
82
+ $ conni conni auth add -p prod
82
83
  ```
83
84
 
84
- _See code: [src/commands/conni/auth/add.ts](https://github.com/hesedcasa/conni/blob/v0.7.2/src/commands/conni/auth/add.ts)_
85
+ _See code: [src/commands/conni/auth/add.ts](https://github.com/hesedcasa/conni/blob/v0.9.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 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 -p prod
108
+ ```
109
+
110
+ _See code: [src/commands/conni/auth/delete.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/auth/list.ts)_
130
+ _See code: [src/commands/conni/auth/list.ts](https://github.com/hesedcasa/conni/blob/v0.9.0/src/commands/conni/auth/list.ts)_
105
131
 
106
132
  ## `conni conni auth profile`
107
133
 
@@ -112,7 +138,7 @@ USAGE
112
138
  $ conni conni auth profile [--json] [--default <value>]
113
139
 
114
140
  FLAGS
115
- --default=<value> Profile name to set as default
141
+ --default=<value> Profile to set as default
116
142
 
117
143
  GLOBAL FLAGS
118
144
  --json Format output as json.
@@ -123,10 +149,10 @@ DESCRIPTION
123
149
  EXAMPLES
124
150
  $ conni conni auth profile
125
151
 
126
- $ conni conni auth profile --default work
152
+ $ conni conni auth profile --default test
127
153
  ```
128
154
 
129
- _See code: [src/commands/conni/auth/profile.ts](https://github.com/hesedcasa/conni/blob/v0.7.2/src/commands/conni/auth/profile.ts)_
155
+ _See code: [src/commands/conni/auth/profile.ts](https://github.com/hesedcasa/conni/blob/v0.9.0/src/commands/conni/auth/profile.ts)_
130
156
 
131
157
  ## `conni conni auth test`
132
158
 
@@ -148,38 +174,38 @@ DESCRIPTION
148
174
  EXAMPLES
149
175
  $ conni conni auth test
150
176
 
151
- $ conni conni auth test --profile work
177
+ $ conni conni auth test -p prod
152
178
  ```
153
179
 
154
- _See code: [src/commands/conni/auth/test.ts](https://github.com/hesedcasa/conni/blob/v0.7.2/src/commands/conni/auth/test.ts)_
180
+ _See code: [src/commands/conni/auth/test.ts](https://github.com/hesedcasa/conni/blob/v0.9.0/src/commands/conni/auth/test.ts)_
155
181
 
156
182
  ## `conni conni auth update`
157
183
 
158
- Update existing authentication profile
184
+ Update Confluence authentication
159
185
 
160
186
  ```
161
187
  USAGE
162
- $ conni conni auth update -t <value> -u <value> [--json] [-e <value>] [-p <value>]
188
+ $ conni conni auth update -p <value> -t <value> -e <value> -u <value> [--json]
163
189
 
164
190
  FLAGS
165
- -e, --email=<value> Account email
166
- -p, --profile=<value> Profile name to update (default: "default")
167
- -t, --token=<value> (required) API Token
168
- -u, --url=<value> (required) Atlassian instance URL (start with https://)
191
+ -e, --email=<value> (required) Account email
192
+ -p, --profile=<value> (required) Profile name
193
+ -t, --apiToken=<value> (required) API Token
194
+ -u, --host=<value> (required) Confluence instance URL
169
195
 
170
196
  GLOBAL FLAGS
171
197
  --json Format output as json.
172
198
 
173
199
  DESCRIPTION
174
- Update existing authentication profile
200
+ Update Confluence authentication
175
201
 
176
202
  EXAMPLES
177
203
  $ conni conni auth update
178
204
 
179
- $ conni conni auth update --profile work
205
+ $ conni conni auth update -p test
180
206
  ```
181
207
 
182
- _See code: [src/commands/conni/auth/update.ts](https://github.com/hesedcasa/conni/blob/v0.7.2/src/commands/conni/auth/update.ts)_
208
+ _See code: [src/commands/conni/auth/update.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/attachment.ts)_
233
+ _See code: [src/commands/conni/content/attachment.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/attachment-download.ts)_
260
+ _See code: [src/commands/conni/content/attachment-download.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/comment.ts)_
294
+ _See code: [src/commands/conni/content/comment.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/comment-delete.ts)_
318
+ _See code: [src/commands/conni/content/comment-delete.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/comment-update.ts)_
352
+ _See code: [src/commands/conni/content/comment-update.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/create.ts)_
399
+ _See code: [src/commands/conni/content/create.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/delete.ts)_
423
+ _See code: [src/commands/conni/content/delete.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/get.ts)_
447
+ _See code: [src/commands/conni/content/get.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/search.ts)_
475
+ _See code: [src/commands/conni/content/search.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/content/update.ts)_
515
+ _See code: [src/commands/conni/content/update.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/space/get.ts)_
539
+ _See code: [src/commands/conni/space/get.ts](https://github.com/hesedcasa/conni/blob/v0.9.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.7.2/src/commands/conni/space/list.ts)_
560
+ _See code: [src/commands/conni/space/list.ts](https://github.com/hesedcasa/conni/blob/v0.9.0/src/commands/conni/space/list.ts)_
535
561
  <!-- commandsstop -->
@@ -1,15 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- import { ApiResult } from '../../../conni/conni-api.js';
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 { input } from '@inquirer/prompts';
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 class AuthAdd extends Command {
8
- static args = {};
9
- static description = 'Add Atlassian authentication';
10
- static enableJsonFlag = true;
11
- static examples = [
12
- '<%= config.bin %> <%= command.id %>',
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.outputJSON(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
+ configFile: 'conni-config.json',
6
+ serviceName: 'Confluence',
7
+ testConnection,
8
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: typeof import("@oclif/core").Command;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { createAuthDeleteCommand } from '@hesed/plugin-lib';
2
+ export default createAuthDeleteCommand({ configFile: 'conni-config.json' });
@@ -1,20 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- interface ProfileInfo {
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 { Command } from '@oclif/core';
2
- import { getDefaultProfile, readProfiles } from '../../../config.js';
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({ configFile: 'conni-config.json' });
@@ -1,11 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- export default class AuthProfile extends Command {
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 { Command, Flags } from '@oclif/core';
2
- import { getDefaultProfile, setDefaultProfile } from '../../../config.js';
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({ configFile: 'conni-config.json' });
@@ -1,12 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- import { ApiResult } from '../../../conni/conni-api.js';
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 { Command, Flags } from '@oclif/core';
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 class AuthTest extends Command {
6
- static args = {};
7
- static description = 'Test authentication and connection';
8
- static enableJsonFlag = true;
9
- static examples = [
10
- '<%= config.bin %> <%= command.id %>',
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
+ configFile: 'conni-config.json',
6
+ serviceName: 'Confluence',
7
+ testConnection,
8
+ });
@@ -1,15 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- import { ApiResult } from '../../../conni/conni-api.js';
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 { confirm, input } from '@inquirer/prompts';
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 class AuthUpdate extends Command {
8
- static args = {};
9
- static description = 'Update existing authentication profile';
10
- static enableJsonFlag = true;
11
- static examples = [
12
- '<%= config.bin %> <%= command.id %>',
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.outputJSON(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
+ configFile: 'conni-config.json',
6
+ serviceName: 'Confluence',
7
+ testConnection,
8
+ });