wildpig 1.0.5 → 1.0.7
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 +5 -6
- package/scripts/WildPig.ts +1 -1
- package/scripts/prebuild.ts +5 -3
- package/scripts/run-prebuild.ts +2 -0
- package/src/router/guard.tsx +0 -1
- package/bin/wildpig.js +0 -17
- package/tsconfig.json +0 -15
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.7",
|
|
3
3
|
"scripts": {
|
|
4
4
|
"dev": "export NODE_ENV=development && bun --hot run index.ts",
|
|
5
|
-
"prebuild": "bun run scripts/prebuild.ts",
|
|
5
|
+
"prebuild": "bun run scripts/run-prebuild.ts",
|
|
6
|
+
|
|
6
7
|
"build": "export NODE_ENV=production && bun run prebuild && bun build --compile ./index.ts --outfile dist/wildpig",
|
|
7
8
|
"build-linux-musl": "export NODE_ENV=production && bun build --compile --target=bun-linux-x64-musl ./index.ts --outfile dist/wildpig",
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"docker:run": "docker run -itd -p 3000:3000 wildpig",
|
|
11
|
-
"testbin": "wildpig dev"
|
|
9
|
+
|
|
10
|
+
"start": "cd dist && ./wildpig"
|
|
12
11
|
},
|
|
13
12
|
"dependencies": {
|
|
14
13
|
"@react-router/dev": "^7.10.1",
|
package/scripts/WildPig.ts
CHANGED
|
@@ -31,7 +31,7 @@ export const startServer = () => {
|
|
|
31
31
|
const metaRes = await metaRoutes[pathname]();
|
|
32
32
|
meta = await metaRes.json();
|
|
33
33
|
}
|
|
34
|
-
return new Response(htmlString.replace("{{TITLE}}", meta?.title || "
|
|
34
|
+
return new Response(htmlString.replace("{{TITLE}}", meta?.title || "WildPig"), {
|
|
35
35
|
headers: {
|
|
36
36
|
"content-type": "text/html; charset=utf-8",
|
|
37
37
|
"Access-Control-Allow-Origin": "*",
|
package/scripts/prebuild.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { genMetaRoutes, genRoutes } from "./genRoutes";
|
|
2
2
|
import { packageStatic } from "./packageStatic";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
await
|
|
6
|
-
await
|
|
4
|
+
export const prebuild = async () => {
|
|
5
|
+
await packageStatic();
|
|
6
|
+
await genRoutes();
|
|
7
|
+
await genMetaRoutes();
|
|
8
|
+
}
|
package/src/router/guard.tsx
CHANGED
|
@@ -5,7 +5,6 @@ export const RouterGuard = () => {
|
|
|
5
5
|
browserRouter.subscribe(({ location }) => {
|
|
6
6
|
// navigationType 值:'PUSH' | 'POP' | 'REPLACE'
|
|
7
7
|
const url = location.pathname + location.search;
|
|
8
|
-
console.log('[router] url=', url);
|
|
9
8
|
// apiGetMeta(location.pathname);
|
|
10
9
|
// 请求对应的meta api,修改title
|
|
11
10
|
fetch("/_WILDPIG_META_API" + url).then(res => res.json()).then(({title}) => {
|
package/bin/wildpig.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { spawn } from "child_process";
|
|
4
|
-
|
|
5
|
-
// 子命令
|
|
6
|
-
const cmd = process.argv[2]; // dev / build / ...
|
|
7
|
-
if (!cmd) {
|
|
8
|
-
console.error('Usage: wildpig dev|build|start');
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// 跑到包自身目录去 npm run xxx
|
|
13
|
-
spawn('bun', ['run', cmd], {
|
|
14
|
-
stdio: 'inherit',
|
|
15
|
-
shell: true,
|
|
16
|
-
cwd: "." // 指向 wp 包根目录
|
|
17
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"jsx": "react-jsx",
|
|
9
|
-
"baseUrl": ".",
|
|
10
|
-
"paths": {
|
|
11
|
-
"@/*": ["src/*"],
|
|
12
|
-
"#/*": ["*"]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|