@c-time/frelio-cli 1.7.0 → 2.0.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.
Files changed (42) hide show
  1. package/README.md +60 -97
  2. package/dist/commands/add-staging.js +8 -8
  3. package/dist/commands/bake.d.ts +14 -0
  4. package/dist/commands/bake.js +59 -0
  5. package/dist/commands/init.d.ts +1 -4
  6. package/dist/commands/init.js +37 -108
  7. package/dist/commands/set-domain.js +1 -1
  8. package/dist/commands/set-mode.js +1 -6
  9. package/dist/commands/update.d.ts +2 -2
  10. package/dist/commands/update.js +3 -8
  11. package/dist/core/__fixtures__/template/worker/index.d.ts +4 -0
  12. package/dist/core/__fixtures__/template/worker/index.js +6 -0
  13. package/dist/core/bake.d.ts +39 -0
  14. package/dist/core/bake.js +104 -0
  15. package/dist/core/bundle.js +14 -12
  16. package/dist/core/cloudflare.d.ts +26 -11
  17. package/dist/core/cloudflare.js +28 -30
  18. package/dist/core/config.js +25 -6
  19. package/dist/core/file-generators.d.ts +16 -13
  20. package/dist/core/file-generators.js +34 -52
  21. package/dist/core/index.d.ts +2 -3
  22. package/dist/core/index.js +2 -4
  23. package/dist/core/migrations/pages-to-workers-issue184.d.ts +18 -0
  24. package/dist/core/migrations/pages-to-workers-issue184.js +70 -0
  25. package/dist/core/migrations/registry.js +8 -1
  26. package/dist/core/site-mode.d.ts +5 -6
  27. package/dist/core/site-mode.js +5 -6
  28. package/dist/core/status.js +1 -2
  29. package/dist/core/template-refresh.d.ts +8 -2
  30. package/dist/core/template-refresh.js +63 -22
  31. package/dist/core/types.d.ts +0 -2
  32. package/dist/index.js +9 -4
  33. package/dist/lib/npm-registry.d.ts +4 -4
  34. package/dist/lib/npm-registry.js +4 -4
  35. package/dist/lib/resource-links.d.ts +1 -1
  36. package/dist/lib/resource-links.js +4 -4
  37. package/dist/lib/template-renderer.js +3 -6
  38. package/dist/lib/templates.d.ts +33 -57
  39. package/dist/lib/templates.js +82 -579
  40. package/package.json +3 -1
  41. package/dist/core/terraform.d.ts +0 -7
  42. package/dist/core/terraform.js +0 -47
@@ -6,8 +6,14 @@
6
6
  *
7
7
  * - ワークフロー(.github/)は GitHub のテンプレートリポジトリから取得して .hbs を描画する。
8
8
  * (init と同じ取得経路。`fetchTemplate` を共有)
