@c-time/frelio-cli 2.4.0 → 2.5.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.
- package/README.md +18 -72
- package/dist/commands/doctor.js +40 -12
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.js +275 -74
- package/dist/commands/set-domain.d.ts +1 -0
- package/dist/commands/set-domain.js +48 -3
- package/dist/commands/validate-templates.d.ts +12 -0
- package/dist/commands/validate-templates.js +44 -0
- package/dist/core/cloudflare.d.ts +16 -0
- package/dist/core/cloudflare.js +35 -0
- package/dist/core/config-doctor.d.ts +28 -0
- package/dist/core/config-doctor.js +82 -0
- package/dist/core/config.js +12 -3
- package/dist/core/domain.d.ts +6 -0
- package/dist/core/domain.js +19 -1
- package/dist/core/file-delivery.d.ts +53 -0
- package/dist/core/file-delivery.js +119 -0
- package/dist/core/template-refresh.js +2 -0
- package/dist/core/types.d.ts +5 -0
- package/dist/core/validate-templates.d.ts +37 -0
- package/dist/core/validate-templates.js +164 -0
- package/dist/index.js +10 -8
- package/dist/lib/template-renderer.js +6 -0
- package/dist/lib/templates.d.ts +92 -1
- package/dist/lib/templates.js +148 -3
- package/package.json +3 -3
- package/dist/commands/add-staging.d.ts +0 -10
- package/dist/commands/add-staging.js +0 -119
package/README.md
CHANGED
|
@@ -139,27 +139,30 @@ frelio init
|
|
|
139
139
|
#### やること
|
|
140
140
|
|
|
141
141
|
1. **前提チェック** — `gh`, `wrangler`, `git` がインストールされ、ログイン済みか確認
|
|
142
|
-
2. **対話式プロンプト** — リポジトリ名、サイトタイトル、R2
|
|
143
|
-
3. **GitHub
|
|
144
|
-
4.
|
|
145
|
-
5.
|
|
146
|
-
6.
|
|
147
|
-
7.
|
|
148
|
-
8. **
|
|
142
|
+
2. **対話式プロンプト** — リポジトリ名、サイトタイトル、R2 設定などを入力(この時点では OAuth は聞かない)
|
|
143
|
+
3. **GitHub リポジトリ作成** — `gh repo create` でプライベートリポジトリを作成・クローン
|
|
144
|
+
4. **コンテンツリポジトリのスキャフォールド** — GitHub から [`c-time/frelio-content-template`](https://github.com/c-time/frelio-content-template) をダウンロードし、設定値を埋め込んで展開(`frelio-data/`、`scripts/`、`.github/workflows/`、`vite.config.ts` 等)
|
|
145
|
+
5. **CMS Admin バンドルの展開** — 最新リリースから `admin/`(SPA)、`admin-worker/`、`workers/` を配置
|
|
146
|
+
6. **設定ファイル生成** — `admin/config.json`、`wrangler.content.toml`、`wrangler.admin.toml`
|
|
147
|
+
7. **Cloudflare セットアップ(deploy-first / Issue #261)** — R2 バケット作成 + **admin Worker を一度デプロイして公開ホスト(`<admin>.<アカウント>.workers.dev`)を確定**し、`previewUrl` 等の実在 URL を `config.json` に反映(`--admin-host` 指定時はこの自動検出をスキップ)
|
|
148
|
+
8. **GitHub OAuth App の案内** — ホスト確定後に**正確なコールバック URL**(`https://<adminホスト>/api/auth/callback`)を提示 → Client ID / Secret を入力 → `GITHUB_CLIENT_SECRET` を投入し admin Worker を再デプロイ
|
|
149
149
|
9. **ブランチ構造の作成** — `main`、`develop`、`staging` ブランチを作成・プッシュ、デフォルトブランチを `develop` に設定
|
|
150
150
|
|
|
151
|
+
> **Issue #261**: workers.dev の URL は `<ワーカー名>.<アカウント部>.workers.dev`。アカウント部はアカウント固定値のため手入力させず、admin Worker の初回デプロイ出力から自動取得する。これにより OAuth コールバックが init 中に確定でき、独自ドメインは「終盤に `frelio set-domain` で後付け」という役割分担になる。
|
|
152
|
+
|
|
151
153
|
#### プロンプトで聞かれること
|
|
152
154
|
|
|
153
155
|
| 項目 | CLI オプション | 説明 | 例 |
|
|
154
156
|
|------|---------------|------|----|
|
|
155
157
|
| リポジトリ名 | `--content-repo` | `owner/repo` 形式 | `my-org/my-site` |
|
|
156
158
|
| サイトタイトル | `--site-title` | 管理画面に表示される名前 | `My Website` |
|
|
157
|
-
| 本番 URL | `--production-url` | 公開サイトの URL
|
|
158
|
-
|
|
|
159
|
+
| 本番 URL | `--production-url` | 公開サイトの URL(任意・通常は終盤に `set-domain` で設定) | `https://example.com` |
|
|
160
|
+
| ステージング独自ドメイン | `--staging-domain` | ステージングの独自ドメイン(任意・通常は空。空なら workers.dev プレビューを使う) | `staging-abc123.example.com` |
|
|
161
|
+
| 管理画面ホスト | `--admin-host` | 管理画面が配信される公開ホスト(指定すると deploy-first の自動検出をスキップ)。workers.dev でも独自ドメインでも可 | `my-site-admin-1a2b.acme.workers.dev` |
|
|
159
162
|
| R2 バケット名 | `--r2-bucket-name` | ファイルストレージ用バケット | `my-site-files` |
|
|
160
163
|
| R2 公開 URL | `--r2-public-url` | アップロードファイル(R2)の配信元 URL(任意)。R2 のカスタムドメイン推奨、`pub-xxxx.r2.dev` も可。空欄なら後から設定可 | `https://files.example.com` |
|
|
161
164
|
| 管理者 GitHub ユーザー名 | `--owner-username` | 最初の管理者ユーザー | `your-username` |
|
|
162
|
-
| OAuth Client ID | `--client-id` | GitHub OAuth App の Client ID | `Ov23li...` |
|
|
165
|
+
| OAuth Client ID | `--client-id` | GitHub OAuth App の Client ID(対話では**ホスト確定後**に入力) | `Ov23li...` |
|
|
163
166
|
| OAuth Client Secret | `--client-secret` | GitHub OAuth App の Client Secret | `********` |
|
|
164
167
|
|
|
165
168
|
#### オプション
|
|
@@ -173,8 +176,9 @@ frelio init --skip-cloudflare # Cloudflare 操作をスキップ(後から
|
|
|
173
176
|
frelio init \
|
|
174
177
|
--content-repo <owner/repo> # リポジトリ名(必須)
|
|
175
178
|
--site-title <title> # サイトタイトル
|
|
176
|
-
--production-url <url> # 本番 URL
|
|
177
|
-
--staging-domain <domain> #
|
|
179
|
+
--production-url <url> # 本番 URL(任意・通常は後から set-domain)
|
|
180
|
+
--staging-domain <domain> # ステージング独自ドメイン(任意・通常は空)
|
|
181
|
+
--admin-host <host> # 管理画面の公開ホスト(指定で deploy-first 自動検出をスキップ)
|
|
178
182
|
--r2-bucket-name <name> # R2 バケット名
|
|
179
183
|
--r2-public-url <url> # R2 公開 URL
|
|
180
184
|
--owner-username <user> # 管理者 GitHub ユーザー名
|
|
@@ -239,7 +243,7 @@ my-site/
|
|
|
239
243
|
│ ├── content_types/ # UI/Views 設定
|
|
240
244
|
│ ├── metadata/ # content_types.json, _dashboard.json
|
|
241
245
|
│ ├── recipes/ # ビルドレシピ
|
|
242
|
-
│ └── structure/ # users.json
|
|
246
|
+
│ └── structure/ # users.json
|
|
243
247
|
├── scripts/ # SSG ビルドスクリプト (tsx)
|
|
244
248
|
├── .github/workflows/ # GitHub Actions(4ワークフロー)
|
|
245
249
|
├── vite.config.ts # テンプレートアセットビルド(SCSS/TS)
|
|
@@ -254,64 +258,6 @@ my-site/
|
|
|
254
258
|
|
|
255
259
|
---
|
|
256
260
|
|
|
257
|
-
### `frelio add-staging` — ステージング環境の追加
|
|
258
|
-
|
|
259
|
-
カスタムステージング環境(プレビュー用ブランチ)を追加する。プロジェクトのルートディレクトリで実行する。コンテンツ配信 Worker のプレビューエイリアスとして公開されるため、別プロジェクトの作成は不要。
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
cd my-site
|
|
263
|
-
frelio add-staging
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
#### やること
|
|
267
|
-
|
|
268
|
-
1. **前提チェック** — `git`, `wrangler` がインストール済みか確認
|
|
269
|
-
2. **対話式プロンプト** — ステージング名、Worker 名、カスタムドメインを入力
|
|
270
|
-
3. **Git ブランチ作成** — `develop` から `staging-{name}` ブランチを作成・プッシュ
|
|
271
|
-
4. **ワークフロー確認** — `build-staging.yml` のブランチリスト(`staging-*`)に対応済みか確認、未対応なら案内を表示
|
|
272
|
-
|
|
273
|
-
#### プロンプトで聞かれること
|
|
274
|
-
|
|
275
|
-
| 項目 | CLI オプション | 説明 | 例 |
|
|
276
|
-
|------|---------------|------|----|
|
|
277
|
-
| ステージング名 | `--name` | ブランチ名に使われる識別子 | `design`, `alice` |
|
|
278
|
-
| Worker 名 | `--pages-project` | コンテンツ配信 Worker 名 | `my-site` |
|
|
279
|
-
| カスタムドメイン | `--domain` | 任意。空欄ならプレビューエイリアス `staging-{name}-<worker>.<subdomain>.workers.dev` | `staging-design.example.com` |
|
|
280
|
-
|
|
281
|
-
#### オプション
|
|
282
|
-
|
|
283
|
-
```bash
|
|
284
|
-
frelio add-staging --name design # 名前を事前指定
|
|
285
|
-
frelio add-staging --skip-cloudflare # Cloudflare 関連の確認をスキップ
|
|
286
|
-
frelio add-staging --pages-project <name> # コンテンツ配信 Worker 名を指定
|
|
287
|
-
frelio add-staging --domain <domain> # カスタムドメインを指定
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
#### 非対話モード(AI エージェント / CI 向け)
|
|
291
|
-
|
|
292
|
-
`--name` を指定するとプロンプトなしで実行される。`--pages-project` と `--domain` は省略するとデフォルト値が自動算出される。
|
|
293
|
-
|
|
294
|
-
```bash
|
|
295
|
-
# 最小構成(name のみ、他はデフォルト算出)
|
|
296
|
-
frelio add-staging --name preview1
|
|
297
|
-
|
|
298
|
-
# 全パラメータ指定
|
|
299
|
-
frelio add-staging \
|
|
300
|
-
--name preview1 \
|
|
301
|
-
--pages-project my-site-staging-preview1 \
|
|
302
|
-
--domain preview1-abc123.example.com
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
#### 完了後の手動作業
|
|
306
|
-
|
|
307
|
-
| 作業 | 必須 |
|
|
308
|
-
|------|:----:|
|
|
309
|
-
| カスタムドメインの設定 | - |
|
|
310
|
-
| Cloudflare Access でアクセス制限 | 推奨 |
|
|
311
|
-
| CMS 管理画面の `/staging` ページでブランチを登録 | ○ |
|
|
312
|
-
|
|
313
|
-
---
|
|
314
|
-
|
|
315
261
|
### `frelio update` — CMS Admin の更新
|
|
316
262
|
|
|
317
263
|
CMS Admin バンドルを最新バージョン(または指定バージョン)に更新する。
|
|
@@ -622,7 +568,7 @@ Cloudflare Access は 50 ユーザーまで無料。
|
|
|
622
568
|
|
|
623
569
|
## GitHub OAuth App の作成手順
|
|
624
570
|
|
|
625
|
-
`frelio init`
|
|
571
|
+
`frelio init` は管理画面 Worker を一度デプロイしてホストを確定した後に、**正確なコールバック URL**(`https://<adminホスト>/api/auth/callback`)を提示する(Issue #261)。その値をそのまま貼れば下記の手入力は不要。事前に作成しておく場合は以下の手順で作る(ホストが分かっていれば `frelio init --admin-host <host>` で init 中にも正確な URL が提示される)。
|
|
626
572
|
|
|
627
573
|
1. [GitHub Developer Settings](https://github.com/settings/developers) にアクセス
|
|
628
574
|
2. **OAuth Apps** → **New OAuth App**
|
package/dist/commands/doctor.js
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* マイグレーション定義(#84)を読み、カレントプロジェクトをスキャンして
|
|
5
5
|
* 期限付き廃止や未適用のテンプレ更新を検出し、直し方を提示する。
|
|
6
6
|
*/
|
|
7
|
-
import { log, logSuccess, logError } from '../lib/shell.js';
|
|
7
|
+
import { log, logSuccess, logError, logWarning } from '../lib/shell.js';
|
|
8
8
|
import { runDoctor, daysUntil } from '../core/doctor.js';
|
|
9
|
+
import { checkConfigUrls } from '../core/config-doctor.js';
|
|
9
10
|
const SEVERITY_ORDER = ['critical', 'warning', 'info'];
|
|
10
11
|
const SEVERITY_LABEL = {
|
|
11
12
|
critical: '🔴 重大',
|
|
@@ -50,22 +51,49 @@ export async function doctorCommand(options) {
|
|
|
50
51
|
process.exit(1);
|
|
51
52
|
}
|
|
52
53
|
const { findings, scannedFileCount, actionable } = result.data;
|
|
54
|
+
// --- マイグレーション診断 ---
|
|
53
55
|
if (findings.length === 0) {
|
|
54
|
-
logSuccess(
|
|
55
|
-
log('');
|
|
56
|
-
return;
|
|
56
|
+
logSuccess(`マイグレーションの問題は見つかりませんでした(${scannedFileCount} ファイルを確認)`);
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
SEVERITY_ORDER.indexOf(
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
else {
|
|
59
|
+
// 重大度順に表示
|
|
60
|
+
const sorted = [...findings].sort((a, b) => SEVERITY_ORDER.indexOf(a.migration.severity) -
|
|
61
|
+
SEVERITY_ORDER.indexOf(b.migration.severity));
|
|
62
|
+
for (const f of sorted) {
|
|
63
|
+
printFinding(f);
|
|
64
|
+
}
|
|
65
|
+
log('');
|
|
66
|
+
log(` ${findings.length} 件の指摘が見つかりました(${scannedFileCount} ファイルを確認)。`);
|
|
63
67
|
}
|
|
64
68
|
log('');
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
// --- 設定 URL の診断(Issue #261: previewUrl の未解決/CI 実デプロイ先との不一致など)---
|
|
70
|
+
const configResult = checkConfigUrls(projectDir);
|
|
71
|
+
let configActionable = false;
|
|
72
|
+
if (configResult.success && configResult.data.configFound) {
|
|
73
|
+
const configFindings = configResult.data.findings;
|
|
74
|
+
configActionable = configResult.data.actionable;
|
|
75
|
+
log('🔧 設定 URL の検査(admin/config.json):');
|
|
76
|
+
if (configFindings.length === 0) {
|
|
77
|
+
logSuccess('設定 URL に問題はありません');
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
for (const f of configFindings)
|
|
81
|
+
printConfigFinding(f);
|
|
82
|
+
}
|
|
83
|
+
log('');
|
|
84
|
+
}
|
|
67
85
|
// --ci 指定時のみ、対応が必要な指摘があれば非ゼロで終了する
|
|
68
|
-
if (options.ci && actionable) {
|
|
86
|
+
if (options.ci && (actionable || configActionable)) {
|
|
69
87
|
process.exit(1);
|
|
70
88
|
}
|
|
71
89
|
}
|
|
90
|
+
function printConfigFinding(finding) {
|
|
91
|
+
const label = finding.severity === 'warning' ? '🟡 警告' : 'ℹ️ 情報';
|
|
92
|
+
if (finding.severity === 'warning') {
|
|
93
|
+
logWarning(` ${label} ${finding.title}(${finding.field})`);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
log(` ${label} ${finding.title}(${finding.field})`);
|
|
97
|
+
}
|
|
98
|
+
log(` ${finding.detail}`);
|
|
99
|
+
}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -11,6 +11,13 @@ type InitOptions = {
|
|
|
11
11
|
siteTitle?: string;
|
|
12
12
|
productionUrl?: string;
|
|
13
13
|
stagingDomain?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 管理画面 Worker が配信される公開ホスト(Issue #261)。
|
|
16
|
+
* 例: `repo-admin-xxxx.acme.workers.dev` / `admin.example.com`。
|
|
17
|
+
* 指定すると deploy-first の自動検出をスキップし、この値で OAuth コールバック等を確定する。
|
|
18
|
+
* 未指定なら init が admin Worker を一度デプロイして自動検出する。
|
|
19
|
+
*/
|
|
20
|
+
adminHost?: string;
|
|
14
21
|
r2BucketName?: string;
|
|
15
22
|
r2PublicUrl?: string;
|
|
16
23
|
ownerUsername?: string;
|