backlog-exporter 0.7.0 → 0.7.1
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 +214 -1
- package/dist/commands/all/index.d.ts +17 -0
- package/dist/commands/all/index.js +210 -0
- package/dist/commands/document/index.d.ts +13 -0
- package/dist/commands/document/index.js +84 -0
- package/dist/commands/issue/index.d.ts +16 -0
- package/dist/commands/issue/index.js +114 -0
- package/dist/commands/update/index.d.ts +27 -0
- package/dist/commands/update/index.js +344 -0
- package/dist/commands/wiki/index.d.ts +12 -0
- package/dist/commands/wiki/index.js +71 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/backlog-api.d.ts +74 -0
- package/dist/utils/backlog-api.js +448 -0
- package/dist/utils/backlog.d.ts +16 -0
- package/dist/utils/backlog.js +34 -0
- package/dist/utils/common.d.ts +25 -0
- package/dist/utils/common.js +54 -0
- package/dist/utils/log.d.ts +6 -0
- package/dist/utils/log.js +18 -0
- package/dist/utils/settings.d.ts +45 -0
- package/dist/utils/settings.js +63 -0
- package/dist/utils/sleep.d.ts +28 -0
- package/dist/utils/sleep.js +42 -0
- package/oclif.manifest.json +435 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ $ npm install -g backlog-exporter
|
|
|
77
77
|
$ backlog-exporter COMMAND
|
|
78
78
|
running command...
|
|
79
79
|
$ backlog-exporter (--version)
|
|
80
|
-
backlog-exporter/0.7.
|
|
80
|
+
backlog-exporter/0.7.1 linux-x64 node-v24.4.1
|
|
81
81
|
$ backlog-exporter --help [COMMAND]
|
|
82
82
|
USAGE
|
|
83
83
|
$ backlog-exporter COMMAND
|
|
@@ -323,7 +323,10 @@ $ backlog-exporter update --apiKey YOUR_API_KEY
|
|
|
323
323
|
# コマンド
|
|
324
324
|
|
|
325
325
|
<!-- commands -->
|
|
326
|
+
* [`backlog-exporter all`](#backlog-exporter-all)
|
|
327
|
+
* [`backlog-exporter document`](#backlog-exporter-document)
|
|
326
328
|
* [`backlog-exporter help [COMMAND]`](#backlog-exporter-help-command)
|
|
329
|
+
* [`backlog-exporter issue`](#backlog-exporter-issue)
|
|
327
330
|
* [`backlog-exporter plugins`](#backlog-exporter-plugins)
|
|
328
331
|
* [`backlog-exporter plugins add PLUGIN`](#backlog-exporter-plugins-add-plugin)
|
|
329
332
|
* [`backlog-exporter plugins:inspect PLUGIN...`](#backlog-exporter-pluginsinspect-plugin)
|
|
@@ -334,6 +337,91 @@ $ backlog-exporter update --apiKey YOUR_API_KEY
|
|
|
334
337
|
* [`backlog-exporter plugins uninstall [PLUGIN]`](#backlog-exporter-plugins-uninstall-plugin)
|
|
335
338
|
* [`backlog-exporter plugins unlink [PLUGIN]`](#backlog-exporter-plugins-unlink-plugin)
|
|
336
339
|
* [`backlog-exporter plugins update`](#backlog-exporter-plugins-update)
|
|
340
|
+
* [`backlog-exporter update [DIRECTORY]`](#backlog-exporter-update-directory)
|
|
341
|
+
* [`backlog-exporter wiki`](#backlog-exporter-wiki)
|
|
342
|
+
|
|
343
|
+
## `backlog-exporter all`
|
|
344
|
+
|
|
345
|
+
Backlogから課題・Wiki・ドキュメントを取得してMarkdownファイルとして保存する
|
|
346
|
+
|
|
347
|
+
```
|
|
348
|
+
USAGE
|
|
349
|
+
$ backlog-exporter all --domain <value> --projectIdOrKey <value> [--apiKey <value>] [--exclude <value>]
|
|
350
|
+
[--issueKeyFileName] [--issueKeyFolder] [-m <value>] [--only <value>] [-o <value>]
|
|
351
|
+
|
|
352
|
+
FLAGS
|
|
353
|
+
-m, --maxCount=<value> [default: 5000] 一度に取得する課題の最大数(デフォルト: 5000)
|
|
354
|
+
-o, --output=<value> 出力ディレクトリパス
|
|
355
|
+
--apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
|
|
356
|
+
--domain=<value> (required) Backlog domain (e.g. example.backlog.jp)
|
|
357
|
+
--exclude=<value> Exclude the specified types, separated by commas (e.g., 'documents,wiki')
|
|
358
|
+
--issueKeyFileName ファイル名を課題キーにする
|
|
359
|
+
--issueKeyFolder 課題キーでフォルダを作成する
|
|
360
|
+
--only=<value> Export only the specified types, separated by commas (e.g., 'issues,wiki')
|
|
361
|
+
--projectIdOrKey=<value> (required) Backlog project ID or key
|
|
362
|
+
|
|
363
|
+
DESCRIPTION
|
|
364
|
+
Backlogから課題・Wiki・ドキュメントを取得してMarkdownファイルとして保存する
|
|
365
|
+
|
|
366
|
+
EXAMPLES
|
|
367
|
+
$ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
|
|
368
|
+
課題・Wiki・ドキュメントをMarkdownファイルとして保存する
|
|
369
|
+
|
|
370
|
+
$ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./my-project
|
|
371
|
+
指定したディレクトリに課題・Wiki・ドキュメントを保存する
|
|
372
|
+
|
|
373
|
+
$ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --only issues,wiki
|
|
374
|
+
課題とWikiのみを取得する
|
|
375
|
+
|
|
376
|
+
$ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --exclude documents
|
|
377
|
+
ドキュメント以外(課題とWiki)を取得する
|
|
378
|
+
|
|
379
|
+
$ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --maxCount 1000
|
|
380
|
+
最大1000件の課題を取得する(デフォルトは5000件)
|
|
381
|
+
|
|
382
|
+
$ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFileName
|
|
383
|
+
ファイル名を課題キーにする
|
|
384
|
+
|
|
385
|
+
$ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFolder
|
|
386
|
+
課題キーでフォルダを作成する
|
|
387
|
+
|
|
388
|
+
$ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFileName --issueKeyFolder
|
|
389
|
+
課題キーでフォルダを作成し、ファイル名も課題キーにする
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
_See code: [src/commands/all/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.7.1/src/commands/all/index.ts)_
|
|
393
|
+
|
|
394
|
+
## `backlog-exporter document`
|
|
395
|
+
|
|
396
|
+
Backlogからドキュメントを取得してMarkdownファイルとして保存する
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
USAGE
|
|
400
|
+
$ backlog-exporter document --domain <value> --projectIdOrKey <value> [--apiKey <value>] [--keyword <value>]
|
|
401
|
+
[-o <value>]
|
|
402
|
+
|
|
403
|
+
FLAGS
|
|
404
|
+
-o, --output=<value> 出力ディレクトリパス
|
|
405
|
+
--apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
|
|
406
|
+
--domain=<value> (required) Backlog domain (e.g. example.backlog.jp)
|
|
407
|
+
--keyword=<value> 検索キーワード
|
|
408
|
+
--projectIdOrKey=<value> (required) Backlog project ID or key
|
|
409
|
+
|
|
410
|
+
DESCRIPTION
|
|
411
|
+
Backlogからドキュメントを取得してMarkdownファイルとして保存する
|
|
412
|
+
|
|
413
|
+
EXAMPLES
|
|
414
|
+
$ backlog-exporter document --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
|
|
415
|
+
ドキュメントをMarkdownファイルとして保存する
|
|
416
|
+
|
|
417
|
+
$ backlog-exporter document --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./my-documents
|
|
418
|
+
指定したディレクトリにドキュメントを保存する
|
|
419
|
+
|
|
420
|
+
$ backlog-exporter document --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --keyword 仕様書
|
|
421
|
+
キーワード「仕様書」を含むドキュメントのみを取得する
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
_See code: [src/commands/document/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.7.1/src/commands/document/index.ts)_
|
|
337
425
|
|
|
338
426
|
## `backlog-exporter help [COMMAND]`
|
|
339
427
|
|
|
@@ -355,6 +443,53 @@ DESCRIPTION
|
|
|
355
443
|
|
|
356
444
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.26/src/commands/help.ts)_
|
|
357
445
|
|
|
446
|
+
## `backlog-exporter issue`
|
|
447
|
+
|
|
448
|
+
Backlogから課題を取得してMarkdownファイルとして保存する
|
|
449
|
+
|
|
450
|
+
```
|
|
451
|
+
USAGE
|
|
452
|
+
$ backlog-exporter issue --domain <value> --projectIdOrKey <value> [--apiKey <value>]
|
|
453
|
+
[--issueKeyFileName] [--issueKeyFolder] [-m <value>] [-o <value>] [--statusId <value>]
|
|
454
|
+
|
|
455
|
+
FLAGS
|
|
456
|
+
-m, --maxCount=<value> [default: 5000] 一度に取得する課題の最大数(デフォルト: 5000)
|
|
457
|
+
-o, --output=<value> 出力ディレクトリパス
|
|
458
|
+
--apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
|
|
459
|
+
--domain=<value> (required) Backlog domain (e.g. example.backlog.jp)
|
|
460
|
+
--issueKeyFileName ファイル名を課題キーにする
|
|
461
|
+
--issueKeyFolder 課題キーでフォルダを作成する
|
|
462
|
+
--projectIdOrKey=<value> (required) Backlog project ID or key
|
|
463
|
+
--statusId=<value> ステータスID(カンマ区切りで複数指定可能)
|
|
464
|
+
|
|
465
|
+
DESCRIPTION
|
|
466
|
+
Backlogから課題を取得してMarkdownファイルとして保存する
|
|
467
|
+
|
|
468
|
+
EXAMPLES
|
|
469
|
+
$ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
|
|
470
|
+
課題をMarkdownファイルとして保存する
|
|
471
|
+
|
|
472
|
+
$ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./my-issues
|
|
473
|
+
指定したディレクトリに課題を保存する
|
|
474
|
+
|
|
475
|
+
$ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --statusId 1,2,3
|
|
476
|
+
指定したステータスIDの課題のみを取得する
|
|
477
|
+
|
|
478
|
+
$ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --maxCount 10000
|
|
479
|
+
最大10000件の課題を取得する(デフォルトは5000件)
|
|
480
|
+
|
|
481
|
+
$ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFileName
|
|
482
|
+
ファイル名を課題キーにする
|
|
483
|
+
|
|
484
|
+
$ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFolder
|
|
485
|
+
課題キーでフォルダを作成する
|
|
486
|
+
|
|
487
|
+
$ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFileName --issueKeyFolder
|
|
488
|
+
課題キーでフォルダを作成し、ファイル名も課題キーにする
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
_See code: [src/commands/issue/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.7.1/src/commands/issue/index.ts)_
|
|
492
|
+
|
|
358
493
|
## `backlog-exporter plugins`
|
|
359
494
|
|
|
360
495
|
List installed plugins.
|
|
@@ -644,6 +779,84 @@ DESCRIPTION
|
|
|
644
779
|
```
|
|
645
780
|
|
|
646
781
|
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/update.ts)_
|
|
782
|
+
|
|
783
|
+
## `backlog-exporter update [DIRECTORY]`
|
|
784
|
+
|
|
785
|
+
Backlogから最新データを取得して更新する
|
|
786
|
+
|
|
787
|
+
```
|
|
788
|
+
USAGE
|
|
789
|
+
$ backlog-exporter update [DIRECTORY] [--apiKey <value>] [--documentsOnly] [--domain <value>] [-f]
|
|
790
|
+
[--issueKeyFileName] [--issueKeyFolder] [--issuesOnly] [--projectIdOrKey <value>] [--wikisOnly]
|
|
791
|
+
|
|
792
|
+
ARGUMENTS
|
|
793
|
+
DIRECTORY 更新対象のディレクトリ(設定ファイルが保存されている場所)
|
|
794
|
+
|
|
795
|
+
FLAGS
|
|
796
|
+
-f, --force 確認プロンプトをスキップする
|
|
797
|
+
--apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
|
|
798
|
+
--documentsOnly ドキュメントのみを更新する
|
|
799
|
+
--domain=<value> Backlog domain (e.g. example.backlog.jp)
|
|
800
|
+
--issueKeyFileName ファイル名を課題キーにする
|
|
801
|
+
--issueKeyFolder 課題キーでフォルダを作成する
|
|
802
|
+
--issuesOnly 課題のみを更新する
|
|
803
|
+
--projectIdOrKey=<value> Backlog project ID or key
|
|
804
|
+
--wikisOnly Wikiのみを更新する
|
|
805
|
+
|
|
806
|
+
DESCRIPTION
|
|
807
|
+
Backlogから最新データを取得して更新する
|
|
808
|
+
|
|
809
|
+
EXAMPLES
|
|
810
|
+
$ backlog-exporter update
|
|
811
|
+
カレントディレクトリの設定を使用して更新する
|
|
812
|
+
|
|
813
|
+
$ backlog-exporter update --force
|
|
814
|
+
確認プロンプトをスキップする
|
|
815
|
+
|
|
816
|
+
$ backlog-exporter update --apiKey YOUR_API_KEY --domain example.backlog.jp --projectIdOrKey PROJECT_KEY
|
|
817
|
+
指定したパラメータで更新する(設定ファイルが存在する場合は上書きされます)
|
|
818
|
+
|
|
819
|
+
$ backlog-exporter update ./my-project
|
|
820
|
+
指定したディレクトリの設定を使用して更新する
|
|
821
|
+
|
|
822
|
+
$ backlog-exporter update --issueKeyFileName
|
|
823
|
+
ファイル名を課題キーにする
|
|
824
|
+
|
|
825
|
+
$ backlog-exporter update --issueKeyFolder
|
|
826
|
+
課題キーでフォルダを作成する
|
|
827
|
+
|
|
828
|
+
$ backlog-exporter update --issueKeyFileName --issueKeyFolder
|
|
829
|
+
課題キーでフォルダを作成し、ファイル名も課題キーにする
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
_See code: [src/commands/update/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.7.1/src/commands/update/index.ts)_
|
|
833
|
+
|
|
834
|
+
## `backlog-exporter wiki`
|
|
835
|
+
|
|
836
|
+
Backlogから Wiki を取得してMarkdownファイルとして保存する
|
|
837
|
+
|
|
838
|
+
```
|
|
839
|
+
USAGE
|
|
840
|
+
$ backlog-exporter wiki --domain <value> --projectIdOrKey <value> [--apiKey <value>] [-o <value>]
|
|
841
|
+
|
|
842
|
+
FLAGS
|
|
843
|
+
-o, --output=<value> 出力ディレクトリパス
|
|
844
|
+
--apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
|
|
845
|
+
--domain=<value> (required) Backlog domain (e.g. example.backlog.jp)
|
|
846
|
+
--projectIdOrKey=<value> (required) Backlog project ID or key
|
|
847
|
+
|
|
848
|
+
DESCRIPTION
|
|
849
|
+
Backlogから Wiki を取得してMarkdownファイルとして保存する
|
|
850
|
+
|
|
851
|
+
EXAMPLES
|
|
852
|
+
$ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
|
|
853
|
+
Wikiをダウンロードする
|
|
854
|
+
|
|
855
|
+
$ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./my-project
|
|
856
|
+
指定したディレクトリにWikiを保存する
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
_See code: [src/commands/wiki/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.7.1/src/commands/wiki/index.ts)_
|
|
647
860
|
<!-- commandsstop -->
|
|
648
861
|
|
|
649
862
|
# 出力形式
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class All extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
apiKey: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
domain: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
exclude: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
issueKeyFileName: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
issueKeyFolder: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
maxCount: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
only: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
projectIdOrKey: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import * as dotenv from 'dotenv';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { downloadDocuments, downloadIssues, downloadWikis } from '../../utils/backlog-api.js';
|
|
5
|
+
import { validateAndGetProjectId } from '../../utils/backlog.js';
|
|
6
|
+
import { createOutputDirectory, getApiKey } from '../../utils/common.js';
|
|
7
|
+
import { FolderType, updateSettings } from '../../utils/settings.js';
|
|
8
|
+
// .envファイルを読み込む
|
|
9
|
+
dotenv.config();
|
|
10
|
+
export default class All extends Command {
|
|
11
|
+
static description = 'Backlogから課題・Wiki・ドキュメントを取得してMarkdownファイルとして保存する';
|
|
12
|
+
static examples = [
|
|
13
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
|
|
14
|
+
課題・Wiki・ドキュメントをMarkdownファイルとして保存する
|
|
15
|
+
`,
|
|
16
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./my-project
|
|
17
|
+
指定したディレクトリに課題・Wiki・ドキュメントを保存する
|
|
18
|
+
`,
|
|
19
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --only issues,wiki
|
|
20
|
+
課題とWikiのみを取得する
|
|
21
|
+
`,
|
|
22
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --exclude documents
|
|
23
|
+
ドキュメント以外(課題とWiki)を取得する
|
|
24
|
+
`,
|
|
25
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --maxCount 1000
|
|
26
|
+
最大1000件の課題を取得する(デフォルトは5000件)
|
|
27
|
+
`,
|
|
28
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFileName
|
|
29
|
+
ファイル名を課題キーにする
|
|
30
|
+
`,
|
|
31
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFolder
|
|
32
|
+
課題キーでフォルダを作成する
|
|
33
|
+
`,
|
|
34
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFileName --issueKeyFolder
|
|
35
|
+
課題キーでフォルダを作成し、ファイル名も課題キーにする
|
|
36
|
+
`,
|
|
37
|
+
];
|
|
38
|
+
static flags = {
|
|
39
|
+
apiKey: Flags.string({
|
|
40
|
+
description: 'Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)',
|
|
41
|
+
required: false,
|
|
42
|
+
}),
|
|
43
|
+
domain: Flags.string({
|
|
44
|
+
description: 'Backlog domain (e.g. example.backlog.jp)',
|
|
45
|
+
required: true,
|
|
46
|
+
}),
|
|
47
|
+
exclude: Flags.string({
|
|
48
|
+
description: "Exclude the specified types, separated by commas (e.g., 'documents,wiki')",
|
|
49
|
+
required: false,
|
|
50
|
+
}),
|
|
51
|
+
issueKeyFileName: Flags.boolean({
|
|
52
|
+
description: 'ファイル名を課題キーにする',
|
|
53
|
+
required: false,
|
|
54
|
+
}),
|
|
55
|
+
issueKeyFolder: Flags.boolean({
|
|
56
|
+
description: '課題キーでフォルダを作成する',
|
|
57
|
+
required: false,
|
|
58
|
+
}),
|
|
59
|
+
maxCount: Flags.integer({
|
|
60
|
+
char: 'm',
|
|
61
|
+
default: 5000,
|
|
62
|
+
description: '一度に取得する課題の最大数(デフォルト: 5000)',
|
|
63
|
+
required: false,
|
|
64
|
+
}),
|
|
65
|
+
only: Flags.string({
|
|
66
|
+
description: "Export only the specified types, separated by commas (e.g., 'issues,wiki')",
|
|
67
|
+
required: false,
|
|
68
|
+
}),
|
|
69
|
+
output: Flags.string({
|
|
70
|
+
char: 'o',
|
|
71
|
+
description: '出力ディレクトリパス',
|
|
72
|
+
required: false,
|
|
73
|
+
}),
|
|
74
|
+
projectIdOrKey: Flags.string({
|
|
75
|
+
description: 'Backlog project ID or key',
|
|
76
|
+
required: true,
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
async run() {
|
|
80
|
+
const { flags } = await this.parse(All);
|
|
81
|
+
try {
|
|
82
|
+
const { domain, exclude, issueKeyFileName, issueKeyFolder, maxCount, only, projectIdOrKey } = flags;
|
|
83
|
+
const apiKey = flags.apiKey || getApiKey(this);
|
|
84
|
+
const outputRoot = flags.output || './backlog-data';
|
|
85
|
+
// Check for conflicting flags
|
|
86
|
+
if (only && exclude) {
|
|
87
|
+
this.error('Cannot use both --only and --exclude flags together. Please use only one.');
|
|
88
|
+
}
|
|
89
|
+
// Determine targets based on flags
|
|
90
|
+
let targets;
|
|
91
|
+
if (only) {
|
|
92
|
+
targets = only.split(',');
|
|
93
|
+
}
|
|
94
|
+
else if (exclude) {
|
|
95
|
+
const excludeTargets = exclude.split(',');
|
|
96
|
+
const allTargets = ['issues', 'wiki', 'documents'];
|
|
97
|
+
targets = allTargets.filter((target) => !excludeTargets.includes(target));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
targets = ['issues', 'wiki', 'documents'];
|
|
101
|
+
}
|
|
102
|
+
// Validate targets
|
|
103
|
+
const validTargets = ['issues', 'wiki', 'documents'];
|
|
104
|
+
const inputTargets = only ? only.split(',') : exclude ? exclude.split(',') : [];
|
|
105
|
+
for (const target of inputTargets) {
|
|
106
|
+
if (!validTargets.includes(target)) {
|
|
107
|
+
this.error(`Invalid target '${target}'. Available targets are: ${validTargets.join(', ')}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Check if any targets remain after exclusion
|
|
111
|
+
if (targets.length === 0) {
|
|
112
|
+
this.error('No targets remaining after exclusion. Please specify valid targets to export.');
|
|
113
|
+
}
|
|
114
|
+
// 出力ディレクトリの作成
|
|
115
|
+
await createOutputDirectory(outputRoot);
|
|
116
|
+
// プロジェクトキーからプロジェクトIDを取得
|
|
117
|
+
const projectId = await validateAndGetProjectId(domain, projectIdOrKey, apiKey);
|
|
118
|
+
this.log(`プロジェクトID: ${projectId} を使用します`);
|
|
119
|
+
if (targets.includes('issues')) {
|
|
120
|
+
// 課題の出力ディレクトリ
|
|
121
|
+
const issueOutput = path.join(outputRoot, 'issues');
|
|
122
|
+
await createOutputDirectory(issueOutput);
|
|
123
|
+
// 課題フォルダに設定ファイルを保存
|
|
124
|
+
await updateSettings(issueOutput, {
|
|
125
|
+
apiKey,
|
|
126
|
+
domain,
|
|
127
|
+
folderType: FolderType.ISSUE,
|
|
128
|
+
issueKeyFileName,
|
|
129
|
+
issueKeyFolder,
|
|
130
|
+
outputDir: issueOutput,
|
|
131
|
+
projectIdOrKey,
|
|
132
|
+
});
|
|
133
|
+
// 課題の取得と保存
|
|
134
|
+
this.log('課題の取得を開始します...');
|
|
135
|
+
await downloadIssues(this, {
|
|
136
|
+
apiKey,
|
|
137
|
+
count: maxCount,
|
|
138
|
+
domain,
|
|
139
|
+
issueKeyFileName,
|
|
140
|
+
issueKeyFolder,
|
|
141
|
+
outputDir: issueOutput,
|
|
142
|
+
projectId,
|
|
143
|
+
});
|
|
144
|
+
// 課題フォルダの最終更新日時を更新
|
|
145
|
+
await updateSettings(issueOutput, {
|
|
146
|
+
lastUpdated: new Date().toISOString(),
|
|
147
|
+
});
|
|
148
|
+
this.log('課題の取得が完了しました');
|
|
149
|
+
}
|
|
150
|
+
if (targets.includes('wiki')) {
|
|
151
|
+
// Wikiの出力ディレクトリ
|
|
152
|
+
const wikiOutput = path.join(outputRoot, 'wiki');
|
|
153
|
+
await createOutputDirectory(wikiOutput);
|
|
154
|
+
// Wikiフォルダに設定ファイルを保存
|
|
155
|
+
await updateSettings(wikiOutput, {
|
|
156
|
+
apiKey,
|
|
157
|
+
domain,
|
|
158
|
+
folderType: FolderType.WIKI,
|
|
159
|
+
outputDir: wikiOutput,
|
|
160
|
+
projectIdOrKey,
|
|
161
|
+
});
|
|
162
|
+
// Wikiの取得と保存
|
|
163
|
+
this.log('Wikiの取得を開始します...');
|
|
164
|
+
await downloadWikis(this, {
|
|
165
|
+
apiKey,
|
|
166
|
+
domain,
|
|
167
|
+
outputDir: wikiOutput,
|
|
168
|
+
projectIdOrKey,
|
|
169
|
+
});
|
|
170
|
+
// Wikiフォルダの最終更新日時を更新
|
|
171
|
+
await updateSettings(wikiOutput, {
|
|
172
|
+
lastUpdated: new Date().toISOString(),
|
|
173
|
+
});
|
|
174
|
+
this.log('Wikiの取得が完了しました');
|
|
175
|
+
}
|
|
176
|
+
if (targets.includes('documents')) {
|
|
177
|
+
// ドキュメントの出力ディレクトリ
|
|
178
|
+
const documentOutput = path.join(outputRoot, 'documents');
|
|
179
|
+
await createOutputDirectory(documentOutput);
|
|
180
|
+
// ドキュメントフォルダに設定ファイルを保存
|
|
181
|
+
await updateSettings(documentOutput, {
|
|
182
|
+
apiKey,
|
|
183
|
+
domain,
|
|
184
|
+
folderType: FolderType.DOCUMENT,
|
|
185
|
+
outputDir: documentOutput,
|
|
186
|
+
projectIdOrKey,
|
|
187
|
+
});
|
|
188
|
+
// ドキュメントの取得と保存
|
|
189
|
+
this.log('ドキュメントの取得を開始します...');
|
|
190
|
+
await downloadDocuments(this, {
|
|
191
|
+
apiKey,
|
|
192
|
+
domain,
|
|
193
|
+
outputDir: documentOutput,
|
|
194
|
+
projectId,
|
|
195
|
+
projectIdOrKey,
|
|
196
|
+
});
|
|
197
|
+
// ドキュメントフォルダの最終更新日時を更新
|
|
198
|
+
await updateSettings(documentOutput, {
|
|
199
|
+
lastUpdated: new Date().toISOString(),
|
|
200
|
+
});
|
|
201
|
+
this.log('ドキュメントの取得が完了しました');
|
|
202
|
+
}
|
|
203
|
+
this.log('すべてのデータの取得が完了しました!');
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
207
|
+
this.error(`データの取得に失敗しました: ${errorMessage}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Document extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
apiKey: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
domain: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
keyword: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
projectIdOrKey: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import * as dotenv from 'dotenv';
|
|
3
|
+
import { downloadDocuments } from '../../utils/backlog-api.js';
|
|
4
|
+
import { validateAndGetProjectId } from '../../utils/backlog.js';
|
|
5
|
+
import { createOutputDirectory, getApiKey } from '../../utils/common.js';
|
|
6
|
+
import { FolderType, updateSettings } from '../../utils/settings.js';
|
|
7
|
+
// .envファイルを読み込む
|
|
8
|
+
dotenv.config();
|
|
9
|
+
export default class Document extends Command {
|
|
10
|
+
static description = 'Backlogからドキュメントを取得してMarkdownファイルとして保存する';
|
|
11
|
+
static examples = [
|
|
12
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
|
|
13
|
+
ドキュメントをMarkdownファイルとして保存する
|
|
14
|
+
`,
|
|
15
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./my-documents
|
|
16
|
+
指定したディレクトリにドキュメントを保存する
|
|
17
|
+
`,
|
|
18
|
+
`<%= config.bin %> <%= command.id %> --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --keyword 仕様書
|
|
19
|
+
キーワード「仕様書」を含むドキュメントのみを取得する
|
|
20
|
+
`,
|
|
21
|
+
];
|
|
22
|
+
static flags = {
|
|
23
|
+
apiKey: Flags.string({
|
|
24
|
+
description: 'Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)',
|
|
25
|
+
required: false,
|
|
26
|
+
}),
|
|
27
|
+
domain: Flags.string({
|
|
28
|
+
description: 'Backlog domain (e.g. example.backlog.jp)',
|
|
29
|
+
required: true,
|
|
30
|
+
}),
|
|
31
|
+
keyword: Flags.string({
|
|
32
|
+
description: '検索キーワード',
|
|
33
|
+
required: false,
|
|
34
|
+
}),
|
|
35
|
+
output: Flags.string({
|
|
36
|
+
char: 'o',
|
|
37
|
+
description: '出力ディレクトリパス',
|
|
38
|
+
required: false,
|
|
39
|
+
}),
|
|
40
|
+
projectIdOrKey: Flags.string({
|
|
41
|
+
description: 'Backlog project ID or key',
|
|
42
|
+
required: true,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
async run() {
|
|
46
|
+
const { flags } = await this.parse(Document);
|
|
47
|
+
try {
|
|
48
|
+
const { domain, keyword, projectIdOrKey } = flags;
|
|
49
|
+
const apiKey = flags.apiKey || getApiKey(this);
|
|
50
|
+
const outputDir = flags.output || './backlog-documents';
|
|
51
|
+
// 出力ディレクトリの作成
|
|
52
|
+
await createOutputDirectory(outputDir);
|
|
53
|
+
// プロジェクトキーからプロジェクトIDを取得
|
|
54
|
+
const projectId = await validateAndGetProjectId(domain, projectIdOrKey, apiKey);
|
|
55
|
+
this.log(`プロジェクトID: ${projectId} を使用します`);
|
|
56
|
+
// 設定ファイルを保存
|
|
57
|
+
await updateSettings(outputDir, {
|
|
58
|
+
apiKey,
|
|
59
|
+
domain,
|
|
60
|
+
folderType: FolderType.DOCUMENT,
|
|
61
|
+
outputDir,
|
|
62
|
+
projectIdOrKey,
|
|
63
|
+
});
|
|
64
|
+
// ドキュメントの取得と保存
|
|
65
|
+
await downloadDocuments(this, {
|
|
66
|
+
apiKey,
|
|
67
|
+
domain,
|
|
68
|
+
keyword,
|
|
69
|
+
outputDir,
|
|
70
|
+
projectId,
|
|
71
|
+
projectIdOrKey,
|
|
72
|
+
});
|
|
73
|
+
// 最終更新日時を更新
|
|
74
|
+
await updateSettings(outputDir, {
|
|
75
|
+
lastUpdated: new Date().toISOString(),
|
|
76
|
+
});
|
|
77
|
+
this.log('ドキュメントの取得が完了しました!');
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
81
|
+
this.error(`ドキュメントの取得に失敗しました: ${errorMessage}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Issue extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
apiKey: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
domain: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
issueKeyFileName: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
issueKeyFolder: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
maxCount: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
projectIdOrKey: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
statusId: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|