@kengic/uni 0.6.3-beta.61 → 0.6.3-beta.63
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/script/postinstall.mjs +12 -7
package/package.json
CHANGED
package/script/postinstall.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import { sortBy } from 'lodash-es';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 获取当前时间.
|
|
@@ -8,18 +9,19 @@ function now() {
|
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* 项目的根目录.
|
|
12
13
|
*/
|
|
13
|
-
const
|
|
14
|
+
const PROJECT_DIR_01 = '../../../../../../..';
|
|
15
|
+
const PROJECT_DIR_02 = '../../../../../..';
|
|
14
16
|
|
|
15
17
|
console.log(`${now()}`);
|
|
16
|
-
console.log(`${now()}${process.cwd()}`);
|
|
18
|
+
console.log(`${now()}当前目录 | ${process.cwd()}`);
|
|
17
19
|
|
|
18
20
|
let json01 = null;
|
|
19
21
|
|
|
20
22
|
try {
|
|
21
23
|
console.log(`${now()}开始读取组件的 package.json`);
|
|
22
|
-
json01 = (await import(`../package.json
|
|
24
|
+
json01 = (await import(`../package.json`, { with: { type: 'json' } })).default;
|
|
23
25
|
console.log(`${now()}成功读取组件的 package.json`);
|
|
24
26
|
} catch (e) {
|
|
25
27
|
console.log(`${now()}失败读取组件的 package.json`);
|
|
@@ -30,19 +32,22 @@ let json02 = null;
|
|
|
30
32
|
|
|
31
33
|
try {
|
|
32
34
|
console.log(`${now()}开始读取项目的 package.json`);
|
|
33
|
-
json02 = (await import(`${
|
|
35
|
+
json02 = (await import(`${PROJECT_DIR_01}/package.json`, { with: { type: 'json' } })).default;
|
|
34
36
|
console.log(`${now()}成功读取项目的 package.json`);
|
|
35
37
|
} catch (e) {
|
|
36
38
|
console.log(`${now()}失败读取项目的 package.json`);
|
|
37
39
|
throw e;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
if (json02) {
|
|
42
|
+
if (json01 && json02) {
|
|
41
43
|
for (let key of Object.keys(json01.dependencies)) {
|
|
42
44
|
json02.dependencies[key] = json01.dependencies[key];
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
// 排序,
|
|
48
|
+
json02.dependencies = sortBy(json02.dependencies);
|
|
49
|
+
|
|
45
50
|
console.log(`${now()}开始写入项目的 package.json`);
|
|
46
|
-
fs.writeFileSync(`${
|
|
51
|
+
fs.writeFileSync(`${PROJECT_DIR_02}/package.json`, `${JSON.stringify(json02, null, 4)}\n`, {});
|
|
47
52
|
console.log(`${now()}成功写入项目的 package.json`);
|
|
48
53
|
}
|