minidev 1.0.3 → 1.0.7
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/assets/web-sim/devtool/index.html +18 -0
- package/assets/web-sim/devtool/main.js +2 -0
- package/assets/web-sim/devtool/main.js.LICENSE.txt +47 -0
- package/assets/web-sim/index.html +17 -0
- package/assets/web-sim/main.js +2 -0
- package/assets/web-sim/main.js.LICENSE.txt +82 -0
- package/assets/web-sim/simulator/index.html +18 -0
- package/assets/web-sim/simulator/main.js +2 -0
- package/assets/web-sim/simulator/main.js.LICENSE.txt +67 -0
- package/docs/guide/base/cli.md +37 -0
- package/docs/guide/base/node-js-api.md +31 -0
- package/docs/guide/base/quick-start.md +135 -0
- package/docs/guide/commands/build.md +103 -0
- package/docs/guide/commands/config.md +79 -0
- package/docs/guide/commands/dev-daemon-commands/ide.md +70 -0
- package/docs/guide/commands/dev-daemon-commands/preview.md +54 -0
- package/docs/guide/commands/dev-daemon-commands/remote-debug.md +63 -0
- package/docs/guide/commands/dev-daemon-commands/web.md +110 -0
- package/docs/guide/commands/dev.md +150 -0
- package/docs/guide/commands/download-assets.md +48 -0
- package/docs/guide/commands/ide.md +117 -0
- package/docs/guide/commands/index.md +19 -0
- package/docs/guide/commands/login.md +53 -0
- package/docs/guide/commands/preview.md +121 -0
- package/docs/guide/commands/remote-debug.md +137 -0
- package/docs/guide/commands/upload.md +95 -0
- package/docs/guide/experiences/auth.md +65 -0
- package/docs/guide/experiences/client-type.md +16 -0
- package/docs/guide/experiences/config.md +127 -0
- package/docs/guide/experiences/sandbox.md +12 -0
- package/docs/guide/experiences/scene.md +33 -0
- package/index.d.ts +65 -7
- package/lib/index.js +1 -1
- package/lib/index.js.LICENSE.txt +195 -0
- package/lib/worker.js +2 -0
- package/lib/worker.js.LICENSE.txt +14 -0
- package/package.json +8 -6
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# remote-debug
|
|
2
|
+
## 用途
|
|
3
|
+
|
|
4
|
+
构建小程序并发起真机调试。
|
|
5
|
+
|
|
6
|
+
运行后,支付宝小程序 CLI 将会构建可以在手机 App (如支付宝钱包)中使用的真机调试版小程序,并将其发布到支付宝开放平台供手机 App 访问。
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
运行成功后,将会返回可供手机 App 扫描的小程序真机调试二维码,使用对应手机 App 扫码即可查看小程序。部分 App 支持自动同步小程序到手机 App 中,无需进行扫码操作。
|
|
11
|
+
|
|
12
|
+
同时,CLI 会输出可以在浏览器中打开的调试连接,使用浏览器打开后即可开始进行真机调试(默认尝试自动打开)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
> 使用该指令要求工具进行[授权](../../guide/experiences/auth.md)
|
|
16
|
+
|
|
17
|
+
## CLI 风格使用
|
|
18
|
+
|
|
19
|
+
````
|
|
20
|
+
Usage: minidev remote-debug [options]
|
|
21
|
+
|
|
22
|
+
发起真机调试
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
--auto-push [可选] 自动推送到客户端, 默认打开, 使用 --no-auto-push 来关 (default: true)
|
|
26
|
+
--ignore-http-domain-check [可选] 忽略 http 请求白名单校验
|
|
27
|
+
--ignore-webview-domain-check [可选] 忽略 webview 加载域名白名单校验
|
|
28
|
+
-a, --app-id <appId> [必填] 小程序应用 id
|
|
29
|
+
-c, --client-type <clientType> [可选] 端类型
|
|
30
|
+
--page <page> [可选] 入口页面
|
|
31
|
+
--page-query <page> [可选] 页面参数, 可在当前页面的 onLoad 中取得,如: name=vendor&color=black
|
|
32
|
+
--query <page> [可选] 全局参数,app.js 的 onLaunch 中取得,如: name=vendor&color=black
|
|
33
|
+
--scene <page> [可选] 进入场景值
|
|
34
|
+
````
|
|
35
|
+
|
|
36
|
+
## Node.js API 风格使用
|
|
37
|
+
|
|
38
|
+
````javascript
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
qrcodeSchema,
|
|
42
|
+
qrcodeUrl,
|
|
43
|
+
debugUrl
|
|
44
|
+
} = await minidev.remoteDebug({
|
|
45
|
+
appId: 'YourAppId',
|
|
46
|
+
project: '/path/to/mini-program',
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// 真机调试二维码图片地址
|
|
50
|
+
console.log(qrcodeUrl);
|
|
51
|
+
|
|
52
|
+
// 真机调试 schema url,允许手机 App 通过这个 url 唤起调试小程序
|
|
53
|
+
console.log(qrcodeSchema);
|
|
54
|
+
|
|
55
|
+
// 可在浏览器中打开的调试器应用地址
|
|
56
|
+
console.log(debugUrl);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
````
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## 参数说明
|
|
63
|
+
|
|
64
|
+
### appId
|
|
65
|
+
````Typescript
|
|
66
|
+
appId: string
|
|
67
|
+
````
|
|
68
|
+
本次真机调试使用的小程序 App Id。
|
|
69
|
+
|
|
70
|
+
### clientType
|
|
71
|
+
````Typescript
|
|
72
|
+
clientType: string
|
|
73
|
+
````
|
|
74
|
+
|
|
75
|
+
指定真机调试的目标端类型,默认为 alipay (支付宝),详见[端类型](../../guide/experiences/client-type.md)。
|
|
76
|
+
|
|
77
|
+
### autoPush
|
|
78
|
+
````Typescript
|
|
79
|
+
autoPush: boolean
|
|
80
|
+
````
|
|
81
|
+
|
|
82
|
+
如果指定的端(手机 App) 支持,则尝试将调试的小程序直接推送到端,无需进行扫码操作。 此功能默认开启。
|
|
83
|
+
|
|
84
|
+
### ignoreHttpDomainCheck
|
|
85
|
+
````Typescript
|
|
86
|
+
ignoreHttpDomainCheck: boolean
|
|
87
|
+
````
|
|
88
|
+
|
|
89
|
+
此次真机调试的小程序运行时忽略 http 请求白名单校验。详见 [小程序网络 API 使用须知](https://opendocs.alipay.com/mini/008gq6)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### ignoreWebviewDomainCheck
|
|
93
|
+
````Typescript
|
|
94
|
+
ignoreWebviewDomainCheck: boolean
|
|
95
|
+
````
|
|
96
|
+
|
|
97
|
+
此次真机调试的小程序运行时忽略 web-view 组件加载域名白名单校验。详见[ web-view 组件 H5 域名配置](https://opendocs.alipay.com/mini/component/idfvg6)
|
|
98
|
+
|
|
99
|
+
### page
|
|
100
|
+
````Typescript
|
|
101
|
+
page: string
|
|
102
|
+
````
|
|
103
|
+
|
|
104
|
+
本次调试的入口页面路径。 例: `/page/index/index`.
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### pageQuery
|
|
108
|
+
|
|
109
|
+
````Typescript
|
|
110
|
+
pageQuery: string
|
|
111
|
+
````
|
|
112
|
+
|
|
113
|
+
本次调试的页面参数。可在当前页面的 onLoad 中取得,例: `name=vendor&color=black`
|
|
114
|
+
|
|
115
|
+
### query
|
|
116
|
+
````Typescript
|
|
117
|
+
query: string
|
|
118
|
+
````
|
|
119
|
+
|
|
120
|
+
本次调试的全局参数。 可在 app.js 的 onLaunch 中取得,例: `name=vendor&color=black`
|
|
121
|
+
|
|
122
|
+
### scene
|
|
123
|
+
|
|
124
|
+
````Typescript
|
|
125
|
+
scene: string
|
|
126
|
+
````
|
|
127
|
+
本次调试的场景值。 输入值为场景的 channelId。例: `ch_appcenter`
|
|
128
|
+
|
|
129
|
+
可选值可参考[支持的场景值](../../guide/experiences/scene.md)。
|
|
130
|
+
|
|
131
|
+
### autoOpenDevtools
|
|
132
|
+
|
|
133
|
+
````Typescript
|
|
134
|
+
autoOpenDevtools: boolean
|
|
135
|
+
````
|
|
136
|
+
|
|
137
|
+
是否尝试使用默认浏览器自动打开调试器窗口。cli 模式默认自动打开, Node.js API 调用默认不打开。
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# upload
|
|
2
|
+
|
|
3
|
+
## 用途
|
|
4
|
+
|
|
5
|
+
上传小程序以进行[提审](https://opendocs.alipay.com/mini/introduce/release)。
|
|
6
|
+
|
|
7
|
+
> 使用该指令要求工具进行[授权](../../guide/experiences/auth.md)
|
|
8
|
+
|
|
9
|
+
## CLI 风格使用
|
|
10
|
+
|
|
11
|
+
````shell
|
|
12
|
+
Usage: minidev upload [options]
|
|
13
|
+
|
|
14
|
+
上传发布小程序
|
|
15
|
+
|
|
16
|
+
Options:
|
|
17
|
+
-d, --delete-version <deleteVersion> [可选] 上传时,删除指定版本的版本号 (需要对应权限)
|
|
18
|
+
-e, --experience [可选] 上传成功后,自动设置为体验版本 (需要对应权限)
|
|
19
|
+
-v, --version [version] [可选] 上传包版本
|
|
20
|
+
-p, --project <project> [可选] 目标项目, 默认为当前工作目录
|
|
21
|
+
-a, --app-id <appId> [必填] 小程序应用 id
|
|
22
|
+
-c, --client-type <clientType> [可选] 端类型
|
|
23
|
+
|
|
24
|
+
````
|
|
25
|
+
|
|
26
|
+
## Node.js API 风格使用
|
|
27
|
+
|
|
28
|
+
````javascript
|
|
29
|
+
|
|
30
|
+
const uploadResult = await minidev.upload({
|
|
31
|
+
appId: 'yourAppId',
|
|
32
|
+
version: '0.0.1',
|
|
33
|
+
project: '/path/to/mini-program'
|
|
34
|
+
// experience: true 添加 experience 选项的话可以一并把刚上传的版本设置为体验版
|
|
35
|
+
}, {
|
|
36
|
+
onLog: (data) => {
|
|
37
|
+
// 输出日志
|
|
38
|
+
console.log(data);
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// 打印上传版本
|
|
43
|
+
console.log(uploadResult.version);
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
````
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## 参数说明
|
|
50
|
+
|
|
51
|
+
### clientType
|
|
52
|
+
|
|
53
|
+
````Typescript
|
|
54
|
+
clientType: string
|
|
55
|
+
````
|
|
56
|
+
|
|
57
|
+
指定上传提审的目标端类型,默认为 alipay (支付宝),详见[端类型](../../guide/experiences/client-type.md)
|
|
58
|
+
|
|
59
|
+
### deleteVersion
|
|
60
|
+
|
|
61
|
+
````Typescript
|
|
62
|
+
deleteVersion: string
|
|
63
|
+
````
|
|
64
|
+
|
|
65
|
+
如果添加这个参数,在上传过程中会删除指定的版本(即使它正在构建中或不存在)。记录已上传的版本并使用这个参数能有效避免上传版本无法超过 20 个的问题。
|
|
66
|
+
|
|
67
|
+
### appId
|
|
68
|
+
|
|
69
|
+
````Typescript
|
|
70
|
+
appId: string
|
|
71
|
+
````
|
|
72
|
+
|
|
73
|
+
需要上传的小程序的 appId。
|
|
74
|
+
|
|
75
|
+
### version
|
|
76
|
+
|
|
77
|
+
````Typescript
|
|
78
|
+
version: string
|
|
79
|
+
````
|
|
80
|
+
|
|
81
|
+
指定上传的版本号,必须满足 x.y.z 的格式,其中x,y,z 必须都为数字。
|
|
82
|
+
|
|
83
|
+
合法版本号如 `0.0.1`, `10.2.14` 等
|
|
84
|
+
|
|
85
|
+
> 如果不提供版本号,本次上传的版本会根据当前最新的已上传版本号添加一位 patch 版本号(最后一位数字)
|
|
86
|
+
>
|
|
87
|
+
> 比如:之前的最新已上传版本号为 0.2.3, 则本次使用的是 0.2.4
|
|
88
|
+
|
|
89
|
+
### experience
|
|
90
|
+
|
|
91
|
+
````Typescript
|
|
92
|
+
experience: boolean
|
|
93
|
+
````
|
|
94
|
+
|
|
95
|
+
上传成功后,自动设置为[体验版本](https://opendocs.alipay.com/mini/introduce/release#%E8%AE%BE%E7%BD%AE%E4%BD%93%E9%AA%8C%E7%89%88%EF%BC%88%E5%8F%AF%E9%80%89%EF%BC%89) (需要对应小程序的管理员权限)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# 授权信息 & 多机器使用
|
|
2
|
+
|
|
3
|
+
## 授权信息
|
|
4
|
+
|
|
5
|
+
支付宝小程序 CLI 的授权信息在用户使用机器上存储的是一对工具Id `toolId` 和 私钥 `privateKey` 的键值对,对应位于开放平台存储的公钥 `publicKey` 可以在[开放平台工具授权页面](https://open.alipay.com/dev/workspace/key-manage/tool)查看。
|
|
6
|
+
|
|
7
|
+
当需要开始使用 CLI 工具时,可以通过 [login](../commands/login.md) 进行快速授权
|
|
8
|
+
|
|
9
|
+
````shell
|
|
10
|
+
minidev login
|
|
11
|
+
````
|
|
12
|
+
|
|
13
|
+
**一个支付宝用户同一时刻仅能存在一个工具授权信息**。 因此,当在不同的电脑上执行 `minidev login` 进行授权时,会重新生成 toolId 和公私钥,从而导致之前的授权失效。
|
|
14
|
+
|
|
15
|
+
## 授权信息存储位置
|
|
16
|
+
|
|
17
|
+
授权信息存储在用户目录下 minidev 的资料目录中的配置文件中,默认位置在
|
|
18
|
+
|
|
19
|
+
* `MacOS/Linux` ~/.minidev/config.json
|
|
20
|
+
* `Windows` C:\\User\\你的用户名\\.minidev/config.json
|
|
21
|
+
|
|
22
|
+
对应的配置键为 `alipay.authentication`。 配置相关能力见文档[配置的使用](./config.md)
|
|
23
|
+
|
|
24
|
+
## 多机器使用
|
|
25
|
+
|
|
26
|
+
在诸如 ci/cd 的应用场景,由于上述[授权信息的唯一性](##授权信息的唯一性), 我们不能在每一台机器上都通过执行 `minidev login` 来重复进行授权,此时我们建议将上述包含授权信息的配置文件分发到每一台机器上,或者使用运行时配置来注入授权信息。配置项的使用详见[工具配置](./config.md);
|
|
27
|
+
|
|
28
|
+
### 使用配置项环境变量
|
|
29
|
+
|
|
30
|
+
````shell
|
|
31
|
+
export MINIDEV_RUNTIME_CONFIG={"alipay.authentication":{"privateKey": "xxxxxxxxxx", "toolId": "xxxxxxxxxx"}}
|
|
32
|
+
minidev upload -a xxxxxxx
|
|
33
|
+
````
|
|
34
|
+
|
|
35
|
+
### Node.js API 修改授权信息
|
|
36
|
+
Node.js 中的 useDefaults 或者 config.useRuntime 来初始化 minidev 的运行授权信息
|
|
37
|
+
|
|
38
|
+
```` javascript
|
|
39
|
+
|
|
40
|
+
const { minidev, useDefaults } = require('minidev');
|
|
41
|
+
|
|
42
|
+
// 方式 1. 注入默认授权信息
|
|
43
|
+
useDefaults({
|
|
44
|
+
config: {
|
|
45
|
+
defaults: {
|
|
46
|
+
'alipay.authentication.privateKey': 'xxxxxxxxxx',
|
|
47
|
+
'alipay.authentication.toolId': 'xxxxxxxxxx',
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// 方式 2. 注入默认授权信息
|
|
53
|
+
minidev.config.useRuntime({
|
|
54
|
+
'alipay.authentication.privateKey': 'xxxxxxxxxx',
|
|
55
|
+
'alipay.authentication.toolId': 'xxxxxxxxxx',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// 执行需要授权的 api
|
|
59
|
+
minidev.upload({
|
|
60
|
+
appId:'xxxxxxxx',
|
|
61
|
+
project: '/path/to/mini-program'
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
````
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 端类型
|
|
2
|
+
|
|
3
|
+
`preview`、`remote-debug`, `upload` 等指令允许通过传入 `clientType` 参数来指定端类型以开发不同类型的小程序。目前支持的端类型列表如下:
|
|
4
|
+
|
|
5
|
+
- `alipay` 支付宝
|
|
6
|
+
- `ampe` 支付宝 AMPE 设备
|
|
7
|
+
- `amap` 高德地图
|
|
8
|
+
- `genie` 天猫精灵
|
|
9
|
+
- `alios` 阿里车
|
|
10
|
+
- `alipayiot` 支付宝 IOT 设备
|
|
11
|
+
- `uc` UC 浏览器
|
|
12
|
+
- `quark` 夸克浏览器
|
|
13
|
+
- `health` 阿里医院
|
|
14
|
+
- `koubei` 口碑
|
|
15
|
+
- `cainiao` 菜鸟
|
|
16
|
+
- `alihealth` 医蝶谷
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# 工具配置
|
|
2
|
+
|
|
3
|
+
## 配置项
|
|
4
|
+
|
|
5
|
+
支付宝小程序 CLI 的配置选项为 `key-value` 键值对存储的字符串、布尔值或者 JSON Object。获取和设置配置项时,可以通过 `minidev config set/get key [value]` 指令来进行操作。
|
|
6
|
+
|
|
7
|
+
> 典型的配置 key 例子:
|
|
8
|
+
> - `alipay.authentication.privateKey` 工具授权的 privateKey
|
|
9
|
+
> - `compiler.version` 编译器版本
|
|
10
|
+
|
|
11
|
+
### 配置项解构和聚合
|
|
12
|
+
|
|
13
|
+
当配置项遇到 JSON Object 类型的配置项时,会根据需要对其进行解构或者聚合。
|
|
14
|
+
|
|
15
|
+
比如,如下三个配置项是等价的:
|
|
16
|
+
|
|
17
|
+
````javascript
|
|
18
|
+
// 完全解构
|
|
19
|
+
{
|
|
20
|
+
"alipay.authentication.privateKey":"myPrivateKey"
|
|
21
|
+
}
|
|
22
|
+
// 完全聚合
|
|
23
|
+
{
|
|
24
|
+
"alipay": {
|
|
25
|
+
"authentication": {
|
|
26
|
+
"privateKey": "myPrivateKey"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// 半解构半聚合
|
|
31
|
+
{
|
|
32
|
+
"alipay.authentication": {
|
|
33
|
+
"privateKey": "myPrivateKey"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
````
|
|
38
|
+
|
|
39
|
+
> 在解析过程中可能会产生冲突,一般会尝试按照顺序进行解析,如果产生不可被解析的情况,配置模块将会抛出错误
|
|
40
|
+
|
|
41
|
+
## 多级配置
|
|
42
|
+
|
|
43
|
+
支付宝小程序 CLI 使用了**多级配置**概念来管理工具的配置项。整个工具拥有四个等级的配置级别
|
|
44
|
+
|
|
45
|
+
- `RUNTIME`: 运行时的配置项,仅仅存在在单次的 Node.js 运行上下文,或者单次 CLI 调用中。
|
|
46
|
+
- `PROJECT`: 项目的配置。项目配置项会默认存储在项目目录下 .minidev/config.json 中。
|
|
47
|
+
- `GLOBAL`: 当前设备(如果存在多用户的话则是当前用户)的配置,默认存储在用户目录 `(MacOS 为 ~, Windows为 C:\\User\\你的用户名)` 下的 .minidev/config.json 中。
|
|
48
|
+
- `DEFAULT`: 支付宝小程序 CLI 的默认配置
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
这四个级别为从下到上依次被覆盖的关系。即对于同一个 key 的配置项,生效优先级为 `RUNTIME` > `PROJECT` > `GLOBAL` > `DEFAULT`
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
比如考虑一下配置项值表
|
|
55
|
+
|
|
56
|
+
````javascript
|
|
57
|
+
{
|
|
58
|
+
"RUNTIME": {
|
|
59
|
+
"key1":"key1_runtime",
|
|
60
|
+
},
|
|
61
|
+
"PROJECT": {
|
|
62
|
+
"key1":"key1_project",
|
|
63
|
+
"key2.key3": "key3_project",
|
|
64
|
+
},
|
|
65
|
+
"GLOBAL": {
|
|
66
|
+
"key2": {
|
|
67
|
+
"key3": "key3_global",
|
|
68
|
+
"key4": "key4_global",
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"DEFAULT": {
|
|
72
|
+
"key5": {
|
|
73
|
+
"key6": "key6_default",
|
|
74
|
+
},
|
|
75
|
+
"key1": "key1_default"
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
````
|
|
79
|
+
|
|
80
|
+
最终等价的配置值表为:
|
|
81
|
+
|
|
82
|
+
````javascript
|
|
83
|
+
{
|
|
84
|
+
"key1":"key1_runtime",
|
|
85
|
+
"key2": {
|
|
86
|
+
"key3":"key3_project",
|
|
87
|
+
"key4":"key4_global",
|
|
88
|
+
},
|
|
89
|
+
"key5": {
|
|
90
|
+
"key6": "key6_default",
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
````
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## 使用环境变量改变 config
|
|
97
|
+
|
|
98
|
+
支付宝小程序 CLI 允许使用环境变量来改变 `RUNTIME` 的配置值。传入 JSON 序列化后的配置项即可。
|
|
99
|
+
|
|
100
|
+
````shell
|
|
101
|
+
MINIDEV_RUNTIME_CONFIG={"compiler.version.cube":"0.55.20"} minidev build
|
|
102
|
+
````
|
|
103
|
+
|
|
104
|
+
## Node.js API 中工具设置的使用
|
|
105
|
+
|
|
106
|
+
minidev 提供了 `useDefaults` 和 `minidev.config.useRuntime` 指令来允许在 Node.js API 调用时
|
|
107
|
+
|
|
108
|
+
````javascript
|
|
109
|
+
const { minidev, useDefaults } = require('minidev');
|
|
110
|
+
|
|
111
|
+
// 使用 useDefaults 设置 **DEFAULT** 的配置值
|
|
112
|
+
// 注意 useDefaults 必须在 minidev 的任何指令执行前执行,否则会报错。
|
|
113
|
+
useDefaults({
|
|
114
|
+
config: {
|
|
115
|
+
defaults: {
|
|
116
|
+
'alipay.authentication.privateKey': 'xxxxxxxxxx',
|
|
117
|
+
'alipay.authentication.toolId': 'xxxxxxxxxx',
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// 使用 config.useRuntime 来指定 **RUNTIME** 的配置值
|
|
123
|
+
minidev.config.useRuntime({
|
|
124
|
+
'compiler.version.cube': '0.55.20',
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
````
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
# 支持的场景值
|
|
3
|
+
|
|
4
|
+
指令 preview, remote-debug 等支持传入场景值 `channelId` 来模拟[小程序场景值](https://opendocs.alipay.com/mini/framework/scene)
|
|
5
|
+
|
|
6
|
+
目前**仅支付宝端支持传入场景值id, 其他端传入无效**
|
|
7
|
+
|
|
8
|
+
| `channelId` | `ID` | 含义 |
|
|
9
|
+
| ---- | ---- | ---- |
|
|
10
|
+
| ch_appcenter | 1000 | 首页12宫格及更多 |
|
|
11
|
+
| ch_tinycenter | 1001 | 朋友栏小程序主入口,包含最近,收藏,推荐和附近 |
|
|
12
|
+
| ch_appcollect | 1002 | 小程序收藏应用入口,包含朋友tab中的入口 |
|
|
13
|
+
| ch_alipaysearch | 1005 | 顶部搜索框的搜索结果页 |
|
|
14
|
+
| ch_share | 1007 | 单人聊天会话中的小程序消息卡片(分享,包含支付宝内和外部渠道) |
|
|
15
|
+
| ch_scan | 1011 | 二维码,含扫一扫,相册识别,长按识别 |
|
|
16
|
+
| ch_messageservice | 1014 | 小程序模版消息(服务提醒) |
|
|
17
|
+
| ch_life | 1020 | 生活号 profile 页相关小程序列表 |
|
|
18
|
+
| ch_desktop | 1023 | 系统桌面图标 |
|
|
19
|
+
| ch_othertinyapp | 1037 | 小程序打开小程序 |
|
|
20
|
+
| ch_backfromtinyapp | 1038 | 从另一个小程序返回 |
|
|
21
|
+
| ch_tinylongpress | 1090 | 长按小程序右上角菜单唤出的最近使用历史 |
|
|
22
|
+
| ch_cityservice | 1200 | 城市服务频道 |
|
|
23
|
+
| ch_zhima | 1201 | 芝麻信用频道 |
|
|
24
|
+
| ch_carservice | 1202 | 车主服务频道 |
|
|
25
|
+
| ch_medicalservice | 1203 | 医疗服务频道 |
|
|
26
|
+
| ch_college | 1204 | 大学生活频道 |
|
|
27
|
+
| ch_school | 1205 | 中小学频道 |
|
|
28
|
+
| ch_sharebike | 1206 | 共享单车频道 |
|
|
29
|
+
| ch_insurance | 1207 | 保险服务频道 |
|
|
30
|
+
| ch_ttyl | 1208 | 天天有料频道 |
|
|
31
|
+
| ch_membership | 1209 | 支付宝会员频道 |
|
|
32
|
+
| ch_outerUrl | 1300 | 第三方 APP(如钉钉)打开,在跳转链接中传入访问来源参数:chInfo=ch_orderCenter |
|
|
33
|
+
|
package/index.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ declare module 'minidev' {
|
|
|
34
34
|
|
|
35
35
|
export function setSilent(boolean): void;
|
|
36
36
|
|
|
37
|
+
export function setSpinnerEnabled(enabled: boolean): void;
|
|
38
|
+
|
|
39
|
+
export function setLogLevelVerboseEnabled(enabled: boolean): void;
|
|
40
|
+
|
|
37
41
|
export type MaybePromise<T = void> = T | Promise<T>;
|
|
38
42
|
|
|
39
43
|
export interface IMinidevPlugin {
|
|
@@ -83,7 +87,10 @@ declare module 'minidev' {
|
|
|
83
87
|
* 需要在运行 dev 之后运行
|
|
84
88
|
* @param opts
|
|
85
89
|
*/
|
|
86
|
-
devPreview(opts: IDevPreviewArgs): Promise<
|
|
90
|
+
devPreview(opts: IDevPreviewArgs, build?: IDevServerCompileBuild): Promise<IGenerateDebugQRCodeResult>;
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
devWebSimulator(opts:IDevWebSimulatorArgs, build?: IDevServerCompileBuild): Promise<IWebSimulatorLauncher>
|
|
87
94
|
|
|
88
95
|
|
|
89
96
|
/**
|
|
@@ -91,7 +98,7 @@ declare module 'minidev' {
|
|
|
91
98
|
* 需要在运行 dev 之后运行
|
|
92
99
|
* @param opts
|
|
93
100
|
*/
|
|
94
|
-
devRemoteDebug(opts: IDevRemoteDebugArgs): Promise<IRemoteDebugReturn>
|
|
101
|
+
devRemoteDebug(opts: IDevRemoteDebugArgs, build?: IDevServerCompileBuild): Promise<IRemoteDebugReturn>
|
|
95
102
|
|
|
96
103
|
|
|
97
104
|
/**
|
|
@@ -99,7 +106,7 @@ declare module 'minidev' {
|
|
|
99
106
|
* 需要在运行 dev 之后运行
|
|
100
107
|
* @param opts
|
|
101
108
|
*/
|
|
102
|
-
startIdeForDevServer(opts: IDevIDEOptions): Promise<void>;
|
|
109
|
+
startIdeForDevServer(opts: IDevIDEOptions, build?: IDevServerCompileBuild): Promise<void>;
|
|
103
110
|
|
|
104
111
|
/**
|
|
105
112
|
* 进行工具授权
|
|
@@ -110,8 +117,9 @@ declare module 'minidev' {
|
|
|
110
117
|
/**
|
|
111
118
|
* 上传发布小程序
|
|
112
119
|
* @param opts
|
|
120
|
+
* @param @optional hooks
|
|
113
121
|
*/
|
|
114
|
-
upload(opts: IUploadOptions): Promise<IPublishResult>;
|
|
122
|
+
upload(opts: IUploadOptions, hooks?: IPublishHooks): Promise<IPublishResult>;
|
|
115
123
|
|
|
116
124
|
|
|
117
125
|
/**
|
|
@@ -162,6 +170,15 @@ declare module 'minidev' {
|
|
|
162
170
|
|
|
163
171
|
}
|
|
164
172
|
|
|
173
|
+
export interface IPublishHooks {
|
|
174
|
+
|
|
175
|
+
onLog?:(data: string) => void;
|
|
176
|
+
|
|
177
|
+
onTaskCreated?: (taskId: string) => void;
|
|
178
|
+
|
|
179
|
+
onVersionCreated?: (version: string) => void;
|
|
180
|
+
}
|
|
181
|
+
|
|
165
182
|
export interface IMinidevConfig {
|
|
166
183
|
|
|
167
184
|
get<T = any>(configName: string, opts?: IConfigOptions): Promise<T>;
|
|
@@ -170,6 +187,22 @@ declare module 'minidev' {
|
|
|
170
187
|
|
|
171
188
|
}
|
|
172
189
|
|
|
190
|
+
export interface IWebSimulatorLauncher {
|
|
191
|
+
|
|
192
|
+
bundled: string;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 这里返回的 simulator 和 devtool 均为不含 uuid 的模板地址
|
|
196
|
+
* 如何使用:
|
|
197
|
+
* const simulatorUrl = separated.simulator.replace('___uuid___', '当前会话的 uuid')
|
|
198
|
+
* const devtoolUrl = separated.devtool.replace('___uuid___', '当前会话的 uuid')
|
|
199
|
+
*/
|
|
200
|
+
separated: {
|
|
201
|
+
simulator: string;
|
|
202
|
+
devtool: string;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
173
206
|
export interface IConfigOptions extends IProjectArgs {
|
|
174
207
|
|
|
175
208
|
scope?: ConfigScope.GLOBAL | ConfigScope.PROJECT;
|
|
@@ -194,6 +227,15 @@ declare module 'minidev' {
|
|
|
194
227
|
|
|
195
228
|
}
|
|
196
229
|
|
|
230
|
+
export interface IDevWebSimulatorArgs extends IOptionalAppIdArgs, IClientTypeOptions, ICompileModeOptions {
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 自动打开模拟器, 默认行为为打开
|
|
234
|
+
*/
|
|
235
|
+
autoOpen?: boolean;
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
197
239
|
export interface IGenerateQrCodeArgs extends IClientTypeOptions, ICompileModeOptions, IAMPEOptions {
|
|
198
240
|
|
|
199
241
|
/**
|
|
@@ -498,7 +540,7 @@ declare module 'minidev' {
|
|
|
498
540
|
once(event: 'hmr-done', listener: () => any): this;
|
|
499
541
|
once(event: 'hmr-error', listener: (error: IDevError) => any): this;
|
|
500
542
|
once(event: 'project-config-change', listener: () => any): this;
|
|
501
|
-
once(event: 'log', listener: () => any): this;
|
|
543
|
+
once(event: 'log', listener: (data: string) => any): this;
|
|
502
544
|
|
|
503
545
|
restart(options?: {appId?: string}): Promise<void>;
|
|
504
546
|
|
|
@@ -523,6 +565,7 @@ declare module 'minidev' {
|
|
|
523
565
|
export interface IDevDone {
|
|
524
566
|
success: boolean;
|
|
525
567
|
}
|
|
568
|
+
|
|
526
569
|
|
|
527
570
|
export interface IDevIDEOptions extends IOptionalAppIdArgs, IIDECommandOptions {
|
|
528
571
|
|
|
@@ -564,7 +607,12 @@ declare module 'minidev' {
|
|
|
564
607
|
}
|
|
565
608
|
|
|
566
609
|
export interface IDevRemoteDebugArgs extends IGenerateQrCodeArgs, IAppIdArgs {
|
|
567
|
-
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* 是否自动打开 devtool,cli 模式默认自动打开, jsApi 调用默认不打开
|
|
613
|
+
*/
|
|
614
|
+
autoOpenDevtool?: boolean;
|
|
615
|
+
|
|
568
616
|
}
|
|
569
617
|
|
|
570
618
|
export interface IPublishResult {
|
|
@@ -592,6 +640,11 @@ declare module 'minidev' {
|
|
|
592
640
|
* 上传成功后,自动设置为体验版本 (需要对应权限)
|
|
593
641
|
*/
|
|
594
642
|
experience?: boolean;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* 上传时删除指定版本号
|
|
646
|
+
*/
|
|
647
|
+
deleteVersion?: string;
|
|
595
648
|
|
|
596
649
|
}
|
|
597
650
|
|
|
@@ -688,7 +741,12 @@ declare module 'minidev' {
|
|
|
688
741
|
/**
|
|
689
742
|
* 小程序应用 id
|
|
690
743
|
*/
|
|
691
|
-
|
|
744
|
+
appId: string;
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* 是否自动打开 devtool,cli 模式默认自动打开, jsApi 调用默认不打开
|
|
748
|
+
*/
|
|
749
|
+
autoOpenDevtool?: boolean;
|
|
692
750
|
|
|
693
751
|
}
|
|
694
752
|
|