@oxiaom/adoremix 1.0.32 → 1.0.34
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/config/ini.js +3 -0
- package/src/paths.js +19 -0
package/package.json
CHANGED
package/src/config/ini.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
4
5
|
const ini = require('ini');
|
|
5
6
|
|
|
6
7
|
function read(configPath) {
|
|
@@ -10,6 +11,8 @@ function read(configPath) {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
function write(configPath, obj) {
|
|
14
|
+
// 工作目录可能被 uninstall --purge 删掉,写 config.ini 前确保父目录存在
|
|
15
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
13
16
|
const txt = ini.stringify(obj, {
|
|
14
17
|
section: '',
|
|
15
18
|
whitespace: true,
|
package/src/paths.js
CHANGED
|
@@ -34,6 +34,25 @@ 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
|
+
throw _loadError;
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
if (e === _loadError) throw e;
|
|
54
|
+
// package.json 读不到等情况忽略,不阻塞
|
|
55
|
+
}
|
|
37
56
|
return _native;
|
|
38
57
|
}
|
|
39
58
|
|