@c-time/frelio-cli 1.4.0 → 1.4.2

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.
@@ -56,41 +56,6 @@ bucket_name = "${config.r2BucketName}"
56
56
  R2_PUBLIC_URL = "${config.r2PublicUrl}"
57
57
  `;
58
58
  }
59
- export function generateUsersJson(config) {
60
- const owner = config.ownerUsername;
61
- return JSON.stringify([
62
- {
63
- githubUsername: owner,
64
- displayName: owner,
65
- isOwner: true,
66
- permissions: {
67
- canViewUsers: true,
68
- canEditUsers: true,
69
- canViewStaging: true,
70
- canEditStaging: true,
71
- canViewContentType: true,
72
- canEditContentType: true,
73
- canViewBuildRecipes: true,
74
- canEditBuildRecipes: true,
75
- canViewTemplates: true,
76
- canEditTemplates: true,
77
- canViewStorage: true,
78
- canEditStorage: true,
79
- canViewDeploy: true,
80
- canEditDeploy: true,
81
- },
82
- },
83
- ], null, 2);
84
- }
85
- export function generateStagesJson() {
86
- return JSON.stringify([], null, 2);
87
- }
88
- export function generateContentTypesJson() {
89
- return JSON.stringify([], null, 2);
90
- }
91
- export function generateVersionJson() {
92
- return JSON.stringify({ version: '0.0.0' }, null, 2);
93
- }
94
59
  export function generateRedirects() {
95
60
  // 順序重要: 先にマッチしたルールが適用される
96
61
  return [
@@ -136,198 +101,6 @@ export const onRequest: PagesFunction<Env> = async (context) => {
136
101
  }
137
102
  `;
138
103
  }
