@ubean/cli 0.3.5 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +12 -13
  2. package/package.json +12 -12
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
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
  });
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubean/cli",
3
- "version": "0.3.5",
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.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",
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.5",
49
- "@ubean/devtools": "0.3.5",
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
  },