@lark-apaas/coding-templates 0.1.24 → 0.1.26
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
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"build": "bash scripts/build.sh",
|
|
17
17
|
"lint": "npm run lint:client && npm run lint:server",
|
|
18
18
|
"lint:client": "eslint client/src",
|
|
19
|
-
"lint:server": "eslint server"
|
|
19
|
+
"lint:server": "eslint server",
|
|
20
|
+
"gen:db-schema": "npx -y @lark-apaas/db-schema-sync@latest --output server/db/schema.ts"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"@hookform/resolvers": "^5.2.2",
|
|
@@ -47,7 +48,8 @@
|
|
|
47
48
|
"@radix-ui/react-toggle-group": "^1.1.10",
|
|
48
49
|
"@radix-ui/react-tooltip": "^1.1.18",
|
|
49
50
|
"@lark-apaas/client-toolkit-lite": "^0.0.2",
|
|
50
|
-
"@lark-apaas/express-core": "^0.0.
|
|
51
|
+
"@lark-apaas/express-core": "^0.0.6",
|
|
52
|
+
"@lark-apaas/express-datapaas": "^0.0.3",
|
|
51
53
|
"@formkit/auto-animate": "^0.9.0",
|
|
52
54
|
"framer-motion": "^12.38.0",
|
|
53
55
|
"class-variance-authority": "^0.7.1",
|
|
@@ -87,5 +89,11 @@
|
|
|
87
89
|
"tsx": "^4",
|
|
88
90
|
"typescript": "~5.9",
|
|
89
91
|
"vite": "^8"
|
|
92
|
+
},
|
|
93
|
+
"pnpm": {
|
|
94
|
+
"onlyBuiltDependencies": [
|
|
95
|
+
"@lark-apaas/express-datapaas",
|
|
96
|
+
"esbuild"
|
|
97
|
+
]
|
|
90
98
|
}
|
|
91
99
|
}
|
|
@@ -32,7 +32,9 @@ echo '{ "version": 1, "type": "apex", "fallback": "index.html" }' > "$OUTPUT/rou
|
|
|
32
32
|
# 服务端产物(tsc 输出保留 server/、shared/ 子目录)
|
|
33
33
|
cp -r "$ROOT/dist/server/"* "$OUTPUT/"
|
|
34
34
|
|
|
35
|
-
#
|
|
35
|
+
# 声明 CJS(服务端 tsc 输出为 commonjs,需要覆盖根 package.json 的 "type": "module")
|
|
36
|
+
# deploy 时 prune 步骤会用精简版覆盖此文件
|
|
37
|
+
echo '{ "private": true }' > "$OUTPUT/package.json"
|
|
36
38
|
|
|
37
39
|
# 4. assets/ → dist/output_resource/(JS/CSS/字体,上传到 CDN)
|
|
38
40
|
if [ -d "$ROOT/dist/client/assets" ]; then
|
|
@@ -8,76 +8,42 @@ import { registerRoutes } from "./routes/index";
|
|
|
8
8
|
|
|
9
9
|
const port = Number(process.env.FORCE_SERVER_PORT) || 3000;
|
|
10
10
|
const host = process.env.FORCE_SERVER_HOST || "localhost";
|
|
11
|
-
const
|
|
11
|
+
const basePath = process.env.CLIENT_BASE_PATH || "/";
|
|
12
12
|
|
|
13
13
|
const app = express();
|
|
14
14
|
|
|
15
|
-
// Platform middleware
|
|
15
|
+
// Platform middleware
|
|
16
16
|
const { close } = setup(app, {
|
|
17
17
|
database: { schema },
|
|
18
18
|
csrf: { enabled: false },
|
|
19
19
|
viewContext: { enabled: false },
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
|
|
22
|
+
// All routes under basePath
|
|
23
|
+
const router = express.Router();
|
|
24
|
+
registerRoutes(router);
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (isDev) {
|
|
28
|
-
// @ts-ignore -- vite types require bundler moduleResolution, dev-only import
|
|
29
|
-
const { createServer } = await import("vite");
|
|
30
|
-
const vite = await createServer({
|
|
31
|
-
server: { middlewareMode: true },
|
|
32
|
-
appType: "custom",
|
|
33
|
-
});
|
|
26
|
+
const templatePath = path.resolve(__dirname, "../index.html");
|
|
27
|
+
const template = hbs.compile(fs.readFileSync(templatePath, "utf-8"));
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// HBS render: inject platform data
|
|
46
|
-
const template = hbs.compile(transformed);
|
|
47
|
-
const html = template({
|
|
48
|
-
...res.locals,
|
|
49
|
-
appConfig: safeStringify({
|
|
50
|
-
appId: res.locals.appId || process.env.MCLAW_APP_ID || "",
|
|
51
|
-
cdnDomain: process.env.MCLAW_CDN_DOMAIN || "",
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
res.type("html").send(html);
|
|
55
|
-
});
|
|
56
|
-
} else {
|
|
57
|
-
const templatePath = path.resolve(__dirname, "../index.html");
|
|
58
|
-
const template = hbs.compile(fs.readFileSync(templatePath, "utf-8"));
|
|
29
|
+
router.get("/{*path}", createViewContextMiddleware(), (_req: Request, res: Response) => {
|
|
30
|
+
const html = template({
|
|
31
|
+
...res.locals,
|
|
32
|
+
appConfig: safeStringify({
|
|
33
|
+
appId: res.locals.appId || process.env.MCLAW_APP_ID || "",
|
|
34
|
+
cdnDomain: process.env.MCLAW_CDN_DOMAIN || "",
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
res.type("html").send(html);
|
|
38
|
+
});
|
|
59
39
|
|
|
60
|
-
|
|
61
|
-
const html = template({
|
|
62
|
-
...res.locals,
|
|
63
|
-
appConfig: safeStringify({
|
|
64
|
-
appId: res.locals.appId || process.env.MCLAW_APP_ID || "",
|
|
65
|
-
cdnDomain: process.env.MCLAW_CDN_DOMAIN || "",
|
|
66
|
-
}),
|
|
67
|
-
});
|
|
68
|
-
res.type("html").send(html);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
40
|
+
app.use(basePath, router);
|
|
72
41
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
42
|
+
const server = app.listen(port, host, () => {
|
|
43
|
+
console.log(`Server running at http://${host}:${port}${basePath}`);
|
|
44
|
+
});
|
|
77
45
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
await close();
|
|
82
|
-
});
|
|
46
|
+
process.on("SIGTERM", async () => {
|
|
47
|
+
server.close();
|
|
48
|
+
await close();
|
|
83
49
|
});
|