@dongmingzhixiu/vuexir 0.1.0 → 0.1.2
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/config.js +11 -1
- package/dist/gen-ios.js +10 -3
- package/package.json +4 -4
package/dist/config.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* 兼容期:未提供 vrn.config 时,若 <root>/router.ts 或 <root>/App.vue 存在,按「目录即项目」处理;
|
|
10
10
|
* 仓库内开发(旧行为)通过 `--repo-root`(或 cwd 落在仓库内)解析到 examples/<name>。
|
|
11
11
|
*/
|
|
12
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
12
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
13
13
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
14
14
|
const CONFIG_FILES = ['vrn.config.ts', 'vrn.config.mts', 'vrn.config.js', 'vrn.config.mjs', 'vrn.config.json'];
|
|
15
15
|
/** 读取 vrn.config(json 直接解析;ts/mjs 用动态 import,失败则忽略并提示) */
|
|
@@ -49,6 +49,16 @@ export function resolveEntry(cfg) {
|
|
|
49
49
|
const candidates = [];
|
|
50
50
|
if (cfg.entry) {
|
|
51
51
|
const p = isAbsolute(cfg.entry) ? cfg.entry : join(cfg.projectRoot, cfg.entry);
|
|
52
|
+
// entry 允许直接给「目录」:自动补 router.ts / App.vue(CLI --entry 常见传法)
|
|
53
|
+
if (existsSync(p) && statSync(p).isDirectory()) {
|
|
54
|
+
const r = join(p, 'router.ts');
|
|
55
|
+
if (existsSync(r))
|
|
56
|
+
return { entry: r, multiPage: true };
|
|
57
|
+
const a = join(p, 'App.vue');
|
|
58
|
+
if (existsSync(a))
|
|
59
|
+
return { entry: a, multiPage: false };
|
|
60
|
+
throw new Error(`entry 目录内没有 router.ts / App.vue:${p}`);
|
|
61
|
+
}
|
|
52
62
|
if (existsSync(p))
|
|
53
63
|
return { entry: p, multiPage: p.endsWith('router.ts') || p.endsWith('router.js') };
|
|
54
64
|
throw new Error(`vrn.config.entry 指向的文件不存在:${p}`);
|
package/dist/gen-ios.js
CHANGED
|
@@ -21,7 +21,14 @@ import { generateScreenSource, generateComponentSource, collectTheme, buildTheme
|
|
|
21
21
|
import { vueToIr, VueCompileError } from '@dongmingzhixiu/vuexir-compiler';
|
|
22
22
|
// R-PKG:产物与样例根不再假设仓库布局(CLI 通过 VRN_OUT_DIR / VRN_SAMPLES_ROOT 注入)
|
|
23
23
|
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
|
|
24
|
-
|
|
24
|
+
// 安装形态下 <pkg>/dist/../../.. 不是仓库根,样例根不可靠 → 存在才用,否则退回 cwd(显式入口优先)
|
|
25
|
+
const SAMPLES_ROOT = (() => {
|
|
26
|
+
const fromEnv = process.env.VRN_SAMPLES_ROOT;
|
|
27
|
+
if (fromEnv)
|
|
28
|
+
return fromEnv;
|
|
29
|
+
const repoLike = join(ROOT, 'examples');
|
|
30
|
+
return existsSync(repoLike) ? repoLike : process.cwd();
|
|
31
|
+
})();
|
|
25
32
|
/** 工具链版本(manifest 记录;与 @dongmingzhixiu/vuexir 版本同步) */
|
|
26
33
|
const TOOLCHAIN_VERSION = '0.1.0';
|
|
27
34
|
/** 样例根(可写副本:generateIos 可用 opts.samplesRoot 覆盖) */
|
|
@@ -840,7 +847,7 @@ function main() {
|
|
|
840
847
|
function runMain(arg) {
|
|
841
848
|
// all:生成全部样例(compiler/samples/*/ 含 router.ts 的多页目录)
|
|
842
849
|
if (arg === 'all') {
|
|
843
|
-
const dirs = readdirSync(SAMPLES_ROOT_MUT, { withFileTypes: true })
|
|
850
|
+
const dirs = (existsSync(SAMPLES_ROOT_MUT) ? readdirSync(SAMPLES_ROOT_MUT, { withFileTypes: true }) : [])
|
|
844
851
|
.filter((d) => d.isDirectory() && existsSync(join(SAMPLES_ROOT_MUT, d.name, 'router.ts')))
|
|
845
852
|
.map((d) => join(SAMPLES_ROOT_MUT, d.name));
|
|
846
853
|
if (dirs.length === 0) {
|
|
@@ -871,7 +878,7 @@ function runMain(arg) {
|
|
|
871
878
|
const input = resolveInput(arg);
|
|
872
879
|
if (!input) {
|
|
873
880
|
console.error(`[gen-ios] 未找到样例「${arg}」`);
|
|
874
|
-
const samples = readdirSync(SAMPLES_ROOT_MUT, { withFileTypes: true })
|
|
881
|
+
const samples = (existsSync(SAMPLES_ROOT_MUT) ? readdirSync(SAMPLES_ROOT_MUT, { withFileTypes: true }) : [])
|
|
875
882
|
.filter((d) => d.isDirectory())
|
|
876
883
|
.map((d) => d.name);
|
|
877
884
|
console.error(` 可用样例: ${samples.join(' / ') || '(无)'} (或用 all 批量生成)`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dongmingzhixiu/vuexir",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "vrn 命令行:build ios|android、preview、doctor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
},
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/dongmingzhixiu/
|
|
40
|
+
"url": "git+https://github.com/dongmingzhixiu/vuexir.git",
|
|
41
41
|
"directory": "packages/cli"
|
|
42
42
|
},
|
|
43
|
-
"homepage": "https://github.com/dongmingzhixiu/
|
|
43
|
+
"homepage": "https://github.com/dongmingzhixiu/vuexir#readme",
|
|
44
44
|
"bugs": {
|
|
45
|
-
"url": "https://github.com/dongmingzhixiu/
|
|
45
|
+
"url": "https://github.com/dongmingzhixiu/vuexir/issues"
|
|
46
46
|
},
|
|
47
47
|
"author": "panvu"
|
|
48
48
|
}
|