backlog-exporter 0.2.2 → 0.3.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
@@ -38,7 +38,6 @@ Backlog のデータをエクスポートするためのコマンドラインツ
38
38
  * [課題のタイトル](#課題のタイトル)
39
39
  * [Wiki のタイトル](#wiki-のタイトル)
40
40
  * [その他の特徴](#その他の特徴)
41
- * [最近の変更点](#最近の変更点)
42
41
  <!-- tocstop -->
43
42
 
44
43
  # 概要
@@ -59,7 +58,7 @@ $ npm install -g backlog-exporter
59
58
  $ backlog-exporter COMMAND
60
59
  running command...
61
60
  $ backlog-exporter (--version)
62
- backlog-exporter/0.2.2 linux-x64 node-v23.9.0
61
+ backlog-exporter/0.3.0 linux-x64 node-v23.9.0
63
62
  $ backlog-exporter --help [COMMAND]
64
63
  USAGE
65
64
  $ backlog-exporter COMMAND
@@ -220,7 +219,7 @@ EXAMPLES
220
219
  最大1000件の課題を取得する(デフォルトは100件)
221
220
  ```
222
221
 
223
- _See code: [src/commands/all/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.2.2/src/commands/all/index.ts)_
222
+ _See code: [src/commands/all/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.3.0/src/commands/all/index.ts)_
224
223
 
225
224
  ## `backlog-exporter help [COMMAND]`
226
225
 
@@ -276,7 +275,7 @@ EXAMPLES
276
275
  最大10000件の課題を取得する(デフォルトは5000件)
277
276
  ```
278
277
 
279
- _See code: [src/commands/issue/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.2.2/src/commands/issue/index.ts)_
278
+ _See code: [src/commands/issue/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.3.0/src/commands/issue/index.ts)_
280
279
 
281
280
  ## `backlog-exporter plugins`
282
281
 
@@ -605,7 +604,7 @@ EXAMPLES
605
604
  指定したディレクトリの設定を使用して更新する
606
605
  ```
607
606
 
608
- _See code: [src/commands/update/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.2.2/src/commands/update/index.ts)_
607
+ _See code: [src/commands/update/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.3.0/src/commands/update/index.ts)_
609
608
 
610
609
  ## `backlog-exporter wiki`
611
610
 
@@ -632,7 +631,7 @@ EXAMPLES
632
631
  指定したディレクトリにWikiを保存する
633
632
  ```
634
633
 
635
- _See code: [src/commands/wiki/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.2.2/src/commands/wiki/index.ts)_
634
+ _See code: [src/commands/wiki/index.ts](https://github.com/ShuntaToda/backlog-exporter/blob/v0.3.0/src/commands/wiki/index.ts)_
636
635
  <!-- commandsstop -->
637
636
 
638
637
  # 出力形式
@@ -697,16 +696,3 @@ Backlog の書式がそのまま保持されます。
697
696
  - **並列処理**: 並列処理による高速なダウンロード
698
697
  - **ファイル名サニタイズ**: ファイル名の自動サニタイズ(不正な文字の除去)
699
698
  - **階層構造の保持**: Wiki の階層構造を保持したエクスポート
700
-
701
- # 最近の変更点
702
-
703
- ## 2023-07-XX - v0.0.7
704
-
705
- - `update`コマンドの改善:
706
- - ディレクトリ内の`backlog-settings.json`ファイルを再帰的に探索し、見つかったディレクトリでデータを更新
707
- - 親フォルダ内のファイルを直接上書きするように変更(サブフォルダを作成しない)
708
- - コードの改善:メソッドのパラメータをオブジェクト形式に変更し、コードの可読性を向上
709
- - 確認プロンプトの追加:更新前に確認メッセージを表示し、ユーザーの承認を得るように変更
710
- - ドキュメントの改善:
711
- - README に各コマンドの詳細な説明を追加
712
- - `npx`を使った実行方法の説明を追加
@@ -3,6 +3,7 @@ import * as fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import process from 'node:process';
5
5
  import { sanitizeFileName, sanitizeWikiFileName } from './common.js';
6
+ import { appendLog } from './log.js';
6
7
  import { RateLimiter } from './sleep.js';
7
8
  /**
8
9
  * Backlogから課題をダウンロードする
@@ -130,6 +131,9 @@ export async function downloadIssues(command, options) {
130
131
  ${issue.description || '詳細情報なし'}${commentsSection}`;
131
132
  // eslint-disable-next-line no-await-in-loop
132
133
  await fs.writeFile(issueFilePath, markdownContent);
134
+ // ログに記録
135
+ // eslint-disable-next-line no-await-in-loop
136
+ await appendLog(options.outputDir, `課題「${issue.summary}」を更新しました: ${backlogIssueUrl}`);
133
137
  }
134
138
  catch (error) {
135
139
  command.warn(`課題 ${issue.issueKey} の保存に失敗しました: ${error instanceof Error ? error.message : String(error)}`);
@@ -159,6 +163,8 @@ async function fetchAllCommentsForIssue({ apiKey, baseUrl, command, issueKey, ra
159
163
  };
160
164
  try {
161
165
  await fetchComments();
166
+ // コメントを古い順(昇順)に並び替える
167
+ allComments.sort((a, b) => new Date(a.created).getTime() - new Date(b.created).getTime());
162
168
  return { comments: allComments };
163
169
  }
164
170
  catch (error) {
@@ -236,6 +242,9 @@ export async function downloadWikis(command, options) {
236
242
  const markdownContent = `# ${wiki.name}\n\n[Backlog Wiki Link](${backlogWikiUrl})\n\n${content}`;
237
243
  // eslint-disable-next-line no-await-in-loop
238
244
  await fs.writeFile(wikiFilePath, markdownContent);
245
+ // ログに記録
246
+ // eslint-disable-next-line no-await-in-loop
247
+ await appendLog(options.outputDir, `Wiki「${wiki.name}」を更新しました: ${backlogWikiUrl}`);
239
248
  // 進捗状況を一行で更新
240
249
  const wikiIndex = filteredWikis.indexOf(wiki) + 1;
241
250
  process.stdout.write(`\rWikiを保存中... (${wikiIndex}/${filteredWikis.length}件)`);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 更新ログを記録する
3
+ * @param outputDir 出力ディレクトリ
4
+ * @param message ログメッセージ
5
+ */
6
+ export declare function appendLog(outputDir: string, message: string): Promise<void>;
@@ -0,0 +1,18 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ /**
4
+ * 更新ログを記録する
5
+ * @param outputDir 出力ディレクトリ
6
+ * @param message ログメッセージ
7
+ */
8
+ export async function appendLog(outputDir, message) {
9
+ const logPath = path.join(outputDir, 'backlog-update.log');
10
+ const timestamp = new Date().toLocaleString('ja-JP');
11
+ const logMessage = `[${timestamp}] ${message}\n`;
12
+ try {
13
+ await fs.appendFile(logPath, logMessage, 'utf8');
14
+ }
15
+ catch (error) {
16
+ console.error(`ログの記録に失敗しました: ${error instanceof Error ? error.message : String(error)}`);
17
+ }
18
+ }
@@ -289,5 +289,5 @@
289
289
  ]
290
290
  }
291
291
  },
292
- "version": "0.2.2"
292
+ "version": "0.3.0"
293
293
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backlog-exporter",
3
3
  "description": "A new CLI generated with oclif",
4
- "version": "0.2.2",
4
+ "version": "0.3.0",
5
5
  "author": "ShuntaToda",
6
6
  "bin": {
7
7
  "backlog-exporter": "bin/run.js"