@c-time/frelio-cli 1.4.2 → 1.4.4

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 CHANGED
@@ -1,4 +1,4 @@
1
- # @frelio/cli
1
+ # @c-time/frelio-cli
2
2
 
3
3
  Frelio CMS のプロジェクトセットアップと管理を行う CLI ツール。
4
4
 
@@ -114,13 +114,13 @@ wrangler login
114
114
  ## インストール
115
115
 
116
116
  ```bash
117
- npx @frelio/cli init
117
+ npx @c-time/frelio-cli init
118
118
  ```
119
119
 
120
120
  npm でグローバルインストールする場合:
121
121
 
122
122
  ```bash
123
- npm install -g @frelio/cli
123
+ npm install -g @c-time/frelio-cli
124
124
  frelio init
125
125
  ```
126
126
 
@@ -20,6 +20,9 @@ export declare function generateAndWriteRoutesJson(projectDir: string): Operatio
20
20
  export declare function generateAndWritePublicRoutesJson(projectDir: string): OperationResult<{
21
21
  path: string;
22
22
  }>;
23
+ export declare function generateAndWriteWorkerWranglerToml(projectDir: string, config: ProjectConfig): OperationResult<{
24
+ path: string;
25
+ }>;
23
26
  export declare function generateAndWriteStorageFunction(projectDir: string): OperationResult<{
24
27
  path: string;
25
28
  }>;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import path from 'node:path';
8
8
  import { ok, fail } from './types.js';
9
- import { generateConfigJson, generateWranglerToml, generateRedirects, generateRoutesJson, generateStorageFunction, writeFile, } from '../lib/templates.js';
9
+ import { generateConfigJson, generateWranglerToml, generateWorkerWranglerToml, generateRedirects, generateRoutesJson, generateStorageFunction, writeFile, } from '../lib/templates.js';
10
10
  // ---------------------------------------------------------------------------
11
11
  // Individual file generators
12
12
  // ---------------------------------------------------------------------------
@@ -61,6 +61,16 @@ export function generateAndWritePublicRoutesJson(projectDir) {
61
61
  return fail(`public/_routes.json 生成失敗: ${e.message}`, 'EXEC_FAILED');
62
62
  }
63
63
  }
64
+ export function generateAndWriteWorkerWranglerToml(projectDir, config) {
65
+ try {
66
+ const filePath = path.join(projectDir, 'workers', 'file-upload', 'wrangler.toml');
67
+ writeFile(filePath, generateWorkerWranglerToml(config));
68
+ return ok({ path: filePath });
69
+ }
70
+ catch (e) {
71
+ return fail(`worker wrangler.toml 生成失敗: ${e.message}`, 'EXEC_FAILED');
72
+ }
73
+ }
64
74
  export function generateAndWriteStorageFunction(projectDir) {
65
75
  try {
66
76
  const filePath = path.join(projectDir, 'functions', 'storage', '[[path]].ts');
@@ -79,6 +89,7 @@ export function regenerateAllConfigFiles(projectDir, config) {
79
89
  const generators = [
80
90
  () => generateAndWriteConfigJson(projectDir, config),
81
91
  () => generateAndWriteWranglerToml(projectDir, config),
92
+ () => generateAndWriteWorkerWranglerToml(projectDir, config),
82
93
  () => generateAndWriteRedirects(projectDir),
83
94
  () => generateAndWriteRoutesJson(projectDir),
84
95
  () => generateAndWritePublicRoutesJson(projectDir),
@@ -25,6 +25,7 @@ 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 generateWorkerWranglerToml(config: ProjectConfig): string;
28
29
  export declare function generateRedirects(): string;
29
30
  export declare function generateRoutesJson(): string;
30
31
  export declare function generateStorageFunction(): string;
@@ -56,6 +56,27 @@ bucket_name = "${config.r2BucketName}"
56
56
  R2_PUBLIC_URL = "${config.r2PublicUrl}"
57
57
  `;
58
58
  }
59
+ export function generateWorkerWranglerToml(config) {
60
+ const allowedOrigins = [
61
+ 'http://localhost:5173',
62
+ 'http://localhost:5174',
63
+ config.productionUrl,
64
+ config.previewUrl,
65
+ ].filter(Boolean).join(',');
66
+ return `name = "frelio-file-upload"
67
+ main = "src/index.ts"
68
+ compatibility_date = "2024-02-08"
69
+
70
+ [[r2_buckets]]
71
+ binding = "R2"
72
+ bucket_name = "${config.r2BucketName}"
73
+
74
+ [vars]
75
+ R2_PUBLIC_URL = "${config.r2PublicUrl}"
76
+ ALLOWED_ORIGINS = "${allowedOrigins}"
77
+ CONTENT_REPO = "${config.contentRepo}"
78
+ `;
79
+ }
59
80
  export function generateRedirects() {
60
81
  // 順序重要: 先にマッチしたルールが適用される
61
82
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-time/frelio-cli",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Frelio CMS setup CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",