@dongmingzhixiu/vuexir 0.5.6 → 0.6.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/README.md +1 -1
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +1 -1
- package/dist/config.js +13 -5
- package/dist/gen-android.js +5 -2
- package/dist/gen-ios.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* vrn build ios|android [--run] # gen + (--run 时)调用 xcodegen/xcodebuild | gradle
|
|
6
6
|
* vrn doctor # 环境自检
|
|
7
7
|
*
|
|
8
|
-
* 配置来源见 config.ts(
|
|
8
|
+
* 配置来源见 config.ts(vuexir.config.* + CLI 覆盖)。生成器在导入前设置 VRN_NO_AUTO_RUN=1,
|
|
9
9
|
* 避免模块加载时的自动执行。
|
|
10
10
|
*/
|
|
11
11
|
import { existsSync } from 'node:fs';
|
|
@@ -197,7 +197,7 @@ export async function run(argv) {
|
|
|
197
197
|
vrn build ios|android [入口] [--run] # 生成后可选调用平台构建
|
|
198
198
|
vrn doctor # 环境自检
|
|
199
199
|
|
|
200
|
-
配置:<projectRoot>/
|
|
200
|
+
配置:<projectRoot>/vuexir.config.ts(entry / outDir / projectName / bundleId)
|
|
201
201
|
`);
|
|
202
202
|
return 0;
|
|
203
203
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface VrnConfig {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
/** 读取
|
|
23
|
+
/** 读取 vuexir.config(JSON 直接解析;ts/mjs 先用 esbuild 转译再 import) */
|
|
24
24
|
export declare function loadConfig(projectRoot: string): Promise<Partial<VrnConfig>>;
|
|
25
25
|
/** 合并默认值 + 配置文件 + CLI 覆盖 */
|
|
26
26
|
export declare function resolveConfig(base: Partial<VrnConfig> & {
|
package/dist/config.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @dongmingzhixiu/vuexir 配置解析(R-PKG:CLI 只认「项目根 +
|
|
2
|
+
* @dongmingzhixiu/vuexir 配置解析(R-PKG:CLI 只认「项目根 + vuexir.config」两个事实来源)
|
|
3
3
|
*
|
|
4
4
|
* 解析顺序(后者覆盖前者):
|
|
5
5
|
* 1. 内置默认值(projectRoot = process.cwd(),outDir = <root>/native)
|
|
6
|
-
* 2.
|
|
6
|
+
* 2. vuexir.config.ts / .mts / .js / .mjs / .json(旧名 vuexir.config.* 仍兼容)
|
|
7
7
|
* 3. 命令行参数(--out / --entry / --name / --bundle 等)
|
|
8
8
|
*
|
|
9
9
|
* 兼容期:未提供 vrn.config 时,若 <root>/router.ts 或 <root>/App.vue 存在,按「目录即项目」处理;
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
13
13
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
14
|
-
const CONFIG_FILES = ['vuexir.config.ts', 'vuexir.config.mts', 'vuexir.config.js', 'vuexir.config.mjs', 'vuexir.config.json', '
|
|
15
|
-
/** 读取
|
|
14
|
+
const CONFIG_FILES = ['vuexir.config.ts', 'vuexir.config.mts', 'vuexir.config.js', 'vuexir.config.mjs', 'vuexir.config.json', 'vuexir.config.ts', 'vrn.config.mts', 'vrn.config.js', 'vrn.config.mjs', 'vrn.config.json'];
|
|
15
|
+
/** 读取 vuexir.config(JSON 直接解析;ts/mjs 先用 esbuild 转译再 import) */
|
|
16
16
|
export async function loadConfig(projectRoot) {
|
|
17
17
|
for (const file of CONFIG_FILES) {
|
|
18
18
|
const p = join(projectRoot, file);
|
|
@@ -22,6 +22,14 @@ export async function loadConfig(projectRoot) {
|
|
|
22
22
|
if (file.endsWith('.json')) {
|
|
23
23
|
return JSON.parse(readFileSync(p, 'utf-8'));
|
|
24
24
|
}
|
|
25
|
+
// R144:配置文件是 TS 时,Node 无法直接 import → 先用 esbuild 转成 ESM 再加载
|
|
26
|
+
if (/\.m?ts$/.test(file)) {
|
|
27
|
+
const { transformSync } = await import('esbuild');
|
|
28
|
+
const js = transformSync(readFileSync(p, 'utf-8'), { loader: 'ts', format: 'esm', target: 'es2020' }).code;
|
|
29
|
+
const url = `data:text/javascript;base64,${Buffer.from(js, 'utf-8').toString('base64')}`;
|
|
30
|
+
const mod = (await import(url));
|
|
31
|
+
return mod.default ?? {};
|
|
32
|
+
}
|
|
25
33
|
const mod = (await import(`file://${p}`));
|
|
26
34
|
return mod.default ?? {};
|
|
27
35
|
}
|
|
@@ -81,7 +89,7 @@ export function resolveEntry(cfg) {
|
|
|
81
89
|
candidates.push(a);
|
|
82
90
|
}
|
|
83
91
|
throw new Error(`未找到入口(多页 src/router.ts 或单页 src/App.vue)。已尝试:\n ${candidates.join('\n ')}\n` +
|
|
84
|
-
`可在
|
|
92
|
+
`可在 vuexir.config.ts 中用 entry 显式指定。`);
|
|
85
93
|
}
|
|
86
94
|
/** 平台输出目录:<outDir>/<platform>/<ProjectName> */
|
|
87
95
|
export function platformOutDir(cfg, platform, projectName) {
|
package/dist/gen-android.js
CHANGED
|
@@ -27,10 +27,13 @@ export function generateAndroid(opts = {}) {
|
|
|
27
27
|
if (/\.(ts|js|mts)$/.test(input) && existsSync(input)) {
|
|
28
28
|
return runTabs(dirname(input), { routerFile: input, outDirRoot: opts.outDirRoot, projectName: opts.projectName, bundleId: opts.bundleId, renderGradle: (p, b) => buildGradle(b), templateVersion: TEMPLATE_VERSION });
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// 目录入口:兼容 router.ts / index.ts(Vue 工程标准 src/router/index.ts)
|
|
31
|
+
const routerFile = ['router.ts', 'router.js', 'index.ts', 'index.js'].find((f) => existsSync(join(input, f)));
|
|
32
|
+
if (!routerFile) {
|
|
33
|
+
throw new Error(`[vrn] ${input} 缺少 router.ts/index.ts(多页模式需要路由文件;单页请用 gen-ios 路径或补 router.ts)`);
|
|
32
34
|
}
|
|
33
35
|
return runTabs(input, {
|
|
36
|
+
routerFile: join(input, routerFile),
|
|
34
37
|
outDirRoot: opts.outDirRoot,
|
|
35
38
|
projectName: opts.projectName,
|
|
36
39
|
bundleId: opts.bundleId,
|
package/dist/gen-ios.js
CHANGED
|
@@ -35,7 +35,7 @@ const SAMPLES_ROOT = (() => {
|
|
|
35
35
|
const TOOLCHAIN_VERSION = '0.1.0';
|
|
36
36
|
/** 样例根(可写副本:generateIos 可用 opts.samplesRoot 覆盖) */
|
|
37
37
|
let SAMPLES_ROOT_MUT = SAMPLES_ROOT;
|
|
38
|
-
/** CLI 注入的工程名/包名覆盖(
|
|
38
|
+
/** CLI 注入的工程名/包名覆盖(vuexir.config 的 projectName/bundleId) */
|
|
39
39
|
let FORCED_PROJECT_NAME;
|
|
40
40
|
let FORCED_BUNDLE_ID;
|
|
41
41
|
const DEFAULT_INPUT = join(SAMPLES_ROOT_MUT, 'vuexir-demo'); // 多页目录模式默认样例
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dongmingzhixiu/vuexir",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "vrn 命令行:build ios|android、preview、doctor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"LICENSE"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dongmingzhixiu/vuexir-compiler": "^0.
|
|
25
|
-
"@dongmingzhixiu/vuexir-templates": "^0.
|
|
24
|
+
"@dongmingzhixiu/vuexir-compiler": "^0.6.0",
|
|
25
|
+
"@dongmingzhixiu/vuexir-templates": "^0.6.0"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=18"
|