backlog-exporter 0.7.0 → 0.7.2

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
@@ -12,44 +12,10 @@ Backlog のデータをエクスポートするためのコマンドラインツ
12
12
  * [インストール](#インストール)
13
13
  * [使用方法](#使用方法)
14
14
  * [課題のエクスポート](#課題のエクスポート)
15
- * [Wikiのエクスポート](#wikiのエクスポート)
16
- * [ドキュメントのエクスポート](#ドキュメントのエクスポート)
17
- * [課題・Wiki・ドキュメントの一括エクスポート](#課題wikiドキュメントの一括エクスポート)
18
- * [特定のデータタイプのみをエクスポート(onlyフラグ)](#特定のデータタイプのみをエクスポートonlyフラグ)
19
- * [特定のデータタイプを除外してエクスポート(excludeフラグ)](#特定のデータタイプを除外してエクスポートexcludeフラグ)
20
- * [データの更新](#データの更新)
21
- * [npxを使った課題のエクスポート](#npxを使った課題のエクスポート)
22
- * [npxを使ったデータの更新](#npxを使ったデータの更新)
23
- * [課題のエクスポート](#課題のエクスポート)
24
- * [基本的な使用方法](#基本的な使用方法)
25
- * [出力先を指定](#出力先を指定)
26
- * [Markdownファイル名を課題キーにする](#markdownファイル名を課題キーにする)
27
- * [課題キーでフォルダを作成する](#課題キーでフォルダを作成する)
28
- * [課題キーでフォルダを作成し、Markdownファイル名も課題キーにする](#課題キーでフォルダを作成しmarkdownファイル名も課題キーにする)
29
15
  * [Wiki のエクスポート](#wiki-のエクスポート)
30
- * [基本的な使用方法](#基本的な使用方法)
31
- * [出力先を指定](#出力先を指定)
32
16
  * [ドキュメント のエクスポート](#ドキュメント-のエクスポート)
33
- * [基本的な使用方法](#基本的な使用方法)
34
- * [出力先を指定](#出力先を指定)
35
- * [キーワード検索](#キーワード検索)
36
17
  * [課題・Wiki・ドキュメント の一括エクスポート](#課題wikiドキュメント-の一括エクスポート)
37
- * [基本的な使用方法](#基本的な使用方法)
38
- * [出力先を指定](#出力先を指定)
39
- * [特定のデータタイプのみをエクスポート(onlyフラグ)](#特定のデータタイプのみをエクスポートonlyフラグ)
40
- * [特定のデータタイプを除外してエクスポート(excludeフラグ)](#特定のデータタイプを除外してエクスポートexcludeフラグ)
41
- * [課題とWikiのみをエクスポート](#課題とwikiのみをエクスポート)
42
- * [ドキュメントのみをエクスポート](#ドキュメントのみをエクスポート)
43
- * [ドキュメント以外(課題とWiki)をエクスポート](#ドキュメント以外課題とwikiをエクスポート)
44
- * [課題以外(WikiとDocuments)をエクスポート](#課題以外wikiとdocumentsをエクスポート)
45
18
  * [データの更新](#データの更新)
46
- * [カレントディレクトリとそのサブディレクトリのデータを更新](#カレントディレクトリとそのサブディレクトリのデータを更新)
47
- * [指定したディレクトリとそのサブディレクトリのデータを更新](#指定したディレクトリとそのサブディレクトリのデータを更新)
48
- * [確認プロンプトをスキップして更新](#確認プロンプトをスキップして更新)
49
- * [課題のみを更新](#課題のみを更新)
50
- * [Wikiのみを更新](#wikiのみを更新)
51
- * [ドキュメントのみを更新](#ドキュメントのみを更新)
52
- * [APIキーを指定して更新](#apiキーを指定して更新)
53
19
  * [コマンド](#コマンド)
54
20
  * [出力形式](#出力形式)
55
21
  * [課題のタイトル](#課題のタイトル)
@@ -77,7 +43,7 @@ $ npm install -g backlog-exporter
77
43
  $ backlog-exporter COMMAND
78
44
  running command...
79
45
  $ backlog-exporter (--version)
80
- backlog-exporter/0.7.0 linux-x64 node-v24.4.1
46
+ backlog-exporter/0.7.2 linux-x64 node-v25.2.1
81
47
  $ backlog-exporter --help [COMMAND]
82
48
  USAGE
83
49
  $ backlog-exporter COMMAND
@@ -97,36 +63,59 @@ API キーは以下の方法で指定できます:
97
63
 
98
64
  ## 基本的な使用例
99
65
 
66
+ **課題のエクスポート**
67
+
100
68
  ```sh
101
- # 課題のエクスポート
102
69
  $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./issues
70
+ ```
71
+
72
+ **Wikiのエクスポート**
103
73
 
104
- # Wikiのエクスポート
74
+ ```sh
105
75
  $ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./wiki
76
+ ```
77
+
78
+ **ドキュメントのエクスポート**
106
79
 
107
- # ドキュメントのエクスポート
80
+ ```sh
108
81
  $ backlog-exporter document --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./documents
82
+ ```
83
+
84
+ **課題・Wiki・ドキュメントの一括エクスポート**
109
85
 
110
- # 課題・Wiki・ドキュメントの一括エクスポート
86
+ ```sh
111
87
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./backlog-data
88
+ ```
89
+
90
+ **特定のデータタイプのみをエクスポート(onlyフラグ)**
112
91
 
113
- # 特定のデータタイプのみをエクスポート(onlyフラグ)
92
+ ```sh
114
93
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --only issues,wiki
94
+ ```
95
+
96
+ **特定のデータタイプを除外してエクスポート(excludeフラグ)**
115
97
 
116
- # 特定のデータタイプを除外してエクスポート(excludeフラグ)
98
+ ```sh
117
99
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --exclude documents
100
+ ```
118
101
 
119
- # データの更新
102
+ **データの更新**
103
+
104
+ ```sh
120
105
  $ backlog-exporter update
121
106
  ```
122
107
 
123
108
  npx を使用する場合は、コマンドの前に`npx`を付けるだけです:
124
109
 
110
+ **npxを使った課題のエクスポート**
111
+
125
112
  ```sh
126
- # npxを使った課題のエクスポート
127
113
  $ npx backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./issues
114
+ ```
115
+
116
+ **npxを使ったデータの更新**
128
117
 
129
- # npxを使ったデータの更新
118
+ ```sh
130
119
  $ npx backlog-exporter update
131
120
  ```
132
121
 
@@ -134,20 +123,33 @@ $ npx backlog-exporter update
134
123
 
135
124
  `issue`コマンドを使用すると、Backlog の課題を Markdown ファイルとしてエクスポートできます。
136
125
 
126
+ **基本的な使用方法**
127
+
137
128
  ```sh
138
- # 基本的な使用方法
139
129
  $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
130
+ ```
140
131
 
141
- # 出力先を指定
132
+ **出力先を指定**
133
+
134
+ ```sh
142
135
  $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./issues
136
+ ```
143
137
 
144
- # Markdownファイル名を課題キーにする
138
+ **Markdownファイル名を課題キーにする**
139
+
140
+ ```sh
145
141
  $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFileName
142
+ ```
143
+
144
+ **課題キーでフォルダを作成する**
146
145
 
147
- # 課題キーでフォルダを作成する
146
+ ```sh
148
147
  $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFolder
148
+ ```
149
+
150
+ **課題キーでフォルダを作成し、Markdownファイル名も課題キーにする**
149
151
 
150
- # 課題キーでフォルダを作成し、Markdownファイル名も課題キーにする
152
+ ```sh
151
153
  $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --issueKeyFileName --issueKeyFolder
152
154
  ```
153
155
 
@@ -181,11 +183,15 @@ $ backlog-exporter issue --domain example.backlog.jp --projectIdOrKey PROJECT_KE
181
183
 
182
184
  `wiki`コマンドを使用すると、Backlog の Wiki ページを Markdown ファイルとしてエクスポートできます。
183
185
 
186
+ **基本的な使用方法**
187
+
184
188
  ```sh
185
- # 基本的な使用方法
186
189
  $ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
190
+ ```
191
+
192
+ **出力先を指定**
187
193
 
188
- # 出力先を指定
194
+ ```sh
189
195
  $ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./wiki
190
196
  ```
191
197
 
@@ -195,14 +201,21 @@ $ backlog-exporter wiki --domain example.backlog.jp --projectIdOrKey PROJECT_KEY
195
201
 
196
202
  `document`コマンドを使用すると、Backlog のドキュメントページを Markdown ファイルとしてエクスポートできます。
197
203
 
204
+ **基本的な使用方法**
205
+
198
206
  ```sh
199
- # 基本的な使用方法
200
207
  $ backlog-exporter document --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
208
+ ```
209
+
210
+ **出力先を指定**
201
211
 
202
- # 出力先を指定
212
+ ```sh
203
213
  $ backlog-exporter document --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./documents
214
+ ```
215
+
216
+ **キーワード検索**
204
217
 
205
- # キーワード検索
218
+ ```sh
206
219
  $ backlog-exporter document --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --keyword 仕様書
207
220
  ```
208
221
 
@@ -245,17 +258,27 @@ documents/
245
258
 
246
259
  `all`コマンドを使用すると、課題・Wiki・ドキュメントを一度に取得できます。
247
260
 
261
+ **基本的な使用方法**
262
+
248
263
  ```sh
249
- # 基本的な使用方法
250
264
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY
265
+ ```
266
+
267
+ **出力先を指定**
251
268
 
252
- # 出力先を指定
269
+ ```sh
253
270
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --output ./backlog-data
271
+ ```
272
+
273
+ **特定のデータタイプのみをエクスポート(onlyフラグ)**
254
274
 
255
- # 特定のデータタイプのみをエクスポート(onlyフラグ)
275
+ ```sh
256
276
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --only issues,wiki
277
+ ```
278
+
279
+ **特定のデータタイプを除外してエクスポート(excludeフラグ)**
257
280
 
258
- # 特定のデータタイプを除外してエクスポート(excludeフラグ)
281
+ ```sh
259
282
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --apiKey YOUR_API_KEY --exclude documents
260
283
  ```
261
284
 
@@ -269,11 +292,15 @@ $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY
269
292
 
270
293
  特定のデータタイプのみをエクスポートします。カンマ区切りで複数指定可能です。
271
294
 
295
+ **課題とWikiのみをエクスポート**
296
+
272
297
  ```sh
273
- # 課題とWikiのみをエクスポート
274
298
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --only issues,wiki
299
+ ```
275
300
 
276
- # ドキュメントのみをエクスポート
301
+ **ドキュメントのみをエクスポート**
302
+
303
+ ```sh
277
304
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --only documents
278
305
  ```
279
306
 
@@ -281,11 +308,15 @@ $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY
281
308
 
282
309
  特定のデータタイプを除外してエクスポートします。カンマ区切りで複数指定可能です。
283
310
 
311
+ **ドキュメント以外(課題とWiki)をエクスポート**
312
+
284
313
  ```sh
285
- # ドキュメント以外(課題とWiki)をエクスポート
286
314
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --exclude documents
315
+ ```
316
+
317
+ **課題以外(WikiとDocuments)をエクスポート**
287
318
 
288
- # 課題以外(WikiとDocuments)をエクスポート
319
+ ```sh
289
320
  $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY --exclude issues
290
321
  ```
291
322
 
@@ -295,26 +326,45 @@ $ backlog-exporter all --domain example.backlog.jp --projectIdOrKey PROJECT_KEY
295
326
 
296
327
  `update`コマンドを使用すると、既存のエクスポートデータを最新の状態に更新できます。このコマンドは、ディレクトリ内の`backlog-settings.json`ファイルを探索し、見つかったディレクトリでデータを更新します。
297
328
 
329
+ **カレントディレクトリとそのサブディレクトリのデータを更新**
330
+
298
331
  ```sh
299
- # カレントディレクトリとそのサブディレクトリのデータを更新
300
332
  $ backlog-exporter update
333
+ ```
301
334
 
302
- # 指定したディレクトリとそのサブディレクトリのデータを更新
335
+ **指定したディレクトリとそのサブディレクトリのデータを更新**
336
+
337
+ ```sh
303
338
  $ backlog-exporter update ./my-project
339
+ ```
304
340
 
305
- # 確認プロンプトをスキップして更新
341
+ **確認プロンプトをスキップして更新**
342
+
343
+ ```sh
306
344
  $ backlog-exporter update --force
345
+ ```
307
346
 
308
- # 課題のみを更新
347
+ **課題のみを更新**
348
+
349
+ ```sh
309
350
  $ backlog-exporter update --issuesOnly
351
+ ```
352
+
353
+ **Wikiのみを更新**
310
354
 
311
- # Wikiのみを更新
355
+ ```sh
312
356
  $ backlog-exporter update --wikisOnly
357
+ ```
358
+
359
+ **ドキュメントのみを更新**
313
360
 
314
- # ドキュメントのみを更新
361
+ ```sh
315
362
  $ backlog-exporter update --documentsOnly
363
+ ```
364
+
365
+ **APIキーを指定して更新**
316
366
 
317
- # APIキーを指定して更新
367
+ ```sh
318
368
  $ backlog-exporter update --apiKey YOUR_API_KEY
319
369
  ```
320
370
 
@@ -322,19 +372,6 @@ $ backlog-exporter update --apiKey YOUR_API_KEY
322
372
 
323
373
  # コマンド
324
374
 
325
- <!-- commands -->
326
- * [`backlog-exporter help [COMMAND]`](#backlog-exporter-help-command)
327
- * [`backlog-exporter plugins`](#backlog-exporter-plugins)
328
- * [`backlog-exporter plugins add PLUGIN`](#backlog-exporter-plugins-add-plugin)
329
- * [`backlog-exporter plugins:inspect PLUGIN...`](#backlog-exporter-pluginsinspect-plugin)
330
- * [`backlog-exporter plugins install PLUGIN`](#backlog-exporter-plugins-install-plugin)
331
- * [`backlog-exporter plugins link PATH`](#backlog-exporter-plugins-link-path)
332
- * [`backlog-exporter plugins remove [PLUGIN]`](#backlog-exporter-plugins-remove-plugin)
333
- * [`backlog-exporter plugins reset`](#backlog-exporter-plugins-reset)
334
- * [`backlog-exporter plugins uninstall [PLUGIN]`](#backlog-exporter-plugins-uninstall-plugin)
335
- * [`backlog-exporter plugins unlink [PLUGIN]`](#backlog-exporter-plugins-unlink-plugin)
336
- * [`backlog-exporter plugins update`](#backlog-exporter-plugins-update)
337
-
338
375
  ## `backlog-exporter help [COMMAND]`
339
376
 
340
377
  Display help for backlog-exporter.
@@ -644,6 +681,7 @@ DESCRIPTION
644
681
  ```
645
682
 
646
683
  _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/update.ts)_
684
+
647
685
  <!-- commandsstop -->
648
686
 
649
687
  # 出力形式
@@ -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
+ }