@c-time/frelio-cli 1.3.13 → 1.4.1

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 (44) hide show
  1. package/README.md +18 -14
  2. package/dist/commands/add-staging.d.ts +2 -3
  3. package/dist/commands/add-staging.js +38 -184
  4. package/dist/commands/init.d.ts +4 -0
  5. package/dist/commands/init.js +164 -373
  6. package/dist/commands/update.d.ts +2 -0
  7. package/dist/commands/update.js +11 -67
  8. package/dist/core/bundle.d.ts +14 -0
  9. package/dist/core/bundle.js +122 -0
  10. package/dist/core/cloudflare.d.ts +26 -0
  11. package/dist/core/cloudflare.js +60 -0
  12. package/dist/core/config.d.ts +26 -0
  13. package/dist/core/config.js +120 -0
  14. package/dist/core/content-structure.d.ts +13 -0
  15. package/dist/core/content-structure.js +13 -0
  16. package/dist/core/file-generators.d.ts +28 -0
  17. package/dist/core/file-generators.js +93 -0
  18. package/dist/core/git-operations.d.ts +15 -0
  19. package/dist/core/git-operations.js +78 -0
  20. package/dist/core/github.d.ts +16 -0
  21. package/dist/core/github.js +43 -0
  22. package/dist/core/index.d.ts +22 -0
  23. package/dist/core/index.js +30 -0
  24. package/dist/core/prerequisites.d.ts +22 -0
  25. package/dist/core/prerequisites.js +107 -0
  26. package/dist/core/status.d.ts +18 -0
  27. package/dist/core/status.js +122 -0
  28. package/dist/core/template-scaffold.d.ts +14 -0
  29. package/dist/core/template-scaffold.js +99 -0
  30. package/dist/core/terraform.d.ts +7 -0
  31. package/dist/core/terraform.js +47 -0
  32. package/dist/core/types.d.ts +48 -0
  33. package/dist/core/types.js +21 -0
  34. package/dist/core/workflows.d.ts +11 -0
  35. package/dist/core/workflows.js +345 -0
  36. package/dist/index.js +2 -4
  37. package/dist/lib/github-release.d.ts +15 -0
  38. package/dist/lib/github-release.js +41 -0
  39. package/dist/lib/initial-content.js +87 -55
  40. package/dist/lib/template-renderer.d.ts +16 -0
  41. package/dist/lib/template-renderer.js +32 -0
  42. package/dist/lib/templates.d.ts +7 -7
  43. package/dist/lib/templates.js +311 -214
  44. package/package.json +2 -3
