Skip to content

内部構造の改善#28

Merged
wato787 merged 2 commits intomainfrom
cursor/-bc-a9dce2bc-a305-4625-8389-cac9c5093b38-d671
Feb 23, 2026
Merged

内部構造の改善#28
wato787 merged 2 commits intomainfrom
cursor/-bc-a9dce2bc-a305-4625-8389-cac9c5093b38-d671

Conversation

@wato787
Copy link
Owner

@wato787 wato787 commented Feb 23, 2026

概要

コードベースのリファクタリングを行い、可読性、保守性、再利用性を向上させました。汎用的なユーティリティ関数を src/utils/ フォルダに集約し、テストカバレッジを強化しています。

背景 / 目的

ユーザーからのリファクタリング要望に応え、以下の目的を達成します。

  • 重複コードの削減とロジックの集約。
  • src/utils/ フォルダを新設し、将来のコマンド追加に備えた共通ユーティリティの整理。
  • 既存機能の動作をテストでより確実に担保。

変更内容

  • src/utils/ フォルダを新設し、汎用ユーティリティ関数(parse, naming, error 関連)を移動・分離。
  • management-api.ts 内の .map(parser).filter(x => x !== null) パターンを parseArray ユーティリティで解消。
  • config.tsserviceDomainapiKey の重複バリデーションロジックを resolveRequiredConfig() ヘルパーに集約。
  • type-generator.ts から getUniqueNameutils/naming.ts へ移動。
  • 重複していたテストヘルパー (createSchema, createTarget) を __tests__/helpers.ts に抽出。
  • src/utils/ 配下のユーティリティ関数に対するユニットテスト(35ケース)を新規追加。
  • 不要になった src/commands/generate/types/shared.ts を削除。

動作確認

  • bun run build
  • 必要なテストを実行
    • bun test: 全61テスト(既存26 + 新規35)が通過することを確認。
    • bun run lint: lintエラーがないことを確認。

影響範囲

  • ユーザー影響: なし (機能変更なし)
  • 開発者影響: 既存コードの構造が変更され、ユーティリティ関数のインポートパスが変わります。新しいユーティリティの利用を推奨。
  • 後方互換性: 内部的なリファクタリングのため、外部からの利用に影響なし。

補足

  • 特に src/utils/ への関数の分離と、parseArray の導入による重複解消点を見ていただきたいです。
  • 新規追加した utils のユニットテストもご確認ください。

Open in Web Open in Cursor 

- src/utils/parse.ts: isRecord, toStringValue, toBooleanValue, toStringArray, parseArray(新規)
- src/utils/naming.ts: toPascalCase, toTypePropertyName, getUniqueName(type-generatorから移動)
- src/utils/error.ts: toErrorMessage
- src/utils/index.ts: バレルエクスポート

- management-api.ts: parseArray を利用して .map().filter() の重複パターンを解消
- config.ts: resolveRequiredConfig に重複する設定バリデーションを集約
- テストヘルパー(createSchema, createTarget)を __tests__/helpers.ts に抽出
- utils の各関数に対するユニットテストを追加 (35テスト追加)
- shared.ts を削除

Co-authored-by: Ryusei Sugita <wato787@users.noreply.github.com>
@cursor
Copy link

cursor bot commented Feb 23, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Co-authored-by: Ryusei Sugita <wato787@users.noreply.github.com>
@wato787 wato787 marked this pull request as ready for review February 23, 2026 08:49
@wato787 wato787 merged commit b498990 into main Feb 23, 2026
2 checks passed
@wato787 wato787 deleted the cursor/-bc-a9dce2bc-a305-4625-8389-cac9c5093b38-d671 branch February 23, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants