Skip to content

大規模コード改善 - モジュール化・UI刷新・型安全性向上#2

Merged
kazuph merged 10 commits into
mainfrom
feature/massive-improvement
Mar 26, 2026
Merged

大規模コード改善 - モジュール化・UI刷新・型安全性向上#2
kazuph merged 10 commits into
mainfrom
feature/massive-improvement

Conversation

@kazuph

@kazuph kazuph commented Mar 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • 888行の単一ファイル(src/index.ts)を8つの専門モジュールに分割
  • モダンなランディングページ(ダークモード・レスポンシブ・アニメーション対応)
  • Vite + @cloudflare/vite-plugin 導入で開発体験向上
  • tsgo (TypeScript 7.0 native preview) 導入で高速型チェック
  • Chrome拡張「Go to Pera1」でGitHubリポページからワンクリックアクセス

変更内容

モジュール分割

ファイル 責務
src/index.ts ルーティング薄層 (~50行)
src/resolver.ts URL解析+クエリパラメータ結合
src/github.ts GitHub ZIP取得・展開・フォーマット
src/filters.ts バイナリ判定、スキップ判定
src/tree.ts ディレクトリツリー表示
src/ui.ts ランディングページHTML
src/mcp.ts MCPサーバー
src/types.ts 型定義
src/constants.ts 定数

開発ツールチェーン

  • vite dev / vite build で開発・ビルド
  • npm run typecheck:native で tsgo 高速型チェック

Chrome拡張

  • extension/ ディレクトリにManifest V3拡張
  • GitHubリポジトリページでリポ名横に「Go to Pera1」ボタン表示

Screenshots

ランディングページ(ライトモード)

Landing

ダークモード

Dark

Test plan

  • TypeScript型チェック(tsc --noEmit)パス
  • tsgo型チェック パス
  • wrangler dry-run build パス
  • Vite dev server正常起動
  • ルートページ: 200 OK
  • リポジトリ取得: 200 OK
  • MCPエンドポイント: 応答確認
  • エラーページ: 正常表示
  • 本番デプロイ確認

🤖 Generated with Claude Code

kazuph and others added 9 commits March 26, 2026 22:18
- Split 888-line index.ts into 8 focused modules (resolver, github, filters, tree, ui, mcp, types, constants)
- Modern landing page with dark mode, responsive design, animations
- Add Vite + @cloudflare/vite-plugin for modern dev workflow
- Add tsgo (TypeScript 7.0 native preview) for fast type checking
- Chrome extension "Go to Pera1" button on GitHub repo pages
- Cache-Control headers, updated compatibility_date, nodejs_compat

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add escapeHtml() and escapeJs() functions to ui.ts
- Escape all dynamic values (errorMessage, targetUrl, protocol, host)
- Fix O(n²) Array.from() in tree.ts loop

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove package-lock.json from repo (pnpm-lock.yaml is the lockfile)
- Add package-lock.json to .gitignore
- Pin @typescript/native-preview to exact version (preview builds need stability)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add normalizeRepositoryInput() to resolver.ts for SSH/SCP/git:// URL normalization
- Client-side normalization in UI form for git@ format input
- Strip .git suffix from all URL formats
- Support: git@, ssh://, git://, https://, bare github.com/owner/repo

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- 19 unit tests for resolveRequest (basic, tree/blob, query params, SSH, .git removal, errors)
- 14 HTTP integration tests via app.fetch (basic, branch, filter, file, tree, MCP, SSH, landing, fallback, errors)
- vitest config with TS-first resolution
- Test ZIP helper using JSZip for realistic GitHub codeload responses

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- ci.yml: runs vitest + tsc type check on PRs and pushes to main
- deploy.yml: deploys to Cloudflare Workers via wrangler on main merge
- Uses CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID from GitHub Secrets

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- wrangler.toml: add [env.preview] with name = "pera1-preview"
- ci.yml: deploy to preview env on PR, post preview URL as PR comment
- deploy.yml: production deploy only on main merge (unchanged behavior)
- Preview updates on every push to PR branch

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
package-lock.json is gitignored, so npm ci fails. Switch to npm install.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Align fetch interceptor types with Cloudflare Workers RequestInit types.
Use Promise<Response | null> instead of Promise<Response> | null.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Mar 26, 2026

Copy link
Copy Markdown

🚀 Preview deployed!

https://pera1-preview.kazu-san.workers.dev

This preview will be updated on every push to this PR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kazuph kazuph merged commit 3f3a196 into main Mar 26, 2026
2 checks passed
@kazuph kazuph deleted the feature/massive-improvement branch March 26, 2026 21:09
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.

1 participant