backlog-exporter 1.1.0 → 1.2.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.
@@ -1,4 +1,5 @@
1
- import { collectDocumentTreePaths, resolveDocumentLeafPaths } from '../../document/domain/document-path.js';
1
+ import { addFallbackDocumentPaths, collectDocumentTreePaths, resolveDocumentLeafPaths, } from '../../document/domain/document-path.js';
2
+ import { findDocumentsMissingFromTree } from '../../document/domain/document-tree-gap.js';
2
3
  import { buildIssueExpectedPaths } from '../../issue/domain/issue-path.js';
3
4
  import { buildWikiExpectedPaths } from '../../wiki/domain/wiki-path.js';
4
5
  import { pruneLocalMarkdownFiles } from '../repository/prune-walker.js';
@@ -7,19 +8,21 @@ export async function pruneDocuments(deps, options) {
7
8
  logger.log('Backlogのドキュメントツリーを取得しています...');
8
9
  const documentTree = await documentRepository.fetchTree(options.projectId);
9
10
  const expected = collectDocumentTreePaths(documentTree.activeTree.children);
10
- // 保存時のファイル名は詳細のtitle基準のため、一覧APIでタイトルを解決してから期待パスを確定する
11
- let titlesById = new Map();
12
- if (expected.leafNodes.length > 0) {
13
- logger.log(`${expected.leafNodes.length}件のドキュメントの正規ファイル名を確認しています...`);
14
- try {
15
- titlesById = await documentRepository.fetchAllTitles(options.projectId);
16
- }
17
- catch (error) {
18
- // 一覧に欠けが生じると実在ドキュメントを誤削除するため、何も削除せずに中止する
19
- throw new Error(`ドキュメント一覧の取得に失敗しました。誤削除を防ぐため、何も削除せずに中止します: ${error instanceof Error ? error.message : String(error)}`);
20
- }
11
+ // 保存時のファイル名は詳細のtitle基準のため、一覧APIでタイトルを解決してから期待パスを確定する。
12
+ // 一覧はツリーに現れないドキュメントを拾う台帳でもあるため、リーフの有無に関わらず取得する
13
+ logger.log('ドキュメント一覧でファイル名を確認しています...');
14
+ let titlesById;
15
+ try {
16
+ titlesById = await documentRepository.fetchAllTitles(options.projectId);
17
+ }
18
+ catch (error) {
19
+ // 一覧に欠けが生じると実在ドキュメントを誤削除するため、何も削除せずに中止する
20
+ throw new Error(`ドキュメント一覧の取得に失敗しました。誤削除を防ぐため、何も削除せずに中止します: ${error instanceof Error ? error.message : String(error)}`);
21
21
  }
22
22
  resolveDocumentLeafPaths(expected, titlesById);
23
+ // 取得側はツリーに現れないドキュメントを出力ルート直下に保存するため、同じ配置を期待集合に加える
24
+ // (加えないと、補完して取得したファイルをpruneが即座に削除してしまう)
25
+ addFallbackDocumentPaths(expected, findDocumentsMissingFromTree(documentTree, titlesById));
23
26
  return pruneLocalMarkdownFiles({
24
27
  expected,
25
28
  label: 'ドキュメント',
@@ -189,6 +189,71 @@
189
189
  "index.js"
190
190
  ]
191
191
  },
192
+ "prune": {
193
+ "aliases": [],
194
+ "args": {
195
+ "directory": {
196
+ "description": "対象ディレクトリ(設定ファイルが保存されている場所)",
197
+ "name": "directory",
198
+ "required": false
199
+ }
200
+ },
201
+ "description": "Backlog上で削除・移動された課題・ドキュメント・Wikiのローカルファイルを削除し、Backlogと同じ状態に揃える",
202
+ "examples": [
203
+ "<%= config.bin %> <%= command.id %>\nカレントディレクトリ配下の設定ファイルを探索し、Backlog上に存在しないドキュメントファイルを削除する\n",
204
+ "<%= config.bin %> <%= command.id %> ./backlog-documents\n指定したディレクトリを対象にする\n",
205
+ "<%= config.bin %> <%= command.id %> --force\n確認プロンプトをスキップして削除する\n"
206
+ ],
207
+ "flags": {
208
+ "apiKey": {
209
+ "description": "Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)",
210
+ "name": "apiKey",
211
+ "required": false,
212
+ "hasDynamicHelp": false,
213
+ "multiple": false,
214
+ "type": "option"
215
+ },
216
+ "domain": {
217
+ "description": "Backlog domain (e.g. example.backlog.jp)",
218
+ "name": "domain",
219
+ "required": false,
220
+ "hasDynamicHelp": false,
221
+ "multiple": false,
222
+ "type": "option"
223
+ },
224
+ "force": {
225
+ "char": "f",
226
+ "description": "確認プロンプトをスキップする",
227
+ "name": "force",
228
+ "required": false,
229
+ "allowNo": false,
230
+ "type": "boolean"
231
+ },
232
+ "projectIdOrKey": {
233
+ "description": "Backlog project ID or key",
234
+ "name": "projectIdOrKey",
235
+ "required": false,
236
+ "hasDynamicHelp": false,
237
+ "multiple": false,
238
+ "type": "option"
239
+ }
240
+ },
241
+ "hasDynamicHelp": false,
242
+ "hiddenAliases": [],
243
+ "id": "prune",
244
+ "pluginAlias": "backlog-exporter",
245
+ "pluginName": "backlog-exporter",
246
+ "pluginType": "core",
247
+ "strict": true,
248
+ "enableJsonFlag": false,
249
+ "isESM": true,
250
+ "relativePath": [
251
+ "dist",
252
+ "commands",
253
+ "prune",
254
+ "index.js"
255
+ ]
256
+ },
192
257
  "issue": {
193
258
  "aliases": [],
194
259
  "args": {},
@@ -294,71 +359,6 @@
294
359
  "index.js"
295
360
  ]
296
361
  },
297
- "prune": {
298
- "aliases": [],
299
- "args": {
300
- "directory": {
301
- "description": "対象ディレクトリ(設定ファイルが保存されている場所)",
302
- "name": "directory",
303
- "required": false
304
- }
305
- },
306
- "description": "Backlog上で削除・移動された課題・ドキュメント・Wikiのローカルファイルを削除し、Backlogと同じ状態に揃える",
307
- "examples": [
308
- "<%= config.bin %> <%= command.id %>\nカレントディレクトリ配下の設定ファイルを探索し、Backlog上に存在しないドキュメントファイルを削除する\n",
309
- "<%= config.bin %> <%= command.id %> ./backlog-documents\n指定したディレクトリを対象にする\n",
310
- "<%= config.bin %> <%= command.id %> --force\n確認プロンプトをスキップして削除する\n"
311
- ],
312
- "flags": {
313
- "apiKey": {
314
- "description": "Backlog API key (環境変数 BACKLOG_API_KEY からも自動読み取り可能)",
315
- "name": "apiKey",
316
- "required": false,
317
- "hasDynamicHelp": false,
318
- "multiple": false,
319
- "type": "option"
320
- },
321
- "domain": {
322
- "description": "Backlog domain (e.g. example.backlog.jp)",
323
- "name": "domain",
324
- "required": false,
325
- "hasDynamicHelp": false,
326
- "multiple": false,
327
- "type": "option"
328
- },
329
- "force": {
330
- "char": "f",
331
- "description": "確認プロンプトをスキップする",
332
- "name": "force",
333
- "required": false,
334
- "allowNo": false,
335
- "type": "boolean"
336
- },
337
- "projectIdOrKey": {
338
- "description": "Backlog project ID or key",
339
- "name": "projectIdOrKey",
340
- "required": false,
341
- "hasDynamicHelp": false,
342
- "multiple": false,
343
- "type": "option"
344
- }
345
- },
346
- "hasDynamicHelp": false,
347
- "hiddenAliases": [],
348
- "id": "prune",
349
- "pluginAlias": "backlog-exporter",
350
- "pluginName": "backlog-exporter",
351
- "pluginType": "core",
352
- "strict": true,
353
- "enableJsonFlag": false,
354
- "isESM": true,
355
- "relativePath": [
356
- "dist",
357
- "commands",
358
- "prune",
359
- "index.js"
360
- ]
361
- },
362
362
  "update": {
363
363
  "aliases": [],
364
364
  "args": {
@@ -566,5 +566,5 @@
566
566
  ]
567
567
  }
568
568
  },
569
- "version": "1.1.0"
569
+ "version": "1.2.0"
570
570
  }
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": "1.1.0",
4
+ "version": "1.2.0",
5
5
  "author": "ShuntaToda",
6
6
  "bin": {
7
7
  "backlog-exporter": "bin/run.js"