@ubean/scan 0.3.6 → 0.4.0
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/index.js +19 -3
- package/dist/types.d.ts +14 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GLOB_SCAN_PATTERN, HTTP_METHODS } from "./types.js";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
3
3
|
import { getLogger } from "@ubean/shared/logger";
|
|
4
4
|
import { extractCallObject, extractDefinePage, extractDefinePageFromCode, extractSlotAndIntercept, filePathToRoute, filePathToRoute as filePathToRoute$1, generateLayoutName, generateRouteName, generateRouteName as generateRouteName$1, parseMatchers, scanPages, stripRouteGroups } from "@ubean/vue/vite";
|
|
5
5
|
import { basename, dirname, extname, isAbsolute, join, relative } from "pathe";
|
|
@@ -469,14 +469,30 @@ async function scanAppEntry(srcDir) {
|
|
|
469
469
|
}
|
|
470
470
|
return { exists: false };
|
|
471
471
|
};
|
|
472
|
-
const
|
|
472
|
+
const scanRootApp = async () => {
|
|
473
|
+
let entries;
|
|
474
|
+
try {
|
|
475
|
+
entries = await readdir(srcDir);
|
|
476
|
+
} catch {
|
|
477
|
+
return { exists: false };
|
|
478
|
+
}
|
|
479
|
+
for (const name of ["app.vue", "App.vue"]) if (entries.includes(name)) return {
|
|
480
|
+
exists: true,
|
|
481
|
+
fullPath: join(srcDir, name),
|
|
482
|
+
relativePath: name
|
|
483
|
+
};
|
|
484
|
+
return { exists: false };
|
|
485
|
+
};
|
|
486
|
+
const [shared, server, client, root] = await Promise.all([
|
|
473
487
|
findEntry("app"),
|
|
474
488
|
findEntry("app.server"),
|
|
475
|
-
findEntry("app.client")
|
|
489
|
+
findEntry("app.client"),
|
|
490
|
+
scanRootApp()
|
|
476
491
|
]);
|
|
477
492
|
result.shared = shared;
|
|
478
493
|
result.server = server;
|
|
479
494
|
result.client = client;
|
|
495
|
+
if (root.exists) result.root = root;
|
|
480
496
|
return result;
|
|
481
497
|
}
|
|
482
498
|
async function scanServerEntry(srcDir) {
|
package/dist/types.d.ts
CHANGED
|
@@ -60,6 +60,20 @@ interface ScannedAppEntry {
|
|
|
60
60
|
shared: AppEntry;
|
|
61
61
|
server: AppEntry;
|
|
62
62
|
client: AppEntry;
|
|
63
|
+
/**
|
|
64
|
+
* `src/app.vue` / `src/App.vue` — 应用根组件(包装组件,可选)。
|
|
65
|
+
*
|
|
66
|
+
* 两种命名都支持(经典 Vue `App.vue` 大写约定 / Nuxt 风格小写
|
|
67
|
+
* `app.vue`),仅 `.vue` 扩展(defineApp 配置入口 `app.ts`/
|
|
68
|
+
* `app.server.ts`/`app.client.ts` 已占用 ts/js 命名)。若两者同时存在,
|
|
69
|
+
* **小写 `app.vue` 优先**(与配置入口共用 `app` 词根,扩展名不同可共存)。
|
|
70
|
+
*
|
|
71
|
+
* 当用户显式配置 `defineApp({ appRoot })` 时,该文件作为回退
|
|
72
|
+
* (优先级:`defineApp({ appRoot })` > `src/app.vue` > `src/App.vue`)。
|
|
73
|
+
* 组件渲染约定:框架出口(布局链 + 页面)通过默认 slot 注入,组件内用
|
|
74
|
+
* `<slot />` 声明渲染位置。
|
|
75
|
+
*/
|
|
76
|
+
root?: AppEntry;
|
|
63
77
|
}
|
|
64
78
|
interface ScannedServerEntry {
|
|
65
79
|
shared: AppEntry;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubean/scan",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Project scanner & route metadata for ubean — server-side directory scanning (API routes, middleware, plugins, crons, queues, locales, entries) plus page scanning delegated to @ubean/vue",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ubean/shared": "0.
|
|
28
|
-
"@ubean/vue": "0.
|
|
27
|
+
"@ubean/shared": "0.4.0",
|
|
28
|
+
"@ubean/vue": "0.4.0",
|
|
29
29
|
"pathe": "^2.0.3",
|
|
30
30
|
"tinyglobby": "^0.2.17"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^26.4.0",
|
|
34
|
-
"@ubean/markdown": "0.
|
|
34
|
+
"@ubean/markdown": "0.4.0",
|
|
35
35
|
"typescript": "7.0.2",
|
|
36
36
|
"vite-plus": "0.3.0",
|
|
37
37
|
"vue": "^3.5.42",
|