@ubean/cli 0.3.4 → 0.3.6

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 CHANGED
@@ -1,8 +1,8 @@
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-BRUWKaig.js";
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
- import { extname, normalize } from "node:path";
5
- import { getLogger } from "@ubean/shared/logger";
4
+ import { extname, normalize, sep } from "node:path";
5
+ import { getLogger, setDebugLogging } from "@ubean/shared/logger";
6
6
  import { defineCommand, runMain } from "citty";
7
7
  import { BUILTIN_MODULES, isBuiltinDisabled, loadUbeanConfig, resolveModules, resolvePrerenderConfig, resolveSsrConfig } from "@ubean/config";
8
8
  import { readFile, rm, stat } from "node:fs/promises";
@@ -1123,17 +1123,14 @@ const devCommand = {
1123
1123
  },
1124
1124
  onListen({ url }) {
1125
1125
  const label = (text) => dim(text);
1126
- const lines = [
1127
- `${green(bold("🚀 ubean dev server ready"))}\n`,
1128
- ` → ${label("Local:")} ${cyan(url)}`,
1129
- ` → ${label("Scalar UI:")} ${cyan(`${url}/_scalar`)}`,
1130
- ` → ${label("OpenAPI:")} ${cyan(`${url}/_openapi.json`)}`
1131
- ];
1126
+ const lines = [`${green(bold("🚀 ubean dev server ready"))}\n`, ` → ${label("Local:")} ${cyan(url)}`];
1127
+ const hasBackend = config.mode !== "ssg" && config.mode !== "spa";
1128
+ if (hasBackend) lines.push(` → ${label("Scalar UI:")} ${cyan(`${url}/_scalar`)}`, ` → ${label("OpenAPI:")} ${cyan(`${url}/_openapi.json`)}`);
1132
1129
  if (config.devtools.enabled) lines.push(` → ${label("DevTools:")} ${cyan(`${url}${config.devtools.route}`)}`);
1133
1130
  lines.push(` → ${dim("Press Ctrl+C to stop")}`);
1134
1131
  logger$6.info(lines.join("\n"));
1135
- generateOpenApiTypesFromServer(url, { outDir: resolve(cwd, ".ubean") }).then((filePath) => {
1136
- logger$6.info(`OpenAPI types generated: ${filePath}`);
1132
+ if (hasBackend) generateOpenApiTypesFromServer(url, { outDir: resolve(cwd, ".ubean") }).then((filePath) => {
1133
+ if (filePath) logger$6.info(`OpenAPI types generated: ${filePath}`);
1137
1134
  }).catch((err) => {
1138
1135
  logger$6.warn(`Failed to generate OpenAPI types: ${err instanceof Error ? err.message : String(err)}`);
1139
1136
  });
@@ -1231,7 +1228,7 @@ async function buildApp(cwd, config) {
1231
1228
  seoConventions: { srcDir: resolve(cwd, config.srcDir) }
1232
1229
  });
1233
1230
  app.hooks.hook("request:start", (c) => {
1234
- logger$6.info(`${c.req.method} ${c.req.path}`);
1231
+ logger$6.debug(`${c.req.method} ${c.req.path}`);
1235
1232
  });
1236
1233
  return {
1237
1234
  app,
@@ -1980,13 +1977,14 @@ function startStaticServer(opts) {
1980
1977
  return createServer(async (req, res) => {
1981
1978
  try {
1982
1979
  const url = new URL(req.url || "/", `http://${host}`);
1983
- let pathname = normalize(decodeURIComponent(url.pathname));
1984
- if (pathname.includes("..")) {
1980
+ const pathname = decodeURIComponent(url.pathname);
1981
+ let filePath = normalize(join(root, pathname));
1982
+ const rootPath = resolve(root);
1983
+ if (filePath !== rootPath && !filePath.startsWith(rootPath + sep)) {
1985
1984
  res.statusCode = 400;
1986
1985
  res.end("Bad Request");
1987
1986
  return;
1988
1987
  }
1989
- let filePath = join(root, pathname);
1990
1988
  let fileExists = existsSync(filePath) && (await stat(filePath)).isFile();
1991
1989
  if (!fileExists && existsSync(filePath) && (await stat(filePath)).isDirectory()) {
1992
1990
  const indexPath = join(filePath, "index.html");
@@ -2419,6 +2417,7 @@ const main = defineCommand({
2419
2417
  analyze: analyzeCommand
2420
2418
  }
2421
2419
  });
2420
+ if (process.argv.includes("--debug")) setDebugLogging(true);
2422
2421
  runMain(main);
2423
2422
  //#endregion
2424
2423
  export {};
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-BRUWKaig.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-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.4",
3
+ "version": "0.3.6",
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,15 +24,15 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
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",
27
+ "@ubean/app": "0.3.6",
28
+ "@ubean/build": "0.3.6",
29
+ "@ubean/client": "0.3.6",
30
+ "@ubean/config": "0.3.6",
31
+ "@ubean/i18n": "0.3.6",
32
+ "@ubean/islands": "0.3.6",
33
+ "@ubean/preset": "0.3.6",
34
+ "@ubean/scan": "0.3.6",
35
+ "@ubean/shared": "0.3.6",
36
36
  "citty": "^0.2.2",
37
37
  "kolorist": "^1.8.0",
38
38
  "pathe": "^2.0.3"
@@ -45,8 +45,8 @@
45
45
  "vite-plus": "0.3.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@ubean/content": "0.3.4",
49
- "@ubean/devtools": "0.3.4",
48
+ "@ubean/content": "0.3.6",
49
+ "@ubean/devtools": "0.3.6",
50
50
  "@vitejs/plugin-vue": "^6.0.8",
51
51
  "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0"
52
52
  },