@oxiaom/adoremix 1.0.33 → 1.0.35
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/package.json +1 -1
- package/src/doctor.js +19 -0
- package/src/paths.js +21 -0
package/package.json
CHANGED
package/src/doctor.js
CHANGED
|
@@ -166,6 +166,25 @@ function runDoctor(workdir, opts) {
|
|
|
166
166
|
native = paths.loadNative();
|
|
167
167
|
logger.ok(`✓ 平台子包 ${native.pkgName}`);
|
|
168
168
|
} catch (e) {
|
|
169
|
+
if (e && e.code === 'NATIVE_VERSION_MISMATCH') {
|
|
170
|
+
const mainVer = e.mainVersion || require('../package.json').version;
|
|
171
|
+
const fixCmd = `npm install -g @oxiaom/adoremix@${mainVer} --registry https://registry.npmjs.org`;
|
|
172
|
+
issues.push({ type: 'native-version-mismatch', severity: 'error', msg: e.message, fixCmd });
|
|
173
|
+
logger.error(`❌ ${e.message.split('\n')[0]}`);
|
|
174
|
+
logger.log(` 自动修复:adoremix doctor --fix(用官方源重装到 v${mainVer})`);
|
|
175
|
+
logger.log(` 或手动执行:${fixCmd}`);
|
|
176
|
+
if (opts.fix) {
|
|
177
|
+
logger.info('==> 用官方源重装主包(含最新子包)...');
|
|
178
|
+
try {
|
|
179
|
+
execSync(fixCmd, { stdio: 'inherit' });
|
|
180
|
+
logger.ok('✓ 已重装,请重新运行 adoremix doctor 确认');
|
|
181
|
+
} catch (e2) {
|
|
182
|
+
logger.error(`重装失败:${(e2.message || '').split('\n')[0]}`);
|
|
183
|
+
logger.warn(` 请手动执行:${fixCmd}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return reportAndExit(issues, opts);
|
|
187
|
+
}
|
|
169
188
|
issues.push({ type: 'native', severity: 'error', msg: e.message });
|
|
170
189
|
logger.error(`❌ 平台子包未加载:${e.message.split('\n')[0]}`);
|
|
171
190
|
return reportAndExit(issues, opts);
|
package/src/paths.js
CHANGED
|
@@ -34,6 +34,27 @@ function loadNative() {
|
|
|
34
34
|
);
|
|
35
35
|
throw _loadError;
|
|
36
36
|
}
|
|
37
|
+
// 版本一致性校验:主包与平台子包必须同版本。
|
|
38
|
+
// 国内镜像(npmmirror 等)对平台子包同步可能滞后,导致 install 时嵌套了旧版子包,
|
|
39
|
+
// 应用就会加载到旧 native(如旧 ICU 版本),运行报缺库。这里给出明确指引。
|
|
40
|
+
try {
|
|
41
|
+
const mainVer = require('../package.json').version;
|
|
42
|
+
const subPkg = require(`${PLATFORM_PKG}/package.json`);
|
|
43
|
+
if (subPkg && subPkg.version && mainVer && subPkg.version !== mainVer) {
|
|
44
|
+
_native = null;
|
|
45
|
+
_loadError = new Error(
|
|
46
|
+
`平台子包版本不一致:主包 @oxiaom/adoremix@${mainVer},但加载到 ${PLATFORM_PKG}@${subPkg.version}。\n` +
|
|
47
|
+
` 通常是 npm 镜像(npmmirror 等)没同步最新子包导致。请用官方源重装:\n` +
|
|
48
|
+
` npm install -g @oxiaom/adoremix@${mainVer} --registry https://registry.npmjs.org`
|
|
49
|
+
);
|
|
50
|
+
_loadError.code = 'NATIVE_VERSION_MISMATCH';
|
|
51
|
+
_loadError.mainVersion = mainVer;
|
|
52
|
+
throw _loadError;
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
if (e === _loadError) throw e;
|
|
56
|
+
// package.json 读不到等情况忽略,不阻塞
|
|
57
|
+
}
|
|
37
58
|
return _native;
|
|
38
59
|
}
|
|
39
60
|
|