@ubean/cli 0.3.3 → 0.3.5
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 +19 -3
- package/dist/index.js +1 -1
- package/dist/{page-BRUWKaig.js → page-sFQRjxXM.js} +3 -9
- package/package.json +12 -11
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as summarizeBundle, D as compareBundleBaseline, E as createFsOps, O as findClientManifest, S as renderTemplate, a as scaffold, c as scaffoldStarterTemplate, i as recoverScaffold, j as writeBundleBaseline, k as readViteManifest, l as scaffoldUnifyTemplate, n as listScaffoldableFiles, o as scaffoldBlogTemplate, r as pageCommand, s as scaffoldMinimalTemplate, t as deleteScaffold } from "./page-
|
|
1
|
+
import { A as summarizeBundle, D as compareBundleBaseline, E as createFsOps, O as findClientManifest, S as renderTemplate, a as scaffold, c as scaffoldStarterTemplate, i as recoverScaffold, j as writeBundleBaseline, k as readViteManifest, l as scaffoldUnifyTemplate, n as listScaffoldableFiles, o as scaffoldBlogTemplate, r as pageCommand, s as scaffoldMinimalTemplate, t as deleteScaffold } from "./page-sFQRjxXM.js";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, watch } from "node:fs";
|
|
3
3
|
import { basename, join, relative, resolve } from "pathe";
|
|
4
4
|
import { extname, normalize } from "node:path";
|
|
@@ -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);
|
|
@@ -1215,7 +1231,7 @@ async function buildApp(cwd, config) {
|
|
|
1215
1231
|
seoConventions: { srcDir: resolve(cwd, config.srcDir) }
|
|
1216
1232
|
});
|
|
1217
1233
|
app.hooks.hook("request:start", (c) => {
|
|
1218
|
-
logger$6.
|
|
1234
|
+
logger$6.debug(`${c.req.method} ${c.req.path}`);
|
|
1219
1235
|
});
|
|
1220
1236
|
return {
|
|
1221
1237
|
app,
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { n as getScaffoldManifest, t as SCAFFOLD_CONTRACT_VERSION } from "./scaffold-manifest-TrH6OCX8.js";
|
|
2
|
-
import { A as summarizeBundle, C as toCamelCase, D as compareBundleBaseline, E as createFsOps, O as findClientManifest, S as renderTemplate, T as toPascalCase, _ as renderCronTemplate, a as scaffold, b as renderPageTemplate, d as CRON_TEMPLATE, f as LAYOUT_TEMPLATE, g as renderApiTemplate, h as PLUGIN_TEMPLATE, i as recoverScaffold, j as writeBundleBaseline, k as readViteManifest, m as PAGE_TEMPLATE, n as listScaffoldableFiles, p as MIDDLEWARE_TEMPLATE, t as deleteScaffold, u as API_TEMPLATE, v as renderLayoutTemplate, w as toKebabCase, x as renderPluginTemplate, y as renderMiddlewareTemplate } from "./page-
|
|
2
|
+
import { A as summarizeBundle, C as toCamelCase, D as compareBundleBaseline, E as createFsOps, O as findClientManifest, S as renderTemplate, T as toPascalCase, _ as renderCronTemplate, a as scaffold, b as renderPageTemplate, d as CRON_TEMPLATE, f as LAYOUT_TEMPLATE, g as renderApiTemplate, h as PLUGIN_TEMPLATE, i as recoverScaffold, j as writeBundleBaseline, k as readViteManifest, m as PAGE_TEMPLATE, n as listScaffoldableFiles, p as MIDDLEWARE_TEMPLATE, t as deleteScaffold, u as API_TEMPLATE, v as renderLayoutTemplate, w as toKebabCase, x as renderPluginTemplate, y as renderMiddlewareTemplate } from "./page-sFQRjxXM.js";
|
|
3
3
|
export { API_TEMPLATE, CRON_TEMPLATE, LAYOUT_TEMPLATE, MIDDLEWARE_TEMPLATE, PAGE_TEMPLATE, PLUGIN_TEMPLATE, SCAFFOLD_CONTRACT_VERSION, compareBundleBaseline, createFsOps, deleteScaffold, findClientManifest, getScaffoldManifest, listScaffoldableFiles, readViteManifest, recoverScaffold, renderApiTemplate, renderCronTemplate, renderLayoutTemplate, renderMiddlewareTemplate, renderPageTemplate, renderPluginTemplate, renderTemplate, scaffold, summarizeBundle, toCamelCase, toKebabCase, toPascalCase, writeBundleBaseline };
|
|
@@ -577,17 +577,11 @@ const SERVER_TS = [
|
|
|
577
577
|
"import { defineServer } from 'ubean/runtime/app';",
|
|
578
578
|
"",
|
|
579
579
|
"export default defineServer({",
|
|
580
|
-
" // 运行时钩子",
|
|
581
|
-
" hooks: {",
|
|
582
|
-
" 'request:start': c => {",
|
|
583
|
-
" console.log(`[server] ${c.req.method} ${c.req.path}`);",
|
|
584
|
-
" }",
|
|
585
|
-
" },",
|
|
580
|
+
" // 运行时钩子(dev 下请求日志已由 CLI 输出,如需自定义可在此添加)",
|
|
581
|
+
" hooks: {},",
|
|
586
582
|
"",
|
|
587
583
|
" // 在 app.init() 后调用",
|
|
588
|
-
" onServerReady: async _app => {",
|
|
589
|
-
" console.log('[server] Server is ready');",
|
|
590
|
-
" }",
|
|
584
|
+
" onServerReady: async _app => {}",
|
|
591
585
|
"});",
|
|
592
586
|
""
|
|
593
587
|
].join("\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubean/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
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.5",
|
|
28
|
+
"@ubean/build": "0.3.5",
|
|
29
|
+
"@ubean/client": "0.3.5",
|
|
30
|
+
"@ubean/config": "0.3.5",
|
|
31
|
+
"@ubean/i18n": "0.3.5",
|
|
32
|
+
"@ubean/islands": "0.3.5",
|
|
33
|
+
"@ubean/preset": "0.3.5",
|
|
34
|
+
"@ubean/scan": "0.3.5",
|
|
35
|
+
"@ubean/shared": "0.3.5",
|
|
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.5",
|
|
49
|
+
"@ubean/devtools": "0.3.5",
|
|
49
50
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
50
51
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.0"
|
|
51
52
|
},
|