Skip to content

chore: ドキュメントサイトを apps/ 配下へ移動し Vercel デプロイ設定を追加 - #119

Merged
newt239 merged 8 commits into
mainfrom
chore/move-docs-to-apps
Sep 21, 2026
Merged

newt239 merged 8 commits into
mainfrom
chore/move-docs-to-apps

Conversation

@newt239

@newt239 newt239 commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

概要

ドキュメントサイトを app/ginga-ui.com から apps/ginga-ui.com へ移動し、あわせて Vercel にデプロイできる状態にします。

変更内容

1. app/ → apps/ への移動

git mv でディレクトリをリネームし、パスを参照していた 5 ファイルを更新しました。

  • pnpm-workspace.yaml — workspace glob
  • package.json — docs スクリプト
  • tsconfig.json — #/* パスエイリアス
  • knip.json — workspaces エントリ
  • AGENTS.md — モノレポ構造の説明

.changeset/config.json はパッケージ名ベース、.github/・turbo.json・.storybook/・lint 系設定はパス非依存のため変更不要でした。

2. Node.js バージョンを 24.x に統一

Vercel が選べる Node.js は 24.x / 22.x / 20.x のみ(26.x は Vercel Sandbox 専用)のため、devEngines.runtime.version を 26.8.1 → 24.21.0 に変更しました。actions/setup-node も node-version-file: "package.json" を参照しているため、CI も Node 24 に揃います。

3. Vercel のビルド設定を追加

apps/ginga-ui.com/vercel.json

{ "buildCommand": "cd ../.. && pnpm exec turbo run build --filter=ginga-ui.com" }

@ginga-ui/core / @ginga-ui/utils は dist/ を exports しているため、next build の前に tsdown ビルドが必要です。turbo の dependsOn: ["^build"] により依存パッケージが先にビルドされます。

apps/ginga-ui.com/turbo.json

ルート turbo.json の build.outputs は dist/** のみで Next.js の .next/** が漏れており、turbo キャッシュがヒットすると成果物が復元されず Vercel が失敗します。パッケージ単位で outputs を上書きしました。

4. pnpm docs → pnpm run docs

pnpm docs は pnpm 12 の組み込みコマンドと衝突してスクリプトが実行されないため、AGENTS.md の記載を修正しました。

5. テーマ生成 API の API キー取り扱いを修正

/api/generate-theme はリクエストごとに process.env[envKey] を書き換えて ThemeClient を生成し、finally で復元していました。サーバーレス環境で同一インスタンスに並行リクエストが来ると、あるユーザーの API キーが別のユーザーのリクエストで使われうる状態でした。

ThemeClient のコンストラクタに apiKey を追加し(AI SDK の createOpenAI / createGoogleGenerativeAI / createAnthropic を使用)、ルートから process.env の書き換えを削除しました。apiKey を省略した場合は従来どおり環境変数が使われるため、既存の呼び出し側に影響はありません。@ginga-ui/utils の minor として changeset を追加しています。

6. next dev の自動生成ファイルを追跡対象から外す

next dev が apps/ginga-ui.com/AGENTS.md と CLAUDE.md を自動生成していたため、next.config.ts に agentRules: false を追加して無効化しました(Next.js 16 の正式オプション)。リポジトリルートに既に AGENTS.md があるので、サブディレクトリにもう一組を置かない方針です。

あわせて next-env.d.ts を .gitignore に追加し、git rm --cached で追跡から外しました。Next.js 16 の公式ドキュメント(next/dist/docs/01-app/03-api-reference/05-config/02-typescript.md)に「Next.js が管理する実装詳細なので .gitignore に追加し、追跡済みなら Git から削除する」と明記されています。実際 next dev と next build でこのファイルの中身が .next/dev/types/... と .next/types/... の間で往復し、毎回差分が出ていました。

安全性は実測済みです。next-env.d.ts と .next の両方が存在しない状態(CI の新規チェックアウト相当)でも pnpm exec tsc --noEmit は通り、next build がこのファイルを再生成します。

検証

  • pnpm exec tsc --noEmit / pnpm run lint / pnpm run format / pnpm run stylelint / pnpm run knip — すべてパス
  • pnpm exec turbo run build --filter=ginga-ui.com — @ginga-ui/utils → @ginga-ui/core → ginga-ui.com の順に 3 タスク成功
  • .next を削除して再実行し、FULL TURBO キャッシュから .next が復元されることを確認
  • dev サーバーで / /components/button /quick-start /theme-generation がいずれも 200
  • /api/generate-theme の挙動:
リクエスト レスポンス
apiKey なし 400 APIキーとプロンプトが必要です
provider: "browser" 400 不明なプロバイダーです: browser
ダミーキーで provider: "openai" Incorrect API key provided: sk-inval********-key

3 つ目で、ローカル .env の実キーではなくリクエストボディのキーが使われていることを確認しました。

マージ後の作業(Vercel ダッシュボード)

  1. https://vercel.com/new で newt239/ginga-ui を Import し、Root Directory を apps/ginga-ui.com に設定
  2. Build / Install / Output の Override はすべて OFF のまま(vercel.json から適用される)
  3. 環境変数に ENABLE_EXPERIMENTAL_COREPACK=1 を追加(必須)
    ロックファイルは lockfileVersion: '9.0' のため Vercel は pnpm 9/10 を選びますが、本リポジトリのロックファイルには pnpm 12 固有の packageManagerDependencies: / configDependencies:、pnpm-workspace.yaml には pnpm 11+ の allowBuilds / minimumReleaseAgeExcludePrune が含まれており、pnpm 9/10 では install が失敗します
  4. Node.js Version を 24.x に設定

アプリケーション用の環境変数は不要です。

🤖 Generated with Claude Code

newt239 and others added 5 commits September 21, 2026 21:07
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2e71b94

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@ginga-ui/utils Minor
@ginga-ui/core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

newt239 and others added 3 commits September 21, 2026 21:16
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@newt239 newt239 self-assigned this Sep 21, 2026
@newt239
newt239 merged commit b823ab6 into main Sep 21, 2026
1 check passed
@newt239
newt239 deleted the chore/move-docs-to-apps branch September 21, 2026 12:38
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