@c-time/frelio-cli 1.4.0 → 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.
- package/README.md +18 -14
- package/dist/commands/init.js +4 -16
- package/dist/core/content-structure.d.ts +8 -14
- package/dist/core/content-structure.js +9 -112
- package/dist/core/index.d.ts +2 -3
- package/dist/core/index.js +3 -3
- package/dist/core/template-scaffold.d.ts +14 -0
- package/dist/core/template-scaffold.js +99 -0
- package/dist/core/workflows.js +181 -16
- package/dist/lib/github-release.d.ts +15 -0
- package/dist/lib/github-release.js +41 -0
- package/dist/lib/initial-content.js +87 -55
- package/dist/lib/template-renderer.d.ts +16 -0
- package/dist/lib/template-renderer.js +32 -0
- package/dist/lib/templates.d.ts +0 -8
- package/dist/lib/templates.js +0 -227
- package/package.json +2 -3
package/dist/lib/templates.d.ts
CHANGED
|
@@ -25,17 +25,9 @@ export declare function generateHash(): string;
|
|
|
25
25
|
export declare function generateStagingDomain(productionUrl: string, pagesProjectName: string): string;
|
|
26
26
|
export declare function generateConfigJson(config: ProjectConfig): string;
|
|
27
27
|
export declare function generateWranglerToml(config: ProjectConfig): string;
|
|
28
|
-
export declare function generateUsersJson(config: ProjectConfig): string;
|
|
29
|
-
export declare function generateStagesJson(): string;
|
|
30
|
-
export declare function generateContentTypesJson(): string;
|
|
31
|
-
export declare function generateVersionJson(): string;
|
|
32
28
|
export declare function generateRedirects(): string;
|
|
33
29
|
export declare function generateRoutesJson(): string;
|
|
34
30
|
export declare function generateStorageFunction(): string;
|
|
35
|
-
export declare function generateViteConfig(): string;
|
|
36
|
-
export declare function generatePackageJson(config: ProjectConfig): string;
|
|
37
|
-
export declare function generateTsConfig(): string;
|
|
38
|
-
export declare function generateTsConfigNode(): string;
|
|
39
31
|
export declare function generateTerraformProviders(): string;
|
|
40
32
|
export declare function generateTerraformVariables(config: ProjectConfig): string;
|
|
41
33
|
export declare function generateTerraformMain(config: ProjectConfig): string;
|
package/dist/lib/templates.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.4.1",
|
|
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"
|