wildpig 1.1.6 → 1.3.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/bin/cli.ts +40 -0
- package/build/built-api-routes.ts +30 -0
- package/bun.lock +6 -0
- package/package.json +11 -7
- package/public/devHtml.html +12 -0
- package/public/render.js +28162 -0
- package/public/render.tsx +22 -6
- package/router/ServerDataGuard.tsx +38 -0
- package/router/index.ts +15 -0
- package/router/types.ts +7 -0
- package/scripts/WildPig.tsx +104 -0
- package/scripts/apiRoutes.ts +98 -0
- package/scripts/build.ts +23 -0
- package/scripts/packageStatic.ts +4 -2
- package/scripts/server.ts +38 -0
- package/store/serverDataStore.tsx +4 -0
- package/build/built-meta-routes.ts +0 -4
- package/build/built-routes.ts +0 -9
- package/index.ts +0 -3
- package/public/devIndex.html +0 -13
- package/public/index.html +0 -17
- package/router/MetaGuard.tsx +0 -38
- package/scripts/WildPig.ts +0 -74
- package/scripts/genRoutes.ts +0 -99
- package/scripts/htmlString.ts +0 -2
- package/scripts/prebuild.ts +0 -8
- package/scripts/prepareRoutes.ts +0 -28
- package/scripts/run-prebuild.ts +0 -2
package/bin/cli.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { build } from "../scripts/build";
|
|
3
|
+
import { spawn } from "bun";
|
|
4
|
+
const command = process.argv[2];
|
|
5
|
+
|
|
6
|
+
if(command === "start"){
|
|
7
|
+
// 设置一些环境变量
|
|
8
|
+
process.env.NODE_ENV = "production";
|
|
9
|
+
console.log(chalk.green("✨ [Wildpig] Start production server..."));
|
|
10
|
+
const st = performance.now();
|
|
11
|
+
// 启动二进制文件
|
|
12
|
+
spawn(["server"], {
|
|
13
|
+
cwd: "./dist",
|
|
14
|
+
stdout: "inherit",
|
|
15
|
+
env: {
|
|
16
|
+
...process.env
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const ed = performance.now();
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
console.log(chalk.green("✨ [Wildpig] Production server started in " + Math.floor(ed - st) + "ms"));
|
|
22
|
+
}, 300);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if(command === "dev"){
|
|
27
|
+
// 设置一些环境变量
|
|
28
|
+
process.env.NODE_ENV = "development";
|
|
29
|
+
await import("../scripts/server");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if(command === "build"){
|
|
34
|
+
// 设置一些环境变量
|
|
35
|
+
process.env.NODE_ENV = "production";
|
|
36
|
+
const st = performance.now();
|
|
37
|
+
await build();
|
|
38
|
+
console.log(chalk.green("🐗 [Wildpig] Build done, time:"), chalk.blue(performance.now() - st, "ms"));
|
|
39
|
+
console.log(chalk.green(`✨ [Wildpig] Start by command:`), chalk.blue(`bun run start`));
|
|
40
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { middleware } from "@/api/middleware"
|
|
2
|
+
import {
|
|
3
|
+
GET as GET1,
|
|
4
|
+
POST as POST1,
|
|
5
|
+
} from "#/src/api/hello/index";
|
|
6
|
+
import {
|
|
7
|
+
GET as GET2,
|
|
8
|
+
} from "#/src/api/hello/[id]/index";
|
|
9
|
+
import {
|
|
10
|
+
GET as GET3,
|
|
11
|
+
} from "#/src/api/server-data/hello/[id]/index";
|
|
12
|
+
import {
|
|
13
|
+
GET as GET4,
|
|
14
|
+
} from "#/src/api/server-data/home/index";
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
"/api/hello": {
|
|
18
|
+
GET: (req: any) => middleware(req, GET1),
|
|
19
|
+
POST: (req: any) => middleware(req, POST1),
|
|
20
|
+
},
|
|
21
|
+
"/api/hello/:id": {
|
|
22
|
+
GET: (req: any) => middleware(req, GET2),
|
|
23
|
+
},
|
|
24
|
+
"/api/server-data/hello/:id": {
|
|
25
|
+
GET: (req: any) => middleware(req, GET3),
|
|
26
|
+
},
|
|
27
|
+
"/api/server-data/home": {
|
|
28
|
+
GET: (req: any) => middleware(req, GET4),
|
|
29
|
+
},
|
|
30
|
+
}
|
package/bun.lock
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
"": {
|
|
6
6
|
"name": "wildpig",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@nanostores/react": "^1.0.0",
|
|
8
9
|
"@types/bun": "^1.3.4",
|
|
9
10
|
"@types/react": "^19.2.7",
|
|
10
11
|
"@types/react-dom": "^19.2.3",
|
|
11
12
|
"chalk": "^5.6.2",
|
|
13
|
+
"nanostores": "^1.1.0",
|
|
12
14
|
"react": "^19.2.3",
|
|
13
15
|
"react-dom": "^19.2.3",
|
|
14
16
|
"react-router": "^7.10.1",
|
|
@@ -16,6 +18,8 @@
|
|
|
16
18
|
},
|
|
17
19
|
},
|
|
18
20
|
"packages": {
|
|
21
|
+
"@nanostores/react": ["@nanostores/react@1.0.0", "", { "peerDependencies": { "nanostores": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^1.0.0", "react": ">=18.0.0" } }, "sha512-eDduyNy+lbQJMg6XxZ/YssQqF6b4OXMFEZMYKPJCCmBevp1lg0g+4ZRi94qGHirMtsNfAWKNwsjOhC+q1gvC+A=="],
|
|
22
|
+
|
|
19
23
|
"@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="],
|
|
20
24
|
|
|
21
25
|
"@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="],
|
|
@@ -32,6 +36,8 @@
|
|
|
32
36
|
|
|
33
37
|
"csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
|
|
34
38
|
|
|
39
|
+
"nanostores": ["nanostores@1.1.0", "", {}, "sha512-yJBmDJr18xy47dbNVlHcgdPrulSn1nhSE6Ns9vTG+Nx9VPT6iV1MD6aQFp/t52zpf82FhLLTXAXr30NuCnxvwA=="],
|
|
40
|
+
|
|
35
41
|
"react": ["react@19.2.3", "", {}, "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA=="],
|
|
36
42
|
|
|
37
43
|
"react-dom": ["react-dom@19.2.3", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.3" } }, "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg=="],
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wildpig",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"author": "eriktse",
|
|
5
5
|
"main": "index.ts",
|
|
6
|
+
"bin":{
|
|
7
|
+
"wildpig": "./bin/cli.ts"
|
|
8
|
+
},
|
|
6
9
|
"dependencies": {
|
|
10
|
+
"@nanostores/react": "^1.0.0",
|
|
7
11
|
"@types/bun": "^1.3.4",
|
|
8
12
|
"@types/react": "^19.2.7",
|
|
9
13
|
"@types/react-dom": "^19.2.3",
|
|
10
14
|
"chalk": "^5.6.2",
|
|
15
|
+
"nanostores": "^1.1.0",
|
|
11
16
|
"react": "^19.2.3",
|
|
12
17
|
"react-dom": "^19.2.3",
|
|
13
18
|
"react-router": "^7.10.1"
|
|
@@ -16,14 +21,13 @@
|
|
|
16
21
|
"keywords": [
|
|
17
22
|
"fullstack",
|
|
18
23
|
"web",
|
|
19
|
-
"framework"
|
|
24
|
+
"framework",
|
|
25
|
+
"react"
|
|
20
26
|
],
|
|
21
27
|
"license": "ISC",
|
|
22
28
|
"scripts": {
|
|
23
|
-
"dev": "
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"build-linux-musl": "export NODE_ENV=production && bun build --compile --target=bun-linux-x64-musl ./test.ts --outfile dist/wildpig",
|
|
27
|
-
"start": "cd dist && ./wildpig"
|
|
29
|
+
"dev": "wildpig dev",
|
|
30
|
+
"build": "wildpig build",
|
|
31
|
+
"start": "wildpig start"
|
|
28
32
|
}
|
|
29
33
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>WildPig 开发环境</title>
|
|
7
|
+
<script src="./render.tsx"></script>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|