9
- * - wrangler.toml / functions/storage / _redirects / _routes.json は config から決定的に生成する
9
+ * - ルート AI 文書(AGENTS.md / CLAUDE.md)も同テンプレートから verbatim 配信する(#176)。
10
+ * init でのみ配置されていたため、#91 以前に作られた既存プロジェクトへ update で届ける。
11
+ * - wrangler.content.toml / wrangler.admin.toml / worker/site-mode.ts は config から決定的に生成する
10
12
  * (lib/templates.ts の生成関数を共有。set-domain と同一の正本)
13
+ * - worker/index.ts(コンテンツ配信 Worker 本体)はテンプレートから verbatim 配信する(Issue #189)。
14
+ * init scaffold でのみ配置され update では届かず、Pages からの移行時に
15
+ * wrangler.content.toml の main が指す本体を欠く問題があったため、'wrangler' ターゲットで配る
16
+ * (テンプレ取得済みのときのみ。worker/site-mode.ts と対になる静的ハンドラ)。
11
17
  *
12
18
  * ユーザー改変を保護するため、ファイルを2種類に分けて扱う(Issue #150):
13
19
  * - 保護設定ファイル(_redirects / wrangler.toml / workers/file-upload/wrangler.toml):
@@ -23,16 +29,24 @@ import path from 'node:path';
23
29
  import { ok, fail } from './types.js';
24
30
  import { fetchTemplate, cleanupTemplate } from './template-scaffold.js';
25
31
  import { renderTemplate, projectConfigToVars } from '../lib/template-renderer.js';
26
- import { generateWranglerToml, generateWorkerWranglerToml, generateRedirects, generateRoutesJson, generatePublicRoutesJson, generateStorageFunction, generateGateMiddleware, } from '../lib/templates.js';
27
- const DEFAULT_TARGETS = ['workflows', 'wrangler', 'functions', 'routing'];
32
+ import { generateWorkerWranglerToml, generateContentWorkerWranglerToml, generateAdminWorkerWranglerToml, generateContentWorkerSiteMode, } from '../lib/templates.js';
33
+ const DEFAULT_TARGETS = ['workflows', 'docs', 'wrangler', 'functions', 'routing'];
34
+ /**
35
+ * ルート直下の AI コーディングアシスタント向け文書(#176)。
36
+ * `init` でのみ配置され `update` では従来配信されなかったため、#91 以前に作られた
37
+ * 既存プロジェクトには AGENTS.md / CLAUDE.md が無い。これらを update でも届ける。
38
+ * (`.github/copilot-instructions.md` は 'workflows' ターゲットで配信済み)
39
+ */
40
+ const ROOT_DOC_FILES = ['AGENTS.md', 'CLAUDE.md'];
28
41
  /**
29
42
  * 保護対象の設定ファイル(Issue #150)。
30
43
  * ユーザーが恒常的にカスタムを足す前提のファイルは、既定では上書きせず保持する
31
44
  * (config.json と同様)。--force 指定時のみ *.frelio-bak を作って上書きする。
32
45
  */
33
46
  const PROTECTED_CONFIG = new Set([
34
- '_redirects',
35
- 'wrangler.toml',
47
+ // Issue #184: Workers(Static Assets) の wrangler 設定(content / admin)。ユーザー編集を保持。
48
+ 'wrangler.content.toml',
49
+ 'wrangler.admin.toml',
36
50
  'workers/file-upload/wrangler.toml',
37
51
  // database_id を含み init 時に一度だけ生成するため update では保持する
38
52
  'workers/contact/wrangler.toml',
@@ -71,33 +85,52 @@ function planWorkflows(templateDir, config) {
71
85
  }
72
86
  return planned;
73
87
  }
88
+ /**
89
+ * テンプレートから コンテンツ配信 Worker 本体(worker/index.ts)の配信計画を作る(Issue #189)。
90
+ * 静的ファイルなので verbatim でコピーする。テンプレに存在しなければ何もしない。
91
+ */
92
+ function planContentWorkerSource(templateDir) {
93
+ const src = path.join(templateDir, 'worker', 'index.ts');
94
+ if (!fs.existsSync(src))
95
+ return [];
96
+ return [{ relPath: 'worker/index.ts', content: fs.readFileSync(src, 'utf-8') }];
97
+ }
98
+ /** テンプレートのルート直下から AI 文書(AGENTS.md / CLAUDE.md)の生成計画を作る */
99
+ function planRootDocs(templateDir) {
100
+ const planned = [];
101
+ for (const name of ROOT_DOC_FILES) {
102
+ const src = path.join(templateDir, name);
103
+ if (!fs.existsSync(src))
104
+ continue;
105
+ planned.push({ relPath: name, content: fs.readFileSync(src, 'utf-8') });
106
+ }
107
+ return planned;
108
+ }
74
109
  /** config から決定的に生成するファイル群の計画を作る */
75
110
  function planGenerated(config, targets) {
76
111
  const planned = [];
77
112
  if (targets.includes('wrangler')) {
78
- planned.push({ relPath: 'wrangler.toml', content: generateWranglerToml(config) });
113
+ // Issue #184: Workers(Static Assets) 構成。content/admin の wrangler 設定 + file-upload。
79
114
  planned.push({
80
- relPath: 'workers/file-upload/wrangler.toml',
81
- content: generateWorkerWranglerToml(config),
115
+ relPath: 'wrangler.content.toml',
116
+ content: generateContentWorkerWranglerToml(config),
82
117
  });
83
- }
84
- if (targets.includes('functions')) {
85
118
  planned.push({
86
- relPath: 'functions/storage/[[path]].ts',
87
- content: generateStorageFunction(),
119
+ relPath: 'wrangler.admin.toml',
120
+ content: generateAdminWorkerWranglerToml(config),
88
121
  });
89
- // 本番ゲート middleware(Issue #93)
90
122
  planned.push({
91
- relPath: 'functions/_middleware.ts',
92
- content: generateGateMiddleware(),
123
+ relPath: 'workers/file-upload/wrangler.toml',
124
+ content: generateWorkerWranglerToml(config),
125
+ });
126
+ // コンテンツ配信 Worker の siteMode 焼き込み(旧 functions/_middleware.ts の代替)
127
+ planned.push({
128
+ relPath: 'worker/site-mode.ts',
129
+ content: generateContentWorkerSiteMode(config),
93
130
  });
94
131
  }
95
- if (targets.includes('routing')) {
96
- planned.push({ relPath: '_redirects', content: generateRedirects() });
97
- planned.push({ relPath: '_routes.json', content: generateRoutesJson() });
98
- // コンテンツ配信側 _routes.json(include /* で全リクエストをゲート経由に / Issue #93)
99
- planned.push({ relPath: 'public/_routes.json', content: generatePublicRoutesJson() });
100
- }
132
+ // 'functions' / 'routing' ターゲットは旧 Cloudflare Pages 資産(functions/・_redirects・
133
+ // _routes.json)向け。Issue #184 の Workers 移行で廃止(後方互換のため enum 値は残置・no-op)。
101
134
  return planned;
102
135
  }
103
136
  /** 1ファイルを競合モードに従って適用する */
@@ -152,7 +185,7 @@ export async function refreshTemplates(projectDir, config, opts = {}) {
152
185
  backedUp: [],
153
186
  preserved: [],
154
187
  };
155
- const needsTemplate = targets.includes('workflows');
188
+ const needsTemplate = targets.includes('workflows') || targets.includes('docs');
156
189
  let templateDir = opts.templateDir ?? null;
157
190
  let ownTemplate = false;
158
191
  try {
@@ -169,6 +202,14 @@ export async function refreshTemplates(projectDir, config, opts = {}) {
169
202
  if (targets.includes('workflows') && templateDir) {
170
203
  planned.push(...planWorkflows(templateDir, config));
171
204
  }
205
+ if (targets.includes('docs') && templateDir) {
206
+ planned.push(...planRootDocs(templateDir));
207
+ }
208
+ // worker/index.ts(コンテンツ配信 Worker 本体)はテンプレ取得済みのときのみ配る(Issue #189)。
209
+ // テンプレ未取得(オフラインの wrangler 単独再生成)では従来どおり site-mode/wrangler のみ生成する。
210
+ if (targets.includes('wrangler') && templateDir) {
211
+ planned.push(...planContentWorkerSource(templateDir));
212
+ }
172
213
  planned.push(...planGenerated(config, targets));
173
214
  for (const file of planned) {
174
215
  applyFile(projectDir, file, mode, result, force);
@@ -29,7 +29,6 @@ export type ProjectStatus = {
29
29
  hasConfigJson: boolean;
30
30
  hasWranglerToml: boolean;
31
31
  hasWorkflows: boolean;
32
- hasTerraform: boolean;
33
32
  config: ProjectConfig | null;
34
33
  branches: string[];
35
34
  remoteUrl: string | null;
@@ -45,7 +44,6 @@ export type BuildConfigParams = {
45
44
  r2BucketName?: string;
46
45
  r2PublicUrl?: string;
47
46
  ownerUsername?: string;
48
- cloudflareAccountId?: string;
49
47
  /** 保存タイムゾーン(ISO 8601 オフセット表記、例 "+09:00")。issue #92 */
50
48
  saveTimezone?: string;
51
49
  /**
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import { setDomainCommand } from './commands/set-domain.js';
10
10
  import { setModeCommand } from './commands/set-mode.js';
11
11
  import { doctorCommand } from './commands/doctor.js';
12
12
  import { fleetCommand } from './commands/fleet.js';
13
+ import { bakeCommand } from './commands/bake.js';
13
14
  import { maybeNotifyUpdate } from './core/version-check.js';
14
15
  // バージョンは package.json から読む(ハードコードしない)
15
16
  const pkg = JSON.parse(readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf-8'));
@@ -22,8 +23,7 @@ program
22
23
  .command('init')
23
24
  .description('Initialize a new Frelio CMS project (creates repo, deploys admin, sets up R2)')
24
25
  .option('--skip-github', 'Skip GitHub repository creation')
25
- .option('--skip-cloudflare', 'Skip Cloudflare setup (R2, Pages)')
26
- .option('--terraform', 'Generate Terraform files instead of running wrangler commands')
26
+ .option('--skip-cloudflare', 'Skip Cloudflare setup (R2 bucket, Worker secrets)')
27
27
  .option('--content-repo <repo>', 'Repository name (owner/repo)')
28
28
  .option('--site-title <title>', 'Site title')
29
29
  .option('--production-url <url>', 'Production URL')
@@ -33,8 +33,6 @@ program
33
33
  .option('--owner-username <user>', 'Admin GitHub username')
34
34
  .option('--client-id <id>', 'GitHub OAuth Client ID')
35
35
  .option('--client-secret <secret>', 'GitHub OAuth Client Secret')
36
- .option('--cloudflare-account-id <id>', 'Cloudflare Account ID(デプロイ管理機能 / Issue #27)')
37
- .option('--cloudflare-api-token <token>', 'Cloudflare API Token(Pages:Edit・デプロイ一覧/削除に使用)')
38
36
  .option('--no-random-suffix', 'Pages プロジェクト名にランダム hex サフィックスを付けない(従来の単純名 <repo> / <repo>-admin を使う)')
39
37
  .action(initCommand);
40
38
  program
@@ -77,6 +75,13 @@ program
77
75
  .command('set-mode <mode>')
78
76
  .description('Set the production gate mode (live | prelaunch | maintenance | closed) and regenerate config + edge middleware (#93)')
79
77
  .action(setModeCommand);
78
+ program
79
+ .command('bake')
80
+ .description('Bake shared chrome (data-gen-include) + real sample data (data-gen-repeat) into page templates so they open standalone in a browser (#168)')
81
+ .option('--dry-run', 'Show results without writing back to templates')
82
+ .option('--pick <strategy>', 'Representative data for detail templates: latest | first', 'latest')
83
+ .option('--check', 'Verify bake is up to date (CI); exit non-zero on drift')
84
+ .action(bakeCommand);
80
85
  async function main() {
81
86
  await program.parseAsync();
82
87
  // コマンド完了後に最新版チェック(best-effort、本処理には影響しない)
@@ -25,14 +25,14 @@ export declare function downloadTarball(release: Release, destDir: string): Prom
25
25
  *
26
26
  * npm tarball は `package/` ディレクトリに展開される。
27
27
  * 中身は:
28
- * package/dist/ — SPA (index.html, assets/) + bundled functions (functions/)
28
+ * package/dist/ — SPA (index.html, assets/) + bundled admin worker (worker/)
29
29
  * package/workers/ — Worker ソース
30
30
  */
31
31
  export declare function extractNpmTarball(tarPath: string, tmpDir: string): Promise<{
32
- /** SPA ファイル (functions/ を除く dist/ の中身) */
32
+ /** SPA ファイル (worker/ を除く dist/ の中身) */
33
33
  adminDir: string;
34
- /** バンドル済み Pages Functions */
35
- functionsDir: string;
34
+ /** バンドル済み 管理画面 Worker(Issue #184 Phase 2: admin-worker/index.js として配置) */
35
+ adminWorkerDir: string;
36
36
  /** Worker ソース */
37
37
  workersDir: string;
38
38
  }>;
@@ -75,17 +75,17 @@ export async function downloadTarball(release, destDir) {
75
75
  *
76
76
  * npm tarball は `package/` ディレクトリに展開される。
77
77
  * 中身は:
78
- * package/dist/ — SPA (index.html, assets/) + bundled functions (functions/)
78
+ * package/dist/ — SPA (index.html, assets/) + bundled admin worker (worker/)
79
79
  * package/workers/ — Worker ソース
80
80
  */
81
81
  export async function extractNpmTarball(tarPath, tmpDir) {
82
82
  const { extract } = await import('tar');
83
83
  await extract({ file: tarPath, cwd: tmpDir });
84
84
  return {
85
- /** SPA ファイル (functions/ を除く dist/ の中身) */
85
+ /** SPA ファイル (worker/ を除く dist/ の中身) */
86
86
  adminDir: path.join(tmpDir, 'package', 'dist'),
87
- /** バンドル済み Pages Functions */
88
- functionsDir: path.join(tmpDir, 'package', 'dist', 'functions'),
87
+ /** バンドル済み 管理画面 Worker(Issue #184 Phase 2: admin-worker/index.js として配置) */
88
+ adminWorkerDir: path.join(tmpDir, 'package', 'dist', 'worker'),
89
89
  /** Worker ソース */
90
90
  workersDir: path.join(tmpDir, 'package', 'workers'),
91
91
  };
@@ -16,7 +16,7 @@ export type ResourceLinkSection = {
16
16
  export type ResourceLinkOptions = {
17
17
  /** GitHub リポジトリを作成したか(--skip-github で false) */
18
18
  github: boolean;
19
- /** Cloudflare リソースを wrangler で作成したか(--skip-cloudflare / --terraform で false) */
19
+ /** Cloudflare リソースを wrangler で作成したか(--skip-cloudflare で false) */
20
20
  cloudflare: boolean;
21
21
  };
22
22
  /**
@@ -32,12 +32,12 @@ export function buildResourceLinks(config, options) {
32
32
  title: 'Cloudflare',
33
33
  links: [
34
34
  {
35
- label: `コンテンツ配信 Pages (${config.pagesProjectName})`,
36
- url: cloudflareDashUrl(`/pages/view/${config.pagesProjectName}`),
35
+ label: `コンテンツ配信 Worker (${config.contentWorkerName})`,
36
+ url: cloudflareDashUrl(`/workers/services/view/${config.contentWorkerName}/production`),
37
37
  },
38
38
  {
39
- label: `管理画面 Pages (${config.adminPagesProjectName})`,
40
- url: cloudflareDashUrl(`/pages/view/${config.adminPagesProjectName}`),
39
+ label: `管理画面 Worker (${config.adminWorkerName})`,
40
+ url: cloudflareDashUrl(`/workers/services/view/${config.adminWorkerName}/production`),
41
41
  },
42
42
  {
43
43
  label: `R2 バケット (${config.r2BucketName})`,
@@ -4,7 +4,7 @@
4
4
  * {{variable}} 形式のプレースホルダーを値に置換する。
5
5
  * GitHub Actions の ${{ expression }} とは衝突しない。
6
6
  */
7
- import { buildAllowedOrigins, resolveSiteMode, deriveCanonicalHost, deriveContentPagesDev, } from './templates.js';
7
+ import { buildAllowedOrigins, resolveSiteMode, } from './templates.js';
8
8
  /**
9
9
  * テンプレート文字列内の {{variable}} を置換する
10
10
  */
@@ -29,17 +29,14 @@ export function projectConfigToVars(config) {
29
29
  // お問い合わせワーカー(frelio-contact)の URL。初期は空(任意機能)。
30
30
  // 公開後に CMS「基本設定」で設定する。
31
31
  contactApiUrl: '',
32
- pagesProjectName: config.pagesProjectName,
33
- adminPagesProjectName: config.adminPagesProjectName,
32
+ contentWorkerName: config.contentWorkerName,
33
+ adminWorkerName: config.adminWorkerName,
34
34
  r2BucketName: config.r2BucketName,
35
35
  r2PublicUrl: config.r2PublicUrl,
36
36
  ownerUsername: config.ownerUsername,
37
37
  allowedOrigins: buildAllowedOrigins(config),
38
- cloudflareAccountId: config.cloudflareAccountId ?? '',
39
38
  saveTimezone: config.saveTimezone || '+09:00',
40
39
  // 本番ゲート(Issue #93)
41
40
  siteMode: resolveSiteMode(config),
42
- canonicalHost: deriveCanonicalHost(config),
43
- contentPagesDev: deriveContentPagesDev(config),
44
41
  };
45
42
  }
@@ -14,16 +14,17 @@ export type ProjectConfig = {
14
14
  templatePreviewBaseUrl?: string;
15
15
  r2BucketName: string;
16
16
  r2PublicUrl: string;
17
- pagesProjectName: string;
18
- adminPagesProjectName: string;
17
+ /** コンテンツ配信 Worker 名(旧称 pagesProjectName)。 */
18
+ contentWorkerName: string;
19
+ /** 管理画面 Worker 名(旧称 adminPagesProjectName)。 */
20
+ adminWorkerName: string;
19
21
  ownerUsername: string;
20
22
  stagingDomain: string;
21
- cloudflareAccountId: string;
22
23
  /** 保存タイムゾーン(ISO 8601 オフセット表記、例 "+09:00")。issue #92 */
23
24
  saveTimezone: string;
24
25
  /**
25
- * 本番ゲートのサイト公開状態(Issue #93)。未指定は 'live'(通常配信)。
26
- * コンテンツ配信の functions/_middleware.ts がエッジで参照する。
26
+ * サイト公開状態。未指定は 'live'(通常配信)。
27
+ * コンテンツ配信 Worker の worker/site-mode.ts に焼き込まれる。
27
28
  */
28
29
  siteMode?: SiteMode;
29
30
  };
@@ -32,31 +33,27 @@ export declare const SITE_MODES: readonly ["live", "prelaunch", "maintenance", "
32
33
  export type SiteMode = (typeof SITE_MODES)[number];
33
34
  /** config.siteMode を正規化する(未知値・未指定は 'live') */
34
35
  export declare function resolveSiteMode(config: ProjectConfig): SiteMode;
35
- /** productionUrl から正規化先ホスト(独自ドメイン)を導出する。無効/空なら空文字。 */
36
- export declare function deriveCanonicalHost(config: ProjectConfig): string;
37
- /** コンテンツ配信 Pages の本番 pages.dev ホストを導出する(例: mysite.pages.dev)。 */
38
- export declare function deriveContentPagesDev(config: ProjectConfig): string;
39
36
  /**
40
37
  * ランダムな8文字のハッシュを生成(URL推測を困難にする)
41
38
  */
42
39
  export declare function generateHash(): string;
43
40
  /**
44
41
  * ランダムな8桁の16進サフィックスを生成(4バイト → hex)。
45
- * Pages プロジェクト名の世界的な衝突(Cloudflare の自動 `-mg1` 等)を避け、
46
- * `<project>.pages.dev` のプレビュー URL を推測困難にする(Issue #138)。
42
+ * Worker 名の世界的な衝突(Cloudflare の自動サフィックス等)を避け、
43
+ * `<worker>.workers.dev` のプレビュー URL を推測困難にする(Issue #138)。
47
44
  */
48
45
  export declare function generateHexSuffix(): string;
49
46
  /**
50
- * Cloudflare Pages プロジェクト名(content 用・admin 用)を導出する(Issue #138)。
47
+ * Worker 名(content 用・admin 用)を導出する(Issue #138)。
51
48
  * randomSuffix=true なら content/admin それぞれに**別々の** hex サフィックスを付ける
52
49
  * (片方の名前が露出しても、もう片方を推測されないようにする)。
53
50
  *
54
- * 例: ("website", true) → { pagesProjectName: "website-1a2b3c4d",
55
- * adminPagesProjectName: "website-admin-e5f6a7b8" }
51
+ * 例: ("website", true) → { contentWorkerName: "website-1a2b3c4d",
52
+ * adminWorkerName: "website-admin-e5f6a7b8" }
56
53
  */
57
- export declare function buildPagesProjectNames(repoName: string, randomSuffix: boolean): {
58
- pagesProjectName: string;
59
- adminPagesProjectName: string;
54
+ export declare function buildWorkerNames(repoName: string, randomSuffix: boolean): {
55
+ contentWorkerName: string;
56
+ adminWorkerName: string;
60
57
  };
61
58
  /**
62
59
  * productionUrl からステージング用の推測困難なカスタムサブドメインを生成する。
@@ -64,8 +61,7 @@ export declare function buildPagesProjectNames(repoName: string, randomSuffix: b
64
61
  *
65
62
  * productionUrl が無い/無効な場合は空文字を返す(カスタムドメイン無し)。
66
63
  * その場合プレビューは GitHub Actions の wrangler デプロイが生成する
67
- * ブランチエイリアス `staging.<project>.pages.dev` で運用する。
68
- * `*.pages.dev` の任意サブドメインは実在しないため、ここでは生成しない。
64
+ * プレビューエイリアス `<branch>-<worker>.<subdomain>.workers.dev` で運用する。
69
65
  */
70
66
  export declare function generateStagingDomain(productionUrl: string): string;
71
67
  /**
@@ -80,24 +76,9 @@ export declare function rehostStagingDomain(existingStagingDomain: string, newPr
80
76
  export declare function generateConfigJson(config: ProjectConfig): string;
81
77
  /**
82
78
  * CORS 許可オリジンの一覧を生成する(ローカル開発 + 本番/プレビュー)。
83
- * 管理画面 functions/api と file-upload Worker の双方で使用する。
79
+ * 管理画面 Worker(/api)と file-upload Worker の双方で使用する。
84
80
  */
85
81
  export declare function buildAllowedOrigins(config: ProjectConfig): string;
86
- /**
87
- * ルートの wrangler.toml(Cloudflare Pages 設定)を生成する。
88
- *
89
- * Issue #23: `pages_build_output_dir` が無いと `wrangler pages deploy` が
90
- * 設定ファイルを丸ごと無視するため、R2 バインディング・環境変数がデプロイに
91
- * 反映されず、ダッシュボードでの手動設定が必須になっていた。
92
- *
93
- * このファイルはコンテンツ配信・管理画面の両 Pages デプロイで共用する:
94
- * - コンテンツ配信: `wrangler pages deploy public`(pages_build_output_dir と一致)
95
- * - 管理画面: `wrangler pages deploy .admin-deploy`(コマンドライン引数が優先)
96
- * デプロイ先ディレクトリと project 名はコマンドライン引数(`--project-name`)が
97
- * 優先されるため、1 ファイルで両デプロイに R2 バインディング・環境変数を適用できる。
98
- * いずれのデプロイ対象ディレクトリにも本ファイルは含まれない(公開されない)。
99
- */
100
- export declare function generateWranglerToml(config: ProjectConfig): string;
101
82
  export declare function generateWorkerWranglerToml(config: ProjectConfig): string;
102
83
  /** お問い合わせ自動メール(任意)の SMTP 接続設定 */
103
84
  export type ContactSmtpConfig = {
@@ -127,35 +108,30 @@ export type ContactWorkerOptions = {
127
108
  * パスワード等のシークレットは wrangler secret で別途投入する(ここには書かない)。
128
109
  */
129
110
  export declare function generateContactWranglerToml(config: ProjectConfig, opts: ContactWorkerOptions): string;
130
- export declare function generateRedirects(): string;
131
- export declare function generateRoutesJson(): string;
132
111
  /**
133
- * コンテンツ配信側(public/)の _routes.json を生成する。
112
+ * コンテンツ配信 Worker の siteMode 焼き込みモジュール(worker/site-mode.ts)を生成する(Issue #184)。
134
113
  *
135
- * 本番ゲート(Issue #93)の functions/_middleware.ts に全リクエストを通すため
136
- * include を `/*` にする。これにより静的ページもエッジ middleware を経由する
137
- * (live モードでは即 next() で素通り)。
114
+ * siteMode をコード定数として焼き込む。変更は set-mode 後の再デプロイで反映する。
115
+ * テンプレ実ファイル(templates/content-repo/worker/site-mode.ts)と既定(live)で一致する。
138
116
  */
139
- export declare function generatePublicRoutesJson(): string;
117
+ export declare function generateContentWorkerSiteMode(config: ProjectConfig): string;
140
118
  /**
141
- * 本番ゲート middleware(Issue #93)を生成する。
119
+ * コンテンツ配信 Worker(Static Assets)の wrangler.toml を生成する(Issue #184)。
142
120
  *
143
- * 注意: この functions/ は管理画面 Pages にも配られる共有資産のため、
144
- * ホスト判定で「コンテンツのホスト」のみを対象にし、admin / staging /
145
- * localhost / 不明ホストは素通り(next)して CMS を保護する。
121
+ * 静的アセット(SSG 出力 public/)は [assets] バインディング(ASSETS)から配信。
122
+ * /storage/* のみ run_worker_first で Worker を経由し R2 から配信する。
123
+ * siteMode が非 live のときは holding page を全リクエストで返すため run_worker_first=true にする。
124
+ */
125
+ export declare function generateContentWorkerWranglerToml(config: ProjectConfig): string;
126
+ /**
127
+ * 管理画面(CMS Admin)Worker の wrangler 設定(wrangler.admin.toml)を生成する(Issue #184 Phase 2)。
146
128
  *
147
- * テンプレート実ファイル
148
- * (templates/content-repo/functions/_middleware.ts)と同一文字列を返す。
149
- * 乖離は sync テストで検出する。
129
+ * admin の SPA は [assets](./admin)から配信し、SPA フォールバック
130
+ * (not_found_handling="single-page-application")でクライアントルーティングを成立させる。
131
+ * /api/* のみ Worker(admin-worker/index.js = esbuild バンドル済み)を経由する。
132
+ * シークレット(GITHUB_CLIENT_SECRET)は wrangler secret で投入する。
150
133
  */
151
- export declare function generateGateMiddleware(): string;
152
- export declare function generateStorageFunction(): string;
153
- export declare function generateTerraformProviders(): string;
154
- export declare function generateTerraformVariables(config: ProjectConfig): string;
155
- export declare function generateTerraformMain(config: ProjectConfig): string;
156
- export declare function generateTerraformOutputs(): string;
157
- export declare function generateTerraformTfvarsExample(config: ProjectConfig): string;
158
- export declare function generateTerraformReadme(): string;
134
+ export declare function generateAdminWorkerWranglerToml(config: ProjectConfig): string;
159
135
  /**
160
136
  * ファイルを書き込む(ディレクトリがなければ作成)
161
137
  */