@@ -111,8 +111,8 @@ export function generateInitialContent(projectDir) {
111
111
  details: [
112
112
  {
113
113
  type: 'detail',
114
- outputPath: 'news/{$this.slug}/index.json',
115
- templatePath: 'news/_detail/index.html',
114
+ outputPath: 'news/{$this.slug}.json',
115
+ templatePath: 'news/detail.html',
116
116
  },
117
117
  ],
118
118
  lists: [
@@ -206,8 +206,8 @@ function generateTemplates(projectDir) {
206
206
  <meta charset="UTF-8">
207
207
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
208
208
  <title>Frelio Demo</title>
209
- <link rel="stylesheet" href="/home/styles/index.css">
210
- <script type="module" src="/home/scripts/index.js"></script>
209
+ <link rel="stylesheet" href="/styles/index.css">
210
+ <script type="module" src="/scripts/index.js"></script>
211
211
  </head>
212
212
  <body>
213
213
  <template data-gen-scope="" data-gen-include="_parts/header.htm"></template>
@@ -274,8 +274,8 @@ function generateTemplates(projectDir) {
274
274
  </body>
275
275
  </html>
276
276
  `);
277
- // about.html
278
- writeFile(t('about.html'), `<!DOCTYPE html>
277
+ // about/index.html
278
+ writeFile(t('about/index.html'), `<!DOCTYPE html>
279
279
  <html lang="ja">
280
280
  <head>
281
281
  <template data-gen-scope="" data-gen-include="_parts/head.htm"></template>
@@ -344,8 +344,8 @@ function generateTemplates(projectDir) {
344
344
  </body>
345
345
  </html>
346
346
  `);
347
- // contact.html
348
- writeFile(t('contact.html'), `<!DOCTYPE html>
347
+ // contact/index.html
348
+ writeFile(t('contact/index.html'), `<!DOCTYPE html>
349
349
  <html lang="ja">
350
350
  <head>
351
351
  <template data-gen-scope="" data-gen-include="_parts/head.htm"></template>
@@ -472,16 +472,16 @@ function generateTemplates(projectDir) {
472
472
  </body>
473
473
  </html>
474
474
  `);
475
- // news/_detail/index.html
476
- writeFile(t('news/_detail/index.html'), `<!DOCTYPE html>
475
+ // news/detail.html
476
+ writeFile(t('news/detail.html'), `<!DOCTYPE html>
477
477
  <html lang="ja">
478
478
  <head>
479
479
  <template data-gen-scope="" data-gen-include="_parts/head.htm"></template>
480
480
  <meta charset="UTF-8">
481
481
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
482
482
  <title>記事タイトル | Frelio Demo</title>
483
- <link rel="stylesheet" href="/news/detail/styles/index.css">
484
- <script type="module" src="/news/detail/scripts/index.js"></script>
483
+ <link rel="stylesheet" href="/news/styles/index.css">
484
+ <script type="module" src="/news/scripts/index.js"></script>
485
485
  </head>
486
486
  <body>
487
487
  <template data-gen-scope="" data-gen-include="_parts/header.htm"></template>
@@ -535,10 +535,21 @@ function generateTemplates(projectDir) {
535
535
  </body>
536
536
  </html>
537
537
  `);
538
+ // .gitkeep for images directories
539
+ const gitkeepDirs = [
540
+ 'common/images',
541
+ 'images',
542
+ 'about/images',
543
+ 'contact/images',
544
+ 'news/images',
545
+ ];
546
+ for (const dir of gitkeepDirs) {
547
+ writeFile(t(`${dir}/.gitkeep`), '');
548
+ }
538
549
  }
539
550
  // ========== SCSS ==========
540
551
  function generateScss(projectDir) {
541
- const s = (...p) => path.join(projectDir, 'frelio-data/site/templates/assets/scss', ...p);
552
+ const s = (...p) => path.join(projectDir, 'frelio-data/site/templates/common/styles', ...p);
542
553
  // Foundation
543
554
  writeFile(s('foundation/_variables.scss'), `// Colors
544
555
  $color-primary: #0070f3;
@@ -1195,7 +1206,7 @@ button {
1195
1206
  }
1196
1207
  // ========== TypeScript ==========
1197
1208
  function generateTypeScript(projectDir) {
1198
- const ts = (...p) => path.join(projectDir, 'frelio-data/site/templates/assets/ts', ...p);
1209
+ const ts = (...p) => path.join(projectDir, 'frelio-data/site/templates/common/scripts', ...p);
1199
1210
  writeFile(ts('features/mobile-nav.ts'), `export function initMobileNav(): void {
1200
1211
  const toggle = document.querySelector<HTMLButtonElement>('.c-nav__toggle')
1201
1212
  const list = document.querySelector<HTMLUListElement>('.c-nav__list')
@@ -1238,9 +1249,9 @@ function generateTypeScript(projectDir) {
1238
1249
  }
1239
1250
  // ========== Entry Points ==========
1240
1251
  function generateEntries(projectDir) {
1241
- const e = (...p) => path.join(projectDir, 'frelio-data/site/templates/assets/entries', ...p);
1252
+ const t = (...p) => path.join(projectDir, 'frelio-data/site/templates', ...p);
1242
1253
  // common
1243
- writeFile(e('common/styles/index.scss'), `// Foundation
1254
+ writeFile(t('common/styles/index.scss'), `// Foundation
1244
1255
  @use 'foundation/variables' as *;
1245
1256
  @use 'foundation/mixins' as *;
1246
1257
  @use 'foundation/reset';
@@ -1260,55 +1271,48 @@ function generateEntries(projectDir) {
1260
1271
  // Element
1261
1272
  @use 'element/e-heading';
1262
1273
  `);
1263
- writeFile(e('common/scripts/index.ts'), `import '../styles/index.scss'
1264
- import { initMobileNav } from '@features/mobile-nav'
1265
- import { initSmoothScroll } from '@features/smooth-scroll'
1274
+ writeFile(t('common/scripts/index.ts'), `import '../styles/index.scss'
1275
+ import { initMobileNav } from './features/mobile-nav'
1276
+ import { initSmoothScroll } from './features/smooth-scroll'
1266
1277
 
1267
1278
  document.addEventListener('DOMContentLoaded', () => {
1268
1279
  initMobileNav()
1269
1280
  initSmoothScroll()
1270
1281
  })
1271
1282
  `);
1272
- // home
1273
- writeFile(e('home/styles/index.scss'), `@use 'foundation/variables' as *;
1283
+ // home (root level — / maps to templates root)
1284
+ writeFile(t('styles/index.scss'), `@use 'foundation/variables' as *;
1274
1285
  @use 'foundation/mixins' as *;
1275
1286
 
1276
1287
  @use 'project/p-hero';
1277
1288
  @use 'project/p-news-list';
1278
1289
  `);
1279
- writeFile(e('home/scripts/index.ts'), `import '../styles/index.scss'
1290
+ writeFile(t('scripts/index.ts'), `import '../styles/index.scss'
1280
1291
  `);
1281
1292
  // about
1282
- writeFile(e('about/styles/index.scss'), `@use 'foundation/variables' as *;
1293
+ writeFile(t('about/styles/index.scss'), `@use 'foundation/variables' as *;
1283
1294
  @use 'foundation/mixins' as *;
1284
1295
 
1285
1296
  @use 'project/p-about';
1286
1297
  `);
1287
- writeFile(e('about/scripts/index.ts'), `import '../styles/index.scss'
1298
+ writeFile(t('about/scripts/index.ts'), `import '../styles/index.scss'
1288
1299
  `);
1289
1300
  // contact
1290
- writeFile(e('contact/styles/index.scss'), `@use 'foundation/variables' as *;
1301
+ writeFile(t('contact/styles/index.scss'), `@use 'foundation/variables' as *;
1291
1302
  @use 'foundation/mixins' as *;
1292
1303
 
1293
1304
  @use 'project/p-contact';
1294
1305
  `);
1295
- writeFile(e('contact/scripts/index.ts'), `import '../styles/index.scss'
1306
+ writeFile(t('contact/scripts/index.ts'), `import '../styles/index.scss'
1296
1307
  `);
1297
- // news
1298
- writeFile(e('news/styles/index.scss'), `@use 'foundation/variables' as *;
1308
+ // news (list + detail share the same scripts/styles)
1309
+ writeFile(t('news/styles/index.scss'), `@use 'foundation/variables' as *;
1299
1310
  @use 'foundation/mixins' as *;
1300
1311
 
1301
1312
  @use 'project/p-news-list';
1302
- `);
1303
- writeFile(e('news/scripts/index.ts'), `import '../styles/index.scss'
1304
- `);
1305
- // news/detail
1306
- writeFile(e('news/detail/styles/index.scss'), `@use 'foundation/variables' as *;
1307
- @use 'foundation/mixins' as *;
1308
-
1309
1313
  @use 'project/p-article';
1310
1314
  `);
1311
- writeFile(e('news/detail/scripts/index.ts'), `import '../styles/index.scss'
1315
+ writeFile(t('news/scripts/index.ts'), `import '../styles/index.scss'
1312
1316
  `);
1313
1317
  }
1314
1318
  // ========== Build Scripts ==========
@@ -2071,13 +2075,13 @@ Frelio(ヘッドレス CMS)で構築されたサイトリポジトリ。
2071
2075
  ## プロジェクト構成
2072
2076
 
2073
2077
  - \`frelio-data/\` — CMS データ(コンテンツタイプ、コンテンツ、テンプレート、レシピ)
2074
- - \`site/templates/assets/scss/\` — 共有 SCSS パーシャル(FLOCSS 亜種)
2075
- - \`site/templates/assets/ts/\` — 共有 TypeScript(features/)
2076
- - \`site/templates/assets/entries/\` — ページ別エントリーポイント
2077
- - \`public/\` — SSG 出力(HTML + ビルド済みアセット)
2078
+ - \`site/templates/\` — テンプレート(配置 = 出力先 URL 構造)
2079
+ - \`site/templates/common/styles/\` — 共有 SCSS パーシャル(FLOCSS 亜種)
2080
+ - \`site/templates/common/scripts/\` — 共有 TypeScript(features/)
2081
+ - \`site/data/data-json/\` — SSG 中間データ(git 追跡対象)
2082
+ - \`public/\` — SSG 出力(HTML + ビルド済みアセット、git 管理外)
2078
2083
  - \`functions/storage/\` — R2 ファイル配信(/storage/*)
2079
2084
  - \`scripts/\` — ビルドスクリプト(tsx)
2080
- - \`public/images/\` — 静的ファイル(画像等、git 追跡対象)
2081
2085
 
2082
2086
  CMS 管理画面関連(\`admin/\`, \`functions/api/\`, \`workers/\`, \`wrangler.toml\`, \`_redirects\`)は
2083
2087
  \`npx @frelio/cli update\` で追加・更新される。
@@ -2086,7 +2090,7 @@ CMS 管理画面関連(\`admin/\`, \`functions/api/\`, \`workers/\`, \`wrangle
2086
2090
 
2087
2091
  \`\`\`bash
2088
2092
  npm run dev # Vite dev server(テンプレートプレビュー + コンテンツ監視)
2089
- npm run build # SCSS/TS ビルド(ページ別エントリー)
2093
+ npm run build # 静的アセットコピー + SCSS/TS ビルド(ページ別エントリー)
2090
2094
  npm run generate # data-json 生成(差分ビルド)
2091
2095
  npm run generate:full # data-json 生成(フルリビルド)
2092
2096
  npm run generate:html # HTML 生成(data-json → public/)
@@ -2108,23 +2112,50 @@ npx @frelio/cli add-staging # カスタムステージング追加
2108
2112
  5. sitemap.xml 生成 (npm run generate:sitemap)
2109
2113
  \`\`\`
2110
2114
 
2111
- ## ページ別エントリーポイント
2115
+ ## テンプレート構造(= URL 構造)
2112
2116
 
2113
- アセットはページ単位でコード分割される。各ページに \`styles/index.scss\` と \`scripts/index.ts\` がある。
2117
+ テンプレートの配置がそのまま出力先の URL パスになる。各ページに \`styles/index.scss\` と \`scripts/index.ts\` がある。
2114
2118
 
2115
2119
  \`\`\`
2116
- assets/entries/
2117
- ├── common/ 全ページ共通(foundation, layout, component, element + JS初期化)
2118
- ├── home/ トップページ(p-hero, p-news-list)
2119
- ├── about/ 会社概要(p-about)
2120
- ├── contact/ お問い合わせ(p-contact)
2121
- ├── news/ お知らせ一覧(p-news-list)
2122
- └── news/detail/ — 記事詳細(p-article)
2120
+ frelio-data/site/templates/
2121
+ ├── _parts/ 共通パーツ(head.htm, header.htm, footer.htm)
2122
+ ├── common/ 全ページ共通
2123
+ ├── scripts/ JS 初期化 + features/
2124
+ ├── styles/ SCSS パーシャル(FLOCSS: foundation/, layout/, component/, element/, project/)
2125
+ │ └── images/ favicon, logo 等
2126
+ ├── index.html — / (ホーム)
2127
+ ├── scripts/index.ts — ホーム用 JS
2128
+ ├── styles/index.scss — ホーム用 CSS(p-hero, p-news-list)
2129
+ ├── images/ — ホーム画像
2130
+ ├── about/ — /about/
2131
+ │ ├── index.html
2132
+ │ ├── scripts/index.ts
2133
+ │ ├── styles/index.scss(p-about)
2134
+ │ └── images/
2135
+ ├── contact/ — /contact/
2136
+ │ ├── index.html
2137
+ │ ├── scripts/index.ts
2138
+ │ ├── styles/index.scss(p-contact)
2139
+ │ └── images/
2140
+ └── news/ — /news/
2141
+ ├── index.html — 一覧テンプレート
2142
+ ├── detail.html — 詳細テンプレート(レシピで news/{slug}.html に展開)
2143
+ ├── scripts/index.ts — 一覧・詳細で共有
2144
+ ├── styles/index.scss(p-news-list, p-article)
2145
+ └── images/
2123
2146
  \`\`\`
2124
2147
 
2125
2148
  - \`_parts/head.htm\` で common の CSS/JS を読み込み
2126
2149
  - 各ページテンプレートでページ固有の CSS/JS を読み込み
2127
2150
 
2151
+ ### スラッグ展開
2152
+
2153
+ テンプレートファイル名と出力パスの対応はレシピ(\`build-data-recipe.json\`)で制御する。
2154
+ gentl の規約ではなく、レシピの書き方次第。
2155
+
2156
+ - **ファイルベース**: \`news/detail.html\` → \`news/{slug}.html\`(現在の設定)
2157
+ - **ディレクトリベース**: \`news/_detail/index.html\` → \`news/{slug}/index.html\`(別方式、必要に応じて変更可)
2158
+
2128
2159
  ## CSS 記法ルール(FLOCSS 亜種・厳格)
2129
2160
 
2130
2161
  - **プレフィックス**: \`l-\`(layout)、\`c-\`(component)、\`p-\`(project)、\`e-\`(element)のみ
@@ -2145,16 +2176,17 @@ assets/entries/
2145
2176
 
2146
2177
  ## TypeScript ルール
2147
2178
 
2148
- - 共通の初期化ロジックは \`entries/common/scripts/index.ts\` に集約
2149
- - 各機能は \`assets/ts/features/\` にファイル分離
2150
- - ページ固有の JS が必要な場合は \`entries/{page}/scripts/index.ts\` に追加
2179
+ - 共通の初期化ロジックは \`common/scripts/index.ts\` に集約
2180
+ - 各機能は \`common/scripts/features/\` にファイル分離
2181
+ - ページ固有の JS が必要な場合は \`{page}/scripts/index.ts\` に追加
2151
2182
 
2152
2183
  ## テンプレート規約
2153
2184
 
2154
2185
  - テンプレートエンジン: gentl(\`data-gen-*\` 属性ベース)
2155
2186
  - テンプレートは valid HTML(そのままブラウザで開ける)
2156
2187
  - 共通パーツ: \`_parts/*.htm\`(head, header, footer)
2157
- - ページテンプレート: \`*.html\`
2188
+ - ページテンプレート: \`{page}/index.html\`(ホームは \`index.html\`)
2189
+ - 詳細テンプレート: \`{page}/detail.html\`(レシピでスラッグ展開)
2158
2190
 
2159
2191
  ## Cloudflare Pages 構成
2160
2192
 
@@ -0,0 +1,16 @@
1
+ /**
2
+ * テンプレート変数置換
3
+ *
4
+ * {{variable}} 形式のプレースホルダーを値に置換する。
5
+ * GitHub Actions の ${{ expression }} とは衝突しない。
6
+ */
7
+ import type { ProjectConfig } from './templates.js';
8
+ export type TemplateVariables = Record<string, string>;
9
+ /**
10
+ * テンプレート文字列内の {{variable}} を置換する
11
+ */
12
+ export declare function renderTemplate(content: string, vars: TemplateVariables): string;
13
+ /**
14
+ * ProjectConfig からテンプレート変数マップを生成する
15
+ */
16
+ export declare function projectConfigToVars(config: ProjectConfig): TemplateVariables;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * テンプレート変数置換
3
+ *
4
+ * {{variable}} 形式のプレースホルダーを値に置換する。
5
+ * GitHub Actions の ${{ expression }} とは衝突しない。
6
+ */
7
+ /**
8
+ * テンプレート文字列内の {{variable}} を置換する
9
+ */
10
+ export function renderTemplate(content, vars) {
11
+ return content.replace(/\{\{(\w+)\}\}/g, (match, key) => {
12
+ return key in vars ? vars[key] : match;
13
+ });
14
+ }
15
+ /**
16
+ * ProjectConfig からテンプレート変数マップを生成する
17
+ */
18
+ export function projectConfigToVars(config) {
19
+ return {
20
+ contentRepo: config.contentRepo,
21
+ githubClientId: config.githubClientId,
22
+ siteTitle: config.siteTitle,
23
+ productionUrl: config.productionUrl,
24
+ previewUrl: config.previewUrl,
25
+ fileUploadUrl: '/api/storage',
26
+ pagesProjectName: config.pagesProjectName,
27
+ adminPagesProjectName: config.adminPagesProjectName,
28
+ r2BucketName: config.r2BucketName,
29
+ r2PublicUrl: config.r2PublicUrl,
30
+ ownerUsername: config.ownerUsername,
31
+ };
32
+ }
@@ -10,6 +10,7 @@ export type ProjectConfig = {
10
10
  r2BucketName: string;
11
11
  r2PublicUrl: string;
12
12
  pagesProjectName: string;
13
+ adminPagesProjectName: string;
13
14
  ownerUsername: string;
14
15
  stagingDomain: string;
15
16
  };
@@ -24,16 +25,15 @@ export declare function generateHash(): string;
24
25
  export declare function generateStagingDomain(productionUrl: string, pagesProjectName: string): string;
25
26
  export declare function generateConfigJson(config: ProjectConfig): string;
26
27
  export declare function generateWranglerToml(config: ProjectConfig): string;
27
- export declare function generateUsersIndex(config: ProjectConfig): string;
28
- export declare function generateContentTypesJson(): string;
29
- export declare function generateVersionJson(): string;
30
28
  export declare function generateRedirects(): string;
31
29
  export declare function generateRoutesJson(): string;
32
30
  export declare function generateStorageFunction(): string;
33
- export declare function generateViteConfig(): string;
34
- export declare function generatePackageJson(config: ProjectConfig): string;
35
- export declare function generateTsConfig(): string;
36
- export declare function generateTsConfigNode(): string;
31
+ export declare function generateTerraformProviders(): string;
32
+ export declare function generateTerraformVariables(config: ProjectConfig): string;
33
+ export declare function generateTerraformMain(config: ProjectConfig): string;
34
+ export declare function generateTerraformOutputs(): string;
35
+ export declare function generateTerraformTfvarsExample(config: ProjectConfig): string;
36
+ export declare function generateTerraformReadme(): string;
37
37
  /**
38
38
  * ファイルを書き込む(ディレクトリがなければ作成)
39
39
  */