@tarojs/plugin-mini-ci 3.5.7-alpha.9 → 3.5.8

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/README.md CHANGED
@@ -1,17 +1,15 @@
1
1
  # @tarojs/plugin-mini-ci
2
2
 
3
- > Taro 小程序端构建后支持CI(持续集成)的插件, 支持构建完毕后自动打开小程序开发这个工具、上传作为体验版、生成预览二维码. 目前支持微信、字节、支付宝、钉钉、百度小程序
3
+ > Taro 小程序端构建后支持CI(持续集成)的插件, 支持构建完毕后自动打开小程序开发这个工具、上传作为体验版、生成预览二维码. 目前暂时仅支持微信、字节、支付宝、百度小程序
4
4
 
5
5
  ## 使用
6
6
 
7
7
  ### 安装
8
-
9
- ```sh
8
+ ```
10
9
  npm i @tarojs/plugin-mini-ci -D
11
10
  ```
12
11
 
13
12
  ### 使用插件
14
-
15
13
  `/config/index.js`
16
14
 
17
15
  ```js
@@ -30,14 +28,10 @@ const CIPluginOpt = {
30
28
  password: "字节小程序密码"
31
29
  },
32
30
  alipay: {
33
- appid: "支付宝小程序appid",
31
+ appId: "支付宝小程序appId",
34
32
  toolId: "工具id",
35
33
  privateKeyPath: "密钥文件相对项目根目录的相对路径,例如 key/pkcs8-private-pem"
36
34
  },
37
- dd: {
38
- appid: "钉钉小程序appid,即钉钉开放平台后台应用管理的 MiniAppId 选项",
39
- token: "令牌,从钉钉后台获取"
40
- },
41
35
  swan: {
42
36
  token: "鉴权需要的token令牌"
43
37
  },
@@ -53,51 +47,7 @@ const config = {
53
47
  }
54
48
  ```
55
49
 
56
- 除了给插件传入对象, 你也可以传入一个异步函数,在编译时动态返回相关配置。
57
-
58
- ```js
59
- const CIPluginFn = async () => {
60
- // 可以在这里做一些异步事情, 比如请求接口获取配置
61
- /**
62
- * @typedef { import("@tarojs/plugin-mini-ci").CIOptions } CIOptions
63
- * @type {CIOptions}
64
- */
65
- return {
66
- weapp: {
67
- appid: "微信小程序appid",
68
- privateKeyPath: "密钥文件相对项目根目录的相对路径,例如 key/private.appid.key"
69
- },
70
- tt: {
71
- email: "字节小程序邮箱",
72
- password: "字节小程序密码"
73
- },
74
- alipay: {
75
- appid: "支付宝小程序appid",
76
- toolId: "工具id",
77
- privateKeyPath: "密钥文件相对项目根目录的相对路径,例如 key/pkcs8-private-pem"
78
- },
79
- dd: {
80
- appid: "钉钉小程序appid,即钉钉开放平台后台应用管理的 MiniAppId 选项"
81
- token: "令牌,从钉钉后台获取"
82
- },
83
- swan: {
84
- token: "鉴权需要的token令牌"
85
- },
86
- // 版本号
87
- version: "1.0.0",
88
- // 版本发布描述
89
- desc: "版本描述"
90
- }
91
- }
92
-
93
- const config = {
94
- plugins: [
95
- [ "@tarojs/plugin-mini-ci", CIPluginFn ]
96
- ]
97
- }
98
- ```
99
-
100
- ### 作为选项配合 build 命令使用
50
+ ### 配置命令
101
51
 
102
52
  `package.json` 的 `scripts` 字段使用命令参数
103
53
 
@@ -106,12 +56,10 @@ const config = {
106
56
  "scripts": {
107
57
  // 构建完后自动 “打开开发者工具”
108
58
  "build:weapp": "taro build --type weapp --open",
109
- // 构建完后自动 “上传代码作为开发版并生成预览二维码”
110
- "build:weapp:preview": "taro build --type weapp --preview",
111
59
  // 构建完后自动“上传代码作为体验版”
112
60
  "build:weapp:upload": "taro build --type weapp --upload",
113
- // 构建完后自动“上传 dist/xxx 目录的代码作为体验版”, `--projectPath` 参数 适用于 taro 和 原生混合的场景
114
- "build:weapp:upload": "taro build --type weapp --upload --projectPath dist/xxx"
61
+ // 构建完后自动 “上传代码作为开发版并生成预览二维码”
62
+ "build:weapp:preview": "taro build --type weapp --preview"
115
63
  },
116
64
  "taroConfig": {
117
65
  "version": "1.0.0",
@@ -119,148 +67,20 @@ const config = {
119
67
  }
120
68
  }
121
69
  ```
