@ubean/cli 0.3.2 → 0.3.4
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/dist/cli.js +17 -1
- package/package.json +12 -11
package/dist/cli.js
CHANGED
|
@@ -20,6 +20,7 @@ import vue from "@vitejs/plugin-vue";
|
|
|
20
20
|
import { ubeanPlugin } from "@ubean/build/vite";
|
|
21
21
|
import { VUE_PLUGIN_INCLUDE, ubeanVite } from "@ubean/build/vue";
|
|
22
22
|
import { createVueRenderer } from "@ubean/client/ssr";
|
|
23
|
+
import { getVueLocaleParam, toVueRouterLocalePath } from "@ubean/i18n";
|
|
23
24
|
import { ubeanIslandsPlugin } from "@ubean/islands/vite";
|
|
24
25
|
import { findAvailablePort, findUserViteConfig, waitForPort } from "@ubean/shared/node";
|
|
25
26
|
import { execSync, spawn } from "node:child_process";
|
|
@@ -446,6 +447,19 @@ const buildCommand = {
|
|
|
446
447
|
//#endregion
|
|
447
448
|
//#region src/dev-server/vite-server.ts
|
|
448
449
|
const logger$8 = getLogger("dev-server");
|
|
450
|
+
/**
|
|
451
|
+
* Compute the vue-router locale param (e.g. `:locale(zh)?`) from the resolved
|
|
452
|
+
* i18n routing config, mirroring `localeVueParamFromI18n` (`@ubean/build`).
|
|
453
|
+
* Returns `''` when i18n is disabled or no prefix is needed.
|
|
454
|
+
*/
|
|
455
|
+
function resolveLocaleVueParam(config) {
|
|
456
|
+
if (!config?.enabled || !config.locales?.length) return "";
|
|
457
|
+
return getVueLocaleParam({
|
|
458
|
+
defaultLocale: config.defaultLocale,
|
|
459
|
+
locales: config.locales.map((l) => l.code),
|
|
460
|
+
strategy: config.strategy
|
|
461
|
+
});
|
|
462
|
+
}
|
|
449
463
|
async function toWebRequest(req, host, protocol) {
|
|
450
464
|
const url = `${protocol}://${req.headers.host || host}${req.url || "/"}`;
|
|
451
465
|
const headers = new Headers();
|
|
@@ -713,12 +727,14 @@ async function createViteDevServer(options) {
|
|
|
713
727
|
return;
|
|
714
728
|
}
|
|
715
729
|
const scannedPages = app.options.pages || [];
|
|
730
|
+
const ssrLocaleParam = resolveLocaleVueParam(config.i18n);
|
|
716
731
|
const scannedPageByName = /* @__PURE__ */ new Map();
|
|
717
732
|
for (const p of scannedPages) scannedPageByName.set(p.name, p);
|
|
718
733
|
const routes = scannedPages.map((p) => {
|
|
719
734
|
const componentFullPath = (p.isReuse && p.reuseTarget ? scannedPageByName.get(p.reuseTarget) : void 0)?.fullPath || p.fullPath;
|
|
735
|
+
const routePath = p.route.replace(/\*\*:(\w[\w-]*)/g, ":$1(.*)*");
|
|
720
736
|
return {
|
|
721
|
-
path:
|
|
737
|
+
path: ssrLocaleParam ? toVueRouterLocalePath(routePath, ssrLocaleParam) : routePath,
|
|
722
738
|
name: p.name,
|
|
723
739
|
component: async () => {
|
|
724
740
|
const mod = await viteServer.ssrLoadModule(componentFullPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubean/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "CLI for ubean (ubean-next binary: dev, build, prepare, init, preview, page, env, config, devtools, api/layout/middleware/cron/plugin scaffolds) plus the Vite dev server runner",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ubean-next": "./bin/ubean-next.mjs"
|
|
@@ -24,14 +24,15 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ubean/app": "0.3.
|
|
28
|
-
"@ubean/build": "0.3.
|
|
29
|
-
"@ubean/client": "0.3.
|
|
30
|
-
"@ubean/config": "0.3.
|
|
31
|
-
"@ubean/
|
|
32
|
-
"@ubean/
|
|
33
|
-
"@ubean/
|
|
34
|
-
"@ubean/
|
|
27
|
+
"@ubean/app": "0.3.4",
|
|
28
|
+
"@ubean/build": "0.3.4",
|
|
29
|
+
"@ubean/client": "0.3.4",
|
|
30
|
+
"@ubean/config": "0.3.4",
|
|
31
|
+
"@ubean/i18n": "0.3.4",
|
|
32
|
+
"@ubean/islands": "0.3.4",
|
|
33
|
+
"@ubean/preset": "0.3.4",
|
|
34
|
+
"@ubean/scan": "0.3.4",
|
|
35
|
+
"@ubean/shared": "0.3.4",
|
|
35
36
|
"citty": "^0.2.2",
|
|
36
37
|
"kolorist": "^1.8.0",
|
|
37
38
|
"pathe": "^2.0.3"
|
|
@@ -44,8 +45,8 @@
|
|
|
44
45
|
"vite-plus": "0.3.0"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@ubean/content": "0.3.
|
|
48
|
-
"@ubean/devtools": "0.3.
|
|
48
|
+
"@ubean/content": "0.3.4",
|
|
49
|
+
"@ubean/devtools": "0.3.4",
|
|
49
50
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
50
51
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.0"
|
|
51
52
|
},
|