@adelie/wechat-miniprogram 0.0.0-stage → 0.4.2
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/LICENSE +201 -0
- package/icon.svg +7 -0
- package/package.json +17 -3
- package/plugin.json +9 -0
- package/skills/wechat-miniprogram/SKILL.md +148 -0
- package/skills/wechat-miniprogram/scripts/add-ip2.mjs +358 -0
- package/skills/wechat-miniprogram/scripts/auto-submit.mjs +170 -0
- package/skills/wechat-miniprogram/scripts/check-session.mjs +40 -0
- package/skills/wechat-miniprogram/scripts/login2.mjs +226 -0
- package/skills/wechat-miniprogram/scripts/miniapp-info.mjs +67 -0
- package/skills/wechat-miniprogram/scripts/miniapp-nav.mjs +56 -0
- package/skills/wechat-miniprogram/scripts/package.json +12 -0
- package/skills/wechat-miniprogram/scripts/privacy-fill2.mjs +302 -0
- package/skills/wechat-miniprogram/scripts/probe-key-qr.mjs +147 -0
- package/skills/wechat-miniprogram/scripts/probe-privacy.mjs +73 -0
- package/skills/wechat-miniprogram/scripts/probe-privcheck.mjs +129 -0
- package/skills/wechat-miniprogram/scripts/probe-switch3.mjs +104 -0
- package/skills/wechat-miniprogram/scripts/reset-key2.mjs +259 -0
- package/skills/wechat-miniprogram/scripts/stealth.mjs +92 -0
- package/skills/wechat-miniprogram/scripts/submit-review4.mjs +186 -0
- package/skills/wechat-miniprogram/scripts/to-miniapp.mjs +136 -0
- package/skills/wechat-miniprogram/scripts/withdraw2.mjs +229 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/README.md +46 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/app.js +14 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/app.json +12 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/app.wxss +13 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/package.json +14 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/about/about.js +33 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/about/about.json +4 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/about/about.wxml +24 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/about/about.wxss +49 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/index/index.js +145 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/index/index.json +4 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/index/index.wxml +55 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/index/index.wxss +173 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/preview.js +53 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/project.config.json +25 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/sitemap.json +9 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/tools/test-page.js +123 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/tools/validate.js +103 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/upload.js +49 -0
- package/README.md +0 -3
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
.header {
|
|
2
|
+
padding: 8rpx 8rpx 24rpx;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.header__title {
|
|
6
|
+
font-size: 44rpx;
|
|
7
|
+
font-weight: 600;
|
|
8
|
+
letter-spacing: 1rpx;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.header__stat {
|
|
12
|
+
margin-top: 8rpx;
|
|
13
|
+
color: #7e8081;
|
|
14
|
+
font-size: 26rpx;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.stat__num {
|
|
18
|
+
color: #07c160;
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
margin-right: 6rpx;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.stat__label {
|
|
24
|
+
margin-right: 16rpx;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.stat__sep {
|
|
28
|
+
margin-right: 16rpx;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.composer {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
background: #ffffff;
|
|
35
|
+
border-radius: 20rpx;
|
|
36
|
+
padding: 16rpx 16rpx 16rpx 24rpx;
|
|
37
|
+
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.composer__input {
|
|
41
|
+
flex: 1;
|
|
42
|
+
font-size: 30rpx;
|
|
43
|
+
min-height: 60rpx;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.composer__placeholder {
|
|
47
|
+
color: #b1b2b3;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.composer__btn {
|
|
51
|
+
margin-left: 16rpx;
|
|
52
|
+
background: #07c160;
|
|
53
|
+
color: #ffffff;
|
|
54
|
+
border-radius: 12rpx;
|
|
55
|
+
font-size: 28rpx;
|
|
56
|
+
line-height: 2.2;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.tabs {
|
|
60
|
+
display: flex;
|
|
61
|
+
margin: 28rpx 4rpx 12rpx;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.tab {
|
|
65
|
+
padding: 8rpx 24rpx;
|
|
66
|
+
margin-right: 16rpx;
|
|
67
|
+
font-size: 28rpx;
|
|
68
|
+
color: #7e8081;
|
|
69
|
+
border-radius: 999rpx;
|
|
70
|
+
background: #ececee;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.tab_active {
|
|
74
|
+
background: #07c160;
|
|
75
|
+
color: #ffffff;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.list {
|
|
79
|
+
margin-top: 8rpx;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.item {
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
background: #ffffff;
|
|
86
|
+
border-radius: 20rpx;
|
|
87
|
+
padding: 26rpx 24rpx;
|
|
88
|
+
margin-bottom: 16rpx;
|
|
89
|
+
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.item_done {
|
|
93
|
+
opacity: 0.55;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.item__check {
|
|
97
|
+
padding-right: 20rpx;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.item__box {
|
|
101
|
+
width: 44rpx;
|
|
102
|
+
height: 44rpx;
|
|
103
|
+
border-radius: 50%;
|
|
104
|
+
border: 2rpx solid #d4d5d6;
|
|
105
|
+
color: #ffffff;
|
|
106
|
+
font-size: 26rpx;
|
|
107
|
+
text-align: center;
|
|
108
|
+
line-height: 44rpx;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.item_done .item__box {
|
|
112
|
+
background: #07c160;
|
|
113
|
+
border-color: #07c160;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.item__body {
|
|
117
|
+
flex: 1;
|
|
118
|
+
min-width: 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.item__text {
|
|
122
|
+
display: block;
|
|
123
|
+
font-size: 31rpx;
|
|
124
|
+
word-break: break-all;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.item_done .item__text {
|
|
128
|
+
text-decoration: line-through;
|
|
129
|
+
color: #8a8b8c;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.item__time {
|
|
133
|
+
display: block;
|
|
134
|
+
margin-top: 6rpx;
|
|
135
|
+
font-size: 22rpx;
|
|
136
|
+
color: #b1b2b3;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.item__del {
|
|
140
|
+
margin-left: 16rpx;
|
|
141
|
+
padding: 8rpx 12rpx;
|
|
142
|
+
font-size: 26rpx;
|
|
143
|
+
color: #fa5151;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.empty {
|
|
147
|
+
padding: 96rpx 24rpx;
|
|
148
|
+
text-align: center;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.empty__title {
|
|
152
|
+
font-size: 30rpx;
|
|
153
|
+
color: #7e8081;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.empty__desc {
|
|
157
|
+
margin-top: 12rpx;
|
|
158
|
+
font-size: 25rpx;
|
|
159
|
+
color: #b1b2b3;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.footer {
|
|
163
|
+
display: flex;
|
|
164
|
+
justify-content: space-between;
|
|
165
|
+
margin-top: 32rpx;
|
|
166
|
+
padding: 0 8rpx;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.footer__btn {
|
|
170
|
+
font-size: 27rpx;
|
|
171
|
+
color: #576b95;
|
|
172
|
+
padding: 12rpx 8rpx;
|
|
173
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用官方 CI 工具生成「体验版」预览二维码(图片落盘,可直接给用户扫)。
|
|
3
|
+
*
|
|
4
|
+
* 环境变量同 upload.js:MP_APPID / MP_KEY_PATH
|
|
5
|
+
* 可选:MP_QR_OUT 二维码输出路径,默认 ./preview-qrcode.png
|
|
6
|
+
*
|
|
7
|
+
* 用法:MP_APPID=wx... MP_KEY_PATH=/path/private.key node preview.js
|
|
8
|
+
*/
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const ci = require("miniprogram-ci");
|
|
12
|
+
|
|
13
|
+
const appid = process.env.MP_APPID;
|
|
14
|
+
const keyPath = process.env.MP_KEY_PATH;
|
|
15
|
+
|
|
16
|
+
if (!appid || !keyPath) {
|
|
17
|
+
console.error("缺少环境变量:需要 MP_APPID 和 MP_KEY_PATH");
|
|
18
|
+
process.exit(2);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const project = new ci.Project({
|
|
22
|
+
appid,
|
|
23
|
+
type: "miniProgram",
|
|
24
|
+
projectPath: __dirname,
|
|
25
|
+
privateKeyPath: path.resolve(keyPath),
|
|
26
|
+
ignores: ["node_modules/**/*", "tools/**/*"],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
(async () => {
|
|
30
|
+
const result = await ci.preview({
|
|
31
|
+
project,
|
|
32
|
+
desc: `预览 ${new Date().toISOString()}`,
|
|
33
|
+
setting: { es6: true, minify: true },
|
|
34
|
+
qrcodeFormat: "image",
|
|
35
|
+
qrcodeOutputDest: process.env.MP_QR_OUT || path.join(__dirname, "preview-qrcode.png"),
|
|
36
|
+
onProgressUpdate: (info) =>
|
|
37
|
+
console.log(
|
|
38
|
+
"[progress]",
|
|
39
|
+
typeof info === "string" ? info : JSON.stringify(info).slice(0, 200),
|
|
40
|
+
),
|
|
41
|
+
});
|
|
42
|
+
const out = process.env.MP_QR_OUT || path.join(__dirname, "preview-qrcode.png");
|
|
43
|
+
console.log(
|
|
44
|
+
"预览二维码:",
|
|
45
|
+
out,
|
|
46
|
+
fs.existsSync(out) ? `(${fs.statSync(out).size} 字节)` : "(未生成)",
|
|
47
|
+
);
|
|
48
|
+
if (result && result.subPackageInfo)
|
|
49
|
+
console.log("分包信息:", JSON.stringify(result.subPackageInfo).slice(0, 300));
|
|
50
|
+
})().catch((err) => {
|
|
51
|
+
console.error("生成预览失败:", err && err.message ? err.message : err);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "简单待办清单小程序",
|
|
3
|
+
"appid": "wxTEMPLATE_PLACEHOLDER",
|
|
4
|
+
"projectname": "todo-miniprogram",
|
|
5
|
+
"compileType": "miniprogram",
|
|
6
|
+
"miniprogramRoot": "./",
|
|
7
|
+
"libVersion": "latest",
|
|
8
|
+
"setting": {
|
|
9
|
+
"es6": true,
|
|
10
|
+
"enhance": true,
|
|
11
|
+
"postcss": true,
|
|
12
|
+
"minified": true,
|
|
13
|
+
"urlCheck": false,
|
|
14
|
+
"coverView": true,
|
|
15
|
+
"ignoreDevUnusedFiles": false,
|
|
16
|
+
"ignoreUploadUnusedFiles": true
|
|
17
|
+
},
|
|
18
|
+
"packOptions": {
|
|
19
|
+
"ignore": [
|
|
20
|
+
{ "type": "folder", "value": "node_modules" },
|
|
21
|
+
{ "type": "folder", "value": "tools" },
|
|
22
|
+
{ "type": "file", "value": "README.md" }
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 页面逻辑的无头测试:把 wx / Page / getApp 打桩后直接跑 pages/index 的业务方法。
|
|
3
|
+
* 微信开发者工具跑不了(服务器是 Linux 无图形界面),所以用这个保证核心逻辑正确。
|
|
4
|
+
* 用法:node tools/test-page.js
|
|
5
|
+
*/
|
|
6
|
+
const assert = require("assert");
|
|
7
|
+
|
|
8
|
+
let store = {};
|
|
9
|
+
const toasts = [];
|
|
10
|
+
let modalConfirm = true;
|
|
11
|
+
|
|
12
|
+
global.wx = {
|
|
13
|
+
getStorageSync: (k) => (k in store ? store[k] : ""),
|
|
14
|
+
setStorageSync: (k, v) => {
|
|
15
|
+
store[k] = v;
|
|
16
|
+
},
|
|
17
|
+
showToast: (o) => toasts.push(o && o.title),
|
|
18
|
+
showModal: (o) => {
|
|
19
|
+
if (o && o.success) o.success({ confirm: modalConfirm });
|
|
20
|
+
},
|
|
21
|
+
vibrateShort: () => {},
|
|
22
|
+
navigateTo: () => {},
|
|
23
|
+
};
|
|
24
|
+
global.getApp = () => ({ globalData: { version: "test" } });
|
|
25
|
+
|
|
26
|
+
let pageDef = null;
|
|
27
|
+
global.Page = (def) => {
|
|
28
|
+
pageDef = def;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
require("../pages/index/index.js");
|
|
32
|
+
assert.ok(pageDef, "Page() 没有被调用");
|
|
33
|
+
|
|
34
|
+
function newInstance() {
|
|
35
|
+
const inst = { data: JSON.parse(JSON.stringify(pageDef.data)) };
|
|
36
|
+
inst.setData = function (patch, cb) {
|
|
37
|
+
Object.assign(this.data, patch);
|
|
38
|
+
if (cb) cb();
|
|
39
|
+
};
|
|
40
|
+
for (const key of Object.keys(pageDef)) {
|
|
41
|
+
if (typeof pageDef[key] === "function") inst[key] = pageDef[key].bind(inst);
|
|
42
|
+
}
|
|
43
|
+
return inst;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const tap = (id) => ({ currentTarget: { dataset: { id } } });
|
|
47
|
+
|
|
48
|
+
// 1. 空存储时初始化
|
|
49
|
+
store = {};
|
|
50
|
+
let p = newInstance();
|
|
51
|
+
p.load();
|
|
52
|
+
assert.deepStrictEqual(p.data.counts, { total: 0, active: 0, done: 0 });
|
|
53
|
+
assert.strictEqual(p.data.visible.length, 0);
|
|
54
|
+
|
|
55
|
+
// 2. 空白输入不添加
|
|
56
|
+
p.setData({ input: " " });
|
|
57
|
+
p.addTodo();
|
|
58
|
+
assert.strictEqual(p.data.todos.length, 0, "空白输入不应新增");
|
|
59
|
+
assert.ok(toasts.includes("先写点内容"), "应提示先写内容");
|
|
60
|
+
|
|
61
|
+
// 3. 正常添加:去空格、置顶、清空输入、落盘
|
|
62
|
+
p.setData({ input: " 写周报 " });
|
|
63
|
+
p.addTodo();
|
|
64
|
+
assert.strictEqual(p.data.todos.length, 1);
|
|
65
|
+
assert.strictEqual(p.data.todos[0].text, "写周报");
|
|
66
|
+
assert.strictEqual(p.data.input, "");
|
|
67
|
+
assert.strictEqual(store["todos:v1"].length, 1, "应写入本地存储");
|
|
68
|
+
assert.ok(p.data.todos[0].timeText, "应有时间文案");
|
|
69
|
+
assert.strictEqual(p.data.counts.active, 1);
|
|
70
|
+
|
|
71
|
+
// 4. 再添加一条,新的排在最前
|
|
72
|
+
p.setData({ input: "买牛奶" });
|
|
73
|
+
p.addTodo();
|
|
74
|
+
assert.strictEqual(p.data.todos[0].text, "买牛奶");
|
|
75
|
+
assert.strictEqual(p.data.counts.total, 2);
|
|
76
|
+
|
|
77
|
+
// 5. 切换完成状态
|
|
78
|
+
const firstId = p.data.todos[0].id;
|
|
79
|
+
p.toggleTodo(tap(firstId));
|
|
80
|
+
assert.strictEqual(p.data.todos[0].done, true);
|
|
81
|
+
assert.deepStrictEqual(p.data.counts, { total: 2, active: 1, done: 1 });
|
|
82
|
+
|
|
83
|
+
// 6. 筛选
|
|
84
|
+
p.setData({ filter: "done" });
|
|
85
|
+
p.commit(p.data.todos);
|
|
86
|
+
assert.strictEqual(p.data.visible.length, 1);
|
|
87
|
+
assert.strictEqual(p.data.visible[0].id, firstId);
|
|
88
|
+
p.setFilter({ currentTarget: { dataset: { filter: "active" } } });
|
|
89
|
+
assert.strictEqual(p.data.visible.length, 1);
|
|
90
|
+
assert.strictEqual(p.data.visible[0].text, "写周报");
|
|
91
|
+
p.setFilter({ currentTarget: { dataset: { filter: "all" } } });
|
|
92
|
+
assert.strictEqual(p.data.visible.length, 2);
|
|
93
|
+
|
|
94
|
+
// 7. 取消删除时数据不动
|
|
95
|
+
modalConfirm = false;
|
|
96
|
+
p.removeTodo(tap(firstId));
|
|
97
|
+
assert.strictEqual(p.data.todos.length, 2, "取消后不应删除");
|
|
98
|
+
|
|
99
|
+
// 8. 确认删除
|
|
100
|
+
modalConfirm = true;
|
|
101
|
+
p.removeTodo(tap(firstId));
|
|
102
|
+
assert.strictEqual(p.data.todos.length, 1);
|
|
103
|
+
assert.strictEqual(p.data.counts.done, 0);
|
|
104
|
+
assert.strictEqual(store["todos:v1"].length, 1, "删除后存储同步");
|
|
105
|
+
|
|
106
|
+
// 9. 持久化 round-trip:新实例能读回
|
|
107
|
+
const p2 = newInstance();
|
|
108
|
+
p2.load();
|
|
109
|
+
assert.strictEqual(p2.data.todos.length, 1);
|
|
110
|
+
assert.strictEqual(p2.data.todos[0].text, "写周报");
|
|
111
|
+
|
|
112
|
+
// 10. 清空已完成
|
|
113
|
+
p2.toggleTodo(tap(p2.data.todos[0].id));
|
|
114
|
+
p2.clearDone();
|
|
115
|
+
assert.strictEqual(p2.data.todos.length, 0);
|
|
116
|
+
assert.strictEqual(store["todos:v1"].length, 0);
|
|
117
|
+
|
|
118
|
+
// 11. 落盘时不应把展示用的 timeText 也存进去
|
|
119
|
+
p2.setData({ input: "检查存储字段" });
|
|
120
|
+
p2.addTodo();
|
|
121
|
+
assert.ok(!("timeText" in store["todos:v1"][0]), "存储里不应包含 timeText");
|
|
122
|
+
|
|
123
|
+
console.log("✅ 页面逻辑测试全部通过(11 项)");
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 校验小程序工程结构(不依赖微信开发者工具,纯 Node)
|
|
3
|
+
* 检查:app.json 声明的页面四件套是否齐全、所有 JSON 能否解析、所有 JS 语法是否合法、
|
|
4
|
+
* WXML 的插值括号是否配对、project.config.json 的 appid 是否还是占位值。
|
|
5
|
+
*/
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const { execFileSync } = require("child_process");
|
|
9
|
+
|
|
10
|
+
const root = path.resolve(__dirname, "..");
|
|
11
|
+
const errors = [];
|
|
12
|
+
const warnings = [];
|
|
13
|
+
const rel = (p) => path.relative(root, p);
|
|
14
|
+
|
|
15
|
+
function readJson(file) {
|
|
16
|
+
const text = fs.readFileSync(file, "utf8");
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(text);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
errors.push(`${rel(file)} JSON 解析失败: ${e.message}`);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 1. 遍历全部 json / wxml,做语法层面检查
|
|
26
|
+
function walk(dir) {
|
|
27
|
+
for (const name of fs.readdirSync(dir)) {
|
|
28
|
+
if (name === "node_modules" || name.startsWith(".")) continue;
|
|
29
|
+
const full = path.join(dir, name);
|
|
30
|
+
const stat = fs.statSync(full);
|
|
31
|
+
if (stat.isDirectory()) {
|
|
32
|
+
walk(full);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (name.endsWith(".json")) readJson(full);
|
|
36
|
+
if (name.endsWith(".wxml")) {
|
|
37
|
+
const t = fs.readFileSync(full, "utf8");
|
|
38
|
+
const open = (t.match(/\{\{/g) || []).length;
|
|
39
|
+
const close = (t.match(/\}\}/g) || []).length;
|
|
40
|
+
if (open !== close) errors.push(`${rel(full)} 插值括号不配对:{{ ×${open} vs }} ×${close}`);
|
|
41
|
+
}
|
|
42
|
+
if (name.endsWith(".js")) {
|
|
43
|
+
if (/^\s*(import|export)\s/m.test(fs.readFileSync(full, "utf8"))) {
|
|
44
|
+
errors.push(`${rel(full)} 使用了 ESM 语法,小程序页面应使用 CommonJS`);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
execFileSync(process.execPath, ["--check", full], { stdio: "pipe" });
|
|
48
|
+
} catch (e) {
|
|
49
|
+
errors.push(`${rel(full)} 语法错误: ${String(e.stderr || e.message).split("\n")[0]}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 2. app.json 页面四件套
|
|
56
|
+
const appJsonPath = path.join(root, "app.json");
|
|
57
|
+
const appJson = fs.existsSync(appJsonPath)
|
|
58
|
+
? readJson(appJsonPath)
|
|
59
|
+
: (errors.push("缺少 app.json"), null);
|
|
60
|
+
if (appJson) {
|
|
61
|
+
if (!Array.isArray(appJson.pages) || appJson.pages.length === 0)
|
|
62
|
+
errors.push("app.json 没有声明 pages");
|
|
63
|
+
for (const page of appJson.pages || []) {
|
|
64
|
+
for (const ext of ["js", "wxml", "json"]) {
|
|
65
|
+
const f = path.join(root, `${page}.${ext}`);
|
|
66
|
+
if (!fs.existsSync(f)) errors.push(`页面文件缺失: ${page}.${ext}`);
|
|
67
|
+
}
|
|
68
|
+
if (!fs.existsSync(path.join(root, `${page}.wxss`)))
|
|
69
|
+
warnings.push(`${page}.wxss 不存在(不是必须)`);
|
|
70
|
+
}
|
|
71
|
+
if (appJson.sitemapLocation && !fs.existsSync(path.join(root, appJson.sitemapLocation))) {
|
|
72
|
+
errors.push(`sitemapLocation 指向的文件不存在: ${appJson.sitemapLocation}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 3. 入口文件
|
|
77
|
+
for (const f of ["app.js", "app.wxss", "project.config.json"]) {
|
|
78
|
+
if (!fs.existsSync(path.join(root, f))) errors.push(`缺少 ${f}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 4. appid 占位提醒
|
|
82
|
+
const pcPath = path.join(root, "project.config.json");
|
|
83
|
+
if (fs.existsSync(pcPath)) {
|
|
84
|
+
const pc = readJson(pcPath);
|
|
85
|
+
if (pc && ["touristappid", "", undefined].includes(pc.appid)) {
|
|
86
|
+
warnings.push(
|
|
87
|
+
`project.config.json 的 appid 仍是占位值「${pc.appid}」,正式上传前需替换为真实 AppID`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
walk(root);
|
|
93
|
+
|
|
94
|
+
if (warnings.length) {
|
|
95
|
+
console.log("提醒:");
|
|
96
|
+
warnings.forEach((w) => console.log(" ⚠ " + w));
|
|
97
|
+
}
|
|
98
|
+
if (errors.length) {
|
|
99
|
+
console.log("发现 " + errors.length + " 个问题:");
|
|
100
|
+
errors.forEach((e) => console.log(" ✗ " + e));
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
console.log("✅ 校验通过:页面结构、JSON、JS 语法、WXML 插值均正常");
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用官方 CI 工具上传代码,生成开发版/体验版(不需要微信开发者工具,Linux 可跑)。
|
|
3
|
+
*
|
|
4
|
+
* 需要两个环境变量:
|
|
5
|
+
* MP_APPID 小程序 AppID(wx 开头)
|
|
6
|
+
* MP_KEY_PATH 后台「开发管理 → 开发设置 → 小程序代码上传」生成的密钥文件路径
|
|
7
|
+
* 可选:
|
|
8
|
+
* MP_VERSION 版本号,默认 1.0.0
|
|
9
|
+
* MP_DESC 版本描述,默认时间戳
|
|
10
|
+
*
|
|
11
|
+
* 用法:MP_APPID=wx... MP_KEY_PATH=/path/private.key node upload.js
|
|
12
|
+
*/
|
|
13
|
+
const path = require("path");
|
|
14
|
+
const ci = require("miniprogram-ci");
|
|
15
|
+
|
|
16
|
+
const appid = process.env.MP_APPID;
|
|
17
|
+
const keyPath = process.env.MP_KEY_PATH;
|
|
18
|
+
|
|
19
|
+
if (!appid || !keyPath) {
|
|
20
|
+
console.error("缺少环境变量:需要 MP_APPID 和 MP_KEY_PATH");
|
|
21
|
+
process.exit(2);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const project = new ci.Project({
|
|
25
|
+
appid,
|
|
26
|
+
type: "miniProgram",
|
|
27
|
+
projectPath: __dirname,
|
|
28
|
+
privateKeyPath: path.resolve(keyPath),
|
|
29
|
+
ignores: ["node_modules/**/*", "tools/**/*"],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
(async () => {
|
|
33
|
+
const result = await ci.upload({
|
|
34
|
+
project,
|
|
35
|
+
version: process.env.MP_VERSION || "1.0.0",
|
|
36
|
+
desc: process.env.MP_DESC || `CI 上传 ${new Date().toISOString()}`,
|
|
37
|
+
setting: { es6: true, minify: true, autoPrefixWXSS: true },
|
|
38
|
+
onProgressUpdate: (info) =>
|
|
39
|
+
console.log(
|
|
40
|
+
"[progress]",
|
|
41
|
+
typeof info === "string" ? info : JSON.stringify(info).slice(0, 200),
|
|
42
|
+
),
|
|
43
|
+
});
|
|
44
|
+
console.log("上传完成:", result && result.subPackageInfo ? "已上传分包信息" : "已上传");
|
|
45
|
+
console.log("接着去 mp.weixin.qq.com → 管理 → 版本管理,把这次上传设为体验版 / 提交审核");
|
|
46
|
+
})().catch((err) => {
|
|
47
|
+
console.error("上传失败:", err && err.message ? err.message : err);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
});
|
package/README.md
DELETED