wechat-mp-controller 0.0.5 → 0.1.0
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/dist/index.d.ts +20 -5
- package/dist/index.js +35 -35
- package/dist/type.d.ts +41 -3
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { UploadVersionInfo } from './type';
|
|
2
1
|
export type WeChatMpControllerOptions = {
|
|
3
2
|
headless?: boolean;
|
|
4
3
|
};
|
|
@@ -16,11 +15,27 @@ export declare class Controller {
|
|
|
16
15
|
onQrCode?: (qrcode: string) => void;
|
|
17
16
|
onScanSuccess?: (qrcode: string) => void;
|
|
18
17
|
}): Promise<void>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
getVersionInfos(): Promise<{
|
|
19
|
+
online: {
|
|
20
|
+
version: string;
|
|
21
|
+
message: string;
|
|
22
|
+
time: number;
|
|
23
|
+
uploader: {
|
|
24
|
+
name: string;
|
|
25
|
+
openId: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
dev: {
|
|
29
|
+
version: string;
|
|
30
|
+
message: string;
|
|
31
|
+
time: number;
|
|
32
|
+
uploader: {
|
|
33
|
+
name: string;
|
|
34
|
+
openId: string;
|
|
35
|
+
};
|
|
36
|
+
isExperience: boolean;
|
|
37
|
+
}[];
|
|
22
38
|
}>;
|
|
23
|
-
getDevVersionInfos(): Promise<UploadVersionInfo[]>;
|
|
24
39
|
submitAudit(options: {
|
|
25
40
|
message: string;
|
|
26
41
|
uploaderOfTargetVersion: {
|
package/dist/index.js
CHANGED
|
@@ -64,53 +64,52 @@ export class Controller {
|
|
|
64
64
|
await this.page.waitForSelector('#menuBar .menu');
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
async
|
|
67
|
+
async getVersionInfos() {
|
|
68
68
|
if (!this.page) {
|
|
69
69
|
throw new Error('请先进行初始化');
|
|
70
70
|
}
|
|
71
71
|
const versionManageLink = await this.page.$eval('#menuBar a[title="版本管理"]', node => node.href);
|
|
72
72
|
await this.page.goto(versionManageLink);
|
|
73
|
-
await this.page.
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const response = await this.page.waitForResponse(res => {
|
|
74
|
+
return res.url().includes('https://mp.weixin.qq.com/wxamp/cgi/route') && res.url().includes(encodeURIComponent('/wxopen/wacodepage'));
|
|
75
|
+
});
|
|
76
|
+
const responseDataString = (await response.buffer()).toString();
|
|
77
|
+
const body = JSON.parse(responseDataString);
|
|
78
|
+
const {
|
|
79
|
+
code_data
|
|
80
|
+
} = body;
|
|
81
|
+
const codeData = JSON.parse(code_data);
|
|
82
|
+
const onlineData = codeData.online_info.basic_info;
|
|
83
|
+
const devList = codeData.develop_info.info_list;
|
|
76
84
|
return {
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
online: {
|
|
86
|
+
version: onlineData.version,
|
|
87
|
+
message: onlineData.describe,
|
|
88
|
+
time: onlineData.time,
|
|
89
|
+
uploader: {
|
|
90
|
+
name: onlineData.nick_name,
|
|
91
|
+
openId: onlineData.open_id
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
dev: devList.map(item => {
|
|
95
|
+
const basicInfo = item.basic_info;
|
|
96
|
+
return {
|
|
97
|
+
version: basicInfo.version,
|
|
98
|
+
message: basicInfo.describe,
|
|
99
|
+
time: basicInfo.time,
|
|
100
|
+
uploader: {
|
|
101
|
+
name: basicInfo.nick_name,
|
|
102
|
+
openId: basicInfo.open_id
|
|
103
|
+
},
|
|
104
|
+
isExperience: !!item.is_exper
|
|
105
|
+
};
|
|
106
|
+
})
|
|
79
107
|
};
|
|
80
108
|
}
|
|
81
|
-
async getDevVersionInfos() {
|
|
82
|
-
if (!this.page) {
|
|
83
|
-
throw new Error('请先进行初始化');
|
|
84
|
-
}
|
|
85
|
-
const versionManageLink = await this.page.$eval('#menuBar a[title="版本管理"]', node => node.href);
|
|
86
|
-
await this.page.goto(versionManageLink);
|
|
87
|
-
await this.page.waitForSelector('.main_bd .code_version_dev .mod_default_bd:nth-child(2) .code_version_logs .code_version_log');
|
|
88
|
-
const originVersionInfos = await this.page.$$eval('.main_bd .code_version_dev .mod_default_bd:nth-child(2) .code_version_logs .code_version_log .simple_preview_value', nodes => nodes.map(node => node.firstChild?.textContent?.trim() || ''));
|
|
89
|
-
if (!originVersionInfos.length) {
|
|
90
|
-
throw new Error('请先上传版本');
|
|
91
|
-
}
|
|
92
|
-
const versionInfos = [];
|
|
93
|
-
for (let A = 0; A < originVersionInfos.length; A = A + 4) {
|
|
94
|
-
const version = originVersionInfos[A];
|
|
95
|
-
const uploader = originVersionInfos[A + 1];
|
|
96
|
-
const time = originVersionInfos[A + 2];
|
|
97
|
-
const message = originVersionInfos[A + 3];
|
|
98
|
-
versionInfos.push({
|
|
99
|
-
uploader,
|
|
100
|
-
time,
|
|
101
|
-
version,
|
|
102
|
-
message
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return versionInfos;
|
|
106
|
-
}
|
|
107
109
|
async submitAudit(options) {
|
|
108
110
|
if (!this.page) {
|
|
109
111
|
throw new Error('请先进行初始化');
|
|
110
112
|
}
|
|
111
|
-
const versionManageLink = await this.page.$eval('#menuBar a[title="版本管理"]', node => node.href);
|
|
112
|
-
await this.page.goto(versionManageLink);
|
|
113
|
-
await this.page.waitForSelector('.main_bd .code_version_dev .mod_default_bd:nth-child(2) .code_version_logs .code_version_log');
|
|
114
113
|
const url = new URL(this.page.url());
|
|
115
114
|
const urlToken = url.searchParams.get('token');
|
|
116
115
|
if (!urlToken) {
|
|
@@ -127,6 +126,7 @@ export class Controller {
|
|
|
127
126
|
await this.page.waitForSelector('.weui-desktop-form__control-group textarea');
|
|
128
127
|
await this.page.locator('.weui-desktop-form__control-group textarea').fill(options.message);
|
|
129
128
|
await this.page.locator('.btn.btn_primary[data-msgid="提交审核"]').click();
|
|
129
|
+
// 也可以等待 https://mp.weixin.qq.com/wxamp/cgi/route?path=%2Fwxopen%2Fwadevelopcode%3Faction%3Dsubmit_check&token=283379953&lang=zh_CN&random=0.8360122102877674
|
|
130
130
|
await this.page.waitForSelector('div[data-component="sumbitPage"] .main_bd *[data-msgid="已提交审核"]');
|
|
131
131
|
return;
|
|
132
132
|
}
|
package/dist/type.d.ts
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
|
-
export type
|
|
2
|
-
uploader:
|
|
1
|
+
export type VersionInfo = {
|
|
2
|
+
uploader: {
|
|
3
|
+
name: string;
|
|
4
|
+
openId: string;
|
|
5
|
+
};
|
|
3
6
|
version: string;
|
|
4
|
-
time:
|
|
7
|
+
time: number;
|
|
5
8
|
message: string;
|
|
9
|
+
isExperience: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type OriginVersionInfo = {
|
|
12
|
+
online_info: {
|
|
13
|
+
basic_info: {
|
|
14
|
+
open_id: string;
|
|
15
|
+
version: string;
|
|
16
|
+
nick_name: string;
|
|
17
|
+
time: number;
|
|
18
|
+
describe: string;
|
|
19
|
+
warning_api_list: string[];
|
|
20
|
+
avatar: string;
|
|
21
|
+
inner_version: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
develop_info: {
|
|
25
|
+
info_list: Array<{
|
|
26
|
+
basic_info: {
|
|
27
|
+
open_id: string;
|
|
28
|
+
version: string;
|
|
29
|
+
nick_name: string;
|
|
30
|
+
time: number;
|
|
31
|
+
describe: string;
|
|
32
|
+
status: number;
|
|
33
|
+
is_plugin_auto_update: number;
|
|
34
|
+
warning_api_list: string[];
|
|
35
|
+
avatar: string;
|
|
36
|
+
};
|
|
37
|
+
is_exper?: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
developer_size: number;
|
|
40
|
+
preview_info_list: any[];
|
|
41
|
+
};
|
|
42
|
+
need_finance_audit: number;
|
|
43
|
+
qr_path: string;
|
|
6
44
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wechat-mp-controller",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"prepare": "husky",
|
|
20
20
|
"exec:ts-node": "node --disable-warning=ExperimentalWarning --es-module-specifier-resolution=node --loader ts-node/esm",
|
|
21
21
|
"release": "pnpm exec:ts-node \"./scripts/release.ts\"",
|
|
22
|
-
"prepublishOnly": "pnpm build && pnpm exec:ts-node \"./scripts/publish.ts\""
|
|
22
|
+
"prepublishOnly": "pnpm build && pnpm exec:ts-node \"./scripts/publish.ts\"",
|
|
23
|
+
"test": "tsx ./test/index.ts"
|
|
23
24
|
},
|
|
24
25
|
"files": [
|
|
25
26
|
"dist",
|
|
@@ -29,7 +30,6 @@
|
|
|
29
30
|
"author": "ArcherCube",
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"jimp": "^1.6.0",
|
|
32
|
-
"ora": "^9.0.0",
|
|
33
33
|
"puppeteer-core": "^24.22.0",
|
|
34
34
|
"qrcode-reader": "^1.0.4",
|
|
35
35
|
"qrcode-terminal": "^0.12.0"
|
|
@@ -60,8 +60,10 @@
|
|
|
60
60
|
"husky": "^9.1.6",
|
|
61
61
|
"inquirer": "^12.9.6",
|
|
62
62
|
"lint-staged": "^15.2.10",
|
|
63
|
+
"ora": "^9.0.0",
|
|
63
64
|
"prettier": "^3.3.3",
|
|
64
65
|
"ts-node": "^10.9.2",
|
|
66
|
+
"tsx": "^4.20.6",
|
|
65
67
|
"typescript": "^5.7.2",
|
|
66
68
|
"watch": "^1.0.2"
|
|
67
69
|
},
|