122
-
123
- 由上面的示例可知,插件为taro cli命令扩展了4个选项:
70
+ 由上面的示例可知,插件为taro cli命令扩展了3个选项:
124
71
 
125
72
  - --open
126
73
  打开开发者工具,类似于网页开发中自动打开谷歌浏览器
127
- - --preview
128
- 上传代码作为开发版并生成预览二维码
129
74
  - --upload
130
75
  上传代码作为体验版
76
+ - --preview
77
+ 上传代码作为开发版并生成预览二维码
131
78
 
132
- 此3个选项在一条命令里不能同时使用(互斥)
133
-
134
- - --projectPath
135
- 指定要操作(打开、预览、上传)的目录路径, 默认情况下是操作构建后目录路径,即 [outputRoot选项](https://taro-docs.jd.com/taro/docs/next/config-detail#outputroot);
136
-
137
- 此选项必须搭配上述三个选项之一一起使用;
138
-
139
- 此选项优先级为: 终端传入的`--projectPath` > CI配置的`projectPath` 选项 > [outputRoot选项](https://taro-docs.jd.com/taro/docs/next/config-detail#outputroot)。
140
-
141
- ### 作为命令单独使用
142
-
143
- ```json
144
- {
145
- "scripts": {
146
- // 直接 “打开开发者工具并载入项目”
147
- "build:weapp": "taro open --type weapp --projectPath dist/xxx",
148
- // 直接 “上传代码作为开发版并生成预览二维码”
149
- "build:weapp:preview": "taro preview --type weapp",
150
- // 直接“上传代码作为体验版”
151
- "build:weapp:upload": "taro upload --type weapp",
152
- // 上传指定目录代码作为体验版
153
- "build:weapp:upload2": "taro upload --type weapp --projectPath dist/xxx",
154
- },
155
- "taroConfig": {
156
- "version": "1.0.0",
157
- "desc": "上传描述"
158
- }
159
- }
160
- ```
161
-
162
- 由上面的示例可知,插件额外新增了3个独立命令,让你可以直接操作指定目录。适用于把 `taro` 作为项目一部分的使用场景。
163
-
164
- 当直接作为命令使用时,有两个选项:
165
-
166
- - --type
167
- 传入平台名称
168
- - --projectPath
169
- 传入路径。 此选项优先级为: 终端传入的`--projectPath` > CI配置的`projectPath` 选项 > [outputRoot选项](https://taro-docs.jd.com/taro/docs/next/config-detail#outputroot)
170
-
171
- ### Hooks 使用
172
-
173
- 在插件执行完 `预览`、`上传` 操作后, 插件会触发2个钩子事件:
174
-
175
- | 事件名 | 传递参数对象 | 说明 |
176
- | :--- | :--- | :--- |
177
- | onPreviewComplete | 详细见下文 | CI 执行预览后触发 |
178
- | onUploadComplete | 详细见下文| CI 执行上传后触发 |
179
-
180
- 两个钩子被触发时传入的数据对象描述如下
181
-
182
- ```ts
183
- interface HooksData {
184
- /** 是否预览、构建成功 */
185
- success: boolean;
186
- data: {
187
- /** 当前构建的小程序平台 */
188
- platform: string;
189
- /** 预览码本地路径 */
190
- qrCodeLocalPath: string;
191
- /** 预览码内容 */
192
- qrCodeContent: string;
193
- /** 插件传递的预览版本号 */
194
- version: string;
195
- /** 插件传递的描述文本 */
196
- desc: string;
197
- /** 预览或上传的目录路径 */
198
- projectPath: string;
199
- },
200
- /** 错误对象 */
201
- error?: Error;
202
- }
203
- ```
204
-
205
- 你可以写一个自定义插件,来接收上述2个事件传递的值:
206
-
207
- ```js
208
- // config/test.js
209
- module.exports = function(ctx) {
210
- ctx.register({
211
- name: 'onPreviewComplete',
212
- fn: ({success, data, error}) => {
213
- console.log('接收预览后数据', success, data, error)
214
- // 你可以在这里发送钉钉或者飞书消息
215
- }
216
- })
217
- ctx.register({
218
- name: 'onUploadComplete',
219
- fn: ({success, data, error}) => {
220
- console.log('接收上传后数据', success, data, error)
221
- // 你可以在这里发送钉钉或者飞书消息
222
- }
223
- })
224
- }
225
- ```
226
-
227
- 然后把自己写的插件配置应用起来:
228
-
229
- ```js
230
- // config/index.js
231
- const config = {
232
-
233
- plugins: [
234
- ["@tarojs/plugin-mini-ci", CI插件参数],
235
- // 应用自己写的插件
236
- require('path').join(__dirname, './test' )
237
- ],
238
- ... 其他配置省略
239
-
240
- }
241
-
242
- module.exports = function (merge) {
243
- if (process.env.NODE_ENV === 'development') {
244
- return merge({}, config, require('./dev'))
245
- }
246
- return merge({}, config, require('./prod'))
247
- }
248
- ```
249
-
250
- ### 各平台 支持的功能情况对比
251
-
252
- | 平台/功能 | 自动打开IDE | 输出预览二维码 | 输出体验二维码 |
253
- | :--- | :--- | :--- | :--- |
254
- | weapp | ✅ | ✅ |✅ |
255
- | tt | ✅ | ✅ |✅ |
256
- | alipay | ✅ | ✅ |✅ |
257
- | dd | ✅ | ✅ |❌ |
258
- | swan | ✅ | ✅ |✅ |
259
-
260
- > ps: 各平台上传都是支持的,只是不一定会输出二维码
79
+ 此3个选项在一条命令里不能同时使用
261
80
 
262
81
  ## API
263
82
 
83
+
264
84
  ### 插件配置
265
85
 
266
86
  | 参数 | 类型 | 说明 |
@@ -268,22 +88,18 @@ module.exports = function (merge) {
268
88
  | weapp | Object | 微信小程序CI配置 |
269
89
  | tt | Object | 头条小程序配置 |
270
90
  | alipay | Object | 支付宝小程序配置 |
271
- | dd | Object | 钉钉小程序配置(3.6.0 版本开始支持) |
272
91
  | swan | Object | 百度小程序配置 |
273
92
  | version | string | 上传版本号,不传时默认读取package.json下的taroConfig下的version字段 |
274
93
  | desc | string | 上传时的描述信息,不传时默认读取package.json下的taroConfig下的desc字段 |
275
- | projectPath | string | 目标项目目录,对所有小程序生效(不传默认取 outputRoot 字段 )(3.6.0 版本开始支持) |
276
94
 
277
95
  ### 微信小程序CI配置
278
-
279
96
  | 参数 | 类型 | 说明 |
280
97
  | :--- | :--- | :--- |
281
98
  | appid | string | 小程序/小游戏项目的 appid |
282
99
  | privateKeyPath | string | 私钥文件在项目中的相对路径,在获取项目属性和上传时用于鉴权使用|
283
- | devToolsInstallPath | string | 微信开发者工具安装路径,如果你安装微信开发者工具时选的默认路径,则不需要传入此参数(选填) |
284
- | projectPath | string | 上传的小程序的路径(默认取的 outputRoot )(3.6.0 版本已废弃) |
100
+ | devToolsInstallPath | string | 微信开发者工具安装路径,如果你安装微信开发者工具时选的默认路径,则不需要传入此参数 |
101
+ | projectPath | string | 上传的小程序的路径(默认取的 outputPath |
285
102
  | ignores | string[] | 上传需要排除的目录(选填) |
286
- | robot | number | 指定使用哪一个 ci 机器人,可选值:1 ~ 30(选填, 3.6.0 版本开始支持) |
287
103
 
288
104
  官方CI文档[点这里](https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html)
289
105
 
@@ -300,12 +116,10 @@ module.exports = function (merge) {
300
116
 
301
117
  | 参数 | 类型 | 说明 |
302
118
  | :--- | :--- | :--- |
303
- | appid | string | 小程序appid(`3.6.0` 之前参数名是 `appId` , `3.6.0` 开始统一成`appid`) |
304
- | toolId | string | 工具id[查看这里复制](https://open.alipay.com/dev/workspace/key-manage/tool) |
305
- | privateKeyPath | string | 密钥文件相对项目根目录的相对路径, 私钥可通过[支付宝开放平台开发助手](https://opendocs.alipay.com/common/02kipl)生成 |
306
- | privateKey | string | 私钥文本内容, 生成方式同上(privateKeyPath和privateKey之间必须要填写其中一个; 3.6.0 版本开始支持) |
307
- | devToolsInstallPath | string | 小程序开发者工具安装路径(选填, 3.6.0 版本开始支持) |
308
- | clientType | string | 上传的终端,终端类型见下表(选填,默认值alipay) |
119
+ | appId | string | 小程序appId |
120
+ | toolId | string | 工具id,生成方式[查看这里](https://opendocs.alipay.com/mini/miniu/api#%E5%88%9D%E5%A7%8B%E5%8C%96%E9%85%8D%E7%BD%AE%EF%BC%88%E4%B9%8B%E5%89%8D%E7%9A%84%E6%96%B9%E5%BC%8F%EF%BC%8C%E6%8E%A8%E8%8D%90%E4%BD%BF%E7%94%A8%20miniu%20login%EF%BC%89) |
121
+ | privateKeyPath | string | 密钥文件相对项目根目录的相对路径, 支付宝生产的私钥文件名一般是 pkcs8-private-pem |
122
+ | clientType | string | 上传的终端,终端类型见下表(默认值alipay) |
309
123
 
310
124
  ```
311
125
  终端类型值及其含义:
@@ -324,6 +138,8 @@ uc:UC
324
138
 
325
139
  quark:夸克
326
140
 
141
+ taobao:淘宝
142
+
327
143
  koubei:口碑
328
144
 
329
145
  alipayiot:IoT
@@ -331,21 +147,9 @@ alipayiot:IoT
331
147
  cainiao:菜鸟
332
148
 
333
149
  alihealth:阿里健康
334
-
335
- health: 阿里医院
336
150
  ```
337
151
 
338
- 官方CI文档[点这里](https://opendocs.alipay.com/mini/02q29z)
339
-
340
- ### 钉钉小程序CI配置(3.6.0 版本开始支持)
341
-
342
- | 参数 | 类型 | 说明 |
343
- | :--- | :--- | :--- |
344
- | appid | string | 钉钉小程序appid,即钉钉开放平台后台应用管理的 MiniAppId 选项(必填) |
345
- | token | string | 令牌,从钉钉后台获取 (必填) |
346
- | devToolsInstallPath | string | 小程序开发者工具安装路径(选填) |
347
-
348
- `taro` 集成的钉钉CI使用了[钉钉官方仓库](https://github.com/open-dingtalk/dingtalk-design-cli)中的 `dingtalk-miniapp-opensdk` 包,查阅源码封装而成
152
+ 官方CI文档[点这里](https://opendocs.alipay.com/mini/miniu/api)
349
153
 
350
154
  ### 百度小程序CI配置
351
155
 
@@ -356,56 +160,41 @@ health: 阿里医院
356
160
 
357
161
  官方CI文档[点这里](https://smartprogram.baidu.com/docs/develop/devtools/commandtool/)
358
162
 
359
- ### 完整 ts 接口描述
360
-
163
+ ### ts 接口描述
361
164
  ```ts
362
- export interface CIOptions {
363
- /** 发布版本号,默认取 package.json 文件的 taroConfig.version 字段 */
364
- version?: string
365
- /** 版本发布描述, 默认取 package.json 文件的 taroConfig.desc 字段 */
366
- desc?: string
367
- /** 目标项目目录,对所有小程序生效(不传默认取 outputRoot 字段 ) */
368
- projectPath?: string
369
- /** 微信小程序CI配置, 官方文档地址:https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html */
370
- weapp?: WeappConfig
371
- /** 头条小程序配置, 官方文档地址:https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/developer-instrument/development-assistance/ide-order-instrument */
372
- tt?: TTConfig
373
- /** 支付宝系列小程序配置,官方文档地址: https://opendocs.alipay.com/mini/miniu/api */
374
- alipay?: AlipayConfig
375
- /** 钉钉小程序配置 */
376
- dd?: DingtalkConfig
377
- /** 百度小程序配置, 官方文档地址:https://smartprogram.baidu.com/docs/develop/devtools/commandtool/ */
378
- swan?: SwanConfig
165
+ export interface IOptions {
166
+ version?: string;
167
+ desc?: string;
168
+ weapp?: WeappConfig;
169
+ tt?: TTConfig;
170
+ alipay?: AlipayConfig;
171
+ swan?: SwanConfig;
379
172
  }
380
173
 
381
- export type ProjectType = 'miniProgram' | 'miniGame' | 'miniProgramPlugin' | 'miniGamePlugin';
382
-
383
174
  /** 微信小程序配置 */
384
175
  export interface WeappConfig {
385
176
  /** 小程序/小游戏项目的 appid */
386
- appid: string
387
- /** 私钥文件路径,在获取项目属性和上传时用于鉴权使用 */
388
- privateKeyPath: string
177
+ appid: string;
178
+ /** 私钥,在获取项目属性和上传时用于鉴权使用(必填) */
179
+ privateKeyPath: string;
389
180
  /** 微信开发者工具安装路径 */
390
- devToolsInstallPath?: string
181
+ devToolsInstallPath?: string;
182
+ /** 上传的小程序的路径(默认 outputPath ) */
183
+ projectPath?: string;
391
184
  /** 类型,默认miniProgram 小程序 */
392
- type?: ProjectType
185
+ type?: ProjectType;
393
186
  /** 上传需要排除的目录 */
394
- ignores?: Array<string>
395
- /** 指定使用哪一个 ci 机器人,可选值:1 ~ 30 */
396
- robot?: number
187
+ ignores?: Array<string>;
397
188
  }
398
189
 
399
190
  /** 头条小程序配置 */
400
191
  export interface TTConfig {
401
- /** 绑定的邮箱账号 */
402
- email: string
403
- /** 密码 */
404
- password: string
192
+ email: string;
193
+ password: string;
405
194
  }
406
195
 
407
196
  /** 终端类型 */
408
- export type AlipayClientType =
197
+ export type ClientType =
409
198
  /** 支付宝 */'alipay' |
410
199
  /** AMPE */'ampe' |
411
200
  /** 高德 */'amap' |
@@ -413,56 +202,31 @@ export type AlipayClientType =
413
202
  /** ALIOS */ 'alios'|
414
203
  /** UC */'uc'|
415
204
  /** 夸克 */ 'quark'|
205
+ /** 淘宝 */ 'taobao'|
416
206
  /** 口碑 */'koubei' |
417
207
  /** loT */'alipayiot'|
418
208
  /** 菜鸟 */'cainiao' |
419
- /** 阿里健康(医蝶谷) */ 'alihealth'|
420
- /** 阿里医院 */ 'health'
209
+ /** 阿里健康 */ 'alihealth'
421
210
 
422
211
  /** 支付宝系列小程序配置 */
423
212
  export interface AlipayConfig {
424
- /** 小程序appid */
425
- appid: string
213
+ /** 小程序appId */
214
+ appId: string;
426
215
  /** 工具id */
427
- toolId: string
428
- /** 私钥文件路径,在获取项目属性和上传时用于鉴权使用(privateKeyPath和privateKey之间必须要填写其中一个) */
429
- privateKeyPath: string
430
- /** 私钥文本内容,在获取项目属性和上传时用于鉴权使用(privateKeyPath和privateKey之间必须要填写其中一个) */
431
- privateKey: string
432
- /** 小程序开发者工具安装路径 */
433
- devToolsInstallPath?: string
216
+ toolId: string;
217
+ /** 工具私钥 */
218
+ privateKey: string;
219
+ /** 服务代理地址(可选) */
220
+ proxy?: string;
434
221
  /** 上传的终端, 默认alipay */
435
- clientType?: AlipayClientType
436
- }
437
-
438
- export type DingtalkProjectType =
439
- /** 第三方个人应用 */
440
- 'dingtalk-personal'|
441
- /** 第三方企业应用 */
442
- 'dingtalk-biz-isv'|
443
- /** 企业内部应用 */
444
- 'dingtalk-biz'|
445
- /** 企业定制应用 */
446
- 'dingtalk-biz-custom'|
447
- /** 工作台组件 */
448
- 'dingtalk-biz-worktab-plugin'
449
- export interface DingtalkConfig {
450
- /** 钉钉小程序appid,即钉钉开放平台后台应用管理的 MiniAppId 选项(必填) */
451
- appid: string
452
- /** 令牌,从钉钉后台获取 */
453
- token: string
454
- /** 小程序开发者工具安装路径 */
455
- devToolsInstallPath?: string
456
- /** 钉钉应用类型, 默认为:'dingtalk-biz' (企业内部应用) */
457
- projectType?: DingtalkProjectType
222
+ clientType?: ClientType;
458
223
  }
459
224
 
460
225
  /** 百度小程序配置 */
461
226
  export interface SwanConfig {
462
227
  /** 有该小程序发布权限的登录密钥 */
463
- token: string
228
+ token: string;
464
229
  /** 最低基础库版本, 不传默认为 3.350.6 */
465
- minSwanVersion?: string
230
+ minSwanVersion?: string;
466
231
  }
467
-
468
232
  ```