139
- export function generateViteConfig() {
140
- return `import { defineConfig, type Plugin } from 'vite'
141
- import { resolve } from 'path'
142
- import { spawn, type ChildProcess } from 'child_process'
143
-
144
- const templateAssets = resolve(__dirname, 'frelio-data/site/templates/assets')
145
- const entries = resolve(templateAssets, 'entries')
146
-
147
- /** dev server 起動時にコンテンツ変更監視を自動開始する Vite プラグイン */
148
- function contentWatcherPlugin(): Plugin {
149
- let watcher: ChildProcess | null = null
150
- return {
151
- name: 'content-watcher',
152
- apply: 'serve',
153
- configureServer(server) {
154
- watcher = spawn('npx', ['tsx', 'scripts/watch-content.ts'], {
155
- cwd: resolve(__dirname),
156
- stdio: 'inherit',
157
- shell: true,
158
- })
159
- watcher.on('error', (err) => {
160
- console.error('[content-watcher] Failed to start:', err.message)
161
- })
162
- server.httpServer?.on('close', () => {
163
- watcher?.kill()
164
- })
165
- },
166
- buildEnd() {
167
- watcher?.kill()
168
- watcher = null
169
- },
170
- }
171
- }
172
-
173
- /** ビルド時に CSS を対応する JS チャンクのパスに合わせて styles/ 配下へ配置する */
174
- function cssRelocatePlugin(): Plugin {
175
- return {
176
- name: 'css-relocate',
177
- apply: 'build',
178
- enforce: 'post',
179
- generateBundle(_, bundle) {
180
- const renames: Array<{ chunkName: string; oldCss: string; newCss: string }> = []
181
-
182
- for (const chunk of Object.values(bundle)) {
183
- if (chunk.type !== 'chunk' || !chunk.isEntry) continue
184
- const meta = (chunk as any).viteMetadata as
185
- | { importedCss?: Set<string> }
186
- | undefined
187
- if (!meta?.importedCss?.size) continue
188
-
189
- const newCss = chunk.name.replace('/scripts/', '/styles/') + '.css'
190
- for (const oldCss of meta.importedCss) {
191
- if (oldCss !== newCss) {
192
- renames.push({ chunkName: chunk.name, oldCss, newCss })
193
- }
194
- }
195
- }
196
-
197
- for (const { oldCss, newCss } of renames) {
198
- const asset = bundle[oldCss]
199
- if (!asset) continue
200
- delete bundle[oldCss]
201
- asset.fileName = newCss
202
- bundle[newCss] = asset
203
- }
204
-
205
- for (const chunk of Object.values(bundle)) {
206
- if (chunk.type !== 'chunk' || !chunk.isEntry) continue
207
- const meta = (chunk as any).viteMetadata as
208
- | { importedCss?: Set<string> }
209
- | undefined
210
- if (!meta?.importedCss) continue
211
- for (const { oldCss, newCss } of renames) {
212
- if (meta.importedCss.has(oldCss)) {
213
- meta.importedCss.delete(oldCss)
214
- meta.importedCss.add(newCss)
215
- }
216
- }
217
- }
218
- },
219
- }
220
- }
221
-
222
- export default defineConfig(({ command }) => ({
223
- root: 'frelio-data/site/templates',
224
- publicDir: command === 'serve' ? resolve(__dirname, 'public') : false,
225
- plugins: [contentWatcherPlugin(), cssRelocatePlugin()],
226
- resolve: {
227
- alias: {
228
- '@features': resolve(templateAssets, 'ts/features'),
229
- },
230
- },
231
- css: {
232
- preprocessorOptions: {
233
- scss: {
234
- api: 'modern-compiler',
235
- loadPaths: [resolve(templateAssets, 'scss')],
236
- },
237
- },
238
- },
239
- build: {
240
- outDir: resolve(__dirname, 'public'),
241
- emptyOutDir: false,
242
- cssCodeSplit: true,
243
- rollupOptions: {
244
- input: {
245
- 'common/scripts/index': resolve(entries, 'common/scripts/index.ts'),
246
- 'home/scripts/index': resolve(entries, 'home/scripts/index.ts'),
247
- 'about/scripts/index': resolve(entries, 'about/scripts/index.ts'),
248
- 'contact/scripts/index': resolve(entries, 'contact/scripts/index.ts'),
249
- 'news/scripts/index': resolve(entries, 'news/scripts/index.ts'),
250
- 'news/detail/scripts/index': resolve(entries, 'news/detail/scripts/index.ts'),
251
- },
252
- output: {
253
- entryFileNames: '[name].js',
254
- assetFileNames: '[name].[ext]',
255
- },
256
- },
257
- },
258
- server: {
259
- open: '/index.html',
260
- },
261
- }))
262
- `;
263
- }
264
- export function generatePackageJson(config) {
265
- return JSON.stringify({
266
- name: config.pagesProjectName,
267
- private: true,
268
- type: 'module',
269
- scripts: {
270
- dev: 'vite',
271
- build: 'vite build',
272
- preview: 'vite preview',
273
- 'generate:dep-map': 'tsx scripts/generate-dependency-map.ts',
274
- generate: 'tsx scripts/generate-data-json.ts',
275
- 'generate:full': 'tsx scripts/generate-data-json.ts --full-rebuild',
276
- 'generate:dry-run': 'tsx scripts/generate-data-json.ts --dry-run',
277
- 'generate:html': 'tsx scripts/generate-html.ts',
278
- 'generate:html:dry-run': 'tsx scripts/generate-html.ts --dry-run',
279
- 'generate:sitemap': 'tsx scripts/generate-sitemap.ts',
280
- 'generate:sitemap:full': 'tsx scripts/generate-sitemap.ts --full-rebuild',
281
- 'watch:content': 'tsx scripts/watch-content.ts',
282
- 'rebuild:indexes': 'tsx scripts/rebuild-indexes.ts',
283
- 'rebuild:indexes:dry-run': 'tsx scripts/rebuild-indexes.ts --dry-run',
284
- },
285
- devDependencies: {
286
- '@c-time/frelio-content-ops': '^0.1.0',
287
- '@c-time/frelio-data-json-generator': '*',
288
- '@c-time/frelio-data-json-recipe': '^1.2.0',
289
- '@c-time/frelio-data-json-recipe-to-dependency-map': '*',
290
- '@c-time/frelio-dependency-map': '*',
291
- '@c-time/frelio-gentl': '*',
292
- '@c-time/frelio-types': '^0.1.0',
293
- sass: '^1.80.0',
294
- tsx: '^4.0.0',
295
- typescript: '^5.7.0',
296
- vite: '^6.0.0',
297
- zod: '^3.25.0',
298
- },
299
- }, null, 2);
300
- }
301
- export function generateTsConfig() {
302
- return JSON.stringify({
303
- compilerOptions: {
304
- target: 'ES2022',
305
- module: 'ESNext',
306
- moduleResolution: 'bundler',
307
- strict: true,
308
- esModuleInterop: true,
309
- skipLibCheck: true,
310
- resolveJsonModule: true,
311
- outDir: 'dist',
312
- },
313
- include: ['frelio-data/site/templates/assets/ts/**/*.ts', 'vite.config.ts'],
314
- }, null, 2);
315
- }
316
- export function generateTsConfigNode() {
317
- return JSON.stringify({
318
- compilerOptions: {
319
- target: 'ES2022',
320
- module: 'NodeNext',
321
- moduleResolution: 'NodeNext',
322
- strict: true,
323
- esModuleInterop: true,
324
- skipLibCheck: true,
325
- resolveJsonModule: true,
326
- outDir: 'dist',
327
- },
328
- include: ['scripts/**/*.ts'],
329
- }, null, 2);
330
- }
331
104
  // --- Terraform generators ---
