backlog-exporter 0.0.6 → 0.1.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 CHANGED
@@ -14,11 +14,31 @@ Backlog のデータをエクスポートするためのコマンドラインツ
14
14
  * [課題のエクスポート](#課題のエクスポート)
15
15
  * [Wikiのエクスポート](#wikiのエクスポート)
16
16
  * [課題とWikiの一括エクスポート](#課題とwikiの一括エクスポート)
17
+ * [データの更新](#データの更新)
18
+ * [npxを使った課題のエクスポート](#npxを使った課題のエクスポート)
19
+ * [npxを使ったデータの更新](#npxを使ったデータの更新)
20
+ * [課題のエクスポート](#課題のエクスポート)
21
+ * [基本的な使用方法](#基本的な使用方法)
22
+ * [出力先を指定](#出力先を指定)
23
+ * [Wiki のエクスポート](#wiki-のエクスポート)
24
+ * [基本的な使用方法](#基本的な使用方法)
25
+ * [出力先を指定](#出力先を指定)
26
+ * [課題と Wiki の一括エクスポート](#課題と-wiki-の一括エクスポート)
27
+ * [基本的な使用方法](#基本的な使用方法)
28
+ * [出力先を指定](#出力先を指定)
29
+ * [データの更新](#データの更新)
30
+ * [カレントディレクトリとそのサブディレクトリのデータを更新](#カレントディレクトリとそのサブディレクトリのデータを更新)
31
+ * [指定したディレクトリとそのサブディレクトリのデータを更新](#指定したディレクトリとそのサブディレクトリのデータを更新)
32
+ * [確認プロンプトをスキップして更新](#確認プロンプトをスキップして更新)
33
+ * [課題のみを更新](#課題のみを更新)
34
+ * [Wikiのみを更新](#wikiのみを更新)
35
+ * [APIキーを指定して更新](#apiキーを指定して更新)
17
36
  * [コマンド](#コマンド)
18
37
  * [出力形式](#出力形式)
19
38
  * [課題のタイトル](#課題のタイトル)
20
39
  * [Wiki のタイトル](#wiki-のタイトル)
21
40
  * [その他の特徴](#その他の特徴)
41
+ * [最近の変更点](#最近の変更点)
22
42
  <!-- tocstop -->
23
43
 
24
44
  # 概要
@@ -29,6 +49,7 @@ backlog-exporter は、Backlog のデータをローカルにエクスポート
29
49
  - **課題(Issue)のエクスポート**:Backlog の課題を Markdown ファイルとして保存
30
50
  - **Wiki 記事のエクスポート**:Backlog の Wiki 記事を Markdown ファイルとして保存
31
51
  - **一括エクスポート**:課題と Wiki を同時に取得する機能
52
+ - **データの更新**:既存のエクスポートデータを最新の状態に更新する機能
32
53
 
33
54
  # インストール
34
55
 
@@ -38,7 +59,7 @@ $ npm install -g backlog-exporter
38
59
  $ backlog-exporter COMMAND
39
60
  running command...
40
61
  $ backlog-exporter (--version)
41
- backlog-exporter/0.0.6 linux-x64 node-v23.9.0
62
+ backlog-exporter/0.1.0 linux-x64 node-v23.9.0
42
63
  $ backlog-exporter --help [COMMAND]
43
64
  USAGE
44
65
  $ backlog-exporter COMMAND
@@ -67,99 +88,134 @@ $ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY
67
88
 
68
89
  # 課題とWikiの一括エクスポート
69
90
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./backlog-data
91
+
92
+ # データの更新
93
+ $ backlog-exporter update
70
94
  ```
71
95
 
72
- # コマンド
96
+ npx を使用する場合は、コマンドの前に`npx`を付けるだけです:
73
97
 
74
- <!-- commands -->
75
- * [`backlog-exporter all [URL]`](#backlog-exporter-all-url)
76
- * [`backlog-exporter hello PERSON`](#backlog-exporter-hello-person)
77
- * [`backlog-exporter hello world`](#backlog-exporter-hello-world)
78
- * [`backlog-exporter help [COMMAND]`](#backlog-exporter-help-command)
79
- * [`backlog-exporter issue [URL]`](#backlog-exporter-issue-url)
80
- * [`backlog-exporter plugins`](#backlog-exporter-plugins)
81
- * [`backlog-exporter plugins add PLUGIN`](#backlog-exporter-plugins-add-plugin)
82
- * [`backlog-exporter plugins:inspect PLUGIN...`](#backlog-exporter-pluginsinspect-plugin)
83
- * [`backlog-exporter plugins install PLUGIN`](#backlog-exporter-plugins-install-plugin)
84
- * [`backlog-exporter plugins link PATH`](#backlog-exporter-plugins-link-path)
85
- * [`backlog-exporter plugins remove [PLUGIN]`](#backlog-exporter-plugins-remove-plugin)
86
- * [`backlog-exporter plugins reset`](#backlog-exporter-plugins-reset)
87
- * [`backlog-exporter plugins uninstall [PLUGIN]`](#backlog-exporter-plugins-uninstall-plugin)
88
- * [`backlog-exporter plugins unlink [PLUGIN]`](#backlog-exporter-plugins-unlink-plugin)
89
- * [`backlog-exporter plugins update`](#backlog-exporter-plugins-update)
90
- * [`backlog-exporter wiki [URL]`](#backlog-exporter-wiki-url)
98
+ ```sh
99
+ # npxを使った課題のエクスポート
100
+ $ npx backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./issues
91
101
 
92
- ## `backlog-exporter all [URL]`
102
+ # npxを使ったデータの更新
103
+ $ npx backlog-exporter update
104
+ ```
93
105
 
94
- Backlogからissueとwikiを同時に取得する
106
+ # 課題のエクスポート
95
107
 
108
+ `issue`コマンドを使用すると、Backlog の課題を Markdown ファイルとしてエクスポートできます。
109
+
110
+ ```sh
111
+ # 基本的な使用方法
112
+ $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
113
+
114
+ # 出力先を指定
115
+ $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./issues
96
116
  ```
97
- USAGE
98
- $ backlog-exporter all [URL] --domain <value> --projectIdOrKey <value> [--apiKey <value>] [-c <value>]
99
- [-o <value>] [--statusId <value>]
100
117
 
101
- ARGUMENTS
102
- URL URL to download from
118
+ エクスポートされた課題は、指定したディレクトリ内に Markdown ファイルとして保存されます。ファイル名は課題のキーに基づいて自動的に生成されます。
103
119
 
104
- FLAGS
105
- -c, --count=<value> [default: 100] 一度に取得する課題数
106
- -o, --output=<value> 出力ディレクトリのルートパス(デフォルトはプロジェクトキー)
107
- --apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
108
- --domain=<value> (required) Backlog domain (e.g. example.backlog.jp)
109
- --projectIdOrKey=<value> (required) Backlog project ID or key
110
- --statusId=<value> Filter issues by status ID
120
+ # Wiki のエクスポート
111
121
 
112
- DESCRIPTION
113
- Backlogからissueとwikiを同時に取得する
122
+ `wiki`コマンドを使用すると、Backlog の Wiki ページを Markdown ファイルとしてエクスポートできます。
114
123
 
115
- EXAMPLES
116
- $ backlog-exporter all --domain cm1.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY -o ./output-dir
117
- BacklogからAPIキーを使用してissueとwikiを同時に取得する
124
+ ```sh
125
+ # 基本的な使用方法
126
+ $ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
127
+
128
+ # 出力先を指定
129
+ $ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./wiki
118
130
  ```
119
131
 
120
- _See code: [src/commands/all/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.0.6/src/commands/all/index.ts)_
132
+ エクスポートされた Wiki は、指定したディレクトリ内に Markdown ファイルとして保存されます。Wiki の階層構造は保持され、ディレクトリ構造として再現されます。
133
+
134
+ # 課題と Wiki の一括エクスポート
121
135
 
122
- ## `backlog-exporter hello PERSON`
136
+ `all`コマンドを使用すると、課題と Wiki を一度に取得できます。
123
137
 
124
- Say hello
138
+ ```sh
139
+ # 基本的な使用方法
140
+ $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
125
141
 
142
+ # 出力先を指定
143
+ $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./backlog-data
126
144
  ```
127
- USAGE
128
- $ backlog-exporter hello PERSON -f <value>
129
145
 
130
- ARGUMENTS
131
- PERSON Person to say hello to
146
+ 一括エクスポートでは、課題は`issues`ディレクトリに、Wiki は`wiki`ディレクトリに保存されます。
132
147
 
133
- FLAGS
134
- -f, --from=<value> (required) Who is saying hello
148
+ # データの更新
135
149
 
136
- DESCRIPTION
137
- Say hello
150
+ `update`コマンドを使用すると、既存のエクスポートデータを最新の状態に更新できます。このコマンドは、ディレクトリ内の`backlog-settings.json`ファイルを探索し、見つかったディレクトリでデータを更新します。
138
151
 
139
- EXAMPLES
140
- $ backlog-exporter hello friend --from oclif
141
- hello friend from oclif! (./src/commands/hello/index.ts)
152
+ ```sh
153
+ # カレントディレクトリとそのサブディレクトリのデータを更新
154
+ $ backlog-exporter update
155
+
156
+ # 指定したディレクトリとそのサブディレクトリのデータを更新
157
+ $ backlog-exporter update ./my-project
158
+
159
+ # 確認プロンプトをスキップして更新
160
+ $ backlog-exporter update --force
161
+
162
+ # 課題のみを更新
163
+ $ backlog-exporter update --issuesOnly
164
+
165
+ # Wikiのみを更新
166
+ $ backlog-exporter update --wikisOnly
167
+
168
+ # APIキーを指定して更新
169
+ $ backlog-exporter update --apiKey YOUR_API_KEY
142
170
  ```
143
171
 
144
- _See code: [src/commands/hello/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.0.6/src/commands/hello/index.ts)_
172
+ 更新コマンドは、各ディレクトリの設定ファイルに基づいて、課題や Wiki を自動的に更新します。設定ファイルが見つかったディレクトリでは、そのディレクトリ内のファイルが直接更新されます(サブフォルダは作成されません)。
145
173
 
146
- ## `backlog-exporter hello world`
174
+ # コマンド
147
175
 
148
- Say hello world
176
+ <!-- commands -->
177
+ * [`backlog-exporter all`](#backlog-exporter-all)
178
+ * [`backlog-exporter help [COMMAND]`](#backlog-exporter-help-command)
179
+ * [`backlog-exporter issue`](#backlog-exporter-issue)
180
+ * [`backlog-exporter plugins`](#backlog-exporter-plugins)
181
+ * [`backlog-exporter plugins add PLUGIN`](#backlog-exporter-plugins-add-plugin)
182
+ * [`backlog-exporter plugins:inspect PLUGIN...`](#backlog-exporter-pluginsinspect-plugin)
183
+ * [`backlog-exporter plugins install PLUGIN`](#backlog-exporter-plugins-install-plugin)
184
+ * [`backlog-exporter plugins link PATH`](#backlog-exporter-plugins-link-path)
185
+ * [`backlog-exporter plugins remove [PLUGIN]`](#backlog-exporter-plugins-remove-plugin)
186
+ * [`backlog-exporter plugins reset`](#backlog-exporter-plugins-reset)
187
+ * [`backlog-exporter plugins uninstall [PLUGIN]`](#backlog-exporter-plugins-uninstall-plugin)
188
+ * [`backlog-exporter plugins unlink [PLUGIN]`](#backlog-exporter-plugins-unlink-plugin)
189
+ * [`backlog-exporter plugins update`](#backlog-exporter-plugins-update)
190
+ * [`backlog-exporter update [DIRECTORY]`](#backlog-exporter-update-directory)
191
+ * [`backlog-exporter wiki`](#backlog-exporter-wiki)
192
+
193
+ ## `backlog-exporter all`
194
+
195
+ Backlogから課題とWikiを取得してMarkdownファイルとして保存する
149
196
 
150
197
  ```
151
198
  USAGE
152
- $ backlog-exporter hello world
199
+ $ backlog-exporter all --domain <value> --projectIdOrKey <value> [--apiKey <value>] [-o <value>]
200
+
201
+ FLAGS
202
+ -o, --output=<value> 出力ディレクトリパス
203
+ --apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
204
+ --domain=<value> (required) Backlog domain (e.g. example.backlog.jp)
205
+ --projectIdOrKey=<value> (required) Backlog project ID or key
153
206
 
154
207
  DESCRIPTION
155
- Say hello world
208
+ Backlogから課題とWikiを取得してMarkdownファイルとして保存する
156
209
 
157
210
  EXAMPLES
158
- $ backlog-exporter hello world
159
- hello world! (./src/commands/hello/world.ts)
211
+ $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
212
+ 課題とWikiをMarkdownファイルとして保存する
213
+
214
+ $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./my-project
215
+ 指定したディレクトリに課題とWikiを保存する
160
216
  ```
161
217
 
162
- _See code: [src/commands/hello/world.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.0.6/src/commands/hello/world.ts)_
218
+ _See code: [src/commands/all/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.1.0/src/commands/all/index.ts)_
163
219
 
164
220
  ## `backlog-exporter help [COMMAND]`
165
221
 
@@ -181,35 +237,32 @@ DESCRIPTION
181
237
 
182
238
  _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.26/src/commands/help.ts)_
183
239
 
184
- ## `backlog-exporter issue [URL]`
240
+ ## `backlog-exporter issue`
185
241
 
186
- Backlogから課題をダウンロードする
242
+ Backlogから課題を取得してMarkdownファイルとして保存する
187
243
 
188
244
  ```
189
245
  USAGE
190
- $ backlog-exporter issue [URL] --domain <value> --projectIdOrKey <value> [--apiKey <value>] [-c <value>]
191
- [-o <value>] [--statusId <value>]
192
-
193
- ARGUMENTS
194
- URL URL to download from
246
+ $ backlog-exporter issue --domain <value> --projectIdOrKey <value> [--apiKey <value>] [-o <value>]
195
247
 
196
248
  FLAGS
197
- -c, --count=<value> [default: 100] 一度に取得する課題数
198
- -o, --output=<value> [default: ./backlog-issues] 出力ディレクトリパス
249
+ -o, --output=<value> 出力ディレクトリパス
199
250
  --apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
200
251
  --domain=<value> (required) Backlog domain (e.g. example.backlog.jp)
201
252
  --projectIdOrKey=<value> (required) Backlog project ID or key
202
- --statusId=<value> Filter issues by status ID
203
253
 
204
254
  DESCRIPTION
205
- Backlogから課題をダウンロードする
255
+ Backlogから課題を取得してMarkdownファイルとして保存する
206
256
 
207
257
  EXAMPLES
208
- $ backlog-exporter issue --domain cm1.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./issue-data
209
- BacklogからAPIキーを使用して課題をダウンロードする
258
+ $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
259
+ 課題をMarkdownファイルとして保存する
260
+
261
+ $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./my-project
262
+ 指定したディレクトリに課題を保存する
210
263
  ```
211
264
 
212
- _See code: [src/commands/issue/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.0.6/src/commands/issue/index.ts)_
265
+ _See code: [src/commands/issue/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.1.0/src/commands/issue/index.ts)_
213
266
 
214
267
  ## `backlog-exporter plugins`
215
268
 
@@ -501,32 +554,71 @@ DESCRIPTION
501
554
 
502
555
  _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/update.ts)_
503
556
 
504
- ## `backlog-exporter wiki [URL]`
557
+ ## `backlog-exporter update [DIRECTORY]`
505
558
 
506
- BacklogからWikiコンテンツをダウンロードする
559
+ Backlogから最新データを取得して更新する
507
560
 
508
561
  ```
509
562
  USAGE
510
- $ backlog-exporter wiki [URL] --domain <value> --projectIdOrKey <value> [--apiKey <value>] [-o <value>]
563
+ $ backlog-exporter update [DIRECTORY] [--apiKey <value>] [--domain <value>] [-f] [--issuesOnly]
564
+ [--projectIdOrKey <value>] [--wikisOnly]
511
565
 
512
566
  ARGUMENTS
513
- URL URL to download from
567
+ DIRECTORY 更新対象のディレクトリ(設定ファイルが保存されている場所)
514
568
 
515
569
  FLAGS
516
- -o, --output=<value> [default: ./backlog-wiki] 出力ディレクトリパス
570
+ -f, --force 確認プロンプトをスキップする
571
+ --apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
572
+ --domain=<value> Backlog domain (e.g. example.backlog.jp)
573
+ --issuesOnly 課題のみを更新する
574
+ --projectIdOrKey=<value> Backlog project ID or key
575
+ --wikisOnly Wikiのみを更新する
576
+
577
+ DESCRIPTION
578
+ Backlogから最新データを取得して更新する
579
+
580
+ EXAMPLES
581
+ $ backlog-exporter update
582
+ カレントディレクトリの設定を使用して更新する
583
+
584
+ $ backlog-exporter update --force
585
+ 確認プロンプトをスキップする
586
+
587
+ $ backlog-exporter update --apiKey YOUR_API_KEY --domain example.backlog.jp --projectIdOrKey PROJECT_KEY
588
+ 指定したパラメータで更新する(設定ファイルが存在する場合は上書きされます)
589
+
590
+ $ backlog-exporter update ./my-project
591
+ 指定したディレクトリの設定を使用して更新する
592
+ ```
593
+
594
+ _See code: [src/commands/update/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.1.0/src/commands/update/index.ts)_
595
+
596
+ ## `backlog-exporter wiki`
597
+
598
+ Backlogから Wiki を取得してMarkdownファイルとして保存する
599
+
600
+ ```
601
+ USAGE
602
+ $ backlog-exporter wiki --domain <value> --projectIdOrKey <value> [--apiKey <value>] [-o <value>]
603
+
604
+ FLAGS
605
+ -o, --output=<value> 出力ディレクトリパス
517
606
  --apiKey=<value> Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)
518
607
  --domain=<value> (required) Backlog domain (e.g. example.backlog.jp)
519
608
  --projectIdOrKey=<value> (required) Backlog project ID or key
520
609
 
521
610
  DESCRIPTION
522
- BacklogからWikiコンテンツをダウンロードする
611
+ Backlogから Wiki を取得してMarkdownファイルとして保存する
523
612
 
524
613
  EXAMPLES
525
- $ backlog-exporter wiki --domain cm1.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./wiki-data
526
- BacklogからAPIキーを使用してWikiコンテンツをダウンロードする
614
+ $ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
615
+ Wikiをダウンロードする
616
+
617
+ $ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./my-project
618
+ 指定したディレクトリにWikiを保存する
527
619
  ```
528
620
 
529
- _See code: [src/commands/wiki/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.0.6/src/commands/wiki/index.ts)_
621
+ _See code: [src/commands/wiki/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.1.0/src/commands/wiki/index.ts)_
530
622
  <!-- commandsstop -->
531
623
 
532
624
  # 出力形式
@@ -591,3 +683,16 @@ Backlog の書式がそのまま保持されます。
591
683
  - **並列処理**: 並列処理による高速なダウンロード
592
684
  - **ファイル名サニタイズ**: ファイル名の自動サニタイズ(不正な文字の除去)
593
685
  - **階層構造の保持**: Wiki の階層構造を保持したエクスポート
686
+
687
+ # 最近の変更点
688
+
689
+ ## 2023-07-XX - v0.0.7
690
+
691
+ - `update`コマンドの改善:
692
+ - ディレクトリ内の`backlog-settings.json`ファイルを再帰的に探索し、見つかったディレクトリでデータを更新
693
+ - 親フォルダ内のファイルを直接上書きするように変更(サブフォルダを作成しない)
694
+ - コードの改善:メソッドのパラメータをオブジェクト形式に変更し、コードの可読性を向上
695
+ - 確認プロンプトの追加:更新前に確認メッセージを表示し、ユーザーの承認を得るように変更
696
+ - ドキュメントの改善:
697
+ - README に各コマンドの詳細な説明を追加
698
+ - `npx`を使った実行方法の説明を追加
@@ -1,17 +1,12 @@
1
1
  import { Command } from '@oclif/core';
2
- export default class DownloadAll extends Command {
3
- static args: {
4
- url: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
- };
2
+ export default class All extends Command {
6
3
  static description: string;
7
4
  static examples: string[];
8
5
  static flags: {
9
6
  apiKey: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
- count: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
7
  domain: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
8
  output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
9
  projectIdOrKey: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
- statusId: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
10
  };
16
11
  run(): Promise<void>;
17
12
  }
@@ -1,19 +1,20 @@
1
- import { Args, Command, Flags } from '@oclif/core';
1
+ import { Command, Flags } from '@oclif/core';
2
2
  import * as dotenv from 'dotenv';
3
3
  import path from 'node:path';
4
4
  import { downloadIssues, downloadWikis } from '../../utils/backlog-api.js';
5
5
  import { validateAndGetProjectId } from '../../utils/backlog.js';
6
6
  import { createOutputDirectory, getApiKey } from '../../utils/common.js';
7
+ import { FolderType, updateSettings } from '../../utils/settings.js';
7
8
  // .envファイルを読み込む
8
9
  dotenv.config();
9
- export default class DownloadAll extends Command {
10
- static args = {
11
- url: Args.string({ description: 'URL to download from', required: false }),
12
- };
13
- static description = 'Backlogからissueとwikiを同時に取得する';
10
+ export default class All extends Command {
11
+ static description = 'Backlogから課題とWikiを取得してMarkdownファイルとして保存する';
14
12
  static examples = [
15
- `<%= config.bin %> <%= command.id %> --domain cm1.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY -o ./output-dir
16
- BacklogからAPIキーを使用してissueとwikiを同時に取得する
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を保存する
17
18
  `,
18
19
  ];
19
20
  static flags = {
@@ -21,44 +22,68 @@ BacklogからAPIキーを使用してissueとwikiを同時に取得する
21
22
  description: 'Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)',
22
23
  required: false,
23
24
  }),
24
- count: Flags.integer({ char: 'c', default: 100, description: '一度に取得する課題数', required: false }),
25
- domain: Flags.string({ description: 'Backlog domain (e.g. example.backlog.jp)', required: true }),
25
+ domain: Flags.string({
26
+ description: 'Backlog domain (e.g. example.backlog.jp)',
27
+ required: true,
28
+ }),
26
29
  output: Flags.string({
27
30
  char: 'o',
28
- description: '出力ディレクトリのルートパス(デフォルトはプロジェクトキー)',
31
+ description: '出力ディレクトリパス',
29
32
  required: false,
30
33
  }),
31
- projectIdOrKey: Flags.string({ description: 'Backlog project ID or key', required: true }),
32
- statusId: Flags.string({ description: 'Filter issues by status ID', required: false }),
34
+ projectIdOrKey: Flags.string({
35
+ description: 'Backlog project ID or key',
36
+ required: true,
37
+ }),
33
38
  };
34
39
  async run() {
35
- const { flags } = await this.parse(DownloadAll);
36
- const { count, domain, projectIdOrKey, statusId } = flags;
37
- const apiKey = getApiKey(this, flags.apiKey);
38
- // 出力ディレクトリのルートパスを設定(デフォルトはプロジェクトキー)
39
- const outputRoot = flags.output || projectIdOrKey;
40
- this.log(`Backlogから ${domain} のプロジェクト ${projectIdOrKey} の課題とWikiを取得しています...`);
41
- this.log(`出力ディレクトリ: ${outputRoot}`);
40
+ const { flags } = await this.parse(All);
42
41
  try {
42
+ const { domain, projectIdOrKey } = flags;
43
+ const apiKey = flags.apiKey || getApiKey(this);
44
+ const outputRoot = flags.output || './backlog-data';
45
+ // 出力ディレクトリの作成
46
+ await createOutputDirectory(outputRoot);
43
47
  // プロジェクトキーからプロジェクトIDを取得
44
48
  const projectId = await validateAndGetProjectId(domain, projectIdOrKey, apiKey);
45
49
  this.log(`プロジェクトID: ${projectId} を使用します`);
46
- // issueとwikiのサブディレクトリパスを作成
50
+ // 課題の出力ディレクトリ
47
51
  const issueOutput = path.join(outputRoot, 'issues');
48
- const wikiOutput = path.join(outputRoot, 'wiki');
49
- // 出力ディレクトリの作成
50
- await createOutputDirectory(outputRoot);
51
52
  await createOutputDirectory(issueOutput);
53
+ // Wikiの出力ディレクトリ
54
+ const wikiOutput = path.join(outputRoot, 'wiki');
52
55
  await createOutputDirectory(wikiOutput);
53
- // 課題とWikiを並列で取得
54
- await Promise.all([
55
- downloadIssues(this, domain, projectId, apiKey, issueOutput, count, statusId),
56
- downloadWikis(this, domain, projectIdOrKey, apiKey, wikiOutput),
57
- ]);
58
- this.log('すべてのダウンロードが完了しました!');
56
+ // 課題の取得と保存
57
+ this.log('課題の取得を開始します...');
58
+ await downloadIssues(this, domain, projectId, apiKey, issueOutput, 100);
59
+ // 課題フォルダに設定ファイルを保存
60
+ await updateSettings(issueOutput, {
61
+ apiKey,
62
+ domain,
63
+ folderType: FolderType.ISSUE,
64
+ lastUpdated: new Date().toISOString(),
65
+ outputDir: issueOutput,
66
+ projectIdOrKey,
67
+ });
68
+ this.log('課題の取得が完了しました');
69
+ // Wikiの取得と保存
70
+ this.log('Wikiの取得を開始します...');
71
+ await downloadWikis(this, domain, projectIdOrKey, apiKey, wikiOutput);
72
+ // Wikiフォルダに設定ファイルを保存
73
+ await updateSettings(wikiOutput, {
74
+ apiKey,
75
+ domain,
76
+ folderType: FolderType.WIKI,
77
+ lastUpdated: new Date().toISOString(),
78
+ outputDir: wikiOutput,
79
+ projectIdOrKey,
80
+ });
81
+ this.log('Wikiの取得が完了しました');
82
+ this.log('すべてのデータの取得が完了しました!');
59
83
  }
60
84
  catch (error) {
61
- this.error(`ダウンロードに失敗しました: ${error instanceof Error ? error.message : String(error)}`);
85
+ const errorMessage = error instanceof Error ? error.message : String(error);
86
+ this.error(`データの取得に失敗しました: ${errorMessage}`);
62
87
  }
63
88
  }
64
89
  }
@@ -1,17 +1,12 @@
1
1
  import { Command } from '@oclif/core';
2
- export default class DownloadIssue extends Command {
3
- static args: {
4
- url: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
- };
2
+ export default class Issue extends Command {
6
3
  static description: string;
7
4
  static examples: string[];
8
5
  static flags: {
9
6
  apiKey: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
- count: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
7
  domain: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
9
  projectIdOrKey: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
- statusId: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
10
  };
16
11
  run(): Promise<void>;
17
12
  }
@@ -1,18 +1,19 @@
1
- import { Args, Command, Flags } from '@oclif/core';
1
+ import { Command, Flags } from '@oclif/core';
2
2
  import * as dotenv from 'dotenv';
3
3
  import { downloadIssues } from '../../utils/backlog-api.js';
4
4
  import { validateAndGetProjectId } from '../../utils/backlog.js';
5
5
  import { createOutputDirectory, getApiKey } from '../../utils/common.js';
6
+ import { FolderType, updateSettings } from '../../utils/settings.js';
6
7
  // .envファイルを読み込む
7
8
  dotenv.config();
8
- export default class DownloadIssue extends Command {
9
- static args = {
10
- url: Args.string({ description: 'URL to download from', required: false }),
11
- };
12
- static description = 'Backlogから課題をダウンロードする';
9
+ export default class Issue extends Command {
10
+ static description = 'Backlogから課題を取得してMarkdownファイルとして保存する';
13
11
  static examples = [
14
- `<%= config.bin %> <%= command.id %> --domain cm1.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./issue-data
15
- BacklogからAPIキーを使用して課題をダウンロードする
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-project
16
+ 指定したディレクトリに課題を保存する
16
17
  `,
17
18
  ];
18
19
  static flags = {
@@ -20,34 +21,47 @@ BacklogからAPIキーを使用して課題をダウンロードする
20
21
  description: 'Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)',
21
22
  required: false,
22
23
  }),
23
- count: Flags.integer({ char: 'c', default: 100, description: '一度に取得する課題数', required: false }),
24
- domain: Flags.string({ description: 'Backlog domain (e.g. example.backlog.jp)', required: true }),
24
+ domain: Flags.string({
25
+ description: 'Backlog domain (e.g. example.backlog.jp)',
26
+ required: true,
27
+ }),
25
28
  output: Flags.string({
26
29
  char: 'o',
27
- default: './backlog-issues',
28
30
  description: '出力ディレクトリパス',
29
31
  required: false,
30
32
  }),
31
- projectIdOrKey: Flags.string({ description: 'Backlog project ID or key', required: true }),
32
- statusId: Flags.string({ description: 'Filter issues by status ID', required: false }),
33
+ projectIdOrKey: Flags.string({
34
+ description: 'Backlog project ID or key',
35
+ required: true,
36
+ }),
33
37
  };
34
38
  async run() {
35
- const { flags } = await this.parse(DownloadIssue);
36
- const { count, domain, output: outputDir, projectIdOrKey, statusId } = flags;
37
- const apiKey = getApiKey(this, flags.apiKey);
38
- this.log(`Backlogから ${domain} のプロジェクト ${projectIdOrKey} の課題を取得しています...`);
39
+ const { flags } = await this.parse(Issue);
39
40
  try {
41
+ const { domain, projectIdOrKey } = flags;
42
+ const apiKey = flags.apiKey || getApiKey(this);
43
+ const outputDir = flags.output || './issues';
44
+ // 出力ディレクトリの作成
45
+ await createOutputDirectory(outputDir);
40
46
  // プロジェクトキーからプロジェクトIDを取得
41
47
  const projectId = await validateAndGetProjectId(domain, projectIdOrKey, apiKey);
42
48
  this.log(`プロジェクトID: ${projectId} を使用します`);
43
- // 出力ディレクトリの作成
44
- await createOutputDirectory(outputDir);
45
- // 課題のダウンロード
46
- await downloadIssues(this, domain, projectId, apiKey, outputDir, count, statusId);
47
- this.log('ダウンロードが完了しました!');
49
+ // 課題の取得と保存
50
+ await downloadIssues(this, domain, projectId, apiKey, outputDir, 100);
51
+ // 設定ファイルを保存
52
+ await updateSettings(outputDir, {
53
+ apiKey,
54
+ domain,
55
+ folderType: FolderType.ISSUE,
56
+ lastUpdated: new Date().toISOString(),
57
+ outputDir,
58
+ projectIdOrKey,
59
+ });
60
+ this.log('課題の取得が完了しました!');
48
61
  }
49
62
  catch (error) {
50
- this.error(`ダウンロードに失敗しました: ${error instanceof Error ? error.message : String(error)}`);
63
+ const errorMessage = error instanceof Error ? error.message : String(error);
64
+ this.error(`課題の取得に失敗しました: ${errorMessage}`);
51
65
  }
52
66
  }
53
67
  }