create-fff-app 0.1.7 → 0.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fff-app",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Scaffold a new fff-stack project",
5
5
  "bin": {
6
6
  "create-fff-app": "src/index.ts"
package/src/index.ts CHANGED
@@ -17,12 +17,29 @@ const bundledTemplate = join(import.meta.dir, '../template');
17
17
  const monorepTemplate = join(import.meta.dir, '../../../template');
18
18
  const TEMPLATE_DIR = existsSync(monorepTemplate) ? monorepTemplate : bundledTemplate;
19
19
  const SKIP_DIRS = new Set(['obj', 'bin', 'node_modules', '.git', 'dist']);
20
+ const SKIP_EXTS = new Set(['.js', '.js.map']);
20
21
 
21
22
  // ── Helpers ───────────────────────────────────────────────────────────────────
22
23
 
24
+ function transformContent(filename: string, content: string): string {
25
+ if (filename === 'package.json') {
26
+ // Replace monorepo file: reference with published npm version
27
+ content = content.replace(
28
+ /"@fff-stack\/fjsx-compiler":\s*"file:[^"]+"/g,
29
+ '"@fff-stack/fjsx-compiler": "^0.1.0"'
30
+ );
31
+ }
32
+ return content;
33
+ }
34
+
35
+ function hasFjsx(dir: string): boolean {
36
+ try { return readdirSync(dir).some(f => f.endsWith('.fjsx')); } catch { return false; }
37
+ }
38
+
23
39
  function copyDir(src: string, dest: string, projectName: string) {
24
40
  const entries = readdirSync(src, { withFileTypes: true });
25
41
  mkdirSync(dest, { recursive: true });
42
+ const fjsxDir = hasFjsx(src);
26
43
 
27
44
  for (const entry of entries) {
28
45
  if (SKIP_DIRS.has(entry.name)) continue;
@@ -33,8 +50,11 @@ function copyDir(src: string, dest: string, projectName: string) {
33
50
  if (entry.isDirectory()) {
34
51
  copyDir(srcPath, destPath, projectName);
35
52
  } else {
53
+ // Skip FJSX-generated JS/map files in directories that contain .fjsx sources
54
+ const ext = entry.name.endsWith('.js.map') ? '.js.map' : entry.name.slice(entry.name.lastIndexOf('.'));
55
+ if (fjsxDir && SKIP_EXTS.has(ext)) continue;
36
56
  const raw = readFileSync(srcPath, 'utf-8');
37
- const content = raw.replace(/fff-stack-app/g, projectName);
57
+ const content = transformContent(entry.name, raw.replace(/fff-stack-app/g, projectName));
38
58
  // npm strips .gitignore from published packages; stored as "gitignore"
39
59
  const outName = entry.name === 'gitignore' ? '.gitignore' : entry.name;
40
60
  const outPath = join(dirname(destPath), outName);
@@ -110,6 +130,9 @@ ${cdStep}
110
130
  ${dim('# Install JS dependencies')}
111
131
  ${cyan('bun install')}
112
132
 
133
+ ${dim('# Install Fable (F# → JS compiler)')}
134
+ ${cyan('dotnet tool restore')}
135
+
113
136
  ${dim('# Set up Cloudflare D1 (run once)')}
114
137
  ${cyan('wrangler d1 create ' + projectName + '-db')}
115
138
  ${dim('# → copy the database_id into wrangler.toml')}
@@ -4,24 +4,23 @@ open Fable.Core
4
4
  open Fable.Core.JsInterop
5
5
 
6
6
  // ── Compiled FJSX page template modules ──────────────────────────────────────
7
- // These static imports are resolved at Worker startup.
8
- // The FJSX files must be compiled first:
9
- // fjsx --dir src/server/Endpoints/Pages --out dist/server/Endpoints/Pages
7
+ // Paths are relative to THIS source file so Fable generates correct dist-relative
8
+ // imports. FJSX output goes to dist/server/Pages/ (4 dirs up from here, then dist/).
9
+ // Run: fjsx --dir src/server/Endpoints/Pages --out dist/server/Pages
10
10
 
11
- [<ImportAll("./Layout.js")>]
11
+ [<ImportAll("../../../../dist/server/Pages/Layout.js")>]
12
12
  let private layoutMod : obj = jsNative
13
13
 
14
- [<ImportAll("./EmployeeList.js")>]
14
+ [<ImportAll("../../../../dist/server/Pages/EmployeeList.js")>]
15
15
  let private employeeListMod : obj = jsNative
16
16
 
17
- [<ImportAll("./EmployeeNew.js")>]
17
+ [<ImportAll("../../../../dist/server/Pages/EmployeeNew.js")>]
18
18
  let private employeeNewMod : obj = jsNative
19
19
 
20
- [<ImportAll("./About.js")>]
20
+ [<ImportAll("../../../../dist/server/Pages/About.js")>]
21
21
  let private aboutMod : obj = jsNative
22
22
 
23
-
24
- [<ImportAll("./EmployeeEdit.js")>]
23
+ [<ImportAll("../../../../dist/server/Pages/EmployeeEdit.js")>]
25
24
  let private employeeEditMod : obj = jsNative
26
25
  // ── Render helpers ────────────────────────────────────────────────────────────
27
26
 
@@ -22,7 +22,7 @@
22
22
  </ItemGroup>
23
23
 
24
24
  <ItemGroup>
25
- <PackageReference Include="FffStack.Server" Version="0.1.2" />
25
+ <PackageReference Include="FffStack.Server" Version="0.1.3" />
26
26
  </ItemGroup>
27
27
 
28
28
  </Project>
@@ -42,4 +42,4 @@ router.OnError(fun _ctx ex ->
42
42
 
43
43
  // ── Cloudflare Workers entry point ────────────────────────────────────────────
44
44
 
45
- router.ExportAsWorkerDefault()
45
+ Router.exportWorkerDefault (router.AsFetchHandler())