create-ampless 0.2.0-alpha.8 → 1.0.0-alpha.39
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.ja.md +77 -0
- package/README.md +4 -1
- package/dist/index.js +670 -88
- package/dist/templates/_shared/AGENTS.ja.md +104 -0
- package/dist/templates/_shared/AGENTS.md +104 -0
- package/dist/templates/_shared/README.ja.md +175 -0
- package/dist/templates/_shared/README.md +175 -0
- package/dist/templates/_shared/RUNBOOK.ja.md +120 -0
- package/dist/templates/_shared/RUNBOOK.md +24 -51
- package/dist/templates/_shared/amplify/auth/post-confirmation/resource.ts +6 -0
- package/dist/templates/_shared/amplify/backend.custom.ts +41 -0
- package/dist/templates/_shared/amplify/backend.ts +12 -2
- package/dist/templates/_shared/amplify/data/get-published-post.js +9 -12
- package/dist/templates/_shared/amplify/data/list-posts-by-tag.js +6 -9
- package/dist/templates/_shared/amplify/data/list-published-posts.js +10 -11
- package/dist/templates/_shared/amplify/data/resource.custom.ts +32 -0
- package/dist/templates/_shared/amplify/data/resource.ts +26 -13
- package/dist/templates/_shared/amplify/events/processor-untrusted/resource.ts +4 -0
- package/dist/templates/_shared/amplify/functions/mcp-handler/handler.ts +1 -0
- package/dist/templates/_shared/amplify/functions/mcp-handler/resource.ts +11 -0
- package/dist/templates/_shared/amplify/functions/user-admin/handler.ts +4 -0
- package/dist/templates/_shared/amplify/functions/user-admin/resource.ts +12 -0
- package/dist/templates/_shared/app/(admin)/admin/mcp-tokens/page.tsx +5 -0
- package/dist/templates/_shared/app/(admin)/admin/users/page.tsx +5 -0
- package/dist/templates/_shared/app/globals.css +55 -39
- package/dist/templates/_shared/app/layout.tsx +24 -11
- package/dist/templates/_shared/app/site/[siteId]/r/[slug]/[[...path]]/route.ts +17 -0
- package/dist/templates/_shared/cms.config.ts +1 -23
- package/dist/templates/_shared/components/site-chrome/site-sidebar.tsx +2 -3
- package/dist/templates/_shared/lib/admin.ts +9 -7
- package/dist/templates/_shared/lib/posts-public.ts +1 -1
- package/dist/templates/_shared/package.json +11 -9
- package/dist/templates/_shared/proxy.ts +3 -3
- package/dist/templates/blog/README.ja.md +22 -0
- package/dist/templates/blog/README.md +17 -47
- package/dist/templates/blog/manifest.ts +1 -1
- package/dist/templates/blog/pages/feed.ts +3 -4
- package/dist/templates/blog/pages/home.tsx +5 -8
- package/dist/templates/blog/pages/post.tsx +7 -7
- package/dist/templates/blog/pages/sitemap.ts +3 -4
- package/dist/templates/blog/pages/tag.tsx +4 -4
- package/dist/templates/blog/tokens.css +26 -40
- package/dist/templates/corporate/README.ja.md +18 -0
- package/dist/templates/corporate/README.md +12 -14
- package/dist/templates/corporate/pages/feed.ts +2 -3
- package/dist/templates/corporate/pages/home.tsx +5 -8
- package/dist/templates/corporate/pages/post.tsx +7 -7
- package/dist/templates/corporate/pages/sitemap.ts +2 -3
- package/dist/templates/corporate/pages/tag.tsx +4 -4
- package/dist/templates/corporate/tokens.css +17 -39
- package/dist/templates/dads/README.ja.md +31 -0
- package/dist/templates/dads/README.md +13 -17
- package/dist/templates/dads/pages/feed.ts +2 -3
- package/dist/templates/dads/pages/home.tsx +5 -8
- package/dist/templates/dads/pages/post.tsx +7 -7
- package/dist/templates/dads/pages/sitemap.ts +2 -3
- package/dist/templates/dads/pages/tag.tsx +4 -4
- package/dist/templates/dads/tokens.css +22 -42
- package/dist/templates/docs/README.ja.md +24 -0
- package/dist/templates/docs/README.md +10 -13
- package/dist/templates/docs/pages/feed.ts +2 -3
- package/dist/templates/docs/pages/home.tsx +5 -6
- package/dist/templates/docs/pages/post.tsx +8 -8
- package/dist/templates/docs/pages/sitemap.ts +2 -3
- package/dist/templates/docs/pages/tag.tsx +5 -5
- package/dist/templates/docs/tokens.css +17 -39
- package/dist/templates/landing/README.ja.md +20 -0
- package/dist/templates/landing/README.md +14 -19
- package/dist/templates/landing/pages/feed.ts +3 -4
- package/dist/templates/landing/pages/home.tsx +5 -8
- package/dist/templates/landing/pages/post.tsx +7 -7
- package/dist/templates/landing/pages/sitemap.ts +2 -3
- package/dist/templates/landing/pages/tag.tsx +4 -4
- package/dist/templates/landing/tokens.css +17 -39
- package/dist/templates/minimal/README.ja.md +14 -0
- package/dist/templates/minimal/README.md +9 -47
- package/dist/templates/minimal/pages/feed.ts +3 -4
- package/dist/templates/minimal/pages/home.tsx +3 -4
- package/dist/templates/minimal/pages/post.tsx +6 -6
- package/dist/templates/minimal/pages/sitemap.ts +3 -4
- package/dist/templates/minimal/pages/tag.tsx +3 -3
- package/dist/templates/minimal/tokens.css +17 -39
- package/package.json +1 -1
- package/dist/templates/_shared/app/(admin)/admin/sites/page.tsx +0 -5
- package/dist/templates/_shared/app/site/[siteId]/raw/[slug]/route.ts +0 -5
- package/dist/templates/_shared/lib/admin-site-client.ts +0 -10
- package/dist/templates/_shared/lib/admin-site.ts +0 -12
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
> English: [AGENTS.md](./AGENTS.md)
|
|
2
|
+
>
|
|
3
|
+
# AGENTS.md
|
|
4
|
+
|
|
5
|
+
このファイルは AI コーディングエージェント(Claude Code, Cursor, Codex など)が読む前提で書かれています。人間向けの日常利用ガイドは `README.ja.md` と `RUNBOOK.ja.md` を参照してください。
|
|
6
|
+
|
|
7
|
+
## プロジェクトのレイアウト
|
|
8
|
+
|
|
9
|
+
- `themes/<name>/` — インストール済みのテーマ(tokens、pages、manifest)。アクティブテーマの切り替えは `/admin/sites/<id>/theme` で行う。
|
|
10
|
+
- `themes/my-<name>/` — ユーザーが所有するカスタマイズ済みのテーマコピー(`npm run copy-theme` で作成)。`my-` プレフィックスがついているコピーは `update-ampless` で上書きされない。
|
|
11
|
+
- `themes-registry.ts` — 自動生成ファイル。手動で編集しない。
|
|
12
|
+
- `amplify/` — TypeScript で定義された Amplify Gen 2 バックエンド(Cognito / DynamoDB / S3 / AppSync / Lambda)。
|
|
13
|
+
- `amplify_outputs.json` — `npm run sandbox` / Amplify Hosting が生成するファイル。編集しない。
|
|
14
|
+
- `app/` — Next.js 15 App Router(公開サイト + `/admin` UI)。
|
|
15
|
+
- `components/` — 共有 UI コンポーネント。
|
|
16
|
+
- `lib/` — 共有ユーティリティ(データアクセス、認証など)。
|
|
17
|
+
- `cms.config.ts` — サイト、プラグイン、デフォルト設定。
|
|
18
|
+
- `proxy.ts` — リクエストプロキシの設定。
|
|
19
|
+
|
|
20
|
+
## 触っていい場所・ダメな場所
|
|
21
|
+
|
|
22
|
+
**自由に編集可能:**
|
|
23
|
+
- `themes/my-*/` — ユーザー自身のテーマコピー。
|
|
24
|
+
- `cms.config.ts` — サイト / プラグインの設定。
|
|
25
|
+
- 投稿コンテンツは管理 UI(推奨)または MCP サーバー経由で操作する。
|
|
26
|
+
|
|
27
|
+
**注意して触る(編集前に理由を説明すること):**
|
|
28
|
+
- `app/`、`components/`、`lib/` — 共有シェルの一部。`update-ampless` 後も編集は残るが、上流が同じファイルを変更した場合のマージはユーザー側の責任になる。テーマ関連の変更であれば、カスタムテーマ経由での拡張を優先する。
|
|
29
|
+
- `themes/<official-name>/`(`my-` プレフィックスなし)— 公式テーマは `update-ampless` で上書きされる。カスタマイズしたい場合は先に `npm run copy-theme <official-name> my-<your-name>` を実行し、コピーを編集する。
|
|
30
|
+
- `package.json` — `ampless` / `@ampless/*` のバージョンは一貫して管理する。バージョンアップには `update-ampless` を使う。
|
|
31
|
+
|
|
32
|
+
**編集禁止:**
|
|
33
|
+
- `themes-registry.ts` — scaffold / copy-theme / update コマンドが再生成する。
|
|
34
|
+
- `amplify/` — バックエンドのスキーマ変更はテーブルの再構築とサンドボックスデータの消失を招く可能性がある。触る前にユーザーの明示的な確認を得ること。
|
|
35
|
+
- `amplify_outputs.json` — `npm run sandbox` のたびに再生成される。
|
|
36
|
+
- `.amplify/` — Amplify CLI の作業ディレクトリ。
|
|
37
|
+
- `pnpm-lock.yaml` / `package-lock.json` — パッケージマネージャーに任せる。
|
|
38
|
+
|
|
39
|
+
## テーマのカスタマイズ(標準的な手順)
|
|
40
|
+
|
|
41
|
+
1. 公式テーマをコピーする:
|
|
42
|
+
```bash
|
|
43
|
+
npm run copy-theme blog my-blog
|
|
44
|
+
```
|
|
45
|
+
`my-` プレフィックスがついているコピーは `npm run update-ampless` で上書きされない。ターゲット名が `my-` で始まらない場合、コマンドは実行を拒否する。
|
|
46
|
+
|
|
47
|
+
2. 以下の優先順位で編集する:
|
|
48
|
+
- `themes/my-blog/tokens.css` — 色、タイポグラフィ、スペーシング(`[data-theme='my-blog']` スコープの CSS カスタムプロパティ)。
|
|
49
|
+
- `themes/my-blog/manifest.ts` — 管理 UI(`/admin/sites/<id>/theme`)に公開するフィールドの宣言。
|
|
50
|
+
- `themes/my-blog/pages/` — レイアウト / 構造(Next.js ページモジュール: フィード、サイトマップ、投稿テンプレート)。
|
|
51
|
+
|
|
52
|
+
3. テーマを有効化する: `/admin/sites/<siteId>/theme` を開き、`my-blog` を選択する。テーマ切り替えはランタイム設定 — 再デプロイは不要。
|
|
53
|
+
|
|
54
|
+
4. 動作確認:
|
|
55
|
+
```bash
|
|
56
|
+
npm run dev # http://localhost:3000
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## MCP サーバー(`@ampless/mcp-server`)
|
|
60
|
+
|
|
61
|
+
エージェントが投稿コンテンツを直接クエリ・編集できる。公開ツール: `list_posts`、`get_post`、`create_post`、`update_post`、`delete_post`、`upload_media`、`get_schema`。
|
|
62
|
+
|
|
63
|
+
登録方法:
|
|
64
|
+
|
|
65
|
+
プロジェクトルートの `.mcp.json` に追加する:
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"ampless": {
|
|
70
|
+
"command": "npx",
|
|
71
|
+
"args": ["-y", "@ampless/mcp-server", "--outputs", "./amplify_outputs.json"],
|
|
72
|
+
"env": {
|
|
73
|
+
"AMPLESS_MCP_EMAIL": "<your-admin-email>",
|
|
74
|
+
"AMPLESS_MCP_PASSWORD": "<your-admin-password>"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
投稿本文は `markdown`、`html`、`tiptap`(JSON ドキュメント)の 3 フォーマットに対応している。
|
|
82
|
+
|
|
83
|
+
## 動作確認の基準
|
|
84
|
+
|
|
85
|
+
変更後は最低限以下を実行すること:
|
|
86
|
+
|
|
87
|
+
- `npm run dev` でブラウザから該当ページを開く。UI / テーマの変更は特に目視確認が必要(Playwright MCP が使える場合はスクリーンショットを活用する)。
|
|
88
|
+
- `npm run build` — 本番ビルドが成功することを確認する。
|
|
89
|
+
- `npm run lint`。
|
|
90
|
+
|
|
91
|
+
UI / テーマを変更した場合、型チェックだけを根拠にタスク完了を報告しない — ブラウザで実際に確認すること。
|
|
92
|
+
|
|
93
|
+
## 既知の制約
|
|
94
|
+
|
|
95
|
+
- **サンドボックスのデータは揮発性。** スキーマに影響する変更は API とテーブルの再構築を引き起こす可能性がある。サンドボックスのコンテンツは使い捨てとして扱うこと。本番データは永続する。
|
|
96
|
+
- **1 Amplify デプロイ = 1 サイト。** 複数サイトを別ドメインで配信したい場合は、サイトごとに Amplify 環境を分けてデプロイする。スキーマの `siteId` カラムは常に `"default"` 固定(前方互換のため残してある)。
|
|
97
|
+
- **AppSync 公開 API キーは `amplify_outputs.json` に含まれ、サイト訪問者から見える。** 低信頼の認証情報として扱うこと — このキーの権限は公開済み投稿の読み取りのみ。`api-key-renewer` Lambda が毎月自動ローテーションするため、手動ローテーションは不要。
|
|
98
|
+
- **最初に登録したユーザーが管理者になる。** 以降のロール変更は Cognito コンソールで行う(RUNBOOK 参照)。
|
|
99
|
+
|
|
100
|
+
## 参照先
|
|
101
|
+
|
|
102
|
+
- `README.ja.md` — サイト運営者向けの日常利用ガイド。
|
|
103
|
+
- `RUNBOOK.ja.md` — 定期的な運用手順(キーローテーション、バックアップ復元など)。
|
|
104
|
+
- `themes/<name>/README.ja.md` — テーマごとのカスタマイズ詳細。
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
> 日本語版: [AGENTS.ja.md](./AGENTS.ja.md)
|
|
2
|
+
>
|
|
3
|
+
# AGENTS.md
|
|
4
|
+
|
|
5
|
+
This file is written for AI coding agents (Claude Code, Cursor, Codex, etc.). For human-readable day-to-day guidance, see `README.md` and `RUNBOOK.md`.
|
|
6
|
+
|
|
7
|
+
## Project layout
|
|
8
|
+
|
|
9
|
+
- `themes/<name>/` — installed themes (tokens, pages, manifest). Switch active theme at `/admin/sites/<id>/theme`.
|
|
10
|
+
- `themes/my-<name>/` — user-owned customised theme copies (created via `npm run copy-theme`). The `my-` prefix is what marks the copy as user-owned; `update-ampless` leaves anything under `themes/my-*/` alone.
|
|
11
|
+
- `themes-registry.ts` — auto-generated, do not hand-edit.
|
|
12
|
+
- `amplify/` — Amplify Gen 2 backend (Cognito / DynamoDB / S3 / AppSync / Lambda) defined in TypeScript.
|
|
13
|
+
- `amplify_outputs.json` — generated by `npm run sandbox` / Amplify Hosting. Do not edit.
|
|
14
|
+
- `app/` — Next.js 15 App Router (public site + `/admin` UI).
|
|
15
|
+
- `components/` — shared UI components.
|
|
16
|
+
- `lib/` — shared utilities (data access, auth, etc.).
|
|
17
|
+
- `cms.config.ts` — site, plugins, defaults.
|
|
18
|
+
- `proxy.ts` — request proxy config.
|
|
19
|
+
|
|
20
|
+
## What you can and can't touch
|
|
21
|
+
|
|
22
|
+
**Free to edit:**
|
|
23
|
+
- `themes/my-*/` — your own theme copies.
|
|
24
|
+
- `cms.config.ts` — site/plugin config.
|
|
25
|
+
- Post content via the admin UI (recommended) or via the MCP server.
|
|
26
|
+
|
|
27
|
+
**Touch with caution (explain why before editing):**
|
|
28
|
+
- `app/`, `components/`, `lib/` — these are part of the shared shell. Edits survive `update-ampless` but you own the merge if upstream changes the same file. Prefer extending via a custom theme if the change is theme-related.
|
|
29
|
+
- `themes/<official-name>/` (no `my-` prefix) — official themes get overwritten by `update-ampless`. If you want to customise, run `npm run copy-theme <official-name> my-<your-name>` first and edit the copy.
|
|
30
|
+
- `package.json` — keep `ampless` / `@ampless/*` versions consistent. Use `update-ampless` to bump them.
|
|
31
|
+
|
|
32
|
+
**Do not edit:**
|
|
33
|
+
- `themes-registry.ts` — regenerated by the scaffold/copy-theme/update commands.
|
|
34
|
+
- `amplify/` — backend schema changes can rebuild tables and wipe sandbox data. Get explicit confirmation from the user before touching.
|
|
35
|
+
- `amplify_outputs.json` — regenerated each `npm run sandbox`.
|
|
36
|
+
- `.amplify/` — Amplify CLI working directory.
|
|
37
|
+
- `pnpm-lock.yaml` / `package-lock.json` — let the package manager update these.
|
|
38
|
+
|
|
39
|
+
## Customising a theme (the standard flow)
|
|
40
|
+
|
|
41
|
+
1. Copy an official theme:
|
|
42
|
+
```bash
|
|
43
|
+
npm run copy-theme blog my-blog
|
|
44
|
+
```
|
|
45
|
+
The `my-` prefix marks the copy as user-owned so `npm run update-ampless` leaves it alone. The target name must start with `my-` or the command refuses to run.
|
|
46
|
+
|
|
47
|
+
2. Edit in this priority order:
|
|
48
|
+
- `themes/my-blog/tokens.css` — colours, typography, spacing (CSS custom properties scoped under `[data-theme='my-blog']`).
|
|
49
|
+
- `themes/my-blog/manifest.ts` — declare which fields are exposed in the admin UI (`/admin/sites/<id>/theme`).
|
|
50
|
+
- `themes/my-blog/pages/` — layout / structure (Next.js page modules: feed, sitemap, post templates).
|
|
51
|
+
|
|
52
|
+
3. Activate the theme: open `/admin/sites/<siteId>/theme` and select `my-blog`. Theme switching is a runtime setting — no redeploy needed.
|
|
53
|
+
|
|
54
|
+
4. Verify:
|
|
55
|
+
```bash
|
|
56
|
+
npm run dev # http://localhost:3000
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## MCP server (`@ampless/mcp-server`)
|
|
60
|
+
|
|
61
|
+
Lets agents query and modify post content directly. Tools exposed: `list_posts`, `get_post`, `create_post`, `update_post`, `delete_post`, `upload_media`, `get_schema`.
|
|
62
|
+
|
|
63
|
+
Registration:
|
|
64
|
+
|
|
65
|
+
Add to `.mcp.json` at the project root:
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"ampless": {
|
|
70
|
+
"command": "npx",
|
|
71
|
+
"args": ["-y", "@ampless/mcp-server", "--outputs", "./amplify_outputs.json"],
|
|
72
|
+
"env": {
|
|
73
|
+
"AMPLESS_MCP_EMAIL": "<your-admin-email>",
|
|
74
|
+
"AMPLESS_MCP_PASSWORD": "<your-admin-password>"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Post bodies accept three formats: `markdown`, `html`, or `tiptap` (JSON document).
|
|
82
|
+
|
|
83
|
+
## Verification expectations
|
|
84
|
+
|
|
85
|
+
After any change, run at minimum:
|
|
86
|
+
|
|
87
|
+
- `npm run dev` and load the affected page in a browser. UI changes especially require visual confirmation (use Playwright MCP for screenshots when available).
|
|
88
|
+
- `npm run build` — confirms the production build succeeds.
|
|
89
|
+
- `npm run lint`.
|
|
90
|
+
|
|
91
|
+
Do not report a task complete based solely on type checks if a UI/theme was modified — load it in a browser.
|
|
92
|
+
|
|
93
|
+
## Known constraints
|
|
94
|
+
|
|
95
|
+
- **Sandbox data is ephemeral.** Schema-affecting changes can rebuild the API and tables; treat sandbox content as throw-away. Production data is durable.
|
|
96
|
+
- **One Amplify deployment = one site.** To serve multiple sites on different domains, deploy separate Amplify environments. The schema's `siteId` column is always the literal `"default"` (retained for forward-compat).
|
|
97
|
+
- **The AppSync public API key is shipped in `amplify_outputs.json` and visible to any site visitor.** Treat it as a low-trust credential — its only privilege is reading published posts. Auto-rotated monthly by the `api-key-renewer` Lambda; no manual rotation needed.
|
|
98
|
+
- **The first registered user becomes admin.** Subsequent role changes go through the Cognito console (see RUNBOOK).
|
|
99
|
+
|
|
100
|
+
## See also
|
|
101
|
+
|
|
102
|
+
- `README.md` — day-to-day usage for site owners.
|
|
103
|
+
- `RUNBOOK.md` — occasional ops procedures (key rotation, backup restore, etc.).
|
|
104
|
+
- `themes/<name>/README.md` — per-theme customization details.
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
> English: [README.md](./README.md)
|
|
2
|
+
>
|
|
3
|
+
# {{siteName}}
|
|
4
|
+
|
|
5
|
+
このサイトは [ampless](https://github.com/heavymoons/ampless) で構築されています — AWS Amplify Gen 2(Cognito + DynamoDB + S3 + AppSync + Lambda)上で動くサーバーレス CMS、フロントエンドは Next.js 15。
|
|
6
|
+
|
|
7
|
+
この README は、サイト運営者として日常的に知っておくべき内容をまとめたものです。たまにやる運用手順(API キーのローテーション、バックアップ復元など)は [RUNBOOK.ja.md](./RUNBOOK.ja.md) に置いています。テーマごとのカスタマイズ詳細は `themes/<name>/README.ja.md` を参照してください。
|
|
8
|
+
|
|
9
|
+
このプロジェクトで AI コーディングエージェント(Claude Code, Cursor, Codex など)を使うなら [AGENTS.ja.md](./AGENTS.ja.md) を読ませてください。エージェントが触っていい場所・ダメな場所がそこに書いてあります。
|
|
10
|
+
|
|
11
|
+
## 必要なもの
|
|
12
|
+
|
|
13
|
+
- **Node.js 20+** と **npm**
|
|
14
|
+
- **AWS アカウント**と CLI 認証情報(`aws configure`)— sandbox / 本番ともに実 AWS リソースをデプロイします
|
|
15
|
+
- 本番ホスティング(AWS Amplify Hosting)用の **GitHub アカウント**
|
|
16
|
+
|
|
17
|
+
## コマンド
|
|
18
|
+
|
|
19
|
+
| コマンド | 内容 |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `npm install` | 依存関係をインストール |
|
|
22
|
+
| `npm run sandbox` | 個人用 AWS サンドボックス(Cognito / DynamoDB / S3 など)をプロビジョニング、`amplify_outputs.json` を再生成し、`next dev` を `http://localhost:3000` で起動 |
|
|
23
|
+
| `npm run dev` | Next.js だけを起動(サンドボックスのプロビジョニングはスキップ — 一度 `sandbox` を実行済みなら使える) |
|
|
24
|
+
| `npm run build` | Next.js アプリの本番ビルド(Amplify Hosting のデプロイでも自動実行される) |
|
|
25
|
+
| `npm run start` | ビルド済みアプリをローカルで配信 |
|
|
26
|
+
| `npm run lint` | `next lint` で lint |
|
|
27
|
+
| `npm run update-ampless` | ampless テンプレートの最新ファイルを取り込む(設定やテーマは保持。下記「ampless の更新」参照) |
|
|
28
|
+
| `npm run copy-theme` | 公式テーマを後から追加する |
|
|
29
|
+
|
|
30
|
+
## 初回セットアップ
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install
|
|
34
|
+
npm run sandbox
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
初回 sandbox は 5〜10 分かかります(AWS リソースのプロビジョニング)。`next dev` 起動前に毎回 `amplify_outputs.json` が再生成されます。
|
|
38
|
+
|
|
39
|
+
[http://localhost:3000/login](http://localhost:3000/login) を開き、**Create admin account** をクリック。最初に登録したユーザーが自動的に `ampless-admin` Cognito グループに追加されます。
|
|
40
|
+
|
|
41
|
+
## 管理画面
|
|
42
|
+
|
|
43
|
+
サインイン後、管理画面は `/admin`:
|
|
44
|
+
|
|
45
|
+
| パス | 役割 |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `/admin` | ダッシュボード |
|
|
48
|
+
| `/admin/posts` | 投稿の一覧 / 作成 / 編集(Tiptap、Markdown、生 HTML、または zip アップロードの静的バンドル) |
|
|
49
|
+
| `/admin/media` | 画像 / 動画 / ファイルを S3 にアップロード |
|
|
50
|
+
| `/admin/sites/<siteId>` | サイトレベル設定(名前、URL) |
|
|
51
|
+
| `/admin/sites/<siteId>/theme` | テーマの切り替え + フィールド調整(カラー、フォント、ナビ、ロゴなど) |
|
|
52
|
+
| `/admin/users` | ユーザー一覧と Cognito グループ所属の確認 |
|
|
53
|
+
| `/admin/mcp-tokens` | HTTP MCP エンドポイント用の Bearer トークンを発行 |
|
|
54
|
+
|
|
55
|
+
ユーザーロール(Cognito グループ):
|
|
56
|
+
|
|
57
|
+
- `ampless-admin` — フルアクセス(コンテンツ + 運用 + 破壊的操作)
|
|
58
|
+
- `ampless-editor` — コンテンツの CRUD(破壊的操作はなし)
|
|
59
|
+
- `ampless-reader` — 将来の REST/MCP API クライアント用に予約
|
|
60
|
+
|
|
61
|
+
ロールの付与 / 取り消しは AWS Cognito コンソールで行います — [RUNBOOK.ja.md → ユーザーの昇格 / 降格](./RUNBOOK.ja.md#promote--demote-a-user) を参照。
|
|
62
|
+
|
|
63
|
+
## コンテンツの執筆
|
|
64
|
+
|
|
65
|
+
投稿(Post)が唯一のコンテンツタイプです。各投稿には以下があります:
|
|
66
|
+
|
|
67
|
+
- **Format** — `tiptap`(リッチテキスト)/ `markdown` / `html`(生 HTML、サニタイズなし)/ `static`(HTML/CSS/JS の zip アップロード)
|
|
68
|
+
- **No layout** フラグ(`format: 'html'` のときのみ)— 本文をそのまま出力し、Next.js のレイアウトもテーマのクロームも適用しない。URL は `/<slug>` のままで、ルートが `/_/<slug>` にリダイレクトする
|
|
69
|
+
- **Slug** — 公開 URL
|
|
70
|
+
- **Status** — `draft`(管理者のみ)または `published`
|
|
71
|
+
|
|
72
|
+
詳細リファレンス: [docs/CONTENT.ja.md(GitHub)](https://github.com/heavymoons/ampless/blob/main/docs/CONTENT.ja.md) ([English](https://github.com/heavymoons/ampless/blob/main/docs/CONTENT.md))
|
|
73
|
+
|
|
74
|
+
## テーマ
|
|
75
|
+
|
|
76
|
+
インストール済みのテーマはすべて `themes/<name>/` にバンドルされています。**アクティブな**テーマはサイトごとのランタイム設定 — テーマの切り替えに**再デプロイは不要**です。
|
|
77
|
+
|
|
78
|
+
アクティブテーマの切り替え: `/admin/sites/<siteId>/theme` → インストール済みリストから選択 → 保存。
|
|
79
|
+
|
|
80
|
+
アクティブテーマのカスタマイズ(カラー、フォント、ヘッダー / フッターナビなど): 同じ画面 — 各テーマが固有のカスタマイズフィールドを公開しています。各テーマで何が変えられるかは `themes/<name>/README.ja.md` を参照。
|
|
81
|
+
|
|
82
|
+
このプロジェクトに別の公式テーマを追加する:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm run copy-theme
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
独自テーマを作る場合: 既存テーマをコピーから始める(`cp -R themes/blog themes/your-theme`)→ `manifest.ts`、`tokens.css`、`pages/*.tsx` を編集 → `themes-registry.ts` に追加。フルガイド: [docs/THEMES.ja.md](https://github.com/heavymoons/ampless/blob/main/docs/THEMES.ja.md) ([English](https://github.com/heavymoons/ampless/blob/main/docs/THEMES.md))
|
|
89
|
+
|
|
90
|
+
## プラグイン
|
|
91
|
+
|
|
92
|
+
プラグインは CMS にイベント駆動の副作用(SEO メタデータ、RSS フィード、外部 URL への webhook、OG 画像生成など)を追加する仕組みです。[`cms.config.ts`](./cms.config.ts) で宣言し、投稿の publish / update / delete 時に Lambda 上で実行されます。
|
|
93
|
+
|
|
94
|
+
`cms.config.ts` に書けば有効になる、同梱の公式プラグイン:
|
|
95
|
+
|
|
96
|
+
| パッケージ | 役割 |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `@ampless/plugin-seo` | 投稿ごとの OGP / Twitter / canonical メタデータ + `sitemap.xml` |
|
|
99
|
+
| `@ampless/plugin-rss` | `/feed.xml` の RSS 2.0 フィード |
|
|
100
|
+
| `@ampless/plugin-webhook` | 外部 URL へのイベント POST(HMAC 署名付き) |
|
|
101
|
+
| `@ampless/plugin-og-image` | `/og/<slug>` での動的 OG 画像生成 |
|
|
102
|
+
|
|
103
|
+
プラグインを追加するには: install(`npm i @ampless/plugin-...`)→ `cms.config.ts` で import → `plugins` 配列に追加:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import seoPlugin from '@ampless/plugin-seo'
|
|
107
|
+
import rssPlugin from '@ampless/plugin-rss'
|
|
108
|
+
|
|
109
|
+
export default defineConfig({
|
|
110
|
+
// ...
|
|
111
|
+
plugins: [
|
|
112
|
+
seoPlugin({ twitterSite: '@example' }),
|
|
113
|
+
rssPlugin({ language: 'ja', limit: 20 }),
|
|
114
|
+
],
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
プラグイン変更には再デプロイが必要です(プラグインコードは Lambda バンドルに含まれます)。
|
|
119
|
+
|
|
120
|
+
## 本番デプロイ
|
|
121
|
+
|
|
122
|
+
同梱の [`amplify.yml`](./amplify.yml) が、connect したブランチへの push のたびに `npx ampx pipeline-deploy`(Amplify バックエンド) + `npm run build`(Next.js)を実行します。
|
|
123
|
+
|
|
124
|
+
1. **GitHub(または Amplify Hosting が対応する git ホスト)にこのプロジェクトを push**:
|
|
125
|
+
```bash
|
|
126
|
+
git init && git add . && git commit -m "init"
|
|
127
|
+
git remote add origin <your-repo>
|
|
128
|
+
git push -u origin main
|
|
129
|
+
```
|
|
130
|
+
2. **AWS Amplify Hosting コンソール** → **Create new app** → **Host web app** → リポジトリを連携 → ブランチを選択 → 自動検出されたビルド設定(`amplify.yml` の内容になっているはず)を確認 → デプロイ
|
|
131
|
+
3. 初回デプロイは 10〜20 分。以降は連携ブランチへの push で自動再デプロイ
|
|
132
|
+
|
|
133
|
+
### 環境変数
|
|
134
|
+
|
|
135
|
+
環境ごとの値は **Amplify Hosting コンソール → Hosting → Environment variables** で設定。よく使うもの:
|
|
136
|
+
|
|
137
|
+
| 変数 | 利用箇所 |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `WEBHOOK_SECRET` | `@ampless/plugin-webhook` の HMAC 署名 |
|
|
140
|
+
|
|
141
|
+
env 変数追加 / 変更後は再デプロイをトリガーしてください。
|
|
142
|
+
|
|
143
|
+
### カスタムドメイン
|
|
144
|
+
|
|
145
|
+
Amplify Hosting アプリの **Domain management** からドメインをバインドします — ACM 証明書と DNS レコードは Amplify が自動でプロビジョニングします。詳細手順: [RUNBOOK.ja.md → カスタムドメインを Amplify Hosting に追加](./RUNBOOK.ja.md#adding-a-custom-domain-to-amplify-hosting)
|
|
146
|
+
|
|
147
|
+
## AI 連携(MCP)
|
|
148
|
+
|
|
149
|
+
ampless は MCP(Model Context Protocol)サーバーを同梱しているので、Claude Desktop / Cursor / Claude Code など MCP に対応した AI クライアントから投稿の読み書きができます。
|
|
150
|
+
|
|
151
|
+
- **ローカル / sandbox** — グローバルに 1 度入れる: `npx -y @ampless/mcp-server@alpha` に `amplify_outputs.json` のパスを渡す
|
|
152
|
+
|
|
153
|
+
## ampless の更新
|
|
154
|
+
|
|
155
|
+
ampless は `alpha` dist-tag でリリースしています。新機能を取り込むには:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
npm run update-ampless
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
これは `npx create-ampless@latest upgrade` を実行し、以下を行います:
|
|
162
|
+
|
|
163
|
+
- `package.json` の `@ampless/*` / `ampless` 依存をバージョンアップ
|
|
164
|
+
- 共有テンプレートファイル(admin アプリの土台、amplify バックエンド、lib/、middleware、テーマ)を再同期 — `cms.config.ts`、`theme.*` 管理画面設定、投稿、テーマ manifest 値などのユーザーカスタマイズは保持されます
|
|
165
|
+
- `update-ampless` / `copy-theme` スクリプトのコマンドが変わっていれば更新
|
|
166
|
+
|
|
167
|
+
commit 前に diff を確認できます。
|
|
168
|
+
|
|
169
|
+
## 運用
|
|
170
|
+
|
|
171
|
+
日常以外の運用レシピ — ユーザー昇格、パスワードリセット、バックアップ復元、カスタムドメイン配線、AppSync API キーローテーション — は [RUNBOOK.ja.md](./RUNBOOK.ja.md) にあります。
|
|
172
|
+
|
|
173
|
+
## ライセンス
|
|
174
|
+
|
|
175
|
+
このプロジェクト自身のコードはあなたのものです。ampless 本体は MIT ライセンスです。詳細は [ampless リポジトリ](https://github.com/heavymoons/ampless) を参照。
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
> 日本語版: [README.ja.md](./README.ja.md)
|
|
2
|
+
>
|
|
3
|
+
# {{siteName}}
|
|
4
|
+
|
|
5
|
+
Your site is built with [ampless](https://github.com/heavymoons/ampless) — a serverless CMS that runs on AWS Amplify Gen 2 (Cognito + DynamoDB + S3 + AppSync + Lambda) with a Next.js 15 frontend.
|
|
6
|
+
|
|
7
|
+
This README covers what you, the site owner, need to know day-to-day. Operational recipes (rotating keys, restoring backups, etc.) live in [RUNBOOK.md](./RUNBOOK.md). Per-theme customization details live in `themes/<name>/README.md`.
|
|
8
|
+
|
|
9
|
+
If you use an AI coding agent (Claude Code, Cursor, Codex, etc.) on this project, point it at [AGENTS.md](./AGENTS.md) — that file tells the agent what it can and can't touch.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- **Node.js 20+** and **npm**
|
|
14
|
+
- **AWS account** with CLI credentials (`aws configure`) — the sandbox + production both deploy real AWS resources
|
|
15
|
+
- **GitHub account** for production hosting via AWS Amplify Hosting
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
| Command | What it does |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `npm install` | Install dependencies |
|
|
22
|
+
| `npm run sandbox` | Provision a personal AWS sandbox (Cognito / DynamoDB / S3 / etc.), regenerate `amplify_outputs.json`, then start `next dev` on `http://localhost:3000` |
|
|
23
|
+
| `npm run dev` | Start Next.js only (skip sandbox provisioning — use after `sandbox` has already run once) |
|
|
24
|
+
| `npm run build` | Production build of the Next.js app (also runs as part of Amplify Hosting deploy) |
|
|
25
|
+
| `npm run start` | Serve the production build locally |
|
|
26
|
+
| `npm run lint` | Lint with `next lint` |
|
|
27
|
+
| `npm run update-ampless` | Pull the latest ampless template files into this project, preserving your config and themes (see "Updating ampless" below) |
|
|
28
|
+
| `npm run copy-theme` | Add another official theme to this project after-the-fact |
|
|
29
|
+
|
|
30
|
+
## First time setup
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install
|
|
34
|
+
npm run sandbox
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
First sandbox run takes 5–10 minutes (AWS resource provisioning). `amplify_outputs.json` is regenerated each time before `next dev` starts.
|
|
38
|
+
|
|
39
|
+
Open [http://localhost:3000/login](http://localhost:3000/login) and click **Create admin account**. The first registered user is automatically added to the `ampless-admin` Cognito group.
|
|
40
|
+
|
|
41
|
+
## Admin UI
|
|
42
|
+
|
|
43
|
+
After signing in, the admin lives at `/admin`:
|
|
44
|
+
|
|
45
|
+
| Path | Purpose |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `/admin` | Dashboard |
|
|
48
|
+
| `/admin/posts` | List / create / edit posts (Tiptap editor, Markdown, raw HTML, or zip-uploaded static bundles) |
|
|
49
|
+
| `/admin/media` | Upload images / videos / files to S3 |
|
|
50
|
+
| `/admin/sites/<siteId>` | Site-level settings (name, URL) |
|
|
51
|
+
| `/admin/sites/<siteId>/theme` | Activate a theme + customize its fields (colors, fonts, nav, logo, etc.) |
|
|
52
|
+
| `/admin/users` | View users + Cognito group memberships |
|
|
53
|
+
| `/admin/mcp-tokens` | Issue Bearer tokens for the HTTP MCP endpoint |
|
|
54
|
+
|
|
55
|
+
User roles (Cognito groups):
|
|
56
|
+
|
|
57
|
+
- `ampless-admin` — full access (content + ops + destructive)
|
|
58
|
+
- `ampless-editor` — content CRUD (no destructive ops)
|
|
59
|
+
- `ampless-reader` — reserved for future REST/MCP API consumers
|
|
60
|
+
|
|
61
|
+
Promotion/demotion is done in the AWS Cognito console — see [RUNBOOK.md → Promote / demote a user](./RUNBOOK.md#promote--demote-a-user).
|
|
62
|
+
|
|
63
|
+
## Authoring content
|
|
64
|
+
|
|
65
|
+
Posts are the single content type. Each post has:
|
|
66
|
+
|
|
67
|
+
- **Format** — `tiptap` (rich text) / `markdown` / `html` (raw, no sanitization) / `static` (zip-upload of HTML/CSS/JS)
|
|
68
|
+
- **No layout** flag (`format: 'html'` only) — render the body verbatim with no Next.js layout and no theme chrome. URL stays `/<slug>`; the route redirects to `/_/<slug>`.
|
|
69
|
+
- **Slug** — the public URL
|
|
70
|
+
- **Status** — `draft` (admin only) or `published`
|
|
71
|
+
|
|
72
|
+
Full reference: [docs/CONTENT.md on GitHub](https://github.com/heavymoons/ampless/blob/main/docs/CONTENT.md) ([日本語](https://github.com/heavymoons/ampless/blob/main/docs/CONTENT.ja.md)).
|
|
73
|
+
|
|
74
|
+
## Themes
|
|
75
|
+
|
|
76
|
+
Every installed theme is bundled in this project under `themes/<name>/`. The **active** theme per site is a runtime setting — switching themes does **not** require a redeploy.
|
|
77
|
+
|
|
78
|
+
To switch the active theme: `/admin/sites/<siteId>/theme` → pick from the installed list → save.
|
|
79
|
+
|
|
80
|
+
To customize the active theme (colors, fonts, header / footer nav, etc.): same page — each theme exposes its own customization fields. See `themes/<name>/README.md` for what's customizable per theme.
|
|
81
|
+
|
|
82
|
+
To install another official theme into this project:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm run copy-theme
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
To author your own theme: copy an existing one as a starting point (`cp -R themes/blog themes/your-theme`), edit `manifest.ts`, `tokens.css`, and `pages/*.tsx`, then add it to `themes-registry.ts`. Full guide: [docs/THEMES.md](https://github.com/heavymoons/ampless/blob/main/docs/THEMES.md) ([日本語](https://github.com/heavymoons/ampless/blob/main/docs/THEMES.ja.md)).
|
|
89
|
+
|
|
90
|
+
## Plugins
|
|
91
|
+
|
|
92
|
+
Plugins extend the CMS with event-driven side effects (SEO metadata, RSS feed, webhooks to external URLs, OG image generation, etc.). They're declared in [`cms.config.ts`](./cms.config.ts) and run on Lambda when posts are published / updated / deleted.
|
|
93
|
+
|
|
94
|
+
Bundled and ready to enable in `cms.config.ts`:
|
|
95
|
+
|
|
96
|
+
| Package | Purpose |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `@ampless/plugin-seo` | Per-post OGP / Twitter / canonical metadata + `sitemap.xml` |
|
|
99
|
+
| `@ampless/plugin-rss` | RSS 2.0 feed at `/feed.xml` |
|
|
100
|
+
| `@ampless/plugin-webhook` | POST events to external URLs (HMAC-signed) |
|
|
101
|
+
| `@ampless/plugin-og-image` | Dynamic Open Graph image generation at `/og/<slug>` |
|
|
102
|
+
|
|
103
|
+
To add a plugin: install (`npm i @ampless/plugin-...`), import in `cms.config.ts`, and add to the `plugins` array:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import seoPlugin from '@ampless/plugin-seo'
|
|
107
|
+
import rssPlugin from '@ampless/plugin-rss'
|
|
108
|
+
|
|
109
|
+
export default defineConfig({
|
|
110
|
+
// ...
|
|
111
|
+
plugins: [
|
|
112
|
+
seoPlugin({ twitterSite: '@example' }),
|
|
113
|
+
rssPlugin({ language: 'en', limit: 20 }),
|
|
114
|
+
],
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
A redeploy is required for plugin changes (the plugin code ships in the Lambda bundle).
|
|
119
|
+
|
|
120
|
+
## Deploying to production
|
|
121
|
+
|
|
122
|
+
The shipped [`amplify.yml`](./amplify.yml) runs `npx ampx pipeline-deploy` (Amplify backend) + `npm run build` (Next.js) on every push to the branch you connect.
|
|
123
|
+
|
|
124
|
+
1. **Push this project to GitHub** (or another git host Amplify Hosting supports):
|
|
125
|
+
```bash
|
|
126
|
+
git init && git add . && git commit -m "init"
|
|
127
|
+
git remote add origin <your-repo>
|
|
128
|
+
git push -u origin main
|
|
129
|
+
```
|
|
130
|
+
2. **AWS Amplify Hosting console** → **Create new app** → **Host web app** → connect the repo → pick the branch → review the auto-detected build settings (they should match `amplify.yml`) → deploy.
|
|
131
|
+
3. First deploy takes 10–20 minutes. Subsequent pushes to the connected branch redeploy automatically.
|
|
132
|
+
|
|
133
|
+
### Environment variables
|
|
134
|
+
|
|
135
|
+
Set per-environment values in **Amplify Hosting console → Hosting → Environment variables**. Common ones:
|
|
136
|
+
|
|
137
|
+
| Variable | Used by |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `WEBHOOK_SECRET` | `@ampless/plugin-webhook` HMAC signing |
|
|
140
|
+
|
|
141
|
+
Trigger a redeploy after adding/changing env vars.
|
|
142
|
+
|
|
143
|
+
### Custom domains
|
|
144
|
+
|
|
145
|
+
Bind a domain to your Amplify Hosting app in **Domain management** — Amplify provisions an ACM certificate and DNS records automatically. Full step-by-step: [RUNBOOK.md → Adding a custom domain](./RUNBOOK.md#adding-a-custom-domain-to-amplify-hosting).
|
|
146
|
+
|
|
147
|
+
## AI integration (MCP)
|
|
148
|
+
|
|
149
|
+
ampless ships an MCP (Model Context Protocol) server so Claude Desktop / Cursor / Claude Code / anything that speaks MCP can read and write your posts.
|
|
150
|
+
|
|
151
|
+
- **Local / sandbox** — install once globally: `npx -y @ampless/mcp-server@alpha` with the path to your `amplify_outputs.json`.
|
|
152
|
+
|
|
153
|
+
## Updating ampless
|
|
154
|
+
|
|
155
|
+
ampless releases on the `alpha` dist-tag. To pick up new features:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
npm run update-ampless
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
This runs `npx create-ampless@latest upgrade`, which:
|
|
162
|
+
|
|
163
|
+
- Bumps the `@ampless/*` and `ampless` dependencies in `package.json`
|
|
164
|
+
- Re-syncs the shared template files (admin app shell, amplify backend, lib/, middleware, themes) — your customizations to `cms.config.ts`, `theme.*` admin settings, posts, and theme manifest values are preserved.
|
|
165
|
+
- Updates `update-ampless` and `copy-theme` script entries if their commands change
|
|
166
|
+
|
|
167
|
+
You can review the diff before committing.
|
|
168
|
+
|
|
169
|
+
## Operations
|
|
170
|
+
|
|
171
|
+
Day-to-day operational recipes — user promotion, password reset, backup restore, custom domain wiring, AppSync API key rotation — live in [RUNBOOK.md](./RUNBOOK.md).
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
This project's own code is yours. ampless itself is MIT-licensed; see the [ampless repository](https://github.com/heavymoons/ampless) for details.
|