@kengic/uni 0.6.3-beta.67 → 0.6.3-beta.68

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kengic/uni",
3
- "version": "0.6.3-beta.67",
3
+ "version": "0.6.3-beta.68",
4
4
  "scripts": {
5
5
  "postinstall": "node ./script/postinstall.mjs"
6
6
  },
@@ -1,5 +1,4 @@
1
1
  import fs from 'fs';
2
- import { sortBy } from 'lodash-es';
3
2
 
4
3
  /**
5
4
  * 获取当前时间.
@@ -8,34 +7,45 @@ function now() {
8
7
  return `[${new Date(Date.now() + 1000 * 60 * 60 * 8).toISOString().substring(0, 23).replace('T', ' ')}] [@kengic/uni] POST INSTALL | `;
9
8
  }
10
9
 
10
+ /**
11
+ * 打印日志.
12
+ *
13
+ * @param message 日志消息.
14
+ */
15
+ function log(message) {
16
+ console.log(`${now()}${message}`);
17
+ }
18
+
11
19
  /**
12
20
  * 项目的根目录.
13
21
  */
14
22
  const PROJECT_DIR_01 = '../../../../../../..';
15
23
  const PROJECT_DIR_02 = '../../../../../..';
16
24
 
17
- console.log(`${now()}`);
18
- console.log(`${now()}当前目录 | ${process.cwd()}`);
25
+ //region 同步依赖
26
+ //----------------------------------------------------------------------------------------------------
27
+ log(``);
28
+ log(`当前目录 | ${process.cwd()}`);
19
29
 
20
30
  let json01 = null;
21
31
 
22
32
  try {
23
- console.log(`${now()}开始读取组件的 package.json`);
33
+ log(`开始读取组件的 package.json`);
24
34
  json01 = (await import(`../package.json`, { with: { type: 'json' } })).default;
25
- console.log(`${now()}成功读取组件的 package.json`);
35
+ log(`成功读取组件的 package.json`);
26
36
  } catch (e) {
27
- console.log(`${now()}失败读取组件的 package.json`);
37
+ log(`失败读取组件的 package.json`);
28
38
  throw e;
29
39
  }
30
40
 
31
41
  let json02 = null;
32
42
 
33
43
  try {
34
- console.log(`${now()}开始读取项目的 package.json`);
44
+ log(`开始读取项目的 package.json`);
35
45
  json02 = (await import(`${PROJECT_DIR_01}/package.json`, { with: { type: 'json' } })).default;
36
- console.log(`${now()}成功读取项目的 package.json`);
46
+ log(`成功读取项目的 package.json`);
37
47
  } catch (e) {
38
- console.log(`${now()}失败读取项目的 package.json`);
48
+ log(`失败读取项目的 package.json`);
39
49
  throw e;
40
50
  }
41
51
 
@@ -47,7 +57,65 @@ if (json01 && json02) {
47
57
  // 排序,
48
58
  json02.dependencies = Object.fromEntries(Object.entries(json02.dependencies).sort(([a], [b]) => a.localeCompare(b)));
49
59
 
50
- console.log(`${now()}开始写入项目的 package.json`);
60
+ log(`开始写入项目的 package.json`);
51
61
  fs.writeFileSync(`${PROJECT_DIR_02}/package.json`, `${JSON.stringify(json02, null, 4)}\n`, {});
52
- console.log(`${now()}成功写入项目的 package.json`);
62
+ log(`成功写入项目的 package.json`);
63
+ }
64
+ //----------------------------------------------------------------------------------------------------
65
+ //endregion
66
+
67
+ //region 移除多余的控制台消息
68
+ //----------------------------------------------------------------------------------------------------
69
+ // vite-plugin-uni 中的编译器版本号不对, 手动修复
70
+ {
71
+ const filepath = `${PROJECT_DIR_01}/node_modules/@dcloudio/vite-plugin-uni/package.json`;
72
+ const json = JSON.parse(fs.readFileSync(filepath, { encoding: 'utf8' }));
73
+ const version = json['version'].split('-')[json['version'].split('-').length - 1].substring(0, 5).replaceAll('0', '.');
74
+ const compilerVersion = json['uni-app']['compilerVersion'];
75
+ if (version !== compilerVersion) {
76
+ json['uni-app']['compilerVersion'] = version;
77
+ fs.writeFileSync(filepath, `${JSON.stringify(json, null, 2)}\n`, {});
78
+ }
79
+ }
80
+
81
+ // 移除 uni-cloud 的广告
82
+ {
83
+ const filepath = `${PROJECT_DIR_01}/node_modules/.pnpm/node_modules/@dcloudio/uni-cloud/lib/uni.plugin.js`;
84
+ let text = fs.readFileSync(filepath, { encoding: 'utf8' });
85
+ text = text.replaceAll(/'欢迎(.*)?'/g, '');
86
+ fs.writeFileSync(filepath, text, {});
87
+ }
88
+
89
+ // 修改 uni-cli-shared 控制台的消息
90
+ {
91
+ {
92
+ const filepath = `${PROJECT_DIR_01}/node_modules/@dcloudio/uni-cli-shared/dist/messages/en.js`;
93
+ let text = fs.readFileSync(filepath, { encoding: 'utf8' });
94
+ text = text.replaceAll("'DONE Build complete.'", "'打包完成'");
95
+ text = text.replaceAll("'Compiling...'", "'正在编译...'");
96
+ text = text.replaceAll("'正在编译中...'", "'正在编译...'");
97
+ text = text.replaceAll("'Run method: open {devtools}, import {outputDir} run.'", "''");
98
+ text = text.replaceAll("'Compiler version: {version}'", "'框架版本: {version}'");
99
+ text = text.replaceAll("'运行方式:打开 {devtools}, 导入 {outputDir} 运行。'", "''");
100
+ text = text.replaceAll(
101
+ "'Please note that in running mode, due to log output, sourcemap, and uncompressed source code, the performance and package size are not as good as release mode.'",
102
+ "''",
103
+ );
104
+ fs.writeFileSync(filepath, text, {});
105
+ }
106
+
107
+ {
108
+ const filepath = `${PROJECT_DIR_01}/node_modules/@dcloudio/uni-cli-shared/dist/messages/zh_CN.js`;
109
+ let text = fs.readFileSync(filepath, { encoding: 'utf8' });
110
+ text = text.replaceAll("'DONE Build complete.'", "'打包完成'");
111
+ text = text.replaceAll("'Compiling...'", "'正在编译...'");
112
+ text = text.replaceAll("'正在编译中...'", "'正在编译...'");
113
+ text = text.replaceAll("'Run method: open {devtools}, import {outputDir} run.'", "''");
114
+ text = text.replaceAll("'编译器版本:{version}'", "'框架版本: {version}'");
115
+ text = text.replaceAll("'运行方式:打开 {devtools}, 导入 {outputDir} 运行。'", "''");
116
+ text = text.replaceAll("'请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。'", "''");
117
+ fs.writeFileSync(filepath, text, {});
118
+ }
53
119
  }
120
+ //----------------------------------------------------------------------------------------------------
121
+ //endregion