332
105
  export function generateTerraformProviders() {
333
106
  return `terraform {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-time/frelio-cli",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Frelio CMS setup CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -8,8 +8,7 @@
8
8
  "frelio": "./dist/index.js"
9
9
  },
10
10
  "files": [
11
- "dist",
12
- "templates"
11
+ "dist"
13
12
  ],
14
13
  "publishConfig": {
15
14
  "access": "public"
@@ -1,11 +0,0 @@
1
- /**
2
- * core/workflows — GitHub Actions ワークフロー生成
3
- */
4
- import { type ProjectConfig, type OperationResult } from './types.js';
5
- export type WorkflowName = 'deploy-admin' | 'build-staging' | 'promote-production' | 'direct-deploy';
6
- export declare function generateWorkflow(projectDir: string, config: ProjectConfig, workflow: WorkflowName): OperationResult<{
7
- path: string;
8
- }>;
9
- export declare function generateWorkflows(projectDir: string, config: ProjectConfig): OperationResult<{
10
- files: string[];
11
- }>;
@@ -1,180 +0,0 @@
1
- /**
2
- * core/workflows — GitHub Actions ワークフロー生成
3
- */
4
- import fs from 'node:fs';
5
- import path from 'node:path';
6
- import { ok, fail } from './types.js';
7
- import { writeFile } from '../lib/templates.js';
8
- // ---------------------------------------------------------------------------
9
- // Individual workflow
10
- // ---------------------------------------------------------------------------
11
- export function generateWorkflow(projectDir, config, workflow) {
12
- const workflowsDir = path.join(projectDir, '.github', 'workflows');
13
- const content = getWorkflowContent(config, workflow);
14
- const fileName = `${workflow}.yml`;
15
- const filePath = path.join(workflowsDir, fileName);
16
- try {
17
- fs.mkdirSync(workflowsDir, { recursive: true });
18
- writeFile(filePath, content);
19
- return ok({ path: filePath });
20
- }
21
- catch (e) {
22
- return fail(`ワークフロー生成失敗 (${fileName}): ${e.message}`, 'EXEC_FAILED');
23
- }
24
- }
25
- // ---------------------------------------------------------------------------
26
- // All workflows
27
- // ---------------------------------------------------------------------------
28
- export function generateWorkflows(projectDir, config) {
29
- const names = ['deploy-admin', 'build-staging', 'promote-production', 'direct-deploy'];
30
- const files = [];
31
- for (const name of names) {
32
- const result = generateWorkflow(projectDir, config, name);
33
- if (!result.success)
34
- return result;
35
- files.push(result.data.path);
36
- }
37
- return ok({ files });
38
- }
39
- // ---------------------------------------------------------------------------
40
- // Workflow templates
41
- // ---------------------------------------------------------------------------
42
- function getWorkflowContent(config, workflow) {
43
- switch (workflow) {
44
- case 'deploy-admin':
45
- return `name: Deploy Admin
46
- on:
47
- push:
48
- branches: [admin]
49
-
50
- jobs:
51
- deploy:
52
- runs-on: ubuntu-latest
53
- steps:
54
- - uses: actions/checkout@v4
55
- - uses: actions/setup-node@v4
56
- with:
57
- node-version: 20
58
- cache: 'npm'
59
- - run: npm ci
60
- - run: npm run build
61
- - name: Deploy to Cloudflare Pages
62
- uses: cloudflare/wrangler-action@v3
63
- with:
64
- apiToken: \${{ secrets.CLOUDFLARE_API_TOKEN }}
65
- accountId: \${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
66
- command: pages deploy dist --project-name=${config.adminPagesProjectName}
67
- `;
68
- case 'build-staging':
69
- return `name: Build Staging
70
- on:
71
- push:
72
- branches: [staging, 'staging-*']
73
-
74
- permissions:
75
- contents: read
76
-
77
- jobs:
78
- build:
79
- runs-on: ubuntu-latest
80
- steps:
81
- - uses: actions/checkout@v4
82
- - uses: actions/setup-node@v4
83
- with:
84
- node-version: 20
85
- cache: 'npm'
86
- - name: Restore SSG cache
87
- uses: actions/cache@v4
88
- with:
89
- path: |
90
- frelio-data/site/data/data-json
91
- public
92
- key: ssg-cache-\${{ github.ref_name }}-\${{ github.sha }}
93
- restore-keys: |
94
- ssg-cache-\${{ github.ref_name }}-
95
- - run: npm ci
96
- - name: SSG Build
97
- run: echo "TODO: Add SSG build steps"
98
- - name: Upload artifact
99
- if: github.ref == 'refs/heads/staging'
100
- uses: actions/upload-artifact@v4
101
- with:
102
- name: staging-build
103
- path: public/
104
- retention-days: 14
105
- - name: Deploy preview
106
- uses: cloudflare/wrangler-action@v3
107
- with:
108
- apiToken: \${{ secrets.CLOUDFLARE_API_TOKEN }}
109
- accountId: \${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
110
- command: pages deploy public --project-name=${config.pagesProjectName} --branch=\${{ github.ref_name }}
111
- `;
112
- case 'promote-production':
113
- return `name: Promote to Production
114
- on:
115
- push:
116
- branches: [main]
117
-
118
- permissions:
119
- contents: write
120
- actions: read
121
-
122
- jobs:
123
- deploy:
124
- runs-on: ubuntu-latest
125
- steps:
126
- - uses: actions/checkout@v4
127
- with:
128
- fetch-depth: 0
129
- - name: Download staging artifact
130
- uses: actions/download-artifact@v4
131
- with:
132
- name: staging-build
133
- path: public/
134
- - name: Deploy to production
135
- uses: cloudflare/wrangler-action@v3
136
- with:
137
- apiToken: \${{ secrets.CLOUDFLARE_API_TOKEN }}
138
- accountId: \${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
139
- command: pages deploy public --project-name=${config.pagesProjectName} --branch=main
140
- - name: Create deploy tag
141
- run: |
142
- VERSION=\$(cat version.json | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).version))")
143
- EXISTING=\$(git tag -l "d\${VERSION}.*" | wc -l)
144
- NEXT=\$((EXISTING + 1))
145
- TAG="d\${VERSION}.\${NEXT}"
146
- git tag "\$TAG"
147
- git push origin "\$TAG"
148
- `;
149
- case 'direct-deploy':
150
- return `name: Direct Deploy
151
- on:
152
- workflow_dispatch:
153
-
154
- permissions:
155
- contents: write
156
-
157
- jobs:
158
- deploy:
159
- runs-on: ubuntu-latest
160
- steps:
161
- - uses: actions/checkout@v4
162
- with:
163
- fetch-depth: 0
164
- - name: Merge develop to staging
165
- run: |
166
- git config user.name "github-actions[bot]"
167
- git config user.email "github-actions[bot]@users.noreply.github.com"
168
- git checkout staging
169
- git merge origin/develop --no-edit
170
- git push origin staging
171
- - name: Wait for staging build
172
- run: echo "Staging build will be triggered by the push above. Monitor build-staging.yml."
173
- - name: Fast-forward main
174
- run: |
175
- git checkout main
176
- git merge staging --ff-only
177
- git push origin main
178
- `;
179
- }
180
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * 初期コンテンツ・テンプレート・レシピの生成
3
- * frelio-demo を踏襲したデモサイト構造
4
- */
5
- export declare function generateInitialContent(projectDir: string): void;