@kengic/vue 0.30.1-beta.94 → 0.30.1-beta.95
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/bin/bin.mjs +57 -0
- package/bin/postinstall.mjs +69 -0
- package/package.json +7 -2
package/bin/bin.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
const program = new Command();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 打印日志.
|
|
8
|
+
*
|
|
9
|
+
* @param message 日志消息.
|
|
10
|
+
*/
|
|
11
|
+
function log(message) {
|
|
12
|
+
console.log(`[${new Date(Date.now() + 1000 * 60 * 60 * 8).toISOString().substring(0, 23).replace('T', ' ')}] [@kengic/uni] COPY-DIST-TO-ANDROID | ${message}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function bin() {
|
|
16
|
+
try {
|
|
17
|
+
program
|
|
18
|
+
.command('copy-dist-to-android')
|
|
19
|
+
.description('COPY DIST TO ANDROID')
|
|
20
|
+
.option('--appid <appid>', 'APPID', '')
|
|
21
|
+
.action(async (args) => {
|
|
22
|
+
try {
|
|
23
|
+
log(`命令参数 | ${JSON.stringify(args)}`);
|
|
24
|
+
log(`当前目录 | ${process.cwd()}`);
|
|
25
|
+
|
|
26
|
+
if (!args.appid) {
|
|
27
|
+
log(`参数不能为空 | appid`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const sourceDir = process.cwd() + '/dist/build/app';
|
|
32
|
+
const targetDir = process.cwd() + '/android/app/src/main/assets/apps/__UNI__8B6E231/www';
|
|
33
|
+
|
|
34
|
+
if (!fs.existsSync(sourceDir)) {
|
|
35
|
+
log(`起始目录尚不存在 | ${sourceDir}`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
log(`开始删除旧的目录 | ${targetDir}`);
|
|
40
|
+
fs.rmSync(targetDir, { force: true, recursive: true });
|
|
41
|
+
log(`完成删除旧的目录 | ${targetDir}`);
|
|
42
|
+
|
|
43
|
+
log(`开始复制新的文件 | ${sourceDir}`);
|
|
44
|
+
fs.cpSync(sourceDir, targetDir, { recursive: true });
|
|
45
|
+
log(`完成复制新的文件 | ${sourceDir}`);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.log(e);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
program.parse(process.argv);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error(e.stack);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
bin();
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 安装完成之后, 处理其他任务.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 打印日志.
|
|
9
|
+
*
|
|
10
|
+
* @param message 日志消息.
|
|
11
|
+
*/
|
|
12
|
+
function log(message) {
|
|
13
|
+
console.log(`[${new Date(Date.now() + 1000 * 60 * 60 * 8).toISOString().substring(0, 23).replace('T', ' ')}] [@kengic/vue] POST-INSTALL | ${message}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 项目的根目录.
|
|
18
|
+
*/
|
|
19
|
+
const PROJECT_DIR_01 = '../../../../../../..';
|
|
20
|
+
const PROJECT_DIR_02 = '../../../../../..';
|
|
21
|
+
|
|
22
|
+
log(``);
|
|
23
|
+
log(`当前目录 | ${process.cwd()}`);
|
|
24
|
+
|
|
25
|
+
//region 同步依赖
|
|
26
|
+
//----------------------------------------------------------------------------------------------------
|
|
27
|
+
/**
|
|
28
|
+
* 要排除的包名列表.
|
|
29
|
+
*/
|
|
30
|
+
const EXCLUDE_PACKAGE_LIST = ['commander', 'chalk'];
|
|
31
|
+
|
|
32
|
+
let json01 = null;
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
log(`开始读取组件的 package.json`);
|
|
36
|
+
json01 = (await import(`../package.json`, { with: { type: 'json' } })).default;
|
|
37
|
+
log(`成功读取组件的 package.json`);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
log(`失败读取组件的 package.json`);
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let json02 = null;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
log(`开始读取项目的 package.json`);
|
|
47
|
+
json02 = (await import(`${PROJECT_DIR_01}/package.json`, { with: { type: 'json' } })).default;
|
|
48
|
+
log(`成功读取项目的 package.json`);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
log(`失败读取项目的 package.json`);
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (json01 && json02) {
|
|
55
|
+
for (let key of Object.keys(json01.dependencies)) {
|
|
56
|
+
if (!EXCLUDE_PACKAGE_LIST.includes(key)) {
|
|
57
|
+
json02.dependencies[key] = json01.dependencies[key];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 排序,
|
|
62
|
+
json02.dependencies = Object.fromEntries(Object.entries(json02.dependencies).sort(([a], [b]) => a.localeCompare(b)));
|
|
63
|
+
|
|
64
|
+
log(`开始写入项目的 package.json`);
|
|
65
|
+
fs.writeFileSync(`${PROJECT_DIR_02}/package.json`, `${JSON.stringify(json02, null, 4)}\n`, {});
|
|
66
|
+
log(`成功写入项目的 package.json`);
|
|
67
|
+
}
|
|
68
|
+
//----------------------------------------------------------------------------------------------------
|
|
69
|
+
//endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kengic/vue",
|
|
3
|
-
"version": "0.30.1-beta.
|
|
4
|
-
"scripts": {
|
|
3
|
+
"version": "0.30.1-beta.95",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"postinstall": "node bin/postinstall.mjs"
|
|
6
|
+
},
|
|
7
|
+
"bin": {
|
|
8
|
+
"kg-uni": "bin/bin.mjs"
|
|
9
|
+
},
|
|
5
10
|
"peerDependencies": {
|
|
6
11
|
"vue": "^3.2.43"
|
|
7
12
|
},
|