-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexample.js
69 lines (62 loc) · 1.36 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const _ = require("lodash");
const MinaAdmin = require("./lib/index.js");
const admin = new MinaAdmin.Admin({
account: "",
password: ""
});
async function main() {
await admin.init();
await admin.login();
await admin.command("mina_visit_official_source")();
const base64Img = await admin.command("mina_qrcode")({
type: "gen",
appId: "抽奖助手",
appPath: "pages/index"
});
console.log(base64Img);
const users = await admin.command("mina_expr_users")({
type: "list"
});
const user = _.find(users, u => {
return u.nickname === "musk";
});
await admin.exec("mina_expr_users", {
type: "remove",
users: [
{
openid: user.openid,
authority: 0
}
]
});
await admin.command("mina_expr_users")({
type: "add",
users: [
{
username: "musk",
authority: 8
}
]
});
const codes = await admin.command("mina_code")({
type: "list"
});
const targtCode = _.find(codes.dev, code => {
return !code.is_exper;
});
if (targtCode) {
const result = await admin.exec("mina_code", {
type: "expr",
code: targtCode
});
console.log(result);
}
const experCode = codes.exper;
if (experCode.status === MinaAdmin.MINA_CODE_REVIEW_PASS) {
await admin.exec("mina_code", {
type: "publish",
code: experCode
});
}
}
main();