create-fiyuu-app 0.1.3 → 0.2.0
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 +45 -0
- package/bin/create-fiyuu-app.mjs +41 -30
- package/package.json +6 -2
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# create-fiyuu-app
|
|
2
|
+
|
|
3
|
+
Scaffold a new Fiyuu project with a single command.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-fiyuu-app my-app
|
|
9
|
+
cd my-app
|
|
10
|
+
npm install
|
|
11
|
+
npm run dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Options
|
|
15
|
+
|
|
16
|
+
The CLI prompts you to select features:
|
|
17
|
+
|
|
18
|
+
- **Sockets** - WebSocket real-time communication
|
|
19
|
+
- **Database** - F1 DB embedded database
|
|
20
|
+
- **Encryption** - Request encryption
|
|
21
|
+
- **Skills** - AI skills integration
|
|
22
|
+
- **Theming** - Dark/light mode support
|
|
23
|
+
- **Auth hints** - Authentication scaffolding
|
|
24
|
+
|
|
25
|
+
## Project Structure
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
my-app/
|
|
29
|
+
app/
|
|
30
|
+
page.tsx # Home page
|
|
31
|
+
layout.tsx # Root layout
|
|
32
|
+
meta.ts # Route metadata
|
|
33
|
+
query.ts # Data fetching
|
|
34
|
+
action.ts # Server mutations
|
|
35
|
+
schema.ts # Zod schemas
|
|
36
|
+
middleware.ts # Request middleware
|
|
37
|
+
api/
|
|
38
|
+
health.ts # API endpoint
|
|
39
|
+
fiyuu.config.ts # Framework configuration
|
|
40
|
+
package.json
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
MIT
|
package/bin/create-fiyuu-app.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { existsSync
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
-
import { execSync } from "node:child_process";
|
|
6
5
|
import path from "node:path";
|
|
7
6
|
import { fileURLToPath } from "node:url";
|
|
8
7
|
import readline from "node:readline/promises";
|
|
@@ -21,17 +20,6 @@ const ui = {
|
|
|
21
20
|
bold: color(1),
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
async function linkFramework(targetDirectory, frameworkRoot) {
|
|
25
|
-
try {
|
|
26
|
-
execSync("npm link", { cwd: frameworkRoot, stdio: "inherit" });
|
|
27
|
-
execSync("npm link fiyuu", { cwd: targetDirectory, stdio: "inherit" });
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.error("Failed to link fiyuu framework. You may need to run:");
|
|
30
|
-
console.error(` cd ${frameworkRoot} && npm link`);
|
|
31
|
-
console.error(` cd ${targetDirectory} && npm link fiyuu`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
23
|
const [, , projectName, ...flags] = process.argv;
|
|
36
24
|
|
|
37
25
|
if (!projectName) {
|
|
@@ -39,7 +27,9 @@ if (!projectName) {
|
|
|
39
27
|
process.exit(1);
|
|
40
28
|
}
|
|
41
29
|
|
|
42
|
-
const
|
|
30
|
+
const frameworkRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
31
|
+
const localFrameworkCheckout = isLocalFrameworkCheckout(frameworkRoot);
|
|
32
|
+
const useLocal = flags.includes("--local") || localFrameworkCheckout;
|
|
43
33
|
const useDefaults = flags.includes("--yes");
|
|
44
34
|
const currentDirectory = process.cwd();
|
|
45
35
|
const targetDirectory = path.resolve(currentDirectory, projectName);
|
|
@@ -50,15 +40,16 @@ if (existsSync(targetDirectory)) {
|
|
|
50
40
|
process.exit(1);
|
|
51
41
|
}
|
|
52
42
|
|
|
53
|
-
|
|
43
|
+
if (flags.includes("--local") && !localFrameworkCheckout) {
|
|
44
|
+
console.warn("Local Fiyuu checkout not found next to create-fiyuu-app. Falling back to the published package.");
|
|
45
|
+
}
|
|
46
|
+
|
|
54
47
|
const dependencyStrategy = resolveDependencyStrategy(frameworkRoot, useLocal);
|
|
55
48
|
const answers = await collectAnswers(useDefaults);
|
|
56
49
|
|
|
57
50
|
await mkdir(targetDirectory, { recursive: true });
|
|
58
51
|
await createProject(targetDirectory, packageName, dependencyStrategy, answers);
|
|
59
52
|
|
|
60
|
-
await linkFramework(targetDirectory, frameworkRoot);
|
|
61
|
-
|
|
62
53
|
renderSuccess(packageName, targetDirectory, answers);
|
|
63
54
|
|
|
64
55
|
async function collectAnswers(useDefaultsFlag) {
|
|
@@ -272,11 +263,29 @@ function color(...codes) {
|
|
|
272
263
|
return useColor ? `\u001b[${codes.join(";")}m` : "";
|
|
273
264
|
}
|
|
274
265
|
|
|
266
|
+
function isLocalFrameworkCheckout(frameworkRoot) {
|
|
267
|
+
return existsSync(path.join(frameworkRoot, "bin", "fiyuu.mjs"))
|
|
268
|
+
&& existsSync(path.join(frameworkRoot, "client.ts"));
|
|
269
|
+
}
|
|
270
|
+
|
|
275
271
|
function resolveDependencyStrategy(frameworkRoot, useLocalFlag) {
|
|
272
|
+
if (useLocalFlag) {
|
|
273
|
+
return {
|
|
274
|
+
cliDependency: `file:${path.join(frameworkRoot, "packages/cli")}`,
|
|
275
|
+
coreDependency: `file:${path.join(frameworkRoot, "packages/core")}`,
|
|
276
|
+
runtimeDependency: `file:${path.join(frameworkRoot, "packages/runtime")}`,
|
|
277
|
+
dbDependency: `file:${path.join(frameworkRoot, "packages/db")}`,
|
|
278
|
+
realtimeDependency: `file:${path.join(frameworkRoot, "packages/realtime")}`,
|
|
279
|
+
clientImportModule: "@fiyuu/core/client",
|
|
280
|
+
};
|
|
281
|
+
}
|
|
276
282
|
return {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
283
|
+
cliDependency: "^0.3.0",
|
|
284
|
+
coreDependency: "^0.3.0",
|
|
285
|
+
runtimeDependency: "^0.3.0",
|
|
286
|
+
dbDependency: "^0.4.0",
|
|
287
|
+
realtimeDependency: "^0.4.0",
|
|
288
|
+
clientImportModule: "@fiyuu/core/client",
|
|
280
289
|
};
|
|
281
290
|
}
|
|
282
291
|
|
|
@@ -355,8 +364,7 @@ async function createProject(targetDirectory, packageName, dependencyStrategy, a
|
|
|
355
364
|
}
|
|
356
365
|
|
|
357
366
|
function createPackageJson(projectName, dependencyStrategy) {
|
|
358
|
-
const {
|
|
359
|
-
const includeSockets = false;
|
|
367
|
+
const { cliDependency, coreDependency, runtimeDependency, dbDependency, realtimeDependency } = dependencyStrategy;
|
|
360
368
|
|
|
361
369
|
return `${JSON.stringify(
|
|
362
370
|
{
|
|
@@ -365,19 +373,22 @@ function createPackageJson(projectName, dependencyStrategy) {
|
|
|
365
373
|
private: true,
|
|
366
374
|
type: "module",
|
|
367
375
|
scripts: {
|
|
368
|
-
dev: "
|
|
369
|
-
build: "
|
|
370
|
-
start: "
|
|
376
|
+
dev: "fiyuu dev",
|
|
377
|
+
build: "fiyuu build",
|
|
378
|
+
start: "fiyuu start",
|
|
371
379
|
},
|
|
372
380
|
dependencies: {
|
|
373
|
-
|
|
381
|
+
"@fiyuu/cli": cliDependency,
|
|
382
|
+
"@fiyuu/core": coreDependency,
|
|
383
|
+
"@fiyuu/runtime": runtimeDependency,
|
|
384
|
+
"@fiyuu/db": dbDependency,
|
|
385
|
+
"@fiyuu/realtime": realtimeDependency,
|
|
374
386
|
"@geajs/core": "^1.1.3",
|
|
375
|
-
...(includeSockets ? { ws: "^8.18.1" } : {}),
|
|
376
387
|
zod: "^3.24.2",
|
|
377
388
|
},
|
|
378
389
|
devDependencies: {
|
|
379
390
|
"@types/node": "^22.13.10",
|
|
380
|
-
|
|
391
|
+
typescript: "^5.8.2",
|
|
381
392
|
},
|
|
382
393
|
},
|
|
383
394
|
null,
|
|
@@ -430,8 +441,8 @@ Generated with create-fiyuu-app.
|
|
|
430
441
|
- npm run dev
|
|
431
442
|
- npm run build
|
|
432
443
|
- npm run start
|
|
433
|
-
-
|
|
434
|
-
-
|
|
444
|
+
- npx fiyuu feat list
|
|
445
|
+
- npx fiyuu feat socket on|off
|
|
435
446
|
|
|
436
447
|
## Starter Routes
|
|
437
